Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

typica.cpp 599KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 622 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. #include <QtNetwork>
  17. /*:5*//*6:*/
  18. #line 639 "./typica.w"
  19. #include "helpmenu.h"
  20. /*:6*//*311:*/
  21. #line 6960 "./typica.w"
  22. #include "units.h"
  23. #line 1 "./measurement.w"
  24. /*:311*//*584:*/
  25. #line 217 "./webview.w"
  26. #include "webview.h"
  27. /*:584*//*597:*/
  28. #line 395 "./webview.w"
  29. #include "webelement.h"
  30. #line 13003 "./typica.w"
  31. #line 1 "./printerselector.w"
  32. /*:597*//*599:*/
  33. #line 40 "./printerselector.w"
  34. #include "printerselector.h"
  35. /*:599*//*730:*/
  36. #line 487 "./daterangeselector.w"
  37. #include "daterangeselector.h"
  38. #line 14891 "./typica.w"
  39. /*:730*//*838:*/
  40. #line 17462 "./typica.w"
  41. #include "qextserialport.h"
  42. #include "qextserialenumerator.h"
  43. /*:838*//*1068:*/
  44. #line 124 "./dataqsdk.w"
  45. #ifdef Q_OS_WIN32
  46. #include <windef.h>
  47. #else
  48. #define PASCAL
  49. #endif
  50. /*:1068*//*1092:*/
  51. #line 862 "./dataqsdk.w"
  52. #include <limits>
  53. /*:1092*//*1107:*/
  54. #line 62 "./scales.w"
  55. #include "draglabel.h"
  56. /*:1107*//*1122:*/
  57. #line 361 "./scales.w"
  58. #include "scale.h"
  59. /*:1122*/
  60. #line 525 "./typica.w"
  61. /*986:*/
  62. #line 114 "./phidget22.w"
  63. #if defined(__stdcall)
  64. #define CCONV __stdcall
  65. #else
  66. #if defined(_MSC_VER)
  67. #define CCONV __stdcall
  68. #else
  69. #define CCONV
  70. #endif
  71. #endif
  72. typedef int(CCONV*PhidgetPointer)(void*);
  73. typedef int(CCONV*PhidgetPointerStringOut)(void*,char**);
  74. typedef int(CCONV*PhidgetPointerIntOut)(void*,int*);
  75. typedef void(CCONV*PhidgetManagerCallback)(void*,void*,void*);
  76. typedef void(CCONV*PhidgetValueCallback)(void*,void*,double);
  77. typedef int(CCONV*PhidgetPointerCallbackPointer)(void*,
  78. PhidgetManagerCallback,
  79. void*);
  80. typedef int(CCONV*PhidgetPointerVCPointer)(void*,
  81. PhidgetValueCallback,
  82. void*);
  83. typedef int(CCONV*PhidgetPointerIntIn)(void*,int);
  84. /*:986*/
  85. #line 526 "./typica.w"
  86. /*991:*/
  87. #line 220 "./phidget22.w"
  88. void CCONV ChannelListAddChannel(void*manager,void*context,void*device);
  89. void CCONV ChannelListRemoveChannel(void*manager,void*context,
  90. void*device);
  91. /*:991*//*1006:*/
  92. #line 773 "./phidget22.w"
  93. void CCONV Phidget22ValueCallback(void*device,void*context,double value);
  94. /*:1006*/
  95. #line 527 "./typica.w"
  96. /*26:*/
  97. #line 1070 "./typica.w"
  98. class ScriptQMainWindow:public QMainWindow
  99. {
  100. Q_OBJECT
  101. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  102. public:
  103. ScriptQMainWindow();
  104. QString closePrompt();
  105. public slots:
  106. void show();
  107. void saveSizeAndPosition(const QString&key);
  108. void restoreSizeAndPosition(const QString&key);
  109. void displayStatus(const QString&message= QString());
  110. void setClosePrompt(QString prompt);
  111. void setupFinished();
  112. signals:
  113. void aboutToClose(void);
  114. void windowReady(void);
  115. protected:
  116. void closeEvent(QCloseEvent*event);
  117. void showEvent(QShowEvent*event);
  118. private:
  119. QString cprompt;
  120. };
  121. /*:26*//*179:*/
  122. #line 4086 "./typica.w"
  123. class SqlQueryConnection:public QSqlQuery
  124. {
  125. public:
  126. SqlQueryConnection(const QString&query= QString());
  127. ~SqlQueryConnection();
  128. QSqlQuery*operator->()const;
  129. private:
  130. QString connection;
  131. QSqlQuery*q;
  132. };
  133. /*:179*//*257:*/
  134. #line 6101 "./typica.w"
  135. class NumericDelegate:public QItemDelegate
  136. {
  137. Q_OBJECT
  138. public:
  139. NumericDelegate(bool positiveOnly= false,QObject*parent= NULL);
  140. QWidget*createEditor(QWidget*parent,
  141. const QStyleOptionViewItem&option,
  142. const QModelIndex&index)const;
  143. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  144. void setModelData(QWidget*editor,QAbstractItemModel*model,
  145. const QModelIndex&index)const;
  146. void updateEditorGeometry(QWidget*editor,
  147. const QStyleOptionViewItem&option,
  148. const QModelIndex&index)const;
  149. private:
  150. bool m_positiveOnly;
  151. };
  152. /*:257*//*263:*/
  153. #line 6210 "./typica.w"
  154. class ScriptValidator:public QValidator
  155. {
  156. Q_OBJECT
  157. public:
  158. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  159. void fixup(QString&input)const;
  160. QValidator::State validate(QString&input,int&pos)const;
  161. private:
  162. QValidator*v;
  163. };
  164. /*:263*//*307:*/
  165. #line 438 "./units.w"
  166. Q_DECLARE_METATYPE(Units::Unit)
  167. /*:307*//*312:*/
  168. #line 19 "./measurement.w"
  169. class Measurement:public QVariantMap
  170. {
  171. public:
  172. Measurement(double temperature= 0,QTime time= QTime(),
  173. Units::Unit sc= Units::Fahrenheit);
  174. Measurement(double temperature);
  175. double temperature()const;
  176. QTime time()const;
  177. void setTemperature(double temperature);
  178. void setTime(QTime time);
  179. void setUnit(Units::Unit scale);
  180. Units::Unit scale()const;
  181. Measurement toFahrenheit();
  182. Measurement toCelsius();
  183. Measurement toKelvin();
  184. Measurement toRankine();
  185. };
  186. /*:312*//*316:*/
  187. #line 128 "./measurement.w"
  188. Q_DECLARE_METATYPE(Measurement)
  189. /*:316*//*323:*/
  190. #line 7024 "./typica.w"
  191. class Channel;
  192. class DAQImplementation;
  193. class DAQ:public QObject
  194. {
  195. Q_OBJECT
  196. Q_ENUMS(ThermocoupleType)
  197. DAQImplementation*imp;
  198. private slots:
  199. void threadFinished();
  200. public:
  201. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  202. ~DAQ();
  203. Channel*newChannel(int units,int thermocouple);
  204. Q_INVOKABLE void setClockRate(double Hz);
  205. Q_INVOKABLE void start();
  206. Q_INVOKABLE void stop();
  207. enum ThermocoupleType
  208. {
  209. TypeJ= 10072,
  210. TypeK= 10073,
  211. TypeN= 10077,
  212. TypeR= 10082,
  213. TypeS= 10085,
  214. TypeT= 10086,
  215. TypeB= 10047,
  216. TypeE= 10055
  217. };
  218. };
  219. /*:323*//*324:*/
  220. #line 7062 "./typica.w"
  221. class DAQImplementation:public QThread
  222. {
  223. Q_OBJECT
  224. public:
  225. DAQImplementation(const QString&driverinfo);
  226. ~DAQImplementation();
  227. void run();
  228. void measure();
  229. /*325:*/
  230. #line 7082 "./typica.w"
  231. typedef int(*daqfp)(...);
  232. daqfp read;
  233. daqfp errorInfo;
  234. daqfp startTask;
  235. daqfp createTask;
  236. daqfp createChannel;
  237. daqfp setClock;
  238. daqfp stopTask;
  239. daqfp clearTask;
  240. daqfp resetDevice;
  241. daqfp waitForMeasurement;
  242. /*:325*/
  243. #line 7071 "./typica.w"
  244. /*326:*/
  245. #line 7098 "./typica.w"
  246. bool useBase;
  247. QString device;
  248. QVector<Channel*> channelMap;
  249. unsigned int handle;
  250. int error;
  251. int channels;
  252. bool ready;
  253. QLibrary driver;
  254. QVector<Units::Unit> unitMap;
  255. /*:326*/
  256. #line 7072 "./typica.w"
  257. };
  258. /*:324*//*342:*/
  259. #line 7603 "./typica.w"
  260. class FakeDAQImplementation:public QThread
  261. {
  262. Q_OBJECT
  263. public:
  264. FakeDAQImplementation();
  265. ~FakeDAQImplementation();
  266. void run();
  267. void measure();
  268. QVector<Channel*> channelMap;
  269. int channels;
  270. bool ready;
  271. double clockRate;
  272. };
  273. class FakeDAQ:public QObject
  274. {
  275. Q_OBJECT
  276. FakeDAQImplementation*imp;
  277. public:
  278. FakeDAQ(QString device);
  279. ~FakeDAQ();
  280. Channel*newChannel(int units,int thermocouple);
  281. Q_INVOKABLE void setClockRate(double Hz);
  282. Q_INVOKABLE void start();
  283. };
  284. /*:342*//*349:*/
  285. #line 7790 "./typica.w"
  286. class Channel:public QObject
  287. {
  288. Q_OBJECT
  289. public:
  290. Channel();
  291. ~Channel();
  292. public slots:
  293. void input(Measurement measurement);
  294. signals:
  295. void newData(Measurement);
  296. };
  297. /*:349*//*353:*/
  298. #line 7857 "./typica.w"
  299. class LinearCalibrator:public QObject
  300. {
  301. Q_OBJECT
  302. Q_PROPERTY(double measuredLower READ measuredLower
  303. WRITE setMeasuredLower)
  304. Q_PROPERTY(double measuredUpper READ measuredUpper
  305. WRITE setMeasuredUpper)
  306. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  307. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  308. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  309. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  310. public:
  311. LinearCalibrator(QObject*parent= NULL);
  312. double measuredLower();
  313. double measuredUpper();
  314. double mappedLower();
  315. double mappedUpper();
  316. bool isClosedRange();
  317. double sensitivity();
  318. public slots:
  319. void setMeasuredLower(double lower);
  320. void setMeasuredUpper(double upper);
  321. void setMappedLower(double lower);
  322. void setMappedUpper(double upper);
  323. void setClosedRange(bool closed);
  324. void setSensitivity(double sensitivity);
  325. Measurement newMeasurement(Measurement measure);
  326. signals:
  327. void measurement(Measurement measure);
  328. void newData(Measurement measure);
  329. private:
  330. double Lo1;
  331. double Lo2;
  332. double Up1;
  333. double Up2;
  334. double sensitivitySetting;
  335. bool clamp;
  336. };
  337. /*:353*//*360:*/
  338. #line 8053 "./typica.w"
  339. class LinearSplineInterpolator:public QObject
  340. {
  341. Q_OBJECT
  342. public:
  343. LinearSplineInterpolator(QObject*parent= NULL);
  344. Q_INVOKABLE void add_pair(double source,double destination);
  345. public slots:
  346. Measurement newMeasurement(Measurement measure);
  347. signals:
  348. void newData(Measurement measure);
  349. private:
  350. void make_interpolators();
  351. QMap<double,double> *pairs;
  352. QList<LinearCalibrator*> *interpolators;
  353. };
  354. /*:360*//*365:*/
  355. #line 8189 "./typica.w"
  356. class TemperatureDisplay:public QLCDNumber
  357. {
  358. Q_OBJECT
  359. int unit;
  360. bool r;
  361. public:
  362. TemperatureDisplay(QWidget*parent= NULL);
  363. ~TemperatureDisplay();
  364. public slots:
  365. void setValue(Measurement temperature);
  366. void invalidate();
  367. void setDisplayUnits(Units::Unit scale);
  368. void setRelativeMode(bool relative);
  369. };
  370. /*:365*//*376:*/
  371. #line 8408 "./typica.w"
  372. class MeasurementTimeOffset:public QObject
  373. {
  374. Q_OBJECT
  375. QTime epoch;
  376. QTime previous;
  377. bool hasPrevious;
  378. public:
  379. MeasurementTimeOffset(QTime zero);
  380. QTime zeroTime();
  381. public slots:
  382. void newMeasurement(Measurement measure);
  383. void setZeroTime(QTime zero);
  384. signals:
  385. void measurement(Measurement measure);
  386. };
  387. /*:376*//*383:*/
  388. #line 8560 "./typica.w"
  389. class ThresholdDetector:public QObject
  390. {
  391. Q_OBJECT
  392. Q_ENUMS(EdgeDirection)
  393. public:
  394. enum EdgeDirection{
  395. Ascending,Descending
  396. };
  397. ThresholdDetector(double value);
  398. public slots:
  399. void newMeasurement(Measurement measure);
  400. void setThreshold(double value);
  401. void setEdgeDirection(EdgeDirection direction);
  402. signals:
  403. void timeForValue(double);
  404. private:
  405. bool previousValueValid;
  406. double previousValue;
  407. double threshold;
  408. EdgeDirection currentDirection;
  409. };
  410. /*:383*//*388:*/
  411. #line 8676 "./typica.w"
  412. class ZeroEmitter:public QObject
  413. {
  414. Q_OBJECT
  415. Q_PROPERTY(int column READ column WRITE setColumn)
  416. Measurement cache;
  417. int col;
  418. public:
  419. ZeroEmitter(int tempcolumn= 1);
  420. int column();
  421. double lastTemperature();
  422. public slots:
  423. void newMeasurement(Measurement measure);
  424. void setColumn(int column);
  425. void emitZero();
  426. signals:
  427. void measurement(Measurement measure,int tempcolumn);
  428. };
  429. /*:388*//*393:*/
  430. #line 8770 "./typica.w"
  431. class MeasurementAdapter:public QObject
  432. {
  433. Q_OBJECT
  434. int col;
  435. public:
  436. MeasurementAdapter(int tempcolumn);
  437. int column();
  438. public slots:
  439. void newMeasurement(Measurement measure);
  440. void setColumn(int column);
  441. signals:
  442. void measurement(Measurement measure,int tempcolumn);
  443. };
  444. /*:393*//*398:*/
  445. #line 8859 "./typica.w"
  446. class GraphView:public QGraphicsView
  447. {
  448. Q_OBJECT
  449. QGraphicsScene*theScene;
  450. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  451. QMap<int,QPointF> *prevPoints;
  452. QMap<int,double> *translations;
  453. QList<QGraphicsItem*> *gridLinesF;
  454. QList<QGraphicsItem*> *gridLinesC;
  455. QList<QGraphicsItem*> *relativeGridLines;
  456. bool relativeEnabled;
  457. bool timeIndicatorEnabled;
  458. QGraphicsLineItem*timeLine;
  459. LinearSplineInterpolator*relativeAdjuster;
  460. public:
  461. GraphView(QWidget*parent= NULL);
  462. void removeSeries(int column);
  463. protected:
  464. void resizeEvent(QResizeEvent*event);
  465. public slots:
  466. void newMeasurement(Measurement measure,int tempcolumn);
  467. void setSeriesTranslation(int column,double offset);
  468. void setTimeIndicatorEnabled(bool enabled);
  469. void clear();
  470. void showF();
  471. void showC();
  472. };
  473. /*:398*//*415:*/
  474. #line 9327 "./typica.w"
  475. class MeasurementModel;
  476. class ZoomLog:public QTableView
  477. {
  478. Q_OBJECT
  479. /*416:*/
  480. #line 9376 "./typica.w"
  481. MeasurementModel*model_ms;
  482. MeasurementModel*model_1s;
  483. MeasurementModel*model_5s;
  484. MeasurementModel*model_10s;
  485. MeasurementModel*model_15s;
  486. MeasurementModel*model_30s;
  487. MeasurementModel*model_1m;
  488. QList<MeasurementModel*> modelSet;
  489. QHash<int,Measurement> lastMeasurement;
  490. MeasurementModel*currentModel;
  491. QList<int> saveTempCols;
  492. QList<int> saveControlCols;
  493. QList<int> saveNoteCols;
  494. QList<int> currentColumnSet;
  495. /*:416*/
  496. #line 9332 "./typica.w"
  497. void switchLOD(MeasurementModel*m);
  498. private slots:
  499. void centerOn(int row);
  500. void persistColumnResize(int column,int oldsize,int newsize);
  501. void restoreColumnWidths();
  502. public:
  503. ZoomLog();
  504. QVariant data(int row,int column)const;
  505. Q_INVOKABLE int rowCount();
  506. bool saveXML(QIODevice*device);
  507. bool saveCSV(QIODevice*device);
  508. QString lastTime(int series);
  509. Q_INVOKABLE Units::Unit displayUnits();
  510. public slots:
  511. void setVisible(bool visibility);
  512. void setHeaderData(int section,QString text);
  513. void LOD_ms();
  514. void LOD_1s();
  515. void LOD_5s();
  516. void LOD_10s();
  517. void LOD_15s();
  518. void LOD_30s();
  519. void LOD_1m();
  520. void newMeasurement(Measurement measure,int tempcolumn);
  521. void newAnnotation(QString annotation,int tempcolumn,
  522. int annotationcolumn);
  523. void clear();
  524. void addOutputTemperatureColumn(int column);
  525. void addOutputControlColumn(int column);
  526. void addOutputAnnotationColumn(int column);
  527. void clearOutputColumns();
  528. void setDisplayUnits(Units::Unit scale);
  529. void addToCurrentColumnSet(int column);
  530. void clearCurrentColumnSet();
  531. protected:
  532. virtual void showEvent(QShowEvent*event);
  533. };
  534. /*:415*//*441:*/
  535. #line 10081 "./typica.w"
  536. class MeasurementList;
  537. class MeasurementModel:public QAbstractItemModel
  538. {
  539. Q_OBJECT
  540. Units::Unit unit;
  541. QList<MeasurementList*> *entries;
  542. QStringList*hData;
  543. int colcount;
  544. QHash<int,int> *lastTemperature;
  545. QList<MeasurementList*> ::iterator lastInsertion;
  546. QHash<int,bool> *controlColumns;
  547. public:
  548. MeasurementModel(QObject*parent= NULL);
  549. ~MeasurementModel();
  550. int rowCount(const QModelIndex&parent= QModelIndex())const;
  551. int columnCount(const QModelIndex&parent= QModelIndex())const;
  552. bool setHeaderData(int section,Qt::Orientation orientation,
  553. const QVariant&value,int role= Qt::DisplayRole);
  554. QVariant data(const QModelIndex&index,int role)const;
  555. bool setData(const QModelIndex&index,const QVariant&value,
  556. int role= Qt::EditRole);
  557. Qt::ItemFlags flags(const QModelIndex&index)const;
  558. QVariant headerData(int section,Qt::Orientation orientation,
  559. int role= Qt::DisplayRole)const;
  560. QModelIndex index(int row,int column,
  561. const QModelIndex&parent= QModelIndex())const;
  562. QModelIndex parent(const QModelIndex&index)const;
  563. Units::Unit displayUnits();
  564. public slots:
  565. void newMeasurement(Measurement measure,int tempcolumn);
  566. void newAnnotation(QString annotation,int tempcolumn,
  567. int annotationColumn);
  568. void clear();
  569. void setDisplayUnits(Units::Unit scale);
  570. signals:
  571. void rowChanged(int);
  572. };
  573. /*:441*//*442:*/
  574. #line 10125 "./typica.w"
  575. class MeasurementList:public QVariantList
  576. {
  577. public:
  578. bool operator<(const MeasurementList&other)const;
  579. bool operator==(const MeasurementList&other)const;
  580. };
  581. /*:442*//*468:*/
  582. #line 10783 "./typica.w"
  583. class AnnotationButton:public QPushButton
  584. {
  585. Q_OBJECT
  586. QString noteTemplate;
  587. QString note;
  588. int tc;
  589. int ac;
  590. int count;
  591. QString batch;
  592. public:
  593. AnnotationButton(const QString&text,QWidget*parent= NULL);
  594. public slots:
  595. void setAnnotation(const QString&annotation);
  596. void setTemperatureColumn(int tempcolumn);
  597. void setAnnotationColumn(int annotationcolumn);
  598. void annotate();
  599. void resetCount();
  600. void resetBatch();
  601. void incrementBatch();
  602. signals:
  603. void annotation(QString annotation,int tempcolumn,
  604. int notecolumn);
  605. };
  606. /*:468*//*478:*/
  607. #line 10963 "./typica.w"
  608. class AnnotationSpinBox:public QDoubleSpinBox
  609. {
  610. Q_OBJECT
  611. QString pretext;
  612. QString posttext;
  613. int tc;
  614. int ac;
  615. bool change;
  616. public:
  617. AnnotationSpinBox(const QString&pret,const QString&postt,
  618. QWidget*parent= NULL);
  619. public slots:
  620. void setPretext(const QString&pret);
  621. void setPosttext(const QString&postt);
  622. void setTemperatureColumn(int tempcolumn);
  623. void setAnnotationColumn(int annotationcolumn);
  624. void annotate();
  625. void resetChange();
  626. signals:
  627. void annotation(QString annotation,int tempcolumn,
  628. int notecolumn);
  629. };
  630. /*:478*//*486:*/
  631. #line 11122 "./typica.w"
  632. class TimerDisplay:public QLCDNumber
  633. {
  634. Q_OBJECT
  635. /*487:*/
  636. #line 11172 "./typica.w"
  637. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  638. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  639. Q_PROPERTY(bool running READ isRunning)
  640. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  641. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  642. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  643. Q_PROPERTY(QString value READ value)
  644. /*:487*/
  645. #line 11126 "./typica.w"
  646. private slots:
  647. void updateTime();
  648. void setCountUpMode();
  649. void setCountDownMode();
  650. void setClockMode();
  651. public:
  652. TimerDisplay(QWidget*parent= NULL);
  653. ~TimerDisplay();
  654. enum TimerMode
  655. {
  656. CountUp,
  657. CountDown,
  658. Clock
  659. };
  660. QString value();
  661. QTime seconds();
  662. TimerMode mode();
  663. bool isRunning();
  664. QTime resetValue();
  665. QString displayFormat();
  666. bool autoReset();
  667. public slots:
  668. void setTimer(QTime value= QTime(0,0,0));
  669. void setMode(TimerMode mode);
  670. void startTimer();
  671. void stopTimer();
  672. void copyTimer();
  673. void setResetValue(QTime value= QTime(0,0,0));
  674. void reset();
  675. void setDisplayFormat(QString format);
  676. void setAutoReset(bool reset);
  677. void updateDisplay();
  678. signals:
  679. void valueChanged(QTime);
  680. void runStateChanged(bool);
  681. private:
  682. /*488:*/
  683. #line 11183 "./typica.w"
  684. QTime s;
  685. QTime r;
  686. QTimer clock;
  687. TimerDisplay::TimerMode m;
  688. bool running;
  689. bool ar;
  690. QAction*startAction;
  691. QAction*stopAction;
  692. QAction*resetAction;
  693. QString f;
  694. QTime relative;
  695. QTime base;
  696. /*:488*/
  697. #line 11163 "./typica.w"
  698. };
  699. /*:486*//*509:*/
  700. #line 11575 "./typica.w"
  701. class PackLayout:public QLayout
  702. {
  703. int doLayout(const QRect&rect,bool testOnly)const;
  704. QList<QLayoutItem*> itemList;
  705. Qt::Orientations orientation;
  706. public:
  707. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  708. PackLayout(int spacing= -1);
  709. ~PackLayout();
  710. void addItem(QLayoutItem*item);
  711. Qt::Orientations expandingDirections()const;
  712. bool hasHeightForWidth()const;
  713. int heightForWidth(int width)const;
  714. int count()const;
  715. QLayoutItem*itemAt(int index)const;
  716. QSize minimumSize()const;
  717. void setGeometry(const QRect&rect);
  718. void setOrientation(Qt::Orientations direction);
  719. QSize sizeHint()const;
  720. QLayoutItem*takeAt(int index);
  721. };
  722. /*:509*//*522:*/
  723. #line 11853 "./typica.w"
  724. class SceneButton:public QGraphicsScene
  725. {
  726. Q_OBJECT
  727. public:
  728. SceneButton();
  729. ~SceneButton();
  730. protected:
  731. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  732. signals:
  733. void clicked(QPoint pos);
  734. };
  735. /*:522*//*524:*/
  736. #line 11895 "./typica.w"
  737. class WidgetDecorator:public QWidget
  738. {
  739. Q_OBJECT
  740. PackLayout*layout;
  741. QGraphicsView*label;
  742. QGraphicsTextItem*text;
  743. SceneButton*scene;
  744. public:
  745. WidgetDecorator(QWidget*widget,const QString&labeltext,
  746. Qt::Orientations orientation= Qt::Horizontal,
  747. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  748. ~WidgetDecorator();
  749. void setBackgroundBrush(QBrush background);
  750. void setTextColor(QColor color);
  751. };
  752. /*:524*//*535:*/
  753. #line 12070 "./typica.w"
  754. class LogEditWindow:public QMainWindow
  755. {
  756. Q_OBJECT
  757. QWidget*centralWidget;
  758. PackLayout*mainLayout;
  759. QHBoxLayout*addRowsLayout;
  760. QLabel*startTimeLabel;
  761. QTimeEdit*startTime;
  762. QLabel*endTimeLabel;
  763. QTimeEdit*endTime;
  764. QLabel*intervalLabel;
  765. QSpinBox*interval;
  766. QPushButton*addRows;
  767. QAction*saveXml;
  768. QAction*saveCsv;
  769. QAction*openXml;
  770. MeasurementModel*model;
  771. QTableView*log;
  772. private slots:
  773. void addTheRows();
  774. void saveXML();
  775. void saveCSV();
  776. void openXML();
  777. protected:
  778. void closeEvent(QCloseEvent*event);
  779. public:
  780. LogEditWindow();
  781. };
  782. /*:535*//*549:*/
  783. #line 12378 "./typica.w"
  784. class XMLOutput:public QObject
  785. {
  786. Q_OBJECT
  787. MeasurementModel*data;
  788. QIODevice*out;
  789. int time;
  790. QMap<int,QString> temperatureColumns;
  791. QMap<int,QString> controlColumns;
  792. QMap<int,QString> annotationColumns;
  793. public:
  794. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  795. void addTemperatureColumn(const QString&series,int column);
  796. void addControlColumn(const QString&series,int column);
  797. void addAnnotationColumn(const QString&series,int column);
  798. void setModel(MeasurementModel*model);
  799. void setTimeColumn(int column);
  800. void setDevice(QIODevice*device);
  801. bool output();
  802. };
  803. /*:549*//*556:*/
  804. #line 12614 "./typica.w"
  805. class XMLInput:public QObject
  806. {
  807. Q_OBJECT
  808. int firstc;
  809. QIODevice*in;
  810. public:
  811. XMLInput(QIODevice*input,int c);
  812. void setFirstColumn(int column);
  813. void setDevice(QIODevice*device);
  814. bool input();
  815. signals:
  816. void measure(Measurement,int);
  817. void annotation(QString,int,int);
  818. void newTemperatureColumn(int,QString);
  819. void newAnnotationColumn(int,QString);
  820. void lastColumn(int);
  821. };
  822. /*:556*//*567:*/
  823. #line 12868 "./typica.w"
  824. class CSVOutput
  825. {
  826. MeasurementModel*data;
  827. QIODevice*out;
  828. int time;
  829. QMap<int,QString> temperatureColumns;
  830. QMap<int,QString> controlColumns;
  831. QMap<int,QString> annotationColumns;
  832. public:
  833. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  834. void addTemperatureColumn(const QString&series,int column);
  835. void addControlColumn(const QString&series,int column);
  836. void addAnnotationColumn(const QString&series,int column);
  837. void setModel(MeasurementModel*model);
  838. void setTimeColumn(int column);
  839. void setDevice(QIODevice*device);
  840. bool output();
  841. };
  842. /*:567*//*607:*/
  843. #line 13013 "./typica.w"
  844. #define AppInstance (qobject_cast<Application *> (qApp))
  845. class NodeInserter;
  846. class DeviceTreeModel;
  847. class DatabaseNotification;
  848. class Application:public QApplication
  849. {
  850. Q_OBJECT
  851. public:
  852. Application(int&argc,char**argv);
  853. QDomDocument*configuration();
  854. /*762:*/
  855. #line 15737 "./typica.w"
  856. QDomDocument deviceConfiguration();
  857. /*:762*//*795:*/
  858. #line 16410 "./typica.w"
  859. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  860. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  861. const QModelIndex&index);
  862. /*:795*//*800:*/
  863. #line 16514 "./typica.w"
  864. QList<NodeInserter*> topLevelNodeInserters;
  865. /*:800*/
  866. #line 13025 "./typica.w"
  867. QSqlDatabase database();
  868. Q_INVOKABLE bool databaseConnected();
  869. Q_INVOKABLE QString currentTypicaUser();
  870. Q_INVOKABLE bool login(const QString&user,const QString&password);
  871. Q_INVOKABLE bool autoLogin();
  872. QScriptEngine*engine;
  873. QNetworkAccessManager*network;
  874. DatabaseNotification*subscribe(const QString&notification);
  875. public slots:
  876. void setDatabaseConnected(bool status);
  877. void setCurrentTypicaUser(const QString&user);
  878. void notify(const QString&notification);
  879. /*763:*/
  880. #line 15744 "./typica.w"
  881. void saveDeviceConfiguration();
  882. /*:763*/
  883. #line 13038 "./typica.w"
  884. signals:
  885. void userChanged(const QString&user);
  886. private:
  887. /*761:*/
  888. #line 15728 "./typica.w"
  889. QDomDocument deviceConfigurationDocument;
  890. /*:761*//*794:*/
  891. #line 16404 "./typica.w"
  892. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  893. /*:794*/
  894. #line 13042 "./typica.w"
  895. QDomDocument conf;
  896. bool connectionStatus;
  897. QString currentUser;
  898. QMap<QString,DatabaseNotification*> notifiers;
  899. QSqlDriver*notificationDriver;
  900. };
  901. /*:607*//*619:*/
  902. #line 13214 "./typica.w"
  903. class DatabaseNotification:public QObject
  904. {
  905. Q_OBJECT
  906. public:
  907. DatabaseNotification();
  908. public slots:
  909. void forwardNotification(const QString&notification);
  910. signals:
  911. void notify(const QString&notification);
  912. };
  913. /*:619*//*620:*/
  914. #line 13228 "./typica.w"
  915. DatabaseNotification::DatabaseNotification():QObject(NULL)
  916. {
  917. }
  918. void DatabaseNotification::forwardNotification(const QString&notification)
  919. {
  920. emit notify(notification);
  921. }
  922. /*:620*//*622:*/
  923. #line 13288 "./typica.w"
  924. class SaltModel:public QAbstractItemModel
  925. {
  926. Q_OBJECT
  927. QList<QList<QMap<int,QVariant> > > modelData;
  928. QStringList hData;
  929. int colcount;
  930. public:
  931. SaltModel(int columns);
  932. ~SaltModel();
  933. int rowCount(const QModelIndex&parent= QModelIndex())const;
  934. int columnCount(const QModelIndex&parent= QModelIndex())const;
  935. bool setHeaderData(int section,Qt::Orientation orientation,
  936. const QVariant&value,int role= Qt::DisplayRole);
  937. QVariant data(const QModelIndex&index,int role)const;
  938. bool setData(const QModelIndex&index,const QVariant&value,
  939. int role= Qt::EditRole);
  940. Qt::ItemFlags flags(const QModelIndex&index)const;
  941. QVariant headerData(int section,Qt::Orientation orientation,
  942. int role= Qt::DisplayRole)const;
  943. QModelIndex index(int row,int column,
  944. const QModelIndex&parent= QModelIndex())const;
  945. QModelIndex parent(const QModelIndex&index)const;
  946. QString arrayLiteral(int column,int role)const;
  947. QString quotedArrayLiteral(int column,int role)const;
  948. void clear();
  949. bool removeRows(int row,int count,
  950. const QModelIndex&parent= QModelIndex());
  951. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  952. };
  953. /*:622*//*638:*/
  954. #line 13673 "./typica.w"
  955. class SqlComboBox:public QComboBox
  956. {
  957. Q_OBJECT
  958. int dataColumn;
  959. int displayColumn;
  960. bool dataColumnShown;
  961. QString specialNullText;
  962. QVariant specialNullData;
  963. public:
  964. SqlComboBox();
  965. ~SqlComboBox();
  966. SqlComboBox*clone(QWidget*parent);
  967. public slots:
  968. void addNullOption();
  969. void addSqlOptions(QString query);
  970. void setDataColumn(int column);
  971. void setDisplayColumn(int column);
  972. void showData(bool show);
  973. void setNullText(QString nullText);
  974. void setNullData(QVariant nullData);
  975. };
  976. /*:638*//*645:*/
  977. #line 13820 "./typica.w"
  978. class SqlComboBoxDelegate:public QItemDelegate
  979. {
  980. Q_OBJECT
  981. SqlComboBox*delegate;
  982. public:
  983. SqlComboBoxDelegate(QObject*parent= NULL);
  984. QWidget*createEditor(QWidget*parent,
  985. const QStyleOptionViewItem&option,
  986. const QModelIndex&index)const;
  987. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  988. void setModelData(QWidget*editor,QAbstractItemModel*model,
  989. const QModelIndex&index)const;
  990. void setWidget(SqlComboBox*widget);
  991. virtual QSize sizeHint()const;
  992. void updateEditorGeometry(QWidget*editor,
  993. const QStyleOptionViewItem&option,
  994. const QModelIndex&index)const;
  995. };
  996. /*:645*//*660:*/
  997. #line 14031 "./typica.w"
  998. class SqlConnectionSetup:public QDialog
  999. {
  1000. Q_OBJECT
  1001. public:
  1002. SqlConnectionSetup();
  1003. ~SqlConnectionSetup();
  1004. public slots:
  1005. void testConnection();
  1006. private:
  1007. QFormLayout*formLayout;
  1008. QComboBox*driver;
  1009. QLineEdit*hostname;
  1010. QLineEdit*portnumber;
  1011. QLineEdit*dbname;
  1012. QLineEdit*user;
  1013. QLineEdit*password;
  1014. QVBoxLayout*layout;
  1015. QHBoxLayout*buttons;
  1016. QPushButton*cancelButton;
  1017. QPushButton*connectButton;
  1018. };
  1019. /*:660*//*665:*/
  1020. #line 14179 "./typica.w"
  1021. class SqlQueryView:public QTableView
  1022. {
  1023. Q_OBJECT
  1024. public:
  1025. SqlQueryView(QWidget*parent= NULL);
  1026. void setQuery(const QString&query);
  1027. bool setHeaderData(int section,Qt::Orientation orientation,
  1028. const QVariant&value,int role);
  1029. Q_INVOKABLE QVariant data(int row,int column,
  1030. int role= Qt::DisplayRole);
  1031. signals:
  1032. void openEntry(QString key);
  1033. void openEntryRow(int row);
  1034. void selectEntry(QString key);
  1035. void selectEntryRow(int row);
  1036. protected:
  1037. virtual void showEvent(QShowEvent*event);
  1038. private slots:
  1039. void openRow(const QModelIndex&index);
  1040. void persistColumnResize(int column,int oldsize,int newsize);
  1041. void selectRow(const QModelIndex&index);
  1042. };
  1043. /*:665*//*680:*/
  1044. #line 14454 "./typica.w"
  1045. class ReportAction:public QAction
  1046. {
  1047. Q_OBJECT
  1048. public:
  1049. ReportAction(const QString&fileName,const QString&reportName,
  1050. QObject*parent= NULL);
  1051. private slots:
  1052. void createReport();
  1053. private:
  1054. QString reportFile;
  1055. };
  1056. /*:680*//*692:*/
  1057. #line 14665 "./typica.w"
  1058. class ReportTable:public QObject
  1059. {
  1060. Q_OBJECT
  1061. QTextFrame*area;
  1062. QDomElement configuration;
  1063. QMap<QString,QVariant> bindings;
  1064. public:
  1065. ReportTable(QTextFrame*frame,QDomElement description);
  1066. ~ReportTable();
  1067. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  1068. public slots:
  1069. void refresh();
  1070. };
  1071. /*:692*//*705:*/
  1072. #line 63 "./plugins.w"
  1073. class PluginAction:public QAction
  1074. {
  1075. Q_OBJECT
  1076. Q_PROPERTY(QString preRun READ preRun WRITE setPreRun);
  1077. Q_PROPERTY(QString postRun READ postRun WRITE setPostRun);
  1078. public:
  1079. PluginAction(const QFileInfo&info,QObject*parent);
  1080. QString preRun();
  1081. QString postRun();
  1082. public slots:
  1083. void setPreRun(const QString&script);
  1084. void setPostRun(const QString&script);
  1085. private slots:
  1086. void runScript();
  1087. private:
  1088. QString pluginFile;
  1089. QString preRunScript;
  1090. QString postRunScript;
  1091. };
  1092. /*:705*//*708:*/
  1093. #line 155 "./plugins.w"
  1094. Q_DECLARE_METATYPE(QScriptValue)
  1095. /*:708*//*731:*/
  1096. #line 14906 "./typica.w"
  1097. class FormArray:public QScrollArea
  1098. {
  1099. Q_OBJECT
  1100. QDomElement configuration;
  1101. QWidget itemContainer;
  1102. QVBoxLayout itemLayout;
  1103. int maxwidth;
  1104. int maxheight;
  1105. public:
  1106. FormArray(QDomElement description);
  1107. Q_INVOKABLE QWidget*elementAt(int index);
  1108. Q_INVOKABLE int elements();
  1109. public slots:
  1110. void addElements(int copies= 1);
  1111. void removeAllElements();
  1112. void setMaximumElementWidth(int width);
  1113. void setMaximumElementHeight(int height);
  1114. };
  1115. /*:731*//*741:*/
  1116. #line 15122 "./typica.w"
  1117. class ScaleControl:public QGraphicsView
  1118. {
  1119. Q_OBJECT
  1120. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1121. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1122. /*742:*/
  1123. #line 15148 "./typica.w"
  1124. QGraphicsScene scene;
  1125. QGraphicsPolygonItem initialDecrement;
  1126. QGraphicsPolygonItem initialIncrement;
  1127. QGraphicsPolygonItem finalDecrement;
  1128. QGraphicsPolygonItem finalIncrement;
  1129. QGraphicsPolygonItem initialIndicator;
  1130. QGraphicsPolygonItem finalIndicator;
  1131. QGraphicsPathItem scaleLine;
  1132. QPolygonF left;
  1133. QPolygonF right;
  1134. QPolygonF down;
  1135. QPolygonF up;
  1136. QPainterPath scalePath;
  1137. QBrush initialBrush;
  1138. QBrush finalBrush;
  1139. double nonScoredValue;
  1140. double scoredValue;
  1141. bool initialSet;
  1142. bool finalSet;
  1143. bool scaleDown;
  1144. /*:742*/
  1145. #line 15128 "./typica.w"
  1146. public:
  1147. ScaleControl();
  1148. double initialValue(void);
  1149. double finalValue(void);
  1150. virtual QSize sizeHint()const;
  1151. public slots:
  1152. void setInitialValue(double value);
  1153. void setFinalValue(double value);
  1154. signals:
  1155. void initialChanged(double);
  1156. void finalChanged(double);
  1157. protected:
  1158. virtual void mousePressEvent(QMouseEvent*event);
  1159. virtual void mouseReleaseEvent(QMouseEvent*event);
  1160. };
  1161. /*:741*//*753:*/
  1162. #line 15445 "./typica.w"
  1163. class IntensityControl:public QGraphicsView
  1164. {
  1165. Q_OBJECT
  1166. Q_PROPERTY(double value READ value WRITE setValue)
  1167. QGraphicsScene scene;
  1168. QGraphicsPolygonItem decrement;
  1169. QGraphicsPolygonItem increment;
  1170. QGraphicsPolygonItem indicator;
  1171. QGraphicsPathItem scaleLine;
  1172. QPolygonF left;
  1173. QPolygonF up;
  1174. QPolygonF down;
  1175. QPainterPath scalePath;
  1176. QBrush theBrush;
  1177. double theValue;
  1178. bool valueSet;
  1179. bool scaleDown;
  1180. public:
  1181. IntensityControl();
  1182. double value();
  1183. virtual QSize sizeHint()const;
  1184. public slots:
  1185. void setValue(double val);
  1186. signals:
  1187. void valueChanged(double);
  1188. protected:
  1189. virtual void mousePressEvent(QMouseEvent*event);
  1190. virtual void mouseReleaseEvent(QMouseEvent*event);
  1191. };
  1192. /*:753*//*769:*/
  1193. #line 15833 "./typica.w"
  1194. class DeviceTreeModelNode
  1195. {
  1196. public:
  1197. DeviceTreeModelNode(QDomNode&node,int row,
  1198. DeviceTreeModelNode*parent= NULL);
  1199. ~DeviceTreeModelNode();
  1200. DeviceTreeModelNode*child(int index);
  1201. DeviceTreeModelNode*parent();
  1202. QDomNode node()const;
  1203. int row();
  1204. private:
  1205. QDomNode domNode;
  1206. QHash<int,DeviceTreeModelNode*> children;
  1207. int rowNumber;
  1208. DeviceTreeModelNode*parentItem;
  1209. };
  1210. /*:769*//*771:*/
  1211. #line 15908 "./typica.w"
  1212. class DeviceTreeModel:public QAbstractItemModel
  1213. {
  1214. Q_OBJECT
  1215. public:
  1216. DeviceTreeModel(QObject*parent= NULL);
  1217. ~DeviceTreeModel();
  1218. QVariant data(const QModelIndex&index,int role)const;
  1219. Qt::ItemFlags flags(const QModelIndex&index)const;
  1220. QVariant headerData(int section,Qt::Orientation orientation,
  1221. int role= Qt::DisplayRole)const;
  1222. QModelIndex index(int row,int column,
  1223. const QModelIndex&parent= QModelIndex())const;
  1224. QModelIndex parent(const QModelIndex&child)const;
  1225. Q_INVOKABLE int rowCount(const QModelIndex&parent= QModelIndex())const;
  1226. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1227. bool setData(const QModelIndex&index,const QVariant&value,
  1228. int role);
  1229. bool removeRows(int row,int count,const QModelIndex&parent);
  1230. QDomElement referenceElement(const QString&id);
  1231. public slots:
  1232. void newNode(const QString&name,const QString&driver,
  1233. const QModelIndex&parent);
  1234. private:
  1235. QDomDocument document;
  1236. DeviceTreeModelNode*root;
  1237. QDomNode referenceSection;
  1238. QDomNode treeRoot;
  1239. };
  1240. /*:771*//*790:*/
  1241. #line 16362 "./typica.w"
  1242. Q_DECLARE_METATYPE(QModelIndex)
  1243. /*:790*//*798:*/
  1244. #line 16469 "./typica.w"
  1245. class NodeInserter:public QAction
  1246. {
  1247. Q_OBJECT
  1248. public:
  1249. NodeInserter(const QString&title,const QString&name,
  1250. const QString&driver,QObject*parent= NULL);
  1251. signals:
  1252. void triggered(QString name,QString driver);
  1253. private slots:
  1254. void onTriggered();
  1255. private:
  1256. QString defaultNodeName;
  1257. QString driverString;
  1258. };
  1259. /*:798*//*801:*/
  1260. #line 16524 "./typica.w"
  1261. class DeviceConfigurationWindow:public QWidget
  1262. {
  1263. Q_OBJECT
  1264. public:
  1265. DeviceConfigurationWindow();
  1266. public slots:
  1267. void addDevice();
  1268. void removeNode();
  1269. void newSelection(const QModelIndex&index);
  1270. private slots:
  1271. void resizeColumn();
  1272. private:
  1273. QDomDocument document;
  1274. DeviceTreeModel*model;
  1275. QTreeView*view;
  1276. QScrollArea*configArea;
  1277. };
  1278. /*:801*//*810:*/
  1279. #line 16694 "./typica.w"
  1280. class BasicDeviceConfigurationWidget:public QWidget
  1281. {
  1282. Q_OBJECT
  1283. public:
  1284. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1285. const QModelIndex&index);
  1286. public slots:
  1287. void insertChildNode(const QString&name,const QString&driver);
  1288. void updateAttribute(const QString&name,const QString&value);
  1289. protected:
  1290. DeviceTreeModel*deviceModel;
  1291. QModelIndex currentNode;
  1292. };
  1293. /*:810*//*814:*/
  1294. #line 16779 "./typica.w"
  1295. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1296. {
  1297. Q_OBJECT
  1298. public:
  1299. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1300. const QModelIndex&index);
  1301. private slots:
  1302. void updateRoasterId(int id);
  1303. void updateCapacityCheck(int value);
  1304. void updateCapacity(const QString&value);
  1305. void updateCapacityUnit(const QString&value);
  1306. };
  1307. /*:814*//*819:*/
  1308. #line 16984 "./typica.w"
  1309. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1310. {
  1311. Q_OBJECT
  1312. public:
  1313. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1314. const QModelIndex&index);
  1315. };
  1316. /*:819*//*821:*/
  1317. #line 17030 "./typica.w"
  1318. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1319. {
  1320. Q_OBJECT
  1321. public:
  1322. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1323. const QModelIndex&index);
  1324. private slots:
  1325. void addChannel();
  1326. void updateDeviceId(const QString&newId);
  1327. };
  1328. /*:821*//*825:*/
  1329. #line 17116 "./typica.w"
  1330. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1331. {
  1332. Q_OBJECT
  1333. public:
  1334. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1335. const QModelIndex&index);
  1336. private slots:
  1337. void updateThermocoupleType(const QString&type);
  1338. void updateColumnName(const QString&name);
  1339. void updateHidden(bool hidden);
  1340. };
  1341. /*:825*//*830:*/
  1342. #line 17232 "./typica.w"
  1343. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1344. {
  1345. Q_OBJECT
  1346. public:
  1347. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1348. const QModelIndex&index);
  1349. };
  1350. /*:830*//*832:*/
  1351. #line 17273 "./typica.w"
  1352. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1353. {
  1354. Q_OBJECT
  1355. public:
  1356. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1357. const QModelIndex&index);
  1358. private slots:
  1359. void addChannel();
  1360. void updateDeviceId(const QString&newId);
  1361. };
  1362. /*:832*//*834:*/
  1363. #line 17342 "./typica.w"
  1364. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1365. {
  1366. Q_OBJECT
  1367. public:
  1368. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1369. const QModelIndex&index);
  1370. private slots:
  1371. void updateDeviceId(const QString&newId);
  1372. void updateThermocoupleType(const QString&type);
  1373. void updateColumnName(const QString&name);
  1374. void updateHidden(bool hidden);
  1375. };
  1376. /*:834*//*839:*/
  1377. #line 17473 "./typica.w"
  1378. class PortSelector:public QComboBox
  1379. {
  1380. Q_OBJECT
  1381. public:
  1382. PortSelector(QWidget*parent= NULL);
  1383. private slots:
  1384. void addDevice(QextPortInfo port);
  1385. private:
  1386. QextSerialEnumerator*lister;
  1387. };
  1388. /*:839*//*841:*/
  1389. #line 17521 "./typica.w"
  1390. class BaudSelector:public QComboBox
  1391. {
  1392. Q_OBJECT
  1393. Q_ENUMS(BaudRateType)
  1394. public:
  1395. BaudSelector(QWidget*parent= NULL);
  1396. enum BaudRateType
  1397. {
  1398. #if defined(Q_OS_UNIX) || defined(qdoc)
  1399. BAUD50= 50,
  1400. BAUD75= 75,
  1401. BAUD134= 134,
  1402. BAUD150= 150,
  1403. BAUD200= 200,
  1404. BAUD1800= 1800,
  1405. #if defined(B76800) || defined(qdoc)
  1406. BAUD76800= 76800,
  1407. #endif
  1408. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1409. BAUD230400= 230400,
  1410. BAUD460800= 460800,
  1411. BAUD500000= 500000,
  1412. BAUD576000= 576000,
  1413. BAUD921600= 921600,
  1414. BAUD1000000= 1000000,
  1415. BAUD1152000= 1152000,
  1416. BAUD1500000= 1500000,
  1417. BAUD2000000= 2000000,
  1418. BAUD2500000= 2500000,
  1419. BAUD3000000= 3000000,
  1420. BAUD3500000= 3500000,
  1421. BAUD4000000= 4000000,
  1422. #endif
  1423. #endif
  1424. #if defined(Q_OS_WIN) || defined(qdoc)
  1425. BAUD14400= 14400,
  1426. BAUD56000= 56000,
  1427. BAUD128000= 128000,
  1428. BAUD256000= 256000,
  1429. #endif
  1430. BAUD110= 110,
  1431. BAUD300= 300,
  1432. BAUD600= 600,
  1433. BAUD1200= 1200,
  1434. BAUD2400= 2400,
  1435. BAUD4800= 4800,
  1436. BAUD9600= 9600,
  1437. BAUD19200= 19200,
  1438. BAUD38400= 38400,
  1439. BAUD57600= 57600,
  1440. BAUD115200= 115200
  1441. };
  1442. };
  1443. /*:841*//*843:*/
  1444. #line 17592 "./typica.w"
  1445. class ParitySelector:public QComboBox
  1446. {
  1447. Q_OBJECT
  1448. Q_ENUMS(ParityType)
  1449. public:
  1450. ParitySelector(QWidget*parent= NULL);
  1451. enum ParityType
  1452. {
  1453. PAR_NONE,
  1454. PAR_ODD,
  1455. PAR_EVEN,
  1456. #if defined(Q_OS_WIN) || defined(qdoc)
  1457. PAR_MARK,
  1458. #endif
  1459. PAR_SPACE
  1460. };
  1461. };
  1462. /*:843*//*845:*/
  1463. #line 17630 "./typica.w"
  1464. class FlowSelector:public QComboBox
  1465. {
  1466. Q_OBJECT
  1467. Q_ENUMS(FlowType)
  1468. public:
  1469. FlowSelector(QWidget*parent= NULL);
  1470. enum FlowType
  1471. {
  1472. FLOW_OFF,
  1473. FLOW_HARDWARE,
  1474. FLOW_XONXOFF
  1475. };
  1476. };
  1477. /*:845*//*847:*/
  1478. #line 17663 "./typica.w"
  1479. class StopSelector:public QComboBox
  1480. {
  1481. Q_OBJECT
  1482. Q_ENUMS(StopBitsType)
  1483. public:
  1484. StopSelector(QWidget*parent= NULL);
  1485. enum StopBitsType
  1486. {
  1487. STOP_1,
  1488. #if defined(Q_OS_WIN) || defined(qdoc)
  1489. STOP_1_5,
  1490. #endif
  1491. STOP_2
  1492. };
  1493. };
  1494. /*:847*//*850:*/
  1495. #line 17720 "./typica.w"
  1496. class ShortHexSpinBox:public QSpinBox
  1497. {
  1498. Q_OBJECT
  1499. public:
  1500. ShortHexSpinBox(QWidget*parent= NULL);
  1501. virtual QValidator::State validate(QString&input,int&pos)const;
  1502. protected:
  1503. virtual int valueFromText(const QString&text)const;
  1504. virtual QString textFromValue(int value)const;
  1505. };
  1506. /*:850*//*852:*/
  1507. #line 17782 "./typica.w"
  1508. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1509. {
  1510. Q_OBJECT
  1511. public:
  1512. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1513. const QModelIndex&index);
  1514. private slots:
  1515. void updatePort(const QString&newPort);
  1516. void updateBaudRate(const QString&newRate);
  1517. void updateParity(const QString&newParity);
  1518. void updateFlowControl(const QString&newFlow);
  1519. void updateStopBits(const QString&newStopBits);
  1520. };
  1521. /*:852*//*854:*/
  1522. #line 17933 "./typica.w"
  1523. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1524. {
  1525. Q_OBJECT
  1526. public:
  1527. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1528. const QModelIndex&index);
  1529. private slots:
  1530. void updateStationNumber(int newStation);
  1531. void updateFixedUnit(bool newFixed);
  1532. void updateFixedDecimal(bool newFixed);
  1533. void updateUnit(const QString&newUnit);
  1534. void updateUnitAddress(int newAddress);
  1535. void updateValueF(int newValue);
  1536. void updateValueC(int newValue);
  1537. void updatePrecisionAddress(int newAddress);
  1538. void updatePrecisionValue(int newValue);
  1539. private:
  1540. QStackedLayout*unitSpecificationLayout;
  1541. QStackedLayout*decimalSpecificationLayout;
  1542. };
  1543. /*:854*//*856:*/
  1544. #line 18192 "./typica.w"
  1545. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1546. {
  1547. Q_OBJECT
  1548. public:
  1549. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1550. const QModelIndex&index);
  1551. private slots:
  1552. void updateAddress(int newAddress);
  1553. };
  1554. /*:856*//*858:*/
  1555. #line 18238 "./typica.w"
  1556. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1557. {
  1558. Q_OBJECT
  1559. public:
  1560. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1561. const QModelIndex&index);
  1562. private slots:
  1563. void updateReadAddress(int newAddress);
  1564. void updateWriteAddress(int newAddress);
  1565. void updateFixedRange(bool fixed);
  1566. void updateLower(const QString&lower);
  1567. void updateUpper(const QString&upper);
  1568. void updateLowerAddress(int newAddress);
  1569. void updateUpperAddress(int newAddress);
  1570. private:
  1571. QStackedLayout*boundsLayout;
  1572. };
  1573. /*:858*//*862:*/
  1574. #line 18432 "./typica.w"
  1575. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1576. {
  1577. Q_OBJECT
  1578. public:
  1579. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1580. private slots:
  1581. void updateButtonText(const QString&text);
  1582. void updateAnnotationText(const QString&text);
  1583. };
  1584. /*:862*//*866:*/
  1585. #line 18500 "./typica.w"
  1586. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1587. {
  1588. Q_OBJECT
  1589. public:
  1590. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1591. private slots:
  1592. void updateButtonText(const QString&text);
  1593. void updateAnnotationText(const QString&text);
  1594. };
  1595. /*:866*//*869:*/
  1596. #line 18575 "./typica.w"
  1597. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1598. {
  1599. Q_OBJECT
  1600. public:
  1601. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1602. private slots:
  1603. void updateLabel(const QString&text);
  1604. void updateMinimum(const QString&minimum);
  1605. void updateMaximum(const QString&maximum);
  1606. void updatePrecision(int precision);
  1607. void updatePretext(const QString&text);
  1608. void updatePosttext(const QString&text);
  1609. };
  1610. /*:869*//*872:*/
  1611. #line 12 "./freeannotation.w"
  1612. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1613. {
  1614. Q_OBJECT
  1615. public:
  1616. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1617. private slots:
  1618. void updateLabel(const QString&text);
  1619. };
  1620. /*:872*//*876:*/
  1621. #line 11 "./settings.w"
  1622. class SettingsWindow:public QMainWindow
  1623. {
  1624. Q_OBJECT
  1625. public:
  1626. SettingsWindow();
  1627. };
  1628. /*:876*//*881:*/
  1629. #line 8 "./graphsettings.w"
  1630. class GraphSettingsWidget:public QWidget
  1631. {
  1632. Q_OBJECT
  1633. public:
  1634. GraphSettingsWidget();
  1635. };
  1636. /*:881*//*883:*/
  1637. #line 46 "./graphsettings.w"
  1638. class GraphSettingsRelativeTab:public QWidget
  1639. {
  1640. Q_OBJECT
  1641. public:
  1642. GraphSettingsRelativeTab();
  1643. public slots:
  1644. void updateEnableSetting(bool enable);
  1645. void updateColorSetting(const QString&color);
  1646. void updateAxisSetting(const QString&gridList);
  1647. void updateUnit(int unit);
  1648. void showColorPicker();
  1649. private:
  1650. QLineEdit*colorEdit;
  1651. };
  1652. /*:883*//*887:*/
  1653. #line 15 "./colorsettings.w"
  1654. class ColorSettingsWidget:public QWidget
  1655. {
  1656. Q_OBJECT
  1657. public:
  1658. ColorSettingsWidget();
  1659. public slots:
  1660. void updateEnable(bool enable);
  1661. void updateAddress(const QString&address);
  1662. void updateScale(int sccale);
  1663. };
  1664. /*:887*//*891:*/
  1665. #line 7 "./advancedsettings.w"
  1666. class AdvancedSettingsWidget:public QWidget
  1667. {
  1668. Q_OBJECT
  1669. public:
  1670. AdvancedSettingsWidget();
  1671. public slots:
  1672. void enableDiagnosticLogging(bool enabled);
  1673. };
  1674. /*:891*//*895:*/
  1675. #line 18700 "./typica.w"
  1676. class ModbusRTUDevice:public QObject
  1677. {
  1678. Q_OBJECT
  1679. public:
  1680. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1681. ~ModbusRTUDevice();
  1682. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1683. Q_INVOKABLE double SVLower();
  1684. Q_INVOKABLE double SVUpper();
  1685. Q_INVOKABLE int decimals();
  1686. QList<Channel*> channels;
  1687. public slots:
  1688. void outputSV(double sv);
  1689. signals:
  1690. void SVLowerChanged(double);
  1691. void SVUpperChanged(double);
  1692. void SVDecimalChanged(int);
  1693. void queueEmpty();
  1694. private slots:
  1695. void dataAvailable();
  1696. void sendNextMessage();
  1697. void decimalResponse(QByteArray response);
  1698. void unitResponse(QByteArray response);
  1699. void svlResponse(QByteArray response);
  1700. void svuResponse(QByteArray response);
  1701. void requestMeasurement();
  1702. void mResponse(QByteArray response);
  1703. void ignore(QByteArray response);
  1704. void timeout();
  1705. private:
  1706. QextSerialPort*port;
  1707. QByteArray responseBuffer;
  1708. QList<QByteArray> messageQueue;
  1709. QList<QObject*> retObjQueue;
  1710. QList<char*> callbackQueue;
  1711. quint16 calculateCRC(QByteArray data);
  1712. QTimer*messageDelayTimer;
  1713. QTimer*commTimeout;
  1714. int delayTime;
  1715. char station;
  1716. int decimalPosition;
  1717. int valueF;
  1718. int valueC;
  1719. bool unitIsF;
  1720. double outputSVLower;
  1721. double outputSVUpper;
  1722. QByteArray outputSVStub;
  1723. QByteArray pvStub;
  1724. QByteArray svStub;
  1725. QByteArray mStub;
  1726. quint16 pvaddress;
  1727. quint16 svaddress;
  1728. bool svenabled;
  1729. bool readingsv;
  1730. double savedpv;
  1731. bool waiting;
  1732. };
  1733. /*:895*//*911:*/
  1734. #line 19398 "./typica.w"
  1735. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1736. {
  1737. Q_OBJECT
  1738. public:
  1739. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1740. private slots:
  1741. void updatePort(const QString&newPort);
  1742. void updateBaudRate(const QString&newRate);
  1743. void updateParity(const QString&newParity);
  1744. void updateFlowControl(const QString&newFlow);
  1745. void updateStopBits(const QString&newStopBits);
  1746. void updateStation(int station);
  1747. void updateFixedDecimal(bool fixed);
  1748. void updateDecimalAddress(int address);
  1749. void updateDecimalPosition(int position);
  1750. void updateFixedUnit(bool fixed);
  1751. void updateUnitAddress(int address);
  1752. void updateValueForF(int value);
  1753. void updateValueForC(int value);
  1754. void updateUnit(const QString&newUnit);
  1755. void updatePVAddress(int address);
  1756. void updateSVEnabled(bool enabled);
  1757. void updateSVReadAddress(int address);
  1758. void updateDeviceLimit(bool query);
  1759. void updateSVLowerAddress(int address);
  1760. void updateSVUpperAddress(int address);
  1761. void updateSVLower(double value);
  1762. void updateSVUpper(double value);
  1763. void updateSVWritable(bool canWriteSV);
  1764. void updateSVWriteAddress(int address);
  1765. void updatePVColumnName(const QString&name);
  1766. void updateSVColumnName(const QString&name);
  1767. void updatePVHidden(bool hidden);
  1768. void updateSVHidden(bool hidden);
  1769. private:
  1770. PortSelector*port;
  1771. BaudSelector*baud;
  1772. ParitySelector*parity;
  1773. FlowSelector*flow;
  1774. StopSelector*stop;
  1775. QSpinBox*station;
  1776. QCheckBox*decimalQuery;
  1777. ShortHexSpinBox*decimalAddress;
  1778. QSpinBox*decimalPosition;
  1779. QCheckBox*unitQuery;
  1780. ShortHexSpinBox*unitAddress;
  1781. QSpinBox*valueF;
  1782. QSpinBox*valueC;
  1783. QComboBox*fixedUnit;
  1784. ShortHexSpinBox*pVAddress;
  1785. QCheckBox*sVEnabled;
  1786. ShortHexSpinBox*sVReadAddress;
  1787. QCheckBox*deviceLimit;
  1788. ShortHexSpinBox*sVLowerAddr;
  1789. ShortHexSpinBox*sVUpperAddr;
  1790. QDoubleSpinBox*sVLower;
  1791. QDoubleSpinBox*sVUpper;
  1792. QCheckBox*sVWritable;
  1793. ShortHexSpinBox*sVOutputAddr;
  1794. QLineEdit*pVColumnName;
  1795. QLineEdit*sVColumnName;
  1796. };
  1797. /*:911*//*915:*/
  1798. #line 22 "./modbus.w"
  1799. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1800. {
  1801. Q_OBJECT
  1802. public:
  1803. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1804. private slots:
  1805. void updatePort(const QString&value);
  1806. void updateBaudRate(const QString&value);
  1807. void updateParity(int value);
  1808. void updateFlowControl(int value);
  1809. void updateStopBits(int value);
  1810. void addInput();
  1811. private:
  1812. ParitySelector*m_parity;
  1813. FlowSelector*m_flow;
  1814. StopSelector*m_stop;
  1815. };
  1816. /*:915*//*917:*/
  1817. #line 144 "./modbus.w"
  1818. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1819. {
  1820. Q_OBJECT
  1821. public:
  1822. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1823. private slots:
  1824. void updateStation(int value);
  1825. void updateAddress(int value);
  1826. void updateFunction(int value);
  1827. void updateFormat(int value);
  1828. void updateDecimals(int value);
  1829. void updateUnit(int value);
  1830. void updateColumnName(const QString&value);
  1831. void updateHidden(bool value);
  1832. };
  1833. /*:917*//*921:*/
  1834. #line 342 "./modbus.w"
  1835. enum ModbusDataFormat
  1836. {
  1837. Int16,
  1838. FloatHL,
  1839. FloatLH
  1840. };
  1841. struct ModbusScanItem
  1842. {
  1843. QByteArray request;
  1844. ModbusDataFormat format;
  1845. int decimalPosition;
  1846. Units::Unit unit;
  1847. mutable double lastValue;
  1848. };
  1849. /*:921*//*922:*/
  1850. #line 362 "./modbus.w"
  1851. class ModbusNG:public QObject
  1852. {
  1853. Q_OBJECT
  1854. public:
  1855. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1856. ~ModbusNG();
  1857. Q_INVOKABLE int channelCount();
  1858. Channel*getChannel(int);
  1859. Q_INVOKABLE QString channelColumnName(int);
  1860. Q_INVOKABLE QString channelIndicatorText(int);
  1861. Q_INVOKABLE bool isChannelHidden(int);
  1862. Q_INVOKABLE QString channelType(int);
  1863. private slots:
  1864. void sendNextMessage();
  1865. void timeout();
  1866. void dataAvailable();
  1867. void rateLimitTimeout();
  1868. private:
  1869. quint16 calculateCRC(QByteArray data);
  1870. QextSerialPort*port;
  1871. int delayTime;
  1872. QTimer*messageDelayTimer;
  1873. QTimer*commTimeout;
  1874. QTimer*rateLimiter;
  1875. int scanPosition;
  1876. bool waiting;
  1877. QByteArray responseBuffer;
  1878. QList<Channel*> channels;
  1879. QList<ModbusScanItem> scanList;
  1880. QList<QString> channelNames;
  1881. QList<QString> channelLabels;
  1882. QList<bool> hiddenStates;
  1883. QList<QString> channelTypeList;
  1884. QVector<double> lastMeasurement;
  1885. };
  1886. /*:922*//*927:*/
  1887. #line 36 "./unsupportedserial.w"
  1888. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1889. {
  1890. Q_OBJECT
  1891. public:
  1892. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1893. const QModelIndex&index);
  1894. private slots:
  1895. void updateConfiguration();
  1896. void saveScript();
  1897. void addChannel();
  1898. private:
  1899. SaltModel*deviceSettingsModel;
  1900. QTextEdit*scriptEditor;
  1901. };
  1902. /*:927*//*932:*/
  1903. #line 166 "./unsupportedserial.w"
  1904. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1905. {
  1906. Q_OBJECT
  1907. public:
  1908. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1909. const QModelIndex&index);
  1910. private slots:
  1911. void updateColumnName(const QString&value);
  1912. void updateHidden(bool hidden);
  1913. void updateConfiguration();
  1914. private:
  1915. SaltModel*channelSettingsModel;
  1916. };
  1917. /*:932*//*937:*/
  1918. #line 301 "./unsupportedserial.w"
  1919. class JavaScriptDevice:public QObject
  1920. {
  1921. Q_OBJECT
  1922. public:
  1923. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1924. QScriptEngine*engine);
  1925. Q_INVOKABLE int channelCount();
  1926. Channel*getChannel(int channel);
  1927. Q_INVOKABLE bool isChannelHidden(int channel);
  1928. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1929. Q_INVOKABLE QString channelColumnName(int channel);
  1930. Q_INVOKABLE QString channelIndicatorText(int channel);
  1931. public slots:
  1932. void setTemperatureColumn(int tcol);
  1933. void setAnnotationColumn(int ncol);
  1934. void start();
  1935. void stop();
  1936. signals:
  1937. void annotation(QString note,int tcol,int ncol);
  1938. void triggerStartBatch();
  1939. void triggerStopBatch();
  1940. void deviceStopRequested();
  1941. private:
  1942. QVariantMap deviceSettings;
  1943. QString deviceScript;
  1944. QList<Channel*> channelList;
  1945. QList<bool> hiddenState;
  1946. QList<Units::Unit> channelUnits;
  1947. QList<QString> columnNames;
  1948. QList<QString> indicatorTexts;
  1949. QList<QVariantMap> channelSettings;
  1950. int annotationTemperatureColumn;
  1951. int annotationNoteColumn;
  1952. QScriptEngine*scriptengine;
  1953. };
  1954. /*:937*//*959:*/
  1955. #line 11 "./phidgets.w"
  1956. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1957. {
  1958. Q_OBJECT
  1959. public:
  1960. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1961. const QModelIndex&index);
  1962. private slots:
  1963. void addChannel();
  1964. void updateRate(int ms);
  1965. };
  1966. /*:959*//*963:*/
  1967. #line 82 "./phidgets.w"
  1968. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1969. {
  1970. Q_OBJECT
  1971. public:
  1972. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1973. const QModelIndex&index);
  1974. private slots:
  1975. void updateColumnName(const QString&value);
  1976. void updateHidden(bool hidden);
  1977. void updateTC(int index);
  1978. void updateChannel(int channel);
  1979. private:
  1980. QComboBox*tcType;
  1981. };
  1982. /*:963*//*968:*/
  1983. #line 213 "./phidgets.w"
  1984. class PhidgetsTemperatureSensor:public QObject
  1985. {
  1986. Q_OBJECT
  1987. public:
  1988. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1989. Q_INVOKABLE int channelCount();
  1990. Channel*getChannel(int channel);
  1991. Q_INVOKABLE bool isChannelHidden(int channel);
  1992. Q_INVOKABLE QString channelColumnName(int channel);
  1993. Q_INVOKABLE QString channelIndicatorText(int channel);
  1994. public slots:
  1995. void start();
  1996. void stop();
  1997. private slots:
  1998. void getMeasurements();
  1999. private:
  2000. QList<int> channelIndices;
  2001. QList<int> tctypes;
  2002. QList<Channel*> channelList;
  2003. QMap<int,Channel*> channelMap;
  2004. QList<bool> hiddenState;
  2005. QList<QString> columnNames;
  2006. QList<QString> indicatorTexts;
  2007. QLibrary driver;
  2008. QTimer sampleTimer;
  2009. void*device;
  2010. /*972:*/
  2011. #line 349 "./phidgets.w"
  2012. #ifdef _WIN32
  2013. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  2014. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  2015. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  2016. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  2017. #else
  2018. typedef int(*PhidgetHandleOnly)(void*);
  2019. typedef int(*PhidgetHandleInt)(void*,int);
  2020. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  2021. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  2022. #endif
  2023. PhidgetHandleOnly createDevice;
  2024. PhidgetHandleInt openDevice;
  2025. PhidgetHandleInt waitForOpen;
  2026. PhidgetHandleIntInt setTCType;
  2027. PhidgetHandleIntDoubleOut getTemperature;
  2028. PhidgetHandleOnly closeDevice;
  2029. PhidgetHandleOnly deleteDevice;
  2030. /*:972*/
  2031. #line 240 "./phidgets.w"
  2032. };
  2033. /*:968*//*983:*/
  2034. #line 46 "./phidget22.w"
  2035. class PhidgetConfWidget:public BasicDeviceConfigurationWidget
  2036. {
  2037. Q_OBJECT
  2038. public:
  2039. Q_INVOKABLE PhidgetConfWidget(DeviceTreeModel*model,
  2040. const QModelIndex&index);
  2041. private slots:
  2042. void addChannel();
  2043. };
  2044. /*:983*//*985:*/
  2045. #line 96 "./phidget22.w"
  2046. class PhidgetChannelSelector:public QComboBox
  2047. {
  2048. Q_OBJECT
  2049. public:
  2050. PhidgetChannelSelector();
  2051. ~PhidgetChannelSelector();
  2052. void addChannel(void*device);
  2053. void removeChannel(void*device);
  2054. private:
  2055. QLibrary driver;
  2056. void*manager;
  2057. /*987:*/
  2058. #line 141 "./phidget22.w"
  2059. PhidgetPointer createManager;
  2060. PhidgetPointerCallbackPointer setOnAttachManager;
  2061. PhidgetPointerCallbackPointer setOnDetachManager;
  2062. PhidgetPointer openManager;
  2063. PhidgetPointerStringOut getDeviceName;
  2064. PhidgetPointerIntOut getDeviceSerialNumber;
  2065. PhidgetPointerIntOut getChannel;
  2066. PhidgetPointerIntOut getChannelClass;
  2067. PhidgetPointerIntOut getChannelSubclass;
  2068. PhidgetPointerIntOut getHubPort;
  2069. PhidgetPointer closeManager;
  2070. PhidgetPointer deleteManager;
  2071. /*:987*/
  2072. #line 108 "./phidget22.w"
  2073. };
  2074. /*:985*//*995:*/
  2075. #line 298 "./phidget22.w"
  2076. class PhidgetChannelConfWidget:public BasicDeviceConfigurationWidget
  2077. {
  2078. Q_OBJECT
  2079. public:
  2080. Q_INVOKABLE PhidgetChannelConfWidget(DeviceTreeModel*model,
  2081. const QModelIndex&index);
  2082. public slots:
  2083. void changeSelectedChannel(int index);
  2084. void updateSerialNumber(const QString&value);
  2085. void updateChannel(const QString&value);
  2086. void updateHubPort(const QString&value);
  2087. void updateColumnName(const QString&value);
  2088. void updateChannelType(int value);
  2089. void updateTCType(int value);
  2090. void updateRTDType(int value);
  2091. void updateRTDWiring(int value);
  2092. void updateHidden(int value);
  2093. private:
  2094. PhidgetChannelSelector*channelSelector;
  2095. QLineEdit*serialNumber;
  2096. QLineEdit*channel;
  2097. QLineEdit*hubPort;
  2098. QComboBox*subtype;
  2099. QStackedLayout*subtypeLayout;
  2100. QComboBox*tctype;
  2101. QComboBox*rtdtype;
  2102. QComboBox*rtdwiring;
  2103. };
  2104. /*:995*//*999:*/
  2105. #line 538 "./phidget22.w"
  2106. struct PhidgetChannelData
  2107. {
  2108. Channel*channel;
  2109. QString columnName;
  2110. QString indicatorLabel;
  2111. int serialNumber;
  2112. int channelNumber;
  2113. int channelType;
  2114. int hubPort;
  2115. int tcType;
  2116. int rtdType;
  2117. int wiring;
  2118. bool hidden;
  2119. void*device;
  2120. };
  2121. /*:999*//*1000:*/
  2122. #line 559 "./phidget22.w"
  2123. class Phidget22:public QObject
  2124. {
  2125. Q_OBJECT
  2126. public:
  2127. Q_INVOKABLE Phidget22(const QModelIndex&deviceIndex);
  2128. Q_INVOKABLE int channelCount();
  2129. Channel*getChannel(int channel);
  2130. Q_INVOKABLE bool isChannelHidden(int channel);
  2131. Q_INVOKABLE QString channelColumnName(int channel);
  2132. Q_INVOKABLE QString channelIndicatorText(int channel);
  2133. public slots:
  2134. void start();
  2135. void stop();
  2136. private:
  2137. QList<PhidgetChannelData*> channelConfiguration;
  2138. QLibrary driver;
  2139. PhidgetPointer p_createTemperatureSensor;
  2140. PhidgetPointerIntIn p_setSerialNumber;
  2141. PhidgetPointerIntIn p_setChannelNumber;
  2142. PhidgetPointerIntIn p_setHubPort;
  2143. PhidgetPointerIntIn p_setTCType;
  2144. PhidgetPointerIntIn p_setRTDType;
  2145. PhidgetPointerIntIn p_setRTDWiring;
  2146. PhidgetPointerVCPointer p_setNewDataCallback;
  2147. PhidgetPointerIntIn p_open;
  2148. PhidgetPointer p_close;
  2149. PhidgetPointer p_delete;
  2150. };
  2151. /*:1000*//*1013:*/
  2152. #line 19940 "./typica.w"
  2153. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  2154. {
  2155. Q_OBJECT
  2156. public:
  2157. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  2158. const QModelIndex&index);
  2159. private slots:
  2160. void updateSourceColumn(const QString&source);
  2161. void updateDestinationColumn(const QString&dest);
  2162. void updateKnots();
  2163. private:
  2164. SaltModel*tablemodel;
  2165. };
  2166. /*:1013*//*1019:*/
  2167. #line 20070 "./typica.w"
  2168. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  2169. {
  2170. Q_OBJECT
  2171. public:
  2172. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  2173. const QModelIndex&index);
  2174. private slots:
  2175. void updateResetTime(QTime time);
  2176. };
  2177. /*:1019*//*1023:*/
  2178. #line 20136 "./typica.w"
  2179. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2180. {
  2181. Q_OBJECT
  2182. public:
  2183. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2184. private slots:
  2185. void updateStartButtonText(const QString&text);
  2186. void updateStopButtonText(const QString&text);
  2187. void updateStartColumnName(const QString&text);
  2188. void updateStopColumnName(const QString&text);
  2189. void updateStartValue(const QString&text);
  2190. void updateStopValue(const QString&text);
  2191. void updateStartTrigger(int option);
  2192. void updateStopTrigger(int option);
  2193. };
  2194. /*:1023*//*1028:*/
  2195. #line 20388 "./typica.w"
  2196. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2197. {
  2198. Q_OBJECT
  2199. public:
  2200. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  2201. const QModelIndex&index);
  2202. private slots:
  2203. void updateColumnName(const QString&text);
  2204. void updateRangeData();
  2205. private:
  2206. SaltModel*tablemodel;
  2207. };
  2208. /*:1028*//*1033:*/
  2209. #line 20490 "./typica.w"
  2210. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  2211. {
  2212. Q_OBJECT
  2213. public:
  2214. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2215. private slots:
  2216. void updateMatchingColumn(const QString&column);
  2217. void updateTemperature();
  2218. void updateDelay();
  2219. private:
  2220. QDoubleSpinBox*temperatureValue;
  2221. QComboBox*unitSelector;
  2222. QSpinBox*delaySelector;
  2223. };
  2224. /*:1033*//*1037:*/
  2225. #line 16 "./rate.w"
  2226. class RateOfChange:public QObject
  2227. {
  2228. Q_OBJECT
  2229. public:
  2230. RateOfChange(int cachetime= 1,int scaletime= 1);
  2231. public slots:
  2232. void newMeasurement(Measurement measure);
  2233. void setCacheTime(int seconds);
  2234. void setScaleTime(int seconds);
  2235. signals:
  2236. void newData(Measurement measure);
  2237. private:
  2238. int ct;
  2239. int st;
  2240. QList<Measurement> cache;
  2241. };
  2242. /*:1037*//*1045:*/
  2243. #line 177 "./rate.w"
  2244. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  2245. {
  2246. Q_OBJECT
  2247. public:
  2248. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2249. private slots:
  2250. void updateColumn(const QString&column);
  2251. void updateCacheTime(const QString&seconds);
  2252. void updateScaleTime(const QString&seconds);
  2253. };
  2254. /*:1045*//*1051:*/
  2255. #line 15 "./mergeseries.w"
  2256. class MergeSeries:public QObject
  2257. {
  2258. Q_OBJECT
  2259. public:
  2260. MergeSeries();
  2261. public slots:
  2262. void in1(Measurement measure);
  2263. void in2(Measurement measure);
  2264. signals:
  2265. void newData(Measurement measure);
  2266. protected:
  2267. virtual void calculate(Measurement m1,Measurement m2)= 0;
  2268. private:
  2269. Measurement last1;
  2270. Measurement last2;
  2271. bool received1;
  2272. bool received2;
  2273. };
  2274. class DifferenceSeries:public MergeSeries
  2275. {
  2276. Q_OBJECT
  2277. public:
  2278. DifferenceSeries();
  2279. protected:
  2280. void calculate(Measurement m1,Measurement m2);
  2281. };
  2282. class MeanSeries:public MergeSeries
  2283. {
  2284. Q_OBJECT
  2285. public:
  2286. MeanSeries();
  2287. protected:
  2288. void calculate(Measurement m1,Measurement m2);
  2289. };
  2290. /*:1051*//*1059:*/
  2291. #line 167 "./mergeseries.w"
  2292. class MergeSeriesConfWidget:public BasicDeviceConfigurationWidget
  2293. {
  2294. Q_OBJECT
  2295. public:
  2296. Q_INVOKABLE MergeSeriesConfWidget(DeviceTreeModel*model,
  2297. const QModelIndex&index);
  2298. private slots:
  2299. void updateColumn1(const QString&column);
  2300. void updateColumn2(const QString&column);
  2301. void updateOutput(const QString&column);
  2302. void updateType(int type);
  2303. };
  2304. /*:1059*//*1065:*/
  2305. #line 19 "./dataqsdk.w"
  2306. class DataqSdkDeviceImplementation;
  2307. class DataqSdkDevice:public QObject
  2308. {
  2309. Q_OBJECT
  2310. DataqSdkDeviceImplementation*imp;
  2311. private slots:
  2312. void threadFinished();
  2313. public:
  2314. DataqSdkDevice(QString device);
  2315. ~DataqSdkDevice();
  2316. Channel*newChannel(Units::Unit scale);
  2317. Q_INVOKABLE void setClockRate(double Hz);
  2318. Q_INVOKABLE void start();
  2319. static QStringList detectPorts();
  2320. static QStringList detectHardware();
  2321. };
  2322. /*:1065*//*1066:*/
  2323. #line 49 "./dataqsdk.w"
  2324. class DataqSdkDeviceImplementation:public QThread
  2325. {
  2326. Q_OBJECT
  2327. public:
  2328. DataqSdkDeviceImplementation();
  2329. ~DataqSdkDeviceImplementation();
  2330. void run();
  2331. /*1067:*/
  2332. #line 70 "./dataqsdk.w"
  2333. typedef struct di_inlist_struct{
  2334. unsigned short chan;
  2335. unsigned short diff;
  2336. unsigned short gain;
  2337. unsigned short unipolar;
  2338. unsigned short dig_out_enable;
  2339. unsigned short dig_out;
  2340. unsigned short ave;
  2341. unsigned short counter;
  2342. }DI_INLIST_STRUCT;
  2343. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2344. typedef int(PASCAL*FPDICLOSE)(void);
  2345. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2346. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2347. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2348. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2349. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2350. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2351. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2352. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2353. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2354. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2355. FPDIOPEN di_open;
  2356. FPDICLOSE di_close;
  2357. FPDISAMPLERATE di_sample_rate;
  2358. FPDIMAXIMUMRATE di_maximum_rate;
  2359. FPDILISTLENGTH di_list_length;
  2360. FPDIINLIST di_inlist;
  2361. FPDIBUFFERALLOC di_buffer_alloc;
  2362. FPDISTARTSCAN di_start_scan;
  2363. FPDISTATUSREAD di_status_read;
  2364. FPDIBUFFERSTATUS di_buffer_status;
  2365. FPDIBURSTRATE di_burst_rate;
  2366. FPDISTOPSCAN di_stop_scan;
  2367. /*:1067*/
  2368. #line 57 "./dataqsdk.w"
  2369. /*1069:*/
  2370. #line 134 "./dataqsdk.w"
  2371. bool isOpen;
  2372. double sampleRate;
  2373. long oversample;
  2374. long burstDivisor;
  2375. QString device;
  2376. unsigned deviceNumber;
  2377. QVector<Channel*> channelMap;
  2378. int error;
  2379. int channels;
  2380. bool ready;
  2381. QLibrary*driver;
  2382. QVector<Units::Unit> unitMap;
  2383. int*input_buffer;
  2384. QTimer*eventClock;
  2385. QMultiMap<int,double> smoother;
  2386. /*:1069*/
  2387. #line 58 "./dataqsdk.w"
  2388. public slots:
  2389. void measure();
  2390. private:
  2391. qint16*buffer;
  2392. };
  2393. /*:1066*//*1086:*/
  2394. #line 663 "./dataqsdk.w"
  2395. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2396. {
  2397. Q_OBJECT
  2398. public:
  2399. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2400. const QModelIndex&index);
  2401. private slots:
  2402. void updateAutoSelect(bool automatic);
  2403. void updateDeviceNumber(int deviceNumber);
  2404. void updatePort(QString portId);
  2405. void addChannel();
  2406. private:
  2407. QStackedWidget*deviceIdStack;
  2408. };
  2409. /*:1086*//*1091:*/
  2410. #line 808 "./dataqsdk.w"
  2411. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2412. {
  2413. Q_OBJECT
  2414. public:
  2415. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2416. const QModelIndex&index);
  2417. private slots:
  2418. void updateUnits(const QString&unit);
  2419. void updateColumnName(const QString&value);
  2420. void updateMeasuredLower(const QString&value);
  2421. void updateMeasuredUpper(const QString&value);
  2422. void updateMappedLower(const QString&value);
  2423. void updateMappedUpper(const QString&value);
  2424. void updateClosedInterval(bool closed);
  2425. void updateSmoothingEnabled(bool enabled);
  2426. void updateSensitivity(const QString&value);
  2427. void startCalibration();
  2428. void stopCalibration();
  2429. void resetCalibration();
  2430. void updateInput(Measurement measure);
  2431. void updateOutput(Measurement measure);
  2432. void updateHidden(bool hidden);
  2433. private:
  2434. QPushButton*startButton;
  2435. QPushButton*resetButton;
  2436. QPushButton*stopButton;
  2437. /*1096:*/
  2438. #line 1098 "./dataqsdk.w"
  2439. bool autoSelect;
  2440. QString deviceID;
  2441. unsigned int channelOfInterest;
  2442. /*:1096*/
  2443. #line 835 "./dataqsdk.w"
  2444. DataqSdkDevice*calibrationDevice;
  2445. LinearCalibrator*calibrator;
  2446. QLineEdit*currentMeasurement;
  2447. QLineEdit*minimumMeasurement;
  2448. QLineEdit*maximumMeasurement;
  2449. QLineEdit*averageMeasurement;
  2450. QLineEdit*currentMapped;
  2451. QLineEdit*minimumMapped;
  2452. QLineEdit*maximumMapped;
  2453. QLineEdit*averageMapped;
  2454. int rmCount;
  2455. int cmCount;
  2456. double rmin;
  2457. double rmax;
  2458. double rmean;
  2459. double cmin;
  2460. double cmax;
  2461. double cmean;
  2462. };
  2463. /*:1091*//*1118:*/
  2464. #line 273 "./scales.w"
  2465. Q_DECLARE_METATYPE(BaudRateType)
  2466. Q_DECLARE_METATYPE(DataBitsType)
  2467. Q_DECLARE_METATYPE(ParityType)
  2468. Q_DECLARE_METATYPE(StopBitsType)
  2469. Q_DECLARE_METATYPE(FlowType)
  2470. /*:1118*//*1125:*/
  2471. #line 396 "./scales.w"
  2472. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2473. {
  2474. Q_OBJECT
  2475. public:
  2476. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2477. const QModelIndex&index);
  2478. private slots:
  2479. void updatePort(const QString&newPort);
  2480. void updateBaudRate(const QString&rate);
  2481. void updateParity(int index);
  2482. void updateFlowControl(int index);
  2483. void updateStopBits(int index);
  2484. void updateWeighCommand(const QString&command);
  2485. void updateCommandTerminator(const QString&terminator);
  2486. private:
  2487. PortSelector*port;
  2488. BaudSelector*baud;
  2489. ParitySelector*parity;
  2490. FlowSelector*flow;
  2491. StopSelector*stop;
  2492. QLineEdit*weighcommand;
  2493. QComboBox*commandterminator;
  2494. };
  2495. /*:1125*//*1130:*/
  2496. #line 14 "./valueannotation.w"
  2497. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2498. {
  2499. Q_OBJECT
  2500. public:
  2501. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2502. const QModelIndex&index);
  2503. private slots:
  2504. void updateSourceColumn(const QString&source);
  2505. void updateAnnotations();
  2506. void updateStart(bool noteOnStart);
  2507. private:
  2508. SaltModel*tablemodel;
  2509. };
  2510. /*:1130*//*1138:*/
  2511. #line 165 "./valueannotation.w"
  2512. class ValueAnnotation:public QObject
  2513. {
  2514. Q_OBJECT
  2515. public:
  2516. ValueAnnotation();
  2517. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2518. public slots:
  2519. void newMeasurement(Measurement measure);
  2520. void annotate();
  2521. void setAnnotationColumn(int column);
  2522. void setTemperatureColumn(int column);
  2523. void setTolerance(double epsilon);
  2524. signals:
  2525. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2526. private:
  2527. int lastIndex;
  2528. int annotationColumn;
  2529. int measurementColumn;
  2530. QList<double> values;
  2531. QStringList annotations;
  2532. double tolerance;
  2533. };
  2534. /*:1138*//*1147:*/
  2535. #line 14 "./thresholdannotation.w"
  2536. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2537. {
  2538. Q_OBJECT
  2539. public:
  2540. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2541. const QModelIndex&index);
  2542. private slots:
  2543. void updateSourceColumn(const QString&source);
  2544. void updateThreshold(double value);
  2545. void updateDirection(int index);
  2546. void updateAnnotation(const QString&note);
  2547. };
  2548. /*:1147*//*1152:*/
  2549. #line 127 "./thresholdannotation.w"
  2550. class Annotator:public QObject
  2551. {
  2552. Q_OBJECT
  2553. QString note;
  2554. int tc;
  2555. int ac;
  2556. QTimer t;
  2557. public:
  2558. Annotator(const QString&text);
  2559. public slots:
  2560. void setAnnotation(const QString&annotation);
  2561. void setTemperatureColumn(int tempcolumn);
  2562. void setAnnotationColumn(int annotationcolumn);
  2563. void annotate();
  2564. private slots:
  2565. void catchTimer();
  2566. signals:
  2567. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2568. };
  2569. /*:1152*//*1163:*/
  2570. #line 78 "./user.w"
  2571. class LoginDialog:public QDialog
  2572. {
  2573. Q_OBJECT
  2574. public:
  2575. LoginDialog();
  2576. public slots:
  2577. void attemptLogin();
  2578. private:
  2579. QLineEdit*user;
  2580. QLineEdit*password;
  2581. QLabel*warning;
  2582. QPushButton*login;
  2583. };
  2584. /*:1163*//*1169:*/
  2585. #line 162 "./user.w"
  2586. class UserLabel:public QLabel
  2587. {
  2588. Q_OBJECT
  2589. public:
  2590. UserLabel();
  2591. public slots:
  2592. void updateLabel(const QString&user);
  2593. protected:
  2594. void mouseReleaseEvent(QMouseEvent*event);
  2595. };
  2596. /*:1169*//*1173:*/
  2597. #line 209 "./user.w"
  2598. class NewTypicaUser:public QDialog
  2599. {
  2600. Q_OBJECT
  2601. public:
  2602. NewTypicaUser();
  2603. public slots:
  2604. void createAndReset();
  2605. void createAndClose();
  2606. void validate();
  2607. void cancelValidate();
  2608. private:
  2609. void createNewUser();
  2610. QLineEdit*userField;
  2611. QLineEdit*passwordField;
  2612. QCheckBox*autoLogin;
  2613. QPushButton*saveAndCloseButton;
  2614. QPushButton*saveAndNewButton;
  2615. QPushButton*cancelButton;
  2616. };
  2617. /*:1173*//*1180:*/
  2618. #line 9 "./roastcoloredit.w"
  2619. class RoastColorEdit:public QWidget
  2620. {
  2621. Q_OBJECT
  2622. Q_PROPERTY(QString value READ value WRITE setValue)
  2623. public:
  2624. RoastColorEdit();
  2625. QString value();
  2626. public slots:
  2627. void setValue(const QString&color);
  2628. private slots:
  2629. void readColor();
  2630. void measureFinished();
  2631. void readFinished();
  2632. private:
  2633. QLineEdit*edit;
  2634. QNetworkReply*networkReply;
  2635. };
  2636. /*:1180*/
  2637. #line 528 "./typica.w"
  2638. /*990:*/
  2639. #line 203 "./phidget22.w"
  2640. void CCONV ChannelListAddChannel(void*,void*context,void*device)
  2641. {
  2642. PhidgetChannelSelector*list=
  2643. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2644. list->addChannel(device);
  2645. }
  2646. void CCONV ChannelListRemoveChannel(void*,void*context,void*device)
  2647. {
  2648. PhidgetChannelSelector*list=
  2649. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2650. list->removeChannel(device);
  2651. }
  2652. /*:990*//*1005:*/
  2653. #line 762 "./phidget22.w"
  2654. void CCONV Phidget22ValueCallback(void*,void*context,double value)
  2655. {
  2656. Channel*channel= (Channel*)context;
  2657. QTime time= QTime::currentTime();
  2658. Measurement measure(value*9.0/5.0+32.0,time);
  2659. channel->input(measure);
  2660. }
  2661. /*:1005*/
  2662. #line 529 "./typica.w"
  2663. /*12:*/
  2664. #line 820 "./typica.w"
  2665. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2666. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*engine);
  2667. /*:12*//*14:*/
  2668. #line 845 "./typica.w"
  2669. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2670. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2671. /*:14*//*19:*/
  2672. #line 905 "./typica.w"
  2673. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2674. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2675. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2676. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2677. QScriptEngine*engine);
  2678. /*:19*//*23:*/
  2679. #line 995 "./typica.w"
  2680. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2681. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2682. QScriptValue displayInfo(QScriptContext*context,QScriptEngine*engine);
  2683. /*:23*//*33:*/
  2684. #line 1229 "./typica.w"
  2685. QScriptValue constructQMainWindow(QScriptContext*context,
  2686. QScriptEngine*engine);
  2687. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2688. QScriptEngine*engine);
  2689. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2690. QScriptEngine*engine);
  2691. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2692. /*:33*//*38:*/
  2693. #line 1328 "./typica.w"
  2694. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2695. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2696. /*:38*//*41:*/
  2697. #line 1373 "./typica.w"
  2698. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2699. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2700. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2701. /*:41*//*44:*/
  2702. #line 1439 "./typica.w"
  2703. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2704. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2705. /*:44*//*47:*/
  2706. #line 1472 "./typica.w"
  2707. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2708. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2709. /*:47*//*50:*/
  2710. #line 1510 "./typica.w"
  2711. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2712. QScriptValue constructQSvgWidget(QScriptContext*context,
  2713. QScriptEngine*engine);
  2714. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2715. QScriptEngine*engine);
  2716. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2717. QStack<QLayout*> *layoutStack);
  2718. /*:50*//*56:*/
  2719. #line 1597 "./typica.w"
  2720. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2721. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2722. /*:56*//*60:*/
  2723. #line 1636 "./typica.w"
  2724. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2725. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2726. QScriptEngine*engine);
  2727. QScriptValue QSplitter_saveState(QScriptContext*context,
  2728. QScriptEngine*engine);
  2729. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2730. QScriptEngine*engine);
  2731. QScriptValue QSplitter_count(QScriptContext*context,
  2732. QScriptEngine*engine);
  2733. QScriptValue QSplitter_setCollapsible(QScriptContext*context,
  2734. QScriptEngine*engine);
  2735. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2736. /*:60*//*67:*/
  2737. #line 1797 "./typica.w"
  2738. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2739. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2740. /*:67*//*69:*/
  2741. #line 1852 "./typica.w"
  2742. QScriptValue constructQBoxLayout(QScriptContext*context,
  2743. QScriptEngine*engine);
  2744. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2745. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2746. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2747. /*:69*//*73:*/
  2748. #line 1965 "./typica.w"
  2749. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2750. QScriptValue QAction_setShortcut(QScriptContext*context,
  2751. QScriptEngine*engine);
  2752. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2753. /*:73*//*76:*/
  2754. #line 2021 "./typica.w"
  2755. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2756. QScriptEngine*engine);
  2757. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2758. QScriptEngine*engine);
  2759. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2760. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2761. /*:76*//*81:*/
  2762. #line 2132 "./typica.w"
  2763. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2764. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2765. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2766. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2767. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2768. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2769. QScriptValue QIODevice_readToString(QScriptContext*context,
  2770. QScriptEngine*engine);
  2771. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2772. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2773. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2774. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2775. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2776. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2777. /*:81*//*92:*/
  2778. #line 2358 "./typica.w"
  2779. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2780. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2781. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2782. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2783. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2784. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2785. /*:92*//*100:*/
  2786. #line 2476 "./typica.w"
  2787. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2788. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2789. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2790. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2791. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2792. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2793. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2794. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2795. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2796. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2797. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2798. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2799. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2800. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2801. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2802. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2803. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2804. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2805. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2806. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2807. /*:100*//*113:*/
  2808. #line 2750 "./typica.w"
  2809. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2810. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2811. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2812. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2813. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2814. /*:113*//*116:*/
  2815. #line 2855 "./typica.w"
  2816. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2817. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2818. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2819. QScriptValue QBuffer_data(QScriptContext*context,QScriptEngine*engine);
  2820. /*:116*//*119:*/
  2821. #line 2908 "./typica.w"
  2822. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2823. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2824. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2825. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2826. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2827. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2828. /*:119*//*125:*/
  2829. #line 2990 "./typica.w"
  2830. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2831. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2832. QScriptEngine*engine);
  2833. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2834. QScriptEngine*engine);
  2835. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2836. QScriptEngine*engine);
  2837. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2838. QScriptEngine*engine);
  2839. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2840. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2841. QScriptEngine*engine);
  2842. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2843. QScriptEngine*engine);
  2844. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2845. QScriptEngine*engine);
  2846. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2847. QScriptEngine*engine);
  2848. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2849. QScriptEngine*engine);
  2850. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2851. QScriptEngine*engine);
  2852. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2853. QScriptEngine*engine);
  2854. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2855. QScriptEngine*engine);
  2856. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2857. /*:125*//*134:*/
  2858. #line 3208 "./typica.w"
  2859. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2860. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2861. QScriptValue XmlReader_attribute(QScriptContext*context,
  2862. QScriptEngine*engine);
  2863. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2864. QScriptEngine*engine);
  2865. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2866. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2867. QScriptEngine*engine);
  2868. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2869. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2870. QScriptEngine*engine);
  2871. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2872. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2873. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2874. /*:134*//*141:*/
  2875. #line 3343 "./typica.w"
  2876. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2877. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2878. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2879. /*:141*//*145:*/
  2880. #line 3425 "./typica.w"
  2881. QScriptValue constructQLCDNumber(QScriptContext*context,
  2882. QScriptEngine*engine);
  2883. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2884. /*:145*//*148:*/
  2885. #line 3463 "./typica.w"
  2886. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2887. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2888. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2889. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2890. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2891. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2892. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2893. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2894. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2895. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2896. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2897. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2898. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2899. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2900. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2901. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2902. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2903. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2904. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2905. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2906. /*:148*//*164:*/
  2907. #line 3940 "./typica.w"
  2908. QScriptValue constructQColor(QScriptContext*context,QScriptEngine*engine);
  2909. /*:164*//*167:*/
  2910. #line 3964 "./typica.w"
  2911. QScriptValue constructQBrush(QScriptContext*context,QScriptEngine*engine);
  2912. /*:167*//*170:*/
  2913. #line 3989 "./typica.w"
  2914. void setQAbstractScrollAreaProperties(QScriptValue value,
  2915. QScriptEngine*engine);
  2916. /*:170*//*172:*/
  2917. #line 4004 "./typica.w"
  2918. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2919. /*:172*//*174:*/
  2920. #line 4017 "./typica.w"
  2921. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2922. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2923. /*:174*//*176:*/
  2924. #line 4041 "./typica.w"
  2925. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2926. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2927. QScriptValue constructQPushButton(QScriptContext*context,
  2928. QScriptEngine*engine);
  2929. /*:176*//*183:*/
  2930. #line 4140 "./typica.w"
  2931. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2932. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2933. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2934. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2935. QScriptEngine*engine);
  2936. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2937. QScriptEngine*engine);
  2938. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2939. QScriptEngine*engine);
  2940. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2941. QScriptEngine*engine);
  2942. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2943. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2944. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2945. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2946. /*:183*//*190:*/
  2947. #line 4311 "./typica.w"
  2948. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2949. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2950. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2951. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2952. QScriptValue annotationFromRecord(QScriptContext*context,
  2953. QScriptEngine*engine);
  2954. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2955. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2956. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2957. /*:190*//*203:*/
  2958. #line 4658 "./typica.w"
  2959. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2960. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2961. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2962. QStack<QLayout*> *layoutStack);
  2963. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2964. QStack<QLayout*> *layoutStack);
  2965. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2966. QStack<QLayout*> *layoutStack);
  2967. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2968. QStack<QLayout*> *layoutStack);
  2969. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2970. QStack<QLayout*> *layoutStack);
  2971. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2972. QStack<QLayout*> *layoutStack);
  2973. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2974. QStack<QLayout*> *layoutStack);
  2975. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2976. QStack<QLayout*> *layoutStack);
  2977. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2978. QStack<QLayout*> *layoutStack);
  2979. void addTemperatureDisplayToSplitter(QDomElement element,
  2980. QStack<QWidget*> *widgetStack,
  2981. QStack<QLayout*> *layoutStack);
  2982. void addTemperatureDisplayToLayout(QDomElement element,
  2983. QStack<QWidget*> *widgetStack,
  2984. QStack<QLayout*> *layoutStack);
  2985. void addTimerDisplayToSplitter(QDomElement element,
  2986. QStack<QWidget*> *widgetStack,
  2987. QStack<QLayout*> *layoutStack);
  2988. void addTimerDisplayToLayout(QDomElement element,
  2989. QStack<QWidget*> *widgetStack,
  2990. QStack<QLayout*> *layoutStack);
  2991. void addDecorationToSplitter(QDomElement element,
  2992. QStack<QWidget*> *widgetStack,
  2993. QStack<QLayout*> *layoutStack);
  2994. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2995. QStack<QLayout*> *layoutStack);
  2996. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2997. QStack<QLayout*> *layoutStack);
  2998. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2999. QStack<QLayout*> *layoutStack);
  3000. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  3001. QStack<QLayout*> *layoutStack);
  3002. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  3003. QStack<QLayout*> *layoutStack);
  3004. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3005. QStack<QLayout*> *layoutStack);
  3006. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3007. QStack<QLayout*> *layoutStack);
  3008. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3009. QStack<QLayout*> *layoutStack);
  3010. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3011. QStack<QLayout*> *layoutStack);
  3012. void addSqlQueryViewToLayout(QDomElement element,
  3013. QStack<QWidget*> *widgetStack,
  3014. QStack<QLayout*> *layoutStack);
  3015. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3016. QStack<QLayout*> *layoutStack);
  3017. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3018. QStack<QLayout*> *layoutStack);
  3019. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3020. QStack<QLayout*> *layoutStack);
  3021. /*:203*//*232:*/
  3022. #line 5139 "./typica.w"
  3023. QScriptValue constructQTabBar(QScriptContext*context,QScriptEngine*engine);
  3024. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine);
  3025. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*engine);
  3026. /*:232*//*274:*/
  3027. #line 6467 "./typica.w"
  3028. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  3029. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  3030. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  3031. QScriptEngine*engine);
  3032. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  3033. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  3034. QScriptEngine*engine);
  3035. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  3036. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  3037. /*:274*//*277:*/
  3038. #line 6512 "./typica.w"
  3039. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  3040. /*:277*//*278:*/
  3041. #line 6520 "./typica.w"
  3042. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  3043. /*:278*//*282:*/
  3044. #line 6667 "./typica.w"
  3045. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  3046. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  3047. QScriptEngine*engine);
  3048. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  3049. QScriptEngine*engine);
  3050. QScriptValue SaltTable_columnSum(QScriptContext*context,
  3051. QScriptEngine*engine);
  3052. QScriptValue SaltTable_columnArray(QScriptContext*context,
  3053. QScriptEngine*engine);
  3054. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  3055. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  3056. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  3057. QScriptEngine*engine);
  3058. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  3059. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  3060. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  3061. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  3062. /*:282*//*292:*/
  3063. #line 6883 "./typica.w"
  3064. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  3065. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  3066. QScriptValue QComboBox_currentData(QScriptContext*context,
  3067. QScriptEngine*engine);
  3068. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  3069. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  3070. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  3071. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  3072. /*:292*//*304:*/
  3073. #line 379 "./units.w"
  3074. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  3075. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  3076. QScriptEngine*engine);
  3077. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  3078. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  3079. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  3080. /*:304*//*308:*/
  3081. #line 443 "./units.w"
  3082. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  3083. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  3084. /*:308*//*317:*/
  3085. #line 133 "./measurement.w"
  3086. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  3087. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  3088. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  3089. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  3090. /*:317*//*337:*/
  3091. #line 7518 "./typica.w"
  3092. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  3093. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3094. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  3095. /*:337*//*346:*/
  3096. #line 7723 "./typica.w"
  3097. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  3098. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3099. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  3100. /*:346*//*351:*/
  3101. #line 7824 "./typica.w"
  3102. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  3103. /*:351*//*357:*/
  3104. #line 8006 "./typica.w"
  3105. QScriptValue constructLinearCalibrator(QScriptContext*context,
  3106. QScriptEngine*engine);
  3107. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  3108. /*:357*//*362:*/
  3109. #line 8146 "./typica.w"
  3110. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  3111. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  3112. /*:362*//*372:*/
  3113. #line 8351 "./typica.w"
  3114. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  3115. QScriptEngine*engine);
  3116. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3117. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  3118. QScriptEngine*engine);
  3119. /*:372*//*380:*/
  3120. #line 8510 "./typica.w"
  3121. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  3122. QScriptEngine*engine);
  3123. void setMeasurementTimeOffsetProperties(QScriptValue value,
  3124. QScriptEngine*engine);
  3125. /*:380*//*385:*/
  3126. #line 8633 "./typica.w"
  3127. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  3128. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  3129. /*:385*//*390:*/
  3130. #line 8731 "./typica.w"
  3131. QScriptValue constructZeroEmitter(QScriptContext*context,
  3132. QScriptEngine*engine);
  3133. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  3134. /*:390*//*395:*/
  3135. #line 8810 "./typica.w"
  3136. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  3137. QScriptEngine*engine);
  3138. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  3139. /*:395*//*412:*/
  3140. #line 9274 "./typica.w"
  3141. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  3142. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  3143. /*:412*//*435:*/
  3144. #line 9913 "./typica.w"
  3145. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  3146. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  3147. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  3148. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  3149. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  3150. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  3151. QScriptEngine*engine);
  3152. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  3153. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  3154. QScriptEngine*engnie);
  3155. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  3156. QScriptEngine*engine);
  3157. /*:435*//*475:*/
  3158. #line 10925 "./typica.w"
  3159. QScriptValue constructAnnotationButton(QScriptContext*context,
  3160. QScriptEngine*engine);
  3161. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  3162. /*:475*//*483:*/
  3163. #line 11065 "./typica.w"
  3164. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  3165. QScriptEngine*engine);
  3166. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3167. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3168. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3169. /*:483*//*504:*/
  3170. #line 11491 "./typica.w"
  3171. QScriptValue constructTimerDisplay(QScriptContext*context,
  3172. QScriptEngine*engine);
  3173. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3174. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  3175. /*:504*//*532:*/
  3176. #line 12016 "./typica.w"
  3177. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  3178. QScriptValue constructWidgetDecorator(QScriptContext*context,
  3179. QScriptEngine*engine);
  3180. /*:532*//*545:*/
  3181. #line 12299 "./typica.w"
  3182. QScriptValue constructLogEditWindow(QScriptContext*context,
  3183. QScriptEngine*engine);
  3184. /*:545*//*564:*/
  3185. #line 12826 "./typica.w"
  3186. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  3187. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  3188. /*:564*//*583:*/
  3189. #line 209 "./webview.w"
  3190. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  3191. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  3192. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3193. QStack<QLayout*> *layoutStack);
  3194. /*:583*//*586:*/
  3195. #line 239 "./webview.w"
  3196. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  3197. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  3198. /*:586*//*590:*/
  3199. #line 297 "./webview.w"
  3200. QScriptValue constructWebElement(QScriptContext*context,
  3201. QScriptEngine*engine);
  3202. /*:590*//*602:*/
  3203. #line 67 "./printerselector.w"
  3204. QScriptValue constructPrinterSelector(QScriptContext*context,
  3205. QScriptEngine*engine);
  3206. void addPrinterSelectorToLayout(QDomElement element,
  3207. QStack<QWidget*> *widgetStack,
  3208. QStack<QLayout*> *layoutStack);
  3209. /*:602*//*617:*/
  3210. #line 13197 "./typica.w"
  3211. QScriptValue Application_subscribe(QScriptContext*context,
  3212. QScriptEngine*engine);
  3213. /*:617*//*675:*/
  3214. #line 14324 "./typica.w"
  3215. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  3216. QScriptValue constructSqlQueryView(QScriptContext*context,
  3217. QScriptEngine*engine);
  3218. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  3219. QScriptEngine*engine);
  3220. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  3221. QScriptEngine*engine);
  3222. QScriptValue SqlQueryView_rows(QScriptContext*context,
  3223. QScriptEngine*engine);
  3224. /*:675*//*685:*/
  3225. #line 14572 "./typica.w"
  3226. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3227. QStack<QLayout*> *layoutStack);
  3228. /*:685*//*701:*/
  3229. #line 14857 "./typica.w"
  3230. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  3231. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  3232. /*:701*//*729:*/
  3233. #line 480 "./daterangeselector.w"
  3234. void addDateRangeToLayout(QDomElement element,
  3235. QStack<QWidget*> *widgetStack,
  3236. QStack<QLayout*> *layoutStack);
  3237. /*:729*//*738:*/
  3238. #line 15056 "./typica.w"
  3239. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3240. QStack<QLayout*> *layoutStack);
  3241. /*:738*//*759:*/
  3242. #line 15640 "./typica.w"
  3243. void addScaleControlToLayout(QDomElement element,
  3244. QStack<QWidget*> *widgetStack,
  3245. QStack<QLayout*> *layoutStack);
  3246. void addIntensityControlToLayout(QDomElement element,
  3247. QStack<QWidget*> *widgetStack,
  3248. QStack<QLayout*> *layoutStack);
  3249. /*:759*//*785:*/
  3250. #line 16226 "./typica.w"
  3251. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  3252. QScriptEngine*engine);
  3253. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  3254. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  3255. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  3256. QScriptEngine*engine);
  3257. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  3258. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  3259. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  3260. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  3261. /*:785*//*791:*/
  3262. #line 16368 "./typica.w"
  3263. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  3264. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  3265. /*:791*//*807:*/
  3266. #line 16666 "./typica.w"
  3267. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  3268. QScriptEngine*engine);
  3269. /*:807*//*878:*/
  3270. #line 44 "./settings.w"
  3271. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  3272. /*:878*//*906:*/
  3273. #line 19305 "./typica.w"
  3274. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  3275. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  3276. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  3277. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3278. /*:906*//*924:*/
  3279. #line 698 "./modbus.w"
  3280. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  3281. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  3282. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  3283. /*:924*//*938:*/
  3284. #line 348 "./unsupportedserial.w"
  3285. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  3286. /*:938*//*944:*/
  3287. #line 428 "./unsupportedserial.w"
  3288. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  3289. /*:944*//*950:*/
  3290. #line 620 "./unsupportedserial.w"
  3291. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  3292. /*:950*//*954:*/
  3293. #line 654 "./unsupportedserial.w"
  3294. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  3295. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  3296. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  3297. /*:954*//*978:*/
  3298. #line 457 "./phidgets.w"
  3299. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  3300. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  3301. /*:978*//*1010:*/
  3302. #line 805 "./phidget22.w"
  3303. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine);
  3304. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine);
  3305. /*:1010*//*1042:*/
  3306. #line 138 "./rate.w"
  3307. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  3308. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  3309. /*:1042*//*1056:*/
  3310. #line 129 "./mergeseries.w"
  3311. QScriptValue constructDifferenceSeries(QScriptContext*context,
  3312. QScriptEngine*engine);
  3313. QScriptValue constructMeanSeries(QScriptContext*context,
  3314. QScriptEngine*engine);
  3315. /*:1056*//*1081:*/
  3316. #line 597 "./dataqsdk.w"
  3317. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  3318. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  3319. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3320. /*:1081*//*1108:*/
  3321. #line 67 "./scales.w"
  3322. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  3323. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  3324. /*:1108*//*1116:*/
  3325. #line 259 "./scales.w"
  3326. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  3327. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  3328. /*:1116*//*1119:*/
  3329. #line 284 "./scales.w"
  3330. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  3331. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  3332. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  3333. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  3334. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  3335. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  3336. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  3337. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  3338. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  3339. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  3340. /*:1119*//*1144:*/
  3341. #line 265 "./valueannotation.w"
  3342. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  3343. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  3344. /*:1144*//*1155:*/
  3345. #line 194 "./thresholdannotation.w"
  3346. QScriptValue constructAnnotator(QScriptContext*context,
  3347. QScriptEngine*engine);
  3348. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  3349. /*:1155*//*1168:*/
  3350. #line 151 "./user.w"
  3351. QScriptValue constructLoginDialog(QScriptContext*context,QScriptEngine*engine);
  3352. /*:1168*//*1178:*/
  3353. #line 339 "./user.w"
  3354. QScriptValue constructNewTypicaUser(QScriptContext*context,QScriptEngine*engine);
  3355. /*:1178*/
  3356. #line 530 "./typica.w"
  3357. /*655:*/
  3358. #line 13957 "./typica.w"
  3359. void messageFileOutput(QtMsgType type,const char*msg);
  3360. /*:655*/
  3361. #line 531 "./typica.w"
  3362. /*4:*/
  3363. #line 540 "./typica.w"
  3364. /*799:*/
  3365. #line 16489 "./typica.w"
  3366. NodeInserter::NodeInserter(const QString&title,const QString&name,
  3367. const QString&driver,QObject*parent):
  3368. QAction(title,parent),defaultNodeName(name),driverString(driver)
  3369. {
  3370. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  3371. }
  3372. void NodeInserter::onTriggered()
  3373. {
  3374. emit triggered(defaultNodeName,driverString);
  3375. }
  3376. /*:799*/
  3377. #line 541 "./typica.w"
  3378. /*313:*/
  3379. #line 40 "./measurement.w"
  3380. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  3381. {
  3382. insert("measurement",temperature);
  3383. insert("time",time);
  3384. insert("unit",sc);
  3385. }
  3386. Measurement::Measurement(double temperature)
  3387. {
  3388. insert("measurement",temperature);
  3389. insert("time",QTime::currentTime());
  3390. insert("unit",Units::Fahrenheit);
  3391. }
  3392. void Measurement::setTemperature(double temperature)
  3393. {
  3394. insert("measurement",temperature);
  3395. }
  3396. void Measurement::setTime(QTime time)
  3397. {
  3398. insert("time",time);
  3399. }
  3400. void Measurement::setUnit(Units::Unit scale)
  3401. {
  3402. insert("unit",scale);
  3403. }
  3404. double Measurement::temperature()const
  3405. {
  3406. return value("measurement").toDouble();
  3407. }
  3408. QTime Measurement::time()const
  3409. {
  3410. return value("time").toTime();
  3411. }
  3412. Units::Unit Measurement::scale()const
  3413. {
  3414. return(Units::Unit)(value("unit").toInt());
  3415. }
  3416. /*:313*//*314:*/
  3417. #line 88 "./measurement.w"
  3418. Measurement Measurement::toFahrenheit()
  3419. {
  3420. return Measurement(Units::convertTemperature(this->temperature(),
  3421. this->scale(),Units::Fahrenheit),
  3422. this->time(),Units::Fahrenheit);
  3423. }
  3424. Measurement Measurement::toCelsius()
  3425. {
  3426. return Measurement(Units::convertTemperature(this->temperature(),
  3427. this->scale(),Units::Celsius),
  3428. this->time(),Units::Celsius);
  3429. }
  3430. Measurement Measurement::toKelvin()
  3431. {
  3432. return Measurement(Units::convertTemperature(this->temperature(),
  3433. this->scale(),Units::Kelvin),
  3434. this->time(),Units::Kelvin);
  3435. }
  3436. Measurement Measurement::toRankine()
  3437. {
  3438. return Measurement(Units::convertTemperature(this->temperature(),
  3439. this->scale(),Units::Rankine),
  3440. this->time(),Units::Rankine);
  3441. }
  3442. /*:314*/
  3443. #line 542 "./typica.w"
  3444. /*327:*/
  3445. #line 7123 "./typica.w"
  3446. void DAQImplementation::measure()
  3447. {
  3448. int samplesRead= 0;
  3449. double buffer[channels];
  3450. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3451. (unsigned long)(0),buffer,(unsigned long)(channels),
  3452. &samplesRead,(signed long)(0));
  3453. if(error)
  3454. {
  3455. ready= false;
  3456. }
  3457. else
  3458. {
  3459. if(samplesRead)
  3460. {
  3461. QTime time= QTime::currentTime();
  3462. for(int i= 0;i<samplesRead;i++)
  3463. {
  3464. for(int j= 0;j<channels;j++)
  3465. {
  3466. double measuredValue= buffer[j+(i*channels)];
  3467. Measurement measure(measuredValue,time,
  3468. unitMap[j]);
  3469. channelMap[j]->input(measure);
  3470. }
  3471. }
  3472. }
  3473. }
  3474. }
  3475. /*:327*//*328:*/
  3476. #line 7166 "./typica.w"
  3477. void DAQImplementation::run()
  3478. {
  3479. setPriority(QThread::TimeCriticalPriority);
  3480. while(ready)
  3481. {
  3482. measure();
  3483. }
  3484. }
  3485. /*:328*//*329:*/
  3486. #line 7182 "./typica.w"
  3487. void DAQ::threadFinished()
  3488. {
  3489. if(imp->error)
  3490. {
  3491. /*330:*/
  3492. #line 7233 "./typica.w"
  3493. imp->ready= false;
  3494. QMessageBox warning;
  3495. warning.setStandardButtons(QMessageBox::Cancel);
  3496. warning.setIcon(QMessageBox::Warning);
  3497. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3498. unsigned long bytes= imp->errorInfo(NULL,0);
  3499. char string[bytes];
  3500. imp->errorInfo(string,bytes);
  3501. warning.setInformativeText(QString(string));
  3502. warning.setWindowTitle(QString(PROGRAM_NAME));
  3503. warning.exec();
  3504. /*:330*/
  3505. #line 7187 "./typica.w"
  3506. }
  3507. }
  3508. /*:329*//*331:*/
  3509. #line 7258 "./typica.w"
  3510. void DAQ::start()
  3511. {
  3512. if(imp->ready)
  3513. {
  3514. imp->error= imp->startTask(imp->handle);
  3515. if(imp->error)
  3516. {
  3517. /*330:*/
  3518. #line 7233 "./typica.w"
  3519. imp->ready= false;
  3520. QMessageBox warning;
  3521. warning.setStandardButtons(QMessageBox::Cancel);
  3522. warning.setIcon(QMessageBox::Warning);
  3523. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3524. unsigned long bytes= imp->errorInfo(NULL,0);
  3525. char string[bytes];
  3526. imp->errorInfo(string,bytes);
  3527. warning.setInformativeText(QString(string));
  3528. warning.setWindowTitle(QString(PROGRAM_NAME));
  3529. warning.exec();
  3530. /*:330*/
  3531. #line 7266 "./typica.w"
  3532. }
  3533. else
  3534. {
  3535. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3536. imp->start();
  3537. }
  3538. }
  3539. }
  3540. void DAQ::stop()
  3541. {
  3542. if(imp->useBase)
  3543. {
  3544. imp->ready= false;
  3545. imp->wait(ULONG_MAX);
  3546. imp->stopTask(imp->handle);
  3547. }
  3548. else
  3549. {
  3550. imp->ready= false;
  3551. imp->error= imp->stopTask(imp->handle);
  3552. if(imp->error)
  3553. {
  3554. /*330:*/
  3555. #line 7233 "./typica.w"
  3556. imp->ready= false;
  3557. QMessageBox warning;
  3558. warning.setStandardButtons(QMessageBox::Cancel);
  3559. warning.setIcon(QMessageBox::Warning);
  3560. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3561. unsigned long bytes= imp->errorInfo(NULL,0);
  3562. char string[bytes];
  3563. imp->errorInfo(string,bytes);
  3564. warning.setInformativeText(QString(string));
  3565. warning.setWindowTitle(QString(PROGRAM_NAME));
  3566. warning.exec();
  3567. /*:330*/
  3568. #line 7290 "./typica.w"
  3569. }
  3570. imp->error= imp->clearTask(imp->handle);
  3571. if(imp->error)
  3572. {
  3573. /*330:*/
  3574. #line 7233 "./typica.w"
  3575. imp->ready= false;
  3576. QMessageBox warning;
  3577. warning.setStandardButtons(QMessageBox::Cancel);
  3578. warning.setIcon(QMessageBox::Warning);
  3579. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3580. unsigned long bytes= imp->errorInfo(NULL,0);
  3581. char string[bytes];
  3582. imp->errorInfo(string,bytes);
  3583. warning.setInformativeText(QString(string));
  3584. warning.setWindowTitle(QString(PROGRAM_NAME));
  3585. warning.exec();
  3586. /*:330*/
  3587. #line 7295 "./typica.w"
  3588. }
  3589. }
  3590. }
  3591. /*:331*//*332:*/
  3592. #line 7305 "./typica.w"
  3593. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3594. {
  3595. imp->device= device;
  3596. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3597. if(imp->error)
  3598. {
  3599. /*330:*/
  3600. #line 7233 "./typica.w"
  3601. imp->ready= false;
  3602. QMessageBox warning;
  3603. warning.setStandardButtons(QMessageBox::Cancel);
  3604. warning.setIcon(QMessageBox::Warning);
  3605. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3606. unsigned long bytes= imp->errorInfo(NULL,0);
  3607. char string[bytes];
  3608. imp->errorInfo(string,bytes);
  3609. warning.setInformativeText(QString(string));
  3610. warning.setWindowTitle(QString(PROGRAM_NAME));
  3611. warning.exec();
  3612. /*:330*/
  3613. #line 7312 "./typica.w"
  3614. }
  3615. else
  3616. {
  3617. imp->ready= true;
  3618. }
  3619. }
  3620. /*:332*//*333:*/
  3621. #line 7326 "./typica.w"
  3622. Channel*DAQ::newChannel(int units,int thermocouple)
  3623. {
  3624. Channel*retval= new Channel();
  3625. imp->channelMap[imp->channels]= retval;
  3626. imp->unitMap[imp->channels]= (Units::Unit)units;
  3627. imp->channels++;
  3628. if(imp->ready)
  3629. {
  3630. if(imp->useBase)
  3631. {
  3632. imp->error= imp->createChannel(imp->handle,
  3633. QString("%1/ai%2").arg(imp->device).
  3634. arg(imp->channels-1).
  3635. toAscii().data(),
  3636. "",(double)(-1.0),(double)(100.0),
  3637. (signed long)(units),
  3638. (signed long)(thermocouple),
  3639. (signed long)(10200),(double)(0),
  3640. "");
  3641. }
  3642. else
  3643. {
  3644. imp->error= imp->createChannel(imp->handle,
  3645. QString("%1/ai%2").arg(imp->device).
  3646. arg(imp->channels-1).
  3647. toAscii().data(),
  3648. "",(double)(50.0),(double)(500.0),
  3649. (signed long)(units),
  3650. (signed long)(thermocouple),
  3651. (signed long)(10200),(double)(0),
  3652. "");
  3653. }
  3654. if(imp->error)
  3655. {
  3656. /*330:*/
  3657. #line 7233 "./typica.w"
  3658. imp->ready= false;
  3659. QMessageBox warning;
  3660. warning.setStandardButtons(QMessageBox::Cancel);
  3661. warning.setIcon(QMessageBox::Warning);
  3662. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3663. unsigned long bytes= imp->errorInfo(NULL,0);
  3664. char string[bytes];
  3665. imp->errorInfo(string,bytes);
  3666. warning.setInformativeText(QString(string));
  3667. warning.setWindowTitle(QString(PROGRAM_NAME));
  3668. warning.exec();
  3669. /*:330*/
  3670. #line 7361 "./typica.w"
  3671. }
  3672. }
  3673. return retval;
  3674. }
  3675. /*:333*//*334:*/
  3676. #line 7375 "./typica.w"
  3677. void DAQ::setClockRate(double Hz)
  3678. {
  3679. if(imp->ready)
  3680. {
  3681. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3682. (signed long)(10280),(signed long)(10123),
  3683. (unsigned long long)(1));
  3684. if(imp->error)
  3685. {
  3686. /*330:*/
  3687. #line 7233 "./typica.w"
  3688. imp->ready= false;
  3689. QMessageBox warning;
  3690. warning.setStandardButtons(QMessageBox::Cancel);
  3691. warning.setIcon(QMessageBox::Warning);
  3692. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3693. unsigned long bytes= imp->errorInfo(NULL,0);
  3694. char string[bytes];
  3695. imp->errorInfo(string,bytes);
  3696. warning.setInformativeText(QString(string));
  3697. warning.setWindowTitle(QString(PROGRAM_NAME));
  3698. warning.exec();
  3699. /*:330*/
  3700. #line 7385 "./typica.w"
  3701. }
  3702. }
  3703. }
  3704. /*:334*//*335:*/
  3705. #line 7395 "./typica.w"
  3706. DAQ::~DAQ()
  3707. {
  3708. if(imp->useBase)
  3709. {
  3710. imp->resetDevice(imp->device.toAscii().data());
  3711. imp->clearTask(imp->handle);
  3712. }
  3713. else
  3714. {
  3715. if(imp->ready)
  3716. {
  3717. imp->ready= false;
  3718. imp->wait(ULONG_MAX);
  3719. imp->stopTask(imp->handle);
  3720. imp->resetDevice(imp->device.toAscii().data());
  3721. imp->clearTask(imp->handle);
  3722. }
  3723. }
  3724. delete imp;
  3725. }
  3726. /*:335*//*336:*/
  3727. #line 7426 "./typica.w"
  3728. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3729. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3730. unitMap(4)
  3731. {
  3732. if(driverinfo=="nidaqmxbase")
  3733. {
  3734. useBase= true;
  3735. }
  3736. else
  3737. {
  3738. useBase= false;
  3739. }
  3740. if(useBase)
  3741. {
  3742. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3743. if(!driver.load())
  3744. {
  3745. driver.setFileName("nidaqmxbase");
  3746. if(!driver.load())
  3747. {
  3748. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3749. tr("Failed to find nidaqmxbase. Please install it."));
  3750. QApplication::quit();
  3751. }
  3752. }
  3753. }
  3754. else
  3755. {
  3756. driver.setFileName("nicaiu");
  3757. if(!driver.load())
  3758. {
  3759. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3760. tr("Failed to find nidaqmx. Please install it."));
  3761. QApplication::quit();
  3762. }
  3763. }
  3764. if(useBase)
  3765. {
  3766. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3767. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3768. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3769. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3770. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3771. ==0||
  3772. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3773. 0||
  3774. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3775. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3776. 0||
  3777. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3778. {
  3779. waitForMeasurement= NULL;
  3780. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3781. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3782. QApplication::quit();
  3783. }
  3784. }
  3785. else
  3786. {
  3787. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3788. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3789. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3790. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3791. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3792. ==0||
  3793. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3794. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3795. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3796. 0||
  3797. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3798. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3799. {
  3800. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3801. tr("Failed to link a required symbol in NI-DAQmx."));
  3802. QApplication::quit();
  3803. }
  3804. }
  3805. }
  3806. DAQImplementation::~DAQImplementation()
  3807. {
  3808. driver.unload();
  3809. }
  3810. /*:336*/
  3811. #line 543 "./typica.w"
  3812. /*1070:*/
  3813. #line 197 "./dataqsdk.w"
  3814. void DataqSdkDeviceImplementation::measure()
  3815. {
  3816. unsigned count= channels*40;
  3817. di_status_read(buffer,count);
  3818. QTime time= QTime::currentTime();
  3819. for(unsigned int i= 0;i<count;i++)
  3820. {
  3821. buffer[i]= buffer[i]&0xFFFC;
  3822. }
  3823. QList<int> countList;
  3824. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3825. {
  3826. QList<double> channelBuffer;
  3827. for(unsigned int j= 0;j<40;j++)
  3828. {
  3829. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3830. if(i==0)
  3831. {
  3832. countList<<buffer[i+(channels*j)];
  3833. }
  3834. }
  3835. double value= 0.0;
  3836. for(unsigned int j= 0;j<40;j++)
  3837. {
  3838. value+= channelBuffer[j];
  3839. }
  3840. value/= 40.0;
  3841. if(i==0)
  3842. {
  3843. QList<double> smoothingList;
  3844. smoothingList<<value;
  3845. QList<int> smoothingKeys= smoother.uniqueKeys();
  3846. for(int j= 0;j<smoothingKeys.size();j++)
  3847. {
  3848. if(countList.contains(smoothingKeys[j]))
  3849. {
  3850. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3851. for(int k= 0;k<keyValues.size();k++)
  3852. {
  3853. smoothingList<<keyValues[k];
  3854. }
  3855. }
  3856. else
  3857. {
  3858. smoother.remove(smoothingKeys[j]);
  3859. }
  3860. }
  3861. qSort(countList);
  3862. int lastCount= 0;
  3863. for(int j= 0;j<countList.size();j++)
  3864. {
  3865. if(j==0||countList[j]!=lastCount)
  3866. {
  3867. smoother.insert(countList[j],value);
  3868. lastCount= countList[j];
  3869. }
  3870. }
  3871. value= 0.0;
  3872. for(int j= 0;j<smoothingList.size();j++)
  3873. {
  3874. value+= smoothingList[j];
  3875. }
  3876. value/= smoothingList.size();
  3877. }
  3878. Measurement measure(value,time,unitMap[i]);
  3879. channelMap[i]->input(measure);
  3880. }
  3881. }
  3882. /*:1070*//*1071:*/
  3883. #line 290 "./dataqsdk.w"
  3884. void DataqSdkDeviceImplementation::run()
  3885. {
  3886. if(!ready)
  3887. {
  3888. error= 9;
  3889. return;
  3890. }
  3891. driver= new QLibrary(device);
  3892. if(!driver->load())
  3893. {
  3894. error= 1;
  3895. qDebug()<<"Failed to load driver: "<<device;
  3896. return;
  3897. }
  3898. di_open= (FPDIOPEN)driver->resolve("di_open");
  3899. di_close= (FPDICLOSE)driver->resolve("di_close");
  3900. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3901. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3902. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3903. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3904. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3905. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3906. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3907. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3908. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3909. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3910. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3911. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3912. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3913. (!di_burst_rate)||(!di_stop_scan))
  3914. {
  3915. error= 2;
  3916. return;
  3917. }
  3918. error= di_open(deviceNumber);
  3919. if(error)
  3920. {
  3921. di_close();
  3922. error= di_open(deviceNumber);
  3923. if(error)
  3924. {
  3925. error= 3;
  3926. di_close();
  3927. return;
  3928. }
  3929. }
  3930. isOpen= true;
  3931. di_maximum_rate(240.0);
  3932. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3933. &burstDivisor);
  3934. buffer= new qint16[(int)sampleRate];
  3935. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3936. for(unsigned short i= 0;i<channels;i++)
  3937. {
  3938. inlist[i].chan= i;
  3939. inlist[i].gain= 0;
  3940. inlist[i].ave= 1;
  3941. inlist[i].counter= (oversample-1);
  3942. }
  3943. error= di_list_length(channels,0);
  3944. if(error)
  3945. {
  3946. error= 4;
  3947. return;
  3948. }
  3949. error= di_inlist(inlist);
  3950. if(error)
  3951. {
  3952. error= 5;
  3953. return;
  3954. }
  3955. input_buffer= di_buffer_alloc(0,4096);
  3956. if(input_buffer==NULL)
  3957. {
  3958. error= 6;
  3959. return;
  3960. }
  3961. error= di_start_scan();
  3962. if(error)
  3963. {
  3964. error= 7;
  3965. return;
  3966. }
  3967. while(ready)
  3968. {
  3969. measure();
  3970. }
  3971. }
  3972. /*:1071*//*1072:*/
  3973. #line 386 "./dataqsdk.w"
  3974. void DataqSdkDevice::threadFinished()
  3975. {
  3976. if(imp->error)
  3977. {
  3978. /*1073:*/
  3979. #line 400 "./dataqsdk.w"
  3980. imp->ready= false;
  3981. QMessageBox warning;
  3982. warning.setStandardButtons(QMessageBox::Cancel);
  3983. warning.setIcon(QMessageBox::Warning);
  3984. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3985. warning.setInformativeText(tr("An error occurred"));
  3986. warning.setWindowTitle(QString(PROGRAM_NAME));
  3987. warning.exec();
  3988. /*:1073*/
  3989. #line 391 "./dataqsdk.w"
  3990. }
  3991. }
  3992. /*:1072*//*1074:*/
  3993. #line 417 "./dataqsdk.w"
  3994. void DataqSdkDevice::start()
  3995. {
  3996. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3997. imp->start();
  3998. }
  3999. /*:1074*//*1075:*/
  4000. #line 428 "./dataqsdk.w"
  4001. QStringList DataqSdkDevice::detectHardware()
  4002. {
  4003. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  4004. QSettings::NativeFormat);
  4005. QStringList keys= deviceLookup.childKeys();
  4006. QStringList devices;
  4007. for(int i= 0;i<keys.size();i++)
  4008. {
  4009. QString value= deviceLookup.value(keys.at(i)).toString();
  4010. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  4011. {
  4012. devices.append(value.split("\\").at(2));
  4013. }
  4014. }
  4015. QStringList portList;
  4016. foreach(QString device,devices)
  4017. {
  4018. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  4019. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  4020. portList.append(deviceEntry.value("FriendlyName").toString());
  4021. }
  4022. return portList;
  4023. }
  4024. QStringList DataqSdkDevice::detectPorts()
  4025. {
  4026. QStringList friendlyNames= detectHardware();
  4027. QStringList portList;
  4028. foreach(QString name,friendlyNames)
  4029. {
  4030. name.remove(0,name.indexOf("COM"));
  4031. name.chop(1);
  4032. portList.append(name);
  4033. }
  4034. return portList;
  4035. }
  4036. /*:1075*//*1076:*/
  4037. #line 473 "./dataqsdk.w"
  4038. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  4039. {
  4040. bool usesAuto= false;
  4041. int autoIndex= device.toInt(&usesAuto);
  4042. QString finalizedPort;
  4043. if(usesAuto)
  4044. {
  4045. QStringList portList= detectPorts();
  4046. if(autoIndex> 0&&autoIndex<=portList.size())
  4047. {
  4048. finalizedPort= portList.at(autoIndex-1);
  4049. }
  4050. else
  4051. {
  4052. imp->error= 8;
  4053. qDebug()<<"Failed to detect port.";
  4054. }
  4055. }
  4056. else
  4057. {
  4058. finalizedPort= device;
  4059. }
  4060. int rstart= finalizedPort.indexOf("COM");
  4061. finalizedPort.remove(0,rstart+3);
  4062. bool chopFinished= false;
  4063. int finalizedPortNumber= 0;
  4064. while(finalizedPort.size()> 0&&!chopFinished)
  4065. {
  4066. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  4067. if(!chopFinished)
  4068. {
  4069. finalizedPort.chop(1);
  4070. }
  4071. }
  4072. if(finalizedPortNumber<10)
  4073. {
  4074. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  4075. }
  4076. else
  4077. {
  4078. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  4079. }
  4080. imp->deviceNumber= 0x12C02D00;
  4081. imp->deviceNumber+= finalizedPortNumber;
  4082. imp->ready= true;
  4083. }
  4084. /*:1076*//*1077:*/
  4085. #line 523 "./dataqsdk.w"
  4086. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  4087. {
  4088. Channel*retval= NULL;
  4089. if(imp->ready)
  4090. {
  4091. retval= new Channel();
  4092. imp->channelMap[imp->channels]= retval;
  4093. imp->unitMap[imp->channels]= scale;
  4094. imp->channels++;
  4095. }
  4096. return retval;
  4097. }
  4098. /*:1077*//*1078:*/
  4099. #line 547 "./dataqsdk.w"
  4100. void DataqSdkDevice::setClockRate(double Hz)
  4101. {
  4102. imp->sampleRate= Hz;
  4103. }
  4104. /*:1078*//*1079:*/
  4105. #line 557 "./dataqsdk.w"
  4106. DataqSdkDevice::~DataqSdkDevice()
  4107. {
  4108. if(imp->ready)
  4109. {
  4110. imp->ready= false;
  4111. }
  4112. imp->wait(ULONG_MAX);
  4113. delete imp;
  4114. }
  4115. /*:1079*//*1080:*/
  4116. #line 575 "./dataqsdk.w"
  4117. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  4118. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  4119. {
  4120. }
  4121. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  4122. {
  4123. if(isOpen)
  4124. {
  4125. di_stop_scan();
  4126. di_close();
  4127. }
  4128. if(driver->isLoaded())
  4129. {
  4130. driver->unload();
  4131. }
  4132. }
  4133. /*:1080*/
  4134. #line 544 "./typica.w"
  4135. /*343:*/
  4136. #line 7635 "./typica.w"
  4137. void FakeDAQImplementation::measure()
  4138. {
  4139. msleep((int)(1000/clockRate));
  4140. QTime time= QTime::currentTime();
  4141. for(int i= 0;i<channels;i++)
  4142. {
  4143. Measurement measure(qrand()%500,time);
  4144. channelMap[i]->input(measure);
  4145. }
  4146. }
  4147. /*:343*//*344:*/
  4148. #line 7649 "./typica.w"
  4149. void FakeDAQImplementation::run()
  4150. {
  4151. setPriority(QThread::TimeCriticalPriority);
  4152. while(ready)
  4153. {
  4154. measure();
  4155. }
  4156. }
  4157. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  4158. channels(0),ready(false),clockRate(1)
  4159. {
  4160. }
  4161. FakeDAQImplementation::~FakeDAQImplementation()
  4162. {
  4163. }
  4164. /*:344*//*345:*/
  4165. #line 7674 "./typica.w"
  4166. void FakeDAQ::start()
  4167. {
  4168. if(imp->ready)
  4169. {
  4170. imp->start();
  4171. }
  4172. }
  4173. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  4174. {
  4175. imp->ready= true;
  4176. }
  4177. Channel*FakeDAQ::newChannel(int,int)
  4178. {
  4179. Channel*retval;
  4180. if(imp->ready)
  4181. {
  4182. retval= new Channel();
  4183. imp->channelMap[imp->channels]= retval;
  4184. imp->channels++;
  4185. }
  4186. else
  4187. {
  4188. return NULL;
  4189. }
  4190. return retval;
  4191. }
  4192. void FakeDAQ::setClockRate(double Hz)
  4193. {
  4194. if(imp->ready)
  4195. {
  4196. imp->clockRate= Hz;
  4197. }
  4198. }
  4199. FakeDAQ::~FakeDAQ()
  4200. {
  4201. imp->ready= false;
  4202. imp->wait(ULONG_MAX);
  4203. delete imp;
  4204. }
  4205. /*:345*/
  4206. #line 545 "./typica.w"
  4207. /*350:*/
  4208. #line 7805 "./typica.w"
  4209. Channel::Channel():QObject(NULL)
  4210. {
  4211. }
  4212. Channel::~Channel()
  4213. {
  4214. }
  4215. void Channel::input(Measurement measurement)
  4216. {
  4217. emit newData(measurement);
  4218. }
  4219. /*:350*/
  4220. #line 546 "./typica.w"
  4221. /*366:*/
  4222. #line 8210 "./typica.w"
  4223. void TemperatureDisplay::setRelativeMode(bool relative)
  4224. {
  4225. r= relative;
  4226. }
  4227. /*:366*//*367:*/
  4228. #line 8227 "./typica.w"
  4229. void TemperatureDisplay::setValue(Measurement temperature)
  4230. {
  4231. QString number;
  4232. switch(unit)
  4233. {
  4234. case Units::Fahrenheit:
  4235. display(QString("%1'F").
  4236. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  4237. 2)));
  4238. break;
  4239. case Units::Celsius:
  4240. if(!r){
  4241. display(QString("%1'C").
  4242. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  4243. 2)));
  4244. }else{
  4245. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4246. display(QString("%1'C").arg(number));
  4247. }
  4248. break;
  4249. case Units::Kelvin:
  4250. if(!r){
  4251. display(QString("%1").
  4252. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  4253. 2)));
  4254. }else{
  4255. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4256. display(QString("%1").arg(number));
  4257. }
  4258. break;
  4259. case Units::Rankine:
  4260. display(QString("%1'r").
  4261. arg(number.setNum(temperature.toRankine().temperature(),'f',
  4262. 2)));
  4263. break;
  4264. case Units::Unitless:
  4265. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4266. break;
  4267. default:
  4268. switch(temperature.scale())
  4269. {
  4270. case Units::Fahrenheit:
  4271. display(QString("%1'F").
  4272. arg(number.setNum(temperature.temperature(),'f',2)));
  4273. break;
  4274. case Units::Celsius:
  4275. display(QString("%1'C").
  4276. arg(number.setNum(temperature.temperature(),'f',2)));
  4277. break;
  4278. case Units::Kelvin:
  4279. display(QString("%1").
  4280. arg(number.setNum(temperature.temperature(),'f',2)));
  4281. break;
  4282. case Units::Rankine:
  4283. display(QString("%1'r").
  4284. arg(number.setNum(temperature.temperature(),'f',2)));
  4285. break;
  4286. case Units::Unitless:
  4287. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4288. break;
  4289. default:
  4290. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  4291. break;
  4292. }
  4293. break;
  4294. }
  4295. }
  4296. /*:367*//*368:*/
  4297. #line 8306 "./typica.w"
  4298. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  4299. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  4300. {
  4301. setSegmentStyle(Filled);
  4302. display("---.--'F");
  4303. }
  4304. /*:368*//*369:*/
  4305. #line 8322 "./typica.w"
  4306. void TemperatureDisplay::invalidate()
  4307. {
  4308. display("---.--'F");
  4309. }
  4310. /*:369*//*370:*/
  4311. #line 8334 "./typica.w"
  4312. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  4313. {
  4314. unit= scale;
  4315. }
  4316. /*:370*//*371:*/
  4317. #line 8342 "./typica.w"
  4318. TemperatureDisplay::~TemperatureDisplay()
  4319. {
  4320. }
  4321. /*:371*/
  4322. #line 547 "./typica.w"
  4323. /*377:*/
  4324. #line 8442 "./typica.w"
  4325. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  4326. {
  4327. if(measure.time()<epoch)
  4328. {
  4329. if(hasPrevious)
  4330. {
  4331. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  4332. epoch.msec());
  4333. QTime jitComp(epoch.hour(),measure.time().minute(),
  4334. measure.time().second(),measure.time().msec());
  4335. int relTime= jitBase.msecsTo(jitComp);
  4336. /*378:*/
  4337. #line 8476 "./typica.w"
  4338. QTime newTime(0,0,0,0);
  4339. newTime= newTime.addMSecs(relTime);
  4340. if(newTime.hour()> 0)
  4341. {
  4342. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4343. }
  4344. Measurement rel= measure;
  4345. rel.setTime(newTime);
  4346. emit measurement(rel);
  4347. /*:378*/
  4348. #line 8454 "./typica.w"
  4349. }
  4350. else
  4351. {
  4352. Measurement rel= measure;
  4353. rel.setTime(QTime(0,0,0,0));
  4354. emit measurement(rel);
  4355. }
  4356. }
  4357. else
  4358. {
  4359. int relTime= epoch.msecsTo(measure.time());
  4360. /*378:*/
  4361. #line 8476 "./typica.w"
  4362. QTime newTime(0,0,0,0);
  4363. newTime= newTime.addMSecs(relTime);
  4364. if(newTime.hour()> 0)
  4365. {
  4366. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4367. }
  4368. Measurement rel= measure;
  4369. rel.setTime(newTime);
  4370. emit measurement(rel);
  4371. /*:378*/
  4372. #line 8466 "./typica.w"
  4373. }
  4374. hasPrevious= true;
  4375. previous= measure.time();
  4376. }
  4377. /*:377*//*379:*/
  4378. #line 8489 "./typica.w"
  4379. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  4380. previous(0,0,0,0),hasPrevious(false)
  4381. {
  4382. }
  4383. QTime MeasurementTimeOffset::zeroTime()
  4384. {
  4385. return epoch;
  4386. }
  4387. void MeasurementTimeOffset::setZeroTime(QTime zero)
  4388. {
  4389. epoch= zero;
  4390. hasPrevious= false;
  4391. }
  4392. /*:379*/
  4393. #line 548 "./typica.w"
  4394. /*389:*/
  4395. #line 8697 "./typica.w"
  4396. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  4397. {
  4398. }
  4399. int ZeroEmitter::column()
  4400. {
  4401. return col;
  4402. }
  4403. double ZeroEmitter::lastTemperature()
  4404. {
  4405. return cache.temperature();
  4406. }
  4407. void ZeroEmitter::newMeasurement(Measurement measure)
  4408. {
  4409. cache= measure;
  4410. }
  4411. void ZeroEmitter::setColumn(int column)
  4412. {
  4413. col= column;
  4414. }
  4415. void ZeroEmitter::emitZero()
  4416. {
  4417. cache.setTime(QTime(0,0,0,0));
  4418. emit measurement(cache,col);
  4419. }
  4420. /*:389*/
  4421. #line 549 "./typica.w"
  4422. /*394:*/
  4423. #line 8787 "./typica.w"
  4424. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  4425. {
  4426. }
  4427. int MeasurementAdapter::column()
  4428. {
  4429. return col;
  4430. }
  4431. void MeasurementAdapter::newMeasurement(Measurement measure)
  4432. {
  4433. emit measurement(measure,col);
  4434. }
  4435. void MeasurementAdapter::setColumn(int column)
  4436. {
  4437. col= column;
  4438. }
  4439. /*:394*/
  4440. #line 550 "./typica.w"
  4441. /*399:*/
  4442. #line 8909 "./typica.w"
  4443. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4444. theScene(new QGraphicsScene),
  4445. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4446. prevPoints(new QMap<int,QPointF> ),
  4447. translations(new QMap<int,double> ),
  4448. gridLinesF(new QList<QGraphicsItem*> ),
  4449. gridLinesC(new QList<QGraphicsItem*> ),
  4450. relativeGridLines(new QList<QGraphicsItem*> ),
  4451. relativeEnabled(false),
  4452. timeIndicatorEnabled(false),
  4453. timeLine(new QGraphicsLineItem),
  4454. relativeAdjuster(new LinearSplineInterpolator)
  4455. {
  4456. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4457. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4458. setScene(theScene);
  4459. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4460. QPen timePen;
  4461. timePen.setColor(QColor(160,160,164,127));
  4462. timeLine->setPen(timePen);
  4463. timeLine->setLine(0,0,0,-500);
  4464. timeLine->hide();
  4465. theScene->addItem(timeLine);
  4466. /*400:*/
  4467. #line 8949 "./typica.w"
  4468. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4469. tempaxis->setLine(-10,-500,-10,0);
  4470. theScene->addItem(tempaxis);
  4471. QGraphicsLineItem*gridLine;
  4472. QGraphicsTextItem*label;
  4473. for(int y= -100;y> -600;y-= 100)
  4474. {
  4475. gridLine= new QGraphicsLineItem;
  4476. gridLine->setLine(0,y,1200,y);
  4477. theScene->addItem(gridLine);
  4478. label= new QGraphicsTextItem;
  4479. label->setHtml(QString("%1&deg;F").arg(-y));
  4480. label->setPos(-55,y-(label->boundingRect().height()/2));
  4481. theScene->addItem(label);
  4482. gridLinesF->append(gridLine);
  4483. gridLinesF->append(label);
  4484. }
  4485. for(int degC= 50;degC<=250;degC+= 50)
  4486. {
  4487. gridLine= new QGraphicsLineItem;
  4488. int y= -(degC*(9.0/5.0)+32);
  4489. gridLine->setLine(0,y,1200,y);
  4490. gridLine->hide();
  4491. theScene->addItem(gridLine);
  4492. gridLinesC->append(gridLine);
  4493. label= new QGraphicsTextItem;
  4494. label->setHtml(QString("%1&deg;C").arg(degC));
  4495. label->setPos(-55,y-(label->boundingRect().height()/2));
  4496. label->hide();
  4497. theScene->addItem(label);
  4498. gridLinesC->append(label);
  4499. }
  4500. /*:400*/
  4501. #line 8933 "./typica.w"
  4502. ;
  4503. /*401:*/
  4504. #line 8990 "./typica.w"
  4505. QSettings settings;
  4506. if(settings.contains("settings/graph/relative/enable"))
  4507. {
  4508. if(settings.value("settings/graph/relative/enable").toBool())
  4509. {
  4510. relativeEnabled= true;
  4511. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4512. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4513. QMap<double,QString> relativeAxisPairs;
  4514. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4515. foreach(QString item,relativeAxisLabels)
  4516. {
  4517. relativeAxisPairs.insert(item.toDouble(),item);
  4518. }
  4519. if(relativeAxisPairs.size()> 1)
  4520. {
  4521. double skip= 500.0/(relativeAxisPairs.size()-1);
  4522. double y= 0;
  4523. foreach(double key,relativeAxisPairs.keys())
  4524. {
  4525. gridLine= new QGraphicsLineItem;
  4526. gridLine->setLine(0,y,1205,y);
  4527. gridLine->setPen(QPen(relativeColor));
  4528. theScene->addItem(gridLine);
  4529. relativeGridLines->append(gridLine);
  4530. label= new QGraphicsTextItem;
  4531. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4532. label->setPos(1210,y-(label->boundingRect().height()/2));
  4533. theScene->addItem(label);
  4534. relativeGridLines->append(label);
  4535. if(unit=="F")
  4536. {
  4537. relativeAdjuster->add_pair(key,-y);
  4538. }
  4539. else
  4540. {
  4541. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4542. }
  4543. y-= skip;
  4544. }
  4545. }
  4546. }
  4547. }
  4548. /*:401*/
  4549. #line 8934 "./typica.w"
  4550. /*403:*/
  4551. #line 9067 "./typica.w"
  4552. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4553. timeaxis->setLine(0,10,1200,10);
  4554. theScene->addItem(timeaxis);
  4555. for(int x= 0;x<1201;x+= 120)
  4556. {
  4557. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4558. tick->setLine(x,0,x,20);
  4559. theScene->addItem(tick);
  4560. QGraphicsTextItem*label= new QGraphicsTextItem;
  4561. label->setPlainText(QString("%1").arg(x/60));
  4562. label->setPos(x-(label->boundingRect().width()/2),20);
  4563. theScene->addItem(label);
  4564. }
  4565. /*:403*/
  4566. #line 8935 "./typica.w"
  4567. ;
  4568. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4569. }
  4570. /*:399*//*402:*/
  4571. #line 9037 "./typica.w"
  4572. void GraphView::showF()
  4573. {
  4574. for(int i= 0;i<gridLinesF->size();i++)
  4575. {
  4576. gridLinesF->at(i)->show();
  4577. }
  4578. for(int i= 0;i<gridLinesC->size();i++)
  4579. {
  4580. gridLinesC->at(i)->hide();
  4581. }
  4582. }
  4583. void GraphView::showC()
  4584. {
  4585. for(int i= 0;i<gridLinesF->size();i++)
  4586. {
  4587. gridLinesF->at(i)->hide();
  4588. }
  4589. for(int i= 0;i<gridLinesC->size();i++)
  4590. {
  4591. gridLinesC->at(i)->show();
  4592. }
  4593. }
  4594. /*:402*//*404:*/
  4595. #line 9086 "./typica.w"
  4596. void GraphView::resizeEvent(QResizeEvent*)
  4597. {
  4598. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4599. }
  4600. /*:404*//*405:*/
  4601. #line 9100 "./typica.w"
  4602. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4603. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4604. {
  4605. double offset= 0;
  4606. if(measure.contains("relative"))
  4607. {
  4608. if(measure.value("relative").toBool())
  4609. {
  4610. if(relativeEnabled)
  4611. {
  4612. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4613. }
  4614. else
  4615. {
  4616. return;
  4617. }
  4618. }
  4619. }
  4620. if(translations->contains(tempcolumn))
  4621. {
  4622. offset= translations->value(tempcolumn);
  4623. }
  4624. if(prevPoints->contains(tempcolumn))
  4625. {
  4626. /*407:*/
  4627. #line 9177 "./typica.w"
  4628. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4629. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4630. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4631. -(prevPoints->value(tempcolumn).y()),
  4632. nextPoint.x()+offset,-(nextPoint.y()));
  4633. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4634. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4635. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4636. Qt::darkYellow};
  4637. segment->setPen(p[tempcolumn%12]);
  4638. theScene->addItem(segment);
  4639. prevPoints->insert(tempcolumn,nextPoint);
  4640. if(timeIndicatorEnabled)
  4641. {
  4642. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4643. }
  4644. /*:407*/
  4645. #line 9126 "./typica.w"
  4646. if(graphLines->contains(tempcolumn))
  4647. {
  4648. graphLines->value(tempcolumn)->append(segment);
  4649. }
  4650. else
  4651. {
  4652. QList<QGraphicsLineItem*> *newLine=
  4653. new QList<QGraphicsLineItem*> ;
  4654. newLine->append(segment);
  4655. graphLines->insert(tempcolumn,newLine);
  4656. }
  4657. }
  4658. else
  4659. {
  4660. /*406:*/
  4661. #line 9162 "./typica.w"
  4662. int x= FULLTIMETOINT(measure.time())/1000;
  4663. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4664. if(timeIndicatorEnabled)
  4665. {
  4666. timeLine->setLine(x,0,x,-500);
  4667. }
  4668. /*:406*/
  4669. #line 9143 "./typica.w"
  4670. }
  4671. }
  4672. /*:405*//*408:*/
  4673. #line 9198 "./typica.w"
  4674. void GraphView::clear()
  4675. {
  4676. int i;
  4677. foreach(i,prevPoints->keys())
  4678. {
  4679. removeSeries(i);
  4680. }
  4681. translations->clear();
  4682. }
  4683. /*:408*//*409:*/
  4684. #line 9212 "./typica.w"
  4685. void GraphView::removeSeries(int column)
  4686. {
  4687. if(graphLines->contains(column))
  4688. {
  4689. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4690. QGraphicsLineItem*segment;
  4691. foreach(segment,*series)
  4692. {
  4693. theScene->removeItem(segment);
  4694. }
  4695. qDeleteAll(*series);
  4696. }
  4697. graphLines->remove(column);
  4698. prevPoints->remove(column);
  4699. }
  4700. /*:409*//*410:*/
  4701. #line 9231 "./typica.w"
  4702. void GraphView::setSeriesTranslation(int column,double offset)
  4703. {
  4704. if(graphLines->contains(column))
  4705. {
  4706. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4707. QGraphicsLineItem*segment;
  4708. foreach(segment,*series)
  4709. {
  4710. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4711. }
  4712. }
  4713. if(translations->contains(column))
  4714. {
  4715. translations->insert(column,offset+translations->value(column));
  4716. }
  4717. else
  4718. {
  4719. translations->insert(column,offset);
  4720. }
  4721. }
  4722. /*:410*//*411:*/
  4723. #line 9258 "./typica.w"
  4724. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4725. {
  4726. timeIndicatorEnabled= enabled;
  4727. if(enabled)
  4728. {
  4729. timeLine->show();
  4730. }
  4731. else
  4732. {
  4733. timeLine->hide();
  4734. }
  4735. }
  4736. /*:411*/
  4737. #line 551 "./typica.w"
  4738. /*417:*/
  4739. #line 9405 "./typica.w"
  4740. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4741. {
  4742. if(measure.time()!=QTime(0,0,0,0))
  4743. {
  4744. /*419:*/
  4745. #line 9479 "./typica.w"
  4746. if(lastMeasurement.contains(tempcolumn))
  4747. {
  4748. if(lastMeasurement[tempcolumn].time()<measure.time())
  4749. {
  4750. QList<QTime> timelist;
  4751. QList<double> templist;
  4752. QTime z= QTime(0,0,0,0);
  4753. double ptime= (double)(z.secsTo(lastMeasurement[tempcolumn].time()));
  4754. double ptemp= lastMeasurement[tempcolumn].temperature();
  4755. double ctime= (double)(z.secsTo(measure.time()));
  4756. double ctemp= measure.temperature();
  4757. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4758. {
  4759. timelist.append(i);
  4760. double v= ((ptemp*(ctime-z.secsTo(i)))+(ctemp*(z.secsTo(i)-ptime)))/(ctime-ptime);
  4761. templist.append(v);
  4762. }
  4763. for(int i= 0;i<timelist.size();i++)
  4764. {
  4765. Measurement synthesized= measure;
  4766. synthesized.setTime(timelist[i]);
  4767. synthesized.setTemperature(templist[i]);
  4768. newMeasurement(synthesized,tempcolumn);
  4769. }
  4770. }
  4771. }
  4772. /*:419*/
  4773. #line 9410 "./typica.w"
  4774. }
  4775. model_ms->newMeasurement(measure,tempcolumn);
  4776. if(lastMeasurement.contains(tempcolumn))
  4777. {
  4778. if(measure.time().second()!=
  4779. lastMeasurement.value(tempcolumn).time().second())
  4780. {
  4781. Measurement adjusted= measure;
  4782. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4783. adjusted.setTime(adjtime);
  4784. model_1s->newMeasurement(adjusted,tempcolumn);
  4785. if(adjusted.time().second()%5==0)
  4786. {
  4787. model_5s->newMeasurement(adjusted,tempcolumn);
  4788. if(adjusted.time().second()%10==0)
  4789. {
  4790. model_10s->newMeasurement(adjusted,tempcolumn);
  4791. }
  4792. if(adjusted.time().second()%15==0)
  4793. {
  4794. model_15s->newMeasurement(adjusted,tempcolumn);
  4795. if(adjusted.time().second()%30==0)
  4796. {
  4797. model_30s->newMeasurement(adjusted,tempcolumn);
  4798. if(adjusted.time().second()==0)
  4799. {
  4800. model_1m->newMeasurement(adjusted,tempcolumn);
  4801. }
  4802. }
  4803. }
  4804. }
  4805. }
  4806. /*421:*/
  4807. #line 9532 "./typica.w"
  4808. if(currentColumnSet.contains(tempcolumn))
  4809. {
  4810. int replicationcolumn;
  4811. foreach(replicationcolumn,currentColumnSet)
  4812. {
  4813. if(replicationcolumn!=tempcolumn)
  4814. {
  4815. if(lastMeasurement.contains(replicationcolumn))
  4816. {
  4817. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4818. {
  4819. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4820. synthetic.setTime(measure.time());
  4821. model_ms->newMeasurement(synthetic,replicationcolumn);
  4822. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4823. {
  4824. Measurement adjusted= synthetic;
  4825. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4826. model_1s->newMeasurement(adjusted,replicationcolumn);
  4827. if(adjusted.time().second()%5==0)
  4828. {
  4829. model_5s->newMeasurement(adjusted,replicationcolumn);
  4830. if(adjusted.time().second()%10==0)
  4831. {
  4832. model_10s->newMeasurement(adjusted,replicationcolumn);
  4833. }
  4834. if(adjusted.time().second()%15==0)
  4835. {
  4836. model_15s->newMeasurement(adjusted,replicationcolumn);
  4837. if(adjusted.time().second()%30==0)
  4838. {
  4839. model_30s->newMeasurement(adjusted,replicationcolumn);
  4840. if(adjusted.time().second()==0)
  4841. {
  4842. model_1m->newMeasurement(adjusted,replicationcolumn);
  4843. }
  4844. }
  4845. }
  4846. }
  4847. }
  4848. lastMeasurement[replicationcolumn]= synthetic;
  4849. }
  4850. }
  4851. }
  4852. }
  4853. }
  4854. /*:421*/
  4855. #line 9443 "./typica.w"
  4856. }
  4857. else
  4858. {
  4859. /*418:*/
  4860. #line 9455 "./typica.w"
  4861. MeasurementModel*m;
  4862. foreach(m,modelSet)
  4863. {
  4864. m->newMeasurement(measure,tempcolumn);
  4865. }
  4866. /*:418*/
  4867. #line 9447 "./typica.w"
  4868. }
  4869. lastMeasurement.insert(tempcolumn,measure);
  4870. }
  4871. /*:417*//*420:*/
  4872. #line 9518 "./typica.w"
  4873. void ZoomLog::addToCurrentColumnSet(int column)
  4874. {
  4875. currentColumnSet.append(column);
  4876. }
  4877. void ZoomLog::clearCurrentColumnSet()
  4878. {
  4879. currentColumnSet.clear();
  4880. }
  4881. /*:420*//*422:*/
  4882. #line 9602 "./typica.w"
  4883. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4884. int annotationcolumn)
  4885. {
  4886. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4887. MeasurementModel*m;
  4888. if(lastMeasurement.contains(tempcolumn))
  4889. {
  4890. foreach(m,modelSet)
  4891. {
  4892. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4893. }
  4894. }
  4895. foreach(m,modelSet)
  4896. {
  4897. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4898. }
  4899. }
  4900. /*:422*//*423:*/
  4901. #line 9626 "./typica.w"
  4902. void ZoomLog::centerOn(int row)
  4903. {
  4904. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4905. }
  4906. /*:423*//*424:*/
  4907. #line 9636 "./typica.w"
  4908. void ZoomLog::clear()
  4909. {
  4910. MeasurementModel*m;
  4911. foreach(m,modelSet)
  4912. {
  4913. m->clear();
  4914. }
  4915. lastMeasurement.clear();
  4916. saveTempCols.clear();
  4917. saveControlCols.clear();
  4918. saveNoteCols.clear();
  4919. }
  4920. /*:424*//*425:*/
  4921. #line 9654 "./typica.w"
  4922. QVariant ZoomLog::data(int row,int column)const
  4923. {
  4924. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4925. Qt::DisplayRole);
  4926. }
  4927. int ZoomLog::rowCount()
  4928. {
  4929. return model_ms->rowCount();
  4930. }
  4931. /*:425*//*426:*/
  4932. #line 9677 "./typica.w"
  4933. bool ZoomLog::saveXML(QIODevice*device)
  4934. {
  4935. Units::Unit prevUnits= model_ms->displayUnits();
  4936. if(prevUnits!=Units::Fahrenheit)
  4937. {
  4938. model_ms->setDisplayUnits(Units::Fahrenheit);
  4939. }
  4940. XMLOutput writer(model_ms,device,0);
  4941. int c;
  4942. foreach(c,saveTempCols)
  4943. {
  4944. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4945. toString(),c);
  4946. }
  4947. foreach(c,saveControlCols)
  4948. {
  4949. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4950. toString(),c);
  4951. }
  4952. foreach(c,saveNoteCols)
  4953. {
  4954. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4955. toString(),c);
  4956. }
  4957. bool retval= writer.output();
  4958. if(prevUnits!=Units::Fahrenheit)
  4959. {
  4960. model_ms->setDisplayUnits(prevUnits);
  4961. }
  4962. return retval;
  4963. }
  4964. /*:426*//*427:*/
  4965. #line 9713 "./typica.w"
  4966. bool ZoomLog::saveCSV(QIODevice*device)
  4967. {
  4968. CSVOutput writer(currentModel,device,0);
  4969. int c;
  4970. foreach(c,saveTempCols)
  4971. {
  4972. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4973. toString(),c);
  4974. }
  4975. foreach(c,saveControlCols)
  4976. {
  4977. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4978. toString(),c);
  4979. }
  4980. foreach(c,saveNoteCols)
  4981. {
  4982. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4983. toString(),c);
  4984. }
  4985. return writer.output();
  4986. }
  4987. /*:427*//*428:*/
  4988. #line 9742 "./typica.w"
  4989. void ZoomLog::switchLOD(MeasurementModel*m)
  4990. {
  4991. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4992. setModel(m);
  4993. currentModel= m;
  4994. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4995. }
  4996. void ZoomLog::LOD_ms()
  4997. {
  4998. switchLOD(model_ms);
  4999. }
  5000. void ZoomLog::LOD_1s()
  5001. {
  5002. switchLOD(model_1s);
  5003. }
  5004. void ZoomLog::LOD_5s()
  5005. {
  5006. switchLOD(model_5s);
  5007. }
  5008. void ZoomLog::LOD_10s()
  5009. {
  5010. switchLOD(model_10s);
  5011. }
  5012. void ZoomLog::LOD_15s()
  5013. {
  5014. switchLOD(model_15s);
  5015. }
  5016. void ZoomLog::LOD_30s()
  5017. {
  5018. switchLOD(model_30s);
  5019. }
  5020. void ZoomLog::LOD_1m()
  5021. {
  5022. switchLOD(model_1m);
  5023. }
  5024. /*:428*//*429:*/
  5025. #line 9790 "./typica.w"
  5026. void ZoomLog::setDisplayUnits(Units::Unit scale)
  5027. {
  5028. model_ms->setDisplayUnits(scale);
  5029. model_1s->setDisplayUnits(scale);
  5030. model_5s->setDisplayUnits(scale);
  5031. model_10s->setDisplayUnits(scale);
  5032. model_15s->setDisplayUnits(scale);
  5033. model_30s->setDisplayUnits(scale);
  5034. model_1m->setDisplayUnits(scale);
  5035. }
  5036. Units::Unit ZoomLog::displayUnits()
  5037. {
  5038. return model_ms->displayUnits();
  5039. }
  5040. /*:429*//*430:*/
  5041. #line 9810 "./typica.w"
  5042. QString ZoomLog::lastTime(int series)
  5043. {
  5044. Measurement measure= lastMeasurement.value(series);
  5045. QTime time= measure.time();
  5046. return time.toString("h:mm:ss.zzz");
  5047. }
  5048. /*:430*//*431:*/
  5049. #line 9820 "./typica.w"
  5050. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  5051. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  5052. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  5053. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  5054. {
  5055. setEditTriggers(QAbstractItemView::NoEditTriggers);
  5056. setSelectionMode(QAbstractItemView::NoSelection);
  5057. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  5058. model_30s<<model_1m;
  5059. currentModel= model_30s;
  5060. setModel(currentModel);
  5061. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  5062. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  5063. this,SLOT(persistColumnResize(int,int,int)));
  5064. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  5065. this,SLOT(restoreColumnWidths()));
  5066. }
  5067. /*:431*//*432:*/
  5068. #line 9843 "./typica.w"
  5069. void ZoomLog::setHeaderData(int section,QString text)
  5070. {
  5071. MeasurementModel*m;
  5072. foreach(m,modelSet)
  5073. {
  5074. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  5075. }
  5076. }
  5077. /*:432*//*433:*/
  5078. #line 9861 "./typica.w"
  5079. void ZoomLog::addOutputTemperatureColumn(int column)
  5080. {
  5081. saveTempCols.append(column);
  5082. }
  5083. void ZoomLog::addOutputControlColumn(int column)
  5084. {
  5085. saveControlCols.append(column);
  5086. }
  5087. void ZoomLog::addOutputAnnotationColumn(int column)
  5088. {
  5089. saveNoteCols.append(column);
  5090. }
  5091. void ZoomLog::clearOutputColumns()
  5092. {
  5093. saveTempCols.clear();
  5094. saveControlCols.clear();
  5095. saveNoteCols.clear();
  5096. }
  5097. /*:433*//*434:*/
  5098. #line 9887 "./typica.w"
  5099. void ZoomLog::persistColumnResize(int column,int,int newsize)
  5100. {
  5101. /*668:*/
  5102. #line 14233 "./typica.w"
  5103. QSettings settings;
  5104. /*669:*/
  5105. #line 14246 "./typica.w"
  5106. QWidget*topLevelWidget= this;
  5107. while(topLevelWidget->parentWidget())
  5108. {
  5109. topLevelWidget= topLevelWidget->parentWidget();
  5110. }
  5111. /*:669*/
  5112. #line 14235 "./typica.w"
  5113. settings.setValue(QString("columnWidths/%1/%2/%3").
  5114. arg(topLevelWidget->objectName()).
  5115. arg(objectName()).arg(column),
  5116. QVariant(newsize));
  5117. /*:668*/
  5118. #line 9890 "./typica.w"
  5119. }
  5120. void ZoomLog::restoreColumnWidths()
  5121. {
  5122. /*671:*/
  5123. #line 14266 "./typica.w"
  5124. QSettings settings;
  5125. /*669:*/
  5126. #line 14246 "./typica.w"
  5127. QWidget*topLevelWidget= this;
  5128. while(topLevelWidget->parentWidget())
  5129. {
  5130. topLevelWidget= topLevelWidget->parentWidget();
  5131. }
  5132. /*:669*/
  5133. #line 14268 "./typica.w"
  5134. QString baseKey=
  5135. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5136. arg(objectName());
  5137. for(int i= 0;i<model()->columnCount();i++)
  5138. {
  5139. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5140. if(settings.contains(key))
  5141. {
  5142. setColumnWidth(i,settings.value(key).toInt());
  5143. }
  5144. }
  5145. /*:671*/
  5146. #line 9895 "./typica.w"
  5147. }
  5148. void ZoomLog::setVisible(bool visibility)
  5149. {
  5150. QTableView::setVisible(visibility);
  5151. }
  5152. void ZoomLog::showEvent(QShowEvent*)
  5153. {
  5154. /*671:*/
  5155. #line 14266 "./typica.w"
  5156. QSettings settings;
  5157. /*669:*/
  5158. #line 14246 "./typica.w"
  5159. QWidget*topLevelWidget= this;
  5160. while(topLevelWidget->parentWidget())
  5161. {
  5162. topLevelWidget= topLevelWidget->parentWidget();
  5163. }
  5164. /*:669*/
  5165. #line 14268 "./typica.w"
  5166. QString baseKey=
  5167. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5168. arg(objectName());
  5169. for(int i= 0;i<model()->columnCount();i++)
  5170. {
  5171. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5172. if(settings.contains(key))
  5173. {
  5174. setColumnWidth(i,settings.value(key).toInt());
  5175. }
  5176. }
  5177. /*:671*/
  5178. #line 9905 "./typica.w"
  5179. }
  5180. /*:434*/
  5181. #line 552 "./typica.w"
  5182. /*443:*/
  5183. #line 10138 "./typica.w"
  5184. bool MeasurementList::operator<(const MeasurementList&other)const
  5185. {
  5186. return this->first().toTime()<other.first().toTime();
  5187. }
  5188. bool MeasurementList::operator==(const MeasurementList&other)const
  5189. {
  5190. return this->first().toTime()==other.first().toTime();
  5191. }
  5192. /*:443*//*444:*/
  5193. #line 10154 "./typica.w"
  5194. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  5195. {
  5196. return QModelIndex();
  5197. }
  5198. /*:444*//*445:*/
  5199. #line 10164 "./typica.w"
  5200. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  5201. {
  5202. if(measure.scale()==Units::Unitless)
  5203. {
  5204. controlColumns->insert(tempcolumn,true);
  5205. }
  5206. else
  5207. {
  5208. controlColumns->insert(tempcolumn,false);
  5209. }
  5210. MeasurementList*temp;
  5211. temp= new MeasurementList;
  5212. temp->append(QVariant(measure.time()));
  5213. /*446:*/
  5214. #line 10223 "./typica.w"
  5215. /*447:*/
  5216. #line 10268 "./typica.w"
  5217. QList<MeasurementList*> ::iterator i= lastInsertion;
  5218. bool quickscan= false;
  5219. if(entries->size()> 5)
  5220. {
  5221. if(**i<*temp)
  5222. {
  5223. i+= 1;
  5224. for(int j= 10;j> 0;j--)
  5225. {
  5226. if(i!=entries->end())
  5227. {
  5228. if(**i<*temp)
  5229. {
  5230. i+= 1;
  5231. }
  5232. else
  5233. {
  5234. quickscan= true;
  5235. break;
  5236. }
  5237. }
  5238. else
  5239. {
  5240. quickscan= true;
  5241. break;
  5242. }
  5243. }
  5244. }
  5245. else
  5246. {
  5247. if(**i==*temp)
  5248. {
  5249. quickscan= true;
  5250. }
  5251. }
  5252. }
  5253. /*:447*/
  5254. #line 10224 "./typica.w"
  5255. if(quickscan==false)
  5256. {
  5257. i= entries->begin();
  5258. QList<MeasurementList*> ::iterator u= entries->end();
  5259. QList<MeasurementList*> ::iterator midpoint;
  5260. int n= u-i;
  5261. int rA;
  5262. while(n> 0)
  5263. {
  5264. rA= n>>1;
  5265. midpoint= i+rA;
  5266. if(**midpoint<*temp)
  5267. {
  5268. i= midpoint+1;
  5269. n-= rA+1;
  5270. }
  5271. else
  5272. {
  5273. n= rA;
  5274. }
  5275. }
  5276. }
  5277. /*:446*/
  5278. #line 10178 "./typica.w"
  5279. MeasurementList*newEntry;
  5280. int insertion;
  5281. if(i!=entries->end())
  5282. {
  5283. insertion= entries->indexOf(*i);
  5284. if((*i)->first().toTime()==measure.time())
  5285. {
  5286. /*448:*/
  5287. #line 10310 "./typica.w"
  5288. if((*i)->size()<tempcolumn+1)
  5289. {
  5290. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  5291. {
  5292. (*i)->append(QVariant());
  5293. }
  5294. }
  5295. (*i)->replace(tempcolumn,measure);
  5296. lastInsertion= i;
  5297. emit dataChanged(createIndex(insertion,tempcolumn),
  5298. createIndex(insertion,tempcolumn));
  5299. lastTemperature->insert(tempcolumn,insertion);
  5300. /*:448*/
  5301. #line 10186 "./typica.w"
  5302. }
  5303. else
  5304. {
  5305. /*449:*/
  5306. #line 10328 "./typica.w"
  5307. beginInsertRows(QModelIndex(),insertion,insertion);
  5308. newEntry= new MeasurementList;
  5309. newEntry->append(QVariant(measure.time()));
  5310. for(int j= 0;j<tempcolumn+1;j++)
  5311. {
  5312. newEntry->append(QVariant());
  5313. }
  5314. newEntry->replace(tempcolumn,measure);
  5315. lastInsertion= entries->insert(i,newEntry);
  5316. endInsertRows();
  5317. lastTemperature->insert(tempcolumn,insertion);
  5318. /*:449*/
  5319. #line 10190 "./typica.w"
  5320. }
  5321. }
  5322. else
  5323. {
  5324. /*450:*/
  5325. #line 10346 "./typica.w"
  5326. insertion= entries->size();
  5327. /*449:*/
  5328. #line 10328 "./typica.w"
  5329. beginInsertRows(QModelIndex(),insertion,insertion);
  5330. newEntry= new MeasurementList;
  5331. newEntry->append(QVariant(measure.time()));
  5332. for(int j= 0;j<tempcolumn+1;j++)
  5333. {
  5334. newEntry->append(QVariant());
  5335. }
  5336. newEntry->replace(tempcolumn,measure);
  5337. lastInsertion= entries->insert(i,newEntry);
  5338. endInsertRows();
  5339. lastTemperature->insert(tempcolumn,insertion);
  5340. /*:449*/
  5341. #line 10348 "./typica.w"
  5342. /*:450*/
  5343. #line 10195 "./typica.w"
  5344. }
  5345. if(tempcolumn>=colcount)
  5346. {
  5347. colcount= tempcolumn+1;
  5348. }
  5349. emit rowChanged(insertion);
  5350. delete temp;
  5351. }
  5352. /*:445*//*451:*/
  5353. #line 10358 "./typica.w"
  5354. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  5355. int annotationColumn)
  5356. {
  5357. int r;
  5358. if(lastTemperature->contains(tempcolumn))
  5359. {
  5360. r= lastTemperature->value(tempcolumn);
  5361. }
  5362. else
  5363. {
  5364. r= 0;
  5365. }
  5366. if(r==0&&entries->size()==0)
  5367. {
  5368. /*452:*/
  5369. #line 10396 "./typica.w"
  5370. beginInsertRows(QModelIndex(),0,0);
  5371. MeasurementList*newEntry= new MeasurementList;
  5372. newEntry->append(QVariant(QTime(0,0,0,0)));
  5373. entries->append(newEntry);
  5374. endInsertRows();
  5375. /*:452*/
  5376. #line 10373 "./typica.w"
  5377. }
  5378. MeasurementList*row= entries->at(r);
  5379. if(row->size()<=annotationColumn)
  5380. {
  5381. for(int i= row->size()-1;i<annotationColumn+1;i++)
  5382. {
  5383. row->append(QVariant());
  5384. }
  5385. }
  5386. row->replace(annotationColumn,annotation);
  5387. emit dataChanged(createIndex(r,annotationColumn),
  5388. createIndex(r,annotationColumn));
  5389. emit rowChanged(r);
  5390. if(annotationColumn> colcount-1)
  5391. {
  5392. colcount= annotationColumn+1;
  5393. }
  5394. }
  5395. /*:451*//*453:*/
  5396. #line 10407 "./typica.w"
  5397. void MeasurementModel::clear()
  5398. {
  5399. beginRemoveRows(QModelIndex(),0,entries->size());
  5400. while(entries->size()!=0)
  5401. {
  5402. MeasurementList*row= entries->takeFirst();
  5403. delete row;
  5404. }
  5405. endRemoveRows();
  5406. colcount= hData->size();
  5407. lastTemperature->clear();
  5408. reset();
  5409. }
  5410. /*:453*//*454:*/
  5411. #line 10440 "./typica.w"
  5412. bool MeasurementModel::setData(const QModelIndex&index,
  5413. const QVariant&value,int role)
  5414. {
  5415. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  5416. {
  5417. return false;
  5418. }
  5419. /*455:*/
  5420. #line 10472 "./typica.w"
  5421. bool valid= false;
  5422. if(index.isValid())
  5423. {
  5424. if(index.row()<entries->size())
  5425. {
  5426. if(index.column()<colcount)
  5427. {
  5428. valid= true;
  5429. }
  5430. }
  5431. }
  5432. /*:455*/
  5433. #line 10448 "./typica.w"
  5434. if(!valid)
  5435. {
  5436. return false;
  5437. }
  5438. MeasurementList*row= entries->at(index.row());
  5439. if(index.column()>=row->size())
  5440. {
  5441. /*456:*/
  5442. #line 10489 "./typica.w"
  5443. for(int i= row->size()-1;i<index.column();i++)
  5444. {
  5445. row->append(QVariant());
  5446. }
  5447. /*:456*/
  5448. #line 10456 "./typica.w"
  5449. }
  5450. if(index.column()==0)
  5451. {
  5452. /*457:*/
  5453. #line 10504 "./typica.w"
  5454. QTime time;
  5455. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5456. {
  5457. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5458. {
  5459. return false;
  5460. }
  5461. }
  5462. row= entries->takeAt(index.row());
  5463. row->replace(index.column(),QVariant(time));
  5464. MeasurementList*temp= row;
  5465. /*446:*/
  5466. #line 10223 "./typica.w"
  5467. /*447:*/
  5468. #line 10268 "./typica.w"
  5469. QList<MeasurementList*> ::iterator i= lastInsertion;
  5470. bool quickscan= false;
  5471. if(entries->size()> 5)
  5472. {
  5473. if(**i<*temp)
  5474. {
  5475. i+= 1;
  5476. for(int j= 10;j> 0;j--)
  5477. {
  5478. if(i!=entries->end())
  5479. {
  5480. if(**i<*temp)
  5481. {
  5482. i+= 1;
  5483. }
  5484. else
  5485. {
  5486. quickscan= true;
  5487. break;
  5488. }
  5489. }
  5490. else
  5491. {
  5492. quickscan= true;
  5493. break;
  5494. }
  5495. }
  5496. }
  5497. else
  5498. {
  5499. if(**i==*temp)
  5500. {
  5501. quickscan= true;
  5502. }
  5503. }
  5504. }
  5505. /*:447*/
  5506. #line 10224 "./typica.w"
  5507. if(quickscan==false)
  5508. {
  5509. i= entries->begin();
  5510. QList<MeasurementList*> ::iterator u= entries->end();
  5511. QList<MeasurementList*> ::iterator midpoint;
  5512. int n= u-i;
  5513. int rA;
  5514. while(n> 0)
  5515. {
  5516. rA= n>>1;
  5517. midpoint= i+rA;
  5518. if(**midpoint<*temp)
  5519. {
  5520. i= midpoint+1;
  5521. n-= rA+1;
  5522. }
  5523. else
  5524. {
  5525. n= rA;
  5526. }
  5527. }
  5528. }
  5529. /*:446*/
  5530. #line 10516 "./typica.w"
  5531. entries->insert(i,row);
  5532. int newRow= entries->indexOf(*i);
  5533. if(newRow<index.row())
  5534. {
  5535. emit dataChanged(createIndex(newRow,index.column()),index);
  5536. }
  5537. else
  5538. {
  5539. emit dataChanged(index,createIndex(newRow,index.column()));
  5540. }
  5541. /*:457*/
  5542. #line 10460 "./typica.w"
  5543. }
  5544. else
  5545. {
  5546. /*458:*/
  5547. #line 10530 "./typica.w"
  5548. row->replace(index.column(),value);
  5549. emit dataChanged(index,index);
  5550. /*:458*/
  5551. #line 10464 "./typica.w"
  5552. }
  5553. return true;
  5554. }
  5555. /*:454*//*459:*/
  5556. #line 10538 "./typica.w"
  5557. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5558. unit(Units::Fahrenheit),hData(new QStringList),
  5559. lastTemperature(new QHash<int,int> ),
  5560. controlColumns(new QHash<int,bool> )
  5561. {
  5562. colcount= 1;
  5563. entries= new QList<MeasurementList*> ;
  5564. lastInsertion= entries->begin();
  5565. hData->append(tr("Time"));
  5566. }
  5567. /*:459*//*460:*/
  5568. #line 10552 "./typica.w"
  5569. MeasurementModel::~MeasurementModel()
  5570. {
  5571. clear();
  5572. delete entries;
  5573. delete hData;
  5574. }
  5575. /*:460*//*461:*/
  5576. #line 10564 "./typica.w"
  5577. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5578. {
  5579. if(parent==QModelIndex())
  5580. {
  5581. return entries->size();
  5582. }
  5583. return 0;
  5584. }
  5585. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5586. {
  5587. if(parent==QModelIndex())
  5588. {
  5589. return colcount;
  5590. }
  5591. return 0;
  5592. }
  5593. /*:461*//*462:*/
  5594. #line 10591 "./typica.w"
  5595. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5596. const QVariant&value,int)
  5597. {
  5598. if(orientation==Qt::Horizontal)
  5599. {
  5600. if(hData->size()<section+1)
  5601. {
  5602. for(int i= hData->size();i<section+1;i++)
  5603. {
  5604. if(colcount<i)
  5605. {
  5606. beginInsertColumns(QModelIndex(),i,i);
  5607. }
  5608. hData->append(QString());
  5609. if(colcount<i)
  5610. {
  5611. endInsertColumns();
  5612. }
  5613. }
  5614. }
  5615. hData->replace(section,value.toString());
  5616. emit headerDataChanged(orientation,section,section);
  5617. if(colcount<section+1)
  5618. {
  5619. colcount= section+1;
  5620. }
  5621. return true;
  5622. }
  5623. return false;
  5624. }
  5625. /*:462*//*463:*/
  5626. #line 10631 "./typica.w"
  5627. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5628. {
  5629. beginResetModel();
  5630. unit= scale;
  5631. endResetModel();
  5632. }
  5633. Units::Unit MeasurementModel::displayUnits()
  5634. {
  5635. return unit;
  5636. }
  5637. /*:463*//*464:*/
  5638. #line 10657 "./typica.w"
  5639. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5640. {
  5641. /*455:*/
  5642. #line 10472 "./typica.w"
  5643. bool valid= false;
  5644. if(index.isValid())
  5645. {
  5646. if(index.row()<entries->size())
  5647. {
  5648. if(index.column()<colcount)
  5649. {
  5650. valid= true;
  5651. }
  5652. }
  5653. }
  5654. /*:455*/
  5655. #line 10660 "./typica.w"
  5656. if(!valid)
  5657. {
  5658. return QVariant();
  5659. }
  5660. MeasurementList*row= entries->at(index.row());
  5661. if(role==Qt::UserRole)
  5662. {
  5663. return QVariant(row->at(index.column()));
  5664. }
  5665. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5666. {
  5667. if(index.column()> row->size())
  5668. {
  5669. return QVariant();
  5670. }
  5671. else
  5672. {
  5673. if(index.column()==0)
  5674. {
  5675. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5676. }
  5677. else if(lastTemperature->contains(index.column()))
  5678. {
  5679. QVariantMap v= row->at(index.column()).toMap();
  5680. if(!v.contains("measurement"))
  5681. {
  5682. return QVariant();
  5683. }
  5684. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5685. {
  5686. return v.value("measurement");
  5687. }
  5688. else
  5689. {
  5690. if(v.contains("relative"))
  5691. {
  5692. if(v.value("relative").toBool())
  5693. {
  5694. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5695. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5696. }
  5697. }
  5698. return QVariant(QString("%1").
  5699. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5700. (Units::Unit)(v.value("unit").toInt()),unit)));
  5701. }
  5702. }
  5703. return QVariant(row->at(index.column()).toString());
  5704. }
  5705. }
  5706. return QVariant();
  5707. }
  5708. /*:464*//*465:*/
  5709. #line 10716 "./typica.w"
  5710. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5711. int role)const
  5712. {
  5713. if(orientation==Qt::Horizontal)
  5714. {
  5715. if(role==Qt::DisplayRole)
  5716. {
  5717. if(section<hData->size())
  5718. {
  5719. return QVariant(hData->at(section));
  5720. }
  5721. }
  5722. }
  5723. return QVariant();
  5724. }
  5725. /*:465*//*466:*/
  5726. #line 10743 "./typica.w"
  5727. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5728. {
  5729. /*455:*/
  5730. #line 10472 "./typica.w"
  5731. bool valid= false;
  5732. if(index.isValid())
  5733. {
  5734. if(index.row()<entries->size())
  5735. {
  5736. if(index.column()<colcount)
  5737. {
  5738. valid= true;
  5739. }
  5740. }
  5741. }
  5742. /*:455*/
  5743. #line 10746 "./typica.w"
  5744. if(valid)
  5745. {
  5746. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5747. }
  5748. return 0;
  5749. }
  5750. /*:466*//*467:*/
  5751. #line 10758 "./typica.w"
  5752. QModelIndex MeasurementModel::index(int row,int column,
  5753. const QModelIndex&parent)const
  5754. {
  5755. if(parent==QModelIndex())
  5756. {
  5757. if(row<entries->size()&&entries->isEmpty()==false)
  5758. {
  5759. if(column<entries->at(row)->size())
  5760. {
  5761. return createIndex(row,column);
  5762. }
  5763. }
  5764. }
  5765. return QModelIndex();
  5766. }
  5767. /*:467*/
  5768. #line 553 "./typica.w"
  5769. /*469:*/
  5770. #line 10813 "./typica.w"
  5771. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5772. QPushButton(text,parent),noteTemplate(""),note(""),tc(0),ac(0),
  5773. count(0),batch("A")
  5774. {
  5775. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5776. }
  5777. /*:469*//*470:*/
  5778. #line 10829 "./typica.w"
  5779. void AnnotationButton::annotate()
  5780. {
  5781. if(note.contains("%1"))
  5782. {
  5783. count++;
  5784. emit annotation(note.arg(count),tc,ac);
  5785. }
  5786. else
  5787. {
  5788. emit annotation(note,tc,ac);
  5789. }
  5790. }
  5791. /*:470*//*471:*/
  5792. #line 10847 "./typica.w"
  5793. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5794. {
  5795. tc= tempcolumn;
  5796. }
  5797. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5798. {
  5799. ac= annotationcolumn;
  5800. }
  5801. void AnnotationButton::setAnnotation(const QString&annotation)
  5802. {
  5803. noteTemplate= annotation;
  5804. /*472:*/
  5805. #line 10867 "./typica.w"
  5806. int batchReplace= noteTemplate.indexOf("%A");
  5807. if(batchReplace>=0)
  5808. {
  5809. QString temp= noteTemplate;
  5810. note= temp.replace(batchReplace,2,batch);
  5811. }
  5812. else
  5813. {
  5814. note= noteTemplate;
  5815. }
  5816. /*:472*/
  5817. #line 10861 "./typica.w"
  5818. }
  5819. /*:471*//*473:*/
  5820. #line 10882 "./typica.w"
  5821. void AnnotationButton::resetCount()
  5822. {
  5823. count= 0;
  5824. }
  5825. void AnnotationButton::resetBatch()
  5826. {
  5827. batch= "A";
  5828. /*472:*/
  5829. #line 10867 "./typica.w"
  5830. int batchReplace= noteTemplate.indexOf("%A");
  5831. if(batchReplace>=0)
  5832. {
  5833. QString temp= noteTemplate;
  5834. note= temp.replace(batchReplace,2,batch);
  5835. }
  5836. else
  5837. {
  5838. note= noteTemplate;
  5839. }
  5840. /*:472*/
  5841. #line 10891 "./typica.w"
  5842. }
  5843. /*:473*//*474:*/
  5844. #line 10897 "./typica.w"
  5845. void AnnotationButton::incrementBatch()
  5846. {
  5847. int position= batch.size()-1;
  5848. increment:
  5849. if(batch[position]!='Z')
  5850. {
  5851. batch[position]= batch[position].unicode()+1;
  5852. }
  5853. else
  5854. {
  5855. batch[position]= 'A';
  5856. if(position> 0)
  5857. {
  5858. position--;
  5859. goto increment;
  5860. }
  5861. else
  5862. {
  5863. batch.append("A");
  5864. }
  5865. }
  5866. /*472:*/
  5867. #line 10867 "./typica.w"
  5868. int batchReplace= noteTemplate.indexOf("%A");
  5869. if(batchReplace>=0)
  5870. {
  5871. QString temp= noteTemplate;
  5872. note= temp.replace(batchReplace,2,batch);
  5873. }
  5874. else
  5875. {
  5876. note= noteTemplate;
  5877. }
  5878. /*:472*/
  5879. #line 10919 "./typica.w"
  5880. }
  5881. /*:474*/
  5882. #line 554 "./typica.w"
  5883. /*479:*/
  5884. #line 10999 "./typica.w"
  5885. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5886. const QString&postt,
  5887. QWidget*parent)
  5888. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5889. {
  5890. resetChange();
  5891. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5892. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5893. }
  5894. /*:479*//*480:*/
  5895. #line 11016 "./typica.w"
  5896. void AnnotationSpinBox::resetChange()
  5897. {
  5898. change= true;
  5899. }
  5900. /*:480*//*481:*/
  5901. #line 11027 "./typica.w"
  5902. void AnnotationSpinBox::annotate()
  5903. {
  5904. if(change)
  5905. {
  5906. change= false;
  5907. emit annotation(QString("%1%2%3").arg(pretext).
  5908. arg(value()).arg(posttext),tc,ac);
  5909. }
  5910. }
  5911. /*:481*//*482:*/
  5912. #line 11040 "./typica.w"
  5913. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5914. {
  5915. tc= tempcolumn;
  5916. }
  5917. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5918. {
  5919. ac= annotationcolumn;
  5920. }
  5921. void AnnotationSpinBox::setPretext(const QString&pret)
  5922. {
  5923. pretext= pret;
  5924. }
  5925. void AnnotationSpinBox::setPosttext(const QString&postt)
  5926. {
  5927. posttext= postt;
  5928. }
  5929. /*:482*/
  5930. #line 555 "./typica.w"
  5931. /*489:*/
  5932. #line 11209 "./typica.w"
  5933. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5934. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5935. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5936. stopAction(new QAction(tr("Stop"),NULL)),
  5937. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5938. relative(QTime::currentTime()),base(QTime(0,0,0))
  5939. {
  5940. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5941. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5942. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5943. clock.setInterval(500);
  5944. clock.setSingleShot(false);
  5945. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5946. setSegmentStyle(Filled);
  5947. updateDisplay();
  5948. }
  5949. /*:489*//*490:*/
  5950. #line 11230 "./typica.w"
  5951. void TimerDisplay::updateTime()
  5952. {
  5953. QTime time;
  5954. int cseconds= 0;
  5955. int oseconds= 0;
  5956. int r= 0;
  5957. QTime nt= QTime(0,0,0);
  5958. int n= 0;
  5959. int bseconds= 0;
  5960. switch(m)
  5961. {
  5962. case TimerDisplay::CountUp:
  5963. /*491:*/
  5964. #line 11262 "./typica.w"
  5965. /*492:*/
  5966. #line 11275 "./typica.w"
  5967. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5968. time= QTime::currentTime();
  5969. cseconds= TIMETOINT(time);
  5970. oseconds= TIMETOINT(relative);
  5971. r= cseconds-oseconds;
  5972. /*:492*/
  5973. #line 11263 "./typica.w"
  5974. nt= nt.addSecs(r);
  5975. if(nt!=s)
  5976. {
  5977. s= nt;
  5978. emit valueChanged(s);
  5979. }
  5980. /*:491*/
  5981. #line 11243 "./typica.w"
  5982. ;
  5983. break;
  5984. case TimerDisplay::CountDown:
  5985. /*493:*/
  5986. #line 11287 "./typica.w"
  5987. if(s> QTime(0,0,0))
  5988. {
  5989. /*492:*/
  5990. #line 11275 "./typica.w"
  5991. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5992. time= QTime::currentTime();
  5993. cseconds= TIMETOINT(time);
  5994. oseconds= TIMETOINT(relative);
  5995. r= cseconds-oseconds;
  5996. /*:492*/
  5997. #line 11290 "./typica.w"
  5998. bseconds= TIMETOINT(base);
  5999. n= bseconds-r;
  6000. nt= nt.addSecs(n);
  6001. if(nt!=s)
  6002. {
  6003. s= nt;
  6004. emit valueChanged(s);
  6005. }
  6006. }else{
  6007. stopTimer();
  6008. }
  6009. /*:493*/
  6010. #line 11246 "./typica.w"
  6011. ;
  6012. break;
  6013. case TimerDisplay::Clock:
  6014. /*494:*/
  6015. #line 11306 "./typica.w"
  6016. time= QTime::currentTime();
  6017. if(time!=s)
  6018. {
  6019. s= time;
  6020. emit valueChanged(s);
  6021. }
  6022. /*:494*/
  6023. #line 11249 "./typica.w"
  6024. ;
  6025. break;
  6026. default:
  6027. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  6028. break;
  6029. }
  6030. updateDisplay();
  6031. }
  6032. /*:490*//*495:*/
  6033. #line 11318 "./typica.w"
  6034. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  6035. void TimerDisplay::startTimer()
  6036. {
  6037. if(!running)
  6038. {
  6039. relative= QTime::currentTime();
  6040. if(ar)
  6041. {
  6042. reset();
  6043. }
  6044. else
  6045. {
  6046. relative= TIMESUBTRACT(relative,s);
  6047. }
  6048. if(m==Clock)
  6049. {
  6050. updateTime();
  6051. }
  6052. base= s;
  6053. clock.start();
  6054. running= true;
  6055. emit runStateChanged(true);
  6056. }
  6057. }
  6058. /*:495*//*496:*/
  6059. #line 11348 "./typica.w"
  6060. void TimerDisplay::stopTimer()
  6061. {
  6062. if(running)
  6063. {
  6064. clock.stop();
  6065. running= false;
  6066. emit runStateChanged(false);
  6067. }
  6068. }
  6069. /*:496*//*497:*/
  6070. #line 11361 "./typica.w"
  6071. TimerDisplay::~TimerDisplay()
  6072. {
  6073. clock.stop();
  6074. }
  6075. /*:497*//*498:*/
  6076. #line 11370 "./typica.w"
  6077. void TimerDisplay::setCountUpMode()
  6078. {
  6079. m= TimerDisplay::CountUp;
  6080. }
  6081. void TimerDisplay::setCountDownMode()
  6082. {
  6083. m= TimerDisplay::CountDown;
  6084. }
  6085. void TimerDisplay::setClockMode()
  6086. {
  6087. m= TimerDisplay::Clock;
  6088. }
  6089. /*:498*//*499:*/
  6090. #line 11388 "./typica.w"
  6091. QString TimerDisplay::value()
  6092. {
  6093. return s.toString(f);
  6094. }
  6095. QTime TimerDisplay::seconds()
  6096. {
  6097. return s;
  6098. }
  6099. TimerDisplay::TimerMode TimerDisplay::mode()
  6100. {
  6101. return m;
  6102. }
  6103. bool TimerDisplay::isRunning()
  6104. {
  6105. return running;
  6106. }
  6107. QTime TimerDisplay::resetValue()
  6108. {
  6109. return r;
  6110. }
  6111. QString TimerDisplay::displayFormat()
  6112. {
  6113. return f;
  6114. }
  6115. bool TimerDisplay::autoReset()
  6116. {
  6117. return ar;
  6118. }
  6119. /*:499*//*500:*/
  6120. #line 11426 "./typica.w"
  6121. void TimerDisplay::setTimer(QTime value)
  6122. {
  6123. if(value.isValid())
  6124. {
  6125. s= value;
  6126. updateDisplay();
  6127. emit valueChanged(value);
  6128. }
  6129. }
  6130. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  6131. {
  6132. m= mode;
  6133. }
  6134. void TimerDisplay::setResetValue(QTime value)
  6135. {
  6136. r= value;
  6137. }
  6138. void TimerDisplay::setDisplayFormat(QString format)
  6139. {
  6140. f= format;
  6141. setNumDigits(format.length());
  6142. }
  6143. void TimerDisplay::setAutoReset(bool reset)
  6144. {
  6145. ar= reset;
  6146. }
  6147. /*:500*//*501:*/
  6148. #line 11461 "./typica.w"
  6149. void TimerDisplay::copyTimer()
  6150. {
  6151. QApplication::clipboard()->setText(value());
  6152. }
  6153. /*:501*//*502:*/
  6154. #line 11470 "./typica.w"
  6155. void TimerDisplay::reset()
  6156. {
  6157. if(!running)
  6158. {
  6159. s= r;
  6160. updateDisplay();
  6161. }
  6162. }
  6163. /*:502*//*503:*/
  6164. #line 11483 "./typica.w"
  6165. void TimerDisplay::updateDisplay()
  6166. {
  6167. display(value());
  6168. }
  6169. /*:503*/
  6170. #line 556 "./typica.w"
  6171. /*510:*/
  6172. #line 11608 "./typica.w"
  6173. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  6174. {
  6175. int x= rect.x();
  6176. int y= rect.y();
  6177. QLayoutItem*item;
  6178. if(orientation==Qt::Horizontal)
  6179. {
  6180. /*511:*/
  6181. #line 11632 "./typica.w"
  6182. foreach(item,itemList)
  6183. {
  6184. int nextX= x+item->sizeHint().width()+spacing();
  6185. int right= x+item->sizeHint().width();
  6186. if(item==itemList.last())
  6187. {
  6188. right= rect.right();
  6189. }
  6190. int bottom= rect.bottom();
  6191. if(!testOnly)
  6192. {
  6193. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6194. }
  6195. x= nextX;
  6196. }
  6197. /*:511*/
  6198. #line 11616 "./typica.w"
  6199. }
  6200. else
  6201. {
  6202. /*512:*/
  6203. #line 11651 "./typica.w"
  6204. foreach(item,itemList)
  6205. {
  6206. int nextY= y+item->sizeHint().height()+spacing();
  6207. int bottom= y+item->sizeHint().height();
  6208. if(item==itemList.last())
  6209. {
  6210. bottom= rect.bottom();
  6211. }
  6212. int right= rect.right();
  6213. if(!testOnly)
  6214. {
  6215. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6216. }
  6217. y= nextY;
  6218. }
  6219. /*:512*/
  6220. #line 11620 "./typica.w"
  6221. }
  6222. return y;
  6223. }
  6224. /*:510*//*513:*/
  6225. #line 11675 "./typica.w"
  6226. QSize PackLayout::minimumSize()const
  6227. {
  6228. QSize size;
  6229. QLayoutItem*item;
  6230. foreach(item,itemList)
  6231. {
  6232. if(orientation==Qt::Horizontal)
  6233. {
  6234. size+= QSize(item->minimumSize().width(),0);
  6235. if(size.height()<item->minimumSize().height())
  6236. {
  6237. size.setHeight(item->minimumSize().height());
  6238. }
  6239. }
  6240. else
  6241. {
  6242. size+= QSize(0,item->minimumSize().height());
  6243. if(size.width()<item->minimumSize().width())
  6244. {
  6245. size.setWidth(item->minimumSize().width());
  6246. }
  6247. }
  6248. }
  6249. size+= QSize(2*margin(),2*margin());
  6250. return size;
  6251. }
  6252. /*:513*//*514:*/
  6253. #line 11707 "./typica.w"
  6254. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  6255. QLayout(parent)
  6256. {
  6257. setMargin(margin);
  6258. setSpacing(spacing);
  6259. setOrientation(Qt::Horizontal);
  6260. }
  6261. PackLayout::PackLayout(int spacing)
  6262. {
  6263. setSpacing(spacing);
  6264. setOrientation(Qt::Horizontal);
  6265. }
  6266. /*:514*//*515:*/
  6267. #line 11725 "./typica.w"
  6268. PackLayout::~PackLayout()
  6269. {
  6270. QLayoutItem*item;
  6271. while((item= takeAt(0)))
  6272. {
  6273. delete item;
  6274. }
  6275. }
  6276. /*:515*//*516:*/
  6277. #line 11739 "./typica.w"
  6278. QLayoutItem*PackLayout::takeAt(int index)
  6279. {
  6280. if(index>=0&&index<itemList.size())
  6281. {
  6282. return itemList.takeAt(index);
  6283. }
  6284. else
  6285. {
  6286. return NULL;
  6287. }
  6288. }
  6289. /*:516*//*517:*/
  6290. #line 11755 "./typica.w"
  6291. QLayoutItem*PackLayout::itemAt(int index)const
  6292. {
  6293. if(index>=0&&index<itemList.size())
  6294. {
  6295. return itemList.at(index);
  6296. }
  6297. else
  6298. {
  6299. return NULL;
  6300. }
  6301. }
  6302. /*:517*//*518:*/
  6303. #line 11778 "./typica.w"
  6304. void PackLayout::addItem(QLayoutItem*item)
  6305. {
  6306. itemList.append(item);
  6307. }
  6308. /*:518*//*519:*/
  6309. #line 11786 "./typica.w"
  6310. int PackLayout::count()const
  6311. {
  6312. return itemList.size();
  6313. }
  6314. /*:519*//*520:*/
  6315. #line 11798 "./typica.w"
  6316. Qt::Orientations PackLayout::expandingDirections()const
  6317. {
  6318. return Qt::Vertical|Qt::Horizontal;
  6319. }
  6320. bool PackLayout::hasHeightForWidth()const
  6321. {
  6322. return false;
  6323. }
  6324. int PackLayout::heightForWidth(int width)const
  6325. {
  6326. return doLayout(QRect(0,0,width,0),true);
  6327. }
  6328. void PackLayout::setGeometry(const QRect&rect)
  6329. {
  6330. QLayout::setGeometry(rect);
  6331. doLayout(rect,false);
  6332. }
  6333. QSize PackLayout::sizeHint()const
  6334. {
  6335. return minimumSize();
  6336. }
  6337. /*:520*//*521:*/
  6338. #line 11829 "./typica.w"
  6339. void PackLayout::setOrientation(Qt::Orientations direction)
  6340. {
  6341. orientation= direction;
  6342. doLayout(geometry(),false);
  6343. }
  6344. /*:521*/
  6345. #line 557 "./typica.w"
  6346. /*523:*/
  6347. #line 11868 "./typica.w"
  6348. SceneButton::SceneButton():QGraphicsScene()
  6349. {
  6350. }
  6351. SceneButton::~SceneButton()
  6352. {
  6353. }
  6354. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  6355. {
  6356. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  6357. }
  6358. /*:523*/
  6359. #line 558 "./typica.w"
  6360. /*525:*/
  6361. #line 11914 "./typica.w"
  6362. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  6363. Qt::Orientations orientation,
  6364. QWidget*parent,Qt::WindowFlags f):
  6365. QWidget(parent,f),label(new QGraphicsView()),
  6366. scene(new SceneButton())
  6367. {
  6368. layout= new PackLayout(this);
  6369. layout->setOrientation(orientation);
  6370. /*526:*/
  6371. #line 11934 "./typica.w"
  6372. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6373. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6374. label->setFrameShape(QFrame::NoFrame);
  6375. label->setInteractive(true);
  6376. /*:526*/
  6377. #line 11923 "./typica.w"
  6378. /*527:*/
  6379. #line 11945 "./typica.w"
  6380. scene->setBackgroundBrush(Qt::cyan);
  6381. text= scene->addText(labeltext);
  6382. if(orientation==Qt::Horizontal)
  6383. {
  6384. text->rotate(270.0);
  6385. }
  6386. label->setScene(scene);
  6387. /*:527*/
  6388. #line 11924 "./typica.w"
  6389. /*528:*/
  6390. #line 11963 "./typica.w"
  6391. if(orientation==Qt::Horizontal)
  6392. {
  6393. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  6394. }
  6395. else
  6396. {
  6397. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  6398. }
  6399. label->centerOn(text);
  6400. /*:528*/
  6401. #line 11925 "./typica.w"
  6402. /*529:*/
  6403. #line 11978 "./typica.w"
  6404. layout->addWidget(label);
  6405. layout->addWidget(widget);
  6406. if(orientation==Qt::Horizontal)
  6407. {
  6408. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  6409. widget->sizeHint().height());
  6410. }
  6411. else
  6412. {
  6413. setMinimumSize(widget->sizeHint().width(),
  6414. widget->sizeHint().height()+label->sizeHint().height());
  6415. }
  6416. /*:529*/
  6417. #line 11926 "./typica.w"
  6418. }
  6419. /*:525*//*530:*/
  6420. #line 11995 "./typica.w"
  6421. void WidgetDecorator::setBackgroundBrush(QBrush background)
  6422. {
  6423. scene->setBackgroundBrush(background);
  6424. }
  6425. void WidgetDecorator::setTextColor(QColor color)
  6426. {
  6427. text->setDefaultTextColor(color);
  6428. }
  6429. /*:530*//*531:*/
  6430. #line 12008 "./typica.w"
  6431. WidgetDecorator::~WidgetDecorator()
  6432. {
  6433. }
  6434. /*:531*/
  6435. #line 559 "./typica.w"
  6436. /*536:*/
  6437. #line 12107 "./typica.w"
  6438. void LogEditWindow::addTheRows()
  6439. {
  6440. QTime s= startTime->time();
  6441. while(s<endTime->time())
  6442. {
  6443. model->newMeasurement(Measurement(0,s),1);
  6444. s= s.addSecs(interval->value());
  6445. }
  6446. model->newMeasurement(Measurement(0,endTime->time()),1);
  6447. }
  6448. /*:536*//*537:*/
  6449. #line 12121 "./typica.w"
  6450. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  6451. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  6452. addRowsLayout(new QHBoxLayout(NULL)),
  6453. startTimeLabel(new QLabel("Start Time")),
  6454. startTime(new QTimeEdit(QTime(0,0,0,0))),
  6455. endTimeLabel(new QLabel("End Time")),
  6456. endTime(new QTimeEdit(QTime(0,20,0,0))),
  6457. intervalLabel(new QLabel("Interval (seconds)")),
  6458. interval(new QSpinBox()),
  6459. addRows(new QPushButton("Add Rows")),
  6460. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  6461. saveCsv(new QAction(tr("Export CSV"),NULL)),
  6462. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  6463. model(new MeasurementModel()),
  6464. log(new QTableView())
  6465. {
  6466. /*538:*/
  6467. #line 12158 "./typica.w"
  6468. QSettings settings;
  6469. resize(settings.value("logSize",QSize(620,400)).toSize());
  6470. move(settings.value("logPos",QPoint(200,60)).toPoint());
  6471. /*:538*/
  6472. #line 12138 "./typica.w"
  6473. /*539:*/
  6474. #line 12171 "./typica.w"
  6475. mainLayout->setOrientation(Qt::Vertical);
  6476. addRowsLayout->addSpacing(10);
  6477. addRowsLayout->addWidget(startTimeLabel);
  6478. addRowsLayout->addWidget(startTime);
  6479. addRowsLayout->addSpacing(10);
  6480. startTime->setDisplayFormat("mm:ss");
  6481. addRowsLayout->addWidget(endTimeLabel);
  6482. addRowsLayout->addWidget(endTime);
  6483. addRowsLayout->addSpacing(10);
  6484. endTime->setDisplayFormat("mm:ss");
  6485. addRowsLayout->addWidget(intervalLabel);
  6486. addRowsLayout->addWidget(interval);
  6487. addRowsLayout->addSpacing(10);
  6488. interval->setRange(0,60);
  6489. interval->setValue(30);
  6490. addRowsLayout->addWidget(addRows);
  6491. addRowsLayout->addSpacing(10);
  6492. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  6493. /*:539*/
  6494. #line 12139 "./typica.w"
  6495. /*540:*/
  6496. #line 12194 "./typica.w"
  6497. model->setHeaderData(0,Qt::Horizontal,"Time");
  6498. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  6499. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  6500. model->clear();
  6501. /*:540*/
  6502. #line 12140 "./typica.w"
  6503. /*541:*/
  6504. #line 12203 "./typica.w"
  6505. log->setModel(model);
  6506. log->setColumnWidth(0,100);
  6507. log->setColumnWidth(1,100);
  6508. log->setColumnWidth(2,100);
  6509. /*:541*/
  6510. #line 12141 "./typica.w"
  6511. mainLayout->addItem(addRowsLayout);
  6512. mainLayout->addWidget(log);
  6513. centralWidget->setLayout(mainLayout);
  6514. setCentralWidget(centralWidget);
  6515. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  6516. fileMenu->addAction(openXml);
  6517. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  6518. fileMenu->addAction(saveXml);
  6519. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6520. fileMenu->addAction(saveCsv);
  6521. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6522. }
  6523. /*:537*//*542:*/
  6524. #line 12214 "./typica.w"
  6525. void LogEditWindow::saveXML()
  6526. {
  6527. QSettings settings;
  6528. QString lastDir= settings.value("lastDirectory").toString();
  6529. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6530. lastDir,"",0);
  6531. QFile file(filename);
  6532. XMLOutput writer(model,&file,0);
  6533. writer.addTemperatureColumn("Temperature",1);
  6534. writer.addAnnotationColumn("Annotation",2);
  6535. if(writer.output())
  6536. {
  6537. QFileInfo info(filename);
  6538. QDir directory= info.dir();
  6539. lastDir= directory.path();
  6540. settings.setValue("lastDirectory",lastDir);
  6541. }
  6542. }
  6543. void LogEditWindow::saveCSV()
  6544. {
  6545. QSettings settings;
  6546. QString lastDir= settings.value("lastDirectory").toString();
  6547. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6548. lastDir,"",0);
  6549. QFile file(filename);
  6550. CSVOutput writer(model,&file,0);
  6551. writer.addTemperatureColumn("Temperature",1);
  6552. writer.addAnnotationColumn("Annotation",2);
  6553. if(writer.output())
  6554. {
  6555. QFileInfo info(filename);
  6556. QDir directory= info.dir();
  6557. lastDir= directory.path();
  6558. settings.setValue("lastDirectory",lastDir);
  6559. }
  6560. }
  6561. /*:542*//*543:*/
  6562. #line 12257 "./typica.w"
  6563. void LogEditWindow::openXML()
  6564. {
  6565. QSettings settings;
  6566. QString lastDir= settings.value("lastDirectory").toString();
  6567. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6568. lastDir,"",0);
  6569. if(filename.isNull())
  6570. {
  6571. return;
  6572. }
  6573. QFile file(filename);
  6574. XMLInput reader(&file,1);
  6575. connect(&reader,SIGNAL(measure(Measurement,int)),
  6576. model,SLOT(newMeasurement(Measurement,int)));
  6577. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6578. model,SLOT(newAnnotation(QString,int,int)));
  6579. if(reader.input())
  6580. {
  6581. QFileInfo info(filename);
  6582. setWindowTitle(QString(tr("%1 - %2")).
  6583. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6584. QDir directory= info.dir();
  6585. lastDir= directory.path();
  6586. settings.setValue("lastDirectory",lastDir);
  6587. }
  6588. }
  6589. /*:543*//*544:*/
  6590. #line 12288 "./typica.w"
  6591. void LogEditWindow::closeEvent(QCloseEvent*event)
  6592. {
  6593. QSettings settings;
  6594. settings.setValue("logSize",size());
  6595. settings.setValue("logPos",pos());
  6596. event->accept();
  6597. }
  6598. /*:544*/
  6599. #line 560 "./typica.w"
  6600. /*550:*/
  6601. #line 12403 "./typica.w"
  6602. bool XMLOutput::output()
  6603. {
  6604. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6605. {
  6606. return false;
  6607. }
  6608. QXmlStreamWriter xmlout(out);
  6609. xmlout.writeStartDocument("1.0");
  6610. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6611. xmlout.writeStartElement("roastlog");
  6612. /*551:*/
  6613. #line 12436 "./typica.w"
  6614. foreach(int c,temperatureColumns.keys())
  6615. {
  6616. xmlout.writeStartElement("tempseries");
  6617. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6618. xmlout.writeEndElement();
  6619. }
  6620. foreach(int c,controlColumns.keys())
  6621. {
  6622. xmlout.writeStartElement("controlseries");
  6623. xmlout.writeAttribute("name",controlColumns.value(c));
  6624. xmlout.writeEndElement();
  6625. }
  6626. foreach(int c,annotationColumns.keys())
  6627. {
  6628. xmlout.writeStartElement("noteseries");
  6629. xmlout.writeAttribute("name",annotationColumns.value(c));
  6630. xmlout.writeEndElement();
  6631. }
  6632. /*:551*/
  6633. #line 12414 "./typica.w"
  6634. xmlout.writeStartElement("roast");
  6635. bool oresult;
  6636. for(int i= 0;i<data->rowCount();i++)
  6637. {
  6638. /*552:*/
  6639. #line 12461 "./typica.w"
  6640. oresult= false;
  6641. foreach(int c,temperatureColumns.keys())
  6642. {
  6643. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6644. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6645. {
  6646. oresult= true;
  6647. break;
  6648. }
  6649. }
  6650. foreach(int c,controlColumns.keys())
  6651. {
  6652. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6653. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6654. {
  6655. oresult= true;
  6656. break;
  6657. }
  6658. }
  6659. if(oresult==false)
  6660. {
  6661. foreach(int c,annotationColumns.keys())
  6662. {
  6663. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6664. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6665. isEmpty()))
  6666. {
  6667. oresult= true;
  6668. break;
  6669. }
  6670. }
  6671. }
  6672. /*:552*/
  6673. #line 12419 "./typica.w"
  6674. if(oresult)
  6675. {
  6676. /*553:*/
  6677. #line 12500 "./typica.w"
  6678. xmlout.writeStartElement("tuple");
  6679. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6680. Qt::DisplayRole).toString());
  6681. foreach(int c,temperatureColumns.keys())
  6682. {
  6683. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6684. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6685. {
  6686. xmlout.writeStartElement("temperature");
  6687. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6688. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6689. {
  6690. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6691. {
  6692. xmlout.writeAttribute("relative","true");
  6693. }
  6694. }
  6695. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6696. toString());
  6697. xmlout.writeEndElement();
  6698. }
  6699. }
  6700. foreach(int c,controlColumns.keys())
  6701. {
  6702. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6703. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6704. {
  6705. xmlout.writeStartElement("control");
  6706. xmlout.writeAttribute("series",controlColumns.value(c));
  6707. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6708. xmlout.writeEndElement();
  6709. }
  6710. }
  6711. foreach(int c,annotationColumns.keys())
  6712. {
  6713. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6714. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6715. {
  6716. xmlout.writeStartElement("annotation");
  6717. xmlout.writeAttribute("series",annotationColumns.value(c));
  6718. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6719. toString());
  6720. xmlout.writeEndElement();
  6721. }
  6722. }
  6723. xmlout.writeEndElement();
  6724. /*:553*/
  6725. #line 12422 "./typica.w"
  6726. }
  6727. }
  6728. xmlout.writeEndElement();
  6729. xmlout.writeEndElement();
  6730. xmlout.writeEndDocument();
  6731. out->close();
  6732. return true;
  6733. }
  6734. /*:550*//*554:*/
  6735. #line 12550 "./typica.w"
  6736. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6737. :QObject(NULL),data(model),out(device),time(timec)
  6738. {
  6739. }
  6740. void XMLOutput::setModel(MeasurementModel*model)
  6741. {
  6742. data= model;
  6743. }
  6744. void XMLOutput::setTimeColumn(int column)
  6745. {
  6746. time= column;
  6747. }
  6748. void XMLOutput::setDevice(QIODevice*device)
  6749. {
  6750. out= device;
  6751. }
  6752. /*:554*//*555:*/
  6753. #line 12579 "./typica.w"
  6754. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6755. {
  6756. temperatureColumns.insert(column,series);
  6757. }
  6758. void XMLOutput::addControlColumn(const QString&series,int column)
  6759. {
  6760. controlColumns.insert(column,series);
  6761. }
  6762. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6763. {
  6764. annotationColumns.insert(column,series);
  6765. }
  6766. /*:555*/
  6767. #line 561 "./typica.w"
  6768. /*557:*/
  6769. #line 12636 "./typica.w"
  6770. bool XMLInput::input()
  6771. {
  6772. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6773. {
  6774. return false;
  6775. }
  6776. QXmlStreamReader xmlin(in);
  6777. QMap<QString,int> temperatureColumns;
  6778. QMap<QString,int> annotationColumns;
  6779. int nextColumn= firstc;
  6780. /*558:*/
  6781. #line 12667 "./typica.w"
  6782. while(!xmlin.isDTD())
  6783. {
  6784. xmlin.readNext();
  6785. }
  6786. if(xmlin.isDTD())
  6787. {
  6788. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6789. {
  6790. /*559:*/
  6791. #line 12689 "./typica.w"
  6792. emit newTemperatureColumn(firstc,"Bean");
  6793. emit newAnnotationColumn(firstc+1,"Note");
  6794. emit lastColumn(firstc+1);
  6795. /*:559*/
  6796. #line 12676 "./typica.w"
  6797. }
  6798. else
  6799. {
  6800. xmlin.readNext();
  6801. /*560:*/
  6802. #line 12698 "./typica.w"
  6803. while(xmlin.name()!="roast")
  6804. {
  6805. if(xmlin.isStartElement())
  6806. {
  6807. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6808. {
  6809. temperatureColumns.insert(xmlin.attributes().value("name").
  6810. toString(),
  6811. nextColumn);
  6812. emit newTemperatureColumn(nextColumn,
  6813. xmlin.attributes().value("name").
  6814. toString());
  6815. nextColumn++;
  6816. }
  6817. else if(xmlin.name()=="noteseries")
  6818. {
  6819. annotationColumns.insert(xmlin.attributes().value("name").
  6820. toString(),nextColumn);
  6821. emit newAnnotationColumn(nextColumn,
  6822. xmlin.attributes().value("name").
  6823. toString());
  6824. nextColumn++;
  6825. }
  6826. }
  6827. xmlin.readNext();
  6828. }
  6829. emit lastColumn(nextColumn-1);
  6830. /*:560*/
  6831. #line 12681 "./typica.w"
  6832. }
  6833. }
  6834. /*:558*/
  6835. #line 12647 "./typica.w"
  6836. QTime timeval= QTime();
  6837. double tempval= 0;
  6838. QString noteval= QString();
  6839. int column;
  6840. int counter= 0;
  6841. while(!xmlin.atEnd())
  6842. {
  6843. /*561:*/
  6844. #line 12739 "./typica.w"
  6845. xmlin.readNext();
  6846. if(xmlin.isStartElement())
  6847. {
  6848. /*562:*/
  6849. #line 12765 "./typica.w"
  6850. if(xmlin.name()=="time")
  6851. {
  6852. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6853. }
  6854. else if(xmlin.name()=="temperature")
  6855. {
  6856. column= xmlin.attributes().hasAttribute("series")?
  6857. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6858. bool relative= (xmlin.attributes().value("relative")=="true");
  6859. tempval= xmlin.readElementText().toDouble();
  6860. Measurement measurement(tempval,timeval);
  6861. if(relative)
  6862. {
  6863. measurement.insert("relative",true);
  6864. }
  6865. emit measure(measurement,column);
  6866. }
  6867. else if(xmlin.name()=="control")
  6868. {
  6869. column= xmlin.attributes().value("series").toString().isEmpty()?
  6870. firstc:temperatureColumns.value(xmlin.attributes().
  6871. value("series").toString());
  6872. tempval= xmlin.readElementText().toDouble();
  6873. Measurement measurement(tempval,timeval,Units::Unitless);
  6874. emit measure(measurement,column);
  6875. }
  6876. else if(xmlin.name()=="annotation")
  6877. {
  6878. column= xmlin.attributes().value("series").toString().isEmpty()?
  6879. firstc+1:annotationColumns.value(xmlin.attributes().
  6880. value("series").toString());
  6881. noteval= xmlin.readElementText();
  6882. if(!noteval.isEmpty())
  6883. {
  6884. emit annotation(noteval,firstc,column);
  6885. }
  6886. }
  6887. /*:562*/
  6888. #line 12743 "./typica.w"
  6889. }
  6890. counter++;
  6891. if(counter%100==0)
  6892. {
  6893. QCoreApplication::processEvents();
  6894. }
  6895. /*:561*/
  6896. #line 12655 "./typica.w"
  6897. }
  6898. return true;
  6899. }
  6900. /*:557*//*563:*/
  6901. #line 12806 "./typica.w"
  6902. XMLInput::XMLInput(QIODevice*input,int c):
  6903. firstc(c),in(input)
  6904. {
  6905. }
  6906. void XMLInput::setFirstColumn(int column)
  6907. {
  6908. firstc= column;
  6909. }
  6910. void XMLInput::setDevice(QIODevice*device)
  6911. {
  6912. in= device;
  6913. }
  6914. /*:563*/
  6915. #line 562 "./typica.w"
  6916. /*568:*/
  6917. #line 12897 "./typica.w"
  6918. bool CSVOutput::output()
  6919. {
  6920. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6921. {
  6922. return false;
  6923. }
  6924. QTextStream output(out);
  6925. /*569:*/
  6926. #line 12921 "./typica.w"
  6927. output<<"Time";
  6928. foreach(int c,temperatureColumns.keys())
  6929. {
  6930. output<<','<<temperatureColumns.value(c);
  6931. }
  6932. foreach(int c,controlColumns.keys())
  6933. {
  6934. output<<','<<controlColumns.value(c);
  6935. }
  6936. foreach(int c,annotationColumns.keys())
  6937. {
  6938. output<<','<<annotationColumns.value(c);
  6939. }
  6940. output<<'\n';
  6941. /*:569*/
  6942. #line 12905 "./typica.w"
  6943. bool oresult;
  6944. for(int i= 0;i<data->rowCount();i++)
  6945. {
  6946. /*552:*/
  6947. #line 12461 "./typica.w"
  6948. oresult= false;
  6949. foreach(int c,temperatureColumns.keys())
  6950. {
  6951. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6952. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6953. {
  6954. oresult= true;
  6955. break;
  6956. }
  6957. }
  6958. foreach(int c,controlColumns.keys())
  6959. {
  6960. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6961. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6962. {
  6963. oresult= true;
  6964. break;
  6965. }
  6966. }
  6967. if(oresult==false)
  6968. {
  6969. foreach(int c,annotationColumns.keys())
  6970. {
  6971. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6972. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6973. isEmpty()))
  6974. {
  6975. oresult= true;
  6976. break;
  6977. }
  6978. }
  6979. }
  6980. /*:552*/
  6981. #line 12909 "./typica.w"
  6982. if(oresult)
  6983. {
  6984. /*570:*/
  6985. #line 12946 "./typica.w"
  6986. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6987. foreach(int c,temperatureColumns.keys())
  6988. {
  6989. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6990. }
  6991. foreach(int c,controlColumns.keys())
  6992. {
  6993. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6994. }
  6995. foreach(int c,annotationColumns.keys())
  6996. {
  6997. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6998. }
  6999. output<<'\n';
  7000. /*:570*/
  7001. #line 12912 "./typica.w"
  7002. }
  7003. }
  7004. out->close();
  7005. return true;
  7006. }
  7007. /*:568*//*571:*/
  7008. #line 12965 "./typica.w"
  7009. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  7010. data(model),out(device),time(timec)
  7011. {
  7012. }
  7013. void CSVOutput::setModel(MeasurementModel*model)
  7014. {
  7015. data= model;
  7016. }
  7017. void CSVOutput::setTimeColumn(int column)
  7018. {
  7019. time= column;
  7020. }
  7021. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  7022. {
  7023. temperatureColumns.insert(column,series);
  7024. }
  7025. void CSVOutput::addControlColumn(const QString&series,int column)
  7026. {
  7027. controlColumns.insert(column,series);
  7028. }
  7029. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  7030. {
  7031. annotationColumns.insert(column,series);
  7032. }
  7033. void CSVOutput::setDevice(QIODevice*device)
  7034. {
  7035. out= device;
  7036. }
  7037. #line 1 "./webview.w"
  7038. /*:571*/
  7039. #line 563 "./typica.w"
  7040. /*623:*/
  7041. #line 13361 "./typica.w"
  7042. QString SaltModel::arrayLiteral(int column,int role)const
  7043. {
  7044. QString literal= "'{";
  7045. for(int i= 0;i<rowCount();i++)
  7046. {
  7047. QString datum= data(index(i,column),role).toString();
  7048. if(!datum.isEmpty())
  7049. {
  7050. literal.append(datum);
  7051. literal.append(", ");
  7052. }
  7053. }
  7054. if(literal.size()> 2)
  7055. {
  7056. literal.chop(2);
  7057. }
  7058. literal.append("}'");
  7059. return literal;
  7060. }
  7061. QString SaltModel::quotedArrayLiteral(int column,int role)const
  7062. {
  7063. QString literal= "'{";
  7064. for(int i= 0;i<rowCount();i++)
  7065. {
  7066. QString datum= data(index(i,column),role).toString();
  7067. if(!datum.isEmpty())
  7068. {
  7069. literal.append("\"");
  7070. literal.append(datum);
  7071. literal.append("\", ");
  7072. }
  7073. }
  7074. if(literal.size()> 2)
  7075. {
  7076. literal.chop(2);
  7077. }
  7078. literal.append("}'");
  7079. return literal;
  7080. }
  7081. /*:623*//*624:*/
  7082. #line 13405 "./typica.w"
  7083. QModelIndex SaltModel::parent(const QModelIndex&)const
  7084. {
  7085. return QModelIndex();
  7086. }
  7087. /*:624*//*625:*/
  7088. #line 13424 "./typica.w"
  7089. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  7090. int role)
  7091. {
  7092. /*626:*/
  7093. #line 13455 "./typica.w"
  7094. bool valid= false;
  7095. if(index.isValid())
  7096. {
  7097. if(index.row()<modelData.size())
  7098. {
  7099. if(index.column()<colcount)
  7100. {
  7101. valid= true;
  7102. }
  7103. }
  7104. }
  7105. /*:626*/
  7106. #line 13428 "./typica.w"
  7107. if(!valid)
  7108. {
  7109. return false;
  7110. }
  7111. if(index.row()==modelData.size()-1)
  7112. {
  7113. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  7114. /*627:*/
  7115. #line 13471 "./typica.w"
  7116. QList<QMap<int,QVariant> > newRow;
  7117. QMap<int,QVariant> defaults;
  7118. for(int i= 0;i<colcount;i++)
  7119. {
  7120. newRow.append(defaults);
  7121. }
  7122. modelData.append(newRow);
  7123. /*:627*/
  7124. #line 13436 "./typica.w"
  7125. endInsertRows();
  7126. }
  7127. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  7128. QMap<int,QVariant> cell= row.at(index.column());
  7129. cell.insert(role,value);
  7130. if(role==Qt::EditRole)
  7131. {
  7132. cell.insert(Qt::DisplayRole,value);
  7133. }
  7134. row.replace(index.column(),cell);
  7135. modelData.replace(index.row(),row);
  7136. emit dataChanged(index,index);
  7137. return true;
  7138. }
  7139. /*:625*//*628:*/
  7140. #line 13482 "./typica.w"
  7141. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  7142. {
  7143. for(int i= 0;i<columns;i++)
  7144. {
  7145. hData<<"";
  7146. }
  7147. /*627:*/
  7148. #line 13471 "./typica.w"
  7149. QList<QMap<int,QVariant> > newRow;
  7150. QMap<int,QVariant> defaults;
  7151. for(int i= 0;i<colcount;i++)
  7152. {
  7153. newRow.append(defaults);
  7154. }
  7155. modelData.append(newRow);
  7156. /*:627*/
  7157. #line 13489 "./typica.w"
  7158. }
  7159. /*:628*//*629:*/
  7160. #line 13494 "./typica.w"
  7161. SaltModel::~SaltModel()
  7162. {
  7163. }
  7164. /*:629*//*630:*/
  7165. #line 13504 "./typica.w"
  7166. int SaltModel::rowCount(const QModelIndex&parent)const
  7167. {
  7168. return(parent==QModelIndex()?modelData.size():0);
  7169. }
  7170. int SaltModel::columnCount(const QModelIndex&parent)const
  7171. {
  7172. return(parent==QModelIndex()?colcount:0);
  7173. }
  7174. /*:630*//*631:*/
  7175. #line 13517 "./typica.w"
  7176. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  7177. const QVariant&value,int)
  7178. {
  7179. if(orientation==Qt::Horizontal&&section<colcount)
  7180. {
  7181. hData.replace(section,value.toString());
  7182. emit headerDataChanged(orientation,section,section);
  7183. return true;
  7184. }
  7185. return false;
  7186. }
  7187. /*:631*//*632:*/
  7188. #line 13532 "./typica.w"
  7189. QVariant SaltModel::data(const QModelIndex&index,int role)const
  7190. {
  7191. /*626:*/
  7192. #line 13455 "./typica.w"
  7193. bool valid= false;
  7194. if(index.isValid())
  7195. {
  7196. if(index.row()<modelData.size())
  7197. {
  7198. if(index.column()<colcount)
  7199. {
  7200. valid= true;
  7201. }
  7202. }
  7203. }
  7204. /*:626*/
  7205. #line 13535 "./typica.w"
  7206. if(!valid)
  7207. {
  7208. return QVariant();
  7209. }
  7210. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  7211. QMap<int,QVariant> cell= row.at(index.column());
  7212. return cell.value(role,QVariant());
  7213. }
  7214. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  7215. int role)const
  7216. {
  7217. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  7218. section<colcount)
  7219. {
  7220. return QVariant(hData.at(section));
  7221. }
  7222. return QVariant();
  7223. }
  7224. /*:632*//*633:*/
  7225. #line 13559 "./typica.w"
  7226. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  7227. {
  7228. /*626:*/
  7229. #line 13455 "./typica.w"
  7230. bool valid= false;
  7231. if(index.isValid())
  7232. {
  7233. if(index.row()<modelData.size())
  7234. {
  7235. if(index.column()<colcount)
  7236. {
  7237. valid= true;
  7238. }
  7239. }
  7240. }
  7241. /*:626*/
  7242. #line 13562 "./typica.w"
  7243. if(valid)
  7244. {
  7245. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  7246. }
  7247. return 0;
  7248. }
  7249. /*:633*//*634:*/
  7250. #line 13573 "./typica.w"
  7251. QModelIndex SaltModel::index(int row,int column,
  7252. const QModelIndex&parent)const
  7253. {
  7254. if(parent==QModelIndex())
  7255. {
  7256. if(row<modelData.size()&&column<colcount)
  7257. {
  7258. return createIndex(row,column);
  7259. }
  7260. }
  7261. return QModelIndex();
  7262. }
  7263. /*:634*//*635:*/
  7264. #line 13591 "./typica.w"
  7265. void SaltModel::clear()
  7266. {
  7267. beginResetModel();
  7268. modelData.clear();
  7269. /*627:*/
  7270. #line 13471 "./typica.w"
  7271. QList<QMap<int,QVariant> > newRow;
  7272. QMap<int,QVariant> defaults;
  7273. for(int i= 0;i<colcount;i++)
  7274. {
  7275. newRow.append(defaults);
  7276. }
  7277. modelData.append(newRow);
  7278. /*:627*/
  7279. #line 13596 "./typica.w"
  7280. endResetModel();
  7281. }
  7282. /*:635*//*636:*/
  7283. #line 13605 "./typica.w"
  7284. bool SaltModel::removeRows(int row,int count,
  7285. const QModelIndex&parent)
  7286. {
  7287. if(parent==QModelIndex())
  7288. {
  7289. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  7290. {
  7291. beginRemoveRows(parent,row,row+count-1);
  7292. for(int i= 0;i<count;i++)
  7293. {
  7294. modelData.removeAt(row);
  7295. }
  7296. endRemoveRows();
  7297. if(modelData.size()==0)
  7298. {
  7299. beginInsertRows(parent,0,0);
  7300. /*627:*/
  7301. #line 13471 "./typica.w"
  7302. QList<QMap<int,QVariant> > newRow;
  7303. QMap<int,QVariant> defaults;
  7304. for(int i= 0;i<colcount;i++)
  7305. {
  7306. newRow.append(defaults);
  7307. }
  7308. modelData.append(newRow);
  7309. /*:627*/
  7310. #line 13622 "./typica.w"
  7311. endInsertRows();
  7312. }
  7313. return true;
  7314. }
  7315. }
  7316. return false;
  7317. }
  7318. /*:636*//*637:*/
  7319. #line 13636 "./typica.w"
  7320. int SaltModel::findData(const QVariant&value,int column,int role)
  7321. {
  7322. for(int i= 0;i<modelData.size();i++)
  7323. {
  7324. if(modelData.at(i).size()> column)
  7325. {
  7326. if(modelData.at(i).at(column).contains(role))
  7327. {
  7328. if(modelData.at(i).at(column).value(role)==value)
  7329. {
  7330. return i;
  7331. }
  7332. }
  7333. }
  7334. }
  7335. return-1;
  7336. }
  7337. /*:637*/
  7338. #line 564 "./typica.w"
  7339. /*639:*/
  7340. #line 13700 "./typica.w"
  7341. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  7342. {
  7343. SqlComboBox*widget= new SqlComboBox();
  7344. widget->setParent(parent);
  7345. for(int i= 0;i<count();i++)
  7346. {
  7347. widget->addItem(itemText(i),itemData(i));
  7348. }
  7349. return widget;
  7350. }
  7351. /*:639*//*640:*/
  7352. #line 13717 "./typica.w"
  7353. void SqlComboBox::showData(bool show)
  7354. {
  7355. dataColumnShown= show;
  7356. }
  7357. /*:640*//*641:*/
  7358. #line 13731 "./typica.w"
  7359. void SqlComboBox::addNullOption()
  7360. {
  7361. addItem(specialNullText,specialNullData);
  7362. }
  7363. void SqlComboBox::setNullText(QString nullText)
  7364. {
  7365. specialNullText= nullText;
  7366. }
  7367. void SqlComboBox::setNullData(QVariant nullData)
  7368. {
  7369. specialNullData= nullData;
  7370. }
  7371. /*:641*//*642:*/
  7372. #line 13754 "./typica.w"
  7373. void SqlComboBox::setDataColumn(int column)
  7374. {
  7375. dataColumn= column;
  7376. }
  7377. void SqlComboBox::setDisplayColumn(int column)
  7378. {
  7379. displayColumn= column;
  7380. }
  7381. /*:642*//*643:*/
  7382. #line 13768 "./typica.w"
  7383. void SqlComboBox::addSqlOptions(QString query)
  7384. {
  7385. SqlQueryConnection h;
  7386. QSqlQuery*dbquery= h.operator->();
  7387. if(!dbquery->exec(query))
  7388. {
  7389. QSqlError error= dbquery->lastError();
  7390. qDebug()<<error.databaseText();
  7391. qDebug()<<error.driverText();
  7392. qDebug()<<error.text();
  7393. qDebug()<<dbquery->lastQuery();
  7394. }
  7395. while(dbquery->next())
  7396. {
  7397. QString displayValue(dbquery->value(displayColumn).toString());
  7398. QString dataValue(dbquery->value(dataColumn).toString());
  7399. if(dataColumnShown)
  7400. {
  7401. displayValue.append(QString(" (%1)").arg(dataValue));
  7402. }
  7403. addItem(displayValue,dataValue);
  7404. }
  7405. }
  7406. /*:643*//*644:*/
  7407. #line 13804 "./typica.w"
  7408. SqlComboBox::SqlComboBox():
  7409. dataColumn(0),displayColumn(0),dataColumnShown(false),
  7410. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  7411. {
  7412. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  7413. }
  7414. SqlComboBox::~SqlComboBox()
  7415. {
  7416. }
  7417. /*:644*/
  7418. #line 565 "./typica.w"
  7419. /*646:*/
  7420. #line 13843 "./typica.w"
  7421. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  7422. {
  7423. delegate= widget;
  7424. }
  7425. /*:646*//*647:*/
  7426. #line 13852 "./typica.w"
  7427. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  7428. const QStyleOptionViewItem&,
  7429. const QModelIndex&)const
  7430. {
  7431. return delegate->clone(parent);
  7432. }
  7433. /*:647*//*648:*/
  7434. #line 13863 "./typica.w"
  7435. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  7436. const QModelIndex&index)const
  7437. {
  7438. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7439. self->setCurrentIndex(self->findData(
  7440. index.model()->data(index,
  7441. Qt::UserRole).toString()));
  7442. }
  7443. /*:648*//*649:*/
  7444. #line 13876 "./typica.w"
  7445. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  7446. QAbstractItemModel*model,
  7447. const QModelIndex&index)const
  7448. {
  7449. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7450. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  7451. Qt::UserRole);
  7452. model->setData(index,self->currentText(),Qt::DisplayRole);
  7453. }
  7454. /*:649*//*650:*/
  7455. #line 13889 "./typica.w"
  7456. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  7457. const QStyleOptionViewItem&option,
  7458. const QModelIndex&)const
  7459. {
  7460. editor->setGeometry(option.rect);
  7461. }
  7462. /*:650*//*651:*/
  7463. #line 13900 "./typica.w"
  7464. QSize SqlComboBoxDelegate::sizeHint()const
  7465. {
  7466. return delegate->sizeHint();
  7467. }
  7468. /*:651*//*652:*/
  7469. #line 13908 "./typica.w"
  7470. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  7471. :QItemDelegate(parent)
  7472. {
  7473. }
  7474. /*:652*/
  7475. #line 566 "./typica.w"
  7476. /*608:*/
  7477. #line 13053 "./typica.w"
  7478. Application::Application(int&argc,char**argv):QApplication(argc,argv),
  7479. connectionStatus(false),currentUser(QString())
  7480. {
  7481. network= new QNetworkAccessManager(this);
  7482. /*609:*/
  7483. #line 13070 "./typica.w"
  7484. setOrganizationName("Wilson's Coffee & Tea");
  7485. setOrganizationDomain("wilsonscoffee.com");
  7486. setApplicationName(PROGRAM_NAME);
  7487. /*:609*/
  7488. #line 13058 "./typica.w"
  7489. /*610:*/
  7490. #line 13079 "./typica.w"
  7491. QTranslator*base= new QTranslator;
  7492. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7493. {
  7494. installTranslator(base);
  7495. }
  7496. QTranslator*app= new QTranslator;
  7497. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7498. {
  7499. installTranslator(app);
  7500. }
  7501. /*:610*/
  7502. #line 13059 "./typica.w"
  7503. /*315:*/
  7504. #line 123 "./measurement.w"
  7505. qRegisterMetaType<Measurement> ("Measurement");
  7506. /*:315*/
  7507. #line 13060 "./typica.w"
  7508. /*829:*/
  7509. #line 17216 "./typica.w"
  7510. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  7511. tr("NI DAQmx Base"),
  7512. "nidaqmxbase",NULL);
  7513. topLevelNodeInserters.append(inserter);
  7514. /*:829*//*837:*/
  7515. #line 17447 "./typica.w"
  7516. #ifdef Q_OS_WIN32
  7517. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  7518. topLevelNodeInserters.append(inserter);
  7519. #endif
  7520. /*:837*//*861:*/
  7521. #line 18414 "./typica.w"
  7522. #if 0
  7523. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7524. topLevelNodeInserters.append(inserter);
  7525. #endif
  7526. /*:861*//*914:*/
  7527. #line 19923 "./typica.w"
  7528. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7529. topLevelNodeInserters.append(inserter);
  7530. #line 1 "./modbus.w"
  7531. /*:914*//*920:*/
  7532. #line 328 "./modbus.w"
  7533. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7534. topLevelNodeInserters.append(inserter);
  7535. /*:920*//*936:*/
  7536. #line 275 "./unsupportedserial.w"
  7537. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7538. "unsupporteddevice",NULL);
  7539. topLevelNodeInserters.append(inserter);
  7540. /*:936*//*967:*/
  7541. #line 190 "./phidgets.w"
  7542. QLibrary phidgetsCheck("phidget21");
  7543. if(phidgetsCheck.load())
  7544. {
  7545. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7546. "phidgets1048",NULL);
  7547. topLevelNodeInserters.append(inserter);
  7548. phidgetsCheck.unload();
  7549. }
  7550. else
  7551. {
  7552. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7553. if(phidgetsCheck.load())
  7554. {
  7555. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7556. "phidgets1048",NULL);
  7557. topLevelNodeInserters.append(inserter);
  7558. phidgetsCheck.unload();
  7559. }
  7560. }
  7561. /*:967*//*981:*/
  7562. #line 17 "./phidget22.w"
  7563. #if __APPLE__
  7564. QLibrary phidget22check("Phidget22.framework/Phidget22");
  7565. #else
  7566. QLibrary phidget22check("phidget22");
  7567. #endif
  7568. if(phidget22check.load())
  7569. {
  7570. inserter= new NodeInserter(tr("Phidget22"),tr("Phidget22"),"phidget22",
  7571. NULL);
  7572. topLevelNodeInserters.append(inserter);
  7573. phidget22check.unload();
  7574. }
  7575. /*:981*//*1104:*/
  7576. #line 1241 "./dataqsdk.w"
  7577. #ifdef Q_OS_WIN32
  7578. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7579. "dataqsdk",NULL);
  7580. topLevelNodeInserters.append(inserter);
  7581. #endif
  7582. #line 20594 "./typica.w"
  7583. #line 1 "./scales.w"
  7584. /*:1104*//*1129:*/
  7585. #line 557 "./scales.w"
  7586. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7587. topLevelNodeInserters.append(inserter);
  7588. #line 20596 "./typica.w"
  7589. #line 1 "./valueannotation.w"
  7590. /*:1129*/
  7591. #line 13061 "./typica.w"
  7592. }
  7593. /*:608*//*612:*/
  7594. #line 13102 "./typica.w"
  7595. QDomDocument*Application::configuration()
  7596. {
  7597. return&conf;
  7598. }
  7599. /*:612*//*613:*/
  7600. #line 13111 "./typica.w"
  7601. QSqlDatabase Application::database()
  7602. {
  7603. QString connectionName;
  7604. QSqlDatabase connection=
  7605. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7606. do
  7607. {
  7608. connectionName= QUuid::createUuid().toString();
  7609. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7610. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7611. }
  7612. /*:613*//*614:*/
  7613. #line 13127 "./typica.w"
  7614. void Application::setDatabaseConnected(bool status)
  7615. {
  7616. connectionStatus= status;
  7617. }
  7618. bool Application::databaseConnected()
  7619. {
  7620. return connectionStatus;
  7621. }
  7622. /*:614*//*615:*/
  7623. #line 13150 "./typica.w"
  7624. DatabaseNotification*Application::subscribe(const QString&notification)
  7625. {
  7626. DatabaseNotification*retval;
  7627. if(notifiers.contains(notification))
  7628. {
  7629. retval= notifiers.value(notification);
  7630. }
  7631. else
  7632. {
  7633. if(notifiers.size()==0)
  7634. {
  7635. notificationDriver= QSqlDatabase::database().driver();
  7636. connect(notificationDriver,SIGNAL(notification(QString)),this,SLOT(notify(QString)));
  7637. }
  7638. retval= new DatabaseNotification;
  7639. connect(this,SIGNAL(aboutToQuit()),retval,SLOT(deleteLater()));
  7640. if(notifiers.size()!=
  7641. notificationDriver->subscribedToNotifications().size())
  7642. {
  7643. for(int i= 0;i<notifiers.size();i++)
  7644. {
  7645. notificationDriver->subscribeToNotification(notifiers.keys().at(i));
  7646. }
  7647. }
  7648. notifiers.insert(notification,retval);
  7649. notificationDriver->subscribeToNotification(notification);
  7650. }
  7651. return retval;
  7652. }
  7653. /*:615*//*616:*/
  7654. #line 13186 "./typica.w"
  7655. void Application::notify(const QString&notification)
  7656. {
  7657. if(notifiers.contains(notification))
  7658. {
  7659. DatabaseNotification*notifier= notifiers.value(notification);
  7660. notifier->forwardNotification(notification);
  7661. }
  7662. }
  7663. /*:616*//*764:*/
  7664. #line 15749 "./typica.w"
  7665. void Application::saveDeviceConfiguration()
  7666. {
  7667. QSettings settings;
  7668. settings.setValue("DeviceConfiguration",
  7669. QVariant(deviceConfigurationDocument.toByteArray()));
  7670. }
  7671. /*:764*//*765:*/
  7672. #line 15761 "./typica.w"
  7673. QDomDocument Application::deviceConfiguration()
  7674. {
  7675. if(deviceConfigurationDocument.isNull())
  7676. {
  7677. /*766:*/
  7678. #line 15775 "./typica.w"
  7679. QSettings settings;
  7680. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7681. QString etext;
  7682. int eline;
  7683. int ecol;
  7684. if(document.length()==0)
  7685. {
  7686. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7687. /*767:*/
  7688. #line 15799 "./typica.w"
  7689. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7690. emptyDocument.open(QIODevice::ReadOnly);
  7691. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7692. &etext,&eline,&ecol))
  7693. {
  7694. /*768:*/
  7695. #line 15816 "./typica.w"
  7696. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7697. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7698. qDebug()<<etext;
  7699. /*:768*/
  7700. #line 15805 "./typica.w"
  7701. }
  7702. else
  7703. {
  7704. saveDeviceConfiguration();
  7705. }
  7706. /*:767*/
  7707. #line 15784 "./typica.w"
  7708. }
  7709. else
  7710. {
  7711. if(!deviceConfigurationDocument.setContent(document,false,
  7712. &etext,&eline,&ecol))
  7713. {
  7714. /*768:*/
  7715. #line 15816 "./typica.w"
  7716. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7717. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7718. qDebug()<<etext;
  7719. /*:768*/
  7720. #line 15791 "./typica.w"
  7721. /*767:*/
  7722. #line 15799 "./typica.w"
  7723. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7724. emptyDocument.open(QIODevice::ReadOnly);
  7725. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7726. &etext,&eline,&ecol))
  7727. {
  7728. /*768:*/
  7729. #line 15816 "./typica.w"
  7730. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7731. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7732. qDebug()<<etext;
  7733. /*:768*/
  7734. #line 15805 "./typica.w"
  7735. }
  7736. else
  7737. {
  7738. saveDeviceConfiguration();
  7739. }
  7740. /*:767*/
  7741. #line 15792 "./typica.w"
  7742. }
  7743. }
  7744. /*:766*/
  7745. #line 15766 "./typica.w"
  7746. }
  7747. return deviceConfigurationDocument;
  7748. }
  7749. /*:765*//*796:*/
  7750. #line 16417 "./typica.w"
  7751. void Application::registerDeviceConfigurationWidget(QString driver,
  7752. QMetaObject widget)
  7753. {
  7754. deviceConfigurationWidgets.insert(driver,widget);
  7755. }
  7756. /*:796*//*797:*/
  7757. #line 16433 "./typica.w"
  7758. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7759. const QModelIndex&index)
  7760. {
  7761. QVariant nodeReference= index.data(Qt::UserRole);
  7762. QDomElement referenceElement= model->referenceElement(
  7763. model->data(index,Qt::UserRole).toString());
  7764. QMetaObject metaObject=
  7765. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7766. QWidget::staticMetaObject);
  7767. QWidget*editor;
  7768. if(metaObject.className()==QWidget::staticMetaObject.className())
  7769. {
  7770. editor= NULL;
  7771. }
  7772. else
  7773. {
  7774. editor= qobject_cast<QWidget*> (
  7775. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7776. Q_ARG(QModelIndex,index)));
  7777. }
  7778. return editor;
  7779. }
  7780. /*:797*//*1159:*/
  7781. #line 16 "./user.w"
  7782. QString Application::currentTypicaUser()
  7783. {
  7784. return currentUser;
  7785. }
  7786. /*:1159*//*1160:*/
  7787. #line 26 "./user.w"
  7788. void Application::setCurrentTypicaUser(const QString&user)
  7789. {
  7790. currentUser= user;
  7791. emit userChanged(currentUser);
  7792. }
  7793. /*:1160*//*1161:*/
  7794. #line 37 "./user.w"
  7795. bool Application::login(const QString&user,const QString&password)
  7796. {
  7797. SqlQueryConnection h;
  7798. QSqlQuery*dbquery= h.operator->();
  7799. dbquery->prepare("SELECT 1 FROM typica_users WHERE name = :name AND password = :password AND active = TRUE");
  7800. dbquery->bindValue(":name",user);
  7801. dbquery->bindValue(":password",password);
  7802. dbquery->exec();
  7803. if(dbquery->next())
  7804. {
  7805. currentUser= user;
  7806. emit userChanged(currentUser);
  7807. return true;
  7808. }
  7809. return false;
  7810. }
  7811. /*:1161*//*1162:*/
  7812. #line 58 "./user.w"
  7813. bool Application::autoLogin()
  7814. {
  7815. SqlQueryConnection h;
  7816. QSqlQuery*dbquery= h.operator->();
  7817. dbquery->exec("SELECT name FROM typica_users WHERE auto_login = TRUE");
  7818. if(dbquery->next())
  7819. {
  7820. currentUser= dbquery->value(0).toString();
  7821. emit userChanged(currentUser);
  7822. return true;
  7823. }
  7824. return false;
  7825. }
  7826. /*:1162*/
  7827. #line 567 "./typica.w"
  7828. /*661:*/
  7829. #line 14056 "./typica.w"
  7830. SqlConnectionSetup::SqlConnectionSetup():
  7831. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7832. portnumber(new QLineEdit),
  7833. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7834. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7835. cancelButton(new QPushButton(tr("Cancel"))),
  7836. connectButton(new QPushButton(tr("Connect")))
  7837. {
  7838. QSettings settings;
  7839. driver->addItem("PostgreSQL","QPSQL");
  7840. formLayout->addRow(tr("Database driver:"),driver);
  7841. formLayout->addRow(tr("Host name:"),hostname);
  7842. hostname->setText(settings.value("database/hostname").toString());
  7843. formLayout->addRow(tr("Port number:"),portnumber);
  7844. portnumber->setText(settings.value("database/portnumber","5432").toString());
  7845. formLayout->addRow(tr("Database name:"),dbname);
  7846. dbname->setText(settings.value("database/dbname").toString());
  7847. formLayout->addRow(tr("User name:"),user);
  7848. user->setText(settings.value("database/user").toString());
  7849. password->setEchoMode(QLineEdit::Password);
  7850. formLayout->addRow(tr("Password:"),password);
  7851. password->setText(settings.value("database/password").toString());
  7852. layout->addLayout(formLayout);
  7853. buttons->addStretch(1);
  7854. buttons->addWidget(cancelButton);
  7855. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7856. buttons->addWidget(connectButton);
  7857. layout->addLayout(buttons);
  7858. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7859. connectButton->setDefault(true);
  7860. setLayout(layout);
  7861. setModal(true);
  7862. }
  7863. SqlConnectionSetup::~SqlConnectionSetup()
  7864. {
  7865. }
  7866. /*:661*//*662:*/
  7867. #line 14099 "./typica.w"
  7868. void SqlConnectionSetup::testConnection()
  7869. {
  7870. QSqlDatabase database=
  7871. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7872. toString());
  7873. database.setConnectOptions("application_name=Typica");
  7874. database.setHostName(hostname->text());
  7875. database.setPort(portnumber->text().toInt());
  7876. database.setDatabaseName(dbname->text());
  7877. database.setUserName(user->text());
  7878. database.setPassword(password->text());
  7879. if(database.open())
  7880. {
  7881. QSettings settings;
  7882. settings.setValue("database/exists","true");
  7883. settings.setValue("database/driver",
  7884. driver->itemData(driver->currentIndex()).toString());
  7885. settings.setValue("database/hostname",hostname->text());
  7886. settings.setValue("database/portnumber",portnumber->text());
  7887. settings.setValue("database/dbname",dbname->text());
  7888. settings.setValue("database/user",user->text());
  7889. settings.setValue("database/password",password->text());
  7890. AppInstance->setDatabaseConnected(true);
  7891. accept();
  7892. }
  7893. else
  7894. {
  7895. QMessageBox::information(this,tr("Database connection failed"),
  7896. tr("Failed to connect to database."));
  7897. }
  7898. }
  7899. /*:662*/
  7900. #line 568 "./typica.w"
  7901. /*666:*/
  7902. #line 14207 "./typica.w"
  7903. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7904. {
  7905. setModel(new QSqlQueryModel);
  7906. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7907. this,SLOT(openRow(QModelIndex)));
  7908. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7909. this,SLOT(persistColumnResize(int,int,int)));
  7910. connect(this,SIGNAL(activated(QModelIndex)),
  7911. this,SLOT(selectRow(QModelIndex)));
  7912. }
  7913. /*:666*//*667:*/
  7914. #line 14224 "./typica.w"
  7915. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7916. {
  7917. /*668:*/
  7918. #line 14233 "./typica.w"
  7919. QSettings settings;
  7920. /*669:*/
  7921. #line 14246 "./typica.w"
  7922. QWidget*topLevelWidget= this;
  7923. while(topLevelWidget->parentWidget())
  7924. {
  7925. topLevelWidget= topLevelWidget->parentWidget();
  7926. }
  7927. /*:669*/
  7928. #line 14235 "./typica.w"
  7929. settings.setValue(QString("columnWidths/%1/%2/%3").
  7930. arg(topLevelWidget->objectName()).
  7931. arg(objectName()).arg(column),
  7932. QVariant(newsize));
  7933. /*:668*/
  7934. #line 14227 "./typica.w"
  7935. }
  7936. /*:667*//*670:*/
  7937. #line 14256 "./typica.w"
  7938. void SqlQueryView::showEvent(QShowEvent*event)
  7939. {
  7940. /*671:*/
  7941. #line 14266 "./typica.w"
  7942. QSettings settings;
  7943. /*669:*/
  7944. #line 14246 "./typica.w"
  7945. QWidget*topLevelWidget= this;
  7946. while(topLevelWidget->parentWidget())
  7947. {
  7948. topLevelWidget= topLevelWidget->parentWidget();
  7949. }
  7950. /*:669*/
  7951. #line 14268 "./typica.w"
  7952. QString baseKey=
  7953. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7954. arg(objectName());
  7955. for(int i= 0;i<model()->columnCount();i++)
  7956. {
  7957. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7958. if(settings.contains(key))
  7959. {
  7960. setColumnWidth(i,settings.value(key).toInt());
  7961. }
  7962. }
  7963. /*:671*/
  7964. #line 14259 "./typica.w"
  7965. event->accept();
  7966. }
  7967. /*:670*//*672:*/
  7968. #line 14283 "./typica.w"
  7969. void SqlQueryView::openRow(const QModelIndex&index)
  7970. {
  7971. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7972. emit openEntryRow(index.row());
  7973. }
  7974. void SqlQueryView::selectRow(const QModelIndex&index)
  7975. {
  7976. emit selectEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7977. emit selectEntryRow(index.row());
  7978. }
  7979. /*:672*//*673:*/
  7980. #line 14298 "./typica.w"
  7981. void SqlQueryView::setQuery(const QString&query)
  7982. {
  7983. QSqlDatabase database= AppInstance->database();
  7984. database.open();
  7985. QSqlQuery q(query,database);
  7986. ((QSqlQueryModel*)model())->setQuery(q);
  7987. database.close();
  7988. }
  7989. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7990. const QVariant&value,int role)
  7991. {
  7992. return model()->setHeaderData(section,orientation,value,role);
  7993. }
  7994. /*:673*//*674:*/
  7995. #line 14316 "./typica.w"
  7996. QVariant SqlQueryView::data(int row,int column,int role)
  7997. {
  7998. return model()->data(model()->index(row,column),role);
  7999. }
  8000. /*:674*/
  8001. #line 569 "./typica.w"
  8002. /*180:*/
  8003. #line 4104 "./typica.w"
  8004. SqlQueryConnection::SqlQueryConnection(const QString&query)
  8005. {
  8006. QSqlDatabase database= AppInstance->database();
  8007. database.open();
  8008. q= new QSqlQuery(query,database);
  8009. connection= database.connectionName();
  8010. }
  8011. /*:180*//*181:*/
  8012. #line 4117 "./typica.w"
  8013. SqlQueryConnection::~SqlQueryConnection()
  8014. {
  8015. delete q;
  8016. {
  8017. QSqlDatabase database= QSqlDatabase::database(connection);
  8018. database.close();
  8019. }
  8020. QSqlDatabase::removeDatabase(connection);
  8021. }
  8022. /*:181*//*182:*/
  8023. #line 4131 "./typica.w"
  8024. QSqlQuery*SqlQueryConnection::operator->()const
  8025. {
  8026. return q;
  8027. }
  8028. /*:182*/
  8029. #line 570 "./typica.w"
  8030. /*693:*/
  8031. #line 14684 "./typica.w"
  8032. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  8033. area(frame),configuration(description)
  8034. {
  8035. refresh();
  8036. }
  8037. ReportTable::~ReportTable()
  8038. {
  8039. }
  8040. /*:693*//*694:*/
  8041. #line 14700 "./typica.w"
  8042. void ReportTable::bind(QString placeholder,QVariant value)
  8043. {
  8044. bindings.insert(placeholder,value);
  8045. }
  8046. /*:694*//*695:*/
  8047. #line 14710 "./typica.w"
  8048. void ReportTable::refresh()
  8049. {
  8050. /*696:*/
  8051. #line 14731 "./typica.w"
  8052. QTextCursor cursor= area->firstCursorPosition();
  8053. while(cursor<area->lastCursorPosition())
  8054. {
  8055. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  8056. }
  8057. cursor.removeSelectedText();
  8058. /*:696*/
  8059. #line 14713 "./typica.w"
  8060. int rows= 1;
  8061. int columns= 1;
  8062. int currentRow= 0;
  8063. QTextTable*table= cursor.insertTable(rows,columns);
  8064. /*697:*/
  8065. #line 14744 "./typica.w"
  8066. QTextTableFormat format= table->format();
  8067. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  8068. if(configuration.hasAttribute("align"))
  8069. {
  8070. if(configuration.attribute("align")=="center")
  8071. {
  8072. format.setAlignment(Qt::AlignHCenter);
  8073. }
  8074. }
  8075. table->setFormat(format);
  8076. /*:697*/
  8077. #line 14718 "./typica.w"
  8078. /*698:*/
  8079. #line 14758 "./typica.w"
  8080. QDomNodeList children= configuration.childNodes();
  8081. for(int i= 0;i<children.count();i++)
  8082. {
  8083. QDomNode current;
  8084. QDomElement currentElement;
  8085. current= children.at(i);
  8086. if(current.isElement())
  8087. {
  8088. currentElement= current.toElement();
  8089. if(currentElement.tagName()=="query")
  8090. {
  8091. /*699:*/
  8092. #line 14785 "./typica.w"
  8093. SqlQueryConnection h;
  8094. QSqlQuery*query= h.operator->();
  8095. query->prepare(currentElement.text());
  8096. foreach(QString key,bindings.uniqueKeys())
  8097. {
  8098. if(currentElement.text().contains(key))
  8099. {
  8100. query->bindValue(key,bindings.value(key));
  8101. }
  8102. }
  8103. query->exec();
  8104. if(!query->next())
  8105. {
  8106. continue;
  8107. }
  8108. if(query->record().count()> columns)
  8109. {
  8110. table->appendColumns(query->record().count()-columns);
  8111. }
  8112. do
  8113. {
  8114. table->appendRows(1);
  8115. rows++;
  8116. currentRow++;
  8117. for(int j= 0;j<query->record().count();j++)
  8118. {
  8119. QTextTableCell cell= table->cellAt(currentRow,j);
  8120. cursor= cell.firstCursorPosition();
  8121. cursor.insertText(query->value(j).toString());
  8122. }
  8123. }while(query->next());
  8124. /*:699*/
  8125. #line 14770 "./typica.w"
  8126. }
  8127. else if(currentElement.tagName()=="row")
  8128. {
  8129. /*700:*/
  8130. #line 14825 "./typica.w"
  8131. table->appendRows(1);
  8132. currentRow++;
  8133. rows++;
  8134. QDomNodeList rowChildren= currentElement.childNodes();
  8135. int currentColumn= 0;
  8136. for(int j= 0;j<rowChildren.count();j++)
  8137. {
  8138. QDomNode node;
  8139. QDomElement nodeElement;
  8140. node= rowChildren.at(j);
  8141. if(node.isElement())
  8142. {
  8143. nodeElement= node.toElement();
  8144. if(nodeElement.tagName()=="cell")
  8145. {
  8146. if(currentColumn==columns)
  8147. {
  8148. table->appendColumns(1);
  8149. columns++;
  8150. }
  8151. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  8152. cursor= cell.firstCursorPosition();
  8153. cursor.insertText(nodeElement.text());
  8154. currentColumn++;
  8155. }
  8156. }
  8157. }
  8158. /*:700*/
  8159. #line 14774 "./typica.w"
  8160. }
  8161. }
  8162. }
  8163. /*:698*/
  8164. #line 14719 "./typica.w"
  8165. if(rows> 1)
  8166. {
  8167. table->removeRows(0,1);
  8168. }
  8169. }
  8170. /*:695*/
  8171. #line 571 "./typica.w"
  8172. /*732:*/
  8173. #line 14931 "./typica.w"
  8174. FormArray::FormArray(QDomElement description):configuration(description),
  8175. maxwidth(-1),maxheight(-1)
  8176. {
  8177. setWidget(&itemContainer);
  8178. itemContainer.setLayout(&itemLayout);
  8179. }
  8180. /*:732*//*733:*/
  8181. #line 14948 "./typica.w"
  8182. void FormArray::addElements(int copies)
  8183. {
  8184. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  8185. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  8186. QWidget*widget;
  8187. for(int i= 0;i<copies;i++)
  8188. {
  8189. widget= new QWidget;
  8190. if(maxwidth> -1)
  8191. {
  8192. widget->setMaximumWidth(maxwidth);
  8193. }
  8194. if(maxheight> -1)
  8195. {
  8196. widget->setMaximumHeight(maxheight);
  8197. }
  8198. if(configuration.hasChildNodes())
  8199. {
  8200. widgetStack->push(widget);
  8201. populateWidget(configuration,widgetStack,layoutStack);
  8202. widgetStack->pop();
  8203. widget->setMinimumHeight(widget->sizeHint().height());
  8204. itemLayout.addWidget(widget);
  8205. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  8206. {
  8207. itemContainer.setMinimumHeight(maxheight*elements()+50);
  8208. }
  8209. else
  8210. {
  8211. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  8212. +widget->sizeHint().height());
  8213. }
  8214. if(maxwidth> -1)
  8215. {
  8216. itemContainer.setMinimumWidth(maxwidth+50);
  8217. }
  8218. else
  8219. {
  8220. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  8221. }
  8222. }
  8223. }
  8224. }
  8225. /*:733*//*734:*/
  8226. #line 14998 "./typica.w"
  8227. QWidget*FormArray::elementAt(int index)
  8228. {
  8229. if(index<itemLayout.count())
  8230. {
  8231. QLayoutItem*item= itemLayout.itemAt(index);
  8232. return item->widget();
  8233. }
  8234. else
  8235. {
  8236. return NULL;
  8237. }
  8238. }
  8239. /*:734*//*735:*/
  8240. #line 15015 "./typica.w"
  8241. void FormArray::removeAllElements()
  8242. {
  8243. while(itemLayout.count()> 0)
  8244. {
  8245. QLayoutItem*item;
  8246. item= itemLayout.itemAt(0);
  8247. item->widget()->hide();
  8248. itemLayout.removeWidget(item->widget());
  8249. }
  8250. itemContainer.setMinimumHeight(0);
  8251. }
  8252. /*:735*//*736:*/
  8253. #line 15031 "./typica.w"
  8254. int FormArray::elements()
  8255. {
  8256. return itemLayout.count();
  8257. }
  8258. /*:736*//*737:*/
  8259. #line 15042 "./typica.w"
  8260. void FormArray::setMaximumElementWidth(int width)
  8261. {
  8262. maxwidth= width;
  8263. }
  8264. void FormArray::setMaximumElementHeight(int height)
  8265. {
  8266. maxheight= height;
  8267. }
  8268. /*:737*/
  8269. #line 572 "./typica.w"
  8270. /*743:*/
  8271. #line 15173 "./typica.w"
  8272. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  8273. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  8274. {
  8275. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  8276. QPointF(0,5);
  8277. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  8278. QPointF(10,5);
  8279. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  8280. QPointF(0,0);
  8281. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  8282. initialBrush.setColor(QColor(170,170,255));
  8283. initialBrush.setStyle(Qt::SolidPattern);
  8284. finalBrush.setColor(Qt::blue);
  8285. finalBrush.setStyle(Qt::SolidPattern);
  8286. initialDecrement.setPolygon(left);
  8287. initialDecrement.setBrush(initialBrush);
  8288. initialDecrement.setPos(0,0);
  8289. scene.addItem(&initialDecrement);
  8290. initialIncrement.setPolygon(right);
  8291. initialIncrement.setBrush(initialBrush);
  8292. initialIncrement.setPos(122,0);
  8293. scene.addItem(&initialIncrement);
  8294. finalDecrement.setPolygon(left);
  8295. finalDecrement.setBrush(finalBrush);
  8296. finalDecrement.setPos(0,12);
  8297. scene.addItem(&finalDecrement);
  8298. finalIncrement.setPolygon(right);
  8299. finalIncrement.setBrush(finalBrush);
  8300. finalIncrement.setPos(122,12);
  8301. scene.addItem(&finalIncrement);
  8302. scalePath.moveTo(0,10);
  8303. scalePath.lineTo(100,10);
  8304. scalePath.moveTo(0,0);
  8305. scalePath.lineTo(0,20);
  8306. scalePath.moveTo(10,5);
  8307. scalePath.lineTo(10,15);
  8308. scalePath.moveTo(20,5);
  8309. scalePath.lineTo(20,15);
  8310. scalePath.moveTo(30,5);
  8311. scalePath.lineTo(30,15);
  8312. scalePath.moveTo(40,5);
  8313. scalePath.lineTo(40,15);
  8314. scalePath.moveTo(50,0);
  8315. scalePath.lineTo(50,20);
  8316. scalePath.moveTo(60,5);
  8317. scalePath.lineTo(60,15);
  8318. scalePath.moveTo(70,5);
  8319. scalePath.lineTo(70,15);
  8320. scalePath.moveTo(80,5);
  8321. scalePath.lineTo(80,15);
  8322. scalePath.moveTo(90,5);
  8323. scalePath.lineTo(90,15);
  8324. scalePath.moveTo(100,0);
  8325. scalePath.lineTo(100,20);
  8326. scaleLine.setPath(scalePath);
  8327. scaleLine.setPos(16,1);
  8328. scene.addItem(&scaleLine);
  8329. setScene(&scene);
  8330. initialIndicator.setPolygon(down);
  8331. initialIndicator.setBrush(initialBrush);
  8332. finalIndicator.setPolygon(up);
  8333. finalIndicator.setBrush(finalBrush);
  8334. setMinimumSize(sizeHint());
  8335. setMaximumSize(sizeHint());
  8336. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8337. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8338. setMinimumSize(sizeHint());
  8339. }
  8340. /*:743*//*744:*/
  8341. #line 15246 "./typica.w"
  8342. QSize ScaleControl::sizeHint()const
  8343. {
  8344. return QSize(140,30);
  8345. }
  8346. /*:744*//*745:*/
  8347. #line 15255 "./typica.w"
  8348. void ScaleControl::setInitialValue(double value)
  8349. {
  8350. if(value>=0&&value<=10)
  8351. {
  8352. nonScoredValue= value;
  8353. if(!initialSet)
  8354. {
  8355. scene.addItem(&initialIndicator);
  8356. }
  8357. initialSet= true;
  8358. initialIndicator.setPos(value*10+16,10);
  8359. emit initialChanged(value);
  8360. if(!finalSet)
  8361. {
  8362. setFinalValue(value);
  8363. }
  8364. }
  8365. }
  8366. void ScaleControl::setFinalValue(double value)
  8367. {
  8368. if(value>=0&&value<=10)
  8369. {
  8370. scoredValue= value;
  8371. if(!finalSet)
  8372. {
  8373. scene.addItem(&finalIndicator);
  8374. }
  8375. finalSet= true;
  8376. finalIndicator.setPos(value*10+16,11);
  8377. emit finalChanged(value);
  8378. }
  8379. }
  8380. /*:745*//*746:*/
  8381. #line 15292 "./typica.w"
  8382. double ScaleControl::initialValue(void)
  8383. {
  8384. return nonScoredValue;
  8385. }
  8386. double ScaleControl::finalValue(void)
  8387. {
  8388. return scoredValue;
  8389. }
  8390. /*:746*//*747:*/
  8391. #line 15313 "./typica.w"
  8392. void ScaleControl::mousePressEvent(QMouseEvent*event)
  8393. {
  8394. /*748:*/
  8395. #line 15325 "./typica.w"
  8396. if(event->button()!=Qt::LeftButton)
  8397. {
  8398. event->ignore();
  8399. return;
  8400. }
  8401. /*:748*/
  8402. #line 15316 "./typica.w"
  8403. scaleDown= true;
  8404. event->accept();
  8405. }
  8406. /*:747*//*749:*/
  8407. #line 15336 "./typica.w"
  8408. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  8409. {
  8410. /*748:*/
  8411. #line 15325 "./typica.w"
  8412. if(event->button()!=Qt::LeftButton)
  8413. {
  8414. event->ignore();
  8415. return;
  8416. }
  8417. /*:748*/
  8418. #line 15339 "./typica.w"
  8419. if(!scaleDown)
  8420. {
  8421. event->ignore();
  8422. return;
  8423. }
  8424. scaleDown= false;
  8425. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8426. /*750:*/
  8427. #line 15361 "./typica.w"
  8428. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  8429. {
  8430. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8431. {
  8432. if(initialSet)
  8433. {
  8434. setInitialValue(nonScoredValue-0.05);
  8435. }
  8436. event->accept();
  8437. return;
  8438. }
  8439. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8440. {
  8441. if(finalSet)
  8442. {
  8443. setFinalValue(scoredValue-0.05);
  8444. event->accept();
  8445. return;
  8446. }
  8447. }
  8448. }
  8449. /*:750*/
  8450. #line 15347 "./typica.w"
  8451. /*751:*/
  8452. #line 15387 "./typica.w"
  8453. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  8454. {
  8455. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8456. {
  8457. if(initialSet)
  8458. {
  8459. setInitialValue(nonScoredValue+0.05);
  8460. event->accept();
  8461. return;
  8462. }
  8463. }
  8464. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8465. {
  8466. if(finalSet)
  8467. {
  8468. setFinalValue(scoredValue+0.05);
  8469. event->accept();
  8470. return;
  8471. }
  8472. }
  8473. }
  8474. /*:751*/
  8475. #line 15348 "./typica.w"
  8476. /*752:*/
  8477. #line 15413 "./typica.w"
  8478. double relativeX= sceneCoordinate.x()-16;
  8479. if(initialSet)
  8480. {
  8481. if(relativeX>=0&&relativeX<=100)
  8482. {
  8483. setFinalValue(relativeX/10.0);
  8484. event->accept();
  8485. return;
  8486. }
  8487. }
  8488. else
  8489. {
  8490. if(relativeX>=0&&relativeX<=100)
  8491. {
  8492. setInitialValue(relativeX/10.0);
  8493. event->accept();
  8494. return;
  8495. }
  8496. }
  8497. /*:752*/
  8498. #line 15349 "./typica.w"
  8499. event->ignore();
  8500. return;
  8501. }
  8502. /*:749*/
  8503. #line 573 "./typica.w"
  8504. /*754:*/
  8505. #line 15479 "./typica.w"
  8506. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  8507. valueSet(false),scaleDown(false)
  8508. {
  8509. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8510. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8511. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  8512. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  8513. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  8514. theBrush.setColor(Qt::blue);
  8515. theBrush.setStyle(Qt::SolidPattern);
  8516. increment.setPolygon(up);
  8517. increment.setBrush(theBrush);
  8518. increment.setPos(0,0);
  8519. scene.addItem(&increment);
  8520. decrement.setPolygon(down);
  8521. decrement.setBrush(theBrush);
  8522. decrement.setPos(0,122);
  8523. scene.addItem(&decrement);
  8524. scalePath.moveTo(5,0);
  8525. scalePath.lineTo(5,100);
  8526. scalePath.moveTo(0,0);
  8527. scalePath.lineTo(10,0);
  8528. scalePath.moveTo(0,10);
  8529. scalePath.lineTo(10,10);
  8530. scalePath.moveTo(0,20);
  8531. scalePath.lineTo(10,20);
  8532. scalePath.moveTo(0,30);
  8533. scalePath.lineTo(10,30);
  8534. scalePath.moveTo(0,40);
  8535. scalePath.lineTo(10,40);
  8536. scalePath.moveTo(0,50);
  8537. scalePath.lineTo(10,50);
  8538. scalePath.moveTo(0,60);
  8539. scalePath.lineTo(10,60);
  8540. scalePath.moveTo(0,70);
  8541. scalePath.lineTo(10,70);
  8542. scalePath.moveTo(0,80);
  8543. scalePath.lineTo(10,80);
  8544. scalePath.moveTo(0,90);
  8545. scalePath.lineTo(10,90);
  8546. scalePath.moveTo(0,100);
  8547. scalePath.lineTo(10,100);
  8548. scaleLine.setPath(scalePath);
  8549. scaleLine.setPos(0,16);
  8550. scene.addItem(&scaleLine);
  8551. setScene(&scene);
  8552. indicator.setPolygon(left);
  8553. indicator.setBrush(theBrush);
  8554. setMinimumSize(sizeHint());
  8555. setMaximumSize(sizeHint());
  8556. }
  8557. /*:754*//*755:*/
  8558. #line 15534 "./typica.w"
  8559. QSize IntensityControl::sizeHint()const
  8560. {
  8561. return QSize(25,160);
  8562. }
  8563. /*:755*//*756:*/
  8564. #line 15549 "./typica.w"
  8565. void IntensityControl::setValue(double val)
  8566. {
  8567. if(val>=0&&val<=10)
  8568. {
  8569. theValue= val;
  8570. if(!valueSet)
  8571. {
  8572. scene.addItem(&indicator);
  8573. }
  8574. valueSet= true;
  8575. indicator.setPos(6,(100-(val*10))+16);
  8576. emit(valueChanged(val));
  8577. }
  8578. else if(val<1)
  8579. {
  8580. setValue(0);
  8581. }
  8582. else
  8583. {
  8584. setValue(10);
  8585. }
  8586. }
  8587. double IntensityControl::value()
  8588. {
  8589. return theValue;
  8590. }
  8591. /*:756*//*757:*/
  8592. #line 15581 "./typica.w"
  8593. void IntensityControl::mousePressEvent(QMouseEvent*event)
  8594. {
  8595. /*748:*/
  8596. #line 15325 "./typica.w"
  8597. if(event->button()!=Qt::LeftButton)
  8598. {
  8599. event->ignore();
  8600. return;
  8601. }
  8602. /*:748*/
  8603. #line 15584 "./typica.w"
  8604. scaleDown= true;
  8605. event->accept();
  8606. }
  8607. /*:757*//*758:*/
  8608. #line 15595 "./typica.w"
  8609. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  8610. {
  8611. /*748:*/
  8612. #line 15325 "./typica.w"
  8613. if(event->button()!=Qt::LeftButton)
  8614. {
  8615. event->ignore();
  8616. return;
  8617. }
  8618. /*:748*/
  8619. #line 15598 "./typica.w"
  8620. if(!scaleDown)
  8621. {
  8622. event->ignore();
  8623. return;
  8624. }
  8625. scaleDown= false;
  8626. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8627. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  8628. {
  8629. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8630. {
  8631. if(valueSet)
  8632. {
  8633. setValue(theValue+0.05);
  8634. }
  8635. event->accept();
  8636. return;
  8637. }
  8638. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  8639. {
  8640. if(valueSet)
  8641. {
  8642. setValue(theValue-0.05);
  8643. }
  8644. event->accept();
  8645. return;
  8646. }
  8647. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8648. {
  8649. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8650. event->accept();
  8651. return;
  8652. }
  8653. }
  8654. }
  8655. /*:758*/
  8656. #line 574 "./typica.w"
  8657. /*384:*/
  8658. #line 8593 "./typica.w"
  8659. void ThresholdDetector::newMeasurement(Measurement measure)
  8660. {
  8661. if((currentDirection==Ascending&&previousValue<threshold&&
  8662. previousValueValid)||(currentDirection==Descending&&
  8663. previousValue> threshold&&previousValueValid))
  8664. {
  8665. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8666. (currentDirection==Descending&&measure.temperature()<=threshold))
  8667. {
  8668. double offset= measure.time().hour()*60*60;
  8669. offset+= measure.time().minute()*60;
  8670. offset+= measure.time().second();
  8671. offset+= measure.time().msec()/1000;
  8672. emit timeForValue(offset);
  8673. }
  8674. }
  8675. previousValue= measure.temperature();
  8676. previousValueValid= true;
  8677. }
  8678. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8679. previousValueValid(false),
  8680. previousValue(-1),threshold(value),currentDirection(Ascending)
  8681. {
  8682. }
  8683. void ThresholdDetector::setThreshold(double value)
  8684. {
  8685. threshold= value;
  8686. }
  8687. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8688. {
  8689. currentDirection= direction;
  8690. }
  8691. /*:384*/
  8692. #line 575 "./typica.w"
  8693. /*840:*/
  8694. #line 17487 "./typica.w"
  8695. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8696. lister(new QextSerialEnumerator)
  8697. {
  8698. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8699. QextPortInfo port;
  8700. foreach(port,ports)
  8701. {
  8702. #ifdef Q_OS_WIN32
  8703. addItem(port.portName);
  8704. #else
  8705. addItem(port.physName);
  8706. #endif
  8707. }
  8708. lister->setUpNotifications();
  8709. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8710. this,SLOT(addDevice(QextPortInfo)));
  8711. setEditable(true);
  8712. }
  8713. void PortSelector::addDevice(QextPortInfo port)
  8714. {
  8715. addItem(port.portName);
  8716. }
  8717. /*:840*/
  8718. #line 576 "./typica.w"
  8719. /*842:*/
  8720. #line 17579 "./typica.w"
  8721. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8722. {
  8723. QMetaObject meta= BaudSelector::staticMetaObject;
  8724. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8725. for(int i= 0;i<type.keyCount();i++)
  8726. {
  8727. addItem(QString("%1").arg(type.value(i)));
  8728. }
  8729. }
  8730. /*:842*/
  8731. #line 577 "./typica.w"
  8732. /*844:*/
  8733. #line 17617 "./typica.w"
  8734. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8735. {
  8736. QMetaObject meta= ParitySelector::staticMetaObject;
  8737. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8738. for(int i= 0;i<type.keyCount();i++)
  8739. {
  8740. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8741. }
  8742. }
  8743. /*:844*/
  8744. #line 578 "./typica.w"
  8745. /*846:*/
  8746. #line 17647 "./typica.w"
  8747. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8748. {
  8749. QMetaObject meta= FlowSelector::staticMetaObject;
  8750. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8751. for(int i= 0;i<type.keyCount();i++)
  8752. {
  8753. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8754. }
  8755. }
  8756. /*:846*/
  8757. #line 579 "./typica.w"
  8758. /*848:*/
  8759. #line 17682 "./typica.w"
  8760. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8761. {
  8762. QMetaObject meta= StopSelector::staticMetaObject;
  8763. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8764. for(int i= 0;i<type.keyCount();i++)
  8765. {
  8766. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8767. }
  8768. }
  8769. /*:848*/
  8770. #line 580 "./typica.w"
  8771. /*912:*/
  8772. #line 19464 "./typica.w"
  8773. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8774. :BasicDeviceConfigurationWidget(model,index),
  8775. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8776. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8777. decimalQuery(new QCheckBox(tr("Enable"))),
  8778. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8779. unitQuery(new QCheckBox(tr("Enable"))),
  8780. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8781. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8782. pVAddress(new ShortHexSpinBox),
  8783. sVEnabled(new QCheckBox(tr("Enable"))),
  8784. sVReadAddress(new ShortHexSpinBox),
  8785. deviceLimit(new QCheckBox(tr("Enable"))),
  8786. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8787. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8788. sVWritable(new QCheckBox(tr("Enable"))),
  8789. sVOutputAddr(new ShortHexSpinBox),
  8790. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8791. {
  8792. QHBoxLayout*layout= new QHBoxLayout;
  8793. QWidget*form= new QWidget;
  8794. QHBoxLayout*masterLayout= new QHBoxLayout;
  8795. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8796. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8797. QFormLayout*serialSection= new QFormLayout;
  8798. serialSection->addRow(QString(tr("Port:")),port);
  8799. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8800. serialSection->addRow(QString(tr("Parity:")),parity);
  8801. serialSection->addRow(QString(tr("Flow control:")),flow);
  8802. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8803. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8804. serialSectionBox->setLayout(serialSection);
  8805. portAndDeviceLayout->addWidget(serialSectionBox);
  8806. QFormLayout*deviceSection= new QFormLayout;
  8807. station->setMinimum(1);
  8808. station->setMaximum(255);
  8809. decimalPosition->setMinimum(0);
  8810. decimalPosition->setMaximum(9);
  8811. valueF->setMinimum(0);
  8812. valueF->setMaximum(0xFFFF);
  8813. valueC->setMinimum(0);
  8814. valueC->setMaximum(0xFFFF);
  8815. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8816. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8817. deviceSection->addRow(tr("Station:"),station);
  8818. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8819. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8820. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8821. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8822. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8823. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8824. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8825. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8826. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8827. deviceSectionBox->setLayout(deviceSection);
  8828. portAndDeviceLayout->addWidget(deviceSectionBox);
  8829. QFormLayout*pVSection= new QFormLayout;
  8830. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8831. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8832. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8833. pVSection->addRow(pVHideBox);
  8834. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8835. processValueBox->setLayout(pVSection);
  8836. seriesLayout->addWidget(processValueBox);
  8837. QFormLayout*sVSection= new QFormLayout;
  8838. sVLower->setDecimals(1);
  8839. sVLower->setMinimum(0.0);
  8840. sVLower->setMaximum(999.9);
  8841. sVUpper->setDecimals(1);
  8842. sVUpper->setMinimum(0.0);
  8843. sVUpper->setMaximum(999.9);
  8844. sVSection->addRow(tr("Set value:"),sVEnabled);
  8845. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8846. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8847. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8848. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8849. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8850. sVSection->addRow(tr("Lower limit:"),sVLower);
  8851. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8852. sVSection->addRow(tr("Output set value:"),sVWritable);
  8853. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8854. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8855. sVSection->addRow(sVHideBox);
  8856. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8857. setValueBox->setLayout(sVSection);
  8858. seriesLayout->addWidget(setValueBox);
  8859. masterLayout->addLayout(portAndDeviceLayout);
  8860. masterLayout->addLayout(seriesLayout);
  8861. form->setLayout(masterLayout);
  8862. /*816:*/
  8863. #line 16928 "./typica.w"
  8864. QDomElement referenceElement=
  8865. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8866. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8867. QDomElement node;
  8868. /*:816*/
  8869. #line 19554 "./typica.w"
  8870. for(int i= 0;i<configData.size();i++)
  8871. {
  8872. node= configData.at(i).toElement();
  8873. if(node.attribute("name")=="port")
  8874. {
  8875. QString portname= node.attribute("value");
  8876. int idx= port->findText(portname);
  8877. if(idx>=0)
  8878. {
  8879. port->setCurrentIndex(idx);
  8880. }
  8881. else
  8882. {
  8883. port->addItem(portname);
  8884. }
  8885. }
  8886. else if(node.attribute("name")=="baud")
  8887. {
  8888. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8889. }
  8890. else if(node.attribute("name")=="parity")
  8891. {
  8892. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8893. }
  8894. else if(node.attribute("name")=="flow")
  8895. {
  8896. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8897. }
  8898. else if(node.attribute("name")=="stop")
  8899. {
  8900. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8901. }
  8902. else if(node.attribute("name")=="station")
  8903. {
  8904. station->setValue(node.attribute("value").toInt());
  8905. }
  8906. else if(node.attribute("name")=="decimalQuery")
  8907. {
  8908. if(node.attribute("value")=="true")
  8909. {
  8910. decimalQuery->setChecked(true);
  8911. }
  8912. else
  8913. {
  8914. decimalQuery->setChecked(false);
  8915. }
  8916. }
  8917. else if(node.attribute("name")=="decimalAddress")
  8918. {
  8919. decimalAddress->setValue(node.attribute("value").toInt());
  8920. }
  8921. else if(node.attribute("name")=="decimalPosition")
  8922. {
  8923. decimalPosition->setValue(node.attribute("value").toInt());
  8924. }
  8925. else if(node.attribute("name")=="unitQuery")
  8926. {
  8927. if(node.attribute("value")=="true")
  8928. {
  8929. unitQuery->setChecked(true);
  8930. }
  8931. else
  8932. {
  8933. unitQuery->setChecked(false);
  8934. }
  8935. }
  8936. else if(node.attribute("name")=="unitAddress")
  8937. {
  8938. unitAddress->setValue(node.attribute("value").toInt());
  8939. }
  8940. else if(node.attribute("name")=="valueF")
  8941. {
  8942. valueF->setValue(node.attribute("value").toInt());
  8943. }
  8944. else if(node.attribute("name")=="valueC")
  8945. {
  8946. valueC->setValue(node.attribute("value").toInt());
  8947. }
  8948. else if(node.attribute("name")=="fixedUnit")
  8949. {
  8950. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8951. }
  8952. else if(node.attribute("name")=="pVAddress")
  8953. {
  8954. pVAddress->setValue(node.attribute("value").toInt());
  8955. }
  8956. else if(node.attribute("name")=="sVEnabled")
  8957. {
  8958. if(node.attribute("value")=="true")
  8959. {
  8960. sVEnabled->setChecked(true);
  8961. }
  8962. else
  8963. {
  8964. sVEnabled->setChecked(false);
  8965. }
  8966. }
  8967. else if(node.attribute("name")=="sVReadAddress")
  8968. {
  8969. sVReadAddress->setValue(node.attribute("value").toInt());
  8970. }
  8971. else if(node.attribute("name")=="deviceLimit")
  8972. {
  8973. if(node.attribute("value")=="true")
  8974. {
  8975. deviceLimit->setChecked(true);
  8976. }
  8977. else
  8978. {
  8979. deviceLimit->setChecked(false);
  8980. }
  8981. }
  8982. else if(node.attribute("name")=="sVLowerAddr")
  8983. {
  8984. sVLowerAddr->setValue(node.attribute("value").toInt());
  8985. }
  8986. else if(node.attribute("name")=="sVUpperAddr")
  8987. {
  8988. sVUpperAddr->setValue(node.attribute("value").toInt());
  8989. }
  8990. else if(node.attribute("name")=="sVLower")
  8991. {
  8992. sVLower->setValue(node.attribute("value").toDouble());
  8993. }
  8994. else if(node.attribute("name")=="sVUpper")
  8995. {
  8996. sVUpper->setValue(node.attribute("value").toDouble());
  8997. }
  8998. else if(node.attribute("name")=="sVWritable")
  8999. {
  9000. if(node.attribute("value")=="true")
  9001. {
  9002. sVWritable->setChecked(true);
  9003. }
  9004. else
  9005. {
  9006. sVWritable->setChecked(false);
  9007. }
  9008. }
  9009. else if(node.attribute("name")=="sVOutputAddr")
  9010. {
  9011. sVOutputAddr->setValue(node.attribute("value").toInt());
  9012. }
  9013. else if(node.attribute("name")=="pvcolname")
  9014. {
  9015. pVColumnName->setText(node.attribute("value"));
  9016. }
  9017. else if(node.attribute("name")=="svcolname")
  9018. {
  9019. sVColumnName->setText(node.attribute("value"));
  9020. }
  9021. else if(node.attribute("name")=="pvhidden")
  9022. {
  9023. pVHideBox->setChecked(node.attribute("value")=="true");
  9024. }
  9025. else if(node.attribute("name")=="svhidden")
  9026. {
  9027. sVHideBox->setChecked(node.attribute("value")=="true");
  9028. }
  9029. }
  9030. updatePort(port->currentText());
  9031. updateBaudRate(baud->currentText());
  9032. updateParity(parity->itemData(parity->currentIndex()).toString());
  9033. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  9034. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  9035. updateStation(station->value());
  9036. updateFixedDecimal(decimalQuery->isChecked());
  9037. updateDecimalAddress(decimalAddress->value());
  9038. updateDecimalPosition(decimalPosition->value());
  9039. updateFixedUnit(unitQuery->isChecked());
  9040. updateUnitAddress(unitAddress->value());
  9041. updateValueForF(valueF->value());
  9042. updateValueForC(valueC->value());
  9043. updateUnit(fixedUnit->currentText());
  9044. updatePVAddress(pVAddress->value());
  9045. updateSVEnabled(sVEnabled->isChecked());
  9046. updateSVReadAddress(sVReadAddress->value());
  9047. updateDeviceLimit(deviceLimit->isChecked());
  9048. updateSVLowerAddress(sVLowerAddr->value());
  9049. updateSVUpperAddress(sVUpperAddr->value());
  9050. updateSVLower(sVLower->value());
  9051. updateSVUpper(sVUpper->value());
  9052. updateSVWritable(sVWritable->isChecked());
  9053. updateSVWriteAddress(sVOutputAddr->value());
  9054. updatePVColumnName(pVColumnName->text());
  9055. updateSVColumnName(sVColumnName->text());
  9056. updatePVHidden(pVHideBox->isChecked());
  9057. updateSVHidden(sVHideBox->isChecked());
  9058. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  9059. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  9060. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  9061. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  9062. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  9063. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  9064. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  9065. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  9066. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  9067. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  9068. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  9069. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  9070. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  9071. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  9072. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  9073. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  9074. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  9075. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  9076. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  9077. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  9078. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  9079. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  9080. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  9081. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  9082. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  9083. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  9084. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  9085. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  9086. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  9087. layout->addWidget(form);
  9088. setLayout(layout);
  9089. }
  9090. void ModbusConfigurator::updatePort(const QString&newPort)
  9091. {
  9092. updateAttribute("port",newPort);
  9093. }
  9094. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  9095. {
  9096. updateAttribute("baud",newRate);
  9097. }
  9098. void ModbusConfigurator::updateParity(const QString&)
  9099. {
  9100. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  9101. }
  9102. void ModbusConfigurator::updateFlowControl(const QString&)
  9103. {
  9104. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  9105. }
  9106. void ModbusConfigurator::updateStopBits(const QString&)
  9107. {
  9108. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  9109. }
  9110. void ModbusConfigurator::updateStation(int station)
  9111. {
  9112. updateAttribute("station",QString("%1").arg(station));
  9113. }
  9114. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  9115. {
  9116. updateAttribute("decimalQuery",fixed?"true":"false");
  9117. }
  9118. void ModbusConfigurator::updateDecimalAddress(int address)
  9119. {
  9120. updateAttribute("decimalAddress",QString("%1").arg(address));
  9121. }
  9122. void ModbusConfigurator::updateDecimalPosition(int position)
  9123. {
  9124. updateAttribute("decimalPosition",QString("%1").arg(position));
  9125. }
  9126. void ModbusConfigurator::updateFixedUnit(bool fixed)
  9127. {
  9128. updateAttribute("unitQuery",fixed?"true":"false");
  9129. }
  9130. void ModbusConfigurator::updateUnitAddress(int address)
  9131. {
  9132. updateAttribute("unitAddress",QString("%1").arg(address));
  9133. }
  9134. void ModbusConfigurator::updateValueForF(int value)
  9135. {
  9136. updateAttribute("valueF",QString("%1").arg(value));
  9137. }
  9138. void ModbusConfigurator::updateValueForC(int value)
  9139. {
  9140. updateAttribute("valueC",QString("%1").arg(value));
  9141. }
  9142. void ModbusConfigurator::updateUnit(const QString&newUnit)
  9143. {
  9144. updateAttribute("fixedUnit",newUnit);
  9145. }
  9146. void ModbusConfigurator::updatePVAddress(int address)
  9147. {
  9148. updateAttribute("pVAddress",QString("%1").arg(address));
  9149. }
  9150. void ModbusConfigurator::updateSVEnabled(bool enabled)
  9151. {
  9152. updateAttribute("sVEnabled",enabled?"true":"false");
  9153. }
  9154. void ModbusConfigurator::updateSVReadAddress(int address)
  9155. {
  9156. updateAttribute("sVReadAddress",QString("%1").arg(address));
  9157. }
  9158. void ModbusConfigurator::updateDeviceLimit(bool query)
  9159. {
  9160. updateAttribute("deviceLimit",query?"true":"false");
  9161. }
  9162. void ModbusConfigurator::updateSVLowerAddress(int address)
  9163. {
  9164. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  9165. }
  9166. void ModbusConfigurator::updateSVUpperAddress(int address)
  9167. {
  9168. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  9169. }
  9170. void ModbusConfigurator::updateSVLower(double value)
  9171. {
  9172. updateAttribute("sVLower",QString("%1").arg(value));
  9173. }
  9174. void ModbusConfigurator::updateSVUpper(double value)
  9175. {
  9176. updateAttribute("sVUpper",QString("%1").arg(value));
  9177. }
  9178. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  9179. {
  9180. updateAttribute("sVWritable",canWriteSV?"true":"false");
  9181. }
  9182. void ModbusConfigurator::updateSVWriteAddress(int address)
  9183. {
  9184. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  9185. }
  9186. void ModbusConfigurator::updatePVColumnName(const QString&name)
  9187. {
  9188. updateAttribute("pvcolname",name);
  9189. }
  9190. void ModbusConfigurator::updateSVColumnName(const QString&name)
  9191. {
  9192. updateAttribute("svcolname",name);
  9193. }
  9194. void ModbusConfigurator::updatePVHidden(bool hidden)
  9195. {
  9196. updateAttribute("pvhidden",hidden?"true":"false");
  9197. }
  9198. void ModbusConfigurator::updateSVHidden(bool hidden)
  9199. {
  9200. updateAttribute("svhidden",hidden?"true":"false");
  9201. }
  9202. /*:912*/
  9203. #line 581 "./typica.w"
  9204. /*851:*/
  9205. #line 17735 "./typica.w"
  9206. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  9207. {
  9208. setMinimum(0);
  9209. setMaximum(0xFFFF);
  9210. setPrefix("0x");
  9211. setMinimumWidth(65);
  9212. }
  9213. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  9214. {
  9215. if(input.size()==2)
  9216. {
  9217. return QValidator::Intermediate;
  9218. }
  9219. bool okay;
  9220. input.toInt(&okay,16);
  9221. if(okay)
  9222. {
  9223. return QValidator::Acceptable;
  9224. }
  9225. return QValidator::Invalid;
  9226. }
  9227. int ShortHexSpinBox::valueFromText(const QString&text)const
  9228. {
  9229. return text.toInt(NULL,16);
  9230. }
  9231. QString ShortHexSpinBox::textFromValue(int value)const
  9232. {
  9233. QString retval;
  9234. retval.setNum(value,16);
  9235. while(retval.size()<4)
  9236. {
  9237. retval.prepend("0");
  9238. }
  9239. return retval.toUpper();
  9240. }
  9241. /*:851*/
  9242. #line 582 "./typica.w"
  9243. /*896:*/
  9244. #line 18768 "./typica.w"
  9245. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  9246. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  9247. waiting(false)
  9248. {
  9249. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  9250. Qt::UserRole).toString());
  9251. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  9252. QDomElement node;
  9253. QVariantMap attributes;
  9254. for(int i= 0;i<portConfigData.size();i++)
  9255. {
  9256. node= portConfigData.at(i).toElement();
  9257. attributes.insert(node.attribute("name"),node.attribute("value"));
  9258. }
  9259. port= new QextSerialPort(attributes.value("port").toString(),
  9260. QextSerialPort::EventDriven);
  9261. int baudRate= attributes.value("baud").toInt();
  9262. port->setBaudRate((BaudRateType)baudRate);
  9263. double temp= ((double)(1)/(double)(baudRate))*48;
  9264. delayTime= (int)(temp*3000);
  9265. messageDelayTimer->setSingleShot(true);
  9266. commTimeout->setSingleShot(true);
  9267. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  9268. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  9269. port->setDataBits(DATA_8);
  9270. port->setParity((ParityType)attributes.value("parity").toInt());
  9271. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  9272. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  9273. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  9274. port->open(QIODevice::ReadWrite);
  9275. station= (char)attributes.value("station").toInt();
  9276. if(attributes.value("decimalQuery")=="true")
  9277. {
  9278. decimalPosition= 0;
  9279. QByteArray message;
  9280. message.append(station);
  9281. message.append((char)0x03);
  9282. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  9283. char*addressBytes= (char*)&address;
  9284. message.append(addressBytes[1]);
  9285. message.append(addressBytes[0]);
  9286. message.append((char)0x00);
  9287. message.append((char)0x01);
  9288. queueMessage(message,this,"decimalResponse(QByteArray)");
  9289. }
  9290. else
  9291. {
  9292. decimalPosition= attributes.value("decimalPosition").toInt();
  9293. }
  9294. valueF= attributes.value("valueF").toInt();
  9295. valueC= attributes.value("valueC").toInt();
  9296. if(attributes.value("unitQuery")=="true")
  9297. {
  9298. QByteArray message;
  9299. message.append(station);
  9300. message.append((char)0x03);
  9301. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  9302. char*addressBytes= (char*)&address;
  9303. message.append(addressBytes[1]);
  9304. message.append(addressBytes[0]);
  9305. message.append((char)0x00);
  9306. message.append((char)0x01);
  9307. queueMessage(message,this,"unitResponse(QByteArray)");
  9308. }
  9309. else
  9310. {
  9311. if(attributes.value("fixedUnit")=="Celsius")
  9312. {
  9313. unitIsF= false;
  9314. }
  9315. }
  9316. if(attributes.value("sVWritable")=="true")
  9317. {
  9318. if(attributes.value("deviceLimit")=="true")
  9319. {
  9320. QByteArray lmessage;
  9321. lmessage.append(station);
  9322. lmessage.append((char)0x03);
  9323. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  9324. char*addressBytes= (char*)&laddress;
  9325. lmessage.append(addressBytes[1]);
  9326. lmessage.append(addressBytes[0]);
  9327. lmessage.append((char)0x00);
  9328. lmessage.append((char)0x01);
  9329. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  9330. QByteArray umessage;
  9331. umessage.append(station);
  9332. umessage.append((char)0x03);
  9333. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  9334. addressBytes= (char*)&uaddress;
  9335. umessage.append(addressBytes[1]);
  9336. umessage.append(addressBytes[0]);
  9337. umessage.append((char)0x00);
  9338. umessage.append((char)0x01);
  9339. queueMessage(umessage,this,"svuResponse(QByteArray)");
  9340. }
  9341. else
  9342. {
  9343. outputSVLower= attributes.value("sVLower").toDouble();
  9344. outputSVUpper= attributes.value("sVUpper").toDouble();
  9345. }
  9346. outputSVStub.append(station);
  9347. outputSVStub.append((char)0x06);
  9348. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  9349. char*addressBytes= (char*)&address;
  9350. outputSVStub.append(addressBytes[1]);
  9351. outputSVStub.append(addressBytes[0]);
  9352. }
  9353. Channel*pv= new Channel;
  9354. channels.append(pv);
  9355. pvStub.append(station);
  9356. pvStub.append((char)0x04);
  9357. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  9358. char*pvac= (char*)&pvaddress;
  9359. pvStub.append(pvac[1]);
  9360. pvStub.append(pvac[0]);
  9361. pvStub.append((char)0x00);
  9362. pvStub.append((char)0x01);
  9363. svenabled= attributes.value("sVEnabled").toBool();
  9364. if(svenabled)
  9365. {
  9366. Channel*sv= new Channel;
  9367. channels.append(sv);
  9368. svStub.append(station);
  9369. svStub.append((char)0x04);
  9370. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  9371. char*svac= (char*)&svaddress;
  9372. svStub.append(svac[1]);
  9373. svStub.append(svac[0]);
  9374. svStub.append((char)0x00);
  9375. svStub.append((char)0x01);
  9376. if(svaddress-pvaddress==1)
  9377. {
  9378. mStub.append(station);
  9379. mStub.append((char)0x04);
  9380. mStub.append(pvac[1]);
  9381. mStub.append(pvac[0]);
  9382. mStub.append((char)0x00);
  9383. mStub.append((char)0x02);
  9384. }
  9385. }
  9386. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  9387. requestMeasurement();
  9388. }
  9389. double ModbusRTUDevice::SVLower()
  9390. {
  9391. return outputSVLower;
  9392. }
  9393. double ModbusRTUDevice::SVUpper()
  9394. {
  9395. return outputSVUpper;
  9396. }
  9397. int ModbusRTUDevice::decimals()
  9398. {
  9399. return decimalPosition;
  9400. }
  9401. void ModbusRTUDevice::decimalResponse(QByteArray response)
  9402. {
  9403. quint16 temp;
  9404. char*tchar= (char*)&temp;
  9405. tchar[1]= response.at(3);
  9406. tchar[0]= response.at(4);
  9407. decimalPosition= temp;
  9408. emit SVDecimalChanged(decimalPosition);
  9409. }
  9410. void ModbusRTUDevice::unitResponse(QByteArray response)
  9411. {
  9412. quint16 temp;
  9413. char*tchar= (char*)&temp;
  9414. tchar[1]= response.at(3);
  9415. tchar[0]= response.at(4);
  9416. int value= temp;
  9417. if(value==valueF)
  9418. {
  9419. unitIsF= true;
  9420. }
  9421. else
  9422. {
  9423. unitIsF= false;
  9424. }
  9425. }
  9426. void ModbusRTUDevice::svlResponse(QByteArray response)
  9427. {
  9428. quint16 temp;
  9429. char*tchar= (char*)&temp;
  9430. tchar[1]= response.at(3);
  9431. tchar[0]= response.at(4);
  9432. outputSVLower= (double)temp;
  9433. for(int i= 0;i<decimalPosition;i++)
  9434. {
  9435. outputSVLower/= 10;
  9436. }
  9437. emit SVLowerChanged(outputSVLower);
  9438. }
  9439. void ModbusRTUDevice::svuResponse(QByteArray response)
  9440. {
  9441. quint16 temp;
  9442. char*tchar= (char*)&temp;
  9443. tchar[1]= response.at(3);
  9444. tchar[0]= response.at(4);
  9445. outputSVUpper= (double)temp;
  9446. for(int i= 0;i<decimalPosition;i++)
  9447. {
  9448. outputSVUpper/= 10;
  9449. }
  9450. emit SVUpperChanged(outputSVUpper);
  9451. }
  9452. void ModbusRTUDevice::requestMeasurement()
  9453. {
  9454. if(mStub.length()> 0)
  9455. {
  9456. queueMessage(mStub,this,"mResponse(QByteArray)");
  9457. }
  9458. else
  9459. {
  9460. queueMessage(pvStub,this,"mResponse(QByteArray)");
  9461. if(svenabled)
  9462. {
  9463. queueMessage(svStub,this,"mResponse(QByteArray)");
  9464. }
  9465. }
  9466. }
  9467. void ModbusRTUDevice::mResponse(QByteArray response)
  9468. {
  9469. QTime time= QTime::currentTime();
  9470. if(response.at(2)==0x04)
  9471. {
  9472. /*897:*/
  9473. #line 19018 "./typica.w"
  9474. quint16 pv;
  9475. quint16 sv;
  9476. char*pvBytes= (char*)&pv;
  9477. char*svBytes= (char*)&sv;
  9478. pvBytes[1]= response.at(3);
  9479. pvBytes[0]= response.at(4);
  9480. svBytes[1]= response.at(5);
  9481. svBytes[0]= response.at(6);
  9482. double pvOut= (double)pv;
  9483. double svOut= (double)sv;
  9484. for(int i= 0;i<decimalPosition;i++)
  9485. {
  9486. pvOut/= 10;
  9487. svOut/= 10;
  9488. }
  9489. if(!unitIsF)
  9490. {
  9491. pvOut= pvOut*9/5+32;
  9492. svOut= svOut*9/5+32;
  9493. }
  9494. Measurement pvm(pvOut,time,Units::Fahrenheit);
  9495. Measurement svm(svOut,time,Units::Fahrenheit);
  9496. channels.at(0)->input(pvm);
  9497. channels.at(1)->input(svm);
  9498. /*:897*/
  9499. #line 19005 "./typica.w"
  9500. }
  9501. else
  9502. {
  9503. /*898:*/
  9504. #line 19048 "./typica.w"
  9505. quint16 value;
  9506. char*valueBytes= (char*)&value;
  9507. valueBytes[1]= response.at(3);
  9508. valueBytes[0]= response.at(4);
  9509. double valueOut= (double)value;
  9510. for(int i= 0;i<decimalPosition;i++)
  9511. {
  9512. valueOut/= 10;
  9513. }
  9514. if(!unitIsF)
  9515. {
  9516. valueOut= valueOut*9/5+32;
  9517. }
  9518. if(!svenabled)
  9519. {
  9520. Measurement vm(valueOut,time,Units::Fahrenheit);
  9521. channels.at(0)->input(vm);
  9522. }
  9523. else
  9524. {
  9525. if(readingsv)
  9526. {
  9527. Measurement pvm(savedpv,time,Units::Fahrenheit);
  9528. Measurement svm(valueOut,time,Units::Fahrenheit);
  9529. channels.at(0)->input(pvm);
  9530. channels.at(1)->input(svm);
  9531. readingsv= false;
  9532. }
  9533. else
  9534. {
  9535. savedpv= valueOut;
  9536. readingsv= true;
  9537. }
  9538. }
  9539. /*:898*/
  9540. #line 19009 "./typica.w"
  9541. }
  9542. }
  9543. /*:896*//*899:*/
  9544. #line 19086 "./typica.w"
  9545. ModbusRTUDevice::~ModbusRTUDevice()
  9546. {
  9547. commTimeout->stop();
  9548. messageDelayTimer->stop();
  9549. port->close();
  9550. }
  9551. /*:899*//*900:*/
  9552. #line 19113 "./typica.w"
  9553. void ModbusRTUDevice::dataAvailable()
  9554. {
  9555. if(messageDelayTimer->isActive())
  9556. {
  9557. messageDelayTimer->stop();
  9558. }
  9559. responseBuffer.append(port->readAll());
  9560. /*901:*/
  9561. #line 19159 "./typica.w"
  9562. if(responseBuffer.size()<5)
  9563. {
  9564. return;
  9565. }
  9566. switch(responseBuffer.at(1))
  9567. {
  9568. case 0x01:
  9569. case 0x02:
  9570. if(responseBuffer.size()<6)
  9571. {
  9572. return;
  9573. }
  9574. responseBuffer= responseBuffer.left(6);
  9575. break;
  9576. case 0x03:
  9577. case 0x04:
  9578. if(responseBuffer.size()<5+responseBuffer.at(2))
  9579. {
  9580. return;
  9581. }
  9582. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  9583. break;
  9584. case 0x05:
  9585. case 0x06:
  9586. case 0x10:
  9587. if(responseBuffer.size()<8)
  9588. {
  9589. return;
  9590. }
  9591. responseBuffer= responseBuffer.left(8);
  9592. break;
  9593. }
  9594. /*:901*/
  9595. #line 19121 "./typica.w"
  9596. commTimeout->stop();
  9597. if(calculateCRC(responseBuffer)==0)
  9598. {
  9599. QObject*object= retObjQueue.at(0);
  9600. char*method= callbackQueue.at(0);
  9601. QMetaMethod metamethod= object->metaObject()->
  9602. method(object->metaObject()->
  9603. indexOfMethod(QMetaObject::normalizedSignature(method)));
  9604. metamethod.invoke(object,Qt::QueuedConnection,
  9605. Q_ARG(QByteArray,responseBuffer));
  9606. messageQueue.removeAt(0);
  9607. retObjQueue.removeAt(0);
  9608. callbackQueue.removeAt(0);
  9609. }
  9610. else
  9611. {
  9612. qDebug()<<"CRC failed";
  9613. }
  9614. messageDelayTimer->start(delayTime);
  9615. waiting= false;
  9616. responseBuffer.clear();
  9617. }
  9618. /*:900*//*902:*/
  9619. #line 19201 "./typica.w"
  9620. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  9621. {
  9622. quint16 retval= 0xFFFF;
  9623. int i= 0;
  9624. while(i<data.size())
  9625. {
  9626. retval^= 0x00FF&(quint16)data.at(i);
  9627. for(int j= 0;j<8;j++)
  9628. {
  9629. if(retval&1)
  9630. {
  9631. retval= (retval>>1)^0xA001;
  9632. }
  9633. else
  9634. {
  9635. retval>>= 1;
  9636. }
  9637. }
  9638. i++;
  9639. }
  9640. return retval;
  9641. }
  9642. /*:902*//*903:*/
  9643. #line 19232 "./typica.w"
  9644. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9645. const char*callback)
  9646. {
  9647. messageQueue.append(request);
  9648. retObjQueue.append(object);
  9649. callbackQueue.append(const_cast<char*> (callback));
  9650. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9651. {
  9652. sendNextMessage();
  9653. }
  9654. }
  9655. void ModbusRTUDevice::sendNextMessage()
  9656. {
  9657. if(messageQueue.size()> 0&&!waiting)
  9658. {
  9659. QByteArray message= messageQueue.at(0);
  9660. quint16 crc= calculateCRC(message);
  9661. char*check= (char*)&crc;
  9662. message.append(check[0]);
  9663. message.append(check[1]);
  9664. port->write(message);
  9665. commTimeout->start(2000);
  9666. messageDelayTimer->start(delayTime);
  9667. waiting= true;
  9668. }
  9669. else
  9670. {
  9671. emit queueEmpty();
  9672. }
  9673. }
  9674. void ModbusRTUDevice::outputSV(double value)
  9675. {
  9676. for(int i= 0;i<decimalPosition;i++)
  9677. {
  9678. value*= 10;
  9679. }
  9680. quint16 outval= (quint16)value;
  9681. QByteArray message(outputSVStub);
  9682. char*valBytes= (char*)&outval;
  9683. message.append(valBytes[1]);
  9684. message.append(valBytes[0]);
  9685. queueMessage(message,this,"ignore(QByteArray)");
  9686. }
  9687. /*:903*//*904:*/
  9688. #line 19281 "./typica.w"
  9689. void ModbusRTUDevice::ignore(QByteArray)
  9690. {
  9691. return;
  9692. }
  9693. /*:904*//*905:*/
  9694. #line 19294 "./typica.w"
  9695. void ModbusRTUDevice::timeout()
  9696. {
  9697. qDebug()<<"Communications timeout.";
  9698. responseBuffer.clear();
  9699. waiting= false;
  9700. messageDelayTimer->start();
  9701. }
  9702. /*:905*/
  9703. #line 583 "./typica.w"
  9704. /*770:*/
  9705. #line 15853 "./typica.w"
  9706. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9707. DeviceTreeModelNode*parent)
  9708. :domNode(node),rowNumber(row),parentItem(parent)
  9709. {
  9710. }
  9711. DeviceTreeModelNode::~DeviceTreeModelNode()
  9712. {
  9713. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9714. for(i= children.begin();i!=children.end();i++)
  9715. {
  9716. delete i.value();
  9717. }
  9718. }
  9719. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9720. {
  9721. return parentItem;
  9722. }
  9723. int DeviceTreeModelNode::row()
  9724. {
  9725. return rowNumber;
  9726. }
  9727. QDomNode DeviceTreeModelNode::node()const
  9728. {
  9729. return domNode;
  9730. }
  9731. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9732. {
  9733. if(children.contains(index))
  9734. {
  9735. return children[index];
  9736. }
  9737. if(index>=0&&index<domNode.childNodes().count())
  9738. {
  9739. QDomNode childNode= domNode.childNodes().item(index);
  9740. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9741. index,this);
  9742. children[index]= childItem;
  9743. return childItem;
  9744. }
  9745. return NULL;
  9746. }
  9747. /*:770*/
  9748. #line 584 "./typica.w"
  9749. /*772:*/
  9750. #line 15942 "./typica.w"
  9751. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9752. :QAbstractItemModel(parent)
  9753. {
  9754. document= AppInstance->deviceConfiguration();
  9755. QDomNodeList elements= document.elementsByTagName("devices");
  9756. if(elements.size()!=1)
  9757. {
  9758. qDebug()<<"Unexpected result when loading device map.";
  9759. }
  9760. treeRoot= elements.at(0);
  9761. root= new DeviceTreeModelNode(treeRoot,0);
  9762. elements= document.elementsByTagName("references");
  9763. if(elements.size()!=1)
  9764. {
  9765. qDebug()<<"No references section. Creating.";
  9766. referenceSection= document.createElement("references");
  9767. document.appendChild(referenceSection);
  9768. }
  9769. else
  9770. {
  9771. referenceSection= elements.at(0);
  9772. }
  9773. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9774. AppInstance,SLOT(saveDeviceConfiguration()));
  9775. connect(this,SIGNAL(modelReset()),
  9776. AppInstance,SLOT(saveDeviceConfiguration()));
  9777. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9778. AppInstance,SLOT(saveDeviceConfiguration()));
  9779. }
  9780. /*:772*//*773:*/
  9781. #line 15977 "./typica.w"
  9782. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9783. {
  9784. return 1;
  9785. }
  9786. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9787. {
  9788. if(parent.column()> 0)
  9789. {
  9790. return 0;
  9791. }
  9792. /*774:*/
  9793. #line 15996 "./typica.w"
  9794. DeviceTreeModelNode*parentItem;
  9795. if(!parent.isValid())
  9796. {
  9797. parentItem= root;
  9798. }
  9799. else
  9800. {
  9801. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9802. }
  9803. /*:774*/
  9804. #line 15989 "./typica.w"
  9805. return parentItem->node().childNodes().count();
  9806. }
  9807. /*:773*//*775:*/
  9808. #line 16010 "./typica.w"
  9809. QModelIndex DeviceTreeModel::index(int row,int column,
  9810. const QModelIndex&parent)const
  9811. {
  9812. if(!hasIndex(row,column,parent))
  9813. {
  9814. return QModelIndex();
  9815. }
  9816. /*774:*/
  9817. #line 15996 "./typica.w"
  9818. DeviceTreeModelNode*parentItem;
  9819. if(!parent.isValid())
  9820. {
  9821. parentItem= root;
  9822. }
  9823. else
  9824. {
  9825. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9826. }
  9827. /*:774*/
  9828. #line 16018 "./typica.w"
  9829. DeviceTreeModelNode*childItem= parentItem->child(row);
  9830. if(childItem)
  9831. {
  9832. return createIndex(row,column,childItem);
  9833. }
  9834. return QModelIndex();
  9835. }
  9836. /*:775*//*776:*/
  9837. #line 16029 "./typica.w"
  9838. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9839. {
  9840. if(!child.isValid())
  9841. {
  9842. return QModelIndex();
  9843. }
  9844. DeviceTreeModelNode*childItem=
  9845. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9846. DeviceTreeModelNode*parentItem= childItem->parent();
  9847. if(!parentItem||parentItem==root)
  9848. {
  9849. return QModelIndex();
  9850. }
  9851. return createIndex(parentItem->row(),0,parentItem);
  9852. }
  9853. /*:776*//*777:*/
  9854. #line 16048 "./typica.w"
  9855. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9856. {
  9857. if(!index.isValid())
  9858. {
  9859. return 0;
  9860. }
  9861. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9862. }
  9863. /*:777*//*778:*/
  9864. #line 16063 "./typica.w"
  9865. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9866. {
  9867. if(!index.isValid())
  9868. {
  9869. return QVariant();
  9870. }
  9871. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9872. {
  9873. return QVariant();
  9874. }
  9875. DeviceTreeModelNode*item=
  9876. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9877. QDomNode node= item->node();
  9878. QDomElement element= node.toElement();
  9879. switch(role)
  9880. {
  9881. case Qt::DisplayRole:
  9882. case Qt::EditRole:
  9883. return QVariant(element.attribute("name"));
  9884. case Qt::UserRole:
  9885. return QVariant(element.attribute("reference"));
  9886. default:
  9887. return QVariant();
  9888. }
  9889. return QVariant();
  9890. }
  9891. /*:778*//*779:*/
  9892. #line 16095 "./typica.w"
  9893. bool DeviceTreeModel::setData(const QModelIndex&index,
  9894. const QVariant&value,int)
  9895. {
  9896. if(!index.isValid())
  9897. {
  9898. return false;
  9899. }
  9900. DeviceTreeModelNode*item=
  9901. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9902. QDomNode node= item->node();
  9903. QDomElement element= node.toElement();
  9904. element.setAttribute("name",value.toString());
  9905. emit dataChanged(index,index);
  9906. return true;
  9907. }
  9908. /*:779*//*780:*/
  9909. #line 16118 "./typica.w"
  9910. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9911. const QModelIndex&parent)
  9912. {
  9913. QString referenceID= QUuid::createUuid().toString();
  9914. /*774:*/
  9915. #line 15996 "./typica.w"
  9916. DeviceTreeModelNode*parentItem;
  9917. if(!parent.isValid())
  9918. {
  9919. parentItem= root;
  9920. }
  9921. else
  9922. {
  9923. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9924. }
  9925. /*:774*/
  9926. #line 16123 "./typica.w"
  9927. QDomNode parentNode= parentItem->node();
  9928. int newRowNumber= rowCount(parent);
  9929. beginInsertRows(parent,newRowNumber,newRowNumber);
  9930. QDomElement deviceElement= document.createElement("node");
  9931. deviceElement.setAttribute("name",name);
  9932. deviceElement.setAttribute("reference",referenceID);
  9933. parentNode.appendChild(deviceElement);
  9934. QDomElement referenceElement= document.createElement("reference");
  9935. referenceElement.setAttribute("id",referenceID);
  9936. referenceElement.setAttribute("driver",driver);
  9937. referenceSection.appendChild(referenceElement);
  9938. endInsertRows();
  9939. }
  9940. /*:780*//*781:*/
  9941. #line 16141 "./typica.w"
  9942. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9943. {
  9944. /*774:*/
  9945. #line 15996 "./typica.w"
  9946. DeviceTreeModelNode*parentItem;
  9947. if(!parent.isValid())
  9948. {
  9949. parentItem= root;
  9950. }
  9951. else
  9952. {
  9953. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9954. }
  9955. /*:774*/
  9956. #line 16144 "./typica.w"
  9957. QDomNode parentNode= parentItem->node();
  9958. QDomNodeList childNodes= parentNode.childNodes();
  9959. if(childNodes.size()<row+count)
  9960. {
  9961. return false;
  9962. }
  9963. beginRemoveRows(parent,row,row+count-1);
  9964. QList<QDomElement> removalList;
  9965. for(int i= row;i<row+count;i++)
  9966. {
  9967. removalList.append(childNodes.at(i).toElement());
  9968. }
  9969. QDomElement element;
  9970. QDomElement reference;
  9971. for(int i= 0;i<count;i++)
  9972. {
  9973. element= removalList.at(i);
  9974. if(element.hasAttribute("reference"))
  9975. {
  9976. reference= referenceElement(element.attribute("reference"));
  9977. if(!reference.isNull())
  9978. {
  9979. referenceSection.removeChild(reference);
  9980. }
  9981. }
  9982. parentNode.removeChild(element);
  9983. }
  9984. endRemoveRows();
  9985. beginResetModel();
  9986. delete root;
  9987. root= new DeviceTreeModelNode(treeRoot,0);
  9988. endResetModel();
  9989. return true;
  9990. }
  9991. /*:781*//*782:*/
  9992. #line 16183 "./typica.w"
  9993. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9994. {
  9995. QDomNodeList childNodes= referenceSection.childNodes();
  9996. QDomElement element;
  9997. for(int i= 0;i<childNodes.size();i++)
  9998. {
  9999. element= childNodes.at(i).toElement();
  10000. if(element.hasAttribute("id"))
  10001. {
  10002. if(element.attribute("id")==id)
  10003. {
  10004. return element;
  10005. }
  10006. }
  10007. }
  10008. return QDomElement();
  10009. }
  10010. /*:782*//*783:*/
  10011. #line 16204 "./typica.w"
  10012. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  10013. {
  10014. return QVariant();
  10015. }
  10016. /*:783*//*784:*/
  10017. #line 16213 "./typica.w"
  10018. DeviceTreeModel::~DeviceTreeModel()
  10019. {
  10020. delete root;
  10021. }
  10022. /*:784*/
  10023. #line 585 "./typica.w"
  10024. /*811:*/
  10025. #line 16713 "./typica.w"
  10026. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  10027. DeviceTreeModel*model,const QModelIndex&index)
  10028. :QWidget(NULL),deviceModel(model),currentNode(index)
  10029. {
  10030. }
  10031. /*:811*//*812:*/
  10032. #line 16725 "./typica.w"
  10033. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  10034. const QString&value)
  10035. {
  10036. QDomElement referenceElement= deviceModel->referenceElement(
  10037. deviceModel->data(currentNode,Qt::UserRole).toString());
  10038. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10039. QDomElement node;
  10040. bool found= false;
  10041. for(int i= 0;i<configData.size();i++)
  10042. {
  10043. node= configData.at(i).toElement();
  10044. if(node.attribute("name")==name)
  10045. {
  10046. node.setAttribute("value",value);
  10047. found= true;
  10048. break;
  10049. }
  10050. }
  10051. if(!found)
  10052. {
  10053. node= AppInstance->deviceConfiguration().createElement("attribute");
  10054. node.setAttribute("name",name);
  10055. node.setAttribute("value",value);
  10056. referenceElement.appendChild(node);
  10057. }
  10058. AppInstance->saveDeviceConfiguration();
  10059. }
  10060. /*:812*//*813:*/
  10061. #line 16759 "./typica.w"
  10062. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  10063. const QString&driver)
  10064. {
  10065. deviceModel->newNode(name,driver,currentNode);
  10066. }
  10067. /*:813*/
  10068. #line 586 "./typica.w"
  10069. /*802:*/
  10070. #line 16557 "./typica.w"
  10071. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  10072. view(new QTreeView),configArea(new QScrollArea)
  10073. {
  10074. QSplitter*splitter= new QSplitter;
  10075. QWidget*leftWidget= new QWidget;
  10076. leftWidget->setMinimumWidth(200);
  10077. QVBoxLayout*left= new QVBoxLayout;
  10078. view->setAnimated(true);
  10079. view->setSelectionMode(QAbstractItemView::SingleSelection);
  10080. document= AppInstance->deviceConfiguration();
  10081. model= new DeviceTreeModel;
  10082. view->setModel(model);
  10083. view->setTextElideMode(Qt::ElideNone);
  10084. view->expandAll();
  10085. view->resizeColumnToContents(0);
  10086. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  10087. QHBoxLayout*treeButtons= new QHBoxLayout;
  10088. QToolButton*addDeviceButton= new QToolButton;
  10089. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  10090. addDeviceButton->setToolTip(tr("New Roaster"));
  10091. connect(addDeviceButton,SIGNAL(clicked()),
  10092. this,SLOT(addDevice()));
  10093. QToolButton*removeNodeButton= new QToolButton;
  10094. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  10095. removeNodeButton->setToolTip(tr("Delete Selection"));
  10096. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  10097. treeButtons->addWidget(addDeviceButton);
  10098. treeButtons->addWidget(removeNodeButton);
  10099. left->addWidget(view);
  10100. left->addLayout(treeButtons);
  10101. leftWidget->setLayout(left);
  10102. splitter->addWidget(leftWidget);
  10103. configArea->setMinimumWidth(580);
  10104. configArea->setMinimumHeight(460);
  10105. configArea->setWidgetResizable(true);
  10106. splitter->addWidget(configArea);
  10107. QVBoxLayout*centralLayout= new QVBoxLayout;
  10108. centralLayout->addWidget(splitter);
  10109. setLayout(centralLayout);
  10110. connect(view,SIGNAL(activated(QModelIndex)),
  10111. this,SLOT(newSelection(QModelIndex)));
  10112. connect(view,SIGNAL(clicked(QModelIndex)),
  10113. this,SLOT(newSelection(QModelIndex)));
  10114. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  10115. view,SLOT(expand(QModelIndex)));
  10116. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  10117. this,SLOT(resizeColumn()));
  10118. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  10119. this,SLOT(resizeColumn()));
  10120. }
  10121. /*:802*//*803:*/
  10122. #line 16612 "./typica.w"
  10123. void DeviceConfigurationWindow::addDevice()
  10124. {
  10125. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  10126. }
  10127. /*:803*//*804:*/
  10128. #line 16620 "./typica.w"
  10129. void DeviceConfigurationWindow::removeNode()
  10130. {
  10131. QModelIndex index= view->currentIndex();
  10132. if(index.isValid())
  10133. {
  10134. int row= index.row();
  10135. QModelIndex parent= index.parent();
  10136. model->removeRow(row,parent);
  10137. }
  10138. }
  10139. /*:804*//*805:*/
  10140. #line 16636 "./typica.w"
  10141. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  10142. {
  10143. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  10144. if(editor)
  10145. {
  10146. configArea->setWidget(editor);
  10147. editor->show();
  10148. }
  10149. }
  10150. /*:805*//*806:*/
  10151. #line 16653 "./typica.w"
  10152. void DeviceConfigurationWindow::resizeColumn()
  10153. {
  10154. view->resizeColumnToContents(0);
  10155. }
  10156. /*:806*/
  10157. #line 587 "./typica.w"
  10158. /*826:*/
  10159. #line 17134 "./typica.w"
  10160. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  10161. const QModelIndex&index):
  10162. BasicDeviceConfigurationWidget(model,index)
  10163. {
  10164. QFormLayout*layout= new QFormLayout;
  10165. QLineEdit*columnName= new QLineEdit;
  10166. layout->addRow(tr("Column Name:"),columnName);
  10167. QComboBox*typeSelector= new QComboBox;
  10168. typeSelector->addItem("J");
  10169. typeSelector->addItem("K");
  10170. typeSelector->addItem("T");
  10171. typeSelector->addItem("B");
  10172. typeSelector->addItem("E");
  10173. typeSelector->addItem("N");
  10174. typeSelector->addItem("R");
  10175. typeSelector->addItem("S");
  10176. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10177. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  10178. layout->addRow(hideSeries);
  10179. setLayout(layout);
  10180. /*816:*/
  10181. #line 16928 "./typica.w"
  10182. QDomElement referenceElement=
  10183. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10184. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10185. QDomElement node;
  10186. /*:816*/
  10187. #line 17155 "./typica.w"
  10188. for(int i= 0;i<configData.size();i++)
  10189. {
  10190. node= configData.at(i).toElement();
  10191. if(node.attribute("name")=="type")
  10192. {
  10193. typeSelector->setCurrentIndex(
  10194. typeSelector->findText(node.attribute("value")));
  10195. }
  10196. else if(node.attribute("name")=="columnname")
  10197. {
  10198. columnName->setText(node.attribute("value"));
  10199. }
  10200. else if(node.attribute("name")=="hidden")
  10201. {
  10202. hideSeries->setChecked(node.attribute("value")=="true");
  10203. }
  10204. }
  10205. updateThermocoupleType(typeSelector->currentText());
  10206. updateColumnName(columnName->text());
  10207. updateHidden(hideSeries->isChecked());
  10208. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  10209. this,SLOT(updateThermocoupleType(QString)));
  10210. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10211. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10212. }
  10213. /*:826*//*827:*/
  10214. #line 17185 "./typica.w"
  10215. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  10216. {
  10217. updateAttribute("type",type);
  10218. }
  10219. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  10220. {
  10221. updateAttribute("columnname",name);
  10222. }
  10223. void Ni9211TcConfWidget::updateHidden(bool hidden)
  10224. {
  10225. updateAttribute("hidden",hidden?"true":"false");
  10226. }
  10227. /*:827*/
  10228. #line 588 "./typica.w"
  10229. /*822:*/
  10230. #line 17048 "./typica.w"
  10231. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  10232. const QModelIndex&index)
  10233. :BasicDeviceConfigurationWidget(model,index)
  10234. {
  10235. QVBoxLayout*layout= new QVBoxLayout;
  10236. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10237. QLabel*label= new QLabel(tr("Device ID:"));
  10238. QLineEdit*deviceId= new QLineEdit;
  10239. deviceIdLayout->addWidget(label);
  10240. deviceIdLayout->addWidget(deviceId);
  10241. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10242. layout->addLayout(deviceIdLayout);
  10243. layout->addWidget(addChannelButton);
  10244. /*816:*/
  10245. #line 16928 "./typica.w"
  10246. QDomElement referenceElement=
  10247. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10248. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10249. QDomElement node;
  10250. /*:816*/
  10251. #line 17062 "./typica.w"
  10252. for(int i= 0;i<configData.size();i++)
  10253. {
  10254. node= configData.at(i).toElement();
  10255. if(node.attribute("name")=="deviceID")
  10256. {
  10257. deviceId->setText(node.attribute("value","Dev1"));
  10258. break;
  10259. }
  10260. }
  10261. updateDeviceId(deviceId->text());
  10262. connect(addChannelButton,SIGNAL(clicked()),
  10263. this,SLOT(addChannel()));
  10264. connect(deviceId,SIGNAL(textEdited(QString)),
  10265. this,SLOT(updateDeviceId(QString)));
  10266. setLayout(layout);
  10267. }
  10268. /*:822*//*823:*/
  10269. #line 17084 "./typica.w"
  10270. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  10271. {
  10272. updateAttribute("deviceID",newId);
  10273. }
  10274. /*:823*//*824:*/
  10275. #line 17092 "./typica.w"
  10276. void NiDaqMxBase9211ConfWidget::addChannel()
  10277. {
  10278. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10279. }
  10280. /*:824*/
  10281. #line 589 "./typica.w"
  10282. /*820:*/
  10283. #line 16999 "./typica.w"
  10284. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  10285. DeviceTreeModel*model,const QModelIndex&index):
  10286. BasicDeviceConfigurationWidget(model,index)
  10287. {
  10288. QHBoxLayout*layout= new QHBoxLayout;
  10289. QToolButton*addDeviceButton= new QToolButton;
  10290. addDeviceButton->setText(tr("Add Device"));
  10291. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  10292. "nidaqmxbase9211series");
  10293. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10294. "nidaqmxbase9211series");
  10295. connect(add9211,SIGNAL(triggered(QString,QString)),
  10296. this,SLOT(insertChildNode(QString,QString)));
  10297. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10298. this,SLOT(insertChildNode(QString,QString)));
  10299. QMenu*deviceMenu= new QMenu;
  10300. deviceMenu->addAction(add9211);
  10301. deviceMenu->addAction(add9211a);
  10302. addDeviceButton->setMenu(deviceMenu);
  10303. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10304. layout->addWidget(addDeviceButton);
  10305. setLayout(layout);
  10306. }
  10307. /*:820*/
  10308. #line 590 "./typica.w"
  10309. /*681:*/
  10310. #line 14471 "./typica.w"
  10311. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  10312. QObject*parent):
  10313. QAction(reportName,parent),reportFile(fileName)
  10314. {
  10315. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  10316. }
  10317. /*:681*//*682:*/
  10318. #line 14487 "./typica.w"
  10319. void ReportAction::createReport()
  10320. {
  10321. QFile file(reportFile);
  10322. QDomDocument document;
  10323. if(file.open(QIODevice::ReadOnly))
  10324. {
  10325. document.setContent(&file,true);
  10326. QDomElement element= document.documentElement();
  10327. QScriptEngine*engine= AppInstance->engine;
  10328. QScriptContext*context= engine->pushContext();
  10329. QScriptValue object;
  10330. QString targetID= reportFile;
  10331. /*208:*/
  10332. #line 4814 "./typica.w"
  10333. ScriptQMainWindow*window= new ScriptQMainWindow;
  10334. window->setObjectName(targetID);
  10335. object= engine->newQObject(window);
  10336. setQMainWindowProperties(object,engine);
  10337. QWidget*central= new(QWidget);
  10338. central->setParent(window);
  10339. central->setObjectName("centralWidget");
  10340. window->setCentralWidget(central);
  10341. if(element.hasChildNodes())
  10342. {
  10343. /*209:*/
  10344. #line 4850 "./typica.w"
  10345. QStack<QWidget*> widgetStack;
  10346. QStack<QLayout*> layoutStack;
  10347. QString windowScript;
  10348. widgetStack.push(central);
  10349. QDomNodeList windowChildren= element.childNodes();
  10350. int i= 0;
  10351. while(i<windowChildren.count())
  10352. {
  10353. QDomNode current;
  10354. QDomElement element;
  10355. current= windowChildren.at(i);
  10356. if(current.isElement())
  10357. {
  10358. element= current.toElement();
  10359. if(element.tagName()=="program")
  10360. {
  10361. windowScript.append(element.text());
  10362. }
  10363. else if(element.tagName()=="layout")
  10364. {
  10365. element.setAttribute("trcontext","configuration");
  10366. addLayoutToWidget(element,&widgetStack,&layoutStack);
  10367. }
  10368. else if(element.tagName()=="menu")
  10369. {
  10370. /*210:*/
  10371. #line 4898 "./typica.w"
  10372. QMenuBar*bar= window->menuBar();
  10373. bar->setParent(window);
  10374. bar->setObjectName("menuBar");
  10375. if(element.hasAttribute("name"))
  10376. {
  10377. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  10378. element.attribute("name").toUtf8().data()));
  10379. menu->setParent(bar);
  10380. if(element.hasAttribute("type"))
  10381. {
  10382. if(element.attribute("type")=="reports")
  10383. {
  10384. if(element.hasAttribute("src"))
  10385. {
  10386. /*679:*/
  10387. #line 14431 "./typica.w"
  10388. QSettings settings;
  10389. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  10390. toString()).
  10391. arg(element.attribute("src"));
  10392. QDir::addSearchPath("reports",reportDirectory);
  10393. QDir directory(reportDirectory);
  10394. directory.setFilter(QDir::Files);
  10395. directory.setSorting(QDir::Name);
  10396. QStringList nameFilter;
  10397. nameFilter<<"*.xml";
  10398. directory.setNameFilters(nameFilter);
  10399. QFileInfoList reportFiles= directory.entryInfoList();
  10400. for(int i= 0;i<reportFiles.size();i++)
  10401. {
  10402. QFileInfo reportFile= reportFiles.at(i);
  10403. /*683:*/
  10404. #line 14511 "./typica.w"
  10405. QString path= reportFile.absoluteFilePath();
  10406. QFile file(path);
  10407. if(file.open(QIODevice::ReadOnly))
  10408. {
  10409. QDomDocument document;
  10410. document.setContent(&file,true);
  10411. QDomElement root= document.documentElement();
  10412. QString translationContext= root.attribute("id");
  10413. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  10414. if(!titleNode.isNull())
  10415. {
  10416. QDomElement titleElement= titleNode.toElement();
  10417. QString title= QCoreApplication::translate("configuration",
  10418. titleElement.text().toUtf8().data());
  10419. if(!title.isEmpty())
  10420. {
  10421. QStringList hierarchy= title.split(":->");
  10422. QMenu*insertionPoint= menu;
  10423. /*684:*/
  10424. #line 14540 "./typica.w"
  10425. for(int j= 0;j<hierarchy.size()-1;j++)
  10426. {
  10427. QObjectList menuList= insertionPoint->children();
  10428. bool menuFound= false;
  10429. for(int k= 0;k<menuList.size();k++)
  10430. {
  10431. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  10432. if(currentItem)
  10433. {
  10434. if(currentItem->title()==hierarchy.at(j))
  10435. {
  10436. menuFound= true;
  10437. insertionPoint= currentItem;
  10438. break;
  10439. }
  10440. }
  10441. }
  10442. if(!menuFound)
  10443. {
  10444. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  10445. }
  10446. }
  10447. /*:684*/
  10448. #line 14530 "./typica.w"
  10449. ReportAction*action= new ReportAction(path,hierarchy.last());
  10450. insertionPoint->addAction(action);
  10451. }
  10452. }
  10453. }
  10454. /*:683*/
  10455. #line 14447 "./typica.w"
  10456. }
  10457. /*:679*/
  10458. #line 4913 "./typica.w"
  10459. }
  10460. }
  10461. }
  10462. if(element.hasChildNodes())
  10463. {
  10464. /*211:*/
  10465. #line 4926 "./typica.w"
  10466. QDomNodeList menuItems= element.childNodes();
  10467. int j= 0;
  10468. while(j<menuItems.count())
  10469. {
  10470. QDomNode item= menuItems.at(j);
  10471. if(item.isElement())
  10472. {
  10473. QDomElement itemElement= item.toElement();
  10474. if(itemElement.tagName()=="item")
  10475. {
  10476. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  10477. itemElement.text().toUtf8().data()),menu);
  10478. if(itemElement.hasAttribute("id"))
  10479. {
  10480. itemAction->setObjectName(itemElement.attribute("id"));
  10481. }
  10482. if(itemElement.hasAttribute("shortcut"))
  10483. {
  10484. itemAction->setShortcut(itemElement.attribute("shortcut"));
  10485. }
  10486. menu->addAction(itemAction);
  10487. }
  10488. else if(itemElement.tagName()=="separator")
  10489. {
  10490. menu->addSeparator();
  10491. }
  10492. else if(itemElement.tagName()=="plugins")
  10493. {
  10494. /*704:*/
  10495. #line 21 "./plugins.w"
  10496. QMenu*pluginMenu= new QMenu(menu);
  10497. if(itemElement.hasAttribute("id"))
  10498. {
  10499. pluginMenu->setObjectName(itemElement.attribute("id"));
  10500. }
  10501. if(itemElement.hasAttribute("title"))
  10502. {
  10503. pluginMenu->setTitle(itemElement.attribute("title"));
  10504. }
  10505. if(itemElement.hasAttribute("src"))
  10506. {
  10507. QSettings settings;
  10508. QString pluginDirectory= QString("%1/%2").
  10509. arg(settings.value("config").toString()).
  10510. arg(itemElement.attribute("src"));
  10511. QDir directory(pluginDirectory);
  10512. directory.setFilter(QDir::Files);
  10513. directory.setSorting(QDir::Name);
  10514. QStringList nameFilter;
  10515. nameFilter<<"*.js";
  10516. directory.setNameFilters(nameFilter);
  10517. QFileInfoList pluginFiles= directory.entryInfoList();
  10518. for(int k= 0;k<pluginFiles.size();k++)
  10519. {
  10520. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  10521. if(itemElement.hasAttribute("preRun"))
  10522. {
  10523. pa->setPreRun(itemElement.attribute("preRun"));
  10524. }
  10525. if(itemElement.hasAttribute("postRun"))
  10526. {
  10527. pa->setPostRun(itemElement.attribute("postRun"));
  10528. }
  10529. pluginMenu->addAction(pa);
  10530. }
  10531. }
  10532. menu->addMenu(pluginMenu);
  10533. /*:704*/
  10534. #line 4955 "./typica.w"
  10535. }
  10536. }
  10537. j++;
  10538. }
  10539. #line 1 "./helpmenu.w"
  10540. /*:211*/
  10541. #line 4919 "./typica.w"
  10542. }
  10543. }
  10544. /*:210*/
  10545. #line 4876 "./typica.w"
  10546. }
  10547. }
  10548. i++;
  10549. }
  10550. QScriptValue oldThis= context->thisObject();
  10551. context->setThisObject(object);
  10552. QScriptValue result= engine->evaluate(windowScript);
  10553. /*202:*/
  10554. #line 4629 "./typica.w"
  10555. if(engine->hasUncaughtException())
  10556. {
  10557. int line= engine->uncaughtExceptionLineNumber();
  10558. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  10559. result.toString();
  10560. QString trace;
  10561. foreach(trace,engine->uncaughtExceptionBacktrace())
  10562. {
  10563. qDebug()<<trace;
  10564. }
  10565. }
  10566. /*:202*/
  10567. #line 4884 "./typica.w"
  10568. context->setThisObject(oldThis);
  10569. /*:209*/
  10570. #line 4825 "./typica.w"
  10571. }
  10572. /*212:*/
  10573. #line 9 "./helpmenu.w"
  10574. HelpMenu*helpMenu= new HelpMenu();
  10575. window->menuBar()->addMenu(helpMenu);
  10576. /*:212*/
  10577. #line 4827 "./typica.w"
  10578. window->show();
  10579. window->setupFinished();
  10580. /*:208*/
  10581. #line 14500 "./typica.w"
  10582. file.close();
  10583. engine->popContext();
  10584. }
  10585. }
  10586. /*:682*/
  10587. #line 591 "./typica.w"
  10588. /*258:*/
  10589. #line 6122 "./typica.w"
  10590. NumericDelegate::NumericDelegate(bool positiveOnly,QObject*parent):
  10591. QItemDelegate(parent),m_positiveOnly(positiveOnly)
  10592. {
  10593. }
  10594. /*:258*//*259:*/
  10595. #line 6134 "./typica.w"
  10596. void NumericDelegate::setEditorData(QWidget*editor,
  10597. const QModelIndex&index)const
  10598. {
  10599. QString value= index.model()->data(index,Qt::EditRole).toString();
  10600. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10601. line->setText(value);
  10602. }
  10603. /*:259*//*260:*/
  10604. #line 6149 "./typica.w"
  10605. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  10606. const QModelIndex&index)const
  10607. {
  10608. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10609. model->setData(index,line->text(),Qt::EditRole);
  10610. QScriptEngine*engine= AppInstance->engine;
  10611. engine->pushContext();
  10612. QString script= QString("Number(%1)").arg(line->text());
  10613. QScriptValue result= engine->evaluate(line->text());
  10614. if(result.isNumber())
  10615. {
  10616. if(m_positiveOnly)
  10617. {
  10618. if(result.toNumber()<0)
  10619. {
  10620. model->setData(index,QVariant(),Qt::DisplayRole);
  10621. }
  10622. else
  10623. {
  10624. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10625. }
  10626. }
  10627. else
  10628. {
  10629. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10630. }
  10631. }
  10632. else
  10633. {
  10634. model->setData(index,QVariant(),Qt::DisplayRole);
  10635. }
  10636. engine->popContext();
  10637. }
  10638. /*:260*//*261:*/
  10639. #line 6186 "./typica.w"
  10640. QWidget*NumericDelegate::createEditor(QWidget*parent,
  10641. const QStyleOptionViewItem&,
  10642. const QModelIndex&)const
  10643. {
  10644. return(new QLineEdit(parent));
  10645. }
  10646. /*:261*//*262:*/
  10647. #line 6197 "./typica.w"
  10648. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  10649. const QStyleOptionViewItem&option,
  10650. const QModelIndex&)const
  10651. {
  10652. editor->setGeometry(option.rect);
  10653. }
  10654. /*:262*/
  10655. #line 592 "./typica.w"
  10656. /*831:*/
  10657. #line 17244 "./typica.w"
  10658. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  10659. const QModelIndex&index)
  10660. :BasicDeviceConfigurationWidget(model,index)
  10661. {
  10662. QHBoxLayout*layout= new QHBoxLayout;
  10663. QToolButton*addDeviceButton= new QToolButton;
  10664. addDeviceButton->setText(tr("Add Device"));
  10665. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10666. "nidaqmx9211series");
  10667. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  10668. "nidaqmxtc01");
  10669. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10670. this,SLOT(insertChildNode(QString,QString)));
  10671. connect(addtc01,SIGNAL(triggered(QString,QString)),
  10672. this,SLOT(insertChildNode(QString,QString)));
  10673. QMenu*deviceMenu= new QMenu;
  10674. deviceMenu->addAction(add9211a);
  10675. deviceMenu->addAction(addtc01);
  10676. addDeviceButton->setMenu(deviceMenu);
  10677. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10678. layout->addWidget(addDeviceButton);
  10679. setLayout(layout);
  10680. }
  10681. /*:831*/
  10682. #line 593 "./typica.w"
  10683. /*833:*/
  10684. #line 17293 "./typica.w"
  10685. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  10686. const QModelIndex&index)
  10687. :BasicDeviceConfigurationWidget(model,index)
  10688. {
  10689. QVBoxLayout*layout= new QVBoxLayout;
  10690. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10691. QLabel*label= new QLabel(tr("Device ID:"));
  10692. QLineEdit*deviceId= new QLineEdit;
  10693. deviceIdLayout->addWidget(label);
  10694. deviceIdLayout->addWidget(deviceId);
  10695. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10696. layout->addLayout(deviceIdLayout);
  10697. layout->addWidget(addChannelButton);
  10698. /*816:*/
  10699. #line 16928 "./typica.w"
  10700. QDomElement referenceElement=
  10701. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10702. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10703. QDomElement node;
  10704. /*:816*/
  10705. #line 17307 "./typica.w"
  10706. for(int i= 0;i<configData.size();i++)
  10707. {
  10708. node= configData.at(i).toElement();
  10709. if(node.attribute("name")=="deviceID")
  10710. {
  10711. deviceId->setText(node.attribute("value","Dev1"));
  10712. break;
  10713. }
  10714. }
  10715. updateDeviceId(deviceId->text());
  10716. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10717. connect(deviceId,SIGNAL(textEdited(QString)),
  10718. this,SLOT(updateDeviceId(QString)));
  10719. setLayout(layout);
  10720. }
  10721. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10722. {
  10723. updateAttribute("deviceID",newId);
  10724. }
  10725. void NiDaqMx9211ConfWidget::addChannel()
  10726. {
  10727. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10728. }
  10729. /*:833*/
  10730. #line 594 "./typica.w"
  10731. /*835:*/
  10732. #line 17358 "./typica.w"
  10733. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10734. const QModelIndex&index)
  10735. :BasicDeviceConfigurationWidget(model,index)
  10736. {
  10737. QFormLayout*layout= new QFormLayout;
  10738. QLineEdit*deviceId= new QLineEdit;
  10739. layout->addRow(tr("Device ID:"),deviceId);
  10740. QLineEdit*columnName= new QLineEdit;
  10741. layout->addRow(tr("Column Name:"),columnName);
  10742. QComboBox*typeSelector= new QComboBox;
  10743. typeSelector->addItem("J");
  10744. typeSelector->addItem("K");
  10745. typeSelector->addItem("T");
  10746. typeSelector->addItem("B");
  10747. typeSelector->addItem("E");
  10748. typeSelector->addItem("N");
  10749. typeSelector->addItem("R");
  10750. typeSelector->addItem("S");
  10751. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10752. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10753. layout->addRow(hideSeries);
  10754. /*816:*/
  10755. #line 16928 "./typica.w"
  10756. QDomElement referenceElement=
  10757. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10758. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10759. QDomElement node;
  10760. /*:816*/
  10761. #line 17380 "./typica.w"
  10762. for(int i= 0;i<configData.size();i++)
  10763. {
  10764. node= configData.at(i).toElement();
  10765. if(node.attribute("name")=="deviceID")
  10766. {
  10767. deviceId->setText(node.attribute("value"));
  10768. }
  10769. else if(node.attribute("name")=="type")
  10770. {
  10771. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10772. }
  10773. else if(node.attribute("name")=="columnname")
  10774. {
  10775. columnName->setText(node.attribute("value"));
  10776. }
  10777. else if(node.attribute("name")=="hidden")
  10778. {
  10779. hideSeries->setChecked(node.attribute("value")=="true");
  10780. }
  10781. }
  10782. updateDeviceId(deviceId->text());
  10783. updateThermocoupleType(typeSelector->currentText());
  10784. updateColumnName(columnName->text());
  10785. updateHidden(hideSeries->isChecked());
  10786. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10787. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10788. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10789. setLayout(layout);
  10790. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10791. }
  10792. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10793. {
  10794. updateAttribute("deviceID",newId);
  10795. }
  10796. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10797. {
  10798. updateAttribute("type",type);
  10799. }
  10800. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10801. {
  10802. updateAttribute("columnname",name);
  10803. }
  10804. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10805. {
  10806. updateAttribute("hidden",hidden?"true":"false");
  10807. }
  10808. /*:835*/
  10809. #line 595 "./typica.w"
  10810. /*853:*/
  10811. #line 17800 "./typica.w"
  10812. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10813. const QModelIndex&index)
  10814. :BasicDeviceConfigurationWidget(model,index)
  10815. {
  10816. QFormLayout*layout= new QFormLayout;
  10817. QToolButton*addDeviceButton= new QToolButton;
  10818. addDeviceButton->setText(tr("Add Device"));
  10819. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10820. "Modbus RTU Device",
  10821. "modbusrtudevice");
  10822. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10823. this,SLOT(insertChildNode(QString,QString)));
  10824. QMenu*deviceMenu= new QMenu;
  10825. deviceMenu->addAction(addModbusRtuDevice);
  10826. addDeviceButton->setMenu(deviceMenu);
  10827. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10828. layout->addRow(QString(),addDeviceButton);
  10829. PortSelector*port= new PortSelector;
  10830. layout->addRow(tr("Port:"),port);
  10831. connect(port,SIGNAL(currentIndexChanged(QString)),
  10832. this,SLOT(updatePort(QString)));
  10833. connect(port,SIGNAL(editTextChanged(QString)),
  10834. this,SLOT(updatePort(QString)));
  10835. BaudSelector*rate= new BaudSelector;
  10836. layout->addRow(tr("Baud:"),rate);
  10837. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10838. this,SLOT(updateBaudRate(QString)));
  10839. ParitySelector*parity= new ParitySelector;
  10840. layout->addRow(tr("Parity:"),parity);
  10841. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10842. this,SLOT(updateParity(QString)));
  10843. FlowSelector*flow= new FlowSelector;
  10844. layout->addRow(tr("Flow Control:"),flow);
  10845. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10846. this,SLOT(updateFlowControl(QString)));
  10847. StopSelector*stop= new StopSelector;
  10848. layout->addRow(tr("Stop Bits:"),stop);
  10849. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10850. this,SLOT(updateStopBits(QString)));
  10851. /*816:*/
  10852. #line 16928 "./typica.w"
  10853. QDomElement referenceElement=
  10854. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10855. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10856. QDomElement node;
  10857. /*:816*/
  10858. #line 17840 "./typica.w"
  10859. for(int i= 0;i<configData.size();i++)
  10860. {
  10861. node= configData.at(i).toElement();
  10862. if(node.attribute("name")=="port")
  10863. {
  10864. int j= port->findText(node.attribute("value"));
  10865. if(j>=0)
  10866. {
  10867. port->setCurrentIndex(j);
  10868. }
  10869. else
  10870. {
  10871. port->insertItem(0,node.attribute("value"));
  10872. port->setCurrentIndex(0);
  10873. }
  10874. }
  10875. else if(node.attribute("name")=="baudrate")
  10876. {
  10877. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10878. }
  10879. else if(node.attribute("name")=="parity")
  10880. {
  10881. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10882. }
  10883. else if(node.attribute("name")=="flowcontrol")
  10884. {
  10885. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10886. }
  10887. else if(node.attribute("name")=="stopbits")
  10888. {
  10889. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10890. }
  10891. }
  10892. updatePort(port->currentText());
  10893. updateBaudRate(rate->currentText());
  10894. updateParity(parity->currentText());
  10895. updateFlowControl(flow->currentText());
  10896. updateStopBits(stop->currentText());
  10897. setLayout(layout);
  10898. }
  10899. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10900. {
  10901. updateAttribute("port",newPort);
  10902. }
  10903. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10904. {
  10905. updateAttribute("baudrate",newRate);
  10906. }
  10907. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10908. {
  10909. updateAttribute("parity",newParity);
  10910. }
  10911. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10912. {
  10913. updateAttribute("flowcontrol",newFlow);
  10914. }
  10915. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10916. {
  10917. updateAttribute("stopbits",newStopBits);
  10918. }
  10919. /*:853*/
  10920. #line 596 "./typica.w"
  10921. /*855:*/
  10922. #line 17963 "./typica.w"
  10923. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10924. const QModelIndex&index)
  10925. :BasicDeviceConfigurationWidget(model,index),
  10926. unitSpecificationLayout(new QStackedLayout),
  10927. decimalSpecificationLayout(new QStackedLayout)
  10928. {
  10929. QVBoxLayout*layout= new QVBoxLayout;
  10930. QToolButton*addChannelButton= new QToolButton;
  10931. addChannelButton->setText(tr("Add Channel"));
  10932. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10933. "Temperature Process Value",
  10934. "modbustemperaturepv");
  10935. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10936. "Temperature Set Value",
  10937. "modbustemperaturesv");
  10938. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10939. this,SLOT(insertChildNode(QString,QString)));
  10940. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10941. this,SLOT(insertChildNode(QString,QString)));
  10942. QMenu*channelMenu= new QMenu;
  10943. channelMenu->addAction(addTemperaturePV);
  10944. channelMenu->addAction(addTemperatureSV);
  10945. addChannelButton->setMenu(channelMenu);
  10946. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10947. layout->addWidget(addChannelButton);
  10948. QHBoxLayout*stationLayout= new QHBoxLayout;
  10949. QLabel*stationLabel= new QLabel(tr("Station:"));
  10950. QSpinBox*stationNumber= new QSpinBox;
  10951. stationNumber->setMinimum(0);
  10952. stationNumber->setMaximum(255);
  10953. stationLayout->addWidget(stationLabel);
  10954. stationLayout->addWidget(stationNumber);
  10955. layout->addLayout(stationLayout);
  10956. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10957. layout->addWidget(fixedUnit);
  10958. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10959. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10960. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10961. QComboBox*fixedUnitSelector= new QComboBox;
  10962. fixedUnitSelector->addItem("Fahrenheit");
  10963. fixedUnitSelector->addItem("Celsius");
  10964. fixedUnitLayout->addWidget(fixedUnitLabel);
  10965. fixedUnitLayout->addWidget(fixedUnitSelector);
  10966. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10967. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10968. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10969. QFormLayout*queriedUnitLayout= new QFormLayout;
  10970. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10971. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10972. QSpinBox*valueF= new QSpinBox;
  10973. valueF->setMinimum(0);
  10974. valueF->setMaximum(65535);
  10975. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10976. QSpinBox*valueC= new QSpinBox;
  10977. valueC->setMinimum(0);
  10978. valueC->setMaximum(65535);
  10979. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10980. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10981. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10982. layout->addLayout(unitSpecificationLayout);
  10983. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10984. layout->addWidget(fixedPrecision);
  10985. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10986. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10987. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10988. fixedPrecisionValue->setMinimum(0);
  10989. fixedPrecisionValue->setMaximum(9);
  10990. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10991. fixedPrecisionValue);
  10992. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10993. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10994. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10995. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10996. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10997. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10998. precisionAddress);
  10999. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  11000. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  11001. layout->addLayout(decimalSpecificationLayout);
  11002. /*816:*/
  11003. #line 16928 "./typica.w"
  11004. QDomElement referenceElement=
  11005. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11006. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11007. QDomElement node;
  11008. /*:816*/
  11009. #line 18043 "./typica.w"
  11010. for(int i= 0;i<configData.size();i++)
  11011. {
  11012. node= configData.at(i).toElement();
  11013. if(node.attribute("name")=="station")
  11014. {
  11015. stationNumber->setValue(node.attribute("value").toInt());
  11016. }
  11017. else if(node.attribute("name")=="fixedunit")
  11018. {
  11019. if(node.attribute("value")=="true")
  11020. {
  11021. fixedUnit->setCheckState(Qt::Checked);
  11022. }
  11023. else if(node.attribute("value")=="false")
  11024. {
  11025. fixedUnit->setCheckState(Qt::Unchecked);
  11026. }
  11027. }
  11028. else if(node.attribute("name")=="fixedprecision")
  11029. {
  11030. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  11031. }
  11032. else if(node.attribute("name")=="unit")
  11033. {
  11034. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  11035. }
  11036. else if(node.attribute("name")=="unitaddress")
  11037. {
  11038. unitAddress->setValue(node.attribute("value").toInt());
  11039. }
  11040. else if(node.attribute("name")=="fvalue")
  11041. {
  11042. valueF->setValue(node.attribute("value").toInt());
  11043. }
  11044. else if(node.attribute("name")=="cvalue")
  11045. {
  11046. valueC->setValue(node.attribute("value").toInt());
  11047. }
  11048. else if(node.attribute("name")=="precisionaddress")
  11049. {
  11050. precisionAddress->setValue(node.attribute("value").toInt());
  11051. }
  11052. else if(node.attribute("name")=="precision")
  11053. {
  11054. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  11055. }
  11056. }
  11057. updateStationNumber(stationNumber->value());
  11058. updateFixedUnit(fixedUnit->isChecked());
  11059. updateFixedDecimal(fixedPrecision->isChecked());
  11060. updateUnit(fixedUnitSelector->currentText());
  11061. updateUnitAddress(unitAddress->value());
  11062. updateValueF(valueF->value());
  11063. updateValueC(valueC->value());
  11064. updatePrecisionAddress(precisionAddress->value());
  11065. updatePrecisionValue(fixedPrecisionValue->value());
  11066. connect(stationNumber,SIGNAL(valueChanged(int)),
  11067. this,SLOT(updateStationNumber(int)));
  11068. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  11069. this,SLOT(updateUnit(QString)));
  11070. connect(unitAddress,SIGNAL(valueChanged(int)),
  11071. this,SLOT(updateUnitAddress(int)));
  11072. connect(valueF,SIGNAL(valueChanged(int)),
  11073. this,SLOT(updateValueF(int)));
  11074. connect(valueC,SIGNAL(valueChanged(int)),
  11075. this,SLOT(updateValueC(int)));
  11076. connect(fixedUnit,SIGNAL(toggled(bool)),
  11077. this,SLOT(updateFixedUnit(bool)));
  11078. connect(fixedPrecision,SIGNAL(toggled(bool)),
  11079. this,SLOT(updateFixedDecimal(bool)));
  11080. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  11081. this,SLOT(updatePrecisionValue(int)));
  11082. connect(precisionAddress,SIGNAL(valueChanged(int)),
  11083. this,SLOT(updatePrecisionAddress(int)));
  11084. setLayout(layout);
  11085. }
  11086. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  11087. {
  11088. updateAttribute("station",QString("%1").arg(newStation));
  11089. }
  11090. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  11091. {
  11092. if(newFixed)
  11093. {
  11094. unitSpecificationLayout->setCurrentIndex(0);
  11095. updateAttribute("fixedunit","true");
  11096. }
  11097. else
  11098. {
  11099. unitSpecificationLayout->setCurrentIndex(1);
  11100. updateAttribute("fixedunit","false");
  11101. }
  11102. }
  11103. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  11104. {
  11105. if(newFixed)
  11106. {
  11107. decimalSpecificationLayout->setCurrentIndex(0);
  11108. updateAttribute("fixedprecision","true");
  11109. }
  11110. else
  11111. {
  11112. decimalSpecificationLayout->setCurrentIndex(1);
  11113. updateAttribute("fixedprecision","false");
  11114. }
  11115. }
  11116. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  11117. {
  11118. updateAttribute("unit",newUnit);
  11119. }
  11120. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  11121. {
  11122. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  11123. }
  11124. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  11125. {
  11126. updateAttribute("fvalue",QString("%1").arg(newValue));
  11127. }
  11128. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  11129. {
  11130. updateAttribute("cvalue",QString("%1").arg(newValue));
  11131. }
  11132. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  11133. {
  11134. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  11135. }
  11136. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  11137. {
  11138. updateAttribute("precision",QString("%1").arg(newValue));
  11139. }
  11140. /*:855*/
  11141. #line 597 "./typica.w"
  11142. /*857:*/
  11143. #line 18206 "./typica.w"
  11144. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  11145. const QModelIndex&index)
  11146. :BasicDeviceConfigurationWidget(model,index)
  11147. {
  11148. QFormLayout*layout= new QFormLayout;
  11149. ShortHexSpinBox*address= new ShortHexSpinBox;
  11150. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  11151. /*816:*/
  11152. #line 16928 "./typica.w"
  11153. QDomElement referenceElement=
  11154. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11155. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11156. QDomElement node;
  11157. /*:816*/
  11158. #line 18214 "./typica.w"
  11159. for(int i= 0;i<configData.size();i++)
  11160. {
  11161. node= configData.at(i).toElement();
  11162. if(node.attribute("name")=="address")
  11163. {
  11164. address->setValue(node.attribute("value").toInt());
  11165. break;
  11166. }
  11167. }
  11168. updateAddress(address->value());
  11169. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  11170. setLayout(layout);
  11171. }
  11172. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  11173. {
  11174. updateAttribute("address",QString("%1").arg(newAddress));
  11175. }
  11176. /*:857*/
  11177. #line 598 "./typica.w"
  11178. /*859:*/
  11179. #line 18262 "./typica.w"
  11180. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  11181. const QModelIndex&index)
  11182. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  11183. {
  11184. QVBoxLayout*layout= new QVBoxLayout;
  11185. QFormLayout*addressLayout= new QFormLayout;
  11186. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  11187. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  11188. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  11189. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  11190. layout->addLayout(addressLayout);
  11191. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  11192. layout->addWidget(fixedRange);
  11193. QWidget*queriedRangePlaceholder= new QWidget(this);
  11194. QFormLayout*queriedRangeLayout= new QFormLayout;
  11195. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  11196. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  11197. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  11198. lowerAddress);
  11199. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  11200. upperAddress);
  11201. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  11202. boundsLayout->addWidget(queriedRangePlaceholder);
  11203. QWidget*fixedRangePlaceholder= new QWidget(this);
  11204. QFormLayout*fixedRangeLayout= new QFormLayout;
  11205. QLineEdit*fixedLower= new QLineEdit;
  11206. QLineEdit*fixedUpper= new QLineEdit;
  11207. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  11208. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  11209. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  11210. boundsLayout->addWidget(fixedRangePlaceholder);
  11211. layout->addLayout(boundsLayout);
  11212. /*816:*/
  11213. #line 16928 "./typica.w"
  11214. QDomElement referenceElement=
  11215. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11216. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11217. QDomElement node;
  11218. /*:816*/
  11219. #line 18295 "./typica.w"
  11220. for(int i= 0;i<configData.size();i++)
  11221. {
  11222. node= configData.at(i).toElement();
  11223. if(node.attribute("name")=="readaddress")
  11224. {
  11225. readAddress->setValue(node.attribute("value").toInt());
  11226. }
  11227. else if(node.attribute("name")=="writeaddress")
  11228. {
  11229. writeAddress->setValue(node.attribute("value").toInt());
  11230. }
  11231. else if(node.attribute("name")=="fixedrange")
  11232. {
  11233. if(node.attribute("value")=="true")
  11234. {
  11235. fixedRange->setCheckState(Qt::Checked);
  11236. }
  11237. else if(node.attribute("value")=="false")
  11238. {
  11239. fixedRange->setCheckState(Qt::Unchecked);
  11240. }
  11241. }
  11242. else if(node.attribute("name")=="fixedlower")
  11243. {
  11244. fixedLower->setText(node.attribute("value"));
  11245. }
  11246. else if(node.attribute("name")=="fixedupper")
  11247. {
  11248. fixedUpper->setText(node.attribute("value"));
  11249. }
  11250. else if(node.attribute("name")=="loweraddress")
  11251. {
  11252. lowerAddress->setValue(node.attribute("value").toInt());
  11253. }
  11254. else if(node.attribute("name")=="upperaddress")
  11255. {
  11256. upperAddress->setValue(node.attribute("value").toInt());
  11257. }
  11258. }
  11259. updateReadAddress(readAddress->value());
  11260. updateWriteAddress(writeAddress->value());
  11261. updateFixedRange(fixedRange->isChecked());
  11262. updateLower(fixedLower->text());
  11263. updateUpper(fixedUpper->text());
  11264. updateLowerAddress(lowerAddress->value());
  11265. updateUpperAddress(upperAddress->value());
  11266. connect(readAddress,SIGNAL(valueChanged(int)),
  11267. this,SLOT(updateReadAddress(int)));
  11268. connect(writeAddress,SIGNAL(valueChanged(int)),
  11269. this,SLOT(updateWriteAddress(int)));
  11270. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  11271. connect(fixedLower,SIGNAL(textChanged(QString)),
  11272. this,SLOT(updateLower(QString)));
  11273. connect(fixedUpper,SIGNAL(textChanged(QString)),
  11274. this,SLOT(updateUpper(QString)));
  11275. connect(lowerAddress,SIGNAL(valueChanged(int)),
  11276. this,SLOT(updateLowerAddress(int)));
  11277. connect(upperAddress,SIGNAL(valueChanged(int)),
  11278. this,SLOT(updateUpperAddress(int)));
  11279. setLayout(layout);
  11280. }
  11281. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  11282. {
  11283. updateAttribute("readaddress",QString("%1").arg(newAddress));
  11284. }
  11285. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  11286. {
  11287. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  11288. }
  11289. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  11290. {
  11291. if(fixed)
  11292. {
  11293. updateAttribute("fixedrange","true");
  11294. boundsLayout->setCurrentIndex(1);
  11295. }
  11296. else
  11297. {
  11298. updateAttribute("fixedrange","false");
  11299. boundsLayout->setCurrentIndex(0);
  11300. }
  11301. }
  11302. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  11303. {
  11304. updateAttribute("fixedlower",lower);
  11305. }
  11306. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  11307. {
  11308. updateAttribute("fixedupper",upper);
  11309. }
  11310. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  11311. {
  11312. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  11313. }
  11314. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  11315. {
  11316. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  11317. }
  11318. /*:859*/
  11319. #line 599 "./typica.w"
  11320. /*815:*/
  11321. #line 16798 "./typica.w"
  11322. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11323. :BasicDeviceConfigurationWidget(model,index)
  11324. {
  11325. QVBoxLayout*layout= new QVBoxLayout;
  11326. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  11327. QMenu*deviceMenu= new QMenu;
  11328. NodeInserter*insertAction;
  11329. foreach(insertAction,AppInstance->topLevelNodeInserters)
  11330. {
  11331. connect(insertAction,SIGNAL(triggered(QString,QString)),
  11332. this,SLOT(insertChildNode(QString,QString)));
  11333. deviceMenu->addAction(insertAction);
  11334. }
  11335. addDeviceButton->setMenu(deviceMenu);
  11336. layout->addWidget(addDeviceButton);
  11337. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  11338. QMenu*annotationMenu= new QMenu;
  11339. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  11340. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  11341. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  11342. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  11343. tr("Free Text"),
  11344. "freeannotation");
  11345. annotationMenu->addAction(basicButtonInserter);
  11346. annotationMenu->addAction(countingButtonInserter);
  11347. annotationMenu->addAction(spinBoxInserter);
  11348. annotationMenu->addAction(freeAnnotationInserter);
  11349. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  11350. this,SLOT(insertChildNode(QString,QString)));
  11351. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  11352. this,SLOT(insertChildNode(QString,QString)));
  11353. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  11354. this,SLOT(insertChildNode(QString,QString)));
  11355. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11356. this,SLOT(insertChildNode(QString,QString)));
  11357. /*1137:*/
  11358. #line 144 "./valueannotation.w"
  11359. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  11360. tr("Value Annotation"),
  11361. "valueannotation");
  11362. annotationMenu->addAction(valueAnnotationInserter);
  11363. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11364. this,SLOT(insertChildNode(QString,QString)));
  11365. /*:1137*//*1151:*/
  11366. #line 115 "./thresholdannotation.w"
  11367. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  11368. tr("Threshold Annotation"),
  11369. "thresholdannotation");
  11370. annotationMenu->addAction(thresholdAnnotationInserter);
  11371. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11372. this,SLOT(insertChildNode(QString,QString)));
  11373. /*:1151*/
  11374. #line 16834 "./typica.w"
  11375. addAnnotationControlButton->setMenu(annotationMenu);
  11376. layout->addWidget(addAnnotationControlButton);
  11377. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  11378. QMenu*timersMenu= new QMenu;
  11379. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  11380. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  11381. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  11382. timersMenu->addAction(coolingTimerInserter);
  11383. timersMenu->addAction(rangeTimerInserter);
  11384. timersMenu->addAction(multirangeTimerInserter);
  11385. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  11386. this,SLOT(insertChildNode(QString,QString)));
  11387. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11388. this,SLOT(insertChildNode(QString,QString)));
  11389. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11390. this,SLOT(insertChildNode(QString,QString)));
  11391. timersButton->setMenu(timersMenu);
  11392. layout->addWidget(timersButton);
  11393. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  11394. QMenu*advancedMenu= new QMenu;
  11395. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  11396. advancedMenu->addAction(linearsplineinserter);
  11397. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  11398. advancedMenu->addAction(translationinserter);
  11399. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11400. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11401. /*1049:*/
  11402. #line 258 "./rate.w"
  11403. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  11404. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11405. advancedMenu->addAction(rateOfChangeInserter);
  11406. /*:1049*//*1063:*/
  11407. #line 272 "./mergeseries.w"
  11408. NodeInserter*mergeSeriesInserter= new NodeInserter(tr("Merge Series"),
  11409. tr("Merge"),
  11410. "mergeseries");
  11411. connect(mergeSeriesInserter,SIGNAL(triggered(QString,QString)),
  11412. this,SLOT(insertChildNode(QString,QString)));
  11413. advancedMenu->addAction(mergeSeriesInserter);
  11414. /*:1063*/
  11415. #line 16863 "./typica.w"
  11416. advancedButton->setMenu(advancedMenu);
  11417. layout->addWidget(advancedButton);
  11418. QHBoxLayout*idLayout= new QHBoxLayout;
  11419. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  11420. idLayout->addWidget(idLabel);
  11421. QSpinBox*id= new QSpinBox;
  11422. idLayout->addWidget(id);
  11423. idLayout->addStretch();
  11424. layout->addLayout(idLayout);
  11425. QHBoxLayout*capacityLayout= new QHBoxLayout;
  11426. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  11427. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  11428. capacity->setMinimum(0.0);
  11429. capacity->setDecimals(3);
  11430. capacity->setMaximum(999999.999);
  11431. QComboBox*capacityUnit= new QComboBox;
  11432. capacityUnit->addItem("g");
  11433. capacityUnit->addItem("Kg");
  11434. capacityUnit->addItem("oz");
  11435. capacityUnit->addItem("Lb");
  11436. capacityUnit->setCurrentIndex(3);
  11437. capacityLayout->addWidget(capacityCheckEnabled);
  11438. capacityLayout->addWidget(capacity);
  11439. capacityLayout->addWidget(capacityUnit);
  11440. capacityLayout->addStretch();
  11441. layout->addLayout(capacityLayout);
  11442. layout->addStretch();
  11443. /*816:*/
  11444. #line 16928 "./typica.w"
  11445. QDomElement referenceElement=
  11446. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11447. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11448. QDomElement node;
  11449. /*:816*/
  11450. #line 16892 "./typica.w"
  11451. for(int i= 0;i<configData.size();i++)
  11452. {
  11453. node= configData.at(i).toElement();
  11454. if(node.attribute("name")=="databaseid")
  11455. {
  11456. id->setValue(node.attribute("value").toInt());
  11457. }
  11458. else if(node.attribute("name")=="checkcapacity")
  11459. {
  11460. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  11461. }
  11462. else if(node.attribute("name")=="capacity")
  11463. {
  11464. capacity->setValue(node.attribute("value").toDouble());
  11465. }
  11466. else if(node.attribute("name")=="capacityunit")
  11467. {
  11468. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  11469. }
  11470. }
  11471. updateRoasterId(id->value());
  11472. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  11473. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  11474. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  11475. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  11476. setLayout(layout);
  11477. }
  11478. /*:815*//*817:*/
  11479. #line 16938 "./typica.w"
  11480. void RoasterConfWidget::updateRoasterId(int id)
  11481. {
  11482. updateAttribute("databaseid",QString("%1").arg(id));
  11483. }
  11484. void RoasterConfWidget::updateCapacityCheck(int value)
  11485. {
  11486. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  11487. }
  11488. void RoasterConfWidget::updateCapacity(const QString&value)
  11489. {
  11490. updateAttribute("capacity",value);
  11491. }
  11492. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  11493. {
  11494. updateAttribute("capacityunit",value);
  11495. }
  11496. /*:817*/
  11497. #line 600 "./typica.w"
  11498. /*863:*/
  11499. #line 18445 "./typica.w"
  11500. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11501. :BasicDeviceConfigurationWidget(model,index)
  11502. {
  11503. QFormLayout*layout= new QFormLayout;
  11504. QLineEdit*buttonTextEdit= new QLineEdit;
  11505. QLineEdit*annotationTextEdit= new QLineEdit;
  11506. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11507. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11508. /*816:*/
  11509. #line 16928 "./typica.w"
  11510. QDomElement referenceElement=
  11511. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11512. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11513. QDomElement node;
  11514. /*:816*/
  11515. #line 18454 "./typica.w"
  11516. for(int i= 0;i<configData.size();i++)
  11517. {
  11518. node= configData.at(i).toElement();
  11519. if(node.attribute("name")=="buttontext")
  11520. {
  11521. buttonTextEdit->setText(node.attribute("value"));
  11522. }
  11523. else if(node.attribute("name")=="annotationtext")
  11524. {
  11525. annotationTextEdit->setText(node.attribute("value"));
  11526. }
  11527. }
  11528. updateButtonText(buttonTextEdit->text());
  11529. updateAnnotationText(annotationTextEdit->text());
  11530. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11531. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11532. setLayout(layout);
  11533. }
  11534. /*:863*//*864:*/
  11535. #line 18476 "./typica.w"
  11536. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  11537. {
  11538. updateAttribute("buttontext",text);
  11539. }
  11540. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11541. {
  11542. updateAttribute("annotationtext",text);
  11543. }
  11544. /*:864*//*867:*/
  11545. #line 18514 "./typica.w"
  11546. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11547. :BasicDeviceConfigurationWidget(model,index)
  11548. {
  11549. QFormLayout*layout= new QFormLayout;
  11550. QLineEdit*buttonTextEdit= new QLineEdit;
  11551. QLineEdit*annotationTextEdit= new QLineEdit;
  11552. annotationTextEdit->setText("%A-%1");
  11553. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11554. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11555. /*816:*/
  11556. #line 16928 "./typica.w"
  11557. QDomElement referenceElement=
  11558. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11559. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11560. QDomElement node;
  11561. /*:816*/
  11562. #line 18524 "./typica.w"
  11563. for(int i= 0;i<configData.size();i++)
  11564. {
  11565. node= configData.at(i).toElement();
  11566. if(node.attribute("name")=="buttontext")
  11567. {
  11568. buttonTextEdit->setText(node.attribute("value"));
  11569. }
  11570. else if(node.attribute("name")=="annotationtext")
  11571. {
  11572. annotationTextEdit->setText(node.attribute("value"));
  11573. }
  11574. }
  11575. updateButtonText(buttonTextEdit->text());
  11576. updateAnnotationText(annotationTextEdit->text());
  11577. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11578. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11579. QTextEdit*documentation= new QTextEdit;
  11580. documentation->setHtml(tr("If the <b>Annotation Text</b> contains <tt>%1</tt>, this will be replaced in the annotation with a number that increments each time the button is pressed."));
  11581. documentation->setReadOnly(true);
  11582. layout->addRow("",documentation);
  11583. setLayout(layout);
  11584. }
  11585. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  11586. {
  11587. updateAttribute("buttontext",text);
  11588. }
  11589. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11590. {
  11591. updateAttribute("annotationtext",text);
  11592. }
  11593. /*:867*/
  11594. #line 601 "./typica.w"
  11595. /*870:*/
  11596. #line 18592 "./typica.w"
  11597. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11598. :BasicDeviceConfigurationWidget(model,index)
  11599. {
  11600. QFormLayout*layout= new QFormLayout;
  11601. QLineEdit*labelEdit= new QLineEdit;
  11602. layout->addRow(tr("Control Label: "),labelEdit);
  11603. QLineEdit*minimumEdit= new QLineEdit;
  11604. layout->addRow(tr("Minimum Value: "),minimumEdit);
  11605. QLineEdit*maximumEdit= new QLineEdit;
  11606. layout->addRow(tr("Maximum Value: "),maximumEdit);
  11607. QSpinBox*precisionEdit= new QSpinBox;
  11608. precisionEdit->setMinimum(0);
  11609. precisionEdit->setMaximum(9);
  11610. layout->addRow(tr("Precision"),precisionEdit);
  11611. QLineEdit*pretext= new QLineEdit;
  11612. layout->addRow(tr("Prefix text"),pretext);
  11613. QLineEdit*posttext= new QLineEdit;
  11614. layout->addRow(tr("Suffix text"),posttext);
  11615. /*816:*/
  11616. #line 16928 "./typica.w"
  11617. QDomElement referenceElement=
  11618. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11619. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11620. QDomElement node;
  11621. /*:816*/
  11622. #line 18611 "./typica.w"
  11623. for(int i= 0;i<configData.size();i++)
  11624. {
  11625. node= configData.at(i).toElement();
  11626. if(node.attribute("name")=="label")
  11627. {
  11628. labelEdit->setText(node.attribute("value"));
  11629. }
  11630. else if(node.attribute("name")=="minimum")
  11631. {
  11632. minimumEdit->setText(node.attribute("value"));
  11633. }
  11634. else if(node.attribute("name")=="maximum")
  11635. {
  11636. maximumEdit->setText(node.attribute("value"));
  11637. }
  11638. else if(node.attribute("name")=="precision")
  11639. {
  11640. precisionEdit->setValue(node.attribute("value").toInt());
  11641. }
  11642. else if(node.attribute("name")=="pretext")
  11643. {
  11644. pretext->setText(node.attribute("value"));
  11645. }
  11646. else if(node.attribute("name")=="posttext")
  11647. {
  11648. posttext->setText(node.attribute("value"));
  11649. }
  11650. }
  11651. updateLabel(labelEdit->text());
  11652. updateMinimum(minimumEdit->text());
  11653. updateMaximum(maximumEdit->text());
  11654. updatePrecision(precisionEdit->value());
  11655. updatePretext(pretext->text());
  11656. updatePosttext(posttext->text());
  11657. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  11658. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  11659. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  11660. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  11661. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  11662. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  11663. setLayout(layout);
  11664. }
  11665. void NoteSpinConfWidget::updateLabel(const QString&text)
  11666. {
  11667. updateAttribute("label",text);
  11668. }
  11669. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  11670. {
  11671. updateAttribute("minimum",minimum);
  11672. }
  11673. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  11674. {
  11675. updateAttribute("maximum",maximum);
  11676. }
  11677. void NoteSpinConfWidget::updatePrecision(int precision)
  11678. {
  11679. updateAttribute("precision",QString("%1").arg(precision));
  11680. }
  11681. void NoteSpinConfWidget::updatePretext(const QString&text)
  11682. {
  11683. updateAttribute("pretext",text);
  11684. }
  11685. void NoteSpinConfWidget::updatePosttext(const QString&text)
  11686. {
  11687. updateAttribute("posttext",text);
  11688. }
  11689. /*:870*/
  11690. #line 602 "./typica.w"
  11691. /*354:*/
  11692. #line 7901 "./typica.w"
  11693. LinearCalibrator::LinearCalibrator(QObject*parent):
  11694. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  11695. {
  11696. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11697. }
  11698. /*:354*//*355:*/
  11699. #line 7915 "./typica.w"
  11700. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  11701. {
  11702. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  11703. if(clamp)
  11704. {
  11705. if(outval<Lo1)
  11706. {
  11707. outval= Lo1;
  11708. }
  11709. else if(outval> Up1)
  11710. {
  11711. outval= Up1;
  11712. }
  11713. }
  11714. if(sensitivitySetting>=0.05)
  11715. {
  11716. int temp= qRound(outval/sensitivitySetting);
  11717. outval= temp*sensitivitySetting;
  11718. }
  11719. Measurement adjusted(outval,measure.time(),measure.scale());
  11720. emit measurement(adjusted);
  11721. return adjusted;
  11722. }
  11723. /*:355*//*356:*/
  11724. #line 7942 "./typica.w"
  11725. double LinearCalibrator::measuredLower()
  11726. {
  11727. return Lo2;
  11728. }
  11729. double LinearCalibrator::measuredUpper()
  11730. {
  11731. return Up2;
  11732. }
  11733. double LinearCalibrator::mappedLower()
  11734. {
  11735. return Lo1;
  11736. }
  11737. double LinearCalibrator::mappedUpper()
  11738. {
  11739. return Up1;
  11740. }
  11741. bool LinearCalibrator::isClosedRange()
  11742. {
  11743. return clamp;
  11744. }
  11745. void LinearCalibrator::setMeasuredLower(double lower)
  11746. {
  11747. Lo2= lower;
  11748. }
  11749. void LinearCalibrator::setMeasuredUpper(double upper)
  11750. {
  11751. Up2= upper;
  11752. }
  11753. void LinearCalibrator::setMappedLower(double lower)
  11754. {
  11755. Lo1= lower;
  11756. }
  11757. void LinearCalibrator::setMappedUpper(double upper)
  11758. {
  11759. Up1= upper;
  11760. }
  11761. void LinearCalibrator::setClosedRange(bool closed)
  11762. {
  11763. clamp= closed;
  11764. }
  11765. void LinearCalibrator::setSensitivity(double sensitivity)
  11766. {
  11767. sensitivitySetting= sensitivity;
  11768. }
  11769. double LinearCalibrator::sensitivity()
  11770. {
  11771. return sensitivitySetting;
  11772. }
  11773. /*:356*/
  11774. #line 603 "./typica.w"
  11775. /*361:*/
  11776. #line 8075 "./typica.w"
  11777. void LinearSplineInterpolator::add_pair(double source,double destination)
  11778. {
  11779. pairs->insert(source,destination);
  11780. make_interpolators();
  11781. }
  11782. void LinearSplineInterpolator::make_interpolators()
  11783. {
  11784. if(pairs->size()> 1)
  11785. {
  11786. while(interpolators->size()> 0)
  11787. {
  11788. LinearCalibrator*removed= interpolators->takeFirst();
  11789. removed->deleteLater();
  11790. }
  11791. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11792. QMap<double,double> ::const_iterator j= i+1;
  11793. while(j!=pairs->constEnd())
  11794. {
  11795. LinearCalibrator*segment= new LinearCalibrator();
  11796. segment->setMeasuredLower(i.key());
  11797. segment->setMappedLower(i.value());
  11798. segment->setMeasuredUpper(j.key());
  11799. segment->setMappedUpper(j.value());
  11800. segment->setClosedRange(false);
  11801. interpolators->append(segment);
  11802. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11803. i++;
  11804. j++;
  11805. }
  11806. }
  11807. }
  11808. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11809. QObject(parent),pairs(new QMap<double,double> ),
  11810. interpolators(new QList<LinearCalibrator*> )
  11811. {
  11812. }
  11813. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11814. {
  11815. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11816. int index= -1;
  11817. while(i!=pairs->constEnd())
  11818. {
  11819. if(measure.temperature()<=i.key())
  11820. {
  11821. break;
  11822. }
  11823. i++;
  11824. index++;
  11825. }
  11826. if(index<0)
  11827. {
  11828. index= 0;
  11829. }
  11830. if(index>=interpolators->size())
  11831. {
  11832. index= interpolators->size()-1;
  11833. }
  11834. if(interpolators->at(index)!=NULL)
  11835. {
  11836. return interpolators->at(index)->newMeasurement(measure);
  11837. }
  11838. return Measurement();
  11839. }
  11840. /*:361*/
  11841. #line 604 "./typica.w"
  11842. /*1014:*/
  11843. #line 19959 "./typica.w"
  11844. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11845. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11846. {
  11847. QFormLayout*layout= new QFormLayout;
  11848. QLineEdit*source= new QLineEdit;
  11849. layout->addRow(tr("Source column name:"),source);
  11850. QLineEdit*destination= new QLineEdit;
  11851. layout->addRow(tr("Destination column name:"),destination);
  11852. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11853. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11854. QTableView*mappingTable= new QTableView;
  11855. mappingTable->setModel(tablemodel);
  11856. NumericDelegate*delegate= new NumericDelegate;
  11857. mappingTable->setItemDelegate(delegate);
  11858. layout->addRow(tr("Mapping data:"),mappingTable);
  11859. /*816:*/
  11860. #line 16928 "./typica.w"
  11861. QDomElement referenceElement=
  11862. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11863. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11864. QDomElement node;
  11865. /*:816*/
  11866. #line 19975 "./typica.w"
  11867. for(int i= 0;i<configData.size();i++)
  11868. {
  11869. node= configData.at(i).toElement();
  11870. if(node.attribute("name")=="source")
  11871. {
  11872. source->setText(node.attribute("value"));
  11873. }
  11874. else if(node.attribute("name")=="destination")
  11875. {
  11876. destination->setText(node.attribute("value"));
  11877. }
  11878. else if(node.attribute("name")=="sourcevalues")
  11879. {
  11880. /*1015:*/
  11881. #line 20014 "./typica.w"
  11882. QString data= node.attribute("value");
  11883. if(data.length()> 3)
  11884. {
  11885. data.chop(2);
  11886. data= data.remove(0,2);
  11887. }
  11888. QStringList itemList= data.split(",");
  11889. /*:1015*/
  11890. #line 19989 "./typica.w"
  11891. int column= 0;
  11892. /*1016:*/
  11893. #line 20026 "./typica.w"
  11894. for(int j= 0;j<itemList.size();j++)
  11895. {
  11896. tablemodel->setData(tablemodel->index(j,column),
  11897. QVariant(itemList.at(j).toDouble()),
  11898. Qt::DisplayRole);
  11899. }
  11900. /*:1016*/
  11901. #line 19991 "./typica.w"
  11902. }
  11903. else if(node.attribute("name")=="destinationvalues")
  11904. {
  11905. /*1015:*/
  11906. #line 20014 "./typica.w"
  11907. QString data= node.attribute("value");
  11908. if(data.length()> 3)
  11909. {
  11910. data.chop(2);
  11911. data= data.remove(0,2);
  11912. }
  11913. QStringList itemList= data.split(",");
  11914. /*:1015*/
  11915. #line 19996 "./typica.w"
  11916. int column= 1;
  11917. /*1016:*/
  11918. #line 20026 "./typica.w"
  11919. for(int j= 0;j<itemList.size();j++)
  11920. {
  11921. tablemodel->setData(tablemodel->index(j,column),
  11922. QVariant(itemList.at(j).toDouble()),
  11923. Qt::DisplayRole);
  11924. }
  11925. /*:1016*/
  11926. #line 19998 "./typica.w"
  11927. }
  11928. }
  11929. updateSourceColumn(source->text());
  11930. updateDestinationColumn(destination->text());
  11931. updateKnots();
  11932. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11933. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11934. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11935. setLayout(layout);
  11936. }
  11937. /*:1014*//*1017:*/
  11938. #line 20037 "./typica.w"
  11939. void LinearSplineInterpolationConfWidget::updateKnots()
  11940. {
  11941. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11942. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11943. }
  11944. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11945. {
  11946. updateAttribute("source",source);
  11947. }
  11948. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11949. {
  11950. updateAttribute("destination",dest);
  11951. }
  11952. /*:1017*/
  11953. #line 605 "./typica.w"
  11954. /*1034:*/
  11955. #line 20508 "./typica.w"
  11956. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11957. :BasicDeviceConfigurationWidget(model,index),
  11958. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox),
  11959. delaySelector(new QSpinBox)
  11960. {
  11961. unitSelector->addItem("Fahrenheit");
  11962. unitSelector->addItem("Celsius");
  11963. temperatureValue->setMinimum(0);
  11964. temperatureValue->setMaximum(1000);
  11965. QFormLayout*layout= new QFormLayout;
  11966. QLineEdit*column= new QLineEdit;
  11967. layout->addRow(tr("Column to match:"),column);
  11968. layout->addRow(tr("Unit:"),unitSelector);
  11969. layout->addRow(tr("Value:"),temperatureValue);
  11970. layout->addRow(tr("Start of batch safety delay:"),delaySelector);
  11971. /*816:*/
  11972. #line 16928 "./typica.w"
  11973. QDomElement referenceElement=
  11974. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11975. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11976. QDomElement node;
  11977. /*:816*/
  11978. #line 20524 "./typica.w"
  11979. for(int i= 0;i<configData.size();i++)
  11980. {
  11981. node= configData.at(i).toElement();
  11982. if(node.attribute("name")=="column")
  11983. {
  11984. column->setText(node.attribute("value"));
  11985. }
  11986. else if(node.attribute("name")=="unit")
  11987. {
  11988. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11989. }
  11990. else if(node.attribute("name")=="value")
  11991. {
  11992. temperatureValue->setValue(node.attribute("value").toDouble());
  11993. }
  11994. else if(node.attribute("name")=="delay")
  11995. {
  11996. delaySelector->setValue(node.attribute("value").toInt());
  11997. }
  11998. }
  11999. updateMatchingColumn(column->text());
  12000. updateTemperature();
  12001. updateDelay();
  12002. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  12003. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  12004. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  12005. connect(delaySelector,SIGNAL(valueChanged(int)),this,SLOT(updateDelay()));
  12006. setLayout(layout);
  12007. }
  12008. /*:1034*//*1035:*/
  12009. #line 20559 "./typica.w"
  12010. void TranslationConfWidget::updateTemperature()
  12011. {
  12012. updateAttribute("unit",unitSelector->currentText());
  12013. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  12014. if(unitSelector->currentText()=="Fahrenheit")
  12015. {
  12016. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  12017. }
  12018. else
  12019. {
  12020. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  12021. }
  12022. }
  12023. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  12024. {
  12025. updateAttribute("column",column);
  12026. }
  12027. void TranslationConfWidget::updateDelay()
  12028. {
  12029. updateAttribute("delay",QString("%1").arg(delaySelector->value()));
  12030. }
  12031. /*:1035*/
  12032. #line 606 "./typica.w"
  12033. /*873:*/
  12034. #line 24 "./freeannotation.w"
  12035. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  12036. const QModelIndex&index)
  12037. :BasicDeviceConfigurationWidget(model,index)
  12038. {
  12039. QFormLayout*layout= new QFormLayout;
  12040. QLineEdit*labelEdit= new QLineEdit;
  12041. layout->addRow(tr("Label Text:"),labelEdit);
  12042. /*816:*/
  12043. #line 16928 "./typica.w"
  12044. QDomElement referenceElement=
  12045. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12046. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12047. QDomElement node;
  12048. /*:816*/
  12049. #line 32 "./freeannotation.w"
  12050. for(int i= 0;i<configData.size();i++)
  12051. {
  12052. node= configData.at(i).toElement();
  12053. if(node.attribute("name")=="labeltext")
  12054. {
  12055. labelEdit->setText(node.attribute("value"));
  12056. }
  12057. }
  12058. updateLabel(labelEdit->text());
  12059. connect(labelEdit,SIGNAL(textEdited(QString)),
  12060. this,SLOT(updateLabel(QString)));
  12061. setLayout(layout);
  12062. }
  12063. /*:873*//*874:*/
  12064. #line 49 "./freeannotation.w"
  12065. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  12066. {
  12067. updateAttribute("labeltext",text);
  12068. }
  12069. /*:874*/
  12070. #line 607 "./typica.w"
  12071. /*1038:*/
  12072. #line 39 "./rate.w"
  12073. void RateOfChange::newMeasurement(Measurement measure)
  12074. {
  12075. cache.append(measure);
  12076. /*1039:*/
  12077. #line 64 "./rate.w"
  12078. if(cache.size()> 2)
  12079. {
  12080. bool done= false;
  12081. while(!done)
  12082. {
  12083. if(cache.front().time().secsTo(cache.back().time())> ct)
  12084. {
  12085. cache.removeFirst();
  12086. }
  12087. else if(cache.back().time()<cache.front().time())
  12088. {
  12089. cache.removeFirst();
  12090. done= true;
  12091. }
  12092. else
  12093. {
  12094. done= true;
  12095. }
  12096. if(cache.size()<3)
  12097. {
  12098. done= true;
  12099. }
  12100. }
  12101. }
  12102. /*:1039*/
  12103. #line 43 "./rate.w"
  12104. if(cache.size()>=2)
  12105. {
  12106. /*1040:*/
  12107. #line 96 "./rate.w"
  12108. int N= cache.size();
  12109. double SXY= 0;
  12110. double SX= 0;
  12111. double SXX= 0;
  12112. double SY= 0;
  12113. double y;
  12114. double x;
  12115. for(int i= 0;i<N;i++)
  12116. {
  12117. y= cache.at(i).temperature();
  12118. SY+= y;
  12119. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  12120. SX+= x;
  12121. SXX+= (x*x);
  12122. SXY+= (x*y);
  12123. }
  12124. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  12125. Measurement value(M*st,cache.back().time(),cache.back().scale());
  12126. value.insert("relative",true);
  12127. emit newData(value);
  12128. /*:1040*/
  12129. #line 46 "./rate.w"
  12130. }
  12131. }
  12132. /*:1038*//*1041:*/
  12133. #line 120 "./rate.w"
  12134. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  12135. {
  12136. setScaleTime(scaletime);
  12137. }
  12138. void RateOfChange::setCacheTime(int seconds)
  12139. {
  12140. ct= seconds;
  12141. }
  12142. void RateOfChange::setScaleTime(int seconds)
  12143. {
  12144. st= (seconds> 0?seconds:1);
  12145. }
  12146. /*:1041*/
  12147. #line 608 "./typica.w"
  12148. /*877:*/
  12149. #line 26 "./settings.w"
  12150. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  12151. {
  12152. QTabWidget*settingsTab= new QTabWidget;
  12153. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  12154. settingsTab->addTab(deviceSettings,tr("Roasters"));
  12155. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  12156. settingsTab->addTab(graphSettings,tr("Graph"));
  12157. ColorSettingsWidget*colorSettings= new ColorSettingsWidget;
  12158. settingsTab->addTab(colorSettings,tr("Color"));
  12159. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  12160. settingsTab->addTab(advancedSettings,tr("Advanced"));
  12161. setCentralWidget(settingsTab);
  12162. }
  12163. /*:877*/
  12164. #line 609 "./typica.w"
  12165. /*882:*/
  12166. #line 27 "./graphsettings.w"
  12167. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  12168. {
  12169. QTabWidget*graphCategories= new QTabWidget;
  12170. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  12171. graphCategories->addTab(relative,tr("Relative Temperatures"));
  12172. QVBoxLayout*layout= new QVBoxLayout;
  12173. layout->addWidget(graphCategories);
  12174. setLayout(layout);
  12175. }
  12176. /*:882*//*884:*/
  12177. #line 69 "./graphsettings.w"
  12178. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  12179. colorEdit(new QLineEdit)
  12180. {
  12181. QSettings settings;
  12182. QVBoxLayout*layout= new QVBoxLayout;
  12183. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  12184. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  12185. updateEnableSetting(enable->isChecked());
  12186. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  12187. layout->addWidget(enable);
  12188. QHBoxLayout*colorLayout= new QHBoxLayout;
  12189. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  12190. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  12191. updateColorSetting(colorEdit->text());
  12192. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  12193. QToolButton*colorPickerButton= new QToolButton();
  12194. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  12195. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  12196. colorLayout->addWidget(colorLabel);
  12197. colorLayout->addWidget(colorEdit);
  12198. colorLayout->addWidget(colorPickerButton);
  12199. colorLayout->addStretch();
  12200. layout->addLayout(colorLayout);
  12201. QHBoxLayout*unitLayout= new QHBoxLayout;
  12202. QLabel*unitLabel= new QLabel(tr("Unit"));
  12203. QComboBox*unitSelector= new QComboBox;
  12204. unitSelector->addItem(tr("Fahrenheit"));
  12205. unitSelector->addItem(tr("Celsius"));
  12206. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  12207. updateUnit(unitSelector->currentIndex());
  12208. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12209. unitLayout->addWidget(unitLabel);
  12210. unitLayout->addWidget(unitSelector);
  12211. unitLayout->addStretch();
  12212. layout->addLayout(unitLayout);
  12213. QHBoxLayout*axisLayout= new QHBoxLayout;
  12214. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  12215. QLineEdit*axisEdit= new QLineEdit;
  12216. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, 0, 30, 65, 100").toString());
  12217. updateAxisSetting(axisEdit->text());
  12218. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  12219. axisLayout->addWidget(axisLabel);
  12220. axisLayout->addWidget(axisEdit);
  12221. layout->addLayout(axisLayout);
  12222. layout->addStretch();
  12223. setLayout(layout);
  12224. }
  12225. /*:884*//*885:*/
  12226. #line 120 "./graphsettings.w"
  12227. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  12228. {
  12229. QSettings settings;
  12230. settings.setValue("settings/graph/relative/enable",enabled);
  12231. }
  12232. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  12233. {
  12234. QSettings settings;
  12235. settings.setValue("settings/graph/relative/color",color);
  12236. }
  12237. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  12238. {
  12239. QSettings settings;
  12240. QString settingValue;
  12241. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  12242. QStringList numbers;
  12243. foreach(QString text,points)
  12244. {
  12245. bool okay= false;
  12246. text.toDouble(&okay);
  12247. if(okay)
  12248. {
  12249. numbers.append(text);
  12250. }
  12251. }
  12252. numbers.removeDuplicates();
  12253. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  12254. }
  12255. void GraphSettingsRelativeTab::updateUnit(int unit)
  12256. {
  12257. QSettings settings;
  12258. settings.setValue("settings/graph/relative/unit",unit);
  12259. }
  12260. /*:885*//*886:*/
  12261. #line 163 "./graphsettings.w"
  12262. void GraphSettingsRelativeTab::showColorPicker()
  12263. {
  12264. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  12265. colorEdit->setText(color.name());
  12266. }
  12267. #line 64 "./settings.w"
  12268. #line 1 "./colorsettings.w"
  12269. /*:886*/
  12270. #line 610 "./typica.w"
  12271. /*1087:*/
  12272. #line 682 "./dataqsdk.w"
  12273. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  12274. const QModelIndex&index)
  12275. :BasicDeviceConfigurationWidget(model,index),
  12276. deviceIdStack(new QStackedWidget)
  12277. {
  12278. QVBoxLayout*layout= new QVBoxLayout;
  12279. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  12280. layout->addWidget(autoDetect);
  12281. QWidget*autoLayerWidget= new QWidget;
  12282. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  12283. QLabel*autoLabel= new QLabel(tr("Device number"));
  12284. QSpinBox*autoNumber= new QSpinBox;
  12285. autoNumber->setMinimum(1);
  12286. autoNumber->setMaximum(99);
  12287. autoLayerLayout->addWidget(autoLabel);
  12288. autoLayerLayout->addWidget(autoNumber);
  12289. autoLayerWidget->setLayout(autoLayerLayout);
  12290. QWidget*fixedLayerWidget= new QWidget;
  12291. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  12292. QLabel*fixedLabel= new QLabel(tr("Device port"));
  12293. QComboBox*portSelection= new QComboBox;
  12294. portSelection->setEditable(true);
  12295. portSelection->addItems(DataqSdkDevice::detectHardware());
  12296. fixedLayerLayout->addWidget(fixedLabel);
  12297. fixedLayerLayout->addWidget(portSelection);
  12298. fixedLayerWidget->setLayout(fixedLayerLayout);
  12299. deviceIdStack->addWidget(autoLayerWidget);
  12300. deviceIdStack->addWidget(fixedLayerWidget);
  12301. layout->addWidget(deviceIdStack);
  12302. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12303. layout->addWidget(addChannelButton);
  12304. /*816:*/
  12305. #line 16928 "./typica.w"
  12306. QDomElement referenceElement=
  12307. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12308. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12309. QDomElement node;
  12310. /*:816*/
  12311. #line 714 "./dataqsdk.w"
  12312. for(int i= 0;i<configData.size();i++)
  12313. {
  12314. node= configData.at(i).toElement();
  12315. if(node.attribute("name")=="autoSelect")
  12316. {
  12317. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  12318. }
  12319. else if(node.attribute("name")=="deviceNumber")
  12320. {
  12321. autoNumber->setValue(node.attribute("value").toInt());
  12322. }
  12323. else if(node.attribute("name")=="port")
  12324. {
  12325. int index= portSelection->findText(node.attribute("value"));
  12326. if(index> -1)
  12327. {
  12328. portSelection->setCurrentIndex(index);
  12329. }
  12330. else
  12331. {
  12332. portSelection->setEditText(node.attribute("value"));
  12333. }
  12334. }
  12335. }
  12336. updateAutoSelect(autoDetect->isChecked());
  12337. updateDeviceNumber(autoNumber->value());
  12338. updatePort(portSelection->currentText());
  12339. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  12340. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  12341. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12342. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12343. setLayout(layout);
  12344. }
  12345. /*:1087*//*1088:*/
  12346. #line 758 "./dataqsdk.w"
  12347. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  12348. {
  12349. if(automatic)
  12350. {
  12351. updateAttribute("autoSelect","true");
  12352. deviceIdStack->setCurrentIndex(0);
  12353. }
  12354. else
  12355. {
  12356. updateAttribute("autoSelect","false");
  12357. deviceIdStack->setCurrentIndex(1);
  12358. }
  12359. }
  12360. /*:1088*//*1089:*/
  12361. #line 775 "./dataqsdk.w"
  12362. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  12363. {
  12364. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  12365. }
  12366. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  12367. {
  12368. updateAttribute("port",portId);
  12369. }
  12370. /*:1089*//*1090:*/
  12371. #line 788 "./dataqsdk.w"
  12372. void DataqSdkDeviceConfWidget::addChannel()
  12373. {
  12374. insertChildNode(tr("Channel"),"dataqsdkchannel");
  12375. }
  12376. /*:1090*//*1093:*/
  12377. #line 868 "./dataqsdk.w"
  12378. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  12379. const QModelIndex&index)
  12380. :BasicDeviceConfigurationWidget(model,index),
  12381. startButton(new QPushButton(tr("Start"))),
  12382. resetButton(new QPushButton(tr("Reset"))),
  12383. stopButton(new QPushButton(tr("Stop"))),
  12384. calibrator(new LinearCalibrator),
  12385. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  12386. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  12387. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  12388. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  12389. rmCount(0),cmCount(0),
  12390. rmin(std::numeric_limits<double> ::max()),
  12391. rmax(std::numeric_limits<double> ::min()),rmean(0),
  12392. cmin(std::numeric_limits<double> ::max()),
  12393. cmax(std::numeric_limits<double> ::min()),cmean(0)
  12394. {
  12395. /*1097:*/
  12396. #line 1107 "./dataqsdk.w"
  12397. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  12398. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  12399. QDomElement deviceNode;
  12400. QString configPort;
  12401. QString configAuto;
  12402. for(int i= 0;i<deviceConfigData.size();i++)
  12403. {
  12404. deviceNode= deviceConfigData.at(i).toElement();
  12405. if(deviceNode.attribute("name")=="autoSelect")
  12406. {
  12407. autoSelect= (deviceNode.attribute("value")=="true");
  12408. }
  12409. else if(deviceNode.attribute("name")=="deviceNumber")
  12410. {
  12411. configAuto= deviceNode.attribute("value");
  12412. }
  12413. else if(deviceNode.attribute("name")=="port")
  12414. {
  12415. configPort= deviceNode.attribute("value");
  12416. }
  12417. }
  12418. deviceID= autoSelect?configAuto:configPort;
  12419. channelOfInterest= index.row();
  12420. /*:1097*/
  12421. #line 886 "./dataqsdk.w"
  12422. resetButton->setEnabled(false);
  12423. stopButton->setEnabled(false);
  12424. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  12425. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  12426. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  12427. QVBoxLayout*layout= new QVBoxLayout;
  12428. QFormLayout*topLayout= new QFormLayout;
  12429. QLineEdit*columnEdit= new QLineEdit;
  12430. topLayout->addRow(tr("Column name"),columnEdit);
  12431. QComboBox*unitSelector= new QComboBox;
  12432. unitSelector->addItem(tr("Temperature"));
  12433. unitSelector->addItem(tr("Control"));
  12434. topLayout->addRow(tr("Measurement type"),unitSelector);
  12435. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  12436. topLayout->addRow(smoothingBox);
  12437. layout->addLayout(topLayout);
  12438. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  12439. topLayout->addRow(hideSeries);
  12440. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  12441. layout->addWidget(calibrationLabel);
  12442. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  12443. QFormLayout*calibrationControlsLayout= new QFormLayout;
  12444. QLineEdit*measuredLowerEdit= new QLineEdit;
  12445. measuredLowerEdit->setText("0");
  12446. QLineEdit*measuredUpperEdit= new QLineEdit;
  12447. measuredUpperEdit->setText("10");
  12448. QLineEdit*mappedLowerEdit= new QLineEdit;
  12449. mappedLowerEdit->setText("0");
  12450. QLineEdit*mappedUpperEdit= new QLineEdit;
  12451. mappedUpperEdit->setText("10");
  12452. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  12453. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  12454. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  12455. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  12456. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  12457. calibrationControlsLayout->addRow(closedBox);
  12458. QLineEdit*sensitivityEdit= new QLineEdit;
  12459. sensitivityEdit->setText("0");
  12460. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  12461. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  12462. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  12463. deviceControlLayout->addWidget(startButton);
  12464. deviceControlLayout->addWidget(resetButton);
  12465. deviceControlLayout->addWidget(stopButton);
  12466. QFormLayout*indicatorLayout= new QFormLayout;
  12467. currentMeasurement->setReadOnly(true);
  12468. minimumMeasurement->setReadOnly(true);
  12469. maximumMeasurement->setReadOnly(true);
  12470. averageMeasurement->setReadOnly(true);
  12471. currentMapped->setReadOnly(true);
  12472. minimumMapped->setReadOnly(true);
  12473. maximumMapped->setReadOnly(true);
  12474. averageMapped->setReadOnly(true);
  12475. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  12476. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  12477. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  12478. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  12479. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  12480. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  12481. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  12482. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  12483. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  12484. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  12485. calibrationTestLayout->addLayout(deviceControlLayout);
  12486. calibrationTestLayout->addLayout(indicatorLayout);
  12487. calibrationLayout->addLayout(calibrationControlsLayout);
  12488. calibrationLayout->addLayout(calibrationTestLayout);
  12489. layout->addLayout(calibrationLayout);
  12490. /*816:*/
  12491. #line 16928 "./typica.w"
  12492. QDomElement referenceElement=
  12493. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12494. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12495. QDomElement node;
  12496. /*:816*/
  12497. #line 955 "./dataqsdk.w"
  12498. for(int i= 0;i<configData.size();i++)
  12499. {
  12500. node= configData.at(i).toElement();
  12501. if(node.attribute("name")=="column")
  12502. {
  12503. columnEdit->setText(node.attribute("value"));
  12504. }
  12505. else if(node.attribute("name")=="type")
  12506. {
  12507. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  12508. }
  12509. else if(node.attribute("name")=="smoothing")
  12510. {
  12511. smoothingBox->setChecked(node.attribute("value")=="true");
  12512. }
  12513. else if(node.attribute("name")=="calibrationMeasuredLower")
  12514. {
  12515. measuredLowerEdit->setText(node.attribute("value"));
  12516. }
  12517. else if(node.attribute("name")=="calibrationMeasuredUpper")
  12518. {
  12519. measuredUpperEdit->setText(node.attribute("value"));
  12520. }
  12521. else if(node.attribute("name")=="calibrationMappedLower")
  12522. {
  12523. mappedLowerEdit->setText(node.attribute("value"));
  12524. }
  12525. else if(node.attribute("name")=="calibrationMappedUpper")
  12526. {
  12527. mappedUpperEdit->setText(node.attribute("value"));
  12528. }
  12529. else if(node.attribute("name")=="calibrationClosedInterval")
  12530. {
  12531. closedBox->setChecked(node.attribute("value")=="true");
  12532. }
  12533. else if(node.attribute("name")=="calibrationSensitivity")
  12534. {
  12535. sensitivityEdit->setText(node.attribute("value"));
  12536. }
  12537. else if(node.attribute("name")=="hidden")
  12538. {
  12539. hideSeries->setChecked(node.attribute("value")=="true");
  12540. }
  12541. }
  12542. updateColumnName(columnEdit->text());
  12543. updateUnits(unitSelector->currentText());
  12544. updateSmoothingEnabled(smoothingBox->isChecked());
  12545. updateMeasuredLower(measuredLowerEdit->text());
  12546. updateMeasuredUpper(measuredUpperEdit->text());
  12547. updateMappedLower(mappedLowerEdit->text());
  12548. updateMappedUpper(mappedUpperEdit->text());
  12549. updateClosedInterval(closedBox->isChecked());
  12550. updateSensitivity(sensitivityEdit->text());
  12551. updateHidden(hideSeries->isChecked());
  12552. connect(columnEdit,SIGNAL(textChanged(QString)),
  12553. this,SLOT(updateColumnName(QString)));
  12554. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  12555. this,SLOT(updateUnits(QString)));
  12556. connect(smoothingBox,SIGNAL(toggled(bool)),
  12557. this,SLOT(updateSmoothingEnabled(bool)));
  12558. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  12559. this,SLOT(updateMeasuredLower(QString)));
  12560. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  12561. this,SLOT(updateMappedLower(QString)));
  12562. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  12563. this,SLOT(updateMeasuredUpper(QString)));
  12564. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  12565. this,SLOT(updateMappedUpper(QString)));
  12566. connect(closedBox,SIGNAL(toggled(bool)),
  12567. this,SLOT(updateClosedInterval(bool)));
  12568. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  12569. this,SLOT(updateSensitivity(QString)));
  12570. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12571. setLayout(layout);
  12572. }
  12573. /*:1093*//*1094:*/
  12574. #line 1038 "./dataqsdk.w"
  12575. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  12576. {
  12577. updateAttribute("type",unit);
  12578. }
  12579. /*:1094*//*1095:*/
  12580. #line 1047 "./dataqsdk.w"
  12581. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  12582. {
  12583. updateAttribute("calibrationMeasuredLower",value);
  12584. calibrator->setMeasuredLower(value.toDouble());
  12585. }
  12586. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  12587. {
  12588. updateAttribute("calibrationMeasuredUpper",value);
  12589. calibrator->setMeasuredUpper(value.toDouble());
  12590. }
  12591. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  12592. {
  12593. updateAttribute("calibrationMappedLower",value);
  12594. calibrator->setMappedLower(value.toDouble());
  12595. }
  12596. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  12597. {
  12598. updateAttribute("calibrationMappedUpper",value);
  12599. calibrator->setMappedUpper(value.toDouble());
  12600. }
  12601. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  12602. {
  12603. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  12604. calibrator->setClosedRange(closed);
  12605. }
  12606. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  12607. {
  12608. updateAttribute("smoothing",enabled?"true":"false");
  12609. }
  12610. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  12611. {
  12612. updateAttribute("calibrationSensitivity",value);
  12613. calibrator->setSensitivity(value.toDouble());
  12614. }
  12615. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  12616. {
  12617. updateAttribute("hidden",hidden?"true":"false");
  12618. }
  12619. /*:1095*//*1098:*/
  12620. #line 1136 "./dataqsdk.w"
  12621. void DataqSdkChannelConfWidget::startCalibration()
  12622. {
  12623. startButton->setEnabled(false);
  12624. stopButton->setEnabled(true);
  12625. resetButton->setEnabled(true);
  12626. calibrationDevice= new DataqSdkDevice(deviceID);
  12627. Channel*channel;
  12628. for(unsigned int i= 0;i<=channelOfInterest;i++)
  12629. {
  12630. channel= calibrationDevice->newChannel(Units::Unitless);
  12631. }
  12632. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  12633. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  12634. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  12635. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  12636. calibrationDevice->start();
  12637. }
  12638. void DataqSdkChannelConfWidget::stopCalibration()
  12639. {
  12640. startButton->setEnabled(true);
  12641. stopButton->setEnabled(false);
  12642. resetButton->setEnabled(false);
  12643. calibrationDevice->deleteLater();
  12644. /*1100:*/
  12645. #line 1181 "./dataqsdk.w"
  12646. rmCount= 0;
  12647. cmCount= 0;
  12648. rmin= std::numeric_limits<double> ::max();
  12649. rmax= std::numeric_limits<double> ::min();
  12650. rmean= 0;
  12651. cmin= std::numeric_limits<double> ::max();
  12652. cmax= std::numeric_limits<double> ::min();
  12653. cmean= 0;
  12654. /*:1100*/
  12655. #line 1161 "./dataqsdk.w"
  12656. }
  12657. /*:1098*//*1099:*/
  12658. #line 1172 "./dataqsdk.w"
  12659. void DataqSdkChannelConfWidget::resetCalibration()
  12660. {
  12661. /*1100:*/
  12662. #line 1181 "./dataqsdk.w"
  12663. rmCount= 0;
  12664. cmCount= 0;
  12665. rmin= std::numeric_limits<double> ::max();
  12666. rmax= std::numeric_limits<double> ::min();
  12667. rmean= 0;
  12668. cmin= std::numeric_limits<double> ::max();
  12669. cmax= std::numeric_limits<double> ::min();
  12670. cmean= 0;
  12671. /*:1100*/
  12672. #line 1175 "./dataqsdk.w"
  12673. }
  12674. /*:1099*//*1101:*/
  12675. #line 1195 "./dataqsdk.w"
  12676. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  12677. {
  12678. double nv= measure.temperature();
  12679. currentMeasurement->setText(QString("%1").arg(nv));
  12680. rmin= qMin(nv,rmin);
  12681. minimumMeasurement->setText(QString("%1").arg(rmin));
  12682. rmax= qMax(nv,rmax);
  12683. maximumMeasurement->setText(QString("%1").arg(rmax));
  12684. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  12685. rmCount++;
  12686. averageMeasurement->setText(QString("%1").arg(rmean));
  12687. }
  12688. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  12689. {
  12690. double nv= measure.temperature();
  12691. currentMapped->setText(QString("%1").arg(nv));
  12692. cmin= qMin(nv,cmin);
  12693. minimumMapped->setText(QString("%1").arg(cmin));
  12694. cmax= qMax(nv,cmax);
  12695. maximumMapped->setText(QString("%1").arg(cmax));
  12696. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  12697. cmCount++;
  12698. averageMapped->setText(QString("%1").arg(cmean));
  12699. }
  12700. /*:1101*//*1102:*/
  12701. #line 1224 "./dataqsdk.w"
  12702. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  12703. {
  12704. updateAttribute("column",value);
  12705. }
  12706. /*:1102*/
  12707. #line 611 "./typica.w"
  12708. /*1126:*/
  12709. #line 423 "./scales.w"
  12710. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  12711. const QModelIndex&index)
  12712. :BasicDeviceConfigurationWidget(model,index),
  12713. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  12714. flow(new FlowSelector),stop(new StopSelector),
  12715. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  12716. {
  12717. QFormLayout*layout= new QFormLayout;
  12718. layout->addRow(tr("Port:"),port);
  12719. connect(port,SIGNAL(currentIndexChanged(QString)),
  12720. this,SLOT(updatePort(QString)));
  12721. connect(port,SIGNAL(editTextChanged(QString)),
  12722. this,SLOT(updatePort(QString)));
  12723. layout->addRow(tr("Baud:"),baud);
  12724. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12725. this,SLOT(updateBaudRate(QString)));
  12726. layout->addRow(tr("Parity:"),parity);
  12727. connect(parity,SIGNAL(currentIndexChanged(int)),
  12728. this,SLOT(updateParity(int)));
  12729. layout->addRow(tr("Flow Control:"),flow);
  12730. connect(flow,SIGNAL(currentIndexChanged(int)),
  12731. this,SLOT(updateFlowControl(int)));
  12732. layout->addRow(tr("Stop Bits:"),stop);
  12733. connect(stop,SIGNAL(currentIndexChanged(int)),
  12734. this,SLOT(updateStopBits(int)));
  12735. layout->addRow(tr("Weigh Command:"),weighcommand);
  12736. connect(weighcommand,SIGNAL(textChanged(QString)),
  12737. this,SLOT(updateWeighCommand(QString)));
  12738. commandterminator->addItem("CRLF");
  12739. commandterminator->addItem("CR");
  12740. commandterminator->addItem("LF");
  12741. layout->addRow(tr("Command Terminator:"),commandterminator);
  12742. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12743. this,SLOT(updateCommandTerminator(QString)));
  12744. /*816:*/
  12745. #line 16928 "./typica.w"
  12746. QDomElement referenceElement=
  12747. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12748. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12749. QDomElement node;
  12750. /*:816*/
  12751. #line 459 "./scales.w"
  12752. for(int i= 0;i<configData.size();i++)
  12753. {
  12754. node= configData.at(i).toElement();
  12755. if(node.attribute("name")=="port")
  12756. {
  12757. int j= port->findText(node.attribute("value"));
  12758. if(j>=0)
  12759. {
  12760. port->setCurrentIndex(j);
  12761. }
  12762. else
  12763. {
  12764. port->insertItem(0,node.attribute("value"));
  12765. port->setCurrentIndex(0);
  12766. }
  12767. }
  12768. else if(node.attribute("name")=="baudrate")
  12769. {
  12770. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12771. }
  12772. else if(node.attribute("name")=="parity")
  12773. {
  12774. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12775. }
  12776. else if(node.attribute("name")=="flowcontrol")
  12777. {
  12778. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12779. }
  12780. else if(node.attribute("name")=="stopbits")
  12781. {
  12782. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12783. }
  12784. else if(node.attribute("name")=="weighcommand")
  12785. {
  12786. weighcommand->setText(node.attribute("value"));
  12787. }
  12788. else if(node.attribute("name")=="commandterminator")
  12789. {
  12790. commandterminator->setCurrentIndex(
  12791. commandterminator->findText(node.attribute("value")));
  12792. }
  12793. }
  12794. updatePort(port->currentText());
  12795. updateBaudRate(baud->currentText());
  12796. updateParity(parity->currentIndex());
  12797. updateFlowControl(flow->currentIndex());
  12798. updateStopBits(stop->currentIndex());
  12799. updateWeighCommand(weighcommand->text());
  12800. updateCommandTerminator(commandterminator->currentText());
  12801. setLayout(layout);
  12802. }
  12803. /*:1126*//*1127:*/
  12804. #line 514 "./scales.w"
  12805. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12806. {
  12807. updateAttribute("port",newPort);
  12808. }
  12809. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12810. {
  12811. updateAttribute("baudrate",rate);
  12812. }
  12813. void SerialScaleConfWidget::updateParity(int index)
  12814. {
  12815. updateAttribute("parity",parity->itemData(index).toString());
  12816. }
  12817. void SerialScaleConfWidget::updateFlowControl(int index)
  12818. {
  12819. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12820. }
  12821. void SerialScaleConfWidget::updateStopBits(int index)
  12822. {
  12823. updateAttribute("stopbits",stop->itemData(index).toString());
  12824. }
  12825. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12826. {
  12827. updateAttribute("weighcommand",command);
  12828. }
  12829. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12830. {
  12831. updateAttribute("commandterminator",terminator);
  12832. }
  12833. /*:1127*/
  12834. #line 612 "./typica.w"
  12835. /*1139:*/
  12836. #line 195 "./valueannotation.w"
  12837. void ValueAnnotation::newMeasurement(Measurement measure)
  12838. {
  12839. for(int i= 0;i<values.size();i++)
  12840. {
  12841. if(measure.temperature()> values.at(i)-tolerance&&
  12842. measure.temperature()<values.at(i)+tolerance)
  12843. {
  12844. if(i!=lastIndex)
  12845. {
  12846. lastIndex= i;
  12847. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12848. }
  12849. }
  12850. }
  12851. }
  12852. /*:1139*//*1140:*/
  12853. #line 216 "./valueannotation.w"
  12854. void ValueAnnotation::annotate()
  12855. {
  12856. if(lastIndex> -1)
  12857. {
  12858. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12859. }
  12860. }
  12861. /*:1140*//*1141:*/
  12862. #line 228 "./valueannotation.w"
  12863. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12864. {
  12865. values.append(value);
  12866. annotations.append(annotation);
  12867. }
  12868. /*:1141*//*1142:*/
  12869. #line 237 "./valueannotation.w"
  12870. void ValueAnnotation::setAnnotationColumn(int column)
  12871. {
  12872. annotationColumn= column;
  12873. }
  12874. void ValueAnnotation::setTemperatureColumn(int column)
  12875. {
  12876. measurementColumn= column;
  12877. }
  12878. void ValueAnnotation::setTolerance(double epsilon)
  12879. {
  12880. tolerance= epsilon;
  12881. }
  12882. /*:1142*//*1143:*/
  12883. #line 255 "./valueannotation.w"
  12884. ValueAnnotation::ValueAnnotation():QObject(),
  12885. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12886. {
  12887. }
  12888. /*:1143*/
  12889. #line 613 "./typica.w"
  12890. /*1131:*/
  12891. #line 33 "./valueannotation.w"
  12892. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12893. const QModelIndex&index)
  12894. :BasicDeviceConfigurationWidget(model,index),
  12895. tablemodel(new SaltModel(2))
  12896. {
  12897. QFormLayout*layout= new QFormLayout;
  12898. QLineEdit*source= new QLineEdit;
  12899. layout->addRow(tr("Source column name:"),source);
  12900. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12901. noteOnStart->setChecked(true);
  12902. layout->addRow(noteOnStart);
  12903. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12904. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12905. QTableView*annotationTable= new QTableView;
  12906. annotationTable->setModel(tablemodel);
  12907. NumericDelegate*delegate= new NumericDelegate;
  12908. annotationTable->setItemDelegateForColumn(0,delegate);
  12909. layout->addRow(tr("Annotations for values:"),annotationTable);
  12910. /*816:*/
  12911. #line 16928 "./typica.w"
  12912. QDomElement referenceElement=
  12913. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12914. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12915. QDomElement node;
  12916. /*:816*/
  12917. #line 52 "./valueannotation.w"
  12918. for(int i= 0;i<configData.size();i++)
  12919. {
  12920. node= configData.at(i).toElement();
  12921. if(node.attribute("name")=="source")
  12922. {
  12923. source->setText(node.attribute("value"));
  12924. }
  12925. else if(node.attribute("name")=="emitOnStart")
  12926. {
  12927. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12928. }
  12929. else if(node.attribute("name")=="measuredValues")
  12930. {
  12931. /*1015:*/
  12932. #line 20014 "./typica.w"
  12933. QString data= node.attribute("value");
  12934. if(data.length()> 3)
  12935. {
  12936. data.chop(2);
  12937. data= data.remove(0,2);
  12938. }
  12939. QStringList itemList= data.split(",");
  12940. /*:1015*/
  12941. #line 66 "./valueannotation.w"
  12942. int column= 0;
  12943. /*1016:*/
  12944. #line 20026 "./typica.w"
  12945. for(int j= 0;j<itemList.size();j++)
  12946. {
  12947. tablemodel->setData(tablemodel->index(j,column),
  12948. QVariant(itemList.at(j).toDouble()),
  12949. Qt::DisplayRole);
  12950. }
  12951. /*:1016*/
  12952. #line 68 "./valueannotation.w"
  12953. }
  12954. else if(node.attribute("name")=="annotations")
  12955. {
  12956. /*1132:*/
  12957. #line 89 "./valueannotation.w"
  12958. QString data= node.attribute("value");
  12959. if(data.length()> 3)
  12960. {
  12961. data.chop(2);
  12962. data= data.remove(0,2);
  12963. }
  12964. QStringList itemList= data.split(",");
  12965. for(int i= 0;i<itemList.size();i++)
  12966. {
  12967. itemList[i]= itemList[i].simplified();
  12968. }
  12969. /*:1132*/
  12970. #line 72 "./valueannotation.w"
  12971. int column= 1;
  12972. /*1133:*/
  12973. #line 104 "./valueannotation.w"
  12974. for(int i= 0;i<itemList.size();i++)
  12975. {
  12976. tablemodel->setData(tablemodel->index(i,column),
  12977. QVariant(itemList.at(i)),
  12978. Qt::DisplayRole);
  12979. }
  12980. /*:1133*/
  12981. #line 74 "./valueannotation.w"
  12982. }
  12983. }
  12984. updateSourceColumn(source->text());
  12985. updateStart(noteOnStart->isChecked());
  12986. updateAnnotations();
  12987. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12988. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12989. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12990. setLayout(layout);
  12991. }
  12992. /*:1131*//*1134:*/
  12993. #line 115 "./valueannotation.w"
  12994. void ValueAnnotationConfWidget::updateAnnotations()
  12995. {
  12996. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12997. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12998. }
  12999. /*:1134*//*1135:*/
  13000. #line 125 "./valueannotation.w"
  13001. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  13002. {
  13003. updateAttribute("source",source);
  13004. }
  13005. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  13006. {
  13007. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  13008. }
  13009. /*:1135*/
  13010. #line 614 "./typica.w"
  13011. /*916:*/
  13012. #line 44 "./modbus.w"
  13013. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  13014. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  13015. m_flow(new FlowSelector),m_stop(new StopSelector)
  13016. {
  13017. QFormLayout*layout= new QFormLayout;
  13018. PortSelector*port= new PortSelector;
  13019. BaudSelector*baud= new BaudSelector;
  13020. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  13021. layout->addRow(QString(tr("Port:")),port);
  13022. layout->addRow(QString(tr("Baud rate:")),baud);
  13023. layout->addRow(QString(tr("Parity:")),m_parity);
  13024. layout->addRow(QString(tr("Flow control:")),m_flow);
  13025. layout->addRow(QString(tr("Stop bits:")),m_stop);
  13026. layout->addRow(newInput);
  13027. /*816:*/
  13028. #line 16928 "./typica.w"
  13029. QDomElement referenceElement=
  13030. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13031. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13032. QDomElement node;
  13033. /*:816*/
  13034. #line 60 "./modbus.w"
  13035. for(int i= 0;i<configData.size();i++)
  13036. {
  13037. node= configData.at(i).toElement();
  13038. if(node.attribute("name")=="port")
  13039. {
  13040. int idx= port->findText(node.attribute("value"));
  13041. if(idx>=0)
  13042. {
  13043. port->setCurrentIndex(idx);
  13044. }
  13045. else
  13046. {
  13047. port->addItem(node.attribute("value"));
  13048. }
  13049. }
  13050. else if(node.attribute("name")=="baud")
  13051. {
  13052. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  13053. }
  13054. else if(node.attribute("name")=="parity")
  13055. {
  13056. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  13057. }
  13058. else if(node.attribute("name")=="flow")
  13059. {
  13060. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  13061. }
  13062. else if(node.attribute("name")=="stop")
  13063. {
  13064. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  13065. }
  13066. }
  13067. updatePort(port->currentText());
  13068. updateBaudRate(baud->currentText());
  13069. updateParity(m_parity->currentIndex());
  13070. updateFlowControl(m_flow->currentIndex());
  13071. updateStopBits(m_stop->currentIndex());
  13072. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  13073. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  13074. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  13075. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  13076. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  13077. this,SLOT(updateFlowControl(int)));
  13078. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  13079. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  13080. setLayout(layout);
  13081. }
  13082. void ModbusNGConfWidget::updatePort(const QString&value)
  13083. {
  13084. updateAttribute("port",value);
  13085. }
  13086. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  13087. {
  13088. updateAttribute("baud",value);
  13089. }
  13090. void ModbusNGConfWidget::updateParity(int value)
  13091. {
  13092. updateAttribute("parity",m_parity->itemData(value).toString());
  13093. }
  13094. void ModbusNGConfWidget::updateFlowControl(int value)
  13095. {
  13096. updateAttribute("flow",m_flow->itemData(value).toString());
  13097. }
  13098. void ModbusNGConfWidget::updateStopBits(int value)
  13099. {
  13100. updateAttribute("stop",m_stop->itemData(value).toString());
  13101. }
  13102. void ModbusNGConfWidget::addInput()
  13103. {
  13104. insertChildNode(tr("Input"),"modbusnginput");
  13105. }
  13106. /*:916*//*918:*/
  13107. #line 164 "./modbus.w"
  13108. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  13109. {
  13110. QFormLayout*layout= new QFormLayout;
  13111. QSpinBox*station= new QSpinBox;
  13112. station->setMinimum(1);
  13113. station->setMaximum(247);
  13114. layout->addRow(tr("Station ID"),station);
  13115. QComboBox*function= new QComboBox;
  13116. function->addItem("3","3");
  13117. function->addItem("4","4");
  13118. function->setCurrentIndex(1);
  13119. layout->addRow(tr("Function"),function);
  13120. ShortHexSpinBox*address= new ShortHexSpinBox;
  13121. layout->addRow(tr("Address"),address);
  13122. QComboBox*format= new QComboBox;
  13123. format->addItem(tr("16 bits fixed point"),"16fixedint");
  13124. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  13125. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  13126. layout->addRow(tr("Data format"),format);
  13127. QSpinBox*decimals= new QSpinBox;
  13128. decimals->setMinimum(0);
  13129. decimals->setMaximum(9);
  13130. layout->addRow(tr("Decimal places"),decimals);
  13131. QComboBox*unit= new QComboBox;
  13132. unit->addItem("Celsius","C");
  13133. unit->addItem("Fahrenheit","F");
  13134. unit->addItem("Control","Control");
  13135. unit->setCurrentIndex(1);
  13136. layout->addRow(tr("Unit"),unit);
  13137. QLineEdit*column= new QLineEdit;
  13138. layout->addRow(tr("Column name"),column);
  13139. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  13140. layout->addRow(hidden);
  13141. /*816:*/
  13142. #line 16928 "./typica.w"
  13143. QDomElement referenceElement=
  13144. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13145. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13146. QDomElement node;
  13147. /*:816*/
  13148. #line 199 "./modbus.w"
  13149. for(int i= 0;i<configData.size();i++)
  13150. {
  13151. node= configData.at(i).toElement();
  13152. if(node.attribute("name")=="station")
  13153. {
  13154. station->setValue(node.attribute("value").toInt());
  13155. }
  13156. else if(node.attribute("name")=="function")
  13157. {
  13158. function->setCurrentIndex(function->findText(node.attribute("value")));
  13159. }
  13160. else if(node.attribute("name")=="address")
  13161. {
  13162. address->setValue(node.attribute("value").toInt());
  13163. }
  13164. else if(node.attribute("name")=="format")
  13165. {
  13166. format->setCurrentIndex(format->findData(node.attribute("value")));
  13167. }
  13168. else if(node.attribute("name")=="decimals")
  13169. {
  13170. decimals->setValue(node.attribute("value").toInt());
  13171. }
  13172. else if(node.attribute("name")=="unit")
  13173. {
  13174. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  13175. }
  13176. else if(node.attribute("name")=="column")
  13177. {
  13178. column->setText(node.attribute("value"));
  13179. }
  13180. else if(node.attribute("name")=="hidden")
  13181. {
  13182. hidden->setChecked(node.attribute("value")=="true"?true:false);
  13183. }
  13184. }
  13185. updateStation(station->value());
  13186. updateFunction(function->currentIndex());
  13187. updateAddress(address->value());
  13188. updateFormat(format->currentIndex());
  13189. updateDecimals(decimals->value());
  13190. updateUnit(unit->currentIndex());
  13191. updateColumnName(column->text());
  13192. updateHidden(hidden->isChecked());
  13193. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  13194. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  13195. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  13196. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  13197. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  13198. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  13199. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13200. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13201. setLayout(layout);
  13202. }
  13203. void ModbusNGInputConfWidget::updateStation(int value)
  13204. {
  13205. updateAttribute("station",QString("%1").arg(value));
  13206. }
  13207. void ModbusNGInputConfWidget::updateFunction(int value)
  13208. {
  13209. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  13210. }
  13211. void ModbusNGInputConfWidget::updateAddress(int value)
  13212. {
  13213. updateAttribute("address",QString("%1").arg(value));
  13214. }
  13215. void ModbusNGInputConfWidget::updateFormat(int value)
  13216. {
  13217. switch(value)
  13218. {
  13219. case 0:
  13220. updateAttribute("format","16fixedint");
  13221. break;
  13222. case 1:
  13223. updateAttribute("format","32floathl");
  13224. break;
  13225. case 2:
  13226. updateAttribute("format","32floatlh");
  13227. break;
  13228. }
  13229. }
  13230. void ModbusNGInputConfWidget::updateDecimals(int value)
  13231. {
  13232. updateAttribute("decimals",QString("%1").arg(value));
  13233. }
  13234. void ModbusNGInputConfWidget::updateUnit(int value)
  13235. {
  13236. switch(value)
  13237. {
  13238. case 0:
  13239. updateAttribute("unit","C");
  13240. break;
  13241. case 1:
  13242. updateAttribute("unit","F");
  13243. break;
  13244. case 2:
  13245. updateAttribute("unit","Control");
  13246. break;
  13247. }
  13248. }
  13249. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  13250. {
  13251. updateAttribute("column",value);
  13252. }
  13253. void ModbusNGInputConfWidget::updateHidden(bool value)
  13254. {
  13255. updateAttribute("hidden",value?"true":"false");
  13256. }
  13257. /*:918*//*923:*/
  13258. #line 403 "./modbus.w"
  13259. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  13260. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  13261. rateLimiter(new QTimer),scanPosition(0),waiting(false)
  13262. {
  13263. QDomElement portReferenceElement=
  13264. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13265. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  13266. QDomElement node;
  13267. QVariantMap attributes;
  13268. for(int i= 0;i<portConfigData.size();i++)
  13269. {
  13270. node= portConfigData.at(i).toElement();
  13271. attributes.insert(node.attribute("name"),node.attribute("value"));
  13272. }
  13273. port= new QextSerialPort(attributes.value("port").toString(),
  13274. QextSerialPort::EventDriven);
  13275. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  13276. port->setDataBits(DATA_8);
  13277. port->setParity((ParityType)attributes.value("parity").toInt());
  13278. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  13279. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  13280. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  13281. messageDelayTimer->setSingleShot(true);
  13282. commTimeout->setSingleShot(true);
  13283. rateLimiter->setSingleShot(true);
  13284. rateLimiter->setInterval(0);
  13285. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  13286. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  13287. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  13288. connect(rateLimiter,SIGNAL(timeout()),this,SLOT(rateLimitTimeout()));
  13289. if(!port->open(QIODevice::ReadWrite))
  13290. {
  13291. qDebug()<<"Failed to open serial port";
  13292. }
  13293. for(int i= 0;i<model->rowCount(index);i++)
  13294. {
  13295. QModelIndex channelIndex= model->index(i,0,index);
  13296. QDomElement channelReferenceElement=
  13297. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13298. QDomNodeList channelConfigData=
  13299. channelReferenceElement.elementsByTagName("attribute");
  13300. QDomElement channelNode;
  13301. QVariantMap channelAttributes;
  13302. for(int j= 0;j<channelConfigData.size();j++)
  13303. {
  13304. channelNode= channelConfigData.at(j).toElement();
  13305. channelAttributes.insert(channelNode.attribute("name"),
  13306. channelNode.attribute("value"));
  13307. }
  13308. ModbusScanItem scanItem;
  13309. QString format= channelAttributes.value("format").toString();
  13310. if(format=="16fixedint")
  13311. {
  13312. scanItem.format= Int16;
  13313. }
  13314. else if(format=="32floathl")
  13315. {
  13316. scanItem.format= FloatHL;
  13317. }
  13318. else if(format=="32floatlh")
  13319. {
  13320. scanItem.format= FloatLH;
  13321. }
  13322. scanItem.request.append((char)channelAttributes.value("station").toInt());
  13323. scanItem.request.append((char)channelAttributes.value("function").toInt());
  13324. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  13325. char*startAddressBytes= (char*)&startAddress;
  13326. scanItem.request.append(startAddressBytes[1]);
  13327. scanItem.request.append(startAddressBytes[0]);
  13328. scanItem.request.append((char)0x00);
  13329. if(scanItem.format==Int16)
  13330. {
  13331. scanItem.request.append((char)0x01);
  13332. }
  13333. else
  13334. {
  13335. scanItem.request.append((char)0x02);
  13336. }
  13337. quint16 crc= calculateCRC(scanItem.request);
  13338. char*crcBytes= (char*)&crc;
  13339. scanItem.request.append(crcBytes[0]);
  13340. scanItem.request.append(crcBytes[1]);
  13341. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  13342. if(channelAttributes.value("unit").toString()=="C")
  13343. {
  13344. scanItem.unit= Units::Celsius;
  13345. channelTypeList.append("T");
  13346. }
  13347. else if(channelAttributes.value("unit").toString()=="F")
  13348. {
  13349. scanItem.unit= Units::Fahrenheit;
  13350. channelTypeList.append("T");
  13351. }
  13352. else
  13353. {
  13354. scanItem.unit= Units::Unitless;
  13355. channelTypeList.append("C");
  13356. }
  13357. scanList.append(scanItem);
  13358. lastMeasurement.append(0.0);
  13359. channels.append(new Channel);
  13360. channelNames.append(channelAttributes.value("column").toString());
  13361. hiddenStates.append(
  13362. channelAttributes.value("hidden").toString()=="true"?true:false);
  13363. channelLabels.append(model->data(channelIndex,0).toString());
  13364. }
  13365. messageDelayTimer->start();
  13366. }
  13367. ModbusNG::~ModbusNG()
  13368. {
  13369. commTimeout->stop();
  13370. messageDelayTimer->stop();
  13371. port->close();
  13372. }
  13373. void ModbusNG::sendNextMessage()
  13374. {
  13375. if(scanList.length()> 0&&!waiting)
  13376. {
  13377. port->write(scanList.at(scanPosition).request);
  13378. commTimeout->start(2000);
  13379. messageDelayTimer->start(delayTime);
  13380. waiting= true;
  13381. }
  13382. }
  13383. void ModbusNG::timeout()
  13384. {
  13385. qDebug()<<"Communications timeout.";
  13386. messageDelayTimer->start();
  13387. }
  13388. void ModbusNG::rateLimitTimeout()
  13389. {
  13390. messageDelayTimer->start();
  13391. }
  13392. void ModbusNG::dataAvailable()
  13393. {
  13394. if(messageDelayTimer->isActive())
  13395. {
  13396. messageDelayTimer->stop();
  13397. }
  13398. responseBuffer.append(port->readAll());
  13399. if(responseBuffer.size()<5)
  13400. {
  13401. return;
  13402. }
  13403. if(responseBuffer.size()<5+responseBuffer.at(2))
  13404. {
  13405. return;
  13406. }
  13407. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  13408. commTimeout->stop();
  13409. if(calculateCRC(responseBuffer)==0)
  13410. {
  13411. quint16 intresponse;
  13412. float floatresponse;
  13413. char*ibytes= (char*)&intresponse;
  13414. char*fbytes= (char*)&floatresponse;
  13415. double output;
  13416. switch(scanList.at(scanPosition).format)
  13417. {
  13418. case Int16:
  13419. ibytes[0]= responseBuffer.at(4);
  13420. ibytes[1]= responseBuffer.at(3);
  13421. output= intresponse;
  13422. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  13423. {
  13424. output/= 10;
  13425. }
  13426. break;
  13427. case FloatHL:
  13428. fbytes[0]= responseBuffer.at(4);
  13429. fbytes[1]= responseBuffer.at(3);
  13430. fbytes[2]= responseBuffer.at(6);
  13431. fbytes[3]= responseBuffer.at(5);
  13432. output= floatresponse;
  13433. break;
  13434. case FloatLH:
  13435. fbytes[0]= responseBuffer.at(6);
  13436. fbytes[1]= responseBuffer.at(5);
  13437. fbytes[2]= responseBuffer.at(4);
  13438. fbytes[3]= responseBuffer.at(3);
  13439. output= floatresponse;
  13440. break;
  13441. }
  13442. if(scanList.at(scanPosition).unit==Units::Celsius)
  13443. {
  13444. output= output*9.0/5.0+32.0;
  13445. }
  13446. scanList.at(scanPosition).lastValue= output;
  13447. }
  13448. else
  13449. {
  13450. qDebug()<<"CRC failed";
  13451. }
  13452. scanPosition= (scanPosition+1)%scanList.size();
  13453. if(scanPosition==0)
  13454. {
  13455. QTime time= QTime::currentTime();
  13456. bool doOutput= false;
  13457. for(int i= 0;i<scanList.size();i++)
  13458. {
  13459. if(scanList.at(i).lastValue!=lastMeasurement.at(i))
  13460. {
  13461. doOutput= true;
  13462. break;
  13463. }
  13464. }
  13465. if(doOutput)
  13466. {
  13467. for(int i= 0;i<scanList.size();i++)
  13468. {
  13469. lastMeasurement[i]= scanList.at(i).lastValue;
  13470. if(scanList.at(scanPosition).unit==Units::Unitless)
  13471. {
  13472. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Unitless));
  13473. }
  13474. else
  13475. {
  13476. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  13477. }
  13478. }
  13479. }
  13480. }
  13481. responseBuffer.clear();
  13482. waiting= false;
  13483. if(scanPosition==0)
  13484. {
  13485. rateLimiter->start();
  13486. }
  13487. else
  13488. {
  13489. messageDelayTimer->start(delayTime);
  13490. }
  13491. }
  13492. quint16 ModbusNG::calculateCRC(QByteArray data)
  13493. {
  13494. quint16 retval= 0xFFFF;
  13495. int i= 0;
  13496. while(i<data.size())
  13497. {
  13498. retval^= 0x00FF&(quint16)data.at(i);
  13499. for(int j= 0;j<8;j++)
  13500. {
  13501. if(retval&1)
  13502. {
  13503. retval= (retval>>1)^0xA001;
  13504. }
  13505. else
  13506. {
  13507. retval>>= 1;
  13508. }
  13509. }
  13510. i++;
  13511. }
  13512. return retval;
  13513. }
  13514. int ModbusNG::channelCount()
  13515. {
  13516. return channels.size();
  13517. }
  13518. Channel*ModbusNG::getChannel(int channel)
  13519. {
  13520. return channels.at(channel);
  13521. }
  13522. QString ModbusNG::channelColumnName(int channel)
  13523. {
  13524. return channelNames.at(channel);
  13525. }
  13526. QString ModbusNG::channelIndicatorText(int channel)
  13527. {
  13528. return channelLabels.at(channel);
  13529. }
  13530. bool ModbusNG::isChannelHidden(int channel)
  13531. {
  13532. return hiddenStates.at(channel);
  13533. }
  13534. QString ModbusNG::channelType(int channel)
  13535. {
  13536. return channelTypeList.at(channel);
  13537. }
  13538. /*:923*/
  13539. #line 615 "./typica.w"
  13540. /*1148:*/
  13541. #line 33 "./thresholdannotation.w"
  13542. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  13543. const QModelIndex&index)
  13544. :BasicDeviceConfigurationWidget(model,index)
  13545. {
  13546. QFormLayout*layout= new QFormLayout;
  13547. QLineEdit*source= new QLineEdit;
  13548. layout->addRow(tr("Source column name:"),source);
  13549. QDoubleSpinBox*value= new QDoubleSpinBox;
  13550. value->setMinimum(-9999.99);
  13551. value->setMaximum(9999.99);
  13552. value->setDecimals(2);
  13553. layout->addRow(tr("Threshold value:"),value);
  13554. QComboBox*direction= new QComboBox;
  13555. direction->addItem(tr("Ascending"));
  13556. direction->addItem(tr("Descending"));
  13557. layout->addRow(tr("Direction:"),direction);
  13558. QLineEdit*annotation= new QLineEdit;
  13559. layout->addRow(tr("Annotation:"),annotation);
  13560. /*816:*/
  13561. #line 16928 "./typica.w"
  13562. QDomElement referenceElement=
  13563. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13564. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13565. QDomElement node;
  13566. /*:816*/
  13567. #line 52 "./thresholdannotation.w"
  13568. for(int i= 0;i<configData.size();i++)
  13569. {
  13570. node= configData.at(i).toElement();
  13571. if(node.attribute("name")=="source")
  13572. {
  13573. source->setText(node.attribute("value"));
  13574. }
  13575. else if(node.attribute("name")=="value")
  13576. {
  13577. value->setValue(node.attribute("value").toDouble());
  13578. }
  13579. else if(node.attribute("name")=="direction")
  13580. {
  13581. direction->setCurrentIndex(node.attribute("value").toInt());
  13582. }
  13583. else if(node.attribute("name")=="annotation")
  13584. {
  13585. annotation->setText(node.attribute("value"));
  13586. }
  13587. }
  13588. updateSourceColumn(source->text());
  13589. updateThreshold(value->value());
  13590. updateDirection(direction->currentIndex());
  13591. updateAnnotation(annotation->text());
  13592. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  13593. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  13594. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  13595. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  13596. setLayout(layout);
  13597. }
  13598. /*:1148*//*1149:*/
  13599. #line 86 "./thresholdannotation.w"
  13600. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  13601. {
  13602. updateAttribute("source",source);
  13603. }
  13604. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  13605. {
  13606. updateAttribute("value",QString("%1").arg(value));
  13607. }
  13608. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  13609. {
  13610. updateAttribute("direction",QString("%1").arg(direction));
  13611. }
  13612. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  13613. {
  13614. updateAttribute("annotation",annotation);
  13615. }
  13616. /*:1149*/
  13617. #line 616 "./typica.w"
  13618. /*1153:*/
  13619. #line 152 "./thresholdannotation.w"
  13620. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  13621. {
  13622. t.setInterval(0);
  13623. t.setSingleShot(true);
  13624. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  13625. }
  13626. void Annotator::setAnnotation(const QString&annotation)
  13627. {
  13628. note= annotation;
  13629. }
  13630. void Annotator::setTemperatureColumn(int tempcolumn)
  13631. {
  13632. tc= tempcolumn;
  13633. }
  13634. void Annotator::setAnnotationColumn(int annotationcolumn)
  13635. {
  13636. ac= annotationcolumn;
  13637. }
  13638. /*:1153*//*1154:*/
  13639. #line 181 "./thresholdannotation.w"
  13640. void Annotator::catchTimer()
  13641. {
  13642. emit annotation(note,tc,ac);
  13643. }
  13644. void Annotator::annotate()
  13645. {
  13646. t.start();
  13647. }
  13648. /*:1154*/
  13649. #line 617 "./typica.w"
  13650. /*:4*//*267:*/
  13651. #line 6262 "./typica.w"
  13652. /*264:*/
  13653. #line 6225 "./typica.w"
  13654. void ScriptValidator::fixup(QString&input)const
  13655. {
  13656. QScriptEngine*engine= AppInstance->engine;
  13657. engine->pushContext();
  13658. input= engine->evaluate(input).toString();
  13659. engine->popContext();
  13660. }
  13661. /*:264*//*265:*/
  13662. #line 6238 "./typica.w"
  13663. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  13664. {
  13665. if(v)
  13666. {
  13667. if(v->validate(input,pos)==QValidator::Acceptable)
  13668. {
  13669. return QValidator::Acceptable;
  13670. }
  13671. }
  13672. return QValidator::Intermediate;
  13673. }
  13674. /*:265*//*266:*/
  13675. #line 6253 "./typica.w"
  13676. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  13677. :QValidator(parent),v(validator)
  13678. {
  13679. }
  13680. /*:266*/
  13681. #line 6263 "./typica.w"
  13682. /*:267*//*709:*/
  13683. #line 160 "./plugins.w"
  13684. /*706:*/
  13685. #line 92 "./plugins.w"
  13686. PluginAction::PluginAction(const QFileInfo&info,QObject*parent):
  13687. QAction(parent),preRunScript(""),postRunScript("")
  13688. {
  13689. pluginFile= info.absoluteFilePath();
  13690. setText(info.baseName());
  13691. connect(this,SIGNAL(triggered()),this,SLOT(runScript()));
  13692. }
  13693. void PluginAction::runScript()
  13694. {
  13695. QFile file(pluginFile);
  13696. if(file.open(QIODevice::ReadOnly))
  13697. {
  13698. QScriptEngine*engine= AppInstance->engine;
  13699. QScriptContext*context= engine->pushContext();
  13700. if(parent()->dynamicPropertyNames().contains("activationObject"))
  13701. {
  13702. QScriptValue activationObject=
  13703. parent()->property("activationObject").value<QScriptValue> ();
  13704. context->setActivationObject(activationObject);
  13705. }
  13706. QString script(file.readAll());
  13707. QScriptValue retval= engine->evaluate(preRunScript+script+postRunScript,pluginFile);
  13708. if(engine->hasUncaughtException())
  13709. {
  13710. qDebug()<<"Uncaught exception: "<<
  13711. engine->uncaughtException().toString()<<
  13712. " in "<<pluginFile<<" line: "<<
  13713. engine->uncaughtExceptionLineNumber();
  13714. }
  13715. engine->popContext();
  13716. file.close();
  13717. }
  13718. }
  13719. /*:706*//*707:*/
  13720. #line 131 "./plugins.w"
  13721. QString PluginAction::preRun()
  13722. {
  13723. return preRunScript;
  13724. }
  13725. QString PluginAction::postRun()
  13726. {
  13727. return postRunScript;
  13728. }
  13729. void PluginAction::setPreRun(const QString&script)
  13730. {
  13731. preRunScript= script;
  13732. }
  13733. void PluginAction::setPostRun(const QString&script)
  13734. {
  13735. postRunScript= script;
  13736. }
  13737. /*:707*/
  13738. #line 161 "./plugins.w"
  13739. #line 14889 "./typica.w"
  13740. #line 1 "./daterangeselector.w"
  13741. /*:709*//*890:*/
  13742. #line 89 "./colorsettings.w"
  13743. /*888:*/
  13744. #line 40 "./colorsettings.w"
  13745. ColorSettingsWidget::ColorSettingsWidget():QWidget(NULL)
  13746. {
  13747. QFormLayout*layout= new QFormLayout;
  13748. QCheckBox*enable= new QCheckBox(tr("Enable Javalytics communication"));
  13749. QSettings settings;
  13750. enable->setChecked(settings.value("settings/color/javalytics/enable",false).toBool());
  13751. QLineEdit*address= new QLineEdit();
  13752. address->setText(settings.value("settings/color/javalytics/address","192.168.1.10").toString());
  13753. QSpinBox*scale= new QSpinBox();
  13754. scale->setMinimum(1);
  13755. scale->setMaximum(4);
  13756. scale->setValue(settings.value("settings/color/javalytics/scale",1).toInt());
  13757. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnable(bool)));
  13758. connect(address,SIGNAL(textChanged(QString)),this,SLOT(updateAddress(QString)));
  13759. connect(scale,SIGNAL(valueChanged(int)),this,SLOT(updateScale(int)));
  13760. layout->addRow(enable);
  13761. layout->addRow(tr("IP Address:"),address);
  13762. layout->addRow(tr("Scale Number:"),scale);
  13763. updateEnable(enable->isChecked());
  13764. updateAddress(address->text());
  13765. updateScale(scale->value());
  13766. setLayout(layout);
  13767. }
  13768. /*:888*//*889:*/
  13769. #line 68 "./colorsettings.w"
  13770. void ColorSettingsWidget::updateEnable(bool enable)
  13771. {
  13772. QSettings settings;
  13773. settings.setValue("settings/color/javalytics/enable",enable);
  13774. }
  13775. void ColorSettingsWidget::updateAddress(const QString&address)
  13776. {
  13777. QSettings settings;
  13778. settings.setValue("settings/color/javalytics/address",address);
  13779. }
  13780. void ColorSettingsWidget::updateScale(int scale)
  13781. {
  13782. QSettings settings;
  13783. settings.setValue("settings/color/javalytics/scale",scale);
  13784. }
  13785. /*:889*/
  13786. #line 90 "./colorsettings.w"
  13787. #line 66 "./settings.w"
  13788. #line 1 "./advancedsettings.w"
  13789. /*:890*//*894:*/
  13790. #line 60 "./advancedsettings.w"
  13791. /*892:*/
  13792. #line 26 "./advancedsettings.w"
  13793. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  13794. {
  13795. QSettings settings;
  13796. QFormLayout*layout= new QFormLayout;
  13797. QCheckBox*logDiagnostics= new QCheckBox;
  13798. logDiagnostics->setCheckState(
  13799. settings.value("settings/advanced/logging",false).toBool()?
  13800. Qt::Checked:Qt::Unchecked);
  13801. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  13802. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  13803. setLayout(layout);
  13804. }
  13805. /*:892*//*893:*/
  13806. #line 43 "./advancedsettings.w"
  13807. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  13808. {
  13809. QSettings settings;
  13810. settings.setValue("settings/advanced/logging",enabled);
  13811. if(enabled)
  13812. {
  13813. qInstallMsgHandler(messageFileOutput);
  13814. }
  13815. else
  13816. {
  13817. qInstallMsgHandler(0);
  13818. }
  13819. }
  13820. /*:893*/
  13821. #line 61 "./advancedsettings.w"
  13822. #line 18693 "./typica.w"
  13823. /*:894*//*953:*/
  13824. #line 642 "./unsupportedserial.w"
  13825. /*928:*/
  13826. #line 58 "./unsupportedserial.w"
  13827. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  13828. const QModelIndex&index)
  13829. :BasicDeviceConfigurationWidget(model,index),
  13830. deviceSettingsModel(new SaltModel(2)),
  13831. scriptEditor(new QTextEdit)
  13832. {
  13833. scriptEditor->setTabStopWidth(20);
  13834. QVBoxLayout*dummyLayout= new QVBoxLayout;
  13835. QTabWidget*central= new QTabWidget;
  13836. QWidget*deviceConfigurationWidget= new QWidget;
  13837. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  13838. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13839. deviceConfigurationLayout->addWidget(addChannelButton);
  13840. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13841. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  13842. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  13843. QTableView*deviceSettingsView= new QTableView;
  13844. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  13845. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  13846. deviceSettingsView->setModel(deviceSettingsModel);
  13847. deviceConfigurationLayout->addWidget(deviceSettingsView);
  13848. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  13849. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  13850. central->addTab(scriptEditor,tr("Script"));
  13851. dummyLayout->addWidget(central);
  13852. /*816:*/
  13853. #line 16928 "./typica.w"
  13854. QDomElement referenceElement=
  13855. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13856. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13857. QDomElement node;
  13858. /*:816*/
  13859. #line 86 "./unsupportedserial.w"
  13860. for(int i= 0;i<configData.size();i++)
  13861. {
  13862. node= configData.at(i).toElement();
  13863. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13864. {
  13865. int column= 0;
  13866. if(node.attribute("name")=="values")
  13867. {
  13868. column= 1;
  13869. }
  13870. QString data= node.attribute("value");
  13871. if(data.length()> 3)
  13872. {
  13873. data.chop(2);
  13874. data= data.remove(0,2);
  13875. }
  13876. QStringList keyList= data.split(", ");
  13877. for(int j= 0;j<keyList.size();j++)
  13878. {
  13879. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  13880. QVariant(keyList.at(j)),
  13881. Qt::EditRole);
  13882. }
  13883. }
  13884. else if(node.attribute("name")=="script")
  13885. {
  13886. scriptEditor->setPlainText(node.attribute("value"));
  13887. }
  13888. }
  13889. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13890. this,SLOT(updateConfiguration()));
  13891. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13892. setLayout(dummyLayout);
  13893. }
  13894. /*:928*//*929:*/
  13895. #line 131 "./unsupportedserial.w"
  13896. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13897. {
  13898. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13899. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13900. }
  13901. /*:929*//*930:*/
  13902. #line 144 "./unsupportedserial.w"
  13903. void UnsupportedSerialDeviceConfWidget::saveScript()
  13904. {
  13905. updateAttribute("script",scriptEditor->toPlainText());
  13906. }
  13907. /*:930*//*931:*/
  13908. #line 155 "./unsupportedserial.w"
  13909. void UnsupportedSerialDeviceConfWidget::addChannel()
  13910. {
  13911. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13912. }
  13913. /*:931*//*933:*/
  13914. #line 183 "./unsupportedserial.w"
  13915. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13916. const QModelIndex&index)
  13917. :BasicDeviceConfigurationWidget(model,index),
  13918. channelSettingsModel(new SaltModel(2))
  13919. {
  13920. QFormLayout*layout= new QFormLayout;
  13921. QLineEdit*columnName= new QLineEdit;
  13922. layout->addRow(tr("Column Name:"),columnName);
  13923. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13924. layout->addRow(hideSeries);
  13925. QTableView*channelSettings= new QTableView;
  13926. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13927. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13928. channelSettings->setModel(channelSettingsModel);
  13929. layout->addRow(channelSettings);
  13930. setLayout(layout);
  13931. /*816:*/
  13932. #line 16928 "./typica.w"
  13933. QDomElement referenceElement=
  13934. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13935. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13936. QDomElement node;
  13937. /*:816*/
  13938. #line 200 "./unsupportedserial.w"
  13939. for(int i= 0;i<configData.size();i++)
  13940. {
  13941. node= configData.at(i).toElement();
  13942. if(node.attribute("name")=="columnname")
  13943. {
  13944. columnName->setText(node.attribute("value"));
  13945. }
  13946. else if(node.attribute("name")=="hidden")
  13947. {
  13948. hideSeries->setChecked(node.attribute("value")=="true");
  13949. }
  13950. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13951. {
  13952. int column= 0;
  13953. if(node.attribute("name")=="values")
  13954. {
  13955. column= 1;
  13956. }
  13957. QString data= node.attribute("value");
  13958. if(data.length()> 3)
  13959. {
  13960. data.chop(2);
  13961. data= data.remove(0,2);
  13962. }
  13963. QStringList keyList= data.split(", ");
  13964. for(int j= 0;j<keyList.size();j++)
  13965. {
  13966. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13967. QVariant(keyList.at(j)),
  13968. Qt::EditRole);
  13969. }
  13970. }
  13971. }
  13972. updateColumnName(columnName->text());
  13973. updateHidden(hideSeries->isChecked());
  13974. updateConfiguration();
  13975. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13976. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13977. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13978. this,SLOT(updateConfiguration()));
  13979. }
  13980. /*:933*//*934:*/
  13981. #line 247 "./unsupportedserial.w"
  13982. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13983. {
  13984. updateAttribute("columnname",value);
  13985. }
  13986. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13987. {
  13988. updateAttribute("hidden",hidden?"true":"false");
  13989. }
  13990. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13991. {
  13992. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13993. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13994. }
  13995. /*:934*/
  13996. #line 643 "./unsupportedserial.w"
  13997. /*941:*/
  13998. #line 374 "./unsupportedserial.w"
  13999. void JavaScriptDevice::start()
  14000. {
  14001. QScriptValue object= scriptengine->newQObject(this);
  14002. /*942:*/
  14003. #line 393 "./unsupportedserial.w"
  14004. QScriptValue settingsObject= scriptengine->newObject();
  14005. QVariantMap::const_iterator i= deviceSettings.constBegin();
  14006. while(i!=deviceSettings.constEnd())
  14007. {
  14008. settingsObject.setProperty(i.key(),i.value().toString());
  14009. i++;
  14010. }
  14011. object.setProperty("settings",settingsObject);
  14012. /*:942*/
  14013. #line 378 "./unsupportedserial.w"
  14014. /*943:*/
  14015. #line 408 "./unsupportedserial.w"
  14016. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  14017. for(int i= 0;i<channelCount();i++)
  14018. {
  14019. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  14020. QScriptValue channelSettingsObject= scriptengine->newObject();
  14021. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  14022. while(j!=channelSettings.at(i).constEnd())
  14023. {
  14024. channelSettingsObject.setProperty(j.key(),j.value().toString());
  14025. j++;
  14026. }
  14027. channelObject.setProperty("settings",channelSettingsObject);
  14028. channelsArray.setProperty(i,channelObject);
  14029. }
  14030. object.setProperty("channels",channelsArray);
  14031. /*:943*/
  14032. #line 379 "./unsupportedserial.w"
  14033. QScriptContext*context= scriptengine->currentContext();
  14034. QScriptValue oldThis= context->thisObject();
  14035. context->setThisObject(object);
  14036. QScriptValue result= scriptengine->evaluate(deviceScript);
  14037. QScriptEngine*engine= scriptengine;
  14038. /*202:*/
  14039. #line 4629 "./typica.w"
  14040. if(engine->hasUncaughtException())
  14041. {
  14042. int line= engine->uncaughtExceptionLineNumber();
  14043. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  14044. result.toString();
  14045. QString trace;
  14046. foreach(trace,engine->uncaughtExceptionBacktrace())
  14047. {
  14048. qDebug()<<trace;
  14049. }
  14050. }
  14051. /*:202*/
  14052. #line 385 "./unsupportedserial.w"
  14053. context->setThisObject(oldThis);
  14054. }
  14055. /*:941*//*946:*/
  14056. #line 449 "./unsupportedserial.w"
  14057. void JavaScriptDevice::stop()
  14058. {
  14059. emit deviceStopRequested();
  14060. }
  14061. /*:946*//*947:*/
  14062. #line 462 "./unsupportedserial.w"
  14063. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  14064. QScriptEngine*engine):
  14065. QObject(NULL),scriptengine(engine)
  14066. {
  14067. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14068. QDomElement deviceReferenceElement=
  14069. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14070. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  14071. QDomElement node;
  14072. QStringList deviceKeys;
  14073. QStringList deviceValues;
  14074. for(int i= 0;i<deviceConfigData.size();i++)
  14075. {
  14076. node= deviceConfigData.at(i).toElement();
  14077. if(node.attribute("name")=="keys")
  14078. {
  14079. QString data= node.attribute("value");
  14080. if(data.length()> 3)
  14081. {
  14082. data.chop(2);
  14083. data= data.remove(0,2);
  14084. }
  14085. deviceKeys= data.split(", ");
  14086. }
  14087. else if(node.attribute("name")=="values")
  14088. {
  14089. QString data= node.attribute("value");
  14090. if(data.length()> 3)
  14091. {
  14092. data.chop(2);
  14093. data= data.remove(0,2);
  14094. }
  14095. deviceValues= data.split(", ");
  14096. }
  14097. else if(node.attribute("name")=="script")
  14098. {
  14099. deviceScript= node.attribute("value");
  14100. }
  14101. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  14102. }
  14103. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  14104. {
  14105. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  14106. }
  14107. if(model->hasChildren(index))
  14108. {
  14109. for(int i= 0;i<model->rowCount(index);i++)
  14110. {
  14111. QModelIndex channelIndex= model->index(i,0,index);
  14112. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  14113. channelList.append(new Channel);
  14114. QDomElement channelReferenceElement=
  14115. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  14116. QDomNodeList channelConfigData=
  14117. channelReferenceElement.elementsByTagName("attribute");
  14118. QStringList channelKeys;
  14119. QStringList channelValues;
  14120. for(int j= 0;j<channelConfigData.size();j++)
  14121. {
  14122. node= channelConfigData.at(j).toElement();
  14123. if(node.attribute("name")=="keys")
  14124. {
  14125. QString data= node.attribute("value");
  14126. if(data.length()> 3)
  14127. {
  14128. data.chop(2);
  14129. data= data.remove(0,2);
  14130. }
  14131. channelKeys= data.split(", ");
  14132. }
  14133. else if(node.attribute("name")=="values")
  14134. {
  14135. QString data= node.attribute("value");
  14136. if(data.length()> 3)
  14137. {
  14138. data.chop(2);
  14139. data= data.remove(0,2);
  14140. }
  14141. channelValues= data.split(", ");
  14142. }
  14143. else if(node.attribute("name")=="hidden")
  14144. {
  14145. hiddenState.append(node.attribute("value")=="true");
  14146. }
  14147. else if(node.attribute("name")=="columnname")
  14148. {
  14149. columnNames.append(node.attribute("value"));
  14150. }
  14151. }
  14152. QVariantMap cs;
  14153. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  14154. {
  14155. cs.insert(channelKeys[j],channelValues[j]);
  14156. }
  14157. channelSettings.append(cs);
  14158. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  14159. channelUnits.append(Units::Fahrenheit);
  14160. }
  14161. }
  14162. }
  14163. /*:947*//*948:*/
  14164. #line 567 "./unsupportedserial.w"
  14165. int JavaScriptDevice::channelCount()
  14166. {
  14167. return channelList.length();
  14168. }
  14169. Channel*JavaScriptDevice::getChannel(int channel)
  14170. {
  14171. return channelList.at(channel);
  14172. }
  14173. bool JavaScriptDevice::isChannelHidden(int channel)
  14174. {
  14175. return hiddenState.at(channel);
  14176. }
  14177. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  14178. {
  14179. return channelUnits.at(channel);
  14180. }
  14181. QString JavaScriptDevice::channelColumnName(int channel)
  14182. {
  14183. if(channel>=0&&channel<columnNames.length())
  14184. {
  14185. return columnNames.at(channel);
  14186. }
  14187. return QString();
  14188. }
  14189. QString JavaScriptDevice::channelIndicatorText(int channel)
  14190. {
  14191. return indicatorTexts.at(channel);
  14192. }
  14193. /*:948*//*949:*/
  14194. #line 604 "./unsupportedserial.w"
  14195. void JavaScriptDevice::setTemperatureColumn(int tcol)
  14196. {
  14197. annotationTemperatureColumn= tcol;
  14198. }
  14199. void JavaScriptDevice::setAnnotationColumn(int ncol)
  14200. {
  14201. annotationNoteColumn= ncol;
  14202. }
  14203. /*:949*/
  14204. #line 644 "./unsupportedserial.w"
  14205. /*:953*//*976:*/
  14206. #line 444 "./phidgets.w"
  14207. /*960:*/
  14208. #line 31 "./phidgets.w"
  14209. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  14210. const QModelIndex&index)
  14211. :BasicDeviceConfigurationWidget(model,index)
  14212. {
  14213. QFormLayout*layout= new QFormLayout;
  14214. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  14215. QSpinBox*sampleRate= new QSpinBox;
  14216. sampleRate->setMinimum(40);
  14217. sampleRate->setMaximum(600);
  14218. sampleRate->setSingleStep(40);
  14219. sampleRate->setValue(360);
  14220. /*816:*/
  14221. #line 16928 "./typica.w"
  14222. QDomElement referenceElement=
  14223. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14224. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14225. QDomElement node;
  14226. /*:816*/
  14227. #line 44 "./phidgets.w"
  14228. for(int i= 0;i<configData.size();i++)
  14229. {
  14230. node= configData.at(i).toElement();
  14231. if(node.attribute("name")=="sampleRate")
  14232. {
  14233. sampleRate->setValue(node.attribute("value").toInt());
  14234. }
  14235. }
  14236. updateRate(sampleRate->value());
  14237. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  14238. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  14239. layout->addRow(addChannelButton);
  14240. layout->addRow(tr("Sample rate:"),sampleRate);
  14241. setLayout(layout);
  14242. }
  14243. /*:960*//*961:*/
  14244. #line 66 "./phidgets.w"
  14245. void PhidgetsTemperatureSensorConfWidget::addChannel()
  14246. {
  14247. insertChildNode(tr("Channel"),"phidgets1048channel");
  14248. }
  14249. /*:961*//*962:*/
  14250. #line 74 "./phidgets.w"
  14251. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  14252. {
  14253. updateAttribute("sampleRate",QString("%1").arg(ms));
  14254. }
  14255. /*:962*//*964:*/
  14256. #line 103 "./phidgets.w"
  14257. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  14258. DeviceTreeModel*model,const QModelIndex&index)
  14259. :BasicDeviceConfigurationWidget(model,index),
  14260. tcType(new QComboBox)
  14261. {
  14262. QFormLayout*layout= new QFormLayout;
  14263. QLineEdit*columnName= new QLineEdit;
  14264. layout->addRow(tr("Column Name:"),columnName);
  14265. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  14266. layout->addRow(hideSeries);
  14267. layout->addRow(tr("Thermocouple Type:"),tcType);
  14268. tcType->addItem("Type K","1");
  14269. tcType->addItem("Type J","2");
  14270. tcType->addItem("Type E","3");
  14271. tcType->addItem("Type T","4");
  14272. QSpinBox*channel= new QSpinBox;
  14273. layout->addRow(tr("Channel:"),channel);
  14274. channel->setMinimum(0);
  14275. channel->setMaximum(3);
  14276. setLayout(layout);
  14277. /*816:*/
  14278. #line 16928 "./typica.w"
  14279. QDomElement referenceElement=
  14280. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14281. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14282. QDomElement node;
  14283. /*:816*/
  14284. #line 124 "./phidgets.w"
  14285. for(int i= 0;i<configData.size();i++)
  14286. {
  14287. node= configData.at(i).toElement();
  14288. if(node.attribute("name")=="columnname")
  14289. {
  14290. columnName->setText(node.attribute("value"));
  14291. }
  14292. else if(node.attribute("name")=="hidden")
  14293. {
  14294. hideSeries->setChecked(node.attribute("value")=="true");
  14295. }
  14296. else if(node.attribute("name")=="tctype")
  14297. {
  14298. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  14299. }
  14300. else if(node.attribute("name")=="channel")
  14301. {
  14302. channel->setValue(node.attribute("value").toInt());
  14303. }
  14304. }
  14305. updateColumnName(columnName->text());
  14306. updateHidden(hideSeries->isChecked());
  14307. updateTC(tcType->currentIndex());
  14308. updateChannel(channel->value());
  14309. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  14310. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  14311. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  14312. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  14313. }
  14314. /*:964*//*965:*/
  14315. #line 157 "./phidgets.w"
  14316. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  14317. {
  14318. updateAttribute("columnname",value);
  14319. }
  14320. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  14321. {
  14322. updateAttribute("hidden",hidden?"true":"false");
  14323. }
  14324. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  14325. {
  14326. updateAttribute("tctype",tcType->itemData(index).toString());
  14327. }
  14328. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  14329. {
  14330. updateAttribute("channel",QString("%1").arg(channel));
  14331. }
  14332. /*:965*//*969:*/
  14333. #line 246 "./phidgets.w"
  14334. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  14335. :QObject(NULL),driver("phidget21"),device(NULL)
  14336. {
  14337. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14338. QDomElement deviceReferenceElement=
  14339. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14340. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  14341. QDomElement node;
  14342. for(int i= 0;i<deviceConfigData.size();i++)
  14343. {
  14344. node= deviceConfigData.at(i).toElement();
  14345. if(node.attribute("name")=="sampleRate")
  14346. {
  14347. sampleTimer.setInterval(node.attribute("value").toInt());
  14348. }
  14349. }
  14350. if(model->hasChildren(index))
  14351. {
  14352. for(int i= 0;i<model->rowCount(index);i++)
  14353. {
  14354. QModelIndex channelIndex= model->index(i,0,index);
  14355. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  14356. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  14357. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  14358. for(int j= 0;j<channelConfigData.size();j++)
  14359. {
  14360. node= channelConfigData.at(j).toElement();
  14361. if(node.attribute("name")=="channel")
  14362. {
  14363. int channelID= node.attribute("value").toInt();
  14364. channelIndices.append(channelID);
  14365. Channel*channel= new Channel;
  14366. channelList.append(channel);
  14367. channelMap.insert(channelID,channel);
  14368. }
  14369. else if(node.attribute("name")=="hidden")
  14370. {
  14371. hiddenState.append(node.attribute("value")=="true");
  14372. }
  14373. else if(node.attribute("name")=="columnname")
  14374. {
  14375. columnNames.append(node.attribute("value"));
  14376. }
  14377. else if(node.attribute("name")=="tctype")
  14378. {
  14379. tctypes.append(node.attribute("value").toInt());
  14380. }
  14381. }
  14382. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  14383. }
  14384. }
  14385. }
  14386. /*:969*//*970:*/
  14387. #line 306 "./phidgets.w"
  14388. int PhidgetsTemperatureSensor::channelCount()
  14389. {
  14390. return channelList.length();
  14391. }
  14392. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  14393. {
  14394. return channelList.at(channel);
  14395. }
  14396. /*:970*//*971:*/
  14397. #line 319 "./phidgets.w"
  14398. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  14399. {
  14400. return hiddenState.at(channel);
  14401. }
  14402. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  14403. {
  14404. if(channel>=0&&channel<columnNames.length())
  14405. {
  14406. return columnNames.at(channel);
  14407. }
  14408. return QString();
  14409. }
  14410. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  14411. {
  14412. if(channel>=0&&channel<indicatorTexts.length())
  14413. {
  14414. return indicatorTexts.at(channel);
  14415. }
  14416. return QString();
  14417. }
  14418. /*:971*//*973:*/
  14419. #line 371 "./phidgets.w"
  14420. void PhidgetsTemperatureSensor::start()
  14421. {
  14422. if(!driver.load())
  14423. {
  14424. driver.setFileName("Phidget21.framework/Phidget21");
  14425. if(!driver.load())
  14426. {
  14427. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14428. tr("Failed to find phidget21. Please install it."));
  14429. return;
  14430. }
  14431. }
  14432. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  14433. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  14434. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  14435. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  14436. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  14437. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  14438. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  14439. {
  14440. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14441. tr("Failed to link a required symbol in phidget21."));
  14442. return;
  14443. }
  14444. createDevice(&device);
  14445. openDevice(device,-1);
  14446. int error;
  14447. if((error= waitForOpen(device,10000)))
  14448. {
  14449. closeDevice(device);
  14450. deleteDevice(device);
  14451. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  14452. tr("CPhidget_waitForAttachment returns error %n",0,error));
  14453. return;
  14454. }
  14455. for(int i= 0;i<channelIndices.length();i++)
  14456. {
  14457. setTCType(device,channelIndices.at(i),tctypes.at(i));
  14458. }
  14459. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  14460. sampleTimer.start();
  14461. }
  14462. /*:973*//*974:*/
  14463. #line 418 "./phidgets.w"
  14464. void PhidgetsTemperatureSensor::getMeasurements()
  14465. {
  14466. double value= 0.0;
  14467. QTime time= QTime::currentTime();
  14468. foreach(int i,channelIndices)
  14469. {
  14470. getTemperature(device,i,&value);
  14471. Measurement measure(value*9.0/5.0+32.0,time);
  14472. channelMap[i]->input(measure);
  14473. }
  14474. }
  14475. /*:974*//*975:*/
  14476. #line 433 "./phidgets.w"
  14477. void PhidgetsTemperatureSensor::stop()
  14478. {
  14479. sampleTimer.stop();
  14480. closeDevice(device);
  14481. deleteDevice(device);
  14482. driver.unload();
  14483. }
  14484. /*:975*/
  14485. #line 445 "./phidgets.w"
  14486. /*:976*//*1008:*/
  14487. #line 792 "./phidget22.w"
  14488. /*984:*/
  14489. #line 60 "./phidget22.w"
  14490. PhidgetConfWidget::PhidgetConfWidget(DeviceTreeModel*model,
  14491. const QModelIndex&index)
  14492. :BasicDeviceConfigurationWidget(model,index)
  14493. {
  14494. QHBoxLayout*layout= new QHBoxLayout;
  14495. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  14496. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  14497. layout->addWidget(addChannelButton);
  14498. setLayout(layout);
  14499. }
  14500. void PhidgetConfWidget::addChannel()
  14501. {
  14502. insertChildNode(tr("Channel"),"phidgetchannel");
  14503. }
  14504. /*:984*//*989:*/
  14505. #line 179 "./phidget22.w"
  14506. PhidgetChannelSelector::PhidgetChannelSelector():QComboBox(),manager(NULL)
  14507. {
  14508. #if __APPLE__
  14509. driver.setFileName("Phidget22.framework/Phidget22");
  14510. #else
  14511. driver.setFileName("phidget22");
  14512. #endif
  14513. if(!driver.load())
  14514. {
  14515. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14516. tr("Failed to find phidget22. Please install it."));
  14517. return;
  14518. }
  14519. /*988:*/
  14520. #line 157 "./phidget22.w"
  14521. if((createManager= (PhidgetPointer)driver.resolve("PhidgetManager_create"))==0||
  14522. (setOnAttachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnAttachHandler"))==0||
  14523. (setOnDetachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnDetachHandler"))==0||
  14524. (openManager= (PhidgetPointer)driver.resolve("PhidgetManager_open"))==0||
  14525. (getDeviceName= (PhidgetPointerStringOut)driver.resolve("Phidget_getDeviceName"))==0||
  14526. (getDeviceSerialNumber= (PhidgetPointerIntOut)driver.resolve("Phidget_getDeviceSerialNumber"))==0||
  14527. (getChannel= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannel"))==0||
  14528. (getChannelClass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelClass"))==0||
  14529. (getChannelSubclass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelSubclass"))==0||
  14530. (getHubPort= (PhidgetPointerIntOut)driver.resolve("Phidget_getHubPort"))==0||
  14531. (closeManager= (PhidgetPointer)driver.resolve("PhidgetManager_close"))==0||
  14532. (deleteManager= (PhidgetPointer)driver.resolve("PhidgetManager_delete"))==0)
  14533. {
  14534. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14535. tr("Failed to link a required symbol in phidget22."));
  14536. return;
  14537. }
  14538. /*:988*/
  14539. #line 193 "./phidget22.w"
  14540. createManager(&manager);
  14541. setOnAttachManager(manager,ChannelListAddChannel,this);
  14542. setOnDetachManager(manager,ChannelListRemoveChannel,this);
  14543. openManager(manager);
  14544. }
  14545. /*:989*//*992:*/
  14546. #line 228 "./phidget22.w"
  14547. void PhidgetChannelSelector::addChannel(void*device)
  14548. {
  14549. char*deviceName;
  14550. int deviceSerialNumber;
  14551. int channel;
  14552. int channelClass;
  14553. int channelSubclass;
  14554. int hubPort;
  14555. getDeviceName(device,&deviceName);
  14556. getDeviceSerialNumber(device,&deviceSerialNumber);
  14557. getChannel(device,&channel);
  14558. getChannelClass(device,&channelClass);
  14559. getChannelSubclass(device,&channelSubclass);
  14560. getHubPort(device,&hubPort);
  14561. QMap<QString,QVariant> itemData;
  14562. if(channelClass==28)
  14563. {
  14564. itemData.insert("serialNumber",QString("%1").arg(deviceSerialNumber));
  14565. itemData.insert("channel",QString("%1").arg(channel));
  14566. itemData.insert("class",QString("%1").arg(channelClass));
  14567. itemData.insert("subclass",QString("%1").arg(channelSubclass));
  14568. itemData.insert("hubport",QString("%1").arg(hubPort));
  14569. addItem(QString("%1: %2").arg(deviceName).arg(channel),QVariant(itemData));
  14570. }
  14571. }
  14572. /*:992*//*993:*/
  14573. #line 266 "./phidget22.w"
  14574. void PhidgetChannelSelector::removeChannel(void*device)
  14575. {
  14576. int deviceSerialNumber;
  14577. getDeviceSerialNumber(device,&deviceSerialNumber);
  14578. for(int i= count()-1;i>=0;i--)
  14579. {
  14580. QMap<QString,QVariant> data= itemData(i).toMap();
  14581. if(data.value("serialNumber").toInt()==deviceSerialNumber)
  14582. {
  14583. removeItem(i);
  14584. }
  14585. }
  14586. }
  14587. /*:993*//*994:*/
  14588. #line 285 "./phidget22.w"
  14589. PhidgetChannelSelector::~PhidgetChannelSelector()
  14590. {
  14591. if(manager!=NULL)
  14592. {
  14593. closeManager(manager);
  14594. deleteManager(&manager);
  14595. }
  14596. }
  14597. /*:994*//*996:*/
  14598. #line 330 "./phidget22.w"
  14599. PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel*model,
  14600. const QModelIndex&index)
  14601. :BasicDeviceConfigurationWidget(model,index),
  14602. channelSelector(new PhidgetChannelSelector),
  14603. serialNumber(new QLineEdit),
  14604. channel(new QLineEdit),
  14605. hubPort(new QLineEdit),
  14606. subtype(new QComboBox),
  14607. subtypeLayout(new QStackedLayout),
  14608. tctype(new QComboBox),
  14609. rtdtype(new QComboBox),
  14610. rtdwiring(new QComboBox)
  14611. {
  14612. QVBoxLayout*outerLayout= new QVBoxLayout;
  14613. QFormLayout*layout= new QFormLayout;
  14614. QLineEdit*columnName= new QLineEdit;
  14615. subtype->addItem(tr("IC"),QVariant(1));
  14616. subtype->addItem(tr("RTD"),QVariant(32));
  14617. subtype->addItem(tr("Thermocouple"),QVariant(33));
  14618. layout->addRow(tr("Channels:"),channelSelector);
  14619. layout->addRow(tr("Column Name:"),columnName);
  14620. QCheckBox*hidden= new QCheckBox(tr("Hide channel"));
  14621. layout->addRow(hidden);
  14622. layout->addRow(tr("Serial Number:"),serialNumber);
  14623. layout->addRow(tr("Hub Port:"),hubPort);
  14624. layout->addRow(tr("Channel Number:"),channel);
  14625. layout->addRow(tr("Channel Type:"),subtype);
  14626. serialNumber->setEnabled(false);
  14627. channel->setEnabled(false);
  14628. subtype->setEnabled(false);
  14629. outerLayout->addLayout(layout);
  14630. QWidget*icconfiguration= new QWidget;
  14631. QWidget*rtdconfiguration= new QWidget;
  14632. QFormLayout*rtdconfigurationLayout= new QFormLayout;
  14633. rtdtype->addItem(tr("PT100 with .00385 curve"),QVariant(1));
  14634. rtdtype->addItem(tr("PT1000 with .00385 curve"),QVariant(2));
  14635. rtdtype->addItem(tr("PT100 with .00392 curve"),QVariant(3));
  14636. rtdtype->addItem(tr("PT1000 with .00392 curve"),QVariant(4));
  14637. rtdconfigurationLayout->addRow(tr("RTD type:"),rtdtype);
  14638. rtdwiring->addItem(tr("2 wire"),QVariant(1));
  14639. rtdwiring->addItem(tr("3 wire"),QVariant(2));
  14640. rtdwiring->addItem(tr("4 wire"),QVariant(3));
  14641. rtdconfigurationLayout->addRow(tr("RTD wiring:"),rtdwiring);
  14642. rtdconfiguration->setLayout(rtdconfigurationLayout);
  14643. QWidget*tcconfiguration= new QWidget;
  14644. QFormLayout*tcconfigurationLayout= new QFormLayout;
  14645. tctype->addItem(tr("Type J"),QVariant(1));
  14646. tctype->addItem(tr("Type K"),QVariant(2));
  14647. tctype->addItem(tr("Type E"),QVariant(3));
  14648. tctype->addItem(tr("Type T"),QVariant(4));
  14649. tcconfigurationLayout->addRow(tr("Thermocouple type:"),tctype);
  14650. tcconfiguration->setLayout(tcconfigurationLayout);
  14651. subtypeLayout->addWidget(icconfiguration);
  14652. subtypeLayout->addWidget(rtdconfiguration);
  14653. subtypeLayout->addWidget(tcconfiguration);
  14654. /*816:*/
  14655. #line 16928 "./typica.w"
  14656. QDomElement referenceElement=
  14657. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14658. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14659. QDomElement node;
  14660. /*:816*/
  14661. #line 387 "./phidget22.w"
  14662. for(int i= 0;i<configData.size();i++)
  14663. {
  14664. node= configData.at(i).toElement();
  14665. if(node.attribute("name")=="serialnumber")
  14666. {
  14667. serialNumber->setText(node.attribute("value"));
  14668. }
  14669. else if(node.attribute("name")=="channel")
  14670. {
  14671. channel->setText(node.attribute("value"));
  14672. }
  14673. else if(node.attribute("name")=="columnname")
  14674. {
  14675. columnName->setText(node.attribute("value"));
  14676. }
  14677. else if(node.attribute("name")=="channeltype")
  14678. {
  14679. subtype->setCurrentIndex(subtype->
  14680. findData(QVariant(node.attribute("value").toInt())));
  14681. subtypeLayout->setCurrentIndex(subtype->currentIndex());
  14682. }
  14683. else if(node.attribute("name")=="tctype")
  14684. {
  14685. tctype->setCurrentIndex(tctype->
  14686. findData(QVariant(node.attribute("value").toInt())));
  14687. }
  14688. else if(node.attribute("name")=="rtdtype")
  14689. {
  14690. rtdtype->setCurrentIndex(rtdtype->
  14691. findData(QVariant(node.attribute("value").toInt())));
  14692. }
  14693. else if(node.attribute("name")=="rtdwiring")
  14694. {
  14695. rtdwiring->setCurrentIndex(rtdwiring->
  14696. findData(QVariant(node.attribute("value").toInt())));
  14697. }
  14698. else if(node.attribute("name")=="hubport")
  14699. {
  14700. hubPort->setText(node.attribute("value"));
  14701. }
  14702. else if(node.attribute("name")=="hidden")
  14703. {
  14704. hidden->setCheckState(node.attribute("value")=="true"?Qt::Checked:Qt::Unchecked);
  14705. }
  14706. }
  14707. outerLayout->addLayout(subtypeLayout);
  14708. setLayout(outerLayout);
  14709. updateSerialNumber(serialNumber->text());
  14710. updateChannel(channel->text());
  14711. updateColumnName(columnName->text());
  14712. updateChannelType(subtype->currentIndex());
  14713. updateTCType(tctype->currentIndex());
  14714. updateRTDType(rtdtype->currentIndex());
  14715. updateRTDWiring(rtdwiring->currentIndex());
  14716. updateHubPort(hubPort->text());
  14717. updateHidden(hidden->checkState());
  14718. connect(channelSelector,SIGNAL(currentIndexChanged(int)),
  14719. this,SLOT(changeSelectedChannel(int)));
  14720. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14721. subtypeLayout,SLOT(setCurrentIndex(int)));
  14722. connect(serialNumber,SIGNAL(textChanged(QString)),
  14723. this,SLOT(updateSerialNumber(QString)));
  14724. connect(channel,SIGNAL(textChanged(QString)),
  14725. this,SLOT(updateChannel(QString)));
  14726. connect(columnName,SIGNAL(textEdited(QString)),
  14727. this,SLOT(updateColumnName(QString)));
  14728. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14729. this,SLOT(updateChannelType(int)));
  14730. connect(tctype,SIGNAL(currentIndexChanged(int)),
  14731. this,SLOT(updateTCType(int)));
  14732. connect(rtdtype,SIGNAL(currentIndexChanged(int)),
  14733. this,SLOT(updateRTDType(int)));
  14734. connect(rtdwiring,SIGNAL(currentIndexChanged(int)),
  14735. this,SLOT(updateRTDWiring(int)));
  14736. connect(hubPort,SIGNAL(textChanged(QString)),
  14737. this,SLOT(updateHubPort(QString)));
  14738. connect(hidden,SIGNAL(stateChanged(int)),
  14739. this,SLOT(updateHidden(int)));
  14740. }
  14741. /*:996*//*997:*/
  14742. #line 471 "./phidget22.w"
  14743. void PhidgetChannelConfWidget::changeSelectedChannel(int index)
  14744. {
  14745. QMap<QString,QVariant> data= channelSelector->itemData(index).toMap();
  14746. serialNumber->setText(data.value("serialNumber").toString());
  14747. channel->setText(data.value("channel").toString());
  14748. subtype->setCurrentIndex(subtype->
  14749. findData(QVariant(data.value("subclass").toString().toInt())));
  14750. hubPort->setText(data.value("hubport").toString());
  14751. }
  14752. /*:997*//*998:*/
  14753. #line 484 "./phidget22.w"
  14754. void PhidgetChannelConfWidget::updateSerialNumber(const QString&value)
  14755. {
  14756. updateAttribute("serialnumber",value);
  14757. }
  14758. void PhidgetChannelConfWidget::updateChannel(const QString&value)
  14759. {
  14760. updateAttribute("channel",value);
  14761. }
  14762. void PhidgetChannelConfWidget::updateColumnName(const QString&value)
  14763. {
  14764. updateAttribute("columnname",value);
  14765. }
  14766. void PhidgetChannelConfWidget::updateChannelType(int value)
  14767. {
  14768. updateAttribute("channeltype",subtype->itemData(value).toString());
  14769. }
  14770. void PhidgetChannelConfWidget::updateTCType(int value)
  14771. {
  14772. updateAttribute("tctype",tctype->itemData(value).toString());
  14773. }
  14774. void PhidgetChannelConfWidget::updateRTDType(int value)
  14775. {
  14776. updateAttribute("rtdtype",rtdtype->itemData(value).toString());
  14777. }
  14778. void PhidgetChannelConfWidget::updateRTDWiring(int value)
  14779. {
  14780. updateAttribute("rtdwiring",rtdwiring->itemData(value).toString());
  14781. }
  14782. void PhidgetChannelConfWidget::updateHubPort(const QString&value)
  14783. {
  14784. updateAttribute("hubport",value);
  14785. }
  14786. void PhidgetChannelConfWidget::updateHidden(int value)
  14787. {
  14788. updateAttribute("hidden",value==0?"false":"true");
  14789. }
  14790. /*:998*//*1001:*/
  14791. #line 593 "./phidget22.w"
  14792. Phidget22::Phidget22(const QModelIndex&index):QObject(NULL)
  14793. {
  14794. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14795. if(model->hasChildren(index))
  14796. {
  14797. for(int i= 0;i<model->rowCount(index);i++)
  14798. {
  14799. QModelIndex channelIndex= model->index(i,0,index);
  14800. QDomElement channelReference= model->
  14801. referenceElement(model->data(channelIndex,32).toString());
  14802. QDomElement channelReferenceElement= model->
  14803. referenceElement(model->
  14804. data(channelIndex,Qt::UserRole).toString());
  14805. QDomNodeList channelConfigData=
  14806. channelReferenceElement.elementsByTagName("attribute");
  14807. PhidgetChannelData*c= new PhidgetChannelData;
  14808. c->channel= new Channel;
  14809. c->indicatorLabel=
  14810. model->data(channelIndex,Qt::DisplayRole).toString();
  14811. c->device= NULL;
  14812. c->hubPort= -1;
  14813. for(int j= 0;j<channelConfigData.size();j++)
  14814. {
  14815. QDomElement node= channelConfigData.at(j).toElement();
  14816. if(node.attribute("name")=="serialnumber")
  14817. {
  14818. c->serialNumber= node.attribute("value").toInt();
  14819. }
  14820. else if(node.attribute("name")=="channel")
  14821. {
  14822. c->channelNumber= node.attribute("value").toInt();
  14823. }
  14824. else if(node.attribute("name")=="channeltype")
  14825. {
  14826. c->channelType= node.attribute("value").toInt();
  14827. }
  14828. else if(node.attribute("name")=="tctype")
  14829. {
  14830. c->tcType= node.attribute("value").toInt();
  14831. }
  14832. else if(node.attribute("name")=="rtdtype")
  14833. {
  14834. c->rtdType= node.attribute("value").toInt();
  14835. }
  14836. else if(node.attribute("name")=="rtdwiring")
  14837. {
  14838. c->wiring= node.attribute("value").toInt();
  14839. }
  14840. else if(node.attribute("name")=="hidden")
  14841. {
  14842. c->hidden= (node.attribute("value")=="true");
  14843. }
  14844. else if(node.attribute("name")=="columnname")
  14845. {
  14846. c->columnName= node.attribute("value");
  14847. }
  14848. else if(node.attribute("name")=="hubport")
  14849. {
  14850. c->hubPort= node.attribute("value").toInt();
  14851. }
  14852. }
  14853. channelConfiguration.append(c);
  14854. }
  14855. }
  14856. }
  14857. /*:1001*//*1002:*/
  14858. #line 663 "./phidget22.w"
  14859. int Phidget22::channelCount()
  14860. {
  14861. return channelConfiguration.length();
  14862. }
  14863. Channel*Phidget22::getChannel(int channel)
  14864. {
  14865. return channelConfiguration.at(channel)->channel;
  14866. }
  14867. /*:1002*//*1003:*/
  14868. #line 677 "./phidget22.w"
  14869. bool Phidget22::isChannelHidden(int channel)
  14870. {
  14871. return channelConfiguration.at(channel)->hidden;
  14872. }
  14873. QString Phidget22::channelColumnName(int channel)
  14874. {
  14875. return channelConfiguration.at(channel)->columnName;
  14876. }
  14877. QString Phidget22::channelIndicatorText(int channel)
  14878. {
  14879. return channelConfiguration.at(channel)->indicatorLabel;
  14880. }
  14881. /*:1003*//*1004:*/
  14882. #line 696 "./phidget22.w"
  14883. void Phidget22::start()
  14884. {
  14885. #if __APPLE__
  14886. driver.setFileName("Phidget22.framework/Phidget22");
  14887. #else
  14888. driver.setFileName("phidget22");
  14889. #endif
  14890. if(!driver.load())
  14891. {
  14892. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14893. tr("Failed to find phidget22. Please install it."));
  14894. return;
  14895. }
  14896. if((p_createTemperatureSensor= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_create"))==0||
  14897. (p_setSerialNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setDeviceSerialNumber"))==0||
  14898. (p_setChannelNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setChannel"))==0||
  14899. (p_setTCType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setThermocoupleType"))==0||
  14900. (p_setRTDType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDType"))==0||
  14901. (p_setRTDWiring= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDWireSetup"))==0||
  14902. (p_setNewDataCallback= (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler"))==0||
  14903. (p_open= (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment"))==0||
  14904. (p_close= (PhidgetPointer)driver.resolve("Phidget_close"))==0||
  14905. (p_delete= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_delete"))==0||
  14906. (p_setHubPort= (PhidgetPointerIntIn)driver.resolve("Phidget_setHubPort"))==0)
  14907. {
  14908. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14909. tr("Failed to link a required symbol in phidget22."));
  14910. return;
  14911. }
  14912. for(int i= 0;i<channelConfiguration.length();i++)
  14913. {
  14914. PhidgetChannelData*c= channelConfiguration.at(i);
  14915. p_createTemperatureSensor(&(c->device));
  14916. p_setSerialNumber(c->device,c->serialNumber);
  14917. p_setChannelNumber(c->device,c->channelNumber);
  14918. switch(c->channelType)
  14919. {
  14920. case 32:
  14921. p_setRTDType(c->device,c->rtdType);
  14922. p_setRTDWiring(c->device,c->wiring);
  14923. break;
  14924. case 33:
  14925. p_setTCType(c->device,c->tcType);
  14926. break;
  14927. default:
  14928. break;
  14929. }
  14930. if(c->hubPort>=0)
  14931. {
  14932. p_setHubPort(c->device,c->hubPort);
  14933. }
  14934. p_setNewDataCallback(c->device,Phidget22ValueCallback,c->channel);
  14935. p_open(c->device,5000);
  14936. }
  14937. }
  14938. /*:1004*//*1007:*/
  14939. #line 779 "./phidget22.w"
  14940. void Phidget22::stop()
  14941. {
  14942. for(int i= 0;i<channelConfiguration.length();i++)
  14943. {
  14944. PhidgetChannelData*c= channelConfiguration.at(i);
  14945. p_close(c->device);
  14946. p_delete(&(c->device));
  14947. }
  14948. }
  14949. /*:1007*/
  14950. #line 793 "./phidget22.w"
  14951. /*:1008*//*1022:*/
  14952. #line 20122 "./typica.w"
  14953. /*1020:*/
  14954. #line 20084 "./typica.w"
  14955. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  14956. const QModelIndex&index)
  14957. :BasicDeviceConfigurationWidget(model,index)
  14958. {
  14959. QHBoxLayout*layout= new QHBoxLayout;
  14960. QLabel*label= new QLabel(tr("Cooling Time: "));
  14961. QTimeEdit*editor= new QTimeEdit;
  14962. editor->setDisplayFormat("mm:ss");
  14963. /*816:*/
  14964. #line 16928 "./typica.w"
  14965. QDomElement referenceElement=
  14966. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14967. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14968. QDomElement node;
  14969. /*:816*/
  14970. #line 20093 "./typica.w"
  14971. for(int i= 0;i<configData.size();i++)
  14972. {
  14973. node= configData.at(i).toElement();
  14974. if(node.attribute("name")=="reset")
  14975. {
  14976. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  14977. }
  14978. }
  14979. updateResetTime(editor->time());
  14980. connect(editor,SIGNAL(timeChanged(QTime)),
  14981. this,SLOT(updateResetTime(QTime)));
  14982. layout->addWidget(label);
  14983. layout->addWidget(editor);
  14984. setLayout(layout);
  14985. }
  14986. void CoolingTimerConfWidget::updateResetTime(QTime time)
  14987. {
  14988. updateAttribute("reset",time.toString("mm:ss"));
  14989. }
  14990. /*:1020*/
  14991. #line 20123 "./typica.w"
  14992. /*:1022*//*1027:*/
  14993. #line 20381 "./typica.w"
  14994. /*1024:*/
  14995. #line 20155 "./typica.w"
  14996. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14997. :BasicDeviceConfigurationWidget(model,index)
  14998. {
  14999. QVBoxLayout*layout= new QVBoxLayout;
  15000. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  15001. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  15002. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  15003. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  15004. QButtonGroup*startOptionGroup= new QButtonGroup;
  15005. startOptionGroup->addButton(startBatchOption,1);
  15006. startOptionGroup->addButton(buttonOption,2);
  15007. startOptionGroup->addButton(thresholdOption,3);
  15008. startBatchOption->setChecked(true);
  15009. QGridLayout*startOptions= new QGridLayout;
  15010. startOptions->addWidget(startBatchOption,0,0);
  15011. startOptions->addWidget(buttonOption,1,0);
  15012. startOptions->addWidget(thresholdOption,2,0);
  15013. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  15014. QLineEdit*buttonTextEdit= new QLineEdit;
  15015. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  15016. buttonTextOptions->addWidget(buttonTextLabel);
  15017. buttonTextOptions->addWidget(buttonTextEdit);
  15018. startOptions->addLayout(buttonTextOptions,1,1);
  15019. QFormLayout*thresholdOptions= new QFormLayout;
  15020. QLineEdit*startColumnName= new QLineEdit;
  15021. QLineEdit*startValue= new QLineEdit;
  15022. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  15023. thresholdOptions->addRow(tr("Value: "),startValue);
  15024. startOptions->addLayout(thresholdOptions,2,1);
  15025. startConfigurationGroup->setLayout(startOptions);
  15026. layout->addWidget(startConfigurationGroup);
  15027. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  15028. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  15029. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  15030. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  15031. QButtonGroup*stopOptionGroup= new QButtonGroup;
  15032. stopOptionGroup->addButton(stopBatchOption,1);
  15033. stopOptionGroup->addButton(stopButtonOption,2);
  15034. stopOptionGroup->addButton(stopThresholdOption,3);
  15035. stopBatchOption->setChecked(true);
  15036. QGridLayout*stopOptions= new QGridLayout;
  15037. stopOptions->addWidget(stopBatchOption,0,0);
  15038. stopOptions->addWidget(stopButtonOption,1,0);
  15039. stopOptions->addWidget(stopThresholdOption,2,0);
  15040. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  15041. QLineEdit*stopButtonEdit= new QLineEdit;
  15042. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  15043. stopButtonTextOptions->addWidget(stopButtonLabel);
  15044. stopButtonTextOptions->addWidget(stopButtonEdit);
  15045. stopOptions->addLayout(stopButtonTextOptions,1,1);
  15046. QLineEdit*stopColumnName= new QLineEdit;
  15047. QLineEdit*stopValue= new QLineEdit;
  15048. QFormLayout*stopThresholdOptions= new QFormLayout;
  15049. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  15050. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  15051. stopOptions->addLayout(stopThresholdOptions,2,1);
  15052. stopConfigurationGroup->setLayout(stopOptions);
  15053. layout->addWidget(stopConfigurationGroup);
  15054. /*816:*/
  15055. #line 16928 "./typica.w"
  15056. QDomElement referenceElement=
  15057. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15058. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15059. QDomElement node;
  15060. /*:816*/
  15061. #line 20217 "./typica.w"
  15062. for(int i= 0;i<configData.size();i++)
  15063. {
  15064. node= configData.at(i).toElement();
  15065. if(node.attribute("name")=="startbuttontext")
  15066. {
  15067. buttonTextEdit->setText(node.attribute("value"));
  15068. }
  15069. else if(node.attribute("name")=="stopbuttontext")
  15070. {
  15071. stopButtonEdit->setText(node.attribute("value"));
  15072. }
  15073. else if(node.attribute("name")=="startcolumnname")
  15074. {
  15075. startColumnName->setText(node.attribute("value"));
  15076. }
  15077. else if(node.attribute("name")=="stopcolumnname")
  15078. {
  15079. stopColumnName->setText(node.attribute("value"));
  15080. }
  15081. else if(node.attribute("name")=="startvalue")
  15082. {
  15083. startValue->setText(node.attribute("value"));
  15084. }
  15085. else if(node.attribute("name")=="stopvalue")
  15086. {
  15087. stopValue->setText(node.attribute("value"));
  15088. }
  15089. else if(node.attribute("name")=="starttrigger")
  15090. {
  15091. if(node.attribute("value")=="batch")
  15092. {
  15093. startBatchOption->setChecked(true);
  15094. }
  15095. else if(node.attribute("value")=="manual")
  15096. {
  15097. buttonOption->setChecked(true);
  15098. }
  15099. else if(node.attribute("value")=="value")
  15100. {
  15101. thresholdOption->setChecked(true);
  15102. }
  15103. }
  15104. else if(node.attribute("name")=="stoptrigger")
  15105. {
  15106. if(node.attribute("value")=="batch")
  15107. {
  15108. stopBatchOption->setChecked(true);
  15109. }
  15110. else if(node.attribute("value")=="manual")
  15111. {
  15112. stopButtonOption->setChecked(true);
  15113. }
  15114. else if(node.attribute("value")=="value")
  15115. {
  15116. stopThresholdOption->setChecked(true);
  15117. }
  15118. }
  15119. }
  15120. updateStartButtonText(buttonTextEdit->text());
  15121. updateStopButtonText(stopButtonEdit->text());
  15122. updateStartColumnName(startColumnName->text());
  15123. updateStopColumnName(stopColumnName->text());
  15124. updateStartValue(startValue->text());
  15125. updateStopValue(stopValue->text());
  15126. updateStartTrigger(startOptionGroup->checkedId());
  15127. updateStopTrigger(stopOptionGroup->checkedId());
  15128. setLayout(layout);
  15129. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  15130. this,SLOT(updateStartButtonText(QString)));
  15131. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  15132. this,SLOT(updateStopButtonText(QString)));
  15133. connect(startColumnName,SIGNAL(textChanged(QString)),
  15134. this,SLOT(updateStartColumnName(QString)));
  15135. connect(stopColumnName,SIGNAL(textChanged(QString)),
  15136. this,SLOT(updateStopColumnName(QString)));
  15137. connect(startValue,SIGNAL(textChanged(QString)),
  15138. this,SLOT(updateStartValue(QString)));
  15139. connect(stopValue,SIGNAL(textChanged(QString)),
  15140. this,SLOT(updateStopValue(QString)));
  15141. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  15142. this,SLOT(updateStartTrigger(int)));
  15143. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  15144. this,SLOT(updateStopTrigger(int)));
  15145. }
  15146. /*:1024*//*1025:*/
  15147. #line 20307 "./typica.w"
  15148. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  15149. {
  15150. updateAttribute("startbuttontext",text);
  15151. }
  15152. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  15153. {
  15154. updateAttribute("stopbuttontext",text);
  15155. }
  15156. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  15157. {
  15158. updateAttribute("startcolumnname",text);
  15159. }
  15160. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  15161. {
  15162. updateAttribute("stopcolumnname",text);
  15163. }
  15164. void RangeTimerConfWidget::updateStartValue(const QString&text)
  15165. {
  15166. updateAttribute("startvalue",text);
  15167. }
  15168. void RangeTimerConfWidget::updateStopValue(const QString&text)
  15169. {
  15170. updateAttribute("stopvalue",text);
  15171. }
  15172. void RangeTimerConfWidget::updateStartTrigger(int option)
  15173. {
  15174. switch(option)
  15175. {
  15176. case 1:
  15177. updateAttribute("starttrigger","batch");
  15178. break;
  15179. case 2:
  15180. updateAttribute("starttrigger","manual");
  15181. break;
  15182. case 3:
  15183. updateAttribute("starttrigger","value");
  15184. break;
  15185. default:
  15186. break;
  15187. }
  15188. }
  15189. void RangeTimerConfWidget::updateStopTrigger(int option)
  15190. {
  15191. switch(option)
  15192. {
  15193. case 1:
  15194. updateAttribute("stoptrigger","batch");
  15195. break;
  15196. case 2:
  15197. updateAttribute("stoptrigger","manual");
  15198. break;
  15199. case 3:
  15200. updateAttribute("stoptrigger","value");
  15201. break;
  15202. default:
  15203. break;
  15204. }
  15205. }
  15206. /*:1025*/
  15207. #line 20382 "./typica.w"
  15208. /*:1027*//*1032:*/
  15209. #line 20482 "./typica.w"
  15210. /*1029:*/
  15211. #line 20406 "./typica.w"
  15212. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  15213. const QModelIndex&index)
  15214. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  15215. {
  15216. QFormLayout*layout= new QFormLayout;
  15217. QLineEdit*trigger= new QLineEdit;
  15218. layout->addRow(tr("Trigger column name:"),trigger);
  15219. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  15220. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  15221. QTableView*rangeTable= new QTableView;
  15222. rangeTable->setModel(tablemodel);
  15223. layout->addRow(tr("Range data:"),rangeTable);
  15224. /*816:*/
  15225. #line 16928 "./typica.w"
  15226. QDomElement referenceElement=
  15227. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15228. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15229. QDomElement node;
  15230. /*:816*/
  15231. #line 20419 "./typica.w"
  15232. for(int i= 0;i<configData.size();i++)
  15233. {
  15234. node= configData.at(i).toElement();
  15235. if(node.attribute("name")=="trigger")
  15236. {
  15237. trigger->setText(node.attribute("value"));
  15238. }
  15239. else if(node.attribute("name")=="rangenames")
  15240. {
  15241. QString data= node.attribute("value");
  15242. if(data.length()> 3)
  15243. {
  15244. data.chop(2);
  15245. data= data.remove(0,2);
  15246. }
  15247. QStringList itemList= data.split(", ");
  15248. for(int j= 0;j<itemList.size();j++)
  15249. {
  15250. QString item= itemList.at(j);
  15251. item.chop(1);
  15252. item= item.remove(0,1);
  15253. tablemodel->setData(tablemodel->index(j,0),
  15254. QVariant(item),Qt::DisplayRole);
  15255. }
  15256. }
  15257. else if(node.attribute("name")=="endtemps")
  15258. {
  15259. /*1015:*/
  15260. #line 20014 "./typica.w"
  15261. QString data= node.attribute("value");
  15262. if(data.length()> 3)
  15263. {
  15264. data.chop(2);
  15265. data= data.remove(0,2);
  15266. }
  15267. QStringList itemList= data.split(",");
  15268. /*:1015*/
  15269. #line 20447 "./typica.w"
  15270. int column= 1;
  15271. /*1016:*/
  15272. #line 20026 "./typica.w"
  15273. for(int j= 0;j<itemList.size();j++)
  15274. {
  15275. tablemodel->setData(tablemodel->index(j,column),
  15276. QVariant(itemList.at(j).toDouble()),
  15277. Qt::DisplayRole);
  15278. }
  15279. /*:1016*/
  15280. #line 20449 "./typica.w"
  15281. }
  15282. }
  15283. updateColumnName(trigger->text());
  15284. updateRangeData();
  15285. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  15286. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  15287. setLayout(layout);
  15288. }
  15289. /*:1029*//*1030:*/
  15290. #line 20463 "./typica.w"
  15291. void MultiRangeTimerConfWidget::updateRangeData()
  15292. {
  15293. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  15294. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  15295. }
  15296. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  15297. {
  15298. updateAttribute("trigger",text);
  15299. }
  15300. /*:1030*/
  15301. #line 20483 "./typica.w"
  15302. /*:1032*//*1050:*/
  15303. #line 265 "./rate.w"
  15304. /*1046:*/
  15305. #line 191 "./rate.w"
  15306. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  15307. :BasicDeviceConfigurationWidget(model,index)
  15308. {
  15309. QFormLayout*layout= new QFormLayout;
  15310. QLineEdit*column= new QLineEdit;
  15311. layout->addRow(tr("Primary series column name:"),column);
  15312. QSpinBox*cacheTime= new QSpinBox;
  15313. cacheTime->setMinimum(0);
  15314. cacheTime->setMaximum(300);
  15315. layout->addRow(tr("Cache time:"),cacheTime);
  15316. QSpinBox*scaleTime= new QSpinBox;
  15317. scaleTime->setMinimum(1);
  15318. scaleTime->setMaximum(300);
  15319. layout->addRow(tr("Scale time:"),scaleTime);
  15320. /*816:*/
  15321. #line 16928 "./typica.w"
  15322. QDomElement referenceElement=
  15323. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15324. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15325. QDomElement node;
  15326. /*:816*/
  15327. #line 206 "./rate.w"
  15328. for(int i= 0;i<configData.size();i++)
  15329. {
  15330. node= configData.at(i).toElement();
  15331. if(node.attribute("name")=="column")
  15332. {
  15333. column->setText(node.attribute("value"));
  15334. }
  15335. else if(node.attribute("name")=="cache")
  15336. {
  15337. cacheTime->setValue(node.attribute("value").toInt());
  15338. }
  15339. else if(node.attribute("name")=="scale")
  15340. {
  15341. scaleTime->setValue(node.attribute("value").toInt());
  15342. }
  15343. }
  15344. updateColumn(column->text());
  15345. updateCacheTime(cacheTime->text());
  15346. updateScaleTime(scaleTime->text());
  15347. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  15348. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  15349. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  15350. setLayout(layout);
  15351. }
  15352. /*:1046*//*1047:*/
  15353. #line 235 "./rate.w"
  15354. void RateOfChangeConfWidget::updateColumn(const QString&column)
  15355. {
  15356. updateAttribute("column",column);
  15357. }
  15358. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  15359. {
  15360. updateAttribute("cache",seconds);
  15361. }
  15362. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  15363. {
  15364. updateAttribute("scale",seconds);
  15365. }
  15366. /*:1047*/
  15367. #line 266 "./rate.w"
  15368. #line 20590 "./typica.w"
  15369. #line 1 "./mergeseries.w"
  15370. /*:1050*//*1064:*/
  15371. #line 282 "./mergeseries.w"
  15372. /*1060:*/
  15373. #line 183 "./mergeseries.w"
  15374. MergeSeriesConfWidget::MergeSeriesConfWidget(DeviceTreeModel*model,
  15375. const QModelIndex&index)
  15376. :BasicDeviceConfigurationWidget(model,index)
  15377. {
  15378. QFormLayout*layout= new QFormLayout;
  15379. QComboBox*type= new QComboBox;
  15380. type->addItem(tr("Difference"),QVariant("Difference"));
  15381. type->addItem(tr("Mean"),QVariant("Mean"));
  15382. layout->addRow(tr("Series type:"),type);
  15383. QLineEdit*column1= new QLineEdit;
  15384. layout->addRow(tr("First input column name:"),column1);
  15385. QLineEdit*column2= new QLineEdit;
  15386. layout->addRow(tr("Second input column name:"),column2);
  15387. QLineEdit*output= new QLineEdit;
  15388. layout->addRow(tr("Output column name:"),output);
  15389. /*816:*/
  15390. #line 16928 "./typica.w"
  15391. QDomElement referenceElement=
  15392. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15393. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15394. QDomElement node;
  15395. /*:816*/
  15396. #line 199 "./mergeseries.w"
  15397. for(int i= 0;i<configData.size();i++)
  15398. {
  15399. node= configData.at(i).toElement();
  15400. if(node.attribute("name")=="type")
  15401. {
  15402. type->setCurrentIndex(type->findData(node.attribute("value")));
  15403. }
  15404. else if(node.attribute("name")=="column1")
  15405. {
  15406. column1->setText(node.attribute("value"));
  15407. }
  15408. else if(node.attribute("name")=="column2")
  15409. {
  15410. column2->setText(node.attribute("value"));
  15411. }
  15412. else if(node.attribute("name")=="output")
  15413. {
  15414. output->setText(node.attribute("value"));
  15415. }
  15416. }
  15417. updateColumn1(column1->text());
  15418. updateColumn2(column2->text());
  15419. updateOutput(output->text());
  15420. updateType(type->currentIndex());
  15421. connect(column1,SIGNAL(textEdited(QString)),this,SLOT(updateColumn1(QString)));
  15422. connect(column2,SIGNAL(textEdited(QString)),this,SLOT(updateColumn2(QString)));
  15423. connect(output,SIGNAL(textEdited(QString)),this,SLOT(updateOutput(QString)));
  15424. connect(type,SIGNAL(currentIndexChanged(int)),this,SLOT(updateType(int)));
  15425. setLayout(layout);
  15426. }
  15427. /*:1060*//*1061:*/
  15428. #line 233 "./mergeseries.w"
  15429. void MergeSeriesConfWidget::updateColumn1(const QString&column)
  15430. {
  15431. updateAttribute("column1",column);
  15432. }
  15433. void MergeSeriesConfWidget::updateColumn2(const QString&column)
  15434. {
  15435. updateAttribute("column2",column);
  15436. }
  15437. void MergeSeriesConfWidget::updateOutput(const QString&column)
  15438. {
  15439. updateAttribute("output",column);
  15440. }
  15441. void MergeSeriesConfWidget::updateType(int index)
  15442. {
  15443. switch(index)
  15444. {
  15445. case 0:
  15446. updateAttribute("type","Difference");
  15447. break;
  15448. case 1:
  15449. updateAttribute("type","Mean");
  15450. break;
  15451. default:
  15452. break;
  15453. }
  15454. }
  15455. /*:1061*/
  15456. #line 283 "./mergeseries.w"
  15457. /*1052:*/
  15458. #line 59 "./mergeseries.w"
  15459. void MergeSeries::in1(Measurement measure)
  15460. {
  15461. last1= measure;
  15462. received1= true;
  15463. if(received1&&received2)
  15464. {
  15465. calculate(last1,last2);
  15466. received1= false;
  15467. received2= false;
  15468. }
  15469. }
  15470. void MergeSeries::in2(Measurement measure)
  15471. {
  15472. last2= measure;
  15473. received2= true;
  15474. if(received1&&received2)
  15475. {
  15476. calculate(last1,last2);
  15477. received1= false;
  15478. received2= false;
  15479. }
  15480. }
  15481. /*:1052*//*1053:*/
  15482. #line 86 "./mergeseries.w"
  15483. MergeSeries::MergeSeries():QObject(NULL),received1(false),received2(false)
  15484. {
  15485. }
  15486. /*:1053*//*1054:*/
  15487. #line 97 "./mergeseries.w"
  15488. void DifferenceSeries::calculate(Measurement m1,Measurement m2)
  15489. {
  15490. Measurement outval(m1.temperature()-m2.temperature(),
  15491. (m1.time()> m2.time()?m1.time():m2.time()));
  15492. outval.insert("relative",true);
  15493. emit newData(outval);
  15494. }
  15495. void MeanSeries::calculate(Measurement m1,Measurement m2)
  15496. {
  15497. Measurement outval((m1.temperature()+m2.temperature())/2,
  15498. (m1.time()> m2.time()?m1.time():m2.time()));
  15499. emit newData(outval);
  15500. }
  15501. /*:1054*//*1055:*/
  15502. #line 115 "./mergeseries.w"
  15503. DifferenceSeries::DifferenceSeries():MergeSeries()
  15504. {
  15505. }
  15506. MeanSeries::MeanSeries():MergeSeries()
  15507. {
  15508. }
  15509. /*:1055*/
  15510. #line 284 "./mergeseries.w"
  15511. #line 20592 "./typica.w"
  15512. #line 1 "./dataqsdk.w"
  15513. /*:1064*//*1179:*/
  15514. #line 344 "./user.w"
  15515. /*1174:*/
  15516. #line 232 "./user.w"
  15517. NewTypicaUser::NewTypicaUser():QDialog(),
  15518. userField(new QLineEdit),passwordField(new QLineEdit),
  15519. autoLogin(new QCheckBox(tr("Log in automatically"))),
  15520. saveAndCloseButton(new QPushButton(tr("Save and Close"))),
  15521. saveAndNewButton(new QPushButton(tr("Save and Create Another"))),
  15522. cancelButton(new QPushButton(tr("Cancel")))
  15523. {
  15524. setModal(true);
  15525. QVBoxLayout*mainLayout= new QVBoxLayout;
  15526. QFormLayout*form= new QFormLayout;
  15527. QHBoxLayout*buttons= new QHBoxLayout;
  15528. form->addRow(tr("Name:"),userField);
  15529. passwordField->setEchoMode(QLineEdit::Password);
  15530. form->addRow(tr("Password:"),passwordField);
  15531. form->addRow(autoLogin);
  15532. buttons->addWidget(cancelButton);
  15533. buttons->addStretch();
  15534. buttons->addWidget(saveAndNewButton);
  15535. buttons->addWidget(saveAndCloseButton);
  15536. mainLayout->addLayout(form);
  15537. mainLayout->addLayout(buttons);
  15538. setLayout(mainLayout);
  15539. setWindowTitle(tr("Create New User"));
  15540. connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
  15541. connect(saveAndCloseButton,SIGNAL(clicked()),this,SLOT(createAndClose()));
  15542. connect(saveAndNewButton,SIGNAL(clicked()),this,SLOT(createAndReset()));
  15543. connect(userField,SIGNAL(textChanged(QString)),this,SLOT(validate()));
  15544. }
  15545. /*:1174*//*1175:*/
  15546. #line 264 "./user.w"
  15547. void NewTypicaUser::createAndReset()
  15548. {
  15549. createNewUser();
  15550. userField->setText("");
  15551. passwordField->setText("");
  15552. autoLogin->setChecked(false);
  15553. }
  15554. void NewTypicaUser::createAndClose()
  15555. {
  15556. createNewUser();
  15557. accept();
  15558. }
  15559. void NewTypicaUser::createNewUser()
  15560. {
  15561. SqlQueryConnection h;
  15562. QSqlQuery*dbquery= h.operator->();
  15563. dbquery->prepare("INSERT INTO typica_users (name, password, active, auto_login) VALUES (:name, :password, true, :auto)");
  15564. dbquery->bindValue(":name",userField->text());
  15565. dbquery->bindValue(":password",passwordField->text());
  15566. dbquery->bindValue(":auto",autoLogin->isChecked());
  15567. dbquery->exec();
  15568. cancelButton->setEnabled(true);
  15569. }
  15570. void NewTypicaUser::validate()
  15571. {
  15572. if(!userField->text().isEmpty())
  15573. {
  15574. saveAndCloseButton->setEnabled(true);
  15575. saveAndNewButton->setEnabled(true);
  15576. }
  15577. else
  15578. {
  15579. saveAndCloseButton->setEnabled(false);
  15580. saveAndNewButton->setEnabled(false);
  15581. }
  15582. }
  15583. void NewTypicaUser::cancelValidate()
  15584. {
  15585. SqlQueryConnection h;
  15586. QSqlQuery*dbquery= h.operator->();
  15587. dbquery->exec("SELECT count(1) FROM typica_users");
  15588. if(dbquery->next())
  15589. {
  15590. if(dbquery->value(0).toInt()> 0)
  15591. {
  15592. cancelButton->setEnabled(true);
  15593. return;
  15594. }
  15595. }
  15596. cancelButton->setEnabled(false);
  15597. }
  15598. /*:1175*/
  15599. #line 345 "./user.w"
  15600. /*1170:*/
  15601. #line 177 "./user.w"
  15602. UserLabel::UserLabel():QLabel()
  15603. {
  15604. setTextFormat(Qt::PlainText);
  15605. updateLabel(AppInstance->currentTypicaUser());
  15606. connect(AppInstance,SIGNAL(userChanged(QString)),
  15607. this,SLOT(updateLabel(QString)));
  15608. }
  15609. /*:1170*//*1171:*/
  15610. #line 188 "./user.w"
  15611. void UserLabel::updateLabel(const QString&user)
  15612. {
  15613. setText(QString(tr("Current operator: %1").arg(user)));
  15614. }
  15615. /*:1171*//*1172:*/
  15616. #line 196 "./user.w"
  15617. void UserLabel::mouseReleaseEvent(QMouseEvent*)
  15618. {
  15619. LoginDialog*dialog= new LoginDialog;
  15620. dialog->exec();
  15621. }
  15622. /*:1172*/
  15623. #line 346 "./user.w"
  15624. /*1164:*/
  15625. #line 95 "./user.w"
  15626. LoginDialog::LoginDialog():QDialog(),
  15627. user(new QLineEdit),password(new QLineEdit),
  15628. warning(new QLabel(tr("Log in failed."))),
  15629. login(new QPushButton(tr("Log In")))
  15630. {
  15631. setModal(true);
  15632. QVBoxLayout*mainLayout= new QVBoxLayout;
  15633. warning->setVisible(false);
  15634. password->setEchoMode(QLineEdit::Password);
  15635. QFormLayout*form= new QFormLayout;
  15636. form->addRow(tr("Name:"),user);
  15637. form->addRow(tr("Password:"),password);
  15638. form->addRow(warning);
  15639. QHBoxLayout*buttonBox= new QHBoxLayout;
  15640. buttonBox->addStretch();
  15641. buttonBox->addWidget(login);
  15642. mainLayout->addLayout(form);
  15643. mainLayout->addLayout(buttonBox);
  15644. connect(login,SIGNAL(clicked()),this,SLOT(attemptLogin()));
  15645. setLayout(mainLayout);
  15646. }
  15647. /*:1164*//*1165:*/
  15648. #line 120 "./user.w"
  15649. void LoginDialog::attemptLogin()
  15650. {
  15651. if(AppInstance->login(user->text(),password->text()))
  15652. {
  15653. accept();
  15654. }
  15655. else
  15656. {
  15657. warning->setVisible(true);
  15658. }
  15659. }
  15660. /*:1165*/
  15661. #line 347 "./user.w"
  15662. #line 20602 "./typica.w"
  15663. #line 1 "./roastcoloredit.w"
  15664. /*:1179*//*1187:*/
  15665. #line 149 "./roastcoloredit.w"
  15666. /*1181:*/
  15667. #line 31 "./roastcoloredit.w"
  15668. RoastColorEdit::RoastColorEdit():edit(new QLineEdit)
  15669. {
  15670. QHBoxLayout*layout= new QHBoxLayout;
  15671. layout->setContentsMargins(0,0,0,0);
  15672. layout->addWidget(edit);
  15673. QSettings settings;
  15674. if(settings.value("settings/color/javalytics/enable",false).toBool())
  15675. {
  15676. QPushButton*button= new QPushButton(tr("Measure"));
  15677. layout->addWidget(button);
  15678. connect(button,SIGNAL(clicked()),this,SLOT(readColor()));
  15679. }
  15680. setLayout(layout);
  15681. }
  15682. /*:1181*//*1182:*/
  15683. #line 50 "./roastcoloredit.w"
  15684. void RoastColorEdit::readColor()
  15685. {
  15686. QSettings settings;
  15687. QUrl postData;
  15688. postData.addQueryItem("calscale",settings.value("settings/color/javalytics/scale",1).toString());
  15689. postData.addQueryItem("webcontrol","20");
  15690. QNetworkRequest request(QUrl("http://"+settings.value("settings/color/javalytics/address","192.168.1.10").toString()+"/index.zhtml"));
  15691. request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
  15692. networkReply= AppInstance->network->post(request,postData.encodedQuery());
  15693. connect(networkReply,SIGNAL(finished()),this,SLOT(measureFinished()));
  15694. }
  15695. /*:1182*//*1183:*/
  15696. #line 66 "./roastcoloredit.w"
  15697. void RoastColorEdit::measureFinished()
  15698. {
  15699. QSettings settings;
  15700. networkReply->deleteLater();
  15701. networkReply= AppInstance->network->get(QNetworkRequest(QUrl("http://"+settings.value("settings/color/javalytics/address","192.168.1.10").toString()+"/data.csv")));
  15702. connect(networkReply,SIGNAL(finished()),this,SLOT(readFinished()));
  15703. }
  15704. /*:1183*//*1184:*/
  15705. #line 93 "./roastcoloredit.w"
  15706. void RoastColorEdit::readFinished()
  15707. {
  15708. QByteArray response= networkReply->readAll();
  15709. networkReply->deleteLater();
  15710. networkReply= 0;
  15711. if(response.size()==0)
  15712. {
  15713. return;
  15714. }
  15715. QList<QByteArray> lines= response.split('\n');
  15716. if(lines.last().size()==0)
  15717. {
  15718. lines.removeLast();
  15719. }
  15720. if(lines.size()==0)
  15721. {
  15722. return;
  15723. }
  15724. QList<QByteArray> fields= lines.last().split(',');
  15725. if(fields.size()<3)
  15726. {
  15727. return;
  15728. }
  15729. edit->setText(QString(fields.at(2)));
  15730. }
  15731. /*:1184*//*1185:*/
  15732. #line 122 "./roastcoloredit.w"
  15733. void RoastColorEdit::setValue(const QString&color)
  15734. {
  15735. edit->setText(color);
  15736. }
  15737. QString RoastColorEdit::value()
  15738. {
  15739. return edit->text();
  15740. }
  15741. /*:1185*/
  15742. #line 150 "./roastcoloredit.w"
  15743. #line 20604 "./typica.w"
  15744. /*:1187*/
  15745. #line 532 "./typica.w"
  15746. /*8:*/
  15747. #line 679 "./typica.w"
  15748. template<class TYPE> TYPE getself(QScriptContext*context)
  15749. {
  15750. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  15751. return self;
  15752. }
  15753. template<> QTime getself(QScriptContext*context)
  15754. {
  15755. QTime self= context->thisObject().toVariant().toTime();
  15756. return self;
  15757. }
  15758. template<> QByteArray getself(QScriptContext*context)
  15759. {
  15760. QByteArray self= context->thisObject().toVariant().toByteArray();
  15761. return self;
  15762. }
  15763. template<> SqlQueryConnection*getself(QScriptContext*context)
  15764. {
  15765. SqlQueryConnection*self=
  15766. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  15767. return self;
  15768. }
  15769. template<> QXmlQuery*getself(QScriptContext*context)
  15770. {
  15771. QXmlQuery*self=
  15772. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  15773. return self;
  15774. }
  15775. template<> QXmlStreamWriter*getself(QScriptContext*context)
  15776. {
  15777. QXmlStreamWriter*self=
  15778. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  15779. return self;
  15780. }
  15781. template<> QXmlStreamReader*getself(QScriptContext*context)
  15782. {
  15783. QXmlStreamReader*self=
  15784. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  15785. return self;
  15786. }
  15787. /*:8*//*9:*/
  15788. #line 730 "./typica.w"
  15789. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  15790. {
  15791. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  15792. return argument;
  15793. }
  15794. template<> QString argument(int arg,QScriptContext*context)
  15795. {
  15796. return context->argument(arg).toString();
  15797. }
  15798. template<> QVariant argument(int arg,QScriptContext*context)
  15799. {
  15800. return context->argument(arg).toVariant();
  15801. }
  15802. template<> int argument(int arg,QScriptContext*context)
  15803. {
  15804. return context->argument(arg).toInt32();
  15805. }
  15806. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  15807. {
  15808. return(SqlQueryConnection*)
  15809. qscriptvalue_cast<void*> (context->argument(arg));
  15810. }
  15811. template<> QModelIndex argument(int arg,QScriptContext*context)
  15812. {
  15813. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  15814. }
  15815. template<> double argument(int arg,QScriptContext*context)
  15816. {
  15817. return(double)(context->argument(arg).toNumber());
  15818. }
  15819. template<> Units::Unit argument(int arg,QScriptContext*context)
  15820. {
  15821. return(Units::Unit)(context->argument(arg).toInt32());
  15822. }
  15823. template<> QByteArray argument(int arg,QScriptContext*context)
  15824. {
  15825. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  15826. }
  15827. template<> bool argument(int arg,QScriptContext*context)
  15828. {
  15829. return context->argument(arg).toBool();
  15830. }
  15831. /*:9*//*13:*/
  15832. #line 829 "./typica.w"
  15833. void setQObjectProperties(QScriptValue value,QScriptEngine*engine)
  15834. {
  15835. value.setProperty("setProperty",engine->newFunction(QObject_setProperty));
  15836. }
  15837. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*)
  15838. {
  15839. QObject*self= getself<QObject*> (context);
  15840. self->setProperty(argument<QString> (0,context).toUtf8().constData(),
  15841. argument<QVariant> (1,context));
  15842. return QScriptValue();
  15843. }
  15844. /*:13*//*15:*/
  15845. #line 851 "./typica.w"
  15846. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  15847. {
  15848. }
  15849. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  15850. {
  15851. }
  15852. /*:15*//*18:*/
  15853. #line 883 "./typica.w"
  15854. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  15855. {
  15856. setQObjectProperties(value,engine);
  15857. }
  15858. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  15859. {
  15860. QScriptValue object= engine->newQObject(new QTimer);
  15861. setQTimerProperties(object,engine);
  15862. return object;
  15863. }
  15864. /*:18*//*21:*/
  15865. #line 925 "./typica.w"
  15866. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  15867. {
  15868. QScriptValue object= engine->newQObject(new QWidget);
  15869. setQWidgetProperties(object,engine);
  15870. return object;
  15871. }
  15872. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  15873. {
  15874. setQObjectProperties(value,engine);
  15875. setQPaintDeviceProperties(value,engine);
  15876. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  15877. value.setProperty("activateWindow",
  15878. engine->newFunction(QWidget_activateWindow));
  15879. }
  15880. /*:21*//*22:*/
  15881. #line 947 "./typica.w"
  15882. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  15883. {
  15884. if(context->argumentCount()==1)
  15885. {
  15886. QWidget*self= getself<QWidget*> (context);
  15887. QLayout*layout= argument<QLayout*> (0,context);
  15888. if(layout)
  15889. {
  15890. self->setLayout(layout);
  15891. }
  15892. else
  15893. {
  15894. context->throwError("Incorrect argument type passed to "
  15895. "QWidget::setLayout(). This method requires "
  15896. "a QLayout.");
  15897. }
  15898. }
  15899. else
  15900. {
  15901. context->throwError("Incorrect number of arguments passed to "
  15902. "QWidget::setLayout(). This method takes one "
  15903. "QLayout as an argument.");
  15904. }
  15905. return QScriptValue();
  15906. }
  15907. QScriptValue QWidget_activateWindow(QScriptContext*context,
  15908. QScriptEngine*)
  15909. {
  15910. QWidget*self= getself<QWidget*> (context);
  15911. self->activateWindow();
  15912. return QScriptValue();
  15913. }
  15914. /*:22*//*25:*/
  15915. #line 1012 "./typica.w"
  15916. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  15917. {
  15918. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  15919. argument<QString> (0,context),
  15920. argument<QString> (1,context),
  15921. QMessageBox::Ok|QMessageBox::Cancel);
  15922. if(selection==QMessageBox::Ok){
  15923. return QScriptValue(true);
  15924. }
  15925. return QScriptValue(false);
  15926. }
  15927. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  15928. {
  15929. QMessageBox::critical(NULL,argument<QString> (0,context),
  15930. argument<QString> (1,context));
  15931. return QScriptValue();
  15932. }
  15933. QScriptValue displayInfo(QScriptContext*context,QScriptEngine*)
  15934. {
  15935. QMessageBox::information(NULL,argument<QString> (0,context),
  15936. argument<QString> (1,context));
  15937. return QScriptValue();
  15938. }
  15939. /*:25*//*27:*/
  15940. #line 1097 "./typica.w"
  15941. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  15942. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  15943. {
  15944. if(!AppInstance->databaseConnected())
  15945. {
  15946. statusBar()->addWidget(new QLabel(tr("Not connected to database")));
  15947. }
  15948. else
  15949. {
  15950. statusBar()->addWidget(new UserLabel);
  15951. }
  15952. }
  15953. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  15954. {
  15955. QSettings settings;
  15956. settings.beginGroup(key);
  15957. settings.setValue("pos",pos());
  15958. settings.setValue("size",size());
  15959. settings.endGroup();
  15960. }
  15961. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  15962. {
  15963. QSettings settings;
  15964. settings.beginGroup(key);
  15965. if(settings.contains("size"))
  15966. {
  15967. resize(settings.value("size").toSize());
  15968. }
  15969. if(settings.contains("pos"))
  15970. {
  15971. move(settings.value("pos").toPoint());
  15972. }
  15973. settings.endGroup();
  15974. }
  15975. void ScriptQMainWindow::displayStatus(const QString&message)
  15976. {
  15977. statusBar()->showMessage(message);
  15978. }
  15979. void ScriptQMainWindow::showEvent(QShowEvent*event)
  15980. {
  15981. if(!event->spontaneous())
  15982. {
  15983. /*32:*/
  15984. #line 1221 "./typica.w"
  15985. QSettings settings;
  15986. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  15987. toByteArray());
  15988. /*:32*/
  15989. #line 1144 "./typica.w"
  15990. event->accept();
  15991. }
  15992. else
  15993. {
  15994. event->ignore();
  15995. }
  15996. }
  15997. void ScriptQMainWindow::show()
  15998. {
  15999. QMainWindow::show();
  16000. }
  16001. void ScriptQMainWindow::setupFinished()
  16002. {
  16003. emit windowReady();
  16004. }
  16005. /*:27*//*28:*/
  16006. #line 1170 "./typica.w"
  16007. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  16008. {
  16009. if(isWindowModified()){
  16010. /*29:*/
  16011. #line 1184 "./typica.w"
  16012. QMessageBox::StandardButton result;
  16013. result= QMessageBox::warning(this,"Typica",closePrompt(),
  16014. QMessageBox::Ok|QMessageBox::Cancel);
  16015. if(result==QMessageBox::Cancel)
  16016. {
  16017. event->ignore();
  16018. return;
  16019. }
  16020. /*:29*/
  16021. #line 1174 "./typica.w"
  16022. }
  16023. emit aboutToClose();
  16024. /*31:*/
  16025. #line 1215 "./typica.w"
  16026. QSettings settings;
  16027. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  16028. /*:31*/
  16029. #line 1177 "./typica.w"
  16030. event->accept();
  16031. }
  16032. /*:28*//*30:*/
  16033. #line 1196 "./typica.w"
  16034. QString ScriptQMainWindow::closePrompt()
  16035. {
  16036. return cprompt;
  16037. }
  16038. void ScriptQMainWindow::setClosePrompt(QString prompt)
  16039. {
  16040. cprompt= prompt;
  16041. }
  16042. /*:30*//*35:*/
  16043. #line 1249 "./typica.w"
  16044. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  16045. {
  16046. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  16047. setQMainWindowProperties(object,engine);
  16048. return object;
  16049. }
  16050. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  16051. {
  16052. setQWidgetProperties(value,engine);
  16053. value.setProperty("setCentralWidget",
  16054. engine->newFunction(QMainWindow_setCentralWidget));
  16055. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  16056. }
  16057. /*:35*//*36:*/
  16058. #line 1271 "./typica.w"
  16059. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  16060. QScriptEngine*)
  16061. {
  16062. if(context->argumentCount()==1)
  16063. {
  16064. QMainWindow*self= getself<QMainWindow*> (context);
  16065. QWidget*widget= argument<QWidget*> (0,context);
  16066. if(widget)
  16067. {
  16068. self->setCentralWidget(widget);
  16069. }
  16070. else
  16071. {
  16072. context->throwError("Incorrect argument type passed to "
  16073. "QMainWindow::setCentralWidget(). This "
  16074. "method requires a QWidget.");
  16075. }
  16076. }
  16077. else
  16078. {
  16079. context->throwError("Incorrect number of arguments passed to "
  16080. "QMainWindow::setCentralWidget(). This method "
  16081. "takes one QWidget as an argument.");
  16082. }
  16083. return QScriptValue();
  16084. }
  16085. /*:36*//*37:*/
  16086. #line 1305 "./typica.w"
  16087. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  16088. {
  16089. QScriptValue object;
  16090. if(context->argumentCount()==0)
  16091. {
  16092. QMainWindow*self= getself<QMainWindow*> (context);
  16093. QMenuBar*bar= self->menuBar();
  16094. object= engine->newQObject(bar);
  16095. setQMenuBarProperties(object,engine);
  16096. }
  16097. else
  16098. {
  16099. context->throwError("Incorrect number of arguments passed to "
  16100. "QMainWindow::menuBar(). This method takes no "
  16101. "arguments.");
  16102. }
  16103. return object;
  16104. }
  16105. /*:37*//*39:*/
  16106. #line 1335 "./typica.w"
  16107. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  16108. {
  16109. setQWidgetProperties(value,engine);
  16110. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  16111. }
  16112. /*:39*//*40:*/
  16113. #line 1350 "./typica.w"
  16114. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  16115. {
  16116. QScriptValue object;
  16117. if(context->argumentCount()==1)
  16118. {
  16119. QMenuBar*self= getself<QMenuBar*> (context);
  16120. QString title= argument<QString> (0,context);
  16121. object= engine->newQObject(self->addMenu(title));
  16122. setQMenuProperties(object,engine);
  16123. }
  16124. else
  16125. {
  16126. context->throwError("Incorrect number of arguments passed to "
  16127. "QMenuBar::addMenu(). This method takes one "
  16128. "string as an argument.");
  16129. }
  16130. return object;
  16131. }
  16132. /*:40*//*42:*/
  16133. #line 1380 "./typica.w"
  16134. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  16135. {
  16136. setQWidgetProperties(value,engine);
  16137. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  16138. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  16139. }
  16140. /*:42*//*43:*/
  16141. #line 1390 "./typica.w"
  16142. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  16143. {
  16144. if(context->argumentCount()==1)
  16145. {
  16146. QMenu*self= getself<QMenu*> (context);
  16147. QAction*action= argument<QAction*> (0,context);
  16148. if(action)
  16149. {
  16150. self->addAction(action);
  16151. }
  16152. else
  16153. {
  16154. context->throwError("Incorrect argument type passed to "
  16155. "QMenu::addAction(). This method requires a "
  16156. "QAction.");
  16157. }
  16158. }
  16159. else
  16160. {
  16161. context->throwError("Incorrect number of arguments passed to "
  16162. "QMenu::addAction(). This method takes one "
  16163. "QAction as an argument.");
  16164. }
  16165. return QScriptValue();
  16166. }
  16167. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  16168. {
  16169. if(context->argumentCount()==0)
  16170. {
  16171. QMenu*self= getself<QMenu*> (context);
  16172. self->addSeparator();
  16173. }
  16174. else
  16175. {
  16176. context->throwError("Incorrect number of arguments passed to "
  16177. "QMenu::addSeparator(). This method takes no "
  16178. "arguments.");
  16179. }
  16180. return QScriptValue();
  16181. }
  16182. /*:43*//*46:*/
  16183. #line 1452 "./typica.w"
  16184. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  16185. {
  16186. QScriptValue object= engine->newQObject(new QFrame);
  16187. setQFrameProperties(object,engine);
  16188. return object;
  16189. }
  16190. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  16191. {
  16192. setQWidgetProperties(value,engine);
  16193. }
  16194. /*:46*//*49:*/
  16195. #line 1486 "./typica.w"
  16196. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  16197. {
  16198. QString text;
  16199. if(context->argumentCount()==1)
  16200. {
  16201. text= argument<QString> (0,context);
  16202. }
  16203. QScriptValue object= engine->newQObject(new QLabel(text));
  16204. setQLabelProperties(object,engine);
  16205. return object;
  16206. }
  16207. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  16208. {
  16209. setQFrameProperties(value,engine);
  16210. }
  16211. /*:49*//*52:*/
  16212. #line 1528 "./typica.w"
  16213. QScriptValue constructQSvgWidget(QScriptContext*,
  16214. QScriptEngine*engine)
  16215. {
  16216. QScriptValue object= engine->newQObject(new QSvgWidget);
  16217. setQSvgWidgetProperties(object,engine);
  16218. return object;
  16219. }
  16220. /*:52*//*53:*/
  16221. #line 1539 "./typica.w"
  16222. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  16223. {
  16224. setQWidgetProperties(value,engine);
  16225. value.setProperty("loadDevice",
  16226. engine->newFunction(QSvgWidget_loadDevice));
  16227. }
  16228. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  16229. {
  16230. if(context->argumentCount()==1)
  16231. {
  16232. QSvgWidget*self= getself<QSvgWidget*> (context);
  16233. QIODevice*device= argument<QIODevice*> (0,context);
  16234. device->reset();
  16235. QByteArray data= device->readAll();
  16236. self->load(data);
  16237. }
  16238. else
  16239. {
  16240. context->throwError("Incorrect number of arguments passed to "
  16241. "QSvgWidget::loadData(). This method takes one "
  16242. "QIODevice as an argument.");
  16243. }
  16244. return QScriptValue();
  16245. }
  16246. /*:53*//*55:*/
  16247. #line 1577 "./typica.w"
  16248. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  16249. QStack<QLayout*> *layoutStack)
  16250. {
  16251. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16252. QSvgWidget*widget= new QSvgWidget;
  16253. layout->addWidget(widget);
  16254. QString id= element.attribute("id");
  16255. if(!id.isEmpty())
  16256. {
  16257. widget->setObjectName(id);
  16258. }
  16259. }
  16260. /*:55*//*58:*/
  16261. #line 1610 "./typica.w"
  16262. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  16263. {
  16264. QScriptValue object= engine->newQObject(new QLineEdit());
  16265. setQLineEditProperties(object,engine);
  16266. return object;
  16267. }
  16268. /*:58*//*59:*/
  16269. #line 1621 "./typica.w"
  16270. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  16271. {
  16272. setQWidgetProperties(value,engine);
  16273. }
  16274. /*:59*//*62:*/
  16275. #line 1659 "./typica.w"
  16276. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  16277. {
  16278. QScriptValue object= engine->newQObject(new QSplitter);
  16279. setQSplitterProperties(object,engine);
  16280. return object;
  16281. }
  16282. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  16283. {
  16284. setQFrameProperties(value,engine);
  16285. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  16286. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  16287. value.setProperty("restoreState",
  16288. engine->newFunction(QSplitter_restoreState));
  16289. value.setProperty("count",engine->newFunction(QSplitter_count));
  16290. value.setProperty("setCollapsible",engine->newFunction(QSplitter_setCollapsible));
  16291. }
  16292. /*:62*//*63:*/
  16293. #line 1681 "./typica.w"
  16294. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  16295. {
  16296. if(context->argumentCount()==1)
  16297. {
  16298. QSplitter*self= getself<QSplitter*> (context);
  16299. QWidget*widget= argument<QWidget*> (0,context);
  16300. if(widget)
  16301. {
  16302. self->addWidget(widget);
  16303. }
  16304. else
  16305. {
  16306. context->throwError("Incorrect argument type passed to "
  16307. "QSplitter::addWidget(). This method "
  16308. "requires a QWidget.");
  16309. }
  16310. }
  16311. else
  16312. {
  16313. context->throwError("Incorrect number of arguments passed to "
  16314. "QSplitter::addWidget(). This method takes one "
  16315. "QWidget as an argument.");
  16316. }
  16317. return QScriptValue();
  16318. }
  16319. /*:63*//*64:*/
  16320. #line 1718 "./typica.w"
  16321. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  16322. {
  16323. QSplitter*self= getself<QSplitter*> (context);
  16324. return QScriptValue(self->count());
  16325. }
  16326. /*:64*//*65:*/
  16327. #line 1731 "./typica.w"
  16328. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  16329. {
  16330. if(context->argumentCount()==1)
  16331. {
  16332. QSplitter*self= getself<QSplitter*> (context);
  16333. QString key= argument<QString> (0,context);
  16334. QSettings settings;
  16335. settings.setValue(key,self->saveState());
  16336. }
  16337. else
  16338. {
  16339. context->throwError("Incorrect number of arguments passed to "
  16340. "QSplitter::saveState(). This method takes one "
  16341. "string as an argument.");
  16342. }
  16343. return QScriptValue();
  16344. }
  16345. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  16346. {
  16347. if(context->argumentCount()==1)
  16348. {
  16349. QSplitter*self= getself<QSplitter*> (context);
  16350. QString key= argument<QString> (0,context);
  16351. QSettings settings;
  16352. self->restoreState(settings.value(key).toByteArray());
  16353. }
  16354. else
  16355. {
  16356. context->throwError("Incorrect number of arguments passed to "
  16357. "QSplitter::restoreState(). This method takes "
  16358. "one string as an argument.");
  16359. }
  16360. return QScriptValue();
  16361. }
  16362. /*:65*//*66:*/
  16363. #line 1772 "./typica.w"
  16364. QScriptValue QSplitter_setCollapsible(QScriptContext*context,QScriptEngine*)
  16365. {
  16366. if(context->argumentCount()==2)
  16367. {
  16368. QSplitter*self= getself<QSplitter*> (context);
  16369. self->setCollapsible(argument<int> (0,context),argument<bool> (1,context));
  16370. }
  16371. else
  16372. {
  16373. context->throwError("Incorrect number of arguments");
  16374. }
  16375. return QScriptValue();
  16376. }
  16377. /*:66*//*68:*/
  16378. #line 1803 "./typica.w"
  16379. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16380. {
  16381. setQLayoutItemProperties(value,engine);
  16382. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  16383. }
  16384. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16385. {
  16386. if(context->argumentCount()==1)
  16387. {
  16388. QLayout*self= getself<QLayout*> (context);
  16389. QWidget*widget= argument<QWidget*> (0,context);
  16390. if(widget)
  16391. {
  16392. self->addWidget(widget);
  16393. }
  16394. else
  16395. {
  16396. context->throwError("Incorrect argument type passed to "
  16397. "QLayout::addWidget(). This method requires "
  16398. "a QWidget.");
  16399. }
  16400. }
  16401. else
  16402. {
  16403. context->throwError("Incorrect number of arguments passed to "
  16404. "QLayout::addWidget(). This method takes one "
  16405. "QWidget as an argument.");
  16406. }
  16407. return QScriptValue();
  16408. }
  16409. /*:68*//*71:*/
  16410. #line 1870 "./typica.w"
  16411. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  16412. {
  16413. QScriptValue object=
  16414. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  16415. setQBoxLayoutProperties(object,engine);
  16416. return object;
  16417. }
  16418. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16419. {
  16420. setQLayoutProperties(value,engine);
  16421. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  16422. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  16423. }
  16424. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  16425. {
  16426. if(context->argumentCount()> 0&&context->argumentCount()<3)
  16427. {
  16428. QBoxLayout*self= getself<QBoxLayout*> (context);
  16429. QLayout*layout= argument<QLayout*> (0,context);
  16430. int stretch= 0;
  16431. if(context->argumentCount()==2)
  16432. {
  16433. stretch= argument<int> (1,context);
  16434. }
  16435. if(layout)
  16436. {
  16437. self->addLayout(layout,stretch);
  16438. }
  16439. else
  16440. {
  16441. context->throwError("Incorrect argument type passed to "
  16442. "QLayout::addLayout(). This method requires "
  16443. "a QLayout.");
  16444. }
  16445. }
  16446. else
  16447. {
  16448. context->throwError("Incorrect number of arguments passed to "
  16449. "QLayout::addLayout(). This method takes one "
  16450. "QLayout as an argument and optionally one integer.");
  16451. }
  16452. return QScriptValue();
  16453. }
  16454. /*:71*//*72:*/
  16455. #line 1921 "./typica.w"
  16456. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16457. {
  16458. if(context->argumentCount()> 0&&context->argumentCount()<4)
  16459. {
  16460. QBoxLayout*self= getself<QBoxLayout*> (context);
  16461. QWidget*widget= argument<QWidget*> (0,context);
  16462. int stretch= 0;
  16463. Qt::Alignment alignment= 0;
  16464. if(context->argumentCount()> 1)
  16465. {
  16466. stretch= argument<int> (1,context);
  16467. }
  16468. if(context->argumentCount()> 2)
  16469. {
  16470. alignment= (Qt::Alignment)(argument<int> (2,context));
  16471. }
  16472. if(widget)
  16473. {
  16474. self->addWidget(widget,stretch,alignment);
  16475. }
  16476. else
  16477. {
  16478. context->throwError("Incorrect argument type passed to "
  16479. "QBoxLayout::addWidget(). This method requires "
  16480. "a QWidget.");
  16481. }
  16482. }
  16483. else
  16484. {
  16485. context->throwError("Incorrect number of arguments passed to "
  16486. "QBoxLayout::addWidget(). This method takes one "
  16487. "QWidget and optionally up to two integers as "
  16488. "arguments.");
  16489. }
  16490. return QScriptValue();
  16491. }
  16492. /*:72*//*75:*/
  16493. #line 1985 "./typica.w"
  16494. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  16495. {
  16496. QScriptValue object= engine->newQObject(new QAction(NULL));
  16497. setQActionProperties(object,engine);
  16498. return object;
  16499. }
  16500. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  16501. {
  16502. setQObjectProperties(value,engine);
  16503. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  16504. }
  16505. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  16506. {
  16507. if(context->argumentCount()==1)
  16508. {
  16509. QAction*self= getself<QAction*> (context);
  16510. self->setShortcut(argument<QString> (0,context));
  16511. }
  16512. else
  16513. {
  16514. context->throwError("Incorrect number of arguments passed to "
  16515. "QAction::setShortcut(). This method takes one "
  16516. "string as an argument.");
  16517. }
  16518. return QScriptValue();
  16519. }
  16520. /*:75*//*78:*/
  16521. #line 2043 "./typica.w"
  16522. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  16523. QScriptEngine*engine)
  16524. {
  16525. QScriptValue retval;
  16526. if(context->argumentCount()==3)
  16527. {
  16528. QWidget*widget= argument<QWidget*> (0,context);
  16529. if(widget)
  16530. {
  16531. QString caption= argument<QString> (1,context);
  16532. QString dir= argument<QString> (2,context);
  16533. retval= QScriptValue(engine,
  16534. QFileDialog::getOpenFileName(widget,caption,
  16535. dir,"",0,0));
  16536. setQFileDialogProperties(retval,engine);
  16537. }
  16538. else
  16539. {
  16540. context->throwError("Incorrect argument type passed to "
  16541. "QFileDialog::getOpenFileName(). The first "
  16542. "argument to this method must be a QWidget.");
  16543. }
  16544. }
  16545. else
  16546. {
  16547. context->throwError("Incorrect number of arguments passed to "
  16548. "QFileDialog::getOpenFileName(). This method "
  16549. "takes one QWidget followed by two strings for a "
  16550. "total of three arguments.");
  16551. }
  16552. return retval;
  16553. }
  16554. /*:78*//*79:*/
  16555. #line 2079 "./typica.w"
  16556. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  16557. QScriptEngine*engine)
  16558. {
  16559. QScriptValue retval;
  16560. if(context->argumentCount()==3)
  16561. {
  16562. QWidget*widget= argument<QWidget*> (0,context);
  16563. if(widget)
  16564. {
  16565. QString caption= argument<QString> (1,context);
  16566. QString dir= argument<QString> (2,context);
  16567. retval= QScriptValue(engine,
  16568. QFileDialog::getSaveFileName(widget,caption,
  16569. dir,"",0,0));
  16570. setQFileDialogProperties(retval,engine);
  16571. }
  16572. else
  16573. {
  16574. context->throwError("Incorrect argument type passed to "
  16575. "QFileDialog::getSaveFileName(). The first "
  16576. "argument to this method must be a QWidget.");
  16577. }
  16578. }
  16579. else
  16580. {
  16581. context->throwError("Incorrect number of arguments passed to "
  16582. "QFileDialog::getSaveFileName(). This method "
  16583. "takes one QWidget followed by two strings for a "
  16584. "total of three arguments.");
  16585. }
  16586. return retval;
  16587. }
  16588. /*:79*//*80:*/
  16589. #line 2116 "./typica.w"
  16590. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  16591. {
  16592. setQDialogProperties(value,engine);
  16593. }
  16594. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  16595. {
  16596. setQWidgetProperties(value,engine);
  16597. }
  16598. /*:80*//*83:*/
  16599. #line 2157 "./typica.w"
  16600. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  16601. {
  16602. QScriptValue object=
  16603. engine->newQObject(new QFile(argument<QString> (0,context)));
  16604. setQFileProperties(object,engine);
  16605. return object;
  16606. }
  16607. /*:83*//*84:*/
  16608. #line 2168 "./typica.w"
  16609. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  16610. {
  16611. setQIODeviceProperties(value,engine);
  16612. value.setProperty("remove",engine->newFunction(QFile_remove));
  16613. }
  16614. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  16615. {
  16616. QFile*self= getself<QFile*> (context);
  16617. bool retval= self->remove();
  16618. return QScriptValue(engine,retval);
  16619. }
  16620. /*:84*//*85:*/
  16621. #line 2190 "./typica.w"
  16622. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  16623. {
  16624. setQObjectProperties(value,engine);
  16625. value.setProperty("open",engine->newFunction(QIODevice_open));
  16626. value.setProperty("close",engine->newFunction(QIODevice_close));
  16627. value.setProperty("readToString",
  16628. engine->newFunction(QIODevice_readToString));
  16629. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  16630. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  16631. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  16632. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  16633. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  16634. value.setProperty("read",engine->newFunction(QIODevice_read));
  16635. }
  16636. /*:85*//*86:*/
  16637. #line 2211 "./typica.w"
  16638. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  16639. {
  16640. QIODevice*self= getself<QIODevice*> (context);
  16641. bool retval= false;
  16642. if(context->argumentCount()==1)
  16643. {
  16644. switch(argument<int> (0,context))
  16645. {
  16646. case 1:
  16647. retval= self->open(QIODevice::ReadOnly);
  16648. break;
  16649. case 2:
  16650. retval= self->open(QIODevice::WriteOnly);
  16651. break;
  16652. case 3:
  16653. retval= self->open(QIODevice::ReadWrite);
  16654. break;
  16655. default:
  16656. break;
  16657. }
  16658. }
  16659. else
  16660. {
  16661. retval= self->open(QIODevice::ReadWrite);
  16662. }
  16663. return QScriptValue(retval);
  16664. }
  16665. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  16666. {
  16667. QIODevice*self= getself<QIODevice*> (context);
  16668. self->close();
  16669. return QScriptValue();
  16670. }
  16671. /*:86*//*87:*/
  16672. #line 2251 "./typica.w"
  16673. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  16674. {
  16675. QIODevice*self= getself<QIODevice*> (context);
  16676. self->reset();
  16677. return QScriptValue(QString(self->readAll()));
  16678. }
  16679. /*:87*//*88:*/
  16680. #line 2267 "./typica.w"
  16681. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  16682. {
  16683. QIODevice*self= getself<QIODevice*> (context);
  16684. if(context->argumentCount()==1)
  16685. {
  16686. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  16687. }
  16688. context->throwError("Incorrect number of arguments passed to "
  16689. "QIODevice::putChar()");
  16690. return QScriptValue();
  16691. }
  16692. /*:88*//*89:*/
  16693. #line 2285 "./typica.w"
  16694. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  16695. {
  16696. QIODevice*self= getself<QIODevice*> (context);
  16697. if(context->argumentCount()==1)
  16698. {
  16699. self->write(argument<QString> (0,context).toUtf8());
  16700. }
  16701. else
  16702. {
  16703. context->throwError("Incorrect number of arguments passed to "
  16704. "QIODevice::writeString()");
  16705. }
  16706. return QScriptValue();
  16707. }
  16708. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  16709. {
  16710. QIODevice*self= getself<QIODevice*> (context);
  16711. if(context->argumentCount()==1)
  16712. {
  16713. self->write(argument<QByteArray> (0,context));
  16714. }
  16715. else
  16716. {
  16717. context->throwError("Incorrect number of arguments passed to "
  16718. "QIODevice::writeBytes()");
  16719. }
  16720. return QScriptValue();
  16721. }
  16722. /*:89*//*90:*/
  16723. #line 2319 "./typica.w"
  16724. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  16725. {
  16726. QIODevice*self= getself<QIODevice*> (context);
  16727. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  16728. setQByteArrayProperties(value,engine);
  16729. return value;
  16730. }
  16731. /*:90*//*91:*/
  16732. #line 2330 "./typica.w"
  16733. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  16734. {
  16735. QIODevice*self= getself<QIODevice*> (context);
  16736. QScriptValue value= engine->toScriptValue<QByteArray> (
  16737. self->peek(argument<int> (0,context)));
  16738. setQByteArrayProperties(value,engine);
  16739. return value;
  16740. }
  16741. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  16742. {
  16743. QIODevice*self= getself<QIODevice*> (context);
  16744. QScriptValue value= engine->toScriptValue<QByteArray> (
  16745. self->read(argument<int> (0,context)));
  16746. setQByteArrayProperties(value,engine);
  16747. return value;
  16748. }
  16749. /*:91*//*94:*/
  16750. #line 2375 "./typica.w"
  16751. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  16752. {
  16753. QScriptValue object= engine->newQObject(new QProcess);
  16754. setQProcessProperties(object,engine);
  16755. return object;
  16756. }
  16757. /*:94*//*95:*/
  16758. #line 2386 "./typica.w"
  16759. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  16760. {
  16761. setQIODeviceProperties(value,engine);
  16762. value.setProperty("execute",engine->newFunction(QProcess_execute));
  16763. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  16764. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  16765. value.setProperty("start",engine->newFunction(QProcess_start));
  16766. }
  16767. /*:95*//*96:*/
  16768. #line 2400 "./typica.w"
  16769. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  16770. {
  16771. QProcess*self= getself<QProcess*> (context);
  16772. QString program= argument<QString> (0,context);
  16773. QStringList arguments= QStringList();
  16774. if(context->argumentCount()> 1){
  16775. arguments= argument<QVariant> (1,context).toStringList();
  16776. }
  16777. int retval= self->execute(program,arguments);
  16778. return QScriptValue(retval);
  16779. }
  16780. /*:96*//*97:*/
  16781. #line 2415 "./typica.w"
  16782. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  16783. {
  16784. QProcess*self= getself<QProcess*> (context);
  16785. QString program= argument<QString> (0,context);
  16786. QStringList arguments= QStringList();
  16787. if(context->argumentCount()> 1){
  16788. arguments= argument<QVariant> (1,context).toStringList();
  16789. }
  16790. QString workingDirectory= "";
  16791. if(context->argumentCount()> 2){
  16792. workingDirectory= argument<QString> (2,context);
  16793. }
  16794. bool retval;
  16795. switch(context->argumentCount())
  16796. {
  16797. case 1:
  16798. retval= self->startDetached(program);
  16799. break;
  16800. case 2:
  16801. retval= self->startDetached(program,arguments);
  16802. break;
  16803. case 3:
  16804. retval= self->startDetached(program,arguments,workingDirectory);
  16805. break;
  16806. default:
  16807. retval= false;
  16808. }
  16809. return QScriptValue(retval);
  16810. }
  16811. /*:97*//*98:*/
  16812. #line 2448 "./typica.w"
  16813. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  16814. {
  16815. QProcess*self= getself<QProcess*> (context);
  16816. QString directory= argument<QString> (0,context);
  16817. self->setWorkingDirectory(directory);
  16818. return QScriptValue();
  16819. }
  16820. /*:98*//*99:*/
  16821. #line 2460 "./typica.w"
  16822. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  16823. {
  16824. QProcess*self= getself<QProcess*> (context);
  16825. QString program= argument<QString> (0,context);
  16826. QStringList arguments= QStringList();
  16827. if(context->argumentCount()> 1){
  16828. arguments= argument<QVariant> (1,context).toStringList();
  16829. }
  16830. self->start(program,arguments);
  16831. return QScriptValue();
  16832. }
  16833. /*:99*//*101:*/
  16834. #line 2501 "./typica.w"
  16835. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  16836. {
  16837. QScriptValue object= engine->newVariant(QVariant(bytes));
  16838. setQByteArrayProperties(object,engine);
  16839. return object;
  16840. }
  16841. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  16842. {
  16843. bytes= value.toVariant().toByteArray();
  16844. }
  16845. /*:101*//*103:*/
  16846. #line 2524 "./typica.w"
  16847. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  16848. {
  16849. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  16850. setQByteArrayProperties(object,engine);
  16851. return object;
  16852. }
  16853. /*:103*//*104:*/
  16854. #line 2535 "./typica.w"
  16855. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  16856. {
  16857. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  16858. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  16859. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  16860. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  16861. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  16862. value.setProperty("size",engine->newFunction(QByteArray_size));
  16863. value.setProperty("left",engine->newFunction(QByteArray_left));
  16864. value.setProperty("right",engine->newFunction(QByteArray_right));
  16865. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  16866. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  16867. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  16868. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  16869. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  16870. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  16871. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  16872. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  16873. }
  16874. /*:104*//*105:*/
  16875. #line 2559 "./typica.w"
  16876. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  16877. {
  16878. QByteArray self= getself<QByteArray> (context);
  16879. QByteArray retval;
  16880. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  16881. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  16882. setQByteArrayProperties(value,engine);
  16883. return value;
  16884. }
  16885. /*:105*//*106:*/
  16886. #line 2573 "./typica.w"
  16887. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  16888. {
  16889. QByteArray self= getself<QByteArray> (context);
  16890. return QScriptValue((int)(self.at(argument<int> (0,context))));
  16891. }
  16892. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  16893. {
  16894. QByteArray self= getself<QByteArray> (context);
  16895. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  16896. return QScriptValue();
  16897. }
  16898. /*:106*//*107:*/
  16899. #line 2591 "./typica.w"
  16900. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  16901. {
  16902. QByteArray self= getself<QByteArray> (context);
  16903. QScriptValue value=
  16904. engine->toScriptValue<QByteArray> (
  16905. self.append(argument<QByteArray> (0,context)));
  16906. setQByteArrayProperties(value,engine);
  16907. return value;
  16908. }
  16909. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  16910. {
  16911. QByteArray self= getself<QByteArray> (context);
  16912. QScriptValue value= engine->toScriptValue<QByteArray> (
  16913. self.append(argument<QString> (0,context)));
  16914. setQByteArrayProperties(value,engine);
  16915. return value;
  16916. }
  16917. /*:107*//*108:*/
  16918. #line 2613 "./typica.w"
  16919. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  16920. {
  16921. QByteArray self= getself<QByteArray> (context);
  16922. return QScriptValue(self.size());
  16923. }
  16924. /*:108*//*109:*/
  16925. #line 2623 "./typica.w"
  16926. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  16927. {
  16928. QByteArray self= getself<QByteArray> (context);
  16929. QScriptValue value= engine->toScriptValue<QByteArray> (
  16930. self.left(argument<int> (0,context)));
  16931. setQByteArrayProperties(value,engine);
  16932. return value;
  16933. }
  16934. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  16935. {
  16936. QByteArray self= getself<QByteArray> (context);
  16937. QScriptValue value= engine->toScriptValue<QByteArray> (
  16938. self.right(argument<int> (0,context)));
  16939. setQByteArrayProperties(value,engine);
  16940. return value;
  16941. }
  16942. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  16943. {
  16944. QByteArray self= getself<QByteArray> (context);
  16945. int length= -1;
  16946. if(context->argumentCount()> 1)
  16947. {
  16948. length= argument<int> (1,context);
  16949. }
  16950. QScriptValue value= engine->toScriptValue<QByteArray> (
  16951. self.mid(argument<int> (0,context),length));
  16952. setQByteArrayProperties(value,engine);
  16953. return value;
  16954. }
  16955. /*:109*//*110:*/
  16956. #line 2658 "./typica.w"
  16957. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  16958. {
  16959. QByteArray self= getself<QByteArray> (context);
  16960. self.chop(argument<int> (0,context));
  16961. return QScriptValue();
  16962. }
  16963. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  16964. {
  16965. QByteArray self= getself<QByteArray> (context);
  16966. QScriptValue value= engine->toScriptValue<QByteArray> (
  16967. self.remove(argument<int> (0,context),argument<int> (1,context)));
  16968. setQByteArrayProperties(value,engine);
  16969. return value;
  16970. }
  16971. /*:110*//*111:*/
  16972. #line 2681 "./typica.w"
  16973. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  16974. {
  16975. QByteArray self= getself<QByteArray> (context);
  16976. int value= 0;
  16977. char*bytes= (char*)&value;
  16978. bytes[0]= self[0];
  16979. return QScriptValue(value);
  16980. }
  16981. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  16982. {
  16983. QByteArray self= getself<QByteArray> (context);
  16984. int value= 0;
  16985. char*bytes= (char*)&value;
  16986. bytes[0]= self[0];
  16987. bytes[1]= self[1];
  16988. return QScriptValue(value);
  16989. }
  16990. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  16991. {
  16992. QByteArray self= getself<QByteArray> (context);
  16993. int value= 0;
  16994. char*bytes= (char*)&value;
  16995. bytes[0]= self[0];
  16996. bytes[1]= self[1];
  16997. bytes[2]= self[2];
  16998. bytes[3]= self[3];
  16999. return QScriptValue(value);
  17000. }
  17001. /*:111*//*112:*/
  17002. #line 2717 "./typica.w"
  17003. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  17004. {
  17005. QByteArray self= getself<QByteArray> (context);
  17006. float value= 0.0;
  17007. char*bytes= (char*)&value;
  17008. bytes[0]= self[0];
  17009. bytes[1]= self[1];
  17010. bytes[2]= self[2];
  17011. bytes[3]= self[3];
  17012. return QScriptValue(value);
  17013. }
  17014. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  17015. {
  17016. QByteArray self= getself<QByteArray> (context);
  17017. double value= 0.0;
  17018. char*bytes= (char*)&value;
  17019. bytes[0]= self[0];
  17020. bytes[1]= self[1];
  17021. bytes[2]= self[2];
  17022. bytes[3]= self[3];
  17023. bytes[4]= self[4];
  17024. bytes[5]= self[5];
  17025. bytes[6]= self[6];
  17026. bytes[7]= self[7];
  17027. return QScriptValue(value);
  17028. }
  17029. /*:112*//*115:*/
  17030. #line 2772 "./typica.w"
  17031. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  17032. {
  17033. qint8 value= (qint8)(argument<int> (0,context));
  17034. char*bytes= (char*)&value;
  17035. QByteArray retval;
  17036. retval.resize(1);
  17037. retval[0]= bytes[0];
  17038. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  17039. setQByteArrayProperties(v,engine);
  17040. return v;
  17041. }
  17042. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  17043. {
  17044. qint16 value= (qint16)(argument<int> (0,context));
  17045. char*bytes= (char*)&value;
  17046. QByteArray retval;
  17047. retval.resize(2);
  17048. retval[0]= bytes[0];
  17049. retval[1]= bytes[1];
  17050. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  17051. setQByteArrayProperties(v,engine);
  17052. return v;
  17053. }
  17054. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  17055. {
  17056. qint32 value= (qint32)(argument<int> (0,context));
  17057. char*bytes= (char*)&value;
  17058. QByteArray retval;
  17059. retval.resize(4);
  17060. retval[0]= bytes[0];
  17061. retval[1]= bytes[1];
  17062. retval[2]= bytes[2];
  17063. retval[3]= bytes[3];
  17064. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  17065. setQByteArrayProperties(v,engine);
  17066. return v;
  17067. }
  17068. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  17069. {
  17070. float value= (float)(argument<double> (0,context));
  17071. char*bytes= (char*)&value;
  17072. QByteArray retval;
  17073. retval.resize(4);
  17074. retval[0]= bytes[0];
  17075. retval[1]= bytes[1];
  17076. retval[2]= bytes[2];
  17077. retval[3]= bytes[3];
  17078. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  17079. setQByteArrayProperties(v,engine);
  17080. return v;
  17081. }
  17082. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  17083. {
  17084. double value= (double)(argument<double> (0,context));
  17085. char*bytes= (char*)&value;
  17086. QByteArray retval;
  17087. retval.resize(8);
  17088. retval[0]= bytes[0];
  17089. retval[1]= bytes[1];
  17090. retval[2]= bytes[2];
  17091. retval[3]= bytes[3];
  17092. retval[4]= bytes[4];
  17093. retval[5]= bytes[5];
  17094. retval[6]= bytes[6];
  17095. retval[7]= bytes[7];
  17096. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  17097. setQByteArrayProperties(v,engine);
  17098. return v;
  17099. }
  17100. /*:115*//*118:*/
  17101. #line 2870 "./typica.w"
  17102. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  17103. {
  17104. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  17105. QScriptValue object= engine->newQObject(new QBuffer(array));
  17106. setQBufferProperties(object,engine);
  17107. return object;
  17108. }
  17109. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  17110. {
  17111. setQIODeviceProperties(value,engine);
  17112. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  17113. value.setProperty("data",engine->newFunction(QBuffer_data));
  17114. }
  17115. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  17116. {
  17117. QBuffer*self= getself<QBuffer*> (context);
  17118. self->setData(argument<QString> (0,context).toAscii());
  17119. return QScriptValue();
  17120. }
  17121. QScriptValue QBuffer_data(QScriptContext*context,QScriptEngine*)
  17122. {
  17123. QBuffer*self= getself<QBuffer*> (context);
  17124. return QScriptValue(QString(self->data()));
  17125. }
  17126. /*:118*//*121:*/
  17127. #line 2926 "./typica.w"
  17128. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  17129. {
  17130. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  17131. setXQueryProperties(object,engine);
  17132. return object;
  17133. }
  17134. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  17135. {
  17136. QXmlQuery*self= getself<QXmlQuery*> (context);
  17137. delete self;
  17138. return QScriptValue();
  17139. }
  17140. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  17141. {
  17142. value.setProperty("bind",engine->newFunction(XQuery_bind));
  17143. value.setProperty("exec",engine->newFunction(XQuery_exec));
  17144. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  17145. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  17146. }
  17147. /*:121*//*122:*/
  17148. #line 2952 "./typica.w"
  17149. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  17150. {
  17151. QXmlQuery*self= getself<QXmlQuery*> (context);
  17152. QIODevice*buffer= argument<QIODevice*> (1,context);
  17153. self->bindVariable(argument<QString> (0,context),buffer);
  17154. return QScriptValue();
  17155. }
  17156. /*:122*//*123:*/
  17157. #line 2963 "./typica.w"
  17158. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  17159. {
  17160. QXmlQuery*self= getself<QXmlQuery*> (context);
  17161. self->setQuery(argument<QString> (0,context));
  17162. return QScriptValue();
  17163. }
  17164. /*:123*//*124:*/
  17165. #line 2973 "./typica.w"
  17166. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  17167. {
  17168. QXmlQuery*self= getself<QXmlQuery*> (context);
  17169. QString result;
  17170. self->evaluateTo(&result);
  17171. return QScriptValue(result);
  17172. }
  17173. /*:124*//*127:*/
  17174. #line 3028 "./typica.w"
  17175. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  17176. {
  17177. QXmlStreamWriter*retval;
  17178. if(context->argumentCount()==1)
  17179. {
  17180. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  17181. }
  17182. else
  17183. {
  17184. retval= new QXmlStreamWriter;
  17185. }
  17186. QScriptValue object= engine->toScriptValue<void*> (retval);
  17187. setXmlWriterProperties(object,engine);
  17188. return object;
  17189. }
  17190. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  17191. {
  17192. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  17193. value.setProperty("writeAttribute",
  17194. engine->newFunction(XmlWriter_writeAttribute));
  17195. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  17196. value.setProperty("writeCharacters",
  17197. engine->newFunction(XmlWriter_writeCharacters));
  17198. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  17199. value.setProperty("writeEmptyElement",
  17200. engine->newFunction(XmlWriter_writeEmptyElement));
  17201. value.setProperty("writeEndDocument",
  17202. engine->newFunction(XmlWriter_writeEndDocument));
  17203. value.setProperty("writeEndElement",
  17204. engine->newFunction(XmlWriter_writeEndElement));
  17205. value.setProperty("writeEntityReference",
  17206. engine->newFunction(XmlWriter_writeEntityReference));
  17207. value.setProperty("writeProcessingInstruction",
  17208. engine->newFunction(XmlWriter_writeProcessingInstruction));
  17209. value.setProperty("writeStartDocument",
  17210. engine->newFunction(XmlWriter_writeStartDocument));
  17211. value.setProperty("writeStartElement",
  17212. engine->newFunction(XmlWriter_writeStartElement));
  17213. value.setProperty("writeTextElement",
  17214. engine->newFunction(XmlWriter_writeTextElement));
  17215. }
  17216. /*:127*//*128:*/
  17217. #line 3075 "./typica.w"
  17218. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  17219. {
  17220. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17221. QIODevice*device= argument<QIODevice*> (0,context);
  17222. self->setDevice(device);
  17223. return QScriptValue();
  17224. }
  17225. /*:128*//*129:*/
  17226. #line 3089 "./typica.w"
  17227. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  17228. QScriptEngine*)
  17229. {
  17230. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17231. self->writeStartDocument(argument<QString> (0,context));
  17232. return QScriptValue();
  17233. }
  17234. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  17235. QScriptEngine*)
  17236. {
  17237. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17238. self->writeEndDocument();
  17239. return QScriptValue();
  17240. }
  17241. /*:129*//*130:*/
  17242. #line 3108 "./typica.w"
  17243. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  17244. {
  17245. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17246. self->writeDTD(argument<QString> (0,context));
  17247. return QScriptValue();
  17248. }
  17249. /*:130*//*131:*/
  17250. #line 3119 "./typica.w"
  17251. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  17252. QScriptEngine*)
  17253. {
  17254. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17255. self->writeStartElement(argument<QString> (0,context));
  17256. return QScriptValue();
  17257. }
  17258. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  17259. {
  17260. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17261. self->writeAttribute(argument<QString> (0,context),
  17262. argument<QString> (1,context));
  17263. return QScriptValue();
  17264. }
  17265. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  17266. {
  17267. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17268. self->writeCharacters(argument<QString> (0,context));
  17269. return QScriptValue();
  17270. }
  17271. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  17272. {
  17273. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17274. self->writeEndElement();
  17275. return QScriptValue();
  17276. }
  17277. /*:131*//*132:*/
  17278. #line 3155 "./typica.w"
  17279. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  17280. QScriptEngine*)
  17281. {
  17282. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17283. self->writeEmptyElement(argument<QString> (0,context));
  17284. return QScriptValue();
  17285. }
  17286. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  17287. QScriptEngine*)
  17288. {
  17289. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17290. self->writeTextElement(argument<QString> (0,context),
  17291. argument<QString> (1,context));
  17292. return QScriptValue();
  17293. }
  17294. /*:132*//*133:*/
  17295. #line 3176 "./typica.w"
  17296. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  17297. {
  17298. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17299. self->writeCDATA(argument<QString> (0,context));
  17300. return QScriptValue();
  17301. }
  17302. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  17303. QScriptEngine*)
  17304. {
  17305. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17306. self->writeEntityReference(argument<QString> (0,context));
  17307. return QScriptValue();
  17308. }
  17309. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  17310. QScriptEngine*)
  17311. {
  17312. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  17313. self->writeProcessingInstruction(argument<QString> (0,context),
  17314. argument<QString> (1,context));
  17315. return QScriptValue();
  17316. }
  17317. /*:133*//*136:*/
  17318. #line 3235 "./typica.w"
  17319. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  17320. {
  17321. QXmlStreamReader*retval=
  17322. new QXmlStreamReader(argument<QIODevice*> (0,context));
  17323. QScriptValue object= engine->toScriptValue<void*> (retval);
  17324. setXmlReaderProperties(object,engine);
  17325. return object;
  17326. }
  17327. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  17328. {
  17329. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  17330. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  17331. value.setProperty("hasAttribute",
  17332. engine->newFunction(XmlReader_hasAttribute));
  17333. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  17334. value.setProperty("isStartElement",
  17335. engine->newFunction(XmlReader_isStartElement));
  17336. value.setProperty("name",engine->newFunction(XmlReader_name));
  17337. value.setProperty("readElementText",
  17338. engine->newFunction(XmlReader_readElementText));
  17339. value.setProperty("readNext",
  17340. engine->newFunction(XmlReader_readNext));
  17341. value.setProperty("text",engine->newFunction(XmlReader_text));
  17342. }
  17343. /*:136*//*137:*/
  17344. #line 3265 "./typica.w"
  17345. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  17346. {
  17347. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17348. QString retval=
  17349. self->attributes().value(argument<QString> (0,context)).toString();
  17350. return QScriptValue(retval);
  17351. }
  17352. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  17353. {
  17354. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17355. bool retval=
  17356. self->attributes().hasAttribute(argument<QString> (0,context));
  17357. return QScriptValue(retval);
  17358. }
  17359. /*:137*//*138:*/
  17360. #line 3285 "./typica.w"
  17361. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  17362. {
  17363. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17364. return QScriptValue(self->atEnd());
  17365. }
  17366. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  17367. {
  17368. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17369. return QScriptValue(self->isDTD());
  17370. }
  17371. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  17372. {
  17373. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17374. return QScriptValue(self->isStartElement());
  17375. }
  17376. /*:138*//*139:*/
  17377. #line 3306 "./typica.w"
  17378. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  17379. {
  17380. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17381. self->readNext();
  17382. return QScriptValue();
  17383. }
  17384. /*:139*//*140:*/
  17385. #line 3316 "./typica.w"
  17386. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  17387. {
  17388. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17389. return QScriptValue(self->name().toString());
  17390. }
  17391. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  17392. {
  17393. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17394. return QScriptValue(self->readElementText());
  17395. }
  17396. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  17397. {
  17398. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17399. return QScriptValue(self->text().toString());
  17400. }
  17401. /*:140*//*143:*/
  17402. #line 3358 "./typica.w"
  17403. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  17404. {
  17405. setQObjectProperties(value,engine);
  17406. value.setProperty("value",engine->newFunction(QSettings_value));
  17407. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  17408. }
  17409. /*:143*//*144:*/
  17410. #line 3370 "./typica.w"
  17411. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  17412. {
  17413. QScriptValue object;
  17414. if(context->argumentCount()==1||context->argumentCount()==2)
  17415. {
  17416. QSettings settings;
  17417. QString key= argument<QString> (0,context);
  17418. QVariant value;
  17419. QVariant retval;
  17420. if(context->argumentCount()> 1)
  17421. {
  17422. value= argument<QVariant> (1,context);
  17423. retval= settings.value(key,value);
  17424. }
  17425. else
  17426. {
  17427. retval= settings.value(key);
  17428. }
  17429. object= engine->newVariant(retval);
  17430. }
  17431. else
  17432. {
  17433. context->throwError("Incorrect number of arguments passed to "
  17434. "QSettings::value(). This method takes one "
  17435. "string and one optional variant type.");
  17436. }
  17437. return object;
  17438. }
  17439. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  17440. {
  17441. if(context->argumentCount()==2)
  17442. {
  17443. QSettings settings;
  17444. QString key= argument<QString> (0,context);
  17445. QVariant value= argument<QVariant> (1,context);
  17446. settings.setValue(key,value);
  17447. }
  17448. else
  17449. {
  17450. context->throwError("Incorrect number of arguments passed to "
  17451. "QSettings::setValue(). This method takes one "
  17452. "string and one variant type for a total of two "
  17453. "arguments.");
  17454. }
  17455. return QScriptValue();
  17456. }
  17457. /*:144*//*147:*/
  17458. #line 3439 "./typica.w"
  17459. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  17460. {
  17461. QScriptValue object= engine->newQObject(new QLCDNumber());
  17462. setQLCDNumberProperties(object,engine);
  17463. return object;
  17464. }
  17465. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  17466. {
  17467. setQFrameProperties(value,engine);
  17468. }
  17469. /*:147*//*150:*/
  17470. #line 3497 "./typica.w"
  17471. QScriptValue constructQTime(QScriptContext*context,
  17472. QScriptEngine*engine)
  17473. {
  17474. QScriptValue object;
  17475. if(context->argumentCount()==0||
  17476. (context->argumentCount()>=2&&context->argumentCount()<=4))
  17477. {
  17478. int arg1= 0;
  17479. int arg2= 0;
  17480. int arg3= 0;
  17481. int arg4= 0;
  17482. switch(context->argumentCount())
  17483. {
  17484. case 4:
  17485. arg4= argument<int> (3,context);
  17486. case 3:
  17487. arg3= argument<int> (2,context);
  17488. case 2:
  17489. arg2= argument<int> (1,context);
  17490. arg1= argument<int> (0,context);
  17491. default:
  17492. break;
  17493. }
  17494. if(context->argumentCount())
  17495. {
  17496. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  17497. arg4));
  17498. }
  17499. else
  17500. {
  17501. object= engine->toScriptValue<QTime> (QTime());
  17502. }
  17503. setQTimeProperties(object,engine);
  17504. }
  17505. else
  17506. {
  17507. context->throwError("Incorrect number of arguments passed to "
  17508. "QTime::QTime(). This method takes zero, two, "
  17509. "three, or four integer arguments.");
  17510. }
  17511. return object;
  17512. }
  17513. /*:150*//*151:*/
  17514. #line 3545 "./typica.w"
  17515. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  17516. {
  17517. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  17518. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  17519. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  17520. value.setProperty("hour",engine->newFunction(QTime_hour));
  17521. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  17522. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  17523. value.setProperty("minute",engine->newFunction(QTime_minute));
  17524. value.setProperty("msec",engine->newFunction(QTime_msec));
  17525. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  17526. value.setProperty("restart",engine->newFunction(QTime_restart));
  17527. value.setProperty("second",engine->newFunction(QTime_second));
  17528. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  17529. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  17530. value.setProperty("start",engine->newFunction(QTime_start));
  17531. value.setProperty("toString",engine->newFunction(QTime_toString));
  17532. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  17533. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  17534. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  17535. }
  17536. /*:151*//*152:*/
  17537. #line 3574 "./typica.w"
  17538. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  17539. {
  17540. QTime self= getself<QTime> (context);
  17541. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  17542. (self.second()*1000)+self.msec();
  17543. return QScriptValue(retval);
  17544. }
  17545. /*:152*//*153:*/
  17546. #line 3588 "./typica.w"
  17547. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  17548. {
  17549. QTime time;
  17550. QScriptValue retval;
  17551. if(context->argumentCount()==1)
  17552. {
  17553. QTime self= getself<QTime> (context);
  17554. time= self.addMSecs(argument<int> (0,context));
  17555. retval= engine->toScriptValue<QTime> (time);
  17556. setQTimeProperties(retval,engine);
  17557. }
  17558. else
  17559. {
  17560. context->throwError("Incorrect number of arguments passed to "
  17561. "QTime::addMSecs(). This method takes one "
  17562. "integer as an argument.");
  17563. }
  17564. return retval;
  17565. }
  17566. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  17567. {
  17568. QTime time;
  17569. QScriptValue retval;
  17570. if(context->argumentCount()==1)
  17571. {
  17572. QTime self= getself<QTime> (context);
  17573. time= self.addSecs(argument<int> (0,context));
  17574. retval= engine->toScriptValue<QTime> (time);
  17575. setQTimeProperties(retval,engine);
  17576. }
  17577. else
  17578. {
  17579. context->throwError("Incorrect number of arguments passed to "
  17580. "QTime::addSecs(). This method takes one "
  17581. "integer as an argument.");
  17582. }
  17583. return retval;
  17584. }
  17585. /*:153*//*154:*/
  17586. #line 3631 "./typica.w"
  17587. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  17588. {
  17589. QScriptValue retval;
  17590. if(context->argumentCount()==0)
  17591. {
  17592. QTime self= getself<QTime> (context);
  17593. retval= QScriptValue(engine,self.elapsed());
  17594. }
  17595. else
  17596. {
  17597. context->throwError("Incorrect number of arguments passed to "
  17598. "QTime::elapsed(). This method takes no "
  17599. "arguments.");
  17600. }
  17601. return retval;
  17602. }
  17603. /*:154*//*155:*/
  17604. #line 3652 "./typica.w"
  17605. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  17606. {
  17607. QScriptValue retval;
  17608. if(context->argumentCount()==0)
  17609. {
  17610. QTime self= getself<QTime> (context);
  17611. retval= QScriptValue(engine,self.hour());
  17612. }
  17613. else
  17614. {
  17615. context->throwError("Incorrect number of arguments passed to "
  17616. "QTime::hour(). This method takes no "
  17617. "arguments.");
  17618. }
  17619. return retval;
  17620. }
  17621. /*:155*//*156:*/
  17622. #line 3672 "./typica.w"
  17623. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  17624. {
  17625. QScriptValue retval;
  17626. if(context->argumentCount()==0)
  17627. {
  17628. QTime self= getself<QTime> (context);
  17629. retval= QScriptValue(engine,self.minute());
  17630. }
  17631. else
  17632. {
  17633. context->throwError("Incorrect number of arguments passed to "
  17634. "QTime::minute(). This method takes no "
  17635. "arguments.");
  17636. }
  17637. return retval;
  17638. }
  17639. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  17640. {
  17641. QScriptValue retval;
  17642. if(context->argumentCount()==0)
  17643. {
  17644. QTime self= getself<QTime> (context);
  17645. retval= QScriptValue(engine,self.second());
  17646. }
  17647. else
  17648. {
  17649. context->throwError("Incorrect number of arguments passed to "
  17650. "QTime::second(). This method takes no "
  17651. "arguments.");
  17652. }
  17653. return retval;
  17654. }
  17655. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  17656. {
  17657. QScriptValue retval;
  17658. if(context->argumentCount()==0)
  17659. {
  17660. QTime self= getself<QTime> (context);
  17661. retval= QScriptValue(engine,self.msec());
  17662. }
  17663. else
  17664. {
  17665. context->throwError("Incorrect number of arguments passed to "
  17666. "QTime::msec(). This method takes no "
  17667. "arguments.");
  17668. }
  17669. return retval;
  17670. }
  17671. /*:156*//*157:*/
  17672. #line 3728 "./typica.w"
  17673. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  17674. {
  17675. QScriptValue retval;
  17676. if(context->argumentCount()==0)
  17677. {
  17678. QTime self= getself<QTime> (context);
  17679. retval= QScriptValue(engine,self.isNull());
  17680. }
  17681. else
  17682. {
  17683. context->throwError("Incorrect number of arguments passed to "
  17684. "QTime::isNull(). This method takes no "
  17685. "arguments.");
  17686. }
  17687. return retval;
  17688. }
  17689. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  17690. {
  17691. QScriptValue retval;
  17692. if(context->argumentCount()==0)
  17693. {
  17694. QTime self= getself<QTime> (context);
  17695. retval= QScriptValue(engine,self.isValid());
  17696. }
  17697. else
  17698. {
  17699. context->throwError("Incorrect number of arguments passed to "
  17700. "QTime::isValid(). This method takes no "
  17701. "arguments.");
  17702. }
  17703. return retval;
  17704. }
  17705. /*:157*//*158:*/
  17706. #line 3766 "./typica.w"
  17707. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  17708. {
  17709. QScriptValue retval;
  17710. if(context->argumentCount()==1)
  17711. {
  17712. QTime self= getself<QTime> (context);
  17713. QTime arg= argument<QVariant> (0,context).toTime();
  17714. retval= QScriptValue(engine,self.msecsTo(arg));
  17715. }
  17716. else
  17717. {
  17718. context->throwError("Incorrect number of arguments passed to "
  17719. "QTime::msecsTo(). This method takes one QTime.");
  17720. }
  17721. return retval;
  17722. }
  17723. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  17724. {
  17725. QScriptValue retval;
  17726. if(context->argumentCount()==1)
  17727. {
  17728. QTime self= getself<QTime> (context);
  17729. QTime arg= argument<QVariant> (0,context).toTime();
  17730. retval= QScriptValue(engine,self.secsTo(arg));
  17731. }
  17732. else
  17733. {
  17734. context->throwError("Incorrect number of arguments passed to "
  17735. "QTime::secsTo(). This method takes one QTime.");
  17736. }
  17737. return retval;
  17738. }
  17739. /*:158*//*159:*/
  17740. #line 3805 "./typica.w"
  17741. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  17742. {
  17743. QScriptValue retval;
  17744. if(context->argumentCount()==0)
  17745. {
  17746. QTime self= getself<QTime> (context);
  17747. retval= QScriptValue(engine,self.restart());
  17748. }
  17749. else
  17750. {
  17751. context->throwError("Incorrect number of arguments passed to "
  17752. "QTime::restart(). This method takes no "
  17753. "arguments.");
  17754. }
  17755. return retval;
  17756. }
  17757. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  17758. {
  17759. if(context->argumentCount()==0)
  17760. {
  17761. QTime self= getself<QTime> (context);
  17762. self.start();
  17763. }
  17764. else
  17765. {
  17766. context->throwError("Incorrect number of arguments passed to "
  17767. "QTime::start(). This method takes no arguments.");
  17768. }
  17769. return QScriptValue();
  17770. }
  17771. /*:159*//*160:*/
  17772. #line 3841 "./typica.w"
  17773. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  17774. {
  17775. QScriptValue retval;
  17776. if(context->argumentCount()==3||context->argumentCount()==4)
  17777. {
  17778. QTime self= getself<QTime> (context);
  17779. int arg1= 0;
  17780. int arg2= 0;
  17781. int arg3= 0;
  17782. int arg4= 0;
  17783. switch(context->argumentCount())
  17784. {
  17785. case 4:
  17786. arg4= argument<int> (3,context);
  17787. case 3:
  17788. arg3= argument<int> (2,context);
  17789. arg2= argument<int> (1,context);
  17790. arg1= argument<int> (0,context);
  17791. default:
  17792. break;
  17793. }
  17794. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  17795. }
  17796. else
  17797. {
  17798. context->throwError("Incorrect number of arguments passed to "
  17799. "QTime::setHMS(). This method takes three or "
  17800. "four integer arguments.");
  17801. }
  17802. return retval;
  17803. }
  17804. /*:160*//*161:*/
  17805. #line 3877 "./typica.w"
  17806. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  17807. {
  17808. QScriptValue retval;
  17809. if(context->argumentCount()==1)
  17810. {
  17811. QTime self= getself<QTime> (context);
  17812. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  17813. }
  17814. else
  17815. {
  17816. context->throwError("Incorrect number of arguments passed to "
  17817. "QTime::toString(). This method takes one QString "
  17818. "as an argument.");
  17819. }
  17820. return retval;
  17821. }
  17822. /*:161*//*162:*/
  17823. #line 3898 "./typica.w"
  17824. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  17825. {
  17826. QScriptValue object;
  17827. object= engine->toScriptValue<QTime> (QTime::currentTime());
  17828. setQTimeProperties(object,engine);
  17829. return object;
  17830. }
  17831. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  17832. {
  17833. QScriptValue object;
  17834. if(context->argumentCount()==2)
  17835. {
  17836. QString time= argument<QString> (0,context);
  17837. QString format= argument<QString> (1,context);
  17838. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  17839. setQTimeProperties(object,engine);
  17840. }
  17841. else
  17842. {
  17843. context->throwError("Incorrect number of arguments passed to "
  17844. "QTime::fromString(). This method takes two "
  17845. "string arguments.");
  17846. }
  17847. return object;
  17848. }
  17849. /*:162*//*163:*/
  17850. #line 3929 "./typica.w"
  17851. template<> QTime argument(int arg,QScriptContext*context)
  17852. {
  17853. return qscriptvalue_cast<QTime> (context->argument(arg));
  17854. }
  17855. /*:163*//*166:*/
  17856. #line 3952 "./typica.w"
  17857. QScriptValue constructQColor(QScriptContext*context,QScriptEngine*engine)
  17858. {
  17859. QScriptValue object= engine->toScriptValue<QColor> (QColor(argument<QString> (0,context)));
  17860. return object;
  17861. }
  17862. /*:166*//*169:*/
  17863. #line 3975 "./typica.w"
  17864. QScriptValue constructQBrush(QScriptContext*context,QScriptEngine*engine)
  17865. {
  17866. QBrush theBrush= QBrush(QColor(argument<QString> (0,context)));
  17867. QScriptValue object= engine->toScriptValue(theBrush);
  17868. return object;
  17869. }
  17870. /*:169*//*171:*/
  17871. #line 3995 "./typica.w"
  17872. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  17873. {
  17874. setQFrameProperties(value,engine);
  17875. }
  17876. /*:171*//*173:*/
  17877. #line 4009 "./typica.w"
  17878. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  17879. {
  17880. setQAbstractScrollAreaProperties(value,engine);
  17881. }
  17882. /*:173*//*175:*/
  17883. #line 4023 "./typica.w"
  17884. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  17885. {
  17886. setQAbstractScrollAreaProperties(value,engine);
  17887. }
  17888. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  17889. {
  17890. setQAbstractItemViewProperties(value,engine);
  17891. }
  17892. /*:175*//*178:*/
  17893. #line 4056 "./typica.w"
  17894. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  17895. {
  17896. QScriptValue object= engine->newQObject(new QPushButton());
  17897. setQPushButtonProperties(object,engine);
  17898. return object;
  17899. }
  17900. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  17901. {
  17902. setQAbstractButtonProperties(value,engine);
  17903. }
  17904. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  17905. {
  17906. setQWidgetProperties(value,engine);
  17907. }
  17908. /*:178*//*185:*/
  17909. #line 4168 "./typica.w"
  17910. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  17911. {
  17912. SqlQueryConnection*obj= new SqlQueryConnection();
  17913. QScriptValue object=
  17914. engine->toScriptValue<void*> (obj);
  17915. setQSqlQueryProperties(object,engine);
  17916. return object;
  17917. }
  17918. /*:185*//*186:*/
  17919. #line 4181 "./typica.w"
  17920. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  17921. {
  17922. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  17923. value.setProperty("bindFileData",
  17924. engine->newFunction(QSqlQuery_bindFileData));
  17925. value.setProperty("bindDeviceData",
  17926. engine->newFunction(QSqlQuery_bindDeviceData));
  17927. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  17928. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  17929. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  17930. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  17931. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  17932. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  17933. }
  17934. /*:186*//*187:*/
  17935. #line 4199 "./typica.w"
  17936. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  17937. {
  17938. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  17939. QScriptValue retval;
  17940. if(context->argumentCount()==1)
  17941. {
  17942. retval= QScriptValue(engine,
  17943. q->exec(argument<QString> (0,context)));
  17944. }
  17945. else
  17946. {
  17947. retval= QScriptValue(engine,q->exec());
  17948. }
  17949. if(q->lastError().isValid())
  17950. {
  17951. qDebug()<<q->lastQuery();
  17952. qDebug()<<q->lastError().text();
  17953. }
  17954. return retval;
  17955. }
  17956. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  17957. {
  17958. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17959. return QScriptValue(query->lastQuery());
  17960. }
  17961. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  17962. {
  17963. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17964. return QScriptValue(engine,query->next());
  17965. }
  17966. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  17967. {
  17968. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17969. return QScriptValue(engine,
  17970. query->value(argument<int> (0,context)).toString());
  17971. }
  17972. /*:187*//*188:*/
  17973. #line 4243 "./typica.w"
  17974. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  17975. {
  17976. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17977. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  17978. }
  17979. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  17980. {
  17981. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17982. query->bindValue(argument<QString> (0,context),
  17983. argument<QVariant> (1,context));
  17984. return QScriptValue();
  17985. }
  17986. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  17987. QScriptEngine*)
  17988. {
  17989. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17990. QString placeholder= argument<QString> (0,context);
  17991. QString filename= argument<QString> (1,context);
  17992. QFile file(filename);
  17993. QByteArray data;
  17994. if(file.open(QIODevice::ReadOnly))
  17995. {
  17996. data= file.readAll();
  17997. file.close();
  17998. }
  17999. query->bindValue(placeholder,data);
  18000. return QScriptValue();
  18001. }
  18002. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  18003. QScriptEngine*)
  18004. {
  18005. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  18006. QString placeholder= argument<QString> (0,context);
  18007. QIODevice*device= argument<QIODevice*> (1,context);
  18008. device->reset();
  18009. QByteArray data;
  18010. data= device->readAll();
  18011. query->bindValue(placeholder,data);
  18012. return QScriptValue();
  18013. }
  18014. /*:188*//*189:*/
  18015. #line 4295 "./typica.w"
  18016. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  18017. {
  18018. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  18019. delete query;
  18020. return QScriptValue::UndefinedValue;
  18021. }
  18022. /*:189*//*192:*/
  18023. #line 4342 "./typica.w"
  18024. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  18025. {
  18026. QFileInfo info(argument<QString> (0,context));
  18027. QScriptValue retval(engine,info.baseName());
  18028. return retval;
  18029. }
  18030. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  18031. {
  18032. QFileInfo info(argument<QString> (0,context));
  18033. QDir dir= info.dir();
  18034. QScriptValue retval(engine,dir.path());
  18035. return retval;
  18036. }
  18037. /*:192*//*193:*/
  18038. #line 4361 "./typica.w"
  18039. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  18040. {
  18041. SqlQueryConnection h;
  18042. QSqlQuery*query= h.operator->();
  18043. QString q= "SELECT file FROM files WHERE id = :file";
  18044. query->prepare(q);
  18045. query->bindValue(":file",argument<int> (0,context));
  18046. query->exec();
  18047. query->next();
  18048. QByteArray array= query->value(0).toByteArray();
  18049. QFile file(argument<QString> (1,context));
  18050. file.open(QIODevice::WriteOnly);
  18051. file.write(array);
  18052. file.close();
  18053. return QScriptValue();
  18054. }
  18055. /*:193*//*194:*/
  18056. #line 4382 "./typica.w"
  18057. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  18058. {
  18059. QString source= argument<QString> (0,context);
  18060. source.remove(0,1);
  18061. source.chop(1);
  18062. QStringList elements= source.split(",");
  18063. QString element;
  18064. QScriptValue dest= engine->newArray(elements.size());
  18065. int i= 0;
  18066. foreach(element,elements)
  18067. {
  18068. if(element.startsWith("\"")&&element.endsWith("\""))
  18069. {
  18070. element.chop(1);
  18071. element= element.remove(0,1);
  18072. }
  18073. dest.setProperty(i,QScriptValue(engine,element));
  18074. i++;
  18075. }
  18076. return dest;
  18077. }
  18078. /*:194*//*195:*/
  18079. #line 4408 "./typica.w"
  18080. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  18081. {
  18082. QString font= argument<QString> (0,context);
  18083. QString classname;
  18084. if(context->argumentCount()> 1)
  18085. {
  18086. classname= argument<QString> (1,context);
  18087. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  18088. }
  18089. else
  18090. {
  18091. QApplication::setFont(QFont(font));
  18092. }
  18093. return QScriptValue();
  18094. }
  18095. /*:195*//*196:*/
  18096. #line 4428 "./typica.w"
  18097. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  18098. {
  18099. SqlQueryConnection h;
  18100. QSqlQuery*query= h.operator->();
  18101. QString q= "SELECT file FROM files WHERE id = :file";
  18102. query->prepare(q);
  18103. query->bindValue(":file",argument<int> (0,context));
  18104. query->exec();
  18105. query->next();
  18106. QByteArray array= query->value(0).toByteArray();
  18107. QBuffer buffer(&array);
  18108. buffer.open(QIODevice::ReadOnly);
  18109. QXmlQuery xquery;
  18110. xquery.bindVariable("profile",&buffer);
  18111. QString xq;
  18112. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  18113. xquery.setQuery(xq);
  18114. QString result;
  18115. xquery.evaluateTo(&result);
  18116. return QScriptValue(result);
  18117. }
  18118. /*:196*//*197:*/
  18119. #line 4455 "./typica.w"
  18120. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  18121. {
  18122. QWidget::setTabOrder(argument<QWidget*> (0,context),
  18123. argument<QWidget*> (1,context));
  18124. return QScriptValue();
  18125. }
  18126. /*:197*//*198:*/
  18127. #line 4466 "./typica.w"
  18128. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  18129. {
  18130. return QScriptValue(QCoreApplication::translate(
  18131. "configuration",
  18132. argument<QString> (1,context).toUtf8().data()));
  18133. }
  18134. /*:198*//*205:*/
  18135. #line 4735 "./typica.w"
  18136. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  18137. {
  18138. QString targetID= argument<QString> (0,context);
  18139. QDomNode element;
  18140. QScriptValue object;
  18141. /*207:*/
  18142. #line 4782 "./typica.w"
  18143. QDomNodeList windows=
  18144. AppInstance->configuration()->documentElement().elementsByTagName("window");
  18145. QDomNode nullNode;
  18146. int i= 0;
  18147. element= nullNode;
  18148. while(i<windows.count())
  18149. {
  18150. element= windows.at(i);
  18151. QDomNamedNodeMap attributes= element.attributes();
  18152. if(attributes.contains("id"))
  18153. {
  18154. if(attributes.namedItem("id").toAttr().value()==targetID)
  18155. {
  18156. break;
  18157. }
  18158. }
  18159. element= nullNode;
  18160. i++;
  18161. }
  18162. /*:207*/
  18163. #line 4741 "./typica.w"
  18164. if(!element.isNull())
  18165. {
  18166. /*208:*/
  18167. #line 4814 "./typica.w"
  18168. ScriptQMainWindow*window= new ScriptQMainWindow;
  18169. window->setObjectName(targetID);
  18170. object= engine->newQObject(window);
  18171. setQMainWindowProperties(object,engine);
  18172. QWidget*central= new(QWidget);
  18173. central->setParent(window);
  18174. central->setObjectName("centralWidget");
  18175. window->setCentralWidget(central);
  18176. if(element.hasChildNodes())
  18177. {
  18178. /*209:*/
  18179. #line 4850 "./typica.w"
  18180. QStack<QWidget*> widgetStack;
  18181. QStack<QLayout*> layoutStack;
  18182. QString windowScript;
  18183. widgetStack.push(central);
  18184. QDomNodeList windowChildren= element.childNodes();
  18185. int i= 0;
  18186. while(i<windowChildren.count())
  18187. {
  18188. QDomNode current;
  18189. QDomElement element;
  18190. current= windowChildren.at(i);
  18191. if(current.isElement())
  18192. {
  18193. element= current.toElement();
  18194. if(element.tagName()=="program")
  18195. {
  18196. windowScript.append(element.text());
  18197. }
  18198. else if(element.tagName()=="layout")
  18199. {
  18200. element.setAttribute("trcontext","configuration");
  18201. addLayoutToWidget(element,&widgetStack,&layoutStack);
  18202. }
  18203. else if(element.tagName()=="menu")
  18204. {
  18205. /*210:*/
  18206. #line 4898 "./typica.w"
  18207. QMenuBar*bar= window->menuBar();
  18208. bar->setParent(window);
  18209. bar->setObjectName("menuBar");
  18210. if(element.hasAttribute("name"))
  18211. {
  18212. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  18213. element.attribute("name").toUtf8().data()));
  18214. menu->setParent(bar);
  18215. if(element.hasAttribute("type"))
  18216. {
  18217. if(element.attribute("type")=="reports")
  18218. {
  18219. if(element.hasAttribute("src"))
  18220. {
  18221. /*679:*/
  18222. #line 14431 "./typica.w"
  18223. QSettings settings;
  18224. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  18225. toString()).
  18226. arg(element.attribute("src"));
  18227. QDir::addSearchPath("reports",reportDirectory);
  18228. QDir directory(reportDirectory);
  18229. directory.setFilter(QDir::Files);
  18230. directory.setSorting(QDir::Name);
  18231. QStringList nameFilter;
  18232. nameFilter<<"*.xml";
  18233. directory.setNameFilters(nameFilter);
  18234. QFileInfoList reportFiles= directory.entryInfoList();
  18235. for(int i= 0;i<reportFiles.size();i++)
  18236. {
  18237. QFileInfo reportFile= reportFiles.at(i);
  18238. /*683:*/
  18239. #line 14511 "./typica.w"
  18240. QString path= reportFile.absoluteFilePath();
  18241. QFile file(path);
  18242. if(file.open(QIODevice::ReadOnly))
  18243. {
  18244. QDomDocument document;
  18245. document.setContent(&file,true);
  18246. QDomElement root= document.documentElement();
  18247. QString translationContext= root.attribute("id");
  18248. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  18249. if(!titleNode.isNull())
  18250. {
  18251. QDomElement titleElement= titleNode.toElement();
  18252. QString title= QCoreApplication::translate("configuration",
  18253. titleElement.text().toUtf8().data());
  18254. if(!title.isEmpty())
  18255. {
  18256. QStringList hierarchy= title.split(":->");
  18257. QMenu*insertionPoint= menu;
  18258. /*684:*/
  18259. #line 14540 "./typica.w"
  18260. for(int j= 0;j<hierarchy.size()-1;j++)
  18261. {
  18262. QObjectList menuList= insertionPoint->children();
  18263. bool menuFound= false;
  18264. for(int k= 0;k<menuList.size();k++)
  18265. {
  18266. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  18267. if(currentItem)
  18268. {
  18269. if(currentItem->title()==hierarchy.at(j))
  18270. {
  18271. menuFound= true;
  18272. insertionPoint= currentItem;
  18273. break;
  18274. }
  18275. }
  18276. }
  18277. if(!menuFound)
  18278. {
  18279. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  18280. }
  18281. }
  18282. /*:684*/
  18283. #line 14530 "./typica.w"
  18284. ReportAction*action= new ReportAction(path,hierarchy.last());
  18285. insertionPoint->addAction(action);
  18286. }
  18287. }
  18288. }
  18289. /*:683*/
  18290. #line 14447 "./typica.w"
  18291. }
  18292. /*:679*/
  18293. #line 4913 "./typica.w"
  18294. }
  18295. }
  18296. }
  18297. if(element.hasChildNodes())
  18298. {
  18299. /*211:*/
  18300. #line 4926 "./typica.w"
  18301. QDomNodeList menuItems= element.childNodes();
  18302. int j= 0;
  18303. while(j<menuItems.count())
  18304. {
  18305. QDomNode item= menuItems.at(j);
  18306. if(item.isElement())
  18307. {
  18308. QDomElement itemElement= item.toElement();
  18309. if(itemElement.tagName()=="item")
  18310. {
  18311. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  18312. itemElement.text().toUtf8().data()),menu);
  18313. if(itemElement.hasAttribute("id"))
  18314. {
  18315. itemAction->setObjectName(itemElement.attribute("id"));
  18316. }
  18317. if(itemElement.hasAttribute("shortcut"))
  18318. {
  18319. itemAction->setShortcut(itemElement.attribute("shortcut"));
  18320. }
  18321. menu->addAction(itemAction);
  18322. }
  18323. else if(itemElement.tagName()=="separator")
  18324. {
  18325. menu->addSeparator();
  18326. }
  18327. else if(itemElement.tagName()=="plugins")
  18328. {
  18329. /*704:*/
  18330. #line 21 "./plugins.w"
  18331. QMenu*pluginMenu= new QMenu(menu);
  18332. if(itemElement.hasAttribute("id"))
  18333. {
  18334. pluginMenu->setObjectName(itemElement.attribute("id"));
  18335. }
  18336. if(itemElement.hasAttribute("title"))
  18337. {
  18338. pluginMenu->setTitle(itemElement.attribute("title"));
  18339. }
  18340. if(itemElement.hasAttribute("src"))
  18341. {
  18342. QSettings settings;
  18343. QString pluginDirectory= QString("%1/%2").
  18344. arg(settings.value("config").toString()).
  18345. arg(itemElement.attribute("src"));
  18346. QDir directory(pluginDirectory);
  18347. directory.setFilter(QDir::Files);
  18348. directory.setSorting(QDir::Name);
  18349. QStringList nameFilter;
  18350. nameFilter<<"*.js";
  18351. directory.setNameFilters(nameFilter);
  18352. QFileInfoList pluginFiles= directory.entryInfoList();
  18353. for(int k= 0;k<pluginFiles.size();k++)
  18354. {
  18355. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  18356. if(itemElement.hasAttribute("preRun"))
  18357. {
  18358. pa->setPreRun(itemElement.attribute("preRun"));
  18359. }
  18360. if(itemElement.hasAttribute("postRun"))
  18361. {
  18362. pa->setPostRun(itemElement.attribute("postRun"));
  18363. }
  18364. pluginMenu->addAction(pa);
  18365. }
  18366. }
  18367. menu->addMenu(pluginMenu);
  18368. /*:704*/
  18369. #line 4955 "./typica.w"
  18370. }
  18371. }
  18372. j++;
  18373. }
  18374. #line 1 "./helpmenu.w"
  18375. /*:211*/
  18376. #line 4919 "./typica.w"
  18377. }
  18378. }
  18379. /*:210*/
  18380. #line 4876 "./typica.w"
  18381. }
  18382. }
  18383. i++;
  18384. }
  18385. QScriptValue oldThis= context->thisObject();
  18386. context->setThisObject(object);
  18387. QScriptValue result= engine->evaluate(windowScript);
  18388. /*202:*/
  18389. #line 4629 "./typica.w"
  18390. if(engine->hasUncaughtException())
  18391. {
  18392. int line= engine->uncaughtExceptionLineNumber();
  18393. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18394. result.toString();
  18395. QString trace;
  18396. foreach(trace,engine->uncaughtExceptionBacktrace())
  18397. {
  18398. qDebug()<<trace;
  18399. }
  18400. }
  18401. /*:202*/
  18402. #line 4884 "./typica.w"
  18403. context->setThisObject(oldThis);
  18404. /*:209*/
  18405. #line 4825 "./typica.w"
  18406. }
  18407. /*212:*/
  18408. #line 9 "./helpmenu.w"
  18409. HelpMenu*helpMenu= new HelpMenu();
  18410. window->menuBar()->addMenu(helpMenu);
  18411. /*:212*/
  18412. #line 4827 "./typica.w"
  18413. window->show();
  18414. window->setupFinished();
  18415. /*:208*/
  18416. #line 4744 "./typica.w"
  18417. }
  18418. return object;
  18419. }
  18420. /*:205*//*206:*/
  18421. #line 4755 "./typica.w"
  18422. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  18423. {
  18424. QString targetID= argument<QString> (0,context);
  18425. QFile file(QString("reports:%1").arg(targetID));
  18426. QScriptValue object;
  18427. if(file.open(QIODevice::ReadOnly))
  18428. {
  18429. QDomDocument document;
  18430. document.setContent(&file,true);
  18431. QDomElement element= document.documentElement();
  18432. if(!element.isNull())
  18433. {
  18434. /*208:*/
  18435. #line 4814 "./typica.w"
  18436. ScriptQMainWindow*window= new ScriptQMainWindow;
  18437. window->setObjectName(targetID);
  18438. object= engine->newQObject(window);
  18439. setQMainWindowProperties(object,engine);
  18440. QWidget*central= new(QWidget);
  18441. central->setParent(window);
  18442. central->setObjectName("centralWidget");
  18443. window->setCentralWidget(central);
  18444. if(element.hasChildNodes())
  18445. {
  18446. /*209:*/
  18447. #line 4850 "./typica.w"
  18448. QStack<QWidget*> widgetStack;
  18449. QStack<QLayout*> layoutStack;
  18450. QString windowScript;
  18451. widgetStack.push(central);
  18452. QDomNodeList windowChildren= element.childNodes();
  18453. int i= 0;
  18454. while(i<windowChildren.count())
  18455. {
  18456. QDomNode current;
  18457. QDomElement element;
  18458. current= windowChildren.at(i);
  18459. if(current.isElement())
  18460. {
  18461. element= current.toElement();
  18462. if(element.tagName()=="program")
  18463. {
  18464. windowScript.append(element.text());
  18465. }
  18466. else if(element.tagName()=="layout")
  18467. {
  18468. element.setAttribute("trcontext","configuration");
  18469. addLayoutToWidget(element,&widgetStack,&layoutStack);
  18470. }
  18471. else if(element.tagName()=="menu")
  18472. {
  18473. /*210:*/
  18474. #line 4898 "./typica.w"
  18475. QMenuBar*bar= window->menuBar();
  18476. bar->setParent(window);
  18477. bar->setObjectName("menuBar");
  18478. if(element.hasAttribute("name"))
  18479. {
  18480. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  18481. element.attribute("name").toUtf8().data()));
  18482. menu->setParent(bar);
  18483. if(element.hasAttribute("type"))
  18484. {
  18485. if(element.attribute("type")=="reports")
  18486. {
  18487. if(element.hasAttribute("src"))
  18488. {
  18489. /*679:*/
  18490. #line 14431 "./typica.w"
  18491. QSettings settings;
  18492. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  18493. toString()).
  18494. arg(element.attribute("src"));
  18495. QDir::addSearchPath("reports",reportDirectory);
  18496. QDir directory(reportDirectory);
  18497. directory.setFilter(QDir::Files);
  18498. directory.setSorting(QDir::Name);
  18499. QStringList nameFilter;
  18500. nameFilter<<"*.xml";
  18501. directory.setNameFilters(nameFilter);
  18502. QFileInfoList reportFiles= directory.entryInfoList();
  18503. for(int i= 0;i<reportFiles.size();i++)
  18504. {
  18505. QFileInfo reportFile= reportFiles.at(i);
  18506. /*683:*/
  18507. #line 14511 "./typica.w"
  18508. QString path= reportFile.absoluteFilePath();
  18509. QFile file(path);
  18510. if(file.open(QIODevice::ReadOnly))
  18511. {
  18512. QDomDocument document;
  18513. document.setContent(&file,true);
  18514. QDomElement root= document.documentElement();
  18515. QString translationContext= root.attribute("id");
  18516. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  18517. if(!titleNode.isNull())
  18518. {
  18519. QDomElement titleElement= titleNode.toElement();
  18520. QString title= QCoreApplication::translate("configuration",
  18521. titleElement.text().toUtf8().data());
  18522. if(!title.isEmpty())
  18523. {
  18524. QStringList hierarchy= title.split(":->");
  18525. QMenu*insertionPoint= menu;
  18526. /*684:*/
  18527. #line 14540 "./typica.w"
  18528. for(int j= 0;j<hierarchy.size()-1;j++)
  18529. {
  18530. QObjectList menuList= insertionPoint->children();
  18531. bool menuFound= false;
  18532. for(int k= 0;k<menuList.size();k++)
  18533. {
  18534. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  18535. if(currentItem)
  18536. {
  18537. if(currentItem->title()==hierarchy.at(j))
  18538. {
  18539. menuFound= true;
  18540. insertionPoint= currentItem;
  18541. break;
  18542. }
  18543. }
  18544. }
  18545. if(!menuFound)
  18546. {
  18547. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  18548. }
  18549. }
  18550. /*:684*/
  18551. #line 14530 "./typica.w"
  18552. ReportAction*action= new ReportAction(path,hierarchy.last());
  18553. insertionPoint->addAction(action);
  18554. }
  18555. }
  18556. }
  18557. /*:683*/
  18558. #line 14447 "./typica.w"
  18559. }
  18560. /*:679*/
  18561. #line 4913 "./typica.w"
  18562. }
  18563. }
  18564. }
  18565. if(element.hasChildNodes())
  18566. {
  18567. /*211:*/
  18568. #line 4926 "./typica.w"
  18569. QDomNodeList menuItems= element.childNodes();
  18570. int j= 0;
  18571. while(j<menuItems.count())
  18572. {
  18573. QDomNode item= menuItems.at(j);
  18574. if(item.isElement())
  18575. {
  18576. QDomElement itemElement= item.toElement();
  18577. if(itemElement.tagName()=="item")
  18578. {
  18579. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  18580. itemElement.text().toUtf8().data()),menu);
  18581. if(itemElement.hasAttribute("id"))
  18582. {
  18583. itemAction->setObjectName(itemElement.attribute("id"));
  18584. }
  18585. if(itemElement.hasAttribute("shortcut"))
  18586. {
  18587. itemAction->setShortcut(itemElement.attribute("shortcut"));
  18588. }
  18589. menu->addAction(itemAction);
  18590. }
  18591. else if(itemElement.tagName()=="separator")
  18592. {
  18593. menu->addSeparator();
  18594. }
  18595. else if(itemElement.tagName()=="plugins")
  18596. {
  18597. /*704:*/
  18598. #line 21 "./plugins.w"
  18599. QMenu*pluginMenu= new QMenu(menu);
  18600. if(itemElement.hasAttribute("id"))
  18601. {
  18602. pluginMenu->setObjectName(itemElement.attribute("id"));
  18603. }
  18604. if(itemElement.hasAttribute("title"))
  18605. {
  18606. pluginMenu->setTitle(itemElement.attribute("title"));
  18607. }
  18608. if(itemElement.hasAttribute("src"))
  18609. {
  18610. QSettings settings;
  18611. QString pluginDirectory= QString("%1/%2").
  18612. arg(settings.value("config").toString()).
  18613. arg(itemElement.attribute("src"));
  18614. QDir directory(pluginDirectory);
  18615. directory.setFilter(QDir::Files);
  18616. directory.setSorting(QDir::Name);
  18617. QStringList nameFilter;
  18618. nameFilter<<"*.js";
  18619. directory.setNameFilters(nameFilter);
  18620. QFileInfoList pluginFiles= directory.entryInfoList();
  18621. for(int k= 0;k<pluginFiles.size();k++)
  18622. {
  18623. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  18624. if(itemElement.hasAttribute("preRun"))
  18625. {
  18626. pa->setPreRun(itemElement.attribute("preRun"));
  18627. }
  18628. if(itemElement.hasAttribute("postRun"))
  18629. {
  18630. pa->setPostRun(itemElement.attribute("postRun"));
  18631. }
  18632. pluginMenu->addAction(pa);
  18633. }
  18634. }
  18635. menu->addMenu(pluginMenu);
  18636. /*:704*/
  18637. #line 4955 "./typica.w"
  18638. }
  18639. }
  18640. j++;
  18641. }
  18642. #line 1 "./helpmenu.w"
  18643. /*:211*/
  18644. #line 4919 "./typica.w"
  18645. }
  18646. }
  18647. /*:210*/
  18648. #line 4876 "./typica.w"
  18649. }
  18650. }
  18651. i++;
  18652. }
  18653. QScriptValue oldThis= context->thisObject();
  18654. context->setThisObject(object);
  18655. QScriptValue result= engine->evaluate(windowScript);
  18656. /*202:*/
  18657. #line 4629 "./typica.w"
  18658. if(engine->hasUncaughtException())
  18659. {
  18660. int line= engine->uncaughtExceptionLineNumber();
  18661. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18662. result.toString();
  18663. QString trace;
  18664. foreach(trace,engine->uncaughtExceptionBacktrace())
  18665. {
  18666. qDebug()<<trace;
  18667. }
  18668. }
  18669. /*:202*/
  18670. #line 4884 "./typica.w"
  18671. context->setThisObject(oldThis);
  18672. /*:209*/
  18673. #line 4825 "./typica.w"
  18674. }
  18675. /*212:*/
  18676. #line 9 "./helpmenu.w"
  18677. HelpMenu*helpMenu= new HelpMenu();
  18678. window->menuBar()->addMenu(helpMenu);
  18679. /*:212*/
  18680. #line 4827 "./typica.w"
  18681. window->show();
  18682. window->setupFinished();
  18683. /*:208*/
  18684. #line 4768 "./typica.w"
  18685. }
  18686. file.close();
  18687. }
  18688. return object;
  18689. }
  18690. /*:206*//*224:*/
  18691. #line 4975 "./typica.w"
  18692. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  18693. QStack<QLayout*> *layoutStack)
  18694. {
  18695. if(element.hasAttribute("type"))
  18696. {
  18697. /*225:*/
  18698. #line 4996 "./typica.w"
  18699. QLayout*layout;
  18700. QString layoutType= element.attribute("type");
  18701. if(layoutType=="horizontal")
  18702. {
  18703. layout= new QHBoxLayout;
  18704. layoutStack->push(layout);
  18705. populateBoxLayout(element,widgetStack,layoutStack);
  18706. }
  18707. else if(layoutType=="vertical")
  18708. {
  18709. layout= new QVBoxLayout;
  18710. layoutStack->push(layout);
  18711. populateBoxLayout(element,widgetStack,layoutStack);
  18712. }
  18713. else if(layoutType=="grid")
  18714. {
  18715. layout= new QGridLayout;
  18716. layoutStack->push(layout);
  18717. populateGridLayout(element,widgetStack,layoutStack);
  18718. }
  18719. else if(layoutType=="stack")
  18720. {
  18721. layout= new QStackedLayout;
  18722. layoutStack->push(layout);
  18723. populateStackedLayout(element,widgetStack,layoutStack);
  18724. }
  18725. if(element.hasAttribute("id"))
  18726. {
  18727. layout->setObjectName(element.attribute("id"));
  18728. }
  18729. if(element.hasAttribute("spacing"))
  18730. {
  18731. layout->setSpacing(element.attribute("spacing").toInt());
  18732. }
  18733. if(element.hasAttribute("margin"))
  18734. {
  18735. int m= element.attribute("margin").toInt();
  18736. layout->setContentsMargins(m,m,m,m);
  18737. }
  18738. /*:225*/
  18739. #line 4981 "./typica.w"
  18740. QWidget*widget= widgetStack->top();
  18741. if(layout)
  18742. {
  18743. widget->setLayout(layout);
  18744. }
  18745. layoutStack->pop();
  18746. }
  18747. }
  18748. /*:224*//*226:*/
  18749. #line 5043 "./typica.w"
  18750. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18751. QStack<QLayout*> *layoutStack)
  18752. {
  18753. QDomNodeList children= element.childNodes();
  18754. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  18755. for(int i= 0;i<children.count();i++)
  18756. {
  18757. QDomNode current;
  18758. QDomElement currentElement;
  18759. current= children.at(i);
  18760. if(current.isElement())
  18761. {
  18762. currentElement= current.toElement();
  18763. if(currentElement.tagName()=="page")
  18764. {
  18765. QWidget*widget= new QWidget;
  18766. layout->addWidget(widget);
  18767. widgetStack->push(widget);
  18768. currentElement.setAttribute("trcontext","configuration");
  18769. populateWidget(currentElement,widgetStack,layoutStack);
  18770. widgetStack->pop();
  18771. }
  18772. }
  18773. }
  18774. }
  18775. /*:226*//*228:*/
  18776. #line 5082 "./typica.w"
  18777. void addTabBarToLayout(QDomElement element,QStack<QWidget*> *,QStack<QLayout*> *layoutStack)
  18778. {
  18779. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18780. QTabBar*widget= new QTabBar;
  18781. layout->addWidget(widget);
  18782. if(!element.attribute("id").isEmpty())
  18783. {
  18784. widget->setObjectName(element.attribute("id"));
  18785. }
  18786. }
  18787. /*:228*//*230:*/
  18788. #line 5104 "./typica.w"
  18789. QScriptValue constructQTabBar(QScriptContext*,QScriptEngine*engine)
  18790. {
  18791. QScriptValue object= engine->newQObject(new QTabBar);
  18792. setQTabBarProperties(object,engine);
  18793. return object;
  18794. }
  18795. /*:230*//*231:*/
  18796. #line 5115 "./typica.w"
  18797. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine)
  18798. {
  18799. setQWidgetProperties(value,engine);
  18800. value.setProperty("addTab",engine->newFunction(QTabBar_addTab));
  18801. }
  18802. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*)
  18803. {
  18804. QTabBar*self= getself<QTabBar*> (context);
  18805. if(context->argumentCount()> 0)
  18806. {
  18807. self->addTab(argument<QString> (0,context));
  18808. }
  18809. else
  18810. {
  18811. context->throwError("Incorrect number of arguments passed to "
  18812. "QTabBar::addTab().");
  18813. }
  18814. return QScriptValue();
  18815. }
  18816. /*:231*//*233:*/
  18817. #line 5150 "./typica.w"
  18818. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18819. QStack<QLayout*> *layoutStack)
  18820. {
  18821. QDomNodeList children= element.childNodes();
  18822. int row= -1;
  18823. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  18824. for(int i= 0;i<children.count();i++)
  18825. {
  18826. QDomNode current;
  18827. QDomElement currentElement;
  18828. current= children.at(i);
  18829. if(current.isElement())
  18830. {
  18831. currentElement= current.toElement();
  18832. if(currentElement.tagName()=="row")
  18833. {
  18834. row++;
  18835. if(currentElement.hasAttribute("height"))
  18836. {
  18837. layout->setRowMinimumHeight(row,
  18838. currentElement.attribute("height").toInt());
  18839. }
  18840. if(currentElement.hasAttribute("stretch"))
  18841. {
  18842. layout->setRowStretch(row,
  18843. currentElement.attribute("stretch").toInt());
  18844. }
  18845. /*234:*/
  18846. #line 5206 "./typica.w"
  18847. int column= -1;
  18848. QDomNodeList rowChildren= currentElement.childNodes();
  18849. for(int j= 0;j<rowChildren.count();j++)
  18850. {
  18851. QDomNode columnNode;
  18852. QDomElement columnElement;
  18853. columnNode= rowChildren.at(j);
  18854. if(columnNode.isElement())
  18855. {
  18856. columnElement= columnNode.toElement();
  18857. if(columnElement.tagName()=="column")
  18858. {
  18859. column++;
  18860. if(columnElement.hasAttribute("column"))
  18861. {
  18862. column= columnElement.attribute("column").toInt();
  18863. }
  18864. if(columnElement.hasAttribute("width"))
  18865. {
  18866. layout->setColumnMinimumWidth(column,
  18867. columnElement.attribute("width").toInt());
  18868. }
  18869. if(columnElement.hasAttribute("stretch"))
  18870. {
  18871. layout->setColumnStretch(column,
  18872. columnElement.attribute("stretch").toInt());
  18873. }
  18874. int hspan= 1;
  18875. int vspan= 1;
  18876. if(columnElement.hasAttribute("rowspan"))
  18877. {
  18878. vspan= columnElement.attribute("rowspan").toInt();
  18879. }
  18880. if(columnElement.hasAttribute("colspan"))
  18881. {
  18882. hspan= columnElement.attribute("colspan").toInt();
  18883. }
  18884. QHBoxLayout*cell= new QHBoxLayout;
  18885. layout->addLayout(cell,row,column,vspan,hspan);
  18886. layoutStack->push(cell);
  18887. columnElement.setAttribute("trcontext","configuration");
  18888. populateBoxLayout(columnElement,widgetStack,layoutStack);
  18889. layoutStack->pop();
  18890. }
  18891. }
  18892. }
  18893. /*:234*/
  18894. #line 5178 "./typica.w"
  18895. }
  18896. }
  18897. }
  18898. }
  18899. /*:233*//*235:*/
  18900. #line 5257 "./typica.w"
  18901. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18902. QStack<QLayout*> *layoutStack)
  18903. {
  18904. QDomNodeList children= element.childNodes();
  18905. for(int i= 0;i<children.count();i++)
  18906. {
  18907. QDomNode current;
  18908. QDomElement currentElement;
  18909. current= children.at(i);
  18910. if(current.isElement())
  18911. {
  18912. currentElement= current.toElement();
  18913. currentElement.setAttribute("trcontext","configuration");
  18914. if(currentElement.tagName()=="button")
  18915. {
  18916. addButtonToLayout(currentElement,widgetStack,layoutStack);
  18917. }
  18918. else if(currentElement.tagName()=="calendar")
  18919. {
  18920. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  18921. }
  18922. else if(currentElement.tagName()=="timeedit")
  18923. {
  18924. addTimeEditToLayout(currentElement,widgetStack,layoutStack);
  18925. }
  18926. else if(currentElement.tagName()=="decoration")
  18927. {
  18928. addDecorationToLayout(currentElement,widgetStack,
  18929. layoutStack);
  18930. }
  18931. else if(currentElement.tagName()=="layout")
  18932. {
  18933. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  18934. }
  18935. else if(currentElement.tagName()=="splitter")
  18936. {
  18937. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  18938. }
  18939. else if(currentElement.tagName()=="label")
  18940. {
  18941. QBoxLayout*layout=
  18942. qobject_cast<QBoxLayout*> (layoutStack->top());
  18943. QLabel*label= new QLabel(QCoreApplication::translate(
  18944. "configuration",
  18945. currentElement.text().toUtf8().data()));
  18946. if(currentElement.hasAttribute("id"))
  18947. {
  18948. label->setObjectName(currentElement.attribute("id"));
  18949. }
  18950. layout->addWidget(label);
  18951. }
  18952. else if(currentElement.tagName()=="lcdtemperature")
  18953. {
  18954. addTemperatureDisplayToLayout(currentElement,widgetStack,
  18955. layoutStack);
  18956. }
  18957. else if(currentElement.tagName()=="lcdtimer")
  18958. {
  18959. addTimerDisplayToLayout(currentElement,widgetStack,
  18960. layoutStack);
  18961. }
  18962. else if(currentElement.tagName()=="line")
  18963. {
  18964. addLineToLayout(currentElement,widgetStack,layoutStack);
  18965. }
  18966. else if(currentElement.tagName()=="report")
  18967. {
  18968. addReportToLayout(currentElement,widgetStack,layoutStack);
  18969. }
  18970. else if(currentElement.tagName()=="sqldrop")
  18971. {
  18972. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  18973. }
  18974. else if(currentElement.tagName()=="sqltablearray")
  18975. {
  18976. addSaltToLayout(currentElement,widgetStack,layoutStack);
  18977. }
  18978. else if(currentElement.tagName()=="sqlview")
  18979. {
  18980. addSqlQueryViewToLayout(currentElement,widgetStack,
  18981. layoutStack);
  18982. }
  18983. else if(currentElement.tagName()=="textarea")
  18984. {
  18985. addTextToLayout(currentElement,widgetStack,layoutStack);
  18986. }
  18987. else if(currentElement.tagName()=="spinbox")
  18988. {
  18989. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  18990. }
  18991. else if(currentElement.tagName()=="formarray")
  18992. {
  18993. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  18994. }
  18995. else if(currentElement.tagName()=="hscale")
  18996. {
  18997. addScaleControlToLayout(currentElement,widgetStack,
  18998. layoutStack);
  18999. }
  19000. else if(currentElement.tagName()=="vscale")
  19001. {
  19002. addIntensityControlToLayout(currentElement,widgetStack,
  19003. layoutStack);
  19004. }
  19005. else if(currentElement.tagName()=="webview")
  19006. {
  19007. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  19008. }
  19009. else if(currentElement.tagName()=="stretch")
  19010. {
  19011. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19012. layout->addStretch();
  19013. }
  19014. /*54:*/
  19015. #line 1569 "./typica.w"
  19016. else if(currentElement.tagName()=="svgwidget")
  19017. {
  19018. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  19019. }
  19020. /*:54*//*227:*/
  19021. #line 5074 "./typica.w"
  19022. else if(currentElement.tagName()=="tabbar")
  19023. {
  19024. addTabBarToLayout(currentElement,widgetStack,layoutStack);
  19025. }
  19026. /*:227*//*606:*/
  19027. #line 111 "./printerselector.w"
  19028. else if(currentElement.tagName()=="printerselector")
  19029. {
  19030. addPrinterSelectorToLayout(currentElement,widgetStack,layoutStack);
  19031. }
  19032. #line 13005 "./typica.w"
  19033. /*:606*//*727:*/
  19034. #line 451 "./daterangeselector.w"
  19035. else if(currentElement.tagName()=="daterange")
  19036. {
  19037. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  19038. }
  19039. /*:727*//*1186:*/
  19040. #line 135 "./roastcoloredit.w"
  19041. else if(currentElement.tagName()=="roastcoloredit")
  19042. {
  19043. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19044. RoastColorEdit*edit= new RoastColorEdit;
  19045. if(currentElement.hasAttribute("id"))
  19046. {
  19047. edit->setObjectName(currentElement.attribute("id"));
  19048. }
  19049. layout->addWidget(edit);
  19050. }
  19051. /*:1186*/
  19052. #line 5371 "./typica.w"
  19053. }
  19054. }
  19055. }
  19056. /*:235*//*236:*/
  19057. #line 5379 "./typica.w"
  19058. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  19059. QStack<QLayout*> *layoutStack)
  19060. {
  19061. QLayout*targetLayout= layoutStack->pop();
  19062. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  19063. if(element.hasAttribute("type"))
  19064. {
  19065. /*225:*/
  19066. #line 4996 "./typica.w"
  19067. QLayout*layout;
  19068. QString layoutType= element.attribute("type");
  19069. if(layoutType=="horizontal")
  19070. {
  19071. layout= new QHBoxLayout;
  19072. layoutStack->push(layout);
  19073. populateBoxLayout(element,widgetStack,layoutStack);
  19074. }
  19075. else if(layoutType=="vertical")
  19076. {
  19077. layout= new QVBoxLayout;
  19078. layoutStack->push(layout);
  19079. populateBoxLayout(element,widgetStack,layoutStack);
  19080. }
  19081. else if(layoutType=="grid")
  19082. {
  19083. layout= new QGridLayout;
  19084. layoutStack->push(layout);
  19085. populateGridLayout(element,widgetStack,layoutStack);
  19086. }
  19087. else if(layoutType=="stack")
  19088. {
  19089. layout= new QStackedLayout;
  19090. layoutStack->push(layout);
  19091. populateStackedLayout(element,widgetStack,layoutStack);
  19092. }
  19093. if(element.hasAttribute("id"))
  19094. {
  19095. layout->setObjectName(element.attribute("id"));
  19096. }
  19097. if(element.hasAttribute("spacing"))
  19098. {
  19099. layout->setSpacing(element.attribute("spacing").toInt());
  19100. }
  19101. if(element.hasAttribute("margin"))
  19102. {
  19103. int m= element.attribute("margin").toInt();
  19104. layout->setContentsMargins(m,m,m,m);
  19105. }
  19106. /*:225*/
  19107. #line 5387 "./typica.w"
  19108. boxLayout->addLayout(layout);
  19109. layoutStack->pop();
  19110. }
  19111. layoutStack->push(targetLayout);
  19112. }
  19113. /*:236*//*237:*/
  19114. #line 5398 "./typica.w"
  19115. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  19116. QStack<QLayout*> *layoutStack)
  19117. {
  19118. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19119. QSplitter*splitter= new(QSplitter);
  19120. layout->addWidget(splitter);
  19121. /*238:*/
  19122. #line 5411 "./typica.w"
  19123. QString orientation= element.attribute("type");
  19124. if(orientation=="horizontal")
  19125. {
  19126. splitter->setOrientation(Qt::Horizontal);
  19127. }
  19128. else if(orientation=="vertical")
  19129. {
  19130. splitter->setOrientation(Qt::Vertical);
  19131. }
  19132. QString id= element.attribute("id");
  19133. if(!id.isEmpty())
  19134. {
  19135. splitter->setObjectName(id);
  19136. }
  19137. if(element.hasChildNodes())
  19138. {
  19139. widgetStack->push(splitter);
  19140. populateSplitter(element,widgetStack,layoutStack);
  19141. widgetStack->pop();
  19142. }
  19143. /*:238*/
  19144. #line 5405 "./typica.w"
  19145. }
  19146. /*:237*//*239:*/
  19147. #line 5437 "./typica.w"
  19148. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19149. QStack<QLayout*> *layoutStack)
  19150. {
  19151. QDomNodeList children= element.childNodes();
  19152. for(int i= 0;i<children.count();i++)
  19153. {
  19154. QDomNode current;
  19155. QDomElement currentElement;
  19156. current= children.at(i);
  19157. if(current.isElement())
  19158. {
  19159. currentElement= current.toElement();
  19160. currentElement.setAttribute("trcontext","configuration");
  19161. if(currentElement.tagName()=="decoration")
  19162. {
  19163. addDecorationToSplitter(currentElement,widgetStack,
  19164. layoutStack);
  19165. }
  19166. else if(currentElement.tagName()=="graph")
  19167. {
  19168. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  19169. }
  19170. else if(currentElement.tagName()=="splitter")
  19171. {
  19172. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  19173. }
  19174. else if(currentElement.tagName()=="lcdtemperature")
  19175. {
  19176. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  19177. layoutStack);
  19178. }
  19179. else if(currentElement.tagName()=="lcdtimer")
  19180. {
  19181. addTimerDisplayToSplitter(currentElement,widgetStack,
  19182. layoutStack);
  19183. }
  19184. else if(currentElement.tagName()=="measurementtable")
  19185. {
  19186. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  19187. }
  19188. else if(currentElement.tagName()=="widget")
  19189. {
  19190. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  19191. }
  19192. }
  19193. }
  19194. }
  19195. /*:239*//*240:*/
  19196. #line 5488 "./typica.w"
  19197. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19198. QStack<QLayout*> *layoutStack)
  19199. {
  19200. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  19201. QSplitter*splitter= new(QSplitter);
  19202. splitter->setParent(parent);
  19203. parent->addWidget(splitter);
  19204. /*238:*/
  19205. #line 5411 "./typica.w"
  19206. QString orientation= element.attribute("type");
  19207. if(orientation=="horizontal")
  19208. {
  19209. splitter->setOrientation(Qt::Horizontal);
  19210. }
  19211. else if(orientation=="vertical")
  19212. {
  19213. splitter->setOrientation(Qt::Vertical);
  19214. }
  19215. QString id= element.attribute("id");
  19216. if(!id.isEmpty())
  19217. {
  19218. splitter->setObjectName(id);
  19219. }
  19220. if(element.hasChildNodes())
  19221. {
  19222. widgetStack->push(splitter);
  19223. populateSplitter(element,widgetStack,layoutStack);
  19224. widgetStack->pop();
  19225. }
  19226. /*:238*/
  19227. #line 5496 "./typica.w"
  19228. }
  19229. /*:240*//*241:*/
  19230. #line 5505 "./typica.w"
  19231. void addTemperatureDisplayToSplitter(QDomElement element,
  19232. QStack<QWidget*> *widgetStack,
  19233. QStack<QLayout*> *)
  19234. {
  19235. TemperatureDisplay*display= new(TemperatureDisplay);
  19236. if(element.hasAttribute("id"))
  19237. {
  19238. display->setObjectName(element.attribute("id"));
  19239. }
  19240. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19241. splitter->addWidget(display);
  19242. }
  19243. void addTemperatureDisplayToLayout(QDomElement element,
  19244. QStack<QWidget*> *,
  19245. QStack<QLayout*> *layoutStack)
  19246. {
  19247. TemperatureDisplay*display= new(TemperatureDisplay);
  19248. if(element.hasAttribute("id"))
  19249. {
  19250. display->setObjectName(element.attribute("id"));
  19251. }
  19252. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19253. layout->addWidget(display);
  19254. }
  19255. /*:241*//*242:*/
  19256. #line 5536 "./typica.w"
  19257. void addTimerDisplayToSplitter(QDomElement element,
  19258. QStack<QWidget*> *widgetStack,
  19259. QStack<QLayout*> *)
  19260. {
  19261. TimerDisplay*display= new(TimerDisplay);
  19262. if(element.hasAttribute("id"))
  19263. {
  19264. display->setObjectName(element.attribute("id"));
  19265. }
  19266. if(element.hasAttribute("format"))
  19267. {
  19268. display->setDisplayFormat(element.attribute("format"));
  19269. }
  19270. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19271. splitter->addWidget(display);
  19272. }
  19273. void addTimerDisplayToLayout(QDomElement element,
  19274. QStack<QWidget*> *,
  19275. QStack<QLayout*> *layoutStack)
  19276. {
  19277. TimerDisplay*display= new(TimerDisplay);
  19278. if(element.hasAttribute("id"))
  19279. {
  19280. display->setObjectName(element.attribute("id"));
  19281. }
  19282. if(element.hasAttribute("format"))
  19283. {
  19284. display->setDisplayFormat(element.attribute("format"));
  19285. }
  19286. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19287. layout->addWidget(display);
  19288. }
  19289. /*:242*//*243:*/
  19290. #line 5574 "./typica.w"
  19291. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  19292. QStack<QLayout*> *layoutStack)
  19293. {
  19294. /*244:*/
  19295. #line 5595 "./typica.w"
  19296. QString labelText=
  19297. QCoreApplication::translate("configuration",
  19298. element.attribute("name").toUtf8().data());
  19299. Qt::Orientations orientation= Qt::Horizontal;
  19300. if(element.hasAttribute("type"))
  19301. {
  19302. if(element.attribute("type")=="horizontal")
  19303. {
  19304. orientation= Qt::Horizontal;
  19305. }
  19306. else if(element.attribute("type")=="vertical")
  19307. {
  19308. orientation= Qt::Vertical;
  19309. }
  19310. }
  19311. /*245:*/
  19312. #line 5622 "./typica.w"
  19313. QWidget*theWidget= NULL;
  19314. QDomNodeList children= element.childNodes();
  19315. for(int i= 0;i<children.count();i++)
  19316. {
  19317. QDomNode item= children.at(i);
  19318. if(item.isElement())
  19319. {
  19320. QDomElement itemElement= item.toElement();
  19321. if(itemElement.tagName()=="lcdtemperature")
  19322. {
  19323. TemperatureDisplay*display= new TemperatureDisplay;
  19324. if(itemElement.hasAttribute("id"))
  19325. {
  19326. display->setObjectName(itemElement.attribute("id"));
  19327. }
  19328. theWidget= display;
  19329. }
  19330. else if(itemElement.tagName()=="lcdtimer")
  19331. {
  19332. TimerDisplay*display= new TimerDisplay;
  19333. if(itemElement.hasAttribute("id"))
  19334. {
  19335. display->setObjectName(itemElement.attribute("id"));
  19336. }
  19337. if(itemElement.hasAttribute("format"))
  19338. {
  19339. display->setDisplayFormat(itemElement.attribute("format"));
  19340. }
  19341. theWidget= display;
  19342. }
  19343. }
  19344. }
  19345. /*:245*/
  19346. #line 5611 "./typica.w"
  19347. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  19348. orientation);
  19349. if(element.hasAttribute("id"))
  19350. {
  19351. decoration->setObjectName(element.attribute("id"));
  19352. }
  19353. /*:244*/
  19354. #line 5578 "./typica.w"
  19355. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19356. layout->addWidget(decoration);
  19357. }
  19358. void addDecorationToSplitter(QDomElement element,
  19359. QStack<QWidget*> *widgetStack,
  19360. QStack<QLayout*> *)
  19361. {
  19362. /*244:*/
  19363. #line 5595 "./typica.w"
  19364. QString labelText=
  19365. QCoreApplication::translate("configuration",
  19366. element.attribute("name").toUtf8().data());
  19367. Qt::Orientations orientation= Qt::Horizontal;
  19368. if(element.hasAttribute("type"))
  19369. {
  19370. if(element.attribute("type")=="horizontal")
  19371. {
  19372. orientation= Qt::Horizontal;
  19373. }
  19374. else if(element.attribute("type")=="vertical")
  19375. {
  19376. orientation= Qt::Vertical;
  19377. }
  19378. }
  19379. /*245:*/
  19380. #line 5622 "./typica.w"
  19381. QWidget*theWidget= NULL;
  19382. QDomNodeList children= element.childNodes();
  19383. for(int i= 0;i<children.count();i++)
  19384. {
  19385. QDomNode item= children.at(i);
  19386. if(item.isElement())
  19387. {
  19388. QDomElement itemElement= item.toElement();
  19389. if(itemElement.tagName()=="lcdtemperature")
  19390. {
  19391. TemperatureDisplay*display= new TemperatureDisplay;
  19392. if(itemElement.hasAttribute("id"))
  19393. {
  19394. display->setObjectName(itemElement.attribute("id"));
  19395. }
  19396. theWidget= display;
  19397. }
  19398. else if(itemElement.tagName()=="lcdtimer")
  19399. {
  19400. TimerDisplay*display= new TimerDisplay;
  19401. if(itemElement.hasAttribute("id"))
  19402. {
  19403. display->setObjectName(itemElement.attribute("id"));
  19404. }
  19405. if(itemElement.hasAttribute("format"))
  19406. {
  19407. display->setDisplayFormat(itemElement.attribute("format"));
  19408. }
  19409. theWidget= display;
  19410. }
  19411. }
  19412. }
  19413. /*:245*/
  19414. #line 5611 "./typica.w"
  19415. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  19416. orientation);
  19417. if(element.hasAttribute("id"))
  19418. {
  19419. decoration->setObjectName(element.attribute("id"));
  19420. }
  19421. /*:244*/
  19422. #line 5587 "./typica.w"
  19423. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19424. splitter->addWidget(decoration);
  19425. }
  19426. /*:243*//*246:*/
  19427. #line 5667 "./typica.w"
  19428. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19429. QStack<QLayout*> *layoutStack)
  19430. {
  19431. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19432. QWidget*widget= new QWidget;
  19433. if(element.hasAttribute("id"))
  19434. {
  19435. widget->setObjectName(element.attribute("id"));
  19436. }
  19437. if(element.hasAttribute("ignoreSizePolicy"))
  19438. {
  19439. if(element.attribute("ignoreSizePolicy")=="true")
  19440. {
  19441. widget->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
  19442. }
  19443. }
  19444. splitter->addWidget(widget);
  19445. if(element.hasChildNodes())
  19446. {
  19447. widgetStack->push(widget);
  19448. populateWidget(element,widgetStack,layoutStack);
  19449. widgetStack->pop();
  19450. }
  19451. }
  19452. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  19453. QStack<QLayout*> *layoutStack)
  19454. {
  19455. QDomNodeList children= element.childNodes();
  19456. for(int i= 0;i<children.count();i++)
  19457. {
  19458. QDomNode current;
  19459. QDomElement currentElement;
  19460. current= children.at(i);
  19461. if(current.isElement())
  19462. {
  19463. currentElement= current.toElement();
  19464. if(currentElement.tagName()=="layout")
  19465. {
  19466. currentElement.setAttribute("trcontext","configuration");
  19467. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  19468. }
  19469. }
  19470. }
  19471. }
  19472. /*:246*//*247:*/
  19473. #line 5718 "./typica.w"
  19474. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  19475. QStack<QLayout*> *layoutStack)
  19476. {
  19477. QAbstractButton*button= NULL;
  19478. QString text=
  19479. QCoreApplication::translate("configuration",
  19480. element.attribute("name").toUtf8().data());
  19481. if(element.hasAttribute("type"))
  19482. {
  19483. QString type= element.attribute("type");
  19484. if(type=="annotation")
  19485. {
  19486. AnnotationButton*abutton= new AnnotationButton(text);
  19487. if(element.hasAttribute("annotation"))
  19488. {
  19489. abutton->setAnnotation(element.attribute("annotation"));
  19490. }
  19491. if(element.hasAttribute("series"))
  19492. {
  19493. abutton->setTemperatureColumn(element.attribute("series").
  19494. toInt());
  19495. }
  19496. if(element.hasAttribute("column"))
  19497. {
  19498. abutton->setAnnotationColumn(element.attribute("column").
  19499. toInt());
  19500. }
  19501. button= abutton;
  19502. }
  19503. else if(type=="check")
  19504. {
  19505. button= new QCheckBox(text);
  19506. }
  19507. else if(type=="push")
  19508. {
  19509. button= new QPushButton(text);
  19510. }
  19511. }
  19512. if(element.hasAttribute("id"))
  19513. {
  19514. button->setObjectName(element.attribute("id"));
  19515. }
  19516. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19517. layout->addWidget(button);
  19518. }
  19519. /*:247*//*248:*/
  19520. #line 5772 "./typica.w"
  19521. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  19522. QStack<QLayout*> *layoutStack)
  19523. {
  19524. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  19525. if(element.hasAttribute("pretext"))
  19526. {
  19527. box->setPretext(QCoreApplication::translate(
  19528. "configuration",
  19529. element.attribute("pretext").toUtf8().data()));
  19530. }
  19531. if(element.hasAttribute("posttext"))
  19532. {
  19533. box->setPosttext(QCoreApplication::translate(
  19534. "configuration",
  19535. element.attribute("posttext").toUtf8().data()));
  19536. }
  19537. if(element.hasAttribute("series"))
  19538. {
  19539. box->setTemperatureColumn(element.attribute("series").toInt());
  19540. }
  19541. if(element.hasAttribute("column"))
  19542. {
  19543. box->setAnnotationColumn(element.attribute("column").toInt());
  19544. }
  19545. if(element.hasAttribute("min"))
  19546. {
  19547. box->setMinimum(element.attribute("min").toDouble());
  19548. }
  19549. if(element.hasAttribute("max"))
  19550. {
  19551. box->setMaximum(element.attribute("max").toDouble());
  19552. }
  19553. if(element.hasAttribute("decimals"))
  19554. {
  19555. box->setDecimals(element.attribute("decimals").toInt());
  19556. }
  19557. if(element.hasAttribute("step"))
  19558. {
  19559. box->setSingleStep(element.attribute("step").toDouble());
  19560. }
  19561. if(element.hasAttribute("id"))
  19562. {
  19563. box->setObjectName(element.attribute("id"));
  19564. }
  19565. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19566. layout->addWidget(box);
  19567. }
  19568. /*:248*//*249:*/
  19569. #line 5832 "./typica.w"
  19570. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19571. QStack<QLayout*> *)
  19572. {
  19573. ZoomLog*widget= new ZoomLog;
  19574. if(element.hasAttribute("id"))
  19575. {
  19576. widget->setObjectName(element.attribute("id"));
  19577. }
  19578. if(element.hasChildNodes())
  19579. {
  19580. QDomNodeList children= element.childNodes();
  19581. int column= 0;
  19582. for(int i= 0;i<children.count();i++)
  19583. {
  19584. QDomNode current;
  19585. QDomElement currentElement;
  19586. current= children.at(i);
  19587. if(current.isElement())
  19588. {
  19589. currentElement= current.toElement();
  19590. if(currentElement.tagName()=="column")
  19591. {
  19592. QString text=
  19593. QCoreApplication::translate(
  19594. "configuration",
  19595. currentElement.text().toUtf8().data());
  19596. widget->setHeaderData(column,text);
  19597. column++;
  19598. }
  19599. }
  19600. }
  19601. }
  19602. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19603. if(splitter)
  19604. {
  19605. splitter->addWidget(widget);
  19606. }
  19607. else
  19608. {
  19609. qDebug()<<"Splitter not found at top of widget stack!";
  19610. }
  19611. }
  19612. /*:249*//*250:*/
  19613. #line 5879 "./typica.w"
  19614. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19615. QStack<QLayout*> *)
  19616. {
  19617. GraphView*view= new GraphView;
  19618. if(element.hasAttribute("id"))
  19619. {
  19620. view->setObjectName(element.attribute("id"));
  19621. }
  19622. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19623. splitter->addWidget(view);
  19624. }
  19625. /*:250*//*251:*/
  19626. #line 5896 "./typica.w"
  19627. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  19628. QStack<QLayout*> *layoutStack)
  19629. {
  19630. SqlComboBox*box= new SqlComboBox();
  19631. if(element.hasAttribute("data"))
  19632. {
  19633. box->setDataColumn(element.attribute("data").toInt());
  19634. }
  19635. if(element.hasAttribute("display"))
  19636. {
  19637. box->setDisplayColumn(element.attribute("display").toInt());
  19638. }
  19639. if(element.hasAttribute("showdata"))
  19640. {
  19641. if(element.attribute("showdata")=="true")
  19642. {
  19643. box->showData(true);
  19644. }
  19645. }
  19646. if(element.hasAttribute("editable"))
  19647. {
  19648. if(element.attribute("editable")=="true")
  19649. {
  19650. box->setEditable(true);
  19651. }
  19652. }
  19653. if(element.hasChildNodes())
  19654. {
  19655. QDomNodeList children= element.childNodes();
  19656. for(int i= 0;i<children.count();i++)
  19657. {
  19658. QDomNode current;
  19659. QDomElement currentElement;
  19660. current= children.at(i);
  19661. if(current.isElement())
  19662. {
  19663. currentElement= current.toElement();
  19664. if(currentElement.tagName()=="null")
  19665. {
  19666. box->addNullOption();
  19667. }
  19668. else if(currentElement.tagName()=="query")
  19669. {
  19670. box->addSqlOptions(currentElement.text());
  19671. }
  19672. }
  19673. }
  19674. }
  19675. if(element.hasAttribute("id"))
  19676. {
  19677. box->setObjectName(element.attribute("id"));
  19678. }
  19679. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19680. layout->addWidget(box);
  19681. }
  19682. /*:251*//*252:*/
  19683. #line 5975 "./typica.w"
  19684. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  19685. QStack<QLayout*> *layoutStack)
  19686. {
  19687. QTableView*view= new QTableView;
  19688. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  19689. SaltModel*model= new SaltModel(element.childNodes().count());
  19690. if(element.hasAttribute("id"))
  19691. {
  19692. view->setObjectName(element.attribute("id"));
  19693. }
  19694. if(element.hasChildNodes())
  19695. {
  19696. QDomNodeList children= element.childNodes();
  19697. int currentColumn= 0;
  19698. for(int i= 0;i<children.count();i++)
  19699. {
  19700. QDomNode current;
  19701. QDomElement currentElement;
  19702. current= children.at(i);
  19703. if(current.isElement())
  19704. {
  19705. currentElement= current.toElement();
  19706. if(currentElement.tagName()=="column")
  19707. {
  19708. if(currentElement.hasAttribute("name"))
  19709. {
  19710. model->setHeaderData(currentColumn,
  19711. Qt::Horizontal,
  19712. QCoreApplication::translate(
  19713. "configuration",
  19714. currentElement.attribute("name").toUtf8().data()));
  19715. }
  19716. if(currentElement.hasAttribute("delegate"))
  19717. {
  19718. /*253:*/
  19719. #line 6026 "./typica.w"
  19720. if(currentElement.attribute("delegate")=="sql")
  19721. {
  19722. /*254:*/
  19723. #line 6046 "./typica.w"
  19724. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  19725. SqlComboBox*widget= new SqlComboBox();
  19726. if(currentElement.hasAttribute("nulltext"))
  19727. {
  19728. widget->setNullText(currentElement.attribute("nulltext"));
  19729. }
  19730. if(currentElement.hasAttribute("nulldata"))
  19731. {
  19732. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  19733. }
  19734. if(currentElement.hasAttribute("null"))
  19735. {
  19736. if(currentElement.attribute("null")=="true")
  19737. {
  19738. widget->addNullOption();
  19739. }
  19740. }
  19741. if(currentElement.hasAttribute("showdata"))
  19742. {
  19743. if(currentElement.attribute("showdata")=="true")
  19744. {
  19745. widget->showData(true);
  19746. }
  19747. }
  19748. if(currentElement.hasAttribute("data"))
  19749. {
  19750. widget->setDataColumn(currentElement.attribute("data").toInt());
  19751. }
  19752. if(currentElement.hasAttribute("display"))
  19753. {
  19754. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  19755. }
  19756. widget->addSqlOptions(currentElement.text());
  19757. delegate->setWidget(widget);
  19758. view->setItemDelegateForColumn(currentColumn,delegate);
  19759. /*:254*/
  19760. #line 6029 "./typica.w"
  19761. }
  19762. else if(currentElement.attribute("delegate")=="numeric")
  19763. {
  19764. /*255:*/
  19765. #line 6085 "./typica.w"
  19766. NumericDelegate*delegate= new NumericDelegate;
  19767. view->setItemDelegateForColumn(currentColumn,delegate);
  19768. /*:255*/
  19769. #line 6033 "./typica.w"
  19770. }
  19771. else if(currentElement.attribute("delegate")=="positivenumeric")
  19772. {
  19773. /*256:*/
  19774. #line 6092 "./typica.w"
  19775. NumericDelegate*delegate= new NumericDelegate(true);
  19776. view->setItemDelegateForColumn(currentColumn,delegate);
  19777. /*:256*/
  19778. #line 6037 "./typica.w"
  19779. }
  19780. /*:253*/
  19781. #line 6010 "./typica.w"
  19782. }
  19783. currentColumn++;
  19784. }
  19785. }
  19786. }
  19787. }
  19788. view->setModel(model);
  19789. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19790. layout->addWidget(view);
  19791. }
  19792. /*:252*//*268:*/
  19793. #line 6281 "./typica.w"
  19794. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  19795. QStack<QLayout*> *layoutStack)
  19796. {
  19797. QLineEdit*widget= new QLineEdit(element.text());
  19798. if(element.hasAttribute("id"))
  19799. {
  19800. widget->setObjectName(element.attribute("id"));
  19801. }
  19802. if(element.hasAttribute("writable"))
  19803. {
  19804. if(element.attribute("writable")=="false")
  19805. {
  19806. widget->setReadOnly(true);
  19807. }
  19808. }
  19809. if(element.hasAttribute("validator"))
  19810. {
  19811. if(element.attribute("validator")=="numeric")
  19812. {
  19813. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  19814. }
  19815. else if(element.attribute("validator")=="integer")
  19816. {
  19817. widget->setValidator(new ScriptValidator(new QIntValidator));
  19818. }
  19819. else if(element.attribute("validator")=="expression"&&
  19820. element.hasAttribute("expression"))
  19821. {
  19822. widget->setValidator(new QRegExpValidator(
  19823. QRegExp(element.attribute("expression")),
  19824. NULL));
  19825. }
  19826. }
  19827. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19828. layout->addWidget(widget);
  19829. }
  19830. /*:268*//*269:*/
  19831. #line 6322 "./typica.w"
  19832. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  19833. QStack<QLayout*> *layoutStack)
  19834. {
  19835. QTextEdit*widget= new QTextEdit;
  19836. if(element.hasAttribute("id"))
  19837. {
  19838. widget->setObjectName(element.attribute("id"));
  19839. }
  19840. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19841. layout->addWidget(widget);
  19842. }
  19843. /*:269*//*270:*/
  19844. #line 6339 "./typica.w"
  19845. void addSqlQueryViewToLayout(QDomElement element,
  19846. QStack<QWidget*> *,
  19847. QStack<QLayout*> *layoutStack)
  19848. {
  19849. SqlQueryView*view= new SqlQueryView;
  19850. if(element.hasAttribute("id"))
  19851. {
  19852. view->setObjectName(element.attribute("id"));
  19853. }
  19854. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19855. layout->addWidget(view);
  19856. }
  19857. /*:270*//*271:*/
  19858. #line 6356 "./typica.w"
  19859. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  19860. QStack<QLayout*> *layoutStack)
  19861. {
  19862. QWidget*widget;
  19863. if(element.hasAttribute("time"))
  19864. {
  19865. if(element.attribute("time")=="true")
  19866. {
  19867. QDateTimeEdit*edit= new QDateTimeEdit;
  19868. edit->setDateTime(QDateTime::currentDateTime());
  19869. edit->setCalendarPopup(true);
  19870. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  19871. widget= qobject_cast<QWidget*> (edit);
  19872. }
  19873. else
  19874. {
  19875. QDateEdit*edit= new QDateEdit;
  19876. edit->setDate(QDate::currentDate());
  19877. edit->setCalendarPopup(true);
  19878. edit->setDisplayFormat("yyyy-MM-dd");
  19879. widget= qobject_cast<QWidget*> (edit);
  19880. }
  19881. }
  19882. else
  19883. {
  19884. QDateEdit*edit= new QDateEdit;
  19885. edit->setDate(QDate::currentDate());
  19886. edit->setCalendarPopup(true);
  19887. edit->setDisplayFormat("yyyy-MM-dd");
  19888. widget= qobject_cast<QWidget*> (edit);
  19889. }
  19890. if(element.hasAttribute("id"))
  19891. {
  19892. widget->setObjectName(element.attribute("id"));
  19893. }
  19894. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19895. layout->addWidget(widget);
  19896. }
  19897. /*:271*//*272:*/
  19898. #line 6399 "./typica.w"
  19899. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  19900. {
  19901. setQDateTimeEditProperties(value,engine);
  19902. }
  19903. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19904. {
  19905. setQAbstractSpinBoxProperties(value,engine);
  19906. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  19907. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  19908. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  19909. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  19910. value.setProperty("setToCurrentTime",
  19911. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  19912. }
  19913. /*:272*//*273:*/
  19914. #line 6421 "./typica.w"
  19915. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  19916. {
  19917. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19918. if(context->argumentCount()==3)
  19919. {
  19920. self->setDate(QDate(argument<int> (0,context),
  19921. argument<int> (1,context),
  19922. argument<int> (2,context)));
  19923. }
  19924. else
  19925. {
  19926. context->throwError("Incorrect number of arguments passed to "
  19927. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  19928. "specifying the year, month, and day.");
  19929. }
  19930. return QScriptValue();
  19931. }
  19932. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  19933. {
  19934. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19935. return QScriptValue(self->date().day());
  19936. }
  19937. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  19938. {
  19939. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19940. return QScriptValue(self->date().month());
  19941. }
  19942. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  19943. {
  19944. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19945. return QScriptValue(self->date().year());
  19946. }
  19947. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  19948. {
  19949. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19950. self->setDateTime(QDateTime::currentDateTime());
  19951. return QScriptValue();
  19952. }
  19953. /*:273*//*275:*/
  19954. #line 6481 "./typica.w"
  19955. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *,
  19956. QStack<QLayout*> *layoutStack)
  19957. {
  19958. QTimeEdit*edit= new QTimeEdit;
  19959. if(element.hasAttribute("displayFormat"))
  19960. {
  19961. edit->setDisplayFormat(element.attribute("displayFormat"));
  19962. }
  19963. else
  19964. {
  19965. edit->setDisplayFormat("mm:ss.zzz");
  19966. }
  19967. if(element.hasAttribute("id"))
  19968. {
  19969. edit->setObjectName(element.attribute("id"));
  19970. }
  19971. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19972. layout->addWidget(edit);
  19973. }
  19974. /*:275*//*276:*/
  19975. #line 6504 "./typica.w"
  19976. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19977. {
  19978. setQDateTimeEditProperties(value,engine);
  19979. }
  19980. /*:276*//*280:*/
  19981. #line 6533 "./typica.w"
  19982. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  19983. {
  19984. QObject*parent= argument<QObject*> (0,context);
  19985. QString name= argument<QString> (1,context);
  19986. QObject*object= parent->findChild<QObject*> (name);
  19987. QScriptValue value;
  19988. if(object)
  19989. {
  19990. value= engine->newQObject(object);
  19991. QString className= object->metaObject()->className();
  19992. /*281:*/
  19993. #line 6551 "./typica.w"
  19994. if(className=="TemperatureDisplay")
  19995. {
  19996. setTemperatureDisplayProperties(value,engine);
  19997. }
  19998. else if(className=="TimerDisplay")
  19999. {
  20000. setTimerDisplayProperties(value,engine);
  20001. }
  20002. else if(className=="QAction")
  20003. {
  20004. setQActionProperties(value,engine);
  20005. }
  20006. else if(className=="QBoxLayout")
  20007. {
  20008. setQBoxLayoutProperties(value,engine);
  20009. }
  20010. else if(className=="QDateEdit")
  20011. {
  20012. setQDateEditProperties(value,engine);
  20013. }
  20014. else if(className=="QDateTimeEdit")
  20015. {
  20016. setQDateTimeEditProperties(value,engine);
  20017. }
  20018. else if(className=="QFrame")
  20019. {
  20020. setQFrameProperties(value,engine);
  20021. }
  20022. else if(className=="QHBoxLayout")
  20023. {
  20024. setQBoxLayoutProperties(value,engine);
  20025. }
  20026. else if(className=="QLCDNumber")
  20027. {
  20028. setQLCDNumberProperties(value,engine);
  20029. }
  20030. else if(className=="QMenu")
  20031. {
  20032. setQMenuProperties(value,engine);
  20033. }
  20034. else if(className=="QMenuBar")
  20035. {
  20036. setQMenuBarProperties(value,engine);
  20037. }
  20038. else if(className=="QPushButton")
  20039. {
  20040. setQPushButtonProperties(value,engine);
  20041. }
  20042. else if(className=="QSplitter")
  20043. {
  20044. setQSplitterProperties(value,engine);
  20045. }
  20046. else if(className=="QTableView")
  20047. {
  20048. if(object->property("tabletype").isValid())
  20049. {
  20050. if(object->property("tabletype").toString()=="SaltTable")
  20051. {
  20052. setSaltTableProperties(value,engine);
  20053. }
  20054. }
  20055. }
  20056. else if(className=="QVBoxLayout")
  20057. {
  20058. setQBoxLayoutProperties(value,engine);
  20059. }
  20060. else if(className=="QWidget")
  20061. {
  20062. setQWidgetProperties(value,engine);
  20063. }
  20064. else if(className=="ScriptQMainWindow")
  20065. {
  20066. setQMainWindowProperties(value,engine);
  20067. }
  20068. else if(className=="SqlComboBox")
  20069. {
  20070. setSqlComboBoxProperties(value,engine);
  20071. }
  20072. else if(className=="SqlQueryView")
  20073. {
  20074. setSqlQueryViewProperties(value,engine);
  20075. }
  20076. else if(className=="ZoomLog")
  20077. {
  20078. setZoomLogProperties(value,engine);
  20079. }
  20080. else if(className=="QTextEdit")
  20081. {
  20082. setQTextEditProperties(value,engine);
  20083. }
  20084. else if(className=="QWebView")
  20085. {
  20086. setQWebViewProperties(value,engine);
  20087. }
  20088. else if(className=="QLineEdit")
  20089. {
  20090. setQLineEditProperties(value,engine);
  20091. }
  20092. else if(className=="QSvgWidget")
  20093. {
  20094. setQSvgWidgetProperties(value,engine);
  20095. }
  20096. else if(className=="QTabBar")
  20097. {
  20098. setQTabBarProperties(value,engine);
  20099. }
  20100. else if(className=="PrinterSelector")
  20101. {
  20102. setQComboBoxProperties(value,engine);
  20103. }
  20104. /*:281*/
  20105. #line 6544 "./typica.w"
  20106. }
  20107. return value;
  20108. }
  20109. /*:280*//*283:*/
  20110. #line 6692 "./typica.w"
  20111. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  20112. {
  20113. QTableView*self= getself<QTableView*> (context);
  20114. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20115. QString datum;
  20116. double total= 0.0;
  20117. int column= argument<int> (0,context);
  20118. int role= argument<int> (1,context);
  20119. for(int i= 0;i<model->rowCount();i++)
  20120. {
  20121. datum= model->data(model->index(i,column),role).toString();
  20122. if(!datum.isEmpty())
  20123. {
  20124. total+= datum.toDouble();
  20125. }
  20126. }
  20127. return QScriptValue(engine,total);
  20128. }
  20129. /*:283*//*284:*/
  20130. #line 6716 "./typica.w"
  20131. QScriptValue SaltTable_columnArray(QScriptContext*context,
  20132. QScriptEngine*engine)
  20133. {
  20134. QTableView*self= getself<QTableView*> (context);
  20135. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20136. int column= argument<int> (0,context);
  20137. int role= argument<int> (1,context);
  20138. QString literal= model->arrayLiteral(column,role);
  20139. return QScriptValue(engine,literal);
  20140. }
  20141. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  20142. QScriptEngine*engine)
  20143. {
  20144. QTableView*self= getself<QTableView*> (context);
  20145. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20146. int column= argument<int> (0,context);
  20147. int role= argument<int> (1,context);
  20148. QString literal= model->quotedArrayLiteral(column,role);
  20149. return QScriptValue(engine,literal);
  20150. }
  20151. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  20152. QScriptEngine*engine)
  20153. {
  20154. QTableView*self= getself<QTableView*> (context);
  20155. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20156. int column= argument<int> (0,context);
  20157. int role= argument<int> (1,context);
  20158. QString literal= model->arrayLiteral(column,role);
  20159. literal.chop(1);
  20160. literal= literal.remove(0,1);
  20161. return QScriptValue(engine,literal);
  20162. }
  20163. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  20164. QScriptEngine*engine)
  20165. {
  20166. QTableView*self= getself<QTableView*> (context);
  20167. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20168. int column= argument<int> (0,context);
  20169. int role= argument<int> (1,context);
  20170. QString literal= model->quotedArrayLiteral(column,role);
  20171. literal.chop(1);
  20172. literal= literal.remove(0,1);
  20173. return QScriptValue(engine,literal);
  20174. }
  20175. /*:284*//*285:*/
  20176. #line 6768 "./typica.w"
  20177. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  20178. {
  20179. QTableView*self= getself<QTableView*> (context);
  20180. QScriptValue value= engine->newQObject(self->model());
  20181. return value;
  20182. }
  20183. /*:285*//*286:*/
  20184. #line 6782 "./typica.w"
  20185. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  20186. {
  20187. QTableView*self= getself<QTableView*> (context);
  20188. int row= argument<int> (0,context);
  20189. int column= argument<int> (1,context);
  20190. QVariant value= argument<QVariant> (2,context);
  20191. int role= argument<int> (3,context);
  20192. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20193. QModelIndex cell= model->index(row,column);
  20194. model->setData(cell,value,role);
  20195. self->update(cell);
  20196. return QScriptValue();
  20197. }
  20198. /*:286*//*287:*/
  20199. #line 6800 "./typica.w"
  20200. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  20201. {
  20202. QTableView*self= getself<QTableView*> (context);
  20203. int row= argument<int> (0,context);
  20204. int column= argument<int> (1,context);
  20205. int role= argument<int> (2,context);
  20206. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20207. QModelIndex cell= model->index(row,column);
  20208. QVariant value= model->data(cell,role);
  20209. QScriptValue retval= engine->newVariant(value);
  20210. retval.setProperty("value",QScriptValue(value.toString()));
  20211. return retval;
  20212. }
  20213. /*:287*//*288:*/
  20214. #line 6820 "./typica.w"
  20215. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  20216. {
  20217. QTableView*self= getself<QTableView*> (context);
  20218. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20219. model->clear();
  20220. return QScriptValue();
  20221. }
  20222. /*:288*//*289:*/
  20223. #line 6832 "./typica.w"
  20224. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  20225. {
  20226. QTableView*self= getself<QTableView*> (context);
  20227. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20228. int row= argument<int> (0,context);
  20229. return engine->newVariant(model->removeRow(row));
  20230. }
  20231. /*:289*//*290:*/
  20232. #line 6845 "./typica.w"
  20233. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  20234. {
  20235. QTableView*self= getself<QTableView*> (context);
  20236. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  20237. QVariant value= argument<QVariant> (0,context);
  20238. int column= argument<int> (1,context);
  20239. return engine->newVariant(model->findData(value,column));
  20240. }
  20241. /*:290*//*291:*/
  20242. #line 6858 "./typica.w"
  20243. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  20244. {
  20245. setQWidgetProperties(value,engine);
  20246. value.setProperty("columnArray",
  20247. engine->newFunction(SaltTable_columnArray));
  20248. value.setProperty("quotedColumnArray",
  20249. engine->newFunction(SaltTable_quotedColumnArray));
  20250. value.setProperty("bindableColumnArray",
  20251. engine->newFunction(SaltTable_bindableColumnArray));
  20252. value.setProperty("bindableQuotedColumnArray",
  20253. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  20254. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  20255. value.setProperty("data",engine->newFunction(SaltTable_data));
  20256. value.setProperty("model",engine->newFunction(SaltTable_model));
  20257. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  20258. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  20259. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  20260. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  20261. }
  20262. /*:291*//*293:*/
  20263. #line 6895 "./typica.w"
  20264. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  20265. {
  20266. setQComboBoxProperties(value,engine);
  20267. }
  20268. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  20269. {
  20270. setQWidgetProperties(value,engine);
  20271. value.setProperty("currentData",
  20272. engine->newFunction(QComboBox_currentData));
  20273. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  20274. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  20275. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  20276. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  20277. }
  20278. QScriptValue QComboBox_currentData(QScriptContext*context,
  20279. QScriptEngine*engine)
  20280. {
  20281. QComboBox*self= getself<QComboBox*> (context);
  20282. return QScriptValue(engine,
  20283. self->itemData(self->currentIndex()).toString());
  20284. }
  20285. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  20286. {
  20287. QComboBox*self= getself<QComboBox*> (context);
  20288. self->addItem(argument<QString> (0,context));
  20289. return QScriptValue();
  20290. }
  20291. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  20292. {
  20293. QComboBox*self= getself<QComboBox*> (context);
  20294. self->setModel(argument<QAbstractItemModel*> (0,context));
  20295. return QScriptValue();
  20296. }
  20297. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  20298. {
  20299. QComboBox*self= getself<QComboBox*> (context);
  20300. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  20301. }
  20302. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  20303. {
  20304. QComboBox*self= getself<QComboBox*> (context);
  20305. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  20306. }
  20307. #line 1 "./abouttypica.w"
  20308. /*:293*//*306:*/
  20309. #line 401 "./units.w"
  20310. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  20311. {
  20312. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  20313. argument<Units::Unit> (1,context),
  20314. argument<Units::Unit> (2,context)));
  20315. }
  20316. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  20317. QScriptEngine*)
  20318. {
  20319. return QScriptValue(Units::convertRelativeTemperature(
  20320. argument<double> (0,context),
  20321. argument<Units::Unit> (1,context),
  20322. argument<Units::Unit> (2,context)));
  20323. }
  20324. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  20325. {
  20326. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  20327. }
  20328. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  20329. {
  20330. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  20331. argument<Units::Unit> (1,context),
  20332. argument<Units::Unit> (2,context)));
  20333. }
  20334. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  20335. {
  20336. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  20337. }
  20338. /*:306*//*309:*/
  20339. #line 449 "./units.w"
  20340. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  20341. {
  20342. return engine->newVariant(QVariant(value));
  20343. }
  20344. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  20345. {
  20346. value= sv.toVariant().value<Units::Unit> ();
  20347. }
  20348. /*:309*//*319:*/
  20349. #line 149 "./measurement.w"
  20350. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  20351. {
  20352. QScriptValue object;
  20353. if(context->argumentCount()==2||context->argumentCount()==3)
  20354. {
  20355. double measurement= argument<double> (0,context);
  20356. QTime timestamp= argument<QTime> (1,context);
  20357. Units::Unit unit= Units::Fahrenheit;
  20358. if(context->argumentCount()==3)
  20359. {
  20360. unit= argument<Units::Unit> (2,context);
  20361. }
  20362. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  20363. setMeasurementProperties(object,engine);
  20364. }
  20365. else
  20366. {
  20367. context->throwError("Incorrect number of arguments passed to "
  20368. "Measurement::Measurement(). This method takes two "
  20369. "or three arguments.");
  20370. }
  20371. return object;
  20372. }
  20373. /*:319*//*320:*/
  20374. #line 176 "./measurement.w"
  20375. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  20376. {
  20377. }
  20378. /*:320*//*321:*/
  20379. #line 184 "./measurement.w"
  20380. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  20381. {
  20382. QVariant var;
  20383. var.setValue(measurement);
  20384. return engine->newVariant(var);
  20385. }
  20386. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  20387. {
  20388. measurement= value.toVariant().value<Measurement> ();
  20389. }
  20390. #line 6964 "./typica.w"
  20391. /*:321*//*339:*/
  20392. #line 7542 "./typica.w"
  20393. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  20394. {
  20395. QScriptValue object;
  20396. if(context->argumentCount()==1)
  20397. {
  20398. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  20399. QScriptEngine::ScriptOwnership);
  20400. setDAQProperties(object,engine);
  20401. }
  20402. else if(context->argumentCount()==2)
  20403. {
  20404. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  20405. argument<QString> (1,context)),
  20406. QScriptEngine::ScriptOwnership);
  20407. setDAQProperties(object,engine);
  20408. }
  20409. else
  20410. {
  20411. context->throwError("Incorrect number of arguments passed to DAQ"
  20412. "constructor. The DAQ constructor takes one"
  20413. "string as an argument specifying a device name."
  20414. "Example: Dev1");
  20415. }
  20416. return object;
  20417. }
  20418. /*:339*//*340:*/
  20419. #line 7572 "./typica.w"
  20420. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  20421. {
  20422. setQObjectProperties(value,engine);
  20423. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  20424. }
  20425. /*:340*//*341:*/
  20426. #line 7582 "./typica.w"
  20427. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20428. {
  20429. DAQ*self= getself<DAQ*> (context);
  20430. QScriptValue object;
  20431. if(self)
  20432. {
  20433. object=
  20434. engine->newQObject(self->newChannel(argument<int> (0,context),
  20435. argument<int> (1,context)));
  20436. setChannelProperties(object,engine);
  20437. }
  20438. return object;
  20439. }
  20440. /*:341*//*348:*/
  20441. #line 7738 "./typica.w"
  20442. QScriptValue constructFakeDAQ(QScriptContext*context,
  20443. QScriptEngine*engine)
  20444. {
  20445. QScriptValue object;
  20446. if(context->argumentCount()==1)
  20447. {
  20448. object=
  20449. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  20450. QScriptEngine::ScriptOwnership);
  20451. setFakeDAQProperties(object,engine);
  20452. }
  20453. else
  20454. {
  20455. context->throwError("Incorrect number of arguments passed to DAQ"
  20456. "constructor. The DAQ constructor takes one"
  20457. "string as an argument specifying a device name."
  20458. "Example: Dev1");
  20459. }
  20460. return object;
  20461. }
  20462. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  20463. {
  20464. setQObjectProperties(value,engine);
  20465. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  20466. }
  20467. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20468. {
  20469. FakeDAQ*self= getself<FakeDAQ*> (context);
  20470. QScriptValue object;
  20471. if(self)
  20472. {
  20473. object=
  20474. engine->newQObject(self->newChannel(argument<int> (0,context),
  20475. argument<int> (1,context)));
  20476. setChannelProperties(object,engine);
  20477. }
  20478. return object;
  20479. }
  20480. /*:348*//*352:*/
  20481. #line 7829 "./typica.w"
  20482. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  20483. {
  20484. setQObjectProperties(value,engine);
  20485. }
  20486. /*:352*//*359:*/
  20487. #line 8021 "./typica.w"
  20488. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  20489. {
  20490. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  20491. setLinearCalibratorProperties(object,engine);
  20492. return object;
  20493. }
  20494. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  20495. {
  20496. setQObjectProperties(value,engine);
  20497. }
  20498. /*:359*//*364:*/
  20499. #line 8159 "./typica.w"
  20500. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  20501. {
  20502. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  20503. setLinearSplineInterpolatorProperties(object,engine);
  20504. return object;
  20505. }
  20506. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  20507. {
  20508. setQObjectProperties(value,engine);
  20509. }
  20510. /*:364*//*374:*/
  20511. #line 8368 "./typica.w"
  20512. QScriptValue constructTemperatureDisplay(QScriptContext*,
  20513. QScriptEngine*engine)
  20514. {
  20515. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  20516. setTemperatureDisplayProperties(object,engine);
  20517. return object;
  20518. }
  20519. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20520. {
  20521. setQLCDNumberProperties(value,engine);
  20522. value.setProperty("setDisplayUnits",
  20523. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  20524. }
  20525. /*:374*//*375:*/
  20526. #line 8392 "./typica.w"
  20527. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20528. {
  20529. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  20530. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20531. return QScriptValue();
  20532. }
  20533. /*:375*//*382:*/
  20534. #line 8529 "./typica.w"
  20535. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  20536. QScriptEngine*engine)
  20537. {
  20538. QScriptValue object=
  20539. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  20540. setMeasurementTimeOffsetProperties(object,engine);
  20541. return object;
  20542. }
  20543. void setMeasurementTimeOffsetProperties(QScriptValue value,
  20544. QScriptEngine*engine)
  20545. {
  20546. setQObjectProperties(value,engine);
  20547. }
  20548. /*:382*//*387:*/
  20549. #line 8648 "./typica.w"
  20550. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  20551. {
  20552. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  20553. return object;
  20554. }
  20555. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  20556. {
  20557. setQObjectProperties(value,engine);
  20558. }
  20559. /*:387*//*392:*/
  20560. #line 8745 "./typica.w"
  20561. QScriptValue constructZeroEmitter(QScriptContext*context,
  20562. QScriptEngine*engine)
  20563. {
  20564. QScriptValue object=
  20565. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  20566. setZeroEmitterProperties(object,engine);
  20567. return object;
  20568. }
  20569. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  20570. {
  20571. setQObjectProperties(value,engine);
  20572. }
  20573. /*:392*//*397:*/
  20574. #line 8825 "./typica.w"
  20575. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  20576. QScriptEngine*engine)
  20577. {
  20578. QScriptValue object=
  20579. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  20580. setMeasurementAdapterProperties(object,engine);
  20581. return object;
  20582. }
  20583. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  20584. {
  20585. setQObjectProperties(value,engine);
  20586. }
  20587. /*:397*//*414:*/
  20588. #line 9287 "./typica.w"
  20589. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  20590. {
  20591. QScriptValue object= engine->newQObject(new GraphView);
  20592. setGraphViewProperties(object,engine);
  20593. return object;
  20594. }
  20595. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  20596. {
  20597. setQGraphicsViewProperties(value,engine);
  20598. }
  20599. /*:414*//*437:*/
  20600. #line 9937 "./typica.w"
  20601. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  20602. {
  20603. QScriptValue object= engine->newQObject(new ZoomLog);
  20604. setZoomLogProperties(object,engine);
  20605. return object;
  20606. }
  20607. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  20608. {
  20609. setQTableViewProperties(value,engine);
  20610. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  20611. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  20612. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  20613. value.setProperty("restoreState",
  20614. engine->newFunction(ZoomLog_restoreState));
  20615. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  20616. value.setProperty("saveTemporary",
  20617. engine->newFunction(ZoomLog_saveTemporary));
  20618. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  20619. }
  20620. /*:437*//*438:*/
  20621. #line 9964 "./typica.w"
  20622. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  20623. {
  20624. ZoomLog*self= getself<ZoomLog*> (context);
  20625. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  20626. return QScriptValue(engine,retval);
  20627. }
  20628. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  20629. {
  20630. ZoomLog*self= getself<ZoomLog*> (context);
  20631. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  20632. return QScriptValue(engine,retval);
  20633. }
  20634. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  20635. QScriptEngine*engine)
  20636. {
  20637. ZoomLog*self= getself<ZoomLog*> (context);
  20638. QString filename= QDir::tempPath();
  20639. filename.append("/");
  20640. filename.append(QUuid::createUuid().toString());
  20641. filename.append(".xml");
  20642. QFile*file= new QFile(filename);
  20643. self->saveXML(file);
  20644. file->close();
  20645. delete file;
  20646. return QScriptValue(engine,filename);
  20647. }
  20648. /*:438*//*439:*/
  20649. #line 10012 "./typica.w"
  20650. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  20651. {
  20652. ZoomLog*self= getself<ZoomLog*> (context);
  20653. QString key= argument<QString> (0,context);
  20654. int columns= argument<int> (1,context);
  20655. QSettings settings;
  20656. for(int i= 0;i<columns;i++)
  20657. {
  20658. if(self->columnWidth(i))
  20659. {
  20660. settings.beginGroup(key);
  20661. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  20662. settings.endGroup();
  20663. }
  20664. }
  20665. return QScriptValue();
  20666. }
  20667. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  20668. {
  20669. ZoomLog*self= getself<ZoomLog*> (context);
  20670. QString key= argument<QString> (0,context);
  20671. int columns= argument<int> (1,context);
  20672. QSettings settings;
  20673. for(int i= 0;i<columns;i++)
  20674. {
  20675. settings.beginGroup(key);
  20676. self->setColumnWidth(i,
  20677. settings.value(QString("%1").arg(i),80).toInt());
  20678. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  20679. {
  20680. self->setColumnWidth(i,80);
  20681. }
  20682. settings.endGroup();
  20683. }
  20684. return QScriptValue();
  20685. }
  20686. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  20687. {
  20688. ZoomLog*self= getself<ZoomLog*> (context);
  20689. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  20690. }
  20691. /*:439*//*440:*/
  20692. #line 10065 "./typica.w"
  20693. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20694. {
  20695. ZoomLog*self= getself<ZoomLog*> (context);
  20696. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20697. return QScriptValue();
  20698. }
  20699. /*:440*//*477:*/
  20700. #line 10940 "./typica.w"
  20701. QScriptValue constructAnnotationButton(QScriptContext*context,
  20702. QScriptEngine*engine)
  20703. {
  20704. QScriptValue object=
  20705. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  20706. setAnnotationButtonProperties(object,engine);
  20707. return object;
  20708. }
  20709. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  20710. {
  20711. setQPushButtonProperties(value,engine);
  20712. }
  20713. /*:477*//*485:*/
  20714. #line 11083 "./typica.w"
  20715. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  20716. QScriptEngine*engine)
  20717. {
  20718. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  20719. argument<QString> (0,context),argument<QString> (1,context)));
  20720. setAnnotationSpinBoxProperties(object,engine);
  20721. return object;
  20722. }
  20723. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20724. {
  20725. setQDoubleSpinBoxProperties(value,engine);
  20726. }
  20727. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20728. {
  20729. setQAbstractSpinBoxProperties(value,engine);
  20730. }
  20731. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20732. {
  20733. setQWidgetProperties(value,engine);
  20734. }
  20735. /*:485*//*506:*/
  20736. #line 11506 "./typica.w"
  20737. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  20738. {
  20739. QScriptValue object= engine->newQObject(new TimerDisplay);
  20740. setTimerDisplayProperties(object,engine);
  20741. return object;
  20742. }
  20743. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20744. {
  20745. setQLCDNumberProperties(value,engine);
  20746. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  20747. }
  20748. /*:506*//*507:*/
  20749. #line 11525 "./typica.w"
  20750. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  20751. {
  20752. TimerDisplay*self= getself<TimerDisplay*> (context);
  20753. if(self)
  20754. {
  20755. switch(argument<int> (0,context))
  20756. {
  20757. case 0:
  20758. self->setMode(TimerDisplay::CountUp);
  20759. break;
  20760. case 1:
  20761. self->setMode(TimerDisplay::CountDown);
  20762. break;
  20763. case 2:
  20764. self->setMode(TimerDisplay::Clock);
  20765. break;
  20766. default:
  20767. break;
  20768. }
  20769. }
  20770. return QScriptValue();
  20771. }
  20772. /*:507*//*534:*/
  20773. #line 12031 "./typica.w"
  20774. QScriptValue constructWidgetDecorator(QScriptContext*context,
  20775. QScriptEngine*engine)
  20776. {
  20777. QWidget*widget= argument<QWidget*> (0,context);
  20778. QString text= argument<QString> (1,context);
  20779. Qt::Orientations orientation;
  20780. switch(argument<int> (2,context))
  20781. {
  20782. case 2:
  20783. orientation= Qt::Vertical;
  20784. break;
  20785. default:
  20786. orientation= Qt::Horizontal;
  20787. break;
  20788. }
  20789. QScriptValue object=
  20790. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  20791. setWidgetDecoratorProperties(object,engine);
  20792. return object;
  20793. }
  20794. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  20795. {
  20796. setQWidgetProperties(value,engine);
  20797. }
  20798. /*:534*//*547:*/
  20799. #line 12312 "./typica.w"
  20800. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  20801. {
  20802. QScriptValue object= engine->newQObject(new LogEditWindow);
  20803. return object;
  20804. }
  20805. /*:547*//*566:*/
  20806. #line 12839 "./typica.w"
  20807. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  20808. {
  20809. QIODevice*device= argument<QIODevice*> (0,context);
  20810. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  20811. argument<int> (1,context)));
  20812. object.setProperty("input",engine->newFunction(XMLInput_input));
  20813. return object;
  20814. }
  20815. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  20816. {
  20817. XMLInput*self= getself<XMLInput*> (context);
  20818. self->input();
  20819. return QScriptValue();
  20820. }
  20821. /*:566*//*581:*/
  20822. #line 172 "./webview.w"
  20823. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  20824. {
  20825. QScriptValue object= engine->newQObject(new TypicaWebView);
  20826. setQWebViewProperties(object,engine);
  20827. return object;
  20828. }
  20829. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  20830. {
  20831. setQWidgetProperties(value,engine);
  20832. }
  20833. /*:581*//*582:*/
  20834. #line 189 "./webview.w"
  20835. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  20836. QStack<QLayout*> *layoutStack)
  20837. {
  20838. TypicaWebView*view= new TypicaWebView;
  20839. int stretch= 0;
  20840. if(element.hasAttribute("id"))
  20841. {
  20842. view->setObjectName(element.attribute("id"));
  20843. }
  20844. if(element.hasAttribute("stretch"))
  20845. {
  20846. stretch= element.attribute("stretch").toInt();
  20847. }
  20848. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20849. layout->addWidget(view,stretch);
  20850. }
  20851. /*:582*//*587:*/
  20852. #line 245 "./webview.w"
  20853. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  20854. {
  20855. QVariant var;
  20856. var.setValue(element);
  20857. QScriptValue object= engine->newVariant(var);
  20858. return object;
  20859. }
  20860. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  20861. {
  20862. element= value.toVariant().value<QWebElement> ();
  20863. }
  20864. /*:587*//*592:*/
  20865. #line 310 "./webview.w"
  20866. template<> QWebElement argument(int arg,QScriptContext*context)
  20867. {
  20868. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  20869. }
  20870. /*:592*//*593:*/
  20871. #line 319 "./webview.w"
  20872. QScriptValue constructWebElement(QScriptContext*context,
  20873. QScriptEngine*engine)
  20874. {
  20875. QWebElement element= argument<QWebElement> (0,context);
  20876. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  20877. return object;
  20878. }
  20879. /*:593*//*604:*/
  20880. #line 85 "./printerselector.w"
  20881. QScriptValue constructPrinterSelector(QScriptContext*,QScriptEngine*engine)
  20882. {
  20883. QScriptValue object= engine->newQObject(new PrinterSelector);
  20884. setQComboBoxProperties(object,engine);
  20885. return object;
  20886. }
  20887. /*:604*//*605:*/
  20888. #line 96 "./printerselector.w"
  20889. void addPrinterSelectorToLayout(QDomElement element,QStack<QWidget*> *,
  20890. QStack<QLayout*> *layoutStack)
  20891. {
  20892. PrinterSelector*selector= new PrinterSelector;
  20893. if(element.hasAttribute("id"))
  20894. {
  20895. selector->setObjectName(element.attribute("id"));
  20896. }
  20897. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20898. layout->addWidget(selector);
  20899. }
  20900. /*:605*//*618:*/
  20901. #line 13203 "./typica.w"
  20902. QScriptValue Application_subscribe(QScriptContext*context,
  20903. QScriptEngine*engine)
  20904. {
  20905. return engine->newQObject(
  20906. AppInstance->subscribe(argument<QString> (0,context)));
  20907. }
  20908. /*:618*//*677:*/
  20909. #line 14345 "./typica.w"
  20910. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  20911. {
  20912. QScriptValue object= engine->newQObject(new SqlQueryView);
  20913. setSqlQueryViewProperties(object,engine);
  20914. return object;
  20915. }
  20916. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  20917. {
  20918. setQTableViewProperties(value,engine);
  20919. value.setProperty("setHeaderData",
  20920. engine->newFunction(SqlQueryView_setHeaderData));
  20921. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  20922. value.setProperty("rows",engine->newFunction(SqlQueryView_rows));
  20923. }
  20924. /*:677*//*678:*/
  20925. #line 14364 "./typica.w"
  20926. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  20927. {
  20928. SqlQueryView*self= getself<SqlQueryView*> (context);
  20929. QString query= argument<QString> (0,context);
  20930. self->setQuery(query);
  20931. self->reset();
  20932. return QScriptValue();
  20933. }
  20934. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  20935. QScriptEngine*)
  20936. {
  20937. SqlQueryView*self= getself<SqlQueryView*> (context);
  20938. int section= argument<int> (0,context);
  20939. QString data= argument<QString> (1,context);
  20940. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  20941. return QScriptValue();
  20942. }
  20943. QScriptValue SqlQueryView_rows(QScriptContext*context,QScriptEngine*)
  20944. {
  20945. SqlQueryView*self= getself<SqlQueryView*> (context);
  20946. return QScriptValue(self->model()->rowCount());
  20947. }
  20948. /*:678*//*686:*/
  20949. #line 14579 "./typica.w"
  20950. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  20951. QStack<QLayout*> *layoutStack)
  20952. {
  20953. QTextEdit*widget= new QTextEdit;
  20954. if(element.hasAttribute("id"))
  20955. {
  20956. widget->setObjectName(element.attribute("id"));
  20957. }
  20958. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20959. layout->addWidget(widget);
  20960. QTextDocument*document= new QTextDocument;
  20961. QFont defaultFont;
  20962. defaultFont.setPointSize(11);
  20963. document->setDefaultFont(defaultFont);
  20964. QTextCursor cursor(document);
  20965. /*687:*/
  20966. #line 14602 "./typica.w"
  20967. QDomNodeList children= element.childNodes();
  20968. for(int i= 0;i<children.count();i++)
  20969. {
  20970. QDomNode current;
  20971. QDomElement currentElement;
  20972. current= children.at(i);
  20973. if(current.isElement())
  20974. {
  20975. currentElement= current.toElement();
  20976. /*688:*/
  20977. #line 14619 "./typica.w"
  20978. if(currentElement.tagName()=="style")
  20979. {
  20980. document->setDefaultStyleSheet(currentElement.text());
  20981. }
  20982. /*:688*//*689:*/
  20983. #line 14630 "./typica.w"
  20984. if(currentElement.tagName()=="html")
  20985. {
  20986. cursor.insertHtml(currentElement.text());
  20987. }
  20988. /*:689*//*690:*/
  20989. #line 14640 "./typica.w"
  20990. if(currentElement.tagName()=="text")
  20991. {
  20992. cursor.insertText(currentElement.text());
  20993. }
  20994. /*:690*//*691:*/
  20995. #line 14650 "./typica.w"
  20996. if(currentElement.tagName()=="table")
  20997. {
  20998. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  20999. ReportTable*table= new ReportTable(frame,currentElement);
  21000. table->setParent(widget);
  21001. if(currentElement.hasAttribute("id"))
  21002. {
  21003. table->setObjectName(currentElement.attribute("id"));
  21004. }
  21005. }
  21006. /*:691*/
  21007. #line 14612 "./typica.w"
  21008. }
  21009. }
  21010. /*:687*/
  21011. #line 14595 "./typica.w"
  21012. widget->setDocument(document);
  21013. }
  21014. /*:686*//*702:*/
  21015. #line 14863 "./typica.w"
  21016. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  21017. {
  21018. QTextEdit*self= getself<QTextEdit*> (context);
  21019. QTextDocument*document= self->document();
  21020. QPrinter printer;
  21021. QPrintDialog printwindow(&printer,self);
  21022. if(printwindow.exec()!=QDialog::Accepted)
  21023. {
  21024. return QScriptValue();
  21025. }
  21026. document->print(&printer);
  21027. return QScriptValue();
  21028. }
  21029. /*:702*//*703:*/
  21030. #line 14881 "./typica.w"
  21031. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  21032. {
  21033. setQAbstractScrollAreaProperties(value,engine);
  21034. value.setProperty("print",engine->newFunction(QTextEdit_print));
  21035. }
  21036. #line 1 "./plugins.w"
  21037. /*:703*//*728:*/
  21038. #line 461 "./daterangeselector.w"
  21039. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  21040. QStack<QLayout*> *layoutStack)
  21041. {
  21042. DateRangeSelector*widget= new DateRangeSelector;
  21043. if(element.hasAttribute("id"))
  21044. {
  21045. widget->setObjectName(element.attribute("id"));
  21046. }
  21047. if(element.hasAttribute("initial"))
  21048. {
  21049. widget->setCurrentIndex(element.attribute("initial").toInt());
  21050. }
  21051. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  21052. layout->addWidget(widget);
  21053. }
  21054. /*:728*//*739:*/
  21055. #line 15063 "./typica.w"
  21056. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  21057. QStack<QLayout*> *layoutStack)
  21058. {
  21059. FormArray*widget= new FormArray(element);
  21060. if(element.hasAttribute("id"))
  21061. {
  21062. widget->setObjectName(element.attribute("id"));
  21063. }
  21064. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  21065. layout->addWidget(widget);
  21066. }
  21067. /*:739*//*760:*/
  21068. #line 15650 "./typica.w"
  21069. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  21070. QStack<QLayout*> *layoutStack)
  21071. {
  21072. ScaleControl*scale= new ScaleControl;
  21073. if(element.hasAttribute("id"))
  21074. {
  21075. scale->setObjectName(element.attribute("id"));
  21076. }
  21077. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  21078. layout->addWidget(scale);
  21079. }
  21080. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  21081. QStack<QLayout*> *layoutStack)
  21082. {
  21083. IntensityControl*scale= new IntensityControl;
  21084. if(element.hasAttribute("id"))
  21085. {
  21086. scale->setObjectName(element.attribute("id"));
  21087. }
  21088. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  21089. layout->addWidget(scale);
  21090. }
  21091. /*:760*//*786:*/
  21092. #line 16240 "./typica.w"
  21093. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  21094. {
  21095. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  21096. setDeviceTreeModelProperties(object,engine);
  21097. return object;
  21098. }
  21099. /*:786*//*788:*/
  21100. #line 16263 "./typica.w"
  21101. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  21102. {
  21103. setQAbstractItemModelProperties(value,engine);
  21104. value.setProperty("referenceElement",
  21105. engine->newFunction(DeviceTreeModel_referenceElement));
  21106. }
  21107. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  21108. {
  21109. setQObjectProperties(value,engine);
  21110. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  21111. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  21112. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  21113. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  21114. }
  21115. /*:788*//*789:*/
  21116. #line 16290 "./typica.w"
  21117. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  21118. QScriptEngine*engine)
  21119. {
  21120. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  21121. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  21122. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  21123. QDomElement node;
  21124. QVariantMap retval;
  21125. retval.insert("driver",referenceElement.attribute("driver"));
  21126. for(int i= 0;i<configData.size();i++)
  21127. {
  21128. node= configData.at(i).toElement();
  21129. retval.insert(node.attribute("name"),node.attribute("value"));
  21130. }
  21131. return engine->toScriptValue(retval);
  21132. }
  21133. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  21134. {
  21135. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21136. QModelIndex index= argument<QModelIndex> (0,context);
  21137. int role= argument<int> (1,context);
  21138. return engine->toScriptValue(model->data(index,role));
  21139. }
  21140. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  21141. {
  21142. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21143. int row= 0;
  21144. int column= 0;
  21145. QModelIndex index;
  21146. if(context->argumentCount()> 1)
  21147. {
  21148. row= argument<int> (0,context);
  21149. column= argument<int> (1,context);
  21150. }
  21151. if(context->argumentCount()> 2)
  21152. {
  21153. index= argument<QModelIndex> (2,context);
  21154. }
  21155. QModelIndex retval= model->index(row,column,index);
  21156. return engine->toScriptValue(retval);
  21157. }
  21158. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  21159. QScriptEngine*)
  21160. {
  21161. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21162. QModelIndex index;
  21163. if(context->argumentCount()==1)
  21164. {
  21165. index= argument<QModelIndex> (0,context);
  21166. }
  21167. return QScriptValue(model->rowCount(index));
  21168. }
  21169. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  21170. QScriptEngine*engine)
  21171. {
  21172. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  21173. QModelIndex index;
  21174. if(context->argumentCount()==1)
  21175. {
  21176. index= argument<QModelIndex> (0,context);
  21177. }
  21178. return QScriptValue(engine,model->hasChildren(index));
  21179. }
  21180. /*:789*//*792:*/
  21181. #line 16374 "./typica.w"
  21182. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  21183. {
  21184. QVariant var;
  21185. var.setValue(index);
  21186. QScriptValue object= engine->newVariant(var);
  21187. return object;
  21188. }
  21189. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  21190. {
  21191. index= value.toVariant().value<QModelIndex> ();
  21192. }
  21193. /*:792*//*808:*/
  21194. #line 16672 "./typica.w"
  21195. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  21196. QScriptEngine*engine)
  21197. {
  21198. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  21199. return object;
  21200. }
  21201. /*:808*//*879:*/
  21202. #line 49 "./settings.w"
  21203. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  21204. {
  21205. QScriptValue object= engine->newQObject(new SettingsWindow);
  21206. return object;
  21207. }
  21208. /*:879*//*908:*/
  21209. #line 19322 "./typica.w"
  21210. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  21211. {
  21212. QScriptValue object;
  21213. if(context->argumentCount()==2)
  21214. {
  21215. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  21216. argument<QModelIndex> (1,context)),
  21217. QScriptEngine::ScriptOwnership);
  21218. setModbusRTUDeviceProperties(object,engine);
  21219. }
  21220. else
  21221. {
  21222. context->throwError("Incorrect number of arguments passed to "
  21223. "ModbusRTUDevice constructor. This takes the configuration model "
  21224. "and an index.");
  21225. }
  21226. return object;
  21227. }
  21228. /*:908*//*909:*/
  21229. #line 19344 "./typica.w"
  21230. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  21231. {
  21232. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  21233. QScriptValue object;
  21234. if(self)
  21235. {
  21236. if(self->channels.size()> 0)
  21237. {
  21238. object= engine->newQObject(self->channels.at(0));
  21239. setChannelProperties(object,engine);
  21240. }
  21241. }
  21242. return object;
  21243. }
  21244. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  21245. {
  21246. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  21247. QScriptValue object;
  21248. if(self)
  21249. {
  21250. if(self->channels.size()> 1)
  21251. {
  21252. object= engine->newQObject(self->channels.at(1));
  21253. setChannelProperties(object,engine);
  21254. }
  21255. }
  21256. return object;
  21257. }
  21258. /*:909*//*910:*/
  21259. #line 19377 "./typica.w"
  21260. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  21261. {
  21262. setQObjectProperties(value,engine);
  21263. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  21264. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  21265. }
  21266. /*:910*//*926:*/
  21267. #line 713 "./modbus.w"
  21268. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  21269. {
  21270. QScriptValue object;
  21271. if(context->argumentCount()==2)
  21272. {
  21273. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  21274. argument<QModelIndex> (1,context)),
  21275. QScriptEngine::ScriptOwnership);
  21276. setModbusNGProperties(object,engine);
  21277. }
  21278. else
  21279. {
  21280. context->throwError("Incorrect number of arguments passed to "
  21281. "ModbusNG constructor.");
  21282. }
  21283. return object;
  21284. }
  21285. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  21286. {
  21287. setQObjectProperties(value,engine);
  21288. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  21289. }
  21290. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  21291. {
  21292. ModbusNG*self= getself<ModbusNG*> (context);
  21293. QScriptValue object;
  21294. if(self)
  21295. {
  21296. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21297. setChannelProperties(object,engine);
  21298. }
  21299. return object;
  21300. }
  21301. #line 19928 "./typica.w"
  21302. #line 1 "./unsupportedserial.w"
  21303. /*:926*//*940:*/
  21304. #line 360 "./unsupportedserial.w"
  21305. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  21306. {
  21307. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  21308. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  21309. QScriptValue object= engine->newQObject(device);
  21310. setQObjectProperties(object,engine);
  21311. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  21312. return object;
  21313. }
  21314. /*:940*//*945:*/
  21315. #line 433 "./unsupportedserial.w"
  21316. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  21317. {
  21318. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  21319. QScriptValue object;
  21320. if(self)
  21321. {
  21322. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21323. setChannelProperties(object,engine);
  21324. }
  21325. return object;
  21326. }
  21327. /*:945*//*952:*/
  21328. #line 633 "./unsupportedserial.w"
  21329. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  21330. {
  21331. return engine->toScriptValue<QTime> (QTime::currentTime());
  21332. }
  21333. /*:952*//*956:*/
  21334. #line 670 "./unsupportedserial.w"
  21335. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  21336. {
  21337. QScriptValue object= engine->newQObject(new QextSerialPort());
  21338. setSerialPortProperties(object,engine);
  21339. return object;
  21340. }
  21341. /*:956*//*957:*/
  21342. #line 681 "./unsupportedserial.w"
  21343. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  21344. {
  21345. setQIODeviceProperties(value,engine);
  21346. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  21347. }
  21348. /*:957*//*958:*/
  21349. #line 690 "./unsupportedserial.w"
  21350. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  21351. {
  21352. QextSerialPort*self= getself<QextSerialPort*> (context);
  21353. self->flush();
  21354. return QScriptValue();
  21355. }
  21356. #line 19930 "./typica.w"
  21357. #line 1 "./phidgets.w"
  21358. /*:958*//*979:*/
  21359. #line 463 "./phidgets.w"
  21360. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  21361. {
  21362. if(context->argumentCount()!=1)
  21363. {
  21364. context->throwError("Incorrect number of arguments passed to "
  21365. "PhidgetsTemperatureSensor constructor. This takes "
  21366. "a QModelIndex.");
  21367. }
  21368. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  21369. setQObjectProperties(object,engine);
  21370. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  21371. return object;
  21372. }
  21373. /*:979*//*980:*/
  21374. #line 480 "./phidgets.w"
  21375. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  21376. {
  21377. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  21378. QScriptValue object;
  21379. if(self)
  21380. {
  21381. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21382. setChannelProperties(object,engine);
  21383. }
  21384. return object;
  21385. }
  21386. #line 19932 "./typica.w"
  21387. #line 1 "./phidget22.w"
  21388. /*:980*//*1011:*/
  21389. #line 811 "./phidget22.w"
  21390. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine)
  21391. {
  21392. if(context->argumentCount()!=1)
  21393. {
  21394. context->throwError("Incorrect number of arguments");
  21395. }
  21396. QScriptValue object= engine->newQObject(new Phidget22(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  21397. setQObjectProperties(object,engine);
  21398. object.setProperty("getChannel",engine->newFunction(Phidget22_getChannel));
  21399. return object;
  21400. }
  21401. /*:1011*//*1012:*/
  21402. #line 826 "./phidget22.w"
  21403. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine)
  21404. {
  21405. Phidget22*self= getself<Phidget22*> (context);
  21406. QScriptValue object;
  21407. if(self)
  21408. {
  21409. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  21410. setChannelProperties(object,engine);
  21411. }
  21412. return object;
  21413. }
  21414. #line 19934 "./typica.w"
  21415. /*:1012*//*1044:*/
  21416. #line 151 "./rate.w"
  21417. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  21418. {
  21419. int cachetime= 1;
  21420. int scaletime= 1;
  21421. if(context->argumentCount()> 0)
  21422. {
  21423. cachetime= argument<int> (0,context);
  21424. if(context->argumentCount()> 1)
  21425. {
  21426. scaletime= argument<int> (1,context);
  21427. }
  21428. }
  21429. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  21430. setRateOfChangeProperties(object,engine);
  21431. return object;
  21432. }
  21433. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  21434. {
  21435. setQObjectProperties(value,engine);
  21436. }
  21437. /*:1044*//*1058:*/
  21438. #line 148 "./mergeseries.w"
  21439. QScriptValue constructDifferenceSeries(QScriptContext*,QScriptEngine*engine)
  21440. {
  21441. QScriptValue object= engine->newQObject(new DifferenceSeries);
  21442. setQObjectProperties(object,engine);
  21443. return object;
  21444. }
  21445. QScriptValue constructMeanSeries(QScriptContext*,QScriptEngine*engine)
  21446. {
  21447. QScriptValue object= engine->newQObject(new MeanSeries);
  21448. setQObjectProperties(object,engine);
  21449. return object;
  21450. }
  21451. /*:1058*//*1083:*/
  21452. #line 614 "./dataqsdk.w"
  21453. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  21454. {
  21455. QScriptValue object;
  21456. if(context->argumentCount()==1)
  21457. {
  21458. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  21459. QScriptEngine::ScriptOwnership);
  21460. setDataqSdkDeviceProperties(object,engine);
  21461. }
  21462. else
  21463. {
  21464. context->throwError("Incorrect number of arguments passed to "
  21465. "DataqSdkDevice. The constructor takes one string "
  21466. "as an argument specifying a device name. "
  21467. "Example: Dev1");
  21468. }
  21469. return object;
  21470. }
  21471. /*:1083*//*1084:*/
  21472. #line 637 "./dataqsdk.w"
  21473. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  21474. {
  21475. setQObjectProperties(value,engine);
  21476. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  21477. }
  21478. /*:1084*//*1085:*/
  21479. #line 647 "./dataqsdk.w"
  21480. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  21481. {
  21482. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  21483. QScriptValue object;
  21484. if(self)
  21485. {
  21486. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  21487. setChannelProperties(object,engine);
  21488. }
  21489. return object;
  21490. }
  21491. /*:1085*//*1110:*/
  21492. #line 80 "./scales.w"
  21493. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  21494. {
  21495. QScriptValue object;
  21496. QString labelText= "";
  21497. if(context->argumentCount()==1)
  21498. {
  21499. labelText= argument<QString> (0,context);
  21500. }
  21501. object= engine->newQObject(new DragLabel(labelText));
  21502. setDragLabelProperties(object,engine);
  21503. return object;
  21504. }
  21505. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  21506. {
  21507. setQLabelProperties(value,engine);
  21508. }
  21509. /*:1110*//*1120:*/
  21510. #line 298 "./scales.w"
  21511. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  21512. {
  21513. return engine->newVariant(QVariant((int)(value)));
  21514. }
  21515. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  21516. {
  21517. value= (BaudRateType)(sv.toVariant().toInt());
  21518. }
  21519. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  21520. {
  21521. return engine->newVariant(QVariant((int)(value)));
  21522. }
  21523. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  21524. {
  21525. value= (DataBitsType)(sv.toVariant().toInt());
  21526. }
  21527. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  21528. {
  21529. return engine->newVariant(QVariant((int)(value)));
  21530. }
  21531. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  21532. {
  21533. value= (ParityType)(sv.toVariant().toInt());
  21534. }
  21535. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  21536. {
  21537. return engine->newVariant(QVariant((int)(value)));
  21538. }
  21539. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  21540. {
  21541. value= (StopBitsType)(sv.toVariant().toInt());
  21542. }
  21543. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  21544. {
  21545. return engine->newVariant(QVariant((int)(value)));
  21546. }
  21547. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  21548. {
  21549. value= (FlowType)(sv.toVariant().toInt());
  21550. }
  21551. /*:1120*//*1123:*/
  21552. #line 367 "./scales.w"
  21553. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  21554. {
  21555. setQIODeviceProperties(value,engine);
  21556. }
  21557. /*:1123*//*1124:*/
  21558. #line 375 "./scales.w"
  21559. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  21560. {
  21561. QScriptValue object;
  21562. if(context->argumentCount()==1)
  21563. {
  21564. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  21565. setSerialScaleProperties(object,engine);
  21566. }
  21567. else
  21568. {
  21569. context->throwError("Incorrect number of arguments passed to "
  21570. "SerialScale. The constructor takes one string "
  21571. "as an argument specifying a port name.");
  21572. }
  21573. return object;
  21574. }
  21575. /*:1124*//*1146:*/
  21576. #line 278 "./valueannotation.w"
  21577. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  21578. {
  21579. QScriptValue object= engine->newQObject(new ValueAnnotation);
  21580. setValueAnnotationProperties(object,engine);
  21581. return object;
  21582. }
  21583. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  21584. {
  21585. setQObjectProperties(value,engine);
  21586. }
  21587. #line 20598 "./typica.w"
  21588. #line 1 "./thresholdannotation.w"
  21589. /*:1146*//*1157:*/
  21590. #line 208 "./thresholdannotation.w"
  21591. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  21592. {
  21593. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  21594. setAnnotatorProperties(object,engine);
  21595. return object;
  21596. }
  21597. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  21598. {
  21599. setQObjectProperties(value,engine);
  21600. }
  21601. #line 20600 "./typica.w"
  21602. #line 1 "./user.w"
  21603. /*:1157*//*1167:*/
  21604. #line 142 "./user.w"
  21605. QScriptValue constructLoginDialog(QScriptContext*,QScriptEngine*engine)
  21606. {
  21607. QScriptValue object= engine->newQObject(new LoginDialog);
  21608. return object;
  21609. }
  21610. /*:1167*//*1177:*/
  21611. #line 330 "./user.w"
  21612. QScriptValue constructNewTypicaUser(QScriptContext*,QScriptEngine*engine)
  21613. {
  21614. QScriptValue object= engine->newQObject(new NewTypicaUser);
  21615. return object;
  21616. }
  21617. /*:1177*/
  21618. #line 533 "./typica.w"
  21619. /*656:*/
  21620. #line 13962 "./typica.w"
  21621. void messageFileOutput(QtMsgType,const char*msg)
  21622. {
  21623. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  21624. output.open(QIODevice::WriteOnly|QIODevice::Append);
  21625. QTextStream outstream(&output);
  21626. outstream<<msg<<"\r\n";
  21627. }
  21628. /*:656*/
  21629. #line 534 "./typica.w"
  21630. /*653:*/
  21631. #line 13923 "./typica.w"
  21632. int main(int argc,char**argv)
  21633. {
  21634. int*c= &argc;
  21635. Application app(*c,argv);
  21636. QSettings settings;
  21637. /*654:*/
  21638. #line 13949 "./typica.w"
  21639. if(settings.value("settings/advanced/logging",false).toBool())
  21640. {
  21641. qInstallMsgHandler(messageFileOutput);
  21642. }
  21643. /*:654*/
  21644. #line 13929 "./typica.w"
  21645. /*657:*/
  21646. #line 13975 "./typica.w"
  21647. QStringList themeSearchPath= QIcon::themeSearchPaths();
  21648. themeSearchPath.append(":/resources/icons/tango");
  21649. QIcon::setThemeSearchPaths(themeSearchPath);
  21650. QIcon::setThemeName(":/resources/icons/tango");
  21651. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  21652. /*:657*/
  21653. #line 13930 "./typica.w"
  21654. /*658:*/
  21655. #line 13995 "./typica.w"
  21656. QFile entypo(":/resources/fonts/entypo.ttf");
  21657. entypo.open(QIODevice::ReadOnly);
  21658. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  21659. entypo.close();
  21660. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  21661. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  21662. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  21663. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  21664. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  21665. /*:658*/
  21666. #line 13931 "./typica.w"
  21667. /*818:*/
  21668. #line 16962 "./typica.w"
  21669. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  21670. /*:818*//*828:*/
  21671. #line 17204 "./typica.w"
  21672. app.registerDeviceConfigurationWidget("nidaqmxbase",
  21673. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  21674. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  21675. NiDaqMxBase9211ConfWidget::staticMetaObject);
  21676. app.registerDeviceConfigurationWidget("ni9211seriestc",
  21677. Ni9211TcConfWidget::staticMetaObject);
  21678. /*:828*//*836:*/
  21679. #line 17435 "./typica.w"
  21680. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  21681. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  21682. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  21683. /*:836*//*860:*/
  21684. #line 18404 "./typica.w"
  21685. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  21686. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  21687. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  21688. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  21689. /*:860*//*865:*/
  21690. #line 18489 "./typica.w"
  21691. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  21692. /*:865*//*868:*/
  21693. #line 18560 "./typica.w"
  21694. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  21695. /*:868*//*871:*/
  21696. #line 18687 "./typica.w"
  21697. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  21698. #line 1 "./freeannotation.w"
  21699. /*:871*//*875:*/
  21700. #line 57 "./freeannotation.w"
  21701. app.registerDeviceConfigurationWidget("freeannotation",
  21702. FreeAnnotationConfWidget::staticMetaObject);
  21703. #line 18691 "./typica.w"
  21704. #line 1 "./settings.w"
  21705. /*:875*//*913:*/
  21706. #line 19918 "./typica.w"
  21707. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  21708. /*:913*//*919:*/
  21709. #line 321 "./modbus.w"
  21710. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  21711. app.registerDeviceConfigurationWidget("modbusnginput",
  21712. ModbusNGInputConfWidget::staticMetaObject);
  21713. /*:919*//*935:*/
  21714. #line 267 "./unsupportedserial.w"
  21715. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  21716. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  21717. app.registerDeviceConfigurationWidget("unsupporteddevice",
  21718. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  21719. /*:935*//*966:*/
  21720. #line 181 "./phidgets.w"
  21721. app.registerDeviceConfigurationWidget("phidgets1048",
  21722. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  21723. app.registerDeviceConfigurationWidget("phidgets1048channel",
  21724. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  21725. /*:966*//*982:*/
  21726. #line 35 "./phidget22.w"
  21727. app.registerDeviceConfigurationWidget("phidget22",
  21728. PhidgetConfWidget::staticMetaObject);
  21729. app.registerDeviceConfigurationWidget("phidgetchannel",
  21730. PhidgetChannelConfWidget::staticMetaObject);
  21731. /*:982*//*1018:*/
  21732. #line 20056 "./typica.w"
  21733. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  21734. /*:1018*//*1021:*/
  21735. #line 20116 "./typica.w"
  21736. app.registerDeviceConfigurationWidget("coolingtimer",
  21737. CoolingTimerConfWidget::staticMetaObject);
  21738. /*:1021*//*1026:*/
  21739. #line 20375 "./typica.w"
  21740. app.registerDeviceConfigurationWidget("rangetimer",
  21741. RangeTimerConfWidget::staticMetaObject);
  21742. /*:1026*//*1031:*/
  21743. #line 20476 "./typica.w"
  21744. app.registerDeviceConfigurationWidget("multirangetimer",
  21745. MultiRangeTimerConfWidget::staticMetaObject);
  21746. /*:1031*//*1036:*/
  21747. #line 20586 "./typica.w"
  21748. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  21749. #line 1 "./rate.w"
  21750. /*:1036*//*1048:*/
  21751. #line 253 "./rate.w"
  21752. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  21753. /*:1048*//*1062:*/
  21754. #line 266 "./mergeseries.w"
  21755. app.registerDeviceConfigurationWidget("mergeseries",
  21756. MergeSeriesConfWidget::staticMetaObject);
  21757. /*:1062*//*1103:*/
  21758. #line 1233 "./dataqsdk.w"
  21759. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  21760. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  21761. DataqSdkChannelConfWidget::staticMetaObject);
  21762. /*:1103*//*1128:*/
  21763. #line 552 "./scales.w"
  21764. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  21765. /*:1128*//*1136:*/
  21766. #line 138 "./valueannotation.w"
  21767. app.registerDeviceConfigurationWidget("valueannotation",
  21768. ValueAnnotationConfWidget::staticMetaObject);
  21769. /*:1136*//*1150:*/
  21770. #line 109 "./thresholdannotation.w"
  21771. app.registerDeviceConfigurationWidget("thresholdannotation",
  21772. ThresholdAnnotationConfWidget::staticMetaObject);
  21773. /*:1150*/
  21774. #line 13933 "./typica.w"
  21775. /*659:*/
  21776. #line 14012 "./typica.w"
  21777. if(settings.value("database/exists","false").toString()=="true")
  21778. {
  21779. /*664:*/
  21780. #line 14146 "./typica.w"
  21781. QSqlDatabase database=
  21782. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  21783. database.setConnectOptions("application_name=Typica");
  21784. database.setHostName(settings.value("database/hostname").toString());
  21785. database.setPort(settings.value("database/portnumber",5432).toInt());
  21786. database.setDatabaseName(settings.value("database/dbname").toString());
  21787. database.setUserName(settings.value("database/user").toString());
  21788. database.setPassword(settings.value("database/password").toString());
  21789. if(!database.open())
  21790. {
  21791. settings.setValue("database/exists","false");
  21792. }
  21793. else
  21794. {
  21795. AppInstance->setDatabaseConnected(true);
  21796. }
  21797. /*:664*/
  21798. #line 14015 "./typica.w"
  21799. }
  21800. if(settings.value("database/exists","false").toString()=="false")
  21801. {
  21802. /*663:*/
  21803. #line 14137 "./typica.w"
  21804. SqlConnectionSetup dialog;
  21805. dialog.exec();
  21806. /*:663*/
  21807. #line 14019 "./typica.w"
  21808. }
  21809. /*:659*/
  21810. #line 13934 "./typica.w"
  21811. /*199:*/
  21812. #line 4503 "./typica.w"
  21813. QStringList arguments= QCoreApplication::arguments();
  21814. int position= arguments.indexOf("-c");
  21815. QString filename= QString();
  21816. if(position!=-1)
  21817. {
  21818. if(arguments.size()>=position+1)
  21819. {
  21820. filename= arguments.at(position+1);
  21821. }
  21822. }else{
  21823. QDir checkPath(QCoreApplication::applicationDirPath()+"/../config/");
  21824. if(checkPath.exists("config.xml")){
  21825. filename= checkPath.filePath("config.xml");
  21826. }else{
  21827. checkPath= QDir(QCoreApplication::applicationDirPath()+"/config/");
  21828. if(checkPath.exists("config.xml")){
  21829. filename= checkPath.filePath("config.xml");
  21830. }
  21831. }
  21832. }
  21833. if(filename.isEmpty())
  21834. {
  21835. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  21836. settings.value("config","").toString());
  21837. }
  21838. QDir directory;
  21839. if(!filename.isEmpty())
  21840. {
  21841. QFile file(filename);
  21842. QFileInfo info(filename);
  21843. directory= info.dir();
  21844. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  21845. QTranslator*configtr= new QTranslator;
  21846. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  21847. QString("%1/Translations").arg(directory.canonicalPath())))
  21848. {
  21849. QCoreApplication::installTranslator(configtr);
  21850. }
  21851. settings.setValue("config",directory.path());
  21852. if(file.open(QIODevice::ReadOnly))
  21853. {
  21854. app.configuration()->setContent(&file,true);
  21855. }
  21856. }else{
  21857. return 1;
  21858. }
  21859. /*200:*/
  21860. #line 4556 "./typica.w"
  21861. QDomElement root= app.configuration()->documentElement();
  21862. QDomNodeList children= root.childNodes();
  21863. QString replacementDoc;
  21864. QDomDocument includedDoc;
  21865. QDomDocumentFragment fragment;
  21866. for(int i= 0;i<children.size();i++)
  21867. {
  21868. QDomNode currentNode= children.at(i);
  21869. QDomElement currentElement;
  21870. if(currentNode.nodeName()=="include")
  21871. {
  21872. currentElement= currentNode.toElement();
  21873. if(currentElement.hasAttribute("src"))
  21874. {
  21875. replacementDoc= directory.path();
  21876. replacementDoc.append('/');
  21877. replacementDoc.append(currentElement.attribute("src"));
  21878. QFile doc(replacementDoc);
  21879. if(doc.open(QIODevice::ReadOnly))
  21880. {
  21881. includedDoc.setContent(&doc,true);
  21882. fragment= includedDoc.createDocumentFragment();
  21883. fragment.appendChild(includedDoc.documentElement());
  21884. root.replaceChild(fragment,currentNode);
  21885. doc.close();
  21886. }
  21887. }
  21888. }
  21889. }
  21890. /*:200*/
  21891. #line 4550 "./typica.w"
  21892. /*:199*/
  21893. #line 13935 "./typica.w"
  21894. /*7:*/
  21895. #line 667 "./typica.w"
  21896. QScriptEngine*engine= new QScriptEngine;
  21897. QScriptValue constructor;
  21898. QScriptValue value;
  21899. /*:7*//*17:*/
  21900. #line 875 "./typica.w"
  21901. constructor= engine->newFunction(constructQTimer);
  21902. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  21903. engine->globalObject().setProperty("Timer",value);
  21904. /*:17*//*20:*/
  21905. #line 914 "./typica.w"
  21906. constructor= engine->newFunction(constructQWidget);
  21907. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  21908. engine->globalObject().setProperty("QWidget",value);
  21909. /*:20*//*24:*/
  21910. #line 1002 "./typica.w"
  21911. constructor= engine->newFunction(displayWarning);
  21912. engine->globalObject().setProperty("displayWarning",constructor);
  21913. constructor= engine->newFunction(displayError);
  21914. engine->globalObject().setProperty("displayError",constructor);
  21915. constructor= engine->newFunction(displayInfo);
  21916. engine->globalObject().setProperty("displayInfo",constructor);
  21917. /*:24*//*34:*/
  21918. #line 1240 "./typica.w"
  21919. constructor= engine->newFunction(constructQMainWindow);
  21920. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  21921. constructor);
  21922. engine->globalObject().setProperty("QMainWindow",value);
  21923. /*:34*//*45:*/
  21924. #line 1445 "./typica.w"
  21925. constructor= engine->newFunction(constructQFrame);
  21926. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  21927. engine->globalObject().setProperty("QFrame",value);
  21928. /*:45*//*48:*/
  21929. #line 1478 "./typica.w"
  21930. constructor= engine->newFunction(constructQLabel);
  21931. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  21932. engine->globalObject().setProperty("QLabel",value);
  21933. /*:48*//*51:*/
  21934. #line 1521 "./typica.w"
  21935. constructor= engine->newFunction(constructQSvgWidget);
  21936. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  21937. engine->globalObject().setProperty("QSvgWidget",value);
  21938. /*:51*//*57:*/
  21939. #line 1603 "./typica.w"
  21940. constructor= engine->newFunction(constructQLineEdit);
  21941. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  21942. engine->globalObject().setProperty("QLineEdit",value);
  21943. /*:57*//*61:*/
  21944. #line 1652 "./typica.w"
  21945. constructor= engine->newFunction(constructQSplitter);
  21946. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  21947. engine->globalObject().setProperty("QSplitter",value);
  21948. /*:61*//*70:*/
  21949. #line 1861 "./typica.w"
  21950. constructor= engine->newFunction(constructQBoxLayout);
  21951. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  21952. engine->globalObject().setProperty("QBoxLayout",value);
  21953. /*:70*//*74:*/
  21954. #line 1973 "./typica.w"
  21955. constructor= engine->newFunction(constructQAction);
  21956. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  21957. engine->globalObject().setProperty("QAction",value);
  21958. /*:74*//*77:*/
  21959. #line 2032 "./typica.w"
  21960. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  21961. value.setProperty("getOpenFileName",
  21962. engine->newFunction(QFileDialog_getOpenFileName));
  21963. value.setProperty("getSaveFileName",
  21964. engine->newFunction(QFileDialog_getSaveFileName));
  21965. engine->globalObject().setProperty("QFileDialog",value);
  21966. /*:77*//*82:*/
  21967. #line 2150 "./typica.w"
  21968. constructor= engine->newFunction(constructQFile);
  21969. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  21970. engine->globalObject().setProperty("QFile",value);
  21971. /*:82*//*93:*/
  21972. #line 2368 "./typica.w"
  21973. constructor= engine->newFunction(constructQProcess);
  21974. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  21975. engine->globalObject().setProperty("QProcess",value);
  21976. /*:93*//*102:*/
  21977. #line 2517 "./typica.w"
  21978. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  21979. constructor= engine->newFunction(constructQByteArray);
  21980. engine->globalObject().setProperty("QByteArray",constructor);
  21981. /*:102*//*114:*/
  21982. #line 2759 "./typica.w"
  21983. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  21984. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  21985. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  21986. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  21987. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  21988. /*:114*//*117:*/
  21989. #line 2863 "./typica.w"
  21990. constructor= engine->newFunction(constructQBuffer);
  21991. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  21992. engine->globalObject().setProperty("QBuffer",value);
  21993. /*:117*//*120:*/
  21994. #line 2919 "./typica.w"
  21995. constructor= engine->newFunction(constructXQuery);
  21996. engine->globalObject().setProperty("XQuery",constructor);
  21997. /*:120*//*126:*/
  21998. #line 3021 "./typica.w"
  21999. constructor= engine->newFunction(constructXmlWriter);
  22000. engine->globalObject().setProperty("XmlWriter",constructor);
  22001. /*:126*//*135:*/
  22002. #line 3227 "./typica.w"
  22003. constructor= engine->newFunction(constructXmlReader);
  22004. engine->globalObject().setProperty("XmlReader",constructor);
  22005. /*:135*//*142:*/
  22006. #line 3351 "./typica.w"
  22007. value= engine->newQObject(&settings);
  22008. setQSettingsProperties(value,engine);
  22009. engine->globalObject().setProperty("QSettings",value);
  22010. /*:142*//*146:*/
  22011. #line 3432 "./typica.w"
  22012. constructor= engine->newFunction(constructQLCDNumber);
  22013. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  22014. engine->globalObject().setProperty("QLCDNumber",value);
  22015. /*:146*//*149:*/
  22016. #line 3488 "./typica.w"
  22017. constructor= engine->newFunction(constructQTime);
  22018. engine->globalObject().setProperty("QTime",constructor);
  22019. /*:149*//*165:*/
  22020. #line 3946 "./typica.w"
  22021. constructor= engine->newFunction(constructQColor);
  22022. engine->globalObject().setProperty("QColor",constructor);
  22023. /*:165*//*168:*/
  22024. #line 3969 "./typica.w"
  22025. constructor= engine->newFunction(constructQBrush);
  22026. engine->globalObject().setProperty("QBrush",constructor);
  22027. /*:168*//*177:*/
  22028. #line 4049 "./typica.w"
  22029. constructor= engine->newFunction(constructQPushButton);
  22030. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  22031. engine->globalObject().setProperty("QPushButton",value);
  22032. /*:177*//*184:*/
  22033. #line 4160 "./typica.w"
  22034. constructor= engine->newFunction(constructQSqlQuery);
  22035. engine->globalObject().setProperty("QSqlQuery",constructor);
  22036. /*:184*//*191:*/
  22037. #line 4324 "./typica.w"
  22038. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  22039. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  22040. engine->globalObject().setProperty("sqlToArray",
  22041. engine->newFunction(sqlToArray));
  22042. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  22043. engine->globalObject().setProperty("annotationFromRecord",
  22044. engine->newFunction(annotationFromRecord));
  22045. engine->globalObject().setProperty("setTabOrder",
  22046. engine->newFunction(setTabOrder));
  22047. engine->globalObject().setProperty("saveFileFromDatabase",
  22048. engine->newFunction(saveFileFromDatabase));
  22049. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  22050. /*:191*//*204:*/
  22051. #line 4725 "./typica.w"
  22052. engine->globalObject().setProperty("createWindow",
  22053. engine->newFunction(createWindow));
  22054. engine->globalObject().setProperty("createReport",
  22055. engine->newFunction(createReport));
  22056. /*:204*//*229:*/
  22057. #line 5097 "./typica.w"
  22058. constructor= engine->newFunction(constructQTabBar);
  22059. value= engine->newQMetaObject(&QTabBar::staticMetaObject,constructor);
  22060. engine->globalObject().setProperty("QTabBar",value);
  22061. /*:229*//*279:*/
  22062. #line 6525 "./typica.w"
  22063. engine->globalObject().setProperty("findChildObject",
  22064. engine->newFunction(findChildObject));
  22065. /*:279*//*305:*/
  22066. #line 389 "./units.w"
  22067. value= engine->newQMetaObject(&Units::staticMetaObject);
  22068. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  22069. value.setProperty("convertRelativeTemperature",
  22070. engine->newFunction(Units_convertRelativeTemperature));
  22071. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  22072. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  22073. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  22074. engine->globalObject().setProperty("Units",value);
  22075. /*:305*//*310:*/
  22076. #line 462 "./units.w"
  22077. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  22078. #line 6957 "./typica.w"
  22079. /*:310*//*318:*/
  22080. #line 141 "./measurement.w"
  22081. constructor= engine->newFunction(constructMeasurement);
  22082. engine->globalObject().setProperty("Measurement",constructor);
  22083. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  22084. /*:318*//*338:*/
  22085. #line 7528 "./typica.w"
  22086. constructor= engine->newFunction(constructDAQ);
  22087. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  22088. value.setProperty("Fahrenheit",Units::Fahrenheit);
  22089. value.setProperty("Celsius",Units::Celsius);
  22090. value.setProperty("Kelvin",Units::Kelvin);
  22091. value.setProperty("Rankine",Units::Rankine);
  22092. engine->globalObject().setProperty("DAQ",value);
  22093. /*:338*//*347:*/
  22094. #line 7730 "./typica.w"
  22095. constructor= engine->newFunction(constructFakeDAQ);
  22096. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  22097. engine->globalObject().setProperty("FakeDAQ",value);
  22098. /*:347*//*358:*/
  22099. #line 8013 "./typica.w"
  22100. constructor= engine->newFunction(constructLinearCalibrator);
  22101. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  22102. constructor);
  22103. engine->globalObject().setProperty("LinearCalibrator",value);
  22104. /*:358*//*363:*/
  22105. #line 8152 "./typica.w"
  22106. constructor= engine->newFunction(constructLinearSplineInterpolator);
  22107. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  22108. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  22109. /*:363*//*373:*/
  22110. #line 8360 "./typica.w"
  22111. constructor= engine->newFunction(constructTemperatureDisplay);
  22112. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  22113. constructor);
  22114. engine->globalObject().setProperty("TemperatureDisplay",value);
  22115. /*:373*//*381:*/
  22116. #line 8518 "./typica.w"
  22117. constructor= engine->newFunction(constructMeasurementTimeOffset);
  22118. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  22119. constructor);
  22120. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  22121. /*:381*//*386:*/
  22122. #line 8639 "./typica.w"
  22123. constructor= engine->newFunction(constructThresholdDetector);
  22124. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  22125. engine->globalObject().setProperty("ThresholdDetector",value);
  22126. /*:386*//*391:*/
  22127. #line 8738 "./typica.w"
  22128. constructor= engine->newFunction(constructZeroEmitter);
  22129. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  22130. engine->globalObject().setProperty("ZeroEmitter",value);
  22131. /*:391*//*396:*/
  22132. #line 8817 "./typica.w"
  22133. constructor= engine->newFunction(constructMeasurementAdapter);
  22134. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  22135. constructor);
  22136. engine->globalObject().setProperty("MeasurementAdapter",value);
  22137. /*:396*//*413:*/
  22138. #line 9280 "./typica.w"
  22139. constructor= engine->newFunction(constructGraphView);
  22140. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  22141. engine->globalObject().setProperty("GraphView",value);
  22142. /*:413*//*436:*/
  22143. #line 9929 "./typica.w"
  22144. constructor= engine->newFunction(constructZoomLog);
  22145. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  22146. engine->globalObject().setProperty("ZoomLog",value);
  22147. /*:436*//*476:*/
  22148. #line 10932 "./typica.w"
  22149. constructor= engine->newFunction(constructAnnotationButton);
  22150. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  22151. constructor);
  22152. engine->globalObject().setProperty("AnnotationButton",value);
  22153. /*:476*//*484:*/
  22154. #line 11074 "./typica.w"
  22155. constructor= engine->newFunction(constructAnnotationSpinBox);
  22156. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  22157. constructor);
  22158. engine->globalObject().setProperty("AnnotationSpinBox",value);
  22159. /*:484*//*505:*/
  22160. #line 11499 "./typica.w"
  22161. constructor= engine->newFunction(constructTimerDisplay);
  22162. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  22163. engine->globalObject().setProperty("TimerDisplay",value);
  22164. /*:505*//*533:*/
  22165. #line 12023 "./typica.w"
  22166. constructor= engine->newFunction(constructWidgetDecorator);
  22167. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  22168. engine->globalObject().setProperty("WidgetDecorator",value);
  22169. /*:533*//*546:*/
  22170. #line 12305 "./typica.w"
  22171. constructor= engine->newFunction(constructLogEditWindow);
  22172. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  22173. engine->globalObject().setProperty("LogEditWindow",value);
  22174. /*:546*//*565:*/
  22175. #line 12832 "./typica.w"
  22176. constructor= engine->newFunction(constructXMLInput);
  22177. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  22178. engine->globalObject().setProperty("XMLInput",value);
  22179. /*:565*//*580:*/
  22180. #line 164 "./webview.w"
  22181. constructor= engine->newFunction(constructWebView);
  22182. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  22183. engine->globalObject().setProperty("WebView",value);
  22184. /*:580*//*588:*/
  22185. #line 261 "./webview.w"
  22186. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  22187. /*:588*//*591:*/
  22188. #line 303 "./webview.w"
  22189. constructor= engine->newFunction(constructWebElement);
  22190. engine->globalObject().setProperty("WebElement",constructor);
  22191. /*:591*//*603:*/
  22192. #line 76 "./printerselector.w"
  22193. constructor= engine->newFunction(constructPrinterSelector);
  22194. engine->globalObject().setProperty("PrinterSelector",constructor);
  22195. /*:603*//*611:*/
  22196. #line 13094 "./typica.w"
  22197. value= engine->newQObject(AppInstance);
  22198. value.setProperty("subscribe",engine->newFunction(Application_subscribe));
  22199. engine->globalObject().setProperty("Application",value);
  22200. /*:611*//*676:*/
  22201. #line 14337 "./typica.w"
  22202. constructor= engine->newFunction(constructSqlQueryView);
  22203. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  22204. engine->globalObject().setProperty("SqlQueryView",value);
  22205. /*:676*//*787:*/
  22206. #line 16250 "./typica.w"
  22207. constructor= engine->newFunction(constructDeviceTreeModel);
  22208. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  22209. constructor);
  22210. engine->globalObject().setProperty("DeviceTreeModel",value);
  22211. /*:787*//*793:*/
  22212. #line 16390 "./typica.w"
  22213. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  22214. /*:793*//*809:*/
  22215. #line 16682 "./typica.w"
  22216. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  22217. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  22218. constructor);
  22219. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  22220. /*:809*//*880:*/
  22221. #line 58 "./settings.w"
  22222. constructor= engine->newFunction(constructSettingsWindow);
  22223. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  22224. engine->globalObject().setProperty("SettingsWindow",value);
  22225. #line 1 "./graphsettings.w"
  22226. /*:880*//*907:*/
  22227. #line 19313 "./typica.w"
  22228. constructor= engine->newFunction(constructModbusRTUDevice);
  22229. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  22230. engine->globalObject().setProperty("ModbusRTUDevice",value);
  22231. /*:907*//*925:*/
  22232. #line 705 "./modbus.w"
  22233. constructor= engine->newFunction(constructModbusNG);
  22234. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  22235. engine->globalObject().setProperty("ModbusNG",value);
  22236. /*:925*//*939:*/
  22237. #line 353 "./unsupportedserial.w"
  22238. engine->globalObject().setProperty("createDevice",
  22239. engine->newFunction(createDevice));
  22240. /*:939*//*951:*/
  22241. #line 625 "./unsupportedserial.w"
  22242. engine->globalObject().setProperty("getMeasurementTimestamp",
  22243. engine->newFunction(getMeasurementTimestamp));
  22244. /*:951*//*955:*/
  22245. #line 661 "./unsupportedserial.w"
  22246. constructor= engine->newFunction(constructSerialPort);
  22247. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  22248. engine->globalObject().setProperty("SerialPort",value);
  22249. /*:955*//*977:*/
  22250. #line 450 "./phidgets.w"
  22251. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  22252. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  22253. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  22254. /*:977*//*1009:*/
  22255. #line 798 "./phidget22.w"
  22256. constructor= engine->newFunction(constructPhidget22);
  22257. value= engine->newQMetaObject(&Phidget22::staticMetaObject,constructor);
  22258. engine->globalObject().setProperty("Phidget22",value);
  22259. /*:1009*//*1043:*/
  22260. #line 144 "./rate.w"
  22261. constructor= engine->newFunction(constructRateOfChange);
  22262. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  22263. engine->globalObject().setProperty("RateOfChange",value);
  22264. /*:1043*//*1057:*/
  22265. #line 137 "./mergeseries.w"
  22266. constructor= engine->newFunction(constructDifferenceSeries);
  22267. value= engine->newQMetaObject(&DifferenceSeries::staticMetaObject,
  22268. constructor);
  22269. engine->globalObject().setProperty("DifferenceSeries",value);
  22270. constructor= engine->newFunction(constructMeanSeries);
  22271. value= engine->newQMetaObject(&MeanSeries::staticMetaObject,constructor);
  22272. engine->globalObject().setProperty("MeanSeries",value);
  22273. /*:1057*//*1082:*/
  22274. #line 604 "./dataqsdk.w"
  22275. constructor= engine->newFunction(constructDataqSdkDevice);
  22276. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  22277. engine->globalObject().setProperty("DataqSdkDevice",value);
  22278. /*:1082*//*1109:*/
  22279. #line 73 "./scales.w"
  22280. constructor= engine->newFunction(constructDragLabel);
  22281. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  22282. engine->globalObject().setProperty("DragLabel",value);
  22283. /*:1109*//*1117:*/
  22284. #line 265 "./scales.w"
  22285. constructor= engine->newFunction(constructSerialScale);
  22286. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  22287. engine->globalObject().setProperty("SerialScale",value);
  22288. /*:1117*//*1121:*/
  22289. #line 351 "./scales.w"
  22290. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  22291. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  22292. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  22293. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  22294. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  22295. /*:1121*//*1145:*/
  22296. #line 271 "./valueannotation.w"
  22297. constructor= engine->newFunction(constructValueAnnotation);
  22298. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  22299. engine->globalObject().setProperty("ValueAnnotation",value);
  22300. /*:1145*//*1156:*/
  22301. #line 201 "./thresholdannotation.w"
  22302. constructor= engine->newFunction(constructAnnotator);
  22303. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  22304. engine->globalObject().setProperty("Annotator",value);
  22305. /*:1156*//*1166:*/
  22306. #line 135 "./user.w"
  22307. constructor= engine->newFunction(constructLoginDialog);
  22308. value= engine->newQMetaObject(&LoginDialog::staticMetaObject,constructor);
  22309. engine->globalObject().setProperty("LoginDialog",value);
  22310. /*:1166*//*1176:*/
  22311. #line 323 "./user.w"
  22312. constructor= engine->newFunction(constructNewTypicaUser);
  22313. value= engine->newQMetaObject(&NewTypicaUser::staticMetaObject,constructor);
  22314. engine->globalObject().setProperty("NewTypicaUser",value);
  22315. /*:1176*/
  22316. #line 13936 "./typica.w"
  22317. app.engine= engine;
  22318. /*201:*/
  22319. #line 4604 "./typica.w"
  22320. QString styleText;
  22321. QString programText;
  22322. QDomElement currentElement;
  22323. for(int i= 0;i<children.size();i++)
  22324. {
  22325. QDomNode currentNode= children.at(i);
  22326. if(currentNode.nodeName()=="style")
  22327. {
  22328. currentElement= currentNode.toElement();
  22329. styleText.append(currentElement.text());
  22330. }
  22331. else if(currentNode.nodeName()=="program")
  22332. {
  22333. currentElement= currentNode.toElement();
  22334. programText.append(currentElement.text());
  22335. }
  22336. }
  22337. app.setStyleSheet(styleText);
  22338. QScriptValue result= engine->evaluate(programText);
  22339. /*202:*/
  22340. #line 4629 "./typica.w"
  22341. if(engine->hasUncaughtException())
  22342. {
  22343. int line= engine->uncaughtExceptionLineNumber();
  22344. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  22345. result.toString();
  22346. QString trace;
  22347. foreach(trace,engine->uncaughtExceptionBacktrace())
  22348. {
  22349. qDebug()<<trace;
  22350. }
  22351. }
  22352. /*:202*/
  22353. #line 4624 "./typica.w"
  22354. /*:201*/
  22355. #line 13938 "./typica.w"
  22356. int retval= app.exec();
  22357. delete engine;
  22358. return retval;
  22359. }
  22360. /*:653*/
  22361. #line 535 "./typica.w"
  22362. #include "moc_typica.cpp"
  22363. /*:3*/