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 482KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 616 "./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. /*:5*//*6:*/
  16. #line 631 "./typica.w"
  17. #include "helpmenu.h"
  18. /*:6*//*265:*/
  19. #line 6005 "./typica.w"
  20. #include "units.h"
  21. #line 1 "./measurement.w"
  22. /*:265*//*534:*/
  23. #line 197 "./webview.w"
  24. #include "webview.h"
  25. /*:534*//*547:*/
  26. #line 375 "./webview.w"
  27. #include "webelement.h"
  28. #line 11934 "./typica.w"
  29. /*:547*//*658:*/
  30. #line 478 "./daterangeselector.w"
  31. #include "daterangeselector.h"
  32. #line 13650 "./typica.w"
  33. /*:658*//*766:*/
  34. #line 16151 "./typica.w"
  35. #include "qextserialport.h"
  36. #include "qextserialenumerator.h"
  37. /*:766*//*920:*/
  38. #line 124 "./dataqsdk.w"
  39. #ifdef Q_OS_WIN32
  40. #include <windef.h>
  41. #else
  42. #define PASCAL
  43. #endif
  44. /*:920*//*944:*/
  45. #line 862 "./dataqsdk.w"
  46. #include <limits>
  47. /*:944*//*959:*/
  48. #line 62 "./scales.w"
  49. #include "draglabel.h"
  50. /*:959*//*974:*/
  51. #line 335 "./scales.w"
  52. #include "scale.h"
  53. /*:974*/
  54. #line 525 "./typica.w"
  55. /*20:*/
  56. #line 946 "./typica.w"
  57. class ScriptQMainWindow:public QMainWindow
  58. {
  59. Q_OBJECT
  60. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  61. public:
  62. ScriptQMainWindow();
  63. QString closePrompt();
  64. public slots:
  65. void show();
  66. void saveSizeAndPosition(const QString&key);
  67. void restoreSizeAndPosition(const QString&key);
  68. void displayStatus(const QString&message= QString());
  69. void setClosePrompt(QString prompt);
  70. protected:
  71. void closeEvent(QCloseEvent*event);
  72. void showEvent(QShowEvent*event);
  73. signals:
  74. void aboutToClose(void);
  75. private:
  76. QString cprompt;
  77. };
  78. /*:20*//*148:*/
  79. #line 3435 "./typica.w"
  80. class SqlQueryConnection:public QSqlQuery
  81. {
  82. public:
  83. SqlQueryConnection(const QString&query= QString());
  84. ~SqlQueryConnection();
  85. QSqlQuery*operator->()const;
  86. private:
  87. QString connection;
  88. QSqlQuery*q;
  89. };
  90. /*:148*//*219:*/
  91. #line 5284 "./typica.w"
  92. class NumericDelegate:public QItemDelegate
  93. {
  94. Q_OBJECT
  95. public:
  96. NumericDelegate(QObject*parent= NULL);
  97. QWidget*createEditor(QWidget*parent,
  98. const QStyleOptionViewItem&option,
  99. const QModelIndex&index)const;
  100. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  101. void setModelData(QWidget*editor,QAbstractItemModel*model,
  102. const QModelIndex&index)const;
  103. void updateEditorGeometry(QWidget*editor,
  104. const QStyleOptionViewItem&option,
  105. const QModelIndex&index)const;
  106. };
  107. /*:219*//*261:*/
  108. #line 425 "./units.w"
  109. Q_DECLARE_METATYPE(Units::Unit)
  110. /*:261*//*266:*/
  111. #line 19 "./measurement.w"
  112. class Measurement:public QVariantMap
  113. {
  114. public:
  115. Measurement(double temperature= 0,QTime time= QTime(),
  116. Units::Unit sc= Units::Fahrenheit);
  117. Measurement(double temperature);
  118. double temperature()const;
  119. QTime time()const;
  120. void setTemperature(double temperature);
  121. void setTime(QTime time);
  122. void setUnit(Units::Unit scale);
  123. Units::Unit scale()const;
  124. Measurement toFahrenheit();
  125. Measurement toCelsius();
  126. Measurement toKelvin();
  127. Measurement toRankine();
  128. };
  129. /*:266*//*270:*/
  130. #line 128 "./measurement.w"
  131. Q_DECLARE_METATYPE(Measurement)
  132. /*:270*//*277:*/
  133. #line 6069 "./typica.w"
  134. class Channel;
  135. class DAQImplementation;
  136. class DAQ:public QObject
  137. {
  138. Q_OBJECT
  139. Q_ENUMS(ThermocoupleType)
  140. DAQImplementation*imp;
  141. private slots:
  142. void threadFinished();
  143. public:
  144. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  145. ~DAQ();
  146. Channel*newChannel(int units,int thermocouple);
  147. Q_INVOKABLE void setClockRate(double Hz);
  148. Q_INVOKABLE void start();
  149. Q_INVOKABLE void stop();
  150. enum ThermocoupleType
  151. {
  152. TypeJ= 10072,
  153. TypeK= 10073,
  154. TypeN= 10077,
  155. TypeR= 10082,
  156. TypeS= 10085,
  157. TypeT= 10086,
  158. TypeB= 10047,
  159. TypeE= 10055
  160. };
  161. };
  162. /*:277*//*278:*/
  163. #line 6107 "./typica.w"
  164. class DAQImplementation:public QThread
  165. {
  166. Q_OBJECT
  167. public:
  168. DAQImplementation(const QString&driverinfo);
  169. ~DAQImplementation();
  170. void run();
  171. void measure();
  172. /*279:*/
  173. #line 6127 "./typica.w"
  174. typedef int(*daqfp)(...);
  175. daqfp read;
  176. daqfp errorInfo;
  177. daqfp startTask;
  178. daqfp createTask;
  179. daqfp createChannel;
  180. daqfp setClock;
  181. daqfp stopTask;
  182. daqfp clearTask;
  183. daqfp resetDevice;
  184. daqfp waitForMeasurement;
  185. /*:279*/
  186. #line 6116 "./typica.w"
  187. /*280:*/
  188. #line 6143 "./typica.w"
  189. bool useBase;
  190. QString device;
  191. QVector<Channel*> channelMap;
  192. unsigned int handle;
  193. int error;
  194. int channels;
  195. bool ready;
  196. QLibrary driver;
  197. QVector<Units::Unit> unitMap;
  198. /*:280*/
  199. #line 6117 "./typica.w"
  200. };
  201. /*:278*//*296:*/
  202. #line 6647 "./typica.w"
  203. class FakeDAQImplementation:public QThread
  204. {
  205. Q_OBJECT
  206. public:
  207. FakeDAQImplementation();
  208. ~FakeDAQImplementation();
  209. void run();
  210. void measure();
  211. QVector<Channel*> channelMap;
  212. int channels;
  213. bool ready;
  214. double clockRate;
  215. };
  216. class FakeDAQ:public QObject
  217. {
  218. Q_OBJECT
  219. FakeDAQImplementation*imp;
  220. public:
  221. FakeDAQ(QString device);
  222. ~FakeDAQ();
  223. Channel*newChannel(int units,int thermocouple);
  224. Q_INVOKABLE void setClockRate(double Hz);
  225. Q_INVOKABLE void start();
  226. };
  227. /*:296*//*303:*/
  228. #line 6834 "./typica.w"
  229. class Channel:public QObject
  230. {
  231. Q_OBJECT
  232. public:
  233. Channel();
  234. ~Channel();
  235. public slots:
  236. void input(Measurement measurement);
  237. signals:
  238. void newData(Measurement);
  239. };
  240. /*:303*//*307:*/
  241. #line 6901 "./typica.w"
  242. class LinearCalibrator:public QObject
  243. {
  244. Q_OBJECT
  245. Q_PROPERTY(double measuredLower READ measuredLower
  246. WRITE setMeasuredLower)
  247. Q_PROPERTY(double measuredUpper READ measuredUpper
  248. WRITE setMeasuredUpper)
  249. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  250. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  251. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  252. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  253. public:
  254. LinearCalibrator(QObject*parent= NULL);
  255. double measuredLower();
  256. double measuredUpper();
  257. double mappedLower();
  258. double mappedUpper();
  259. bool isClosedRange();
  260. double sensitivity();
  261. public slots:
  262. void setMeasuredLower(double lower);
  263. void setMeasuredUpper(double upper);
  264. void setMappedLower(double lower);
  265. void setMappedUpper(double upper);
  266. void setClosedRange(bool closed);
  267. void setSensitivity(double sensitivity);
  268. Measurement newMeasurement(Measurement measure);
  269. signals:
  270. void measurement(Measurement measure);
  271. void newData(Measurement measure);
  272. private:
  273. double Lo1;
  274. double Lo2;
  275. double Up1;
  276. double Up2;
  277. double sensitivitySetting;
  278. bool clamp;
  279. };
  280. /*:307*//*314:*/
  281. #line 7097 "./typica.w"
  282. class LinearSplineInterpolator:public QObject
  283. {
  284. Q_OBJECT
  285. public:
  286. LinearSplineInterpolator(QObject*parent= NULL);
  287. Q_INVOKABLE void add_pair(double source,double destination);
  288. public slots:
  289. Measurement newMeasurement(Measurement measure);
  290. signals:
  291. void newData(Measurement measure);
  292. private:
  293. void make_interpolators();
  294. QMap<double,double> *pairs;
  295. QList<LinearCalibrator*> *interpolators;
  296. };
  297. /*:314*//*319:*/
  298. #line 7233 "./typica.w"
  299. class TemperatureDisplay:public QLCDNumber
  300. {
  301. Q_OBJECT
  302. int unit;
  303. bool r;
  304. public:
  305. TemperatureDisplay(QWidget*parent= NULL);
  306. ~TemperatureDisplay();
  307. public slots:
  308. void setValue(Measurement temperature);
  309. void invalidate();
  310. void setDisplayUnits(Units::Unit scale);
  311. void setRelativeMode(bool relative);
  312. };
  313. /*:319*//*330:*/
  314. #line 7449 "./typica.w"
  315. class MeasurementTimeOffset:public QObject
  316. {
  317. Q_OBJECT
  318. QTime epoch;
  319. QTime previous;
  320. bool hasPrevious;
  321. public:
  322. MeasurementTimeOffset(QTime zero);
  323. QTime zeroTime();
  324. public slots:
  325. void newMeasurement(Measurement measure);
  326. void setZeroTime(QTime zero);
  327. signals:
  328. void measurement(Measurement measure);
  329. };
  330. /*:330*//*337:*/
  331. #line 7601 "./typica.w"
  332. class ThresholdDetector:public QObject
  333. {
  334. Q_OBJECT
  335. Q_ENUMS(EdgeDirection)
  336. public:
  337. enum EdgeDirection{
  338. Ascending,Descending
  339. };
  340. ThresholdDetector(double value);
  341. public slots:
  342. void newMeasurement(Measurement measure);
  343. void setThreshold(double value);
  344. void setEdgeDirection(EdgeDirection direction);
  345. signals:
  346. void timeForValue(double);
  347. private:
  348. double previousValue;
  349. double threshold;
  350. EdgeDirection currentDirection;
  351. };
  352. /*:337*//*342:*/
  353. #line 7707 "./typica.w"
  354. class ZeroEmitter:public QObject
  355. {
  356. Q_OBJECT
  357. Q_PROPERTY(int column READ column WRITE setColumn)
  358. Measurement cache;
  359. int col;
  360. public:
  361. ZeroEmitter(int tempcolumn= 1);
  362. int column();
  363. double lastTemperature();
  364. public slots:
  365. void newMeasurement(Measurement measure);
  366. void setColumn(int column);
  367. void emitZero();
  368. signals:
  369. void measurement(Measurement measure,int tempcolumn);
  370. };
  371. /*:342*//*347:*/
  372. #line 7801 "./typica.w"
  373. class MeasurementAdapter:public QObject
  374. {
  375. Q_OBJECT
  376. int col;
  377. public:
  378. MeasurementAdapter(int tempcolumn);
  379. int column();
  380. public slots:
  381. void newMeasurement(Measurement measure);
  382. void setColumn(int column);
  383. signals:
  384. void measurement(Measurement measure,int tempcolumn);
  385. };
  386. /*:347*//*352:*/
  387. #line 7890 "./typica.w"
  388. class GraphView:public QGraphicsView
  389. {
  390. Q_OBJECT
  391. QGraphicsScene*theScene;
  392. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  393. QMap<int,QPointF> *prevPoints;
  394. QMap<int,double> *translations;
  395. QList<QGraphicsItem*> *gridLinesF;
  396. QList<QGraphicsItem*> *gridLinesC;
  397. QList<QGraphicsItem*> *relativeGridLines;
  398. bool relativeEnabled;
  399. bool timeIndicatorEnabled;
  400. QGraphicsLineItem*timeLine;
  401. LinearSplineInterpolator*relativeAdjuster;
  402. public:
  403. GraphView(QWidget*parent= NULL);
  404. void removeSeries(int column);
  405. protected:
  406. void resizeEvent(QResizeEvent*event);
  407. public slots:
  408. void newMeasurement(Measurement measure,int tempcolumn);
  409. void setSeriesTranslation(int column,double offset);
  410. void setTimeIndicatorEnabled(bool enabled);
  411. void clear();
  412. void showF();
  413. void showC();
  414. };
  415. /*:352*//*369:*/
  416. #line 8355 "./typica.w"
  417. class MeasurementModel;
  418. class ZoomLog:public QTableView
  419. {
  420. Q_OBJECT
  421. /*370:*/
  422. #line 8404 "./typica.w"
  423. MeasurementModel*model_ms;
  424. MeasurementModel*model_1s;
  425. MeasurementModel*model_5s;
  426. MeasurementModel*model_10s;
  427. MeasurementModel*model_15s;
  428. MeasurementModel*model_30s;
  429. MeasurementModel*model_1m;
  430. QList<MeasurementModel*> modelSet;
  431. QHash<int,Measurement> lastMeasurement;
  432. MeasurementModel*currentModel;
  433. QList<int> saveTempCols;
  434. QList<int> saveControlCols;
  435. QList<int> saveNoteCols;
  436. QList<int> currentColumnSet;
  437. /*:370*/
  438. #line 8360 "./typica.w"
  439. void switchLOD(MeasurementModel*m);
  440. private slots:
  441. void centerOn(int row);
  442. void persistColumnResize(int column,int oldsize,int newsize);
  443. void restoreColumnWidths();
  444. public:
  445. ZoomLog();
  446. QVariant data(int row,int column)const;
  447. int rowCount();
  448. bool saveXML(QIODevice*device);
  449. bool saveCSV(QIODevice*device);
  450. QString lastTime(int series);
  451. Q_INVOKABLE Units::Unit displayUnits();
  452. public slots:
  453. void setVisible(bool visibility);
  454. void setHeaderData(int section,QString text);
  455. void LOD_ms();
  456. void LOD_1s();
  457. void LOD_5s();
  458. void LOD_10s();
  459. void LOD_15s();
  460. void LOD_30s();
  461. void LOD_1m();
  462. void newMeasurement(Measurement measure,int tempcolumn);
  463. void newAnnotation(QString annotation,int tempcolumn,
  464. int annotationcolumn);
  465. void clear();
  466. void addOutputTemperatureColumn(int column);
  467. void addOutputControlColumn(int column);
  468. void addOutputAnnotationColumn(int column);
  469. void clearOutputColumns();
  470. void setDisplayUnits(Units::Unit scale);
  471. void addToCurrentColumnSet(int column);
  472. void clearCurrentColumnSet();
  473. protected:
  474. virtual void showEvent(QShowEvent*event);
  475. };
  476. /*:369*//*395:*/
  477. #line 9100 "./typica.w"
  478. class MeasurementList;
  479. class MeasurementModel:public QAbstractItemModel
  480. {
  481. Q_OBJECT
  482. Units::Unit unit;
  483. QList<MeasurementList*> *entries;
  484. QStringList*hData;
  485. int colcount;
  486. QHash<int,int> *lastTemperature;
  487. QList<MeasurementList*> ::iterator lastInsertion;
  488. QHash<int,bool> *controlColumns;
  489. public:
  490. MeasurementModel(QObject*parent= NULL);
  491. ~MeasurementModel();
  492. int rowCount(const QModelIndex&parent= QModelIndex())const;
  493. int columnCount(const QModelIndex&parent= QModelIndex())const;
  494. bool setHeaderData(int section,Qt::Orientation orientation,
  495. const QVariant&value,int role= Qt::DisplayRole);
  496. QVariant data(const QModelIndex&index,int role)const;
  497. bool setData(const QModelIndex&index,const QVariant&value,
  498. int role= Qt::EditRole);
  499. Qt::ItemFlags flags(const QModelIndex&index)const;
  500. QVariant headerData(int section,Qt::Orientation orientation,
  501. int role= Qt::DisplayRole)const;
  502. QModelIndex index(int row,int column,
  503. const QModelIndex&parent= QModelIndex())const;
  504. QModelIndex parent(const QModelIndex&index)const;
  505. Units::Unit displayUnits();
  506. public slots:
  507. void newMeasurement(Measurement measure,int tempcolumn);
  508. void newAnnotation(QString annotation,int tempcolumn,
  509. int annotationColumn);
  510. void clear();
  511. void setDisplayUnits(Units::Unit scale);
  512. signals:
  513. void rowChanged(int);
  514. };
  515. /*:395*//*396:*/
  516. #line 9144 "./typica.w"
  517. class MeasurementList:public QVariantList
  518. {
  519. public:
  520. bool operator<(const MeasurementList&other)const;
  521. bool operator==(const MeasurementList&other)const;
  522. };
  523. /*:396*//*422:*/
  524. #line 9802 "./typica.w"
  525. class AnnotationButton:public QPushButton
  526. {
  527. Q_OBJECT
  528. QString note;
  529. int tc;
  530. int ac;
  531. int count;
  532. public:
  533. AnnotationButton(const QString&text,QWidget*parent= NULL);
  534. public slots:
  535. void setAnnotation(const QString&annotation);
  536. void setTemperatureColumn(int tempcolumn);
  537. void setAnnotationColumn(int annotationcolumn);
  538. void annotate();
  539. void resetCount();
  540. signals:
  541. void annotation(QString annotation,int tempcolumn,
  542. int notecolumn);
  543. };
  544. /*:422*//*430:*/
  545. #line 9927 "./typica.w"
  546. class AnnotationSpinBox:public QDoubleSpinBox
  547. {
  548. Q_OBJECT
  549. QString pretext;
  550. QString posttext;
  551. int tc;
  552. int ac;
  553. bool change;
  554. public:
  555. AnnotationSpinBox(const QString&pret,const QString&postt,
  556. QWidget*parent= NULL);
  557. public slots:
  558. void setPretext(const QString&pret);
  559. void setPosttext(const QString&postt);
  560. void setTemperatureColumn(int tempcolumn);
  561. void setAnnotationColumn(int annotationcolumn);
  562. void annotate();
  563. void resetChange();
  564. signals:
  565. void annotation(QString annotation,int tempcolumn,
  566. int notecolumn);
  567. };
  568. /*:430*//*438:*/
  569. #line 10086 "./typica.w"
  570. class TimerDisplay:public QLCDNumber
  571. {
  572. Q_OBJECT
  573. /*439:*/
  574. #line 10136 "./typica.w"
  575. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  576. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  577. Q_PROPERTY(bool running READ isRunning)
  578. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  579. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  580. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  581. /*:439*/
  582. #line 10090 "./typica.w"
  583. private slots:
  584. void updateTime();
  585. void setCountUpMode();
  586. void setCountDownMode();
  587. void setClockMode();
  588. public:
  589. TimerDisplay(QWidget*parent= NULL);
  590. ~TimerDisplay();
  591. enum TimerMode
  592. {
  593. CountUp,
  594. CountDown,
  595. Clock
  596. };
  597. QString value();
  598. QTime seconds();
  599. TimerMode mode();
  600. bool isRunning();
  601. QTime resetValue();
  602. QString displayFormat();
  603. bool autoReset();
  604. public slots:
  605. void setTimer(QTime value= QTime(0,0,0));
  606. void setMode(TimerMode mode);
  607. void startTimer();
  608. void stopTimer();
  609. void copyTimer();
  610. void setResetValue(QTime value= QTime(0,0,0));
  611. void reset();
  612. void setDisplayFormat(QString format);
  613. void setAutoReset(bool reset);
  614. void updateDisplay();
  615. signals:
  616. void valueChanged(QTime);
  617. void runStateChanged(bool);
  618. private:
  619. /*440:*/
  620. #line 10146 "./typica.w"
  621. QTime s;
  622. QTime r;
  623. QTimer clock;
  624. TimerDisplay::TimerMode m;
  625. bool running;
  626. bool ar;
  627. QAction*startAction;
  628. QAction*stopAction;
  629. QAction*resetAction;
  630. QString f;
  631. QTime relative;
  632. QTime base;
  633. /*:440*/
  634. #line 10127 "./typica.w"
  635. };
  636. /*:438*//*460:*/
  637. #line 10505 "./typica.w"
  638. class PackLayout:public QLayout
  639. {
  640. int doLayout(const QRect&rect,bool testOnly)const;
  641. QList<QLayoutItem*> itemList;
  642. Qt::Orientations orientation;
  643. public:
  644. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  645. PackLayout(int spacing= -1);
  646. ~PackLayout();
  647. void addItem(QLayoutItem*item);
  648. Qt::Orientations expandingDirections()const;
  649. bool hasHeightForWidth()const;
  650. int heightForWidth(int width)const;
  651. int count()const;
  652. QLayoutItem*itemAt(int index)const;
  653. QSize minimumSize()const;
  654. void setGeometry(const QRect&rect);
  655. void setOrientation(Qt::Orientations direction);
  656. QSize sizeHint()const;
  657. QLayoutItem*takeAt(int index);
  658. };
  659. /*:460*//*473:*/
  660. #line 10783 "./typica.w"
  661. class SceneButton:public QGraphicsScene
  662. {
  663. Q_OBJECT
  664. public:
  665. SceneButton();
  666. ~SceneButton();
  667. protected:
  668. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  669. signals:
  670. void clicked(QPoint pos);
  671. };
  672. /*:473*//*475:*/
  673. #line 10825 "./typica.w"
  674. class WidgetDecorator:public QWidget
  675. {
  676. Q_OBJECT
  677. PackLayout*layout;
  678. QGraphicsView*label;
  679. QGraphicsTextItem*text;
  680. SceneButton*scene;
  681. public:
  682. WidgetDecorator(QWidget*widget,const QString&labeltext,
  683. Qt::Orientations orientation= Qt::Horizontal,
  684. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  685. ~WidgetDecorator();
  686. void setBackgroundBrush(QBrush background);
  687. void setTextColor(QColor color);
  688. };
  689. /*:475*//*486:*/
  690. #line 11000 "./typica.w"
  691. class LogEditWindow:public QMainWindow
  692. {
  693. Q_OBJECT
  694. QWidget*centralWidget;
  695. PackLayout*mainLayout;
  696. QHBoxLayout*addRowsLayout;
  697. QLabel*startTimeLabel;
  698. QTimeEdit*startTime;
  699. QLabel*endTimeLabel;
  700. QTimeEdit*endTime;
  701. QLabel*intervalLabel;
  702. QSpinBox*interval;
  703. QPushButton*addRows;
  704. QAction*saveXml;
  705. QAction*saveCsv;
  706. QAction*openXml;
  707. MeasurementModel*model;
  708. QTableView*log;
  709. private slots:
  710. void addTheRows();
  711. void saveXML();
  712. void saveCSV();
  713. void openXML();
  714. protected:
  715. void closeEvent(QCloseEvent*event);
  716. public:
  717. LogEditWindow();
  718. };
  719. /*:486*//*500:*/
  720. #line 11308 "./typica.w"
  721. class XMLOutput:public QObject
  722. {
  723. Q_OBJECT
  724. MeasurementModel*data;
  725. QIODevice*out;
  726. int time;
  727. QMap<int,QString> temperatureColumns;
  728. QMap<int,QString> controlColumns;
  729. QMap<int,QString> annotationColumns;
  730. public:
  731. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  732. void addTemperatureColumn(const QString&series,int column);
  733. void addControlColumn(const QString&series,int column);
  734. void addAnnotationColumn(const QString&series,int column);
  735. void setModel(MeasurementModel*model);
  736. void setTimeColumn(int column);
  737. void setDevice(QIODevice*device);
  738. bool output();
  739. };
  740. /*:500*//*507:*/
  741. #line 11544 "./typica.w"
  742. class XMLInput:public QObject
  743. {
  744. Q_OBJECT
  745. int firstc;
  746. QIODevice*in;
  747. public:
  748. XMLInput(QIODevice*input,int c);
  749. void setFirstColumn(int column);
  750. void setDevice(QIODevice*device);
  751. bool input();
  752. signals:
  753. void measure(Measurement,int);
  754. void annotation(QString,int,int);
  755. void newTemperatureColumn(int,QString);
  756. void newAnnotationColumn(int,QString);
  757. void lastColumn(int);
  758. };
  759. /*:507*//*518:*/
  760. #line 11799 "./typica.w"
  761. class CSVOutput
  762. {
  763. MeasurementModel*data;
  764. QIODevice*out;
  765. int time;
  766. QMap<int,QString> temperatureColumns;
  767. QMap<int,QString> controlColumns;
  768. QMap<int,QString> annotationColumns;
  769. public:
  770. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  771. void addTemperatureColumn(const QString&series,int column);
  772. void addControlColumn(const QString&series,int column);
  773. void addAnnotationColumn(const QString&series,int column);
  774. void setModel(MeasurementModel*model);
  775. void setTimeColumn(int column);
  776. void setDevice(QIODevice*device);
  777. bool output();
  778. };
  779. /*:518*//*548:*/
  780. #line 11942 "./typica.w"
  781. #define AppInstance (qobject_cast<Application *> (qApp))
  782. class NodeInserter;
  783. class DeviceTreeModel;
  784. class Application:public QApplication
  785. {
  786. Q_OBJECT
  787. public:
  788. Application(int&argc,char**argv);
  789. QDomDocument*configuration();
  790. /*690:*/
  791. #line 14496 "./typica.w"
  792. QDomDocument deviceConfiguration();
  793. /*:690*//*723:*/
  794. #line 15169 "./typica.w"
  795. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  796. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  797. const QModelIndex&index);
  798. /*:723*//*728:*/
  799. #line 15273 "./typica.w"
  800. QList<NodeInserter*> topLevelNodeInserters;
  801. /*:728*/
  802. #line 11953 "./typica.w"
  803. QSqlDatabase database();
  804. QScriptEngine*engine;
  805. public slots:
  806. /*691:*/
  807. #line 14503 "./typica.w"
  808. void saveDeviceConfiguration();
  809. /*:691*/
  810. #line 11957 "./typica.w"
  811. private:
  812. /*689:*/
  813. #line 14487 "./typica.w"
  814. QDomDocument deviceConfigurationDocument;
  815. /*:689*//*722:*/
  816. #line 15163 "./typica.w"
  817. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  818. /*:722*/
  819. #line 11959 "./typica.w"
  820. QDomDocument conf;
  821. };
  822. /*:548*//*556:*/
  823. #line 12084 "./typica.w"
  824. class SaltModel:public QAbstractItemModel
  825. {
  826. Q_OBJECT
  827. QList<QList<QMap<int,QVariant> > > modelData;
  828. QStringList hData;
  829. int colcount;
  830. public:
  831. SaltModel(int columns);
  832. ~SaltModel();
  833. int rowCount(const QModelIndex&parent= QModelIndex())const;
  834. int columnCount(const QModelIndex&parent= QModelIndex())const;
  835. bool setHeaderData(int section,Qt::Orientation orientation,
  836. const QVariant&value,int role= Qt::DisplayRole);
  837. QVariant data(const QModelIndex&index,int role)const;
  838. bool setData(const QModelIndex&index,const QVariant&value,
  839. int role= Qt::EditRole);
  840. Qt::ItemFlags flags(const QModelIndex&index)const;
  841. QVariant headerData(int section,Qt::Orientation orientation,
  842. int role= Qt::DisplayRole)const;
  843. QModelIndex index(int row,int column,
  844. const QModelIndex&parent= QModelIndex())const;
  845. QModelIndex parent(const QModelIndex&index)const;
  846. QString arrayLiteral(int column,int role)const;
  847. QString quotedArrayLiteral(int column,int role)const;
  848. void clear();
  849. bool removeRows(int row,int count,
  850. const QModelIndex&parent= QModelIndex());
  851. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  852. };
  853. /*:556*//*572:*/
  854. #line 12469 "./typica.w"
  855. class SqlComboBox:public QComboBox
  856. {
  857. Q_OBJECT
  858. int dataColumn;
  859. int displayColumn;
  860. bool dataColumnShown;
  861. QString specialNullText;
  862. QVariant specialNullData;
  863. public:
  864. SqlComboBox();
  865. ~SqlComboBox();
  866. SqlComboBox*clone(QWidget*parent);
  867. public slots:
  868. void addNullOption();
  869. void addSqlOptions(QString query);
  870. void setDataColumn(int column);
  871. void setDisplayColumn(int column);
  872. void showData(bool show);
  873. void setNullText(QString nullText);
  874. void setNullData(QVariant nullData);
  875. };
  876. /*:572*//*579:*/
  877. #line 12616 "./typica.w"
  878. class SqlComboBoxDelegate:public QItemDelegate
  879. {
  880. Q_OBJECT
  881. SqlComboBox*delegate;
  882. public:
  883. SqlComboBoxDelegate(QObject*parent= NULL);
  884. QWidget*createEditor(QWidget*parent,
  885. const QStyleOptionViewItem&option,
  886. const QModelIndex&index)const;
  887. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  888. void setModelData(QWidget*editor,QAbstractItemModel*model,
  889. const QModelIndex&index)const;
  890. void setWidget(SqlComboBox*widget);
  891. virtual QSize sizeHint()const;
  892. void updateEditorGeometry(QWidget*editor,
  893. const QStyleOptionViewItem&option,
  894. const QModelIndex&index)const;
  895. };
  896. /*:579*//*594:*/
  897. #line 12827 "./typica.w"
  898. class SqlConnectionSetup:public QDialog
  899. {
  900. Q_OBJECT
  901. public:
  902. SqlConnectionSetup();
  903. ~SqlConnectionSetup();
  904. public slots:
  905. void testConnection();
  906. private:
  907. QFormLayout*formLayout;
  908. QComboBox*driver;
  909. QLineEdit*hostname;
  910. QLineEdit*dbname;
  911. QLineEdit*user;
  912. QLineEdit*password;
  913. QVBoxLayout*layout;
  914. QHBoxLayout*buttons;
  915. QPushButton*cancelButton;
  916. QPushButton*connectButton;
  917. };
  918. /*:594*//*599:*/
  919. #line 12962 "./typica.w"
  920. class SqlQueryView:public QTableView
  921. {
  922. Q_OBJECT
  923. public:
  924. SqlQueryView(QWidget*parent= NULL);
  925. void setQuery(const QString&query);
  926. bool setHeaderData(int section,Qt::Orientation orientation,
  927. const QVariant&value,int role);
  928. Q_INVOKABLE QVariant data(int row,int column,
  929. int role= Qt::DisplayRole);
  930. signals:
  931. void openEntry(QString key);
  932. void openEntryRow(int row);
  933. protected:
  934. virtual void showEvent(QShowEvent*event);
  935. private slots:
  936. void openRow(const QModelIndex&index);
  937. void persistColumnResize(int column,int oldsize,int newsize);
  938. };
  939. /*:599*//*614:*/
  940. #line 13217 "./typica.w"
  941. class ReportAction:public QAction
  942. {
  943. Q_OBJECT
  944. public:
  945. ReportAction(const QString&fileName,const QString&reportName,
  946. QObject*parent= NULL);
  947. private slots:
  948. void createReport();
  949. private:
  950. QString reportFile;
  951. };
  952. /*:614*//*626:*/
  953. #line 13426 "./typica.w"
  954. class ReportTable:public QObject
  955. {
  956. Q_OBJECT
  957. QTextFrame*area;
  958. QDomElement configuration;
  959. QMap<QString,QVariant> bindings;
  960. public:
  961. ReportTable(QTextFrame*frame,QDomElement description);
  962. ~ReportTable();
  963. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  964. public slots:
  965. void refresh();
  966. };
  967. /*:626*//*659:*/
  968. #line 13665 "./typica.w"
  969. class FormArray:public QScrollArea
  970. {
  971. Q_OBJECT
  972. QDomElement configuration;
  973. QWidget itemContainer;
  974. QVBoxLayout itemLayout;
  975. int maxwidth;
  976. int maxheight;
  977. public:
  978. FormArray(QDomElement description);
  979. Q_INVOKABLE QWidget*elementAt(int index);
  980. Q_INVOKABLE int elements();
  981. public slots:
  982. void addElements(int copies= 1);
  983. void removeAllElements();
  984. void setMaximumElementWidth(int width);
  985. void setMaximumElementHeight(int height);
  986. };
  987. /*:659*//*669:*/
  988. #line 13881 "./typica.w"
  989. class ScaleControl:public QGraphicsView
  990. {
  991. Q_OBJECT
  992. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  993. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  994. /*670:*/
  995. #line 13907 "./typica.w"
  996. QGraphicsScene scene;
  997. QGraphicsPolygonItem initialDecrement;
  998. QGraphicsPolygonItem initialIncrement;
  999. QGraphicsPolygonItem finalDecrement;
  1000. QGraphicsPolygonItem finalIncrement;
  1001. QGraphicsPolygonItem initialIndicator;
  1002. QGraphicsPolygonItem finalIndicator;
  1003. QGraphicsPathItem scaleLine;
  1004. QPolygonF left;
  1005. QPolygonF right;
  1006. QPolygonF down;
  1007. QPolygonF up;
  1008. QPainterPath scalePath;
  1009. QBrush initialBrush;
  1010. QBrush finalBrush;
  1011. double nonScoredValue;
  1012. double scoredValue;
  1013. bool initialSet;
  1014. bool finalSet;
  1015. bool scaleDown;
  1016. /*:670*/
  1017. #line 13887 "./typica.w"
  1018. public:
  1019. ScaleControl();
  1020. double initialValue(void);
  1021. double finalValue(void);
  1022. virtual QSize sizeHint()const;
  1023. public slots:
  1024. void setInitialValue(double value);
  1025. void setFinalValue(double value);
  1026. signals:
  1027. void initialChanged(double);
  1028. void finalChanged(double);
  1029. protected:
  1030. virtual void mousePressEvent(QMouseEvent*event);
  1031. virtual void mouseReleaseEvent(QMouseEvent*event);
  1032. };
  1033. /*:669*//*681:*/
  1034. #line 14204 "./typica.w"
  1035. class IntensityControl:public QGraphicsView
  1036. {
  1037. Q_OBJECT
  1038. Q_PROPERTY(double value READ value WRITE setValue)
  1039. QGraphicsScene scene;
  1040. QGraphicsPolygonItem decrement;
  1041. QGraphicsPolygonItem increment;
  1042. QGraphicsPolygonItem indicator;
  1043. QGraphicsPathItem scaleLine;
  1044. QPolygonF left;
  1045. QPolygonF up;
  1046. QPolygonF down;
  1047. QPainterPath scalePath;
  1048. QBrush theBrush;
  1049. double theValue;
  1050. bool valueSet;
  1051. bool scaleDown;
  1052. public:
  1053. IntensityControl();
  1054. double value();
  1055. virtual QSize sizeHint()const;
  1056. public slots:
  1057. void setValue(double val);
  1058. signals:
  1059. void valueChanged(double);
  1060. protected:
  1061. virtual void mousePressEvent(QMouseEvent*event);
  1062. virtual void mouseReleaseEvent(QMouseEvent*event);
  1063. };
  1064. /*:681*//*697:*/
  1065. #line 14592 "./typica.w"
  1066. class DeviceTreeModelNode
  1067. {
  1068. public:
  1069. DeviceTreeModelNode(QDomNode&node,int row,
  1070. DeviceTreeModelNode*parent= NULL);
  1071. ~DeviceTreeModelNode();
  1072. DeviceTreeModelNode*child(int index);
  1073. DeviceTreeModelNode*parent();
  1074. QDomNode node()const;
  1075. int row();
  1076. private:
  1077. QDomNode domNode;
  1078. QHash<int,DeviceTreeModelNode*> children;
  1079. int rowNumber;
  1080. DeviceTreeModelNode*parentItem;
  1081. };
  1082. /*:697*//*699:*/
  1083. #line 14667 "./typica.w"
  1084. class DeviceTreeModel:public QAbstractItemModel
  1085. {
  1086. Q_OBJECT
  1087. public:
  1088. DeviceTreeModel(QObject*parent= NULL);
  1089. ~DeviceTreeModel();
  1090. QVariant data(const QModelIndex&index,int role)const;
  1091. Qt::ItemFlags flags(const QModelIndex&index)const;
  1092. QVariant headerData(int section,Qt::Orientation orientation,
  1093. int role= Qt::DisplayRole)const;
  1094. QModelIndex index(int row,int column,
  1095. const QModelIndex&parent= QModelIndex())const;
  1096. QModelIndex parent(const QModelIndex&child)const;
  1097. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1098. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1099. bool setData(const QModelIndex&index,const QVariant&value,
  1100. int role);
  1101. bool removeRows(int row,int count,const QModelIndex&parent);
  1102. QDomElement referenceElement(const QString&id);
  1103. public slots:
  1104. void newNode(const QString&name,const QString&driver,
  1105. const QModelIndex&parent);
  1106. private:
  1107. QDomDocument document;
  1108. DeviceTreeModelNode*root;
  1109. QDomNode referenceSection;
  1110. QDomNode treeRoot;
  1111. };
  1112. /*:699*//*718:*/
  1113. #line 15121 "./typica.w"
  1114. Q_DECLARE_METATYPE(QModelIndex)
  1115. /*:718*//*726:*/
  1116. #line 15228 "./typica.w"
  1117. class NodeInserter:public QAction
  1118. {
  1119. Q_OBJECT
  1120. public:
  1121. NodeInserter(const QString&title,const QString&name,
  1122. const QString&driver,QObject*parent= NULL);
  1123. signals:
  1124. void triggered(QString name,QString driver);
  1125. private slots:
  1126. void onTriggered();
  1127. private:
  1128. QString defaultNodeName;
  1129. QString driverString;
  1130. };
  1131. /*:726*//*729:*/
  1132. #line 15283 "./typica.w"
  1133. class DeviceConfigurationWindow:public QWidget
  1134. {
  1135. Q_OBJECT
  1136. public:
  1137. DeviceConfigurationWindow();
  1138. public slots:
  1139. void addDevice();
  1140. void removeNode();
  1141. void newSelection(const QModelIndex&index);
  1142. private slots:
  1143. void resizeColumn();
  1144. private:
  1145. QDomDocument document;
  1146. DeviceTreeModel*model;
  1147. QTreeView*view;
  1148. QScrollArea*configArea;
  1149. };
  1150. /*:729*//*738:*/
  1151. #line 15453 "./typica.w"
  1152. class BasicDeviceConfigurationWidget:public QWidget
  1153. {
  1154. Q_OBJECT
  1155. public:
  1156. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1157. const QModelIndex&index);
  1158. public slots:
  1159. void insertChildNode(const QString&name,const QString&driver);
  1160. void updateAttribute(const QString&name,const QString&value);
  1161. protected:
  1162. DeviceTreeModel*deviceModel;
  1163. QModelIndex currentNode;
  1164. };
  1165. /*:738*//*742:*/
  1166. #line 15538 "./typica.w"
  1167. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1168. {
  1169. Q_OBJECT
  1170. public:
  1171. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1172. const QModelIndex&index);
  1173. private slots:
  1174. void updateRoasterId(int id);
  1175. };
  1176. /*:742*//*747:*/
  1177. #line 15673 "./typica.w"
  1178. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1179. {
  1180. Q_OBJECT
  1181. public:
  1182. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1183. const QModelIndex&index);
  1184. };
  1185. /*:747*//*749:*/
  1186. #line 15719 "./typica.w"
  1187. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1188. {
  1189. Q_OBJECT
  1190. public:
  1191. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1192. const QModelIndex&index);
  1193. private slots:
  1194. void addChannel();
  1195. void updateDeviceId(const QString&newId);
  1196. };
  1197. /*:749*//*753:*/
  1198. #line 15805 "./typica.w"
  1199. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1200. {
  1201. Q_OBJECT
  1202. public:
  1203. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1204. const QModelIndex&index);
  1205. private slots:
  1206. void updateThermocoupleType(const QString&type);
  1207. void updateColumnName(const QString&name);
  1208. void updateHidden(bool hidden);
  1209. };
  1210. /*:753*//*758:*/
  1211. #line 15921 "./typica.w"
  1212. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1213. {
  1214. Q_OBJECT
  1215. public:
  1216. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1217. const QModelIndex&index);
  1218. };
  1219. /*:758*//*760:*/
  1220. #line 15962 "./typica.w"
  1221. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1222. {
  1223. Q_OBJECT
  1224. public:
  1225. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1226. const QModelIndex&index);
  1227. private slots:
  1228. void addChannel();
  1229. void updateDeviceId(const QString&newId);
  1230. };
  1231. /*:760*//*762:*/
  1232. #line 16031 "./typica.w"
  1233. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1234. {
  1235. Q_OBJECT
  1236. public:
  1237. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1238. const QModelIndex&index);
  1239. private slots:
  1240. void updateDeviceId(const QString&newId);
  1241. void updateThermocoupleType(const QString&type);
  1242. void updateColumnName(const QString&name);
  1243. void updateHidden(bool hidden);
  1244. };
  1245. /*:762*//*767:*/
  1246. #line 16162 "./typica.w"
  1247. class PortSelector:public QComboBox
  1248. {
  1249. Q_OBJECT
  1250. public:
  1251. PortSelector(QWidget*parent= NULL);
  1252. private slots:
  1253. void addDevice(QextPortInfo port);
  1254. private:
  1255. QextSerialEnumerator*lister;
  1256. };
  1257. /*:767*//*769:*/
  1258. #line 16210 "./typica.w"
  1259. class BaudSelector:public QComboBox
  1260. {
  1261. Q_OBJECT
  1262. Q_ENUMS(BaudRateType)
  1263. public:
  1264. BaudSelector(QWidget*parent= NULL);
  1265. enum BaudRateType
  1266. {
  1267. #if defined(Q_OS_UNIX) || defined(qdoc)
  1268. BAUD50= 50,
  1269. BAUD75= 75,
  1270. BAUD134= 134,
  1271. BAUD150= 150,
  1272. BAUD200= 200,
  1273. BAUD1800= 1800,
  1274. #if defined(B76800) || defined(qdoc)
  1275. BAUD76800= 76800,
  1276. #endif
  1277. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1278. BAUD230400= 230400,
  1279. BAUD460800= 460800,
  1280. BAUD500000= 500000,
  1281. BAUD576000= 576000,
  1282. BAUD921600= 921600,
  1283. BAUD1000000= 1000000,
  1284. BAUD1152000= 1152000,
  1285. BAUD1500000= 1500000,
  1286. BAUD2000000= 2000000,
  1287. BAUD2500000= 2500000,
  1288. BAUD3000000= 3000000,
  1289. BAUD3500000= 3500000,
  1290. BAUD4000000= 4000000,
  1291. #endif
  1292. #endif
  1293. #if defined(Q_OS_WIN) || defined(qdoc)
  1294. BAUD14400= 14400,
  1295. BAUD56000= 56000,
  1296. BAUD128000= 128000,
  1297. BAUD256000= 256000,
  1298. #endif
  1299. BAUD110= 110,
  1300. BAUD300= 300,
  1301. BAUD600= 600,
  1302. BAUD1200= 1200,
  1303. BAUD2400= 2400,
  1304. BAUD4800= 4800,
  1305. BAUD9600= 9600,
  1306. BAUD19200= 19200,
  1307. BAUD38400= 38400,
  1308. BAUD57600= 57600,
  1309. BAUD115200= 115200
  1310. };
  1311. };
  1312. /*:769*//*771:*/
  1313. #line 16281 "./typica.w"
  1314. class ParitySelector:public QComboBox
  1315. {
  1316. Q_OBJECT
  1317. Q_ENUMS(ParityType)
  1318. public:
  1319. ParitySelector(QWidget*parent= NULL);
  1320. enum ParityType
  1321. {
  1322. PAR_NONE,
  1323. PAR_ODD,
  1324. PAR_EVEN,
  1325. #if defined(Q_OS_WIN) || defined(qdoc)
  1326. PAR_MARK,
  1327. #endif
  1328. PAR_SPACE
  1329. };
  1330. };
  1331. /*:771*//*773:*/
  1332. #line 16319 "./typica.w"
  1333. class FlowSelector:public QComboBox
  1334. {
  1335. Q_OBJECT
  1336. Q_ENUMS(FlowType)
  1337. public:
  1338. FlowSelector(QWidget*parent= NULL);
  1339. enum FlowType
  1340. {
  1341. FLOW_OFF,
  1342. FLOW_HARDWARE,
  1343. FLOW_XONXOFF
  1344. };
  1345. };
  1346. /*:773*//*775:*/
  1347. #line 16352 "./typica.w"
  1348. class StopSelector:public QComboBox
  1349. {
  1350. Q_OBJECT
  1351. Q_ENUMS(StopBitsType)
  1352. public:
  1353. StopSelector(QWidget*parent= NULL);
  1354. enum StopBitsType
  1355. {
  1356. STOP_1,
  1357. #if defined(Q_OS_WIN) || defined(qdoc)
  1358. STOP_1_5,
  1359. #endif
  1360. STOP_2
  1361. };
  1362. };
  1363. /*:775*//*778:*/
  1364. #line 16405 "./typica.w"
  1365. class ShortHexSpinBox:public QSpinBox
  1366. {
  1367. Q_OBJECT
  1368. public:
  1369. ShortHexSpinBox(QWidget*parent= NULL);
  1370. virtual QValidator::State validate(QString&input,int&pos)const;
  1371. protected:
  1372. virtual int valueFromText(const QString&text)const;
  1373. virtual QString textFromValue(int value)const;
  1374. };
  1375. /*:778*//*780:*/
  1376. #line 16467 "./typica.w"
  1377. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1378. {
  1379. Q_OBJECT
  1380. public:
  1381. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1382. const QModelIndex&index);
  1383. private slots:
  1384. void updatePort(const QString&newPort);
  1385. void updateBaudRate(const QString&newRate);
  1386. void updateParity(const QString&newParity);
  1387. void updateFlowControl(const QString&newFlow);
  1388. void updateStopBits(const QString&newStopBits);
  1389. };
  1390. /*:780*//*782:*/
  1391. #line 16618 "./typica.w"
  1392. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1393. {
  1394. Q_OBJECT
  1395. public:
  1396. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1397. const QModelIndex&index);
  1398. private slots:
  1399. void updateStationNumber(int newStation);
  1400. void updateFixedUnit(bool newFixed);
  1401. void updateFixedDecimal(bool newFixed);
  1402. void updateUnit(const QString&newUnit);
  1403. void updateUnitAddress(int newAddress);
  1404. void updateValueF(int newValue);
  1405. void updateValueC(int newValue);
  1406. void updatePrecisionAddress(int newAddress);
  1407. void updatePrecisionValue(int newValue);
  1408. private:
  1409. QStackedLayout*unitSpecificationLayout;
  1410. QStackedLayout*decimalSpecificationLayout;
  1411. };
  1412. /*:782*//*784:*/
  1413. #line 16877 "./typica.w"
  1414. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1415. {
  1416. Q_OBJECT
  1417. public:
  1418. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1419. const QModelIndex&index);
  1420. private slots:
  1421. void updateAddress(int newAddress);
  1422. };
  1423. /*:784*//*786:*/
  1424. #line 16923 "./typica.w"
  1425. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1426. {
  1427. Q_OBJECT
  1428. public:
  1429. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1430. const QModelIndex&index);
  1431. private slots:
  1432. void updateReadAddress(int newAddress);
  1433. void updateWriteAddress(int newAddress);
  1434. void updateFixedRange(bool fixed);
  1435. void updateLower(const QString&lower);
  1436. void updateUpper(const QString&upper);
  1437. void updateLowerAddress(int newAddress);
  1438. void updateUpperAddress(int newAddress);
  1439. private:
  1440. QStackedLayout*boundsLayout;
  1441. };
  1442. /*:786*//*790:*/
  1443. #line 17117 "./typica.w"
  1444. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1445. {
  1446. Q_OBJECT
  1447. public:
  1448. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1449. private slots:
  1450. void updateButtonText(const QString&text);
  1451. void updateAnnotationText(const QString&text);
  1452. };
  1453. /*:790*//*794:*/
  1454. #line 17185 "./typica.w"
  1455. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1456. {
  1457. Q_OBJECT
  1458. public:
  1459. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1460. private slots:
  1461. void updateButtonText(const QString&text);
  1462. void updateAnnotationText(const QString&text);
  1463. };
  1464. /*:794*//*797:*/
  1465. #line 17259 "./typica.w"
  1466. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1467. {
  1468. Q_OBJECT
  1469. public:
  1470. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1471. private slots:
  1472. void updateLabel(const QString&text);
  1473. void updateMinimum(const QString&minimum);
  1474. void updateMaximum(const QString&maximum);
  1475. void updatePrecision(int precision);
  1476. void updatePretext(const QString&text);
  1477. void updatePosttext(const QString&text);
  1478. };
  1479. /*:797*//*800:*/
  1480. #line 12 "./freeannotation.w"
  1481. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1482. {
  1483. Q_OBJECT
  1484. public:
  1485. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1486. private slots:
  1487. void updateLabel(const QString&text);
  1488. };
  1489. /*:800*//*804:*/
  1490. #line 11 "./settings.w"
  1491. class SettingsWindow:public QMainWindow
  1492. {
  1493. Q_OBJECT
  1494. public:
  1495. SettingsWindow();
  1496. };
  1497. /*:804*//*809:*/
  1498. #line 8 "./graphsettings.w"
  1499. class GraphSettingsWidget:public QWidget
  1500. {
  1501. Q_OBJECT
  1502. public:
  1503. GraphSettingsWidget();
  1504. };
  1505. /*:809*//*811:*/
  1506. #line 46 "./graphsettings.w"
  1507. class GraphSettingsRelativeTab:public QWidget
  1508. {
  1509. Q_OBJECT
  1510. public:
  1511. GraphSettingsRelativeTab();
  1512. public slots:
  1513. void updateEnableSetting(bool enable);
  1514. void updateColorSetting(const QString&color);
  1515. void updateAxisSetting(const QString&gridList);
  1516. void updateUnit(int unit);
  1517. void showColorPicker();
  1518. private:
  1519. QLineEdit*colorEdit;
  1520. };
  1521. /*:811*//*815:*/
  1522. #line 7 "./advancedsettings.w"
  1523. class AdvancedSettingsWidget:public QWidget
  1524. {
  1525. Q_OBJECT
  1526. public:
  1527. AdvancedSettingsWidget();
  1528. public slots:
  1529. void enableDiagnosticLogging(bool enabled);
  1530. };
  1531. /*:815*//*819:*/
  1532. #line 17384 "./typica.w"
  1533. class ModbusRTUDevice:public QObject
  1534. {
  1535. Q_OBJECT
  1536. public:
  1537. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1538. ~ModbusRTUDevice();
  1539. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1540. Q_INVOKABLE double SVLower();
  1541. Q_INVOKABLE double SVUpper();
  1542. Q_INVOKABLE int decimals();
  1543. QList<Channel*> channels;
  1544. public slots:
  1545. void outputSV(double sv);
  1546. signals:
  1547. void SVLowerChanged(double);
  1548. void SVUpperChanged(double);
  1549. void SVDecimalChanged(int);
  1550. void queueEmpty();
  1551. private slots:
  1552. void dataAvailable();
  1553. void sendNextMessage();
  1554. void decimalResponse(QByteArray response);
  1555. void unitResponse(QByteArray response);
  1556. void svlResponse(QByteArray response);
  1557. void svuResponse(QByteArray response);
  1558. void requestMeasurement();
  1559. void mResponse(QByteArray response);
  1560. void ignore(QByteArray response);
  1561. void timeout();
  1562. private:
  1563. QextSerialPort*port;
  1564. QByteArray responseBuffer;
  1565. QList<QByteArray> messageQueue;
  1566. QList<QObject*> retObjQueue;
  1567. QList<char*> callbackQueue;
  1568. quint16 calculateCRC(QByteArray data);
  1569. QTimer*messageDelayTimer;
  1570. QTimer*commTimeout;
  1571. int delayTime;
  1572. char station;
  1573. int decimalPosition;
  1574. int valueF;
  1575. int valueC;
  1576. bool unitIsF;
  1577. double outputSVLower;
  1578. double outputSVUpper;
  1579. QByteArray outputSVStub;
  1580. QByteArray pvStub;
  1581. QByteArray svStub;
  1582. QByteArray mStub;
  1583. quint16 pvaddress;
  1584. quint16 svaddress;
  1585. bool svenabled;
  1586. bool readingsv;
  1587. double savedpv;
  1588. bool waiting;
  1589. };
  1590. /*:819*//*835:*/
  1591. #line 18087 "./typica.w"
  1592. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1593. {
  1594. Q_OBJECT
  1595. public:
  1596. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1597. private slots:
  1598. void updatePort(const QString&newPort);
  1599. void updateBaudRate(const QString&newRate);
  1600. void updateParity(const QString&newParity);
  1601. void updateFlowControl(const QString&newFlow);
  1602. void updateStopBits(const QString&newStopBits);
  1603. void updateStation(int station);
  1604. void updateFixedDecimal(bool fixed);
  1605. void updateDecimalAddress(int address);
  1606. void updateDecimalPosition(int position);
  1607. void updateFixedUnit(bool fixed);
  1608. void updateUnitAddress(int address);
  1609. void updateValueForF(int value);
  1610. void updateValueForC(int value);
  1611. void updateUnit(const QString&newUnit);
  1612. void updatePVAddress(int address);
  1613. void updateSVEnabled(bool enabled);
  1614. void updateSVReadAddress(int address);
  1615. void updateDeviceLimit(bool query);
  1616. void updateSVLowerAddress(int address);
  1617. void updateSVUpperAddress(int address);
  1618. void updateSVLower(double value);
  1619. void updateSVUpper(double value);
  1620. void updateSVWritable(bool canWriteSV);
  1621. void updateSVWriteAddress(int address);
  1622. void updatePVColumnName(const QString&name);
  1623. void updateSVColumnName(const QString&name);
  1624. void updatePVHidden(bool hidden);
  1625. void updateSVHidden(bool hidden);
  1626. private:
  1627. PortSelector*port;
  1628. BaudSelector*baud;
  1629. ParitySelector*parity;
  1630. FlowSelector*flow;
  1631. StopSelector*stop;
  1632. QSpinBox*station;
  1633. QCheckBox*decimalQuery;
  1634. ShortHexSpinBox*decimalAddress;
  1635. QSpinBox*decimalPosition;
  1636. QCheckBox*unitQuery;
  1637. ShortHexSpinBox*unitAddress;
  1638. QSpinBox*valueF;
  1639. QSpinBox*valueC;
  1640. QComboBox*fixedUnit;
  1641. ShortHexSpinBox*pVAddress;
  1642. QCheckBox*sVEnabled;
  1643. ShortHexSpinBox*sVReadAddress;
  1644. QCheckBox*deviceLimit;
  1645. ShortHexSpinBox*sVLowerAddr;
  1646. ShortHexSpinBox*sVUpperAddr;
  1647. QDoubleSpinBox*sVLower;
  1648. QDoubleSpinBox*sVUpper;
  1649. QCheckBox*sVWritable;
  1650. ShortHexSpinBox*sVOutputAddr;
  1651. QLineEdit*pVColumnName;
  1652. QLineEdit*sVColumnName;
  1653. };
  1654. /*:835*//*839:*/
  1655. #line 36 "./unsupportedserial.w"
  1656. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1657. {
  1658. Q_OBJECT
  1659. public:
  1660. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1661. const QModelIndex&index);
  1662. private slots:
  1663. void updateConfiguration();
  1664. void saveScript();
  1665. void addChannel();
  1666. private:
  1667. SaltModel*deviceSettingsModel;
  1668. QTextEdit*scriptEditor;
  1669. };
  1670. /*:839*//*844:*/
  1671. #line 166 "./unsupportedserial.w"
  1672. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1673. {
  1674. Q_OBJECT
  1675. public:
  1676. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1677. const QModelIndex&index);
  1678. private slots:
  1679. void updateColumnName(const QString&value);
  1680. void updateHidden(bool hidden);
  1681. void updateConfiguration();
  1682. private:
  1683. SaltModel*channelSettingsModel;
  1684. };
  1685. /*:844*//*849:*/
  1686. #line 298 "./unsupportedserial.w"
  1687. class JavaScriptDevice:public QObject
  1688. {
  1689. Q_OBJECT
  1690. public:
  1691. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1692. QScriptEngine*engine);
  1693. Q_INVOKABLE int channelCount();
  1694. Channel*getChannel(int channel);
  1695. Q_INVOKABLE bool isChannelHidden(int channel);
  1696. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1697. Q_INVOKABLE QString channelColumnName(int channel);
  1698. Q_INVOKABLE QString channelIndicatorText(int channel);
  1699. public slots:
  1700. void setTemperatureColumn(int tcol);
  1701. void setAnnotationColumn(int ncol);
  1702. void start();
  1703. void stop();
  1704. signals:
  1705. void annotation(QString note,int tcol,int ncol);
  1706. void triggerStartBatch();
  1707. void triggerStopBatch();
  1708. void deviceStopRequested();
  1709. private:
  1710. QVariantMap deviceSettings;
  1711. QString deviceScript;
  1712. QList<Channel*> channelList;
  1713. QList<bool> hiddenState;
  1714. QList<Units::Unit> channelUnits;
  1715. QList<QString> columnNames;
  1716. QList<QString> indicatorTexts;
  1717. QList<QVariantMap> channelSettings;
  1718. int annotationTemperatureColumn;
  1719. int annotationNoteColumn;
  1720. QScriptEngine*scriptengine;
  1721. };
  1722. /*:849*//*871:*/
  1723. #line 11 "./phidgets.w"
  1724. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1725. {
  1726. Q_OBJECT
  1727. public:
  1728. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1729. const QModelIndex&index);
  1730. private slots:
  1731. void addChannel();
  1732. void updateRate(int ms);
  1733. };
  1734. /*:871*//*875:*/
  1735. #line 82 "./phidgets.w"
  1736. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1737. {
  1738. Q_OBJECT
  1739. public:
  1740. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1741. const QModelIndex&index);
  1742. private slots:
  1743. void updateColumnName(const QString&value);
  1744. void updateHidden(bool hidden);
  1745. void updateTC(int index);
  1746. void updateChannel(int channel);
  1747. private:
  1748. QComboBox*tcType;
  1749. };
  1750. /*:875*//*880:*/
  1751. #line 213 "./phidgets.w"
  1752. class PhidgetsTemperatureSensor:public QObject
  1753. {
  1754. Q_OBJECT
  1755. public:
  1756. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1757. Q_INVOKABLE int channelCount();
  1758. Channel*getChannel(int channel);
  1759. Q_INVOKABLE bool isChannelHidden(int channel);
  1760. Q_INVOKABLE QString channelColumnName(int channel);
  1761. Q_INVOKABLE QString channelIndicatorText(int channel);
  1762. public slots:
  1763. void start();
  1764. void stop();
  1765. private slots:
  1766. void getMeasurements();
  1767. private:
  1768. QList<int> channelIndices;
  1769. QList<int> tctypes;
  1770. QList<Channel*> channelList;
  1771. QMap<int,Channel*> channelMap;
  1772. QList<bool> hiddenState;
  1773. QList<QString> columnNames;
  1774. QList<QString> indicatorTexts;
  1775. QLibrary driver;
  1776. QTimer sampleTimer;
  1777. void*device;
  1778. /*884:*/
  1779. #line 349 "./phidgets.w"
  1780. typedef int(*PhidgetHandleOnly)(void*);
  1781. typedef int(*PhidgetHandleInt)(void*,int);
  1782. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1783. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1784. PhidgetHandleOnly createDevice;
  1785. PhidgetHandleInt openDevice;
  1786. PhidgetHandleInt waitForOpen;
  1787. PhidgetHandleIntInt setTCType;
  1788. PhidgetHandleIntDoubleOut getTemperature;
  1789. PhidgetHandleOnly closeDevice;
  1790. PhidgetHandleOnly deleteDevice;
  1791. /*:884*/
  1792. #line 240 "./phidgets.w"
  1793. };
  1794. /*:880*//*893:*/
  1795. #line 18625 "./typica.w"
  1796. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1797. {
  1798. Q_OBJECT
  1799. public:
  1800. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1801. const QModelIndex&index);
  1802. private slots:
  1803. void updateSourceColumn(const QString&source);
  1804. void updateDestinationColumn(const QString&dest);
  1805. void updateKnots();
  1806. private:
  1807. SaltModel*tablemodel;
  1808. };
  1809. /*:893*//*899:*/
  1810. #line 18749 "./typica.w"
  1811. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1812. {
  1813. Q_OBJECT
  1814. public:
  1815. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1816. private slots:
  1817. void updateMatchingColumn(const QString&column);
  1818. void updateTemperature();
  1819. private:
  1820. QDoubleSpinBox*temperatureValue;
  1821. QComboBox*unitSelector;
  1822. };
  1823. /*:899*//*903:*/
  1824. #line 16 "./rate.w"
  1825. class RateOfChange:public QObject
  1826. {
  1827. Q_OBJECT
  1828. public:
  1829. RateOfChange(int cachetime= 1,int scaletime= 1);
  1830. public slots:
  1831. void newMeasurement(Measurement measure);
  1832. void setCacheTime(int seconds);
  1833. void setScaleTime(int seconds);
  1834. signals:
  1835. void newData(Measurement measure);
  1836. private:
  1837. int ct;
  1838. int st;
  1839. QList<Measurement> cache;
  1840. };
  1841. /*:903*//*911:*/
  1842. #line 177 "./rate.w"
  1843. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1844. {
  1845. Q_OBJECT
  1846. public:
  1847. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1848. private slots:
  1849. void updateColumn(const QString&column);
  1850. void updateCacheTime(const QString&seconds);
  1851. void updateScaleTime(const QString&seconds);
  1852. };
  1853. /*:911*//*917:*/
  1854. #line 19 "./dataqsdk.w"
  1855. class DataqSdkDeviceImplementation;
  1856. class DataqSdkDevice:public QObject
  1857. {
  1858. Q_OBJECT
  1859. DataqSdkDeviceImplementation*imp;
  1860. private slots:
  1861. void threadFinished();
  1862. public:
  1863. DataqSdkDevice(QString device);
  1864. ~DataqSdkDevice();
  1865. Channel*newChannel(Units::Unit scale);
  1866. Q_INVOKABLE void setClockRate(double Hz);
  1867. Q_INVOKABLE void start();
  1868. static QStringList detectPorts();
  1869. static QStringList detectHardware();
  1870. };
  1871. /*:917*//*918:*/
  1872. #line 49 "./dataqsdk.w"
  1873. class DataqSdkDeviceImplementation:public QThread
  1874. {
  1875. Q_OBJECT
  1876. public:
  1877. DataqSdkDeviceImplementation();
  1878. ~DataqSdkDeviceImplementation();
  1879. void run();
  1880. /*919:*/
  1881. #line 70 "./dataqsdk.w"
  1882. typedef struct di_inlist_struct{
  1883. unsigned short chan;
  1884. unsigned short diff;
  1885. unsigned short gain;
  1886. unsigned short unipolar;
  1887. unsigned short dig_out_enable;
  1888. unsigned short dig_out;
  1889. unsigned short ave;
  1890. unsigned short counter;
  1891. }DI_INLIST_STRUCT;
  1892. typedef int(PASCAL*FPDIOPEN)(unsigned);
  1893. typedef int(PASCAL*FPDICLOSE)(void);
  1894. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  1895. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  1896. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  1897. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  1898. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  1899. typedef int(PASCAL*FPDISTARTSCAN)(void);
  1900. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  1901. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  1902. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  1903. typedef int(PASCAL*FPDISTOPSCAN)(void);
  1904. FPDIOPEN di_open;
  1905. FPDICLOSE di_close;
  1906. FPDISAMPLERATE di_sample_rate;
  1907. FPDIMAXIMUMRATE di_maximum_rate;
  1908. FPDILISTLENGTH di_list_length;
  1909. FPDIINLIST di_inlist;
  1910. FPDIBUFFERALLOC di_buffer_alloc;
  1911. FPDISTARTSCAN di_start_scan;
  1912. FPDISTATUSREAD di_status_read;
  1913. FPDIBUFFERSTATUS di_buffer_status;
  1914. FPDIBURSTRATE di_burst_rate;
  1915. FPDISTOPSCAN di_stop_scan;
  1916. /*:919*/
  1917. #line 57 "./dataqsdk.w"
  1918. /*921:*/
  1919. #line 134 "./dataqsdk.w"
  1920. bool isOpen;
  1921. double sampleRate;
  1922. long oversample;
  1923. long burstDivisor;
  1924. QString device;
  1925. unsigned deviceNumber;
  1926. QVector<Channel*> channelMap;
  1927. int error;
  1928. int channels;
  1929. bool ready;
  1930. QLibrary*driver;
  1931. QVector<Units::Unit> unitMap;
  1932. int*input_buffer;
  1933. QTimer*eventClock;
  1934. QMultiMap<int,double> smoother;
  1935. /*:921*/
  1936. #line 58 "./dataqsdk.w"
  1937. public slots:
  1938. void measure();
  1939. private:
  1940. qint16*buffer;
  1941. };
  1942. /*:918*//*938:*/
  1943. #line 663 "./dataqsdk.w"
  1944. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  1945. {
  1946. Q_OBJECT
  1947. public:
  1948. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  1949. const QModelIndex&index);
  1950. private slots:
  1951. void updateAutoSelect(bool automatic);
  1952. void updateDeviceNumber(int deviceNumber);
  1953. void updatePort(QString portId);
  1954. void addChannel();
  1955. private:
  1956. QStackedWidget*deviceIdStack;
  1957. };
  1958. /*:938*//*943:*/
  1959. #line 808 "./dataqsdk.w"
  1960. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  1961. {
  1962. Q_OBJECT
  1963. public:
  1964. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  1965. const QModelIndex&index);
  1966. private slots:
  1967. void updateUnits(const QString&unit);
  1968. void updateColumnName(const QString&value);
  1969. void updateMeasuredLower(const QString&value);
  1970. void updateMeasuredUpper(const QString&value);
  1971. void updateMappedLower(const QString&value);
  1972. void updateMappedUpper(const QString&value);
  1973. void updateClosedInterval(bool closed);
  1974. void updateSmoothingEnabled(bool enabled);
  1975. void updateSensitivity(const QString&value);
  1976. void startCalibration();
  1977. void stopCalibration();
  1978. void resetCalibration();
  1979. void updateInput(Measurement measure);
  1980. void updateOutput(Measurement measure);
  1981. void updateHidden(bool hidden);
  1982. private:
  1983. QPushButton*startButton;
  1984. QPushButton*resetButton;
  1985. QPushButton*stopButton;
  1986. /*948:*/
  1987. #line 1098 "./dataqsdk.w"
  1988. bool autoSelect;
  1989. QString deviceID;
  1990. unsigned int channelOfInterest;
  1991. /*:948*/
  1992. #line 835 "./dataqsdk.w"
  1993. DataqSdkDevice*calibrationDevice;
  1994. LinearCalibrator*calibrator;
  1995. QLineEdit*currentMeasurement;
  1996. QLineEdit*minimumMeasurement;
  1997. QLineEdit*maximumMeasurement;
  1998. QLineEdit*averageMeasurement;
  1999. QLineEdit*currentMapped;
  2000. QLineEdit*minimumMapped;
  2001. QLineEdit*maximumMapped;
  2002. QLineEdit*averageMapped;
  2003. int rmCount;
  2004. int cmCount;
  2005. double rmin;
  2006. double rmax;
  2007. double rmean;
  2008. double cmin;
  2009. double cmax;
  2010. double cmean;
  2011. };
  2012. /*:943*//*970:*/
  2013. #line 247 "./scales.w"
  2014. Q_DECLARE_METATYPE(BaudRateType)
  2015. Q_DECLARE_METATYPE(DataBitsType)
  2016. Q_DECLARE_METATYPE(ParityType)
  2017. Q_DECLARE_METATYPE(StopBitsType)
  2018. Q_DECLARE_METATYPE(FlowType)
  2019. /*:970*//*977:*/
  2020. #line 370 "./scales.w"
  2021. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2022. {
  2023. Q_OBJECT
  2024. public:
  2025. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2026. const QModelIndex&index);
  2027. private slots:
  2028. void updatePort(const QString&newPort);
  2029. void updateBaudRate(const QString&rate);
  2030. void updateParity(int index);
  2031. void updateFlowControl(int index);
  2032. void updateStopBits(int index);
  2033. private:
  2034. PortSelector*port;
  2035. BaudSelector*baud;
  2036. ParitySelector*parity;
  2037. FlowSelector*flow;
  2038. StopSelector*stop;
  2039. };
  2040. /*:977*//*982:*/
  2041. #line 14 "./valueannotation.w"
  2042. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2043. {
  2044. Q_OBJECT
  2045. public:
  2046. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2047. const QModelIndex&index);
  2048. private slots:
  2049. void updateSourceColumn(const QString&source);
  2050. void updateAnnotations();
  2051. void updateStart(bool noteOnStart);
  2052. private:
  2053. SaltModel*tablemodel;
  2054. };
  2055. /*:982*//*990:*/
  2056. #line 165 "./valueannotation.w"
  2057. class ValueAnnotation:public QObject
  2058. {
  2059. Q_OBJECT
  2060. public:
  2061. ValueAnnotation();
  2062. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2063. public slots:
  2064. void newMeasurement(Measurement measure);
  2065. void annotate();
  2066. void setAnnotationColumn(int column);
  2067. void setTemperatureColumn(int column);
  2068. void setTolerance(double epsilon);
  2069. signals:
  2070. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2071. private:
  2072. int lastIndex;
  2073. int annotationColumn;
  2074. int measurementColumn;
  2075. QList<double> values;
  2076. QStringList annotations;
  2077. double tolerance;
  2078. };
  2079. /*:990*/
  2080. #line 526 "./typica.w"
  2081. /*12:*/
  2082. #line 807 "./typica.w"
  2083. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2084. /*:12*//*14:*/
  2085. #line 822 "./typica.w"
  2086. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2087. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2088. /*:14*//*16:*/
  2089. #line 847 "./typica.w"
  2090. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2091. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2092. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2093. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2094. QScriptEngine*engine);
  2095. /*:16*//*27:*/
  2096. #line 1091 "./typica.w"
  2097. QScriptValue constructQMainWindow(QScriptContext*context,
  2098. QScriptEngine*engine);
  2099. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2100. QScriptEngine*engine);
  2101. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2102. QScriptEngine*engine);
  2103. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2104. /*:27*//*32:*/
  2105. #line 1190 "./typica.w"
  2106. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2107. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2108. /*:32*//*35:*/
  2109. #line 1235 "./typica.w"
  2110. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2111. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2112. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2113. /*:35*//*38:*/
  2114. #line 1301 "./typica.w"
  2115. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2116. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2117. /*:38*//*41:*/
  2118. #line 1334 "./typica.w"
  2119. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2120. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2121. /*:41*//*44:*/
  2122. #line 1372 "./typica.w"
  2123. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2124. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2125. /*:44*//*48:*/
  2126. #line 1411 "./typica.w"
  2127. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2128. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2129. QScriptEngine*engine);
  2130. QScriptValue QSplitter_saveState(QScriptContext*context,
  2131. QScriptEngine*engine);
  2132. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2133. QScriptEngine*engine);
  2134. QScriptValue QSplitter_count(QScriptContext*context,
  2135. QScriptEngine*engine);
  2136. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2137. /*:48*//*54:*/
  2138. #line 1550 "./typica.w"
  2139. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2140. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2141. /*:54*//*56:*/
  2142. #line 1605 "./typica.w"
  2143. QScriptValue constructQBoxLayout(QScriptContext*context,
  2144. QScriptEngine*engine);
  2145. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2146. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2147. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2148. /*:56*//*60:*/
  2149. #line 1718 "./typica.w"
  2150. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2151. QScriptValue QAction_setShortcut(QScriptContext*context,
  2152. QScriptEngine*engine);
  2153. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2154. /*:60*//*63:*/
  2155. #line 1774 "./typica.w"
  2156. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2157. QScriptEngine*engine);
  2158. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2159. QScriptEngine*engine);
  2160. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2161. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2162. /*:63*//*68:*/
  2163. #line 1885 "./typica.w"
  2164. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2165. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2166. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2167. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2168. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2169. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2170. QScriptValue QIODevice_readToString(QScriptContext*context,
  2171. QScriptEngine*engine);
  2172. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2173. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2174. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2175. /*:68*//*77:*/
  2176. #line 2072 "./typica.w"
  2177. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2178. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2179. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2180. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2181. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2182. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2183. /*:77*//*85:*/
  2184. #line 2190 "./typica.w"
  2185. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2186. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2187. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2188. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2189. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2190. /*:85*//*91:*/
  2191. #line 2260 "./typica.w"
  2192. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2193. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2194. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2195. /*:91*//*94:*/
  2196. #line 2305 "./typica.w"
  2197. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2198. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2199. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2200. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2201. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2202. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2203. /*:94*//*100:*/
  2204. #line 2387 "./typica.w"
  2205. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2206. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2207. QScriptEngine*engine);
  2208. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2209. QScriptEngine*engine);
  2210. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2211. QScriptEngine*engine);
  2212. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2213. QScriptEngine*engine);
  2214. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2215. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2216. QScriptEngine*engine);
  2217. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2218. QScriptEngine*engine);
  2219. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2220. QScriptEngine*engine);
  2221. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2222. QScriptEngine*engine);
  2223. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2224. QScriptEngine*engine);
  2225. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2226. QScriptEngine*engine);
  2227. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2228. QScriptEngine*engine);
  2229. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2230. QScriptEngine*engine);
  2231. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2232. /*:100*//*109:*/
  2233. #line 2605 "./typica.w"
  2234. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2235. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2236. QScriptValue XmlReader_attribute(QScriptContext*context,
  2237. QScriptEngine*engine);
  2238. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2239. QScriptEngine*engine);
  2240. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2241. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2242. QScriptEngine*engine);
  2243. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2244. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2245. QScriptEngine*engine);
  2246. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2247. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2248. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2249. /*:109*//*116:*/
  2250. #line 2740 "./typica.w"
  2251. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2252. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2253. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2254. /*:116*//*120:*/
  2255. #line 2822 "./typica.w"
  2256. QScriptValue constructQLCDNumber(QScriptContext*context,
  2257. QScriptEngine*engine);
  2258. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2259. /*:120*//*123:*/
  2260. #line 2860 "./typica.w"
  2261. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2262. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2263. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2264. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2265. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2266. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2267. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2268. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2269. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2270. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2271. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2272. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2273. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2274. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2275. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2276. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2277. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2278. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2279. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2280. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2281. /*:123*//*139:*/
  2282. #line 3338 "./typica.w"
  2283. void setQAbstractScrollAreaProperties(QScriptValue value,
  2284. QScriptEngine*engine);
  2285. /*:139*//*141:*/
  2286. #line 3353 "./typica.w"
  2287. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2288. /*:141*//*143:*/
  2289. #line 3366 "./typica.w"
  2290. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2291. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2292. /*:143*//*145:*/
  2293. #line 3390 "./typica.w"
  2294. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2295. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2296. QScriptValue constructQPushButton(QScriptContext*context,
  2297. QScriptEngine*engine);
  2298. /*:145*//*152:*/
  2299. #line 3489 "./typica.w"
  2300. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2301. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2302. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2303. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2304. QScriptEngine*engine);
  2305. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2306. QScriptEngine*engine);
  2307. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2308. QScriptEngine*engine);
  2309. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2310. QScriptEngine*engine);
  2311. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2312. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2313. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2314. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2315. /*:152*//*159:*/
  2316. #line 3660 "./typica.w"
  2317. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2318. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2319. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2320. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2321. QScriptValue annotationFromRecord(QScriptContext*context,
  2322. QScriptEngine*engine);
  2323. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2324. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2325. /*:159*//*171:*/
  2326. #line 3972 "./typica.w"
  2327. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2328. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2329. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2330. QStack<QLayout*> *layoutStack);
  2331. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2332. QStack<QLayout*> *layoutStack);
  2333. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2334. QStack<QLayout*> *layoutStack);
  2335. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2336. QStack<QLayout*> *layoutStack);
  2337. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2338. QStack<QLayout*> *layoutStack);
  2339. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2340. QStack<QLayout*> *layoutStack);
  2341. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2342. QStack<QLayout*> *layoutStack);
  2343. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2344. QStack<QLayout*> *layoutStack);
  2345. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2346. QStack<QLayout*> *layoutStack);
  2347. void addTemperatureDisplayToSplitter(QDomElement element,
  2348. QStack<QWidget*> *widgetStack,
  2349. QStack<QLayout*> *layoutStack);
  2350. void addTemperatureDisplayToLayout(QDomElement element,
  2351. QStack<QWidget*> *widgetStack,
  2352. QStack<QLayout*> *layoutStack);
  2353. void addTimerDisplayToSplitter(QDomElement element,
  2354. QStack<QWidget*> *widgetStack,
  2355. QStack<QLayout*> *layoutStack);
  2356. void addTimerDisplayToLayout(QDomElement element,
  2357. QStack<QWidget*> *widgetStack,
  2358. QStack<QLayout*> *layoutStack);
  2359. void addDecorationToSplitter(QDomElement element,
  2360. QStack<QWidget*> *widgetStack,
  2361. QStack<QLayout*> *layoutStack);
  2362. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2363. QStack<QLayout*> *layoutStack);
  2364. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2365. QStack<QLayout*> *layoutStack);
  2366. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2367. QStack<QLayout*> *layoutStack);
  2368. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2369. QStack<QLayout*> *layoutStack);
  2370. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2371. QStack<QLayout*> *layoutStack);
  2372. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2373. QStack<QLayout*> *layoutStack);
  2374. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2375. QStack<QLayout*> *layoutStack);
  2376. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2377. QStack<QLayout*> *layoutStack);
  2378. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2379. QStack<QLayout*> *layoutStack);
  2380. void addSqlQueryViewToLayout(QDomElement element,
  2381. QStack<QWidget*> *widgetStack,
  2382. QStack<QLayout*> *layoutStack);
  2383. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2384. QStack<QLayout*> *layoutStack);
  2385. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2386. QStack<QLayout*> *layoutStack);
  2387. /*:171*//*231:*/
  2388. #line 5562 "./typica.w"
  2389. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2390. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2391. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2392. QScriptEngine*engine);
  2393. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2394. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2395. QScriptEngine*engine);
  2396. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2397. /*:231*//*232:*/
  2398. #line 5577 "./typica.w"
  2399. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2400. /*:232*//*236:*/
  2401. #line 5712 "./typica.w"
  2402. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2403. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2404. QScriptEngine*engine);
  2405. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2406. QScriptEngine*engine);
  2407. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2408. QScriptEngine*engine);
  2409. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2410. QScriptEngine*engine);
  2411. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2412. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2413. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2414. QScriptEngine*engine);
  2415. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2416. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2417. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2418. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2419. /*:236*//*246:*/
  2420. #line 5928 "./typica.w"
  2421. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2422. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2423. QScriptValue QComboBox_currentData(QScriptContext*context,
  2424. QScriptEngine*engine);
  2425. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2426. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2427. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2428. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2429. /*:246*//*258:*/
  2430. #line 366 "./units.w"
  2431. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2432. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2433. QScriptEngine*engine);
  2434. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2435. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2436. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2437. /*:258*//*262:*/
  2438. #line 430 "./units.w"
  2439. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2440. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2441. /*:262*//*271:*/
  2442. #line 133 "./measurement.w"
  2443. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2444. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2445. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2446. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2447. /*:271*//*291:*/
  2448. #line 6562 "./typica.w"
  2449. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2450. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2451. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2452. /*:291*//*300:*/
  2453. #line 6767 "./typica.w"
  2454. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2455. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2456. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2457. /*:300*//*305:*/
  2458. #line 6868 "./typica.w"
  2459. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2460. /*:305*//*311:*/
  2461. #line 7050 "./typica.w"
  2462. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2463. QScriptEngine*engine);
  2464. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2465. /*:311*//*316:*/
  2466. #line 7190 "./typica.w"
  2467. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2468. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2469. /*:316*//*326:*/
  2470. #line 7392 "./typica.w"
  2471. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2472. QScriptEngine*engine);
  2473. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2474. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2475. QScriptEngine*engine);
  2476. /*:326*//*334:*/
  2477. #line 7551 "./typica.w"
  2478. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2479. QScriptEngine*engine);
  2480. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2481. QScriptEngine*engine);
  2482. /*:334*//*339:*/
  2483. #line 7664 "./typica.w"
  2484. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2485. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2486. /*:339*//*344:*/
  2487. #line 7762 "./typica.w"
  2488. QScriptValue constructZeroEmitter(QScriptContext*context,
  2489. QScriptEngine*engine);
  2490. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2491. /*:344*//*349:*/
  2492. #line 7841 "./typica.w"
  2493. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2494. QScriptEngine*engine);
  2495. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2496. /*:349*//*366:*/
  2497. #line 8305 "./typica.w"
  2498. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2499. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2500. /*:366*//*389:*/
  2501. #line 8932 "./typica.w"
  2502. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2503. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2504. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2505. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2506. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2507. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2508. QScriptEngine*engine);
  2509. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2510. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2511. QScriptEngine*engnie);
  2512. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2513. QScriptEngine*engine);
  2514. /*:389*//*427:*/
  2515. #line 9889 "./typica.w"
  2516. QScriptValue constructAnnotationButton(QScriptContext*context,
  2517. QScriptEngine*engine);
  2518. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2519. /*:427*//*435:*/
  2520. #line 10029 "./typica.w"
  2521. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2522. QScriptEngine*engine);
  2523. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2524. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2525. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2526. /*:435*//*456:*/
  2527. #line 10452 "./typica.w"
  2528. QScriptValue constructTimerDisplay(QScriptContext*context,
  2529. QScriptEngine*engine);
  2530. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2531. /*:456*//*483:*/
  2532. #line 10946 "./typica.w"
  2533. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2534. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2535. QScriptEngine*engine);
  2536. /*:483*//*496:*/
  2537. #line 11229 "./typica.w"
  2538. QScriptValue constructLogEditWindow(QScriptContext*context,
  2539. QScriptEngine*engine);
  2540. /*:496*//*515:*/
  2541. #line 11757 "./typica.w"
  2542. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2544. /*:515*//*533:*/
  2545. #line 189 "./webview.w"
  2546. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2547. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2548. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2549. QStack<QLayout*> *layoutStack);
  2550. /*:533*//*536:*/
  2551. #line 219 "./webview.w"
  2552. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2553. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2554. /*:536*//*540:*/
  2555. #line 277 "./webview.w"
  2556. QScriptValue constructWebElement(QScriptContext*context,
  2557. QScriptEngine*engine);
  2558. /*:540*//*609:*/
  2559. #line 13096 "./typica.w"
  2560. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2561. QScriptValue constructSqlQueryView(QScriptContext*context,
  2562. QScriptEngine*engine);
  2563. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2564. QScriptEngine*engine);
  2565. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2566. QScriptEngine*engine);
  2567. /*:609*//*619:*/
  2568. #line 13333 "./typica.w"
  2569. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2570. QStack<QLayout*> *layoutStack);
  2571. /*:619*//*635:*/
  2572. #line 13618 "./typica.w"
  2573. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2574. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2575. /*:635*//*657:*/
  2576. #line 471 "./daterangeselector.w"
  2577. void addDateRangeToLayout(QDomElement element,
  2578. QStack<QWidget*> *widgetStack,
  2579. QStack<QLayout*> *layoutStack);
  2580. /*:657*//*666:*/
  2581. #line 13815 "./typica.w"
  2582. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2583. QStack<QLayout*> *layoutStack);
  2584. /*:666*//*687:*/
  2585. #line 14399 "./typica.w"
  2586. void addScaleControlToLayout(QDomElement element,
  2587. QStack<QWidget*> *widgetStack,
  2588. QStack<QLayout*> *layoutStack);
  2589. void addIntensityControlToLayout(QDomElement element,
  2590. QStack<QWidget*> *widgetStack,
  2591. QStack<QLayout*> *layoutStack);
  2592. /*:687*//*713:*/
  2593. #line 14985 "./typica.w"
  2594. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2595. QScriptEngine*engine);
  2596. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2597. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2598. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2599. QScriptEngine*engine);
  2600. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2601. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2602. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2603. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2604. /*:713*//*719:*/
  2605. #line 15127 "./typica.w"
  2606. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2607. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2608. /*:719*//*735:*/
  2609. #line 15425 "./typica.w"
  2610. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2611. QScriptEngine*engine);
  2612. /*:735*//*806:*/
  2613. #line 42 "./settings.w"
  2614. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2615. /*:806*//*830:*/
  2616. #line 17994 "./typica.w"
  2617. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2618. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2619. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2620. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2621. /*:830*//*850:*/
  2622. #line 345 "./unsupportedserial.w"
  2623. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2624. /*:850*//*856:*/
  2625. #line 425 "./unsupportedserial.w"
  2626. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2627. /*:856*//*862:*/
  2628. #line 617 "./unsupportedserial.w"
  2629. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2630. /*:862*//*866:*/
  2631. #line 651 "./unsupportedserial.w"
  2632. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2633. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2634. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2635. /*:866*//*890:*/
  2636. #line 450 "./phidgets.w"
  2637. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2638. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2639. /*:890*//*908:*/
  2640. #line 138 "./rate.w"
  2641. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2642. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2643. /*:908*//*933:*/
  2644. #line 597 "./dataqsdk.w"
  2645. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2646. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2647. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2648. /*:933*//*960:*/
  2649. #line 67 "./scales.w"
  2650. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2651. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2652. /*:960*//*968:*/
  2653. #line 233 "./scales.w"
  2654. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2655. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2656. /*:968*//*971:*/
  2657. #line 258 "./scales.w"
  2658. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2659. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2660. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2661. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2662. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2663. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2664. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2665. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2666. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2667. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2668. /*:971*//*996:*/
  2669. #line 265 "./valueannotation.w"
  2670. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2671. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2672. /*:996*/
  2673. #line 527 "./typica.w"
  2674. /*589:*/
  2675. #line 12753 "./typica.w"
  2676. void messageFileOutput(QtMsgType type,const char*msg);
  2677. /*:589*/
  2678. #line 528 "./typica.w"
  2679. /*4:*/
  2680. #line 537 "./typica.w"
  2681. /*727:*/
  2682. #line 15248 "./typica.w"
  2683. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2684. const QString&driver,QObject*parent):
  2685. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2686. {
  2687. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2688. }
  2689. void NodeInserter::onTriggered()
  2690. {
  2691. emit triggered(defaultNodeName,driverString);
  2692. }
  2693. /*:727*/
  2694. #line 538 "./typica.w"
  2695. /*267:*/
  2696. #line 40 "./measurement.w"
  2697. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2698. {
  2699. insert("measurement",temperature);
  2700. insert("time",time);
  2701. insert("unit",sc);
  2702. }
  2703. Measurement::Measurement(double temperature)
  2704. {
  2705. insert("measurement",temperature);
  2706. insert("time",QTime::currentTime());
  2707. insert("unit",Units::Fahrenheit);
  2708. }
  2709. void Measurement::setTemperature(double temperature)
  2710. {
  2711. insert("measurement",temperature);
  2712. }
  2713. void Measurement::setTime(QTime time)
  2714. {
  2715. insert("time",time);
  2716. }
  2717. void Measurement::setUnit(Units::Unit scale)
  2718. {
  2719. insert("unit",scale);
  2720. }
  2721. double Measurement::temperature()const
  2722. {
  2723. return value("measurement").toDouble();
  2724. }
  2725. QTime Measurement::time()const
  2726. {
  2727. return value("time").toTime();
  2728. }
  2729. Units::Unit Measurement::scale()const
  2730. {
  2731. return(Units::Unit)(value("unit").toInt());
  2732. }
  2733. /*:267*//*268:*/
  2734. #line 88 "./measurement.w"
  2735. Measurement Measurement::toFahrenheit()
  2736. {
  2737. return Measurement(Units::convertTemperature(this->temperature(),
  2738. this->scale(),Units::Fahrenheit),
  2739. this->time(),Units::Fahrenheit);
  2740. }
  2741. Measurement Measurement::toCelsius()
  2742. {
  2743. return Measurement(Units::convertTemperature(this->temperature(),
  2744. this->scale(),Units::Celsius),
  2745. this->time(),Units::Celsius);
  2746. }
  2747. Measurement Measurement::toKelvin()
  2748. {
  2749. return Measurement(Units::convertTemperature(this->temperature(),
  2750. this->scale(),Units::Kelvin),
  2751. this->time(),Units::Kelvin);
  2752. }
  2753. Measurement Measurement::toRankine()
  2754. {
  2755. return Measurement(Units::convertTemperature(this->temperature(),
  2756. this->scale(),Units::Rankine),
  2757. this->time(),Units::Rankine);
  2758. }
  2759. /*:268*/
  2760. #line 539 "./typica.w"
  2761. /*281:*/
  2762. #line 6168 "./typica.w"
  2763. void DAQImplementation::measure()
  2764. {
  2765. int samplesRead= 0;
  2766. double buffer[channels];
  2767. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2768. (unsigned long)(0),buffer,(unsigned long)(channels),
  2769. &samplesRead,(signed long)(0));
  2770. if(error)
  2771. {
  2772. ready= false;
  2773. }
  2774. else
  2775. {
  2776. if(samplesRead)
  2777. {
  2778. QTime time= QTime::currentTime();
  2779. for(int i= 0;i<samplesRead;i++)
  2780. {
  2781. for(int j= 0;j<channels;j++)
  2782. {
  2783. Measurement measure(buffer[j+(i*channels)],time,
  2784. unitMap[j]);
  2785. channelMap[j]->input(measure);
  2786. }
  2787. }
  2788. }
  2789. }
  2790. }
  2791. /*:281*//*282:*/
  2792. #line 6210 "./typica.w"
  2793. void DAQImplementation::run()
  2794. {
  2795. setPriority(QThread::TimeCriticalPriority);
  2796. while(ready)
  2797. {
  2798. measure();
  2799. }
  2800. }
  2801. /*:282*//*283:*/
  2802. #line 6226 "./typica.w"
  2803. void DAQ::threadFinished()
  2804. {
  2805. if(imp->error)
  2806. {
  2807. /*284:*/
  2808. #line 6277 "./typica.w"
  2809. imp->ready= false;
  2810. QMessageBox warning;
  2811. warning.setStandardButtons(QMessageBox::Cancel);
  2812. warning.setIcon(QMessageBox::Warning);
  2813. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2814. unsigned long bytes= imp->errorInfo(NULL,0);
  2815. char string[bytes];
  2816. imp->errorInfo(string,bytes);
  2817. warning.setInformativeText(QString(string));
  2818. warning.setWindowTitle(QString(PROGRAM_NAME));
  2819. warning.exec();
  2820. /*:284*/
  2821. #line 6231 "./typica.w"
  2822. }
  2823. }
  2824. /*:283*//*285:*/
  2825. #line 6302 "./typica.w"
  2826. void DAQ::start()
  2827. {
  2828. if(imp->ready)
  2829. {
  2830. imp->error= imp->startTask(imp->handle);
  2831. if(imp->error)
  2832. {
  2833. /*284:*/
  2834. #line 6277 "./typica.w"
  2835. imp->ready= false;
  2836. QMessageBox warning;
  2837. warning.setStandardButtons(QMessageBox::Cancel);
  2838. warning.setIcon(QMessageBox::Warning);
  2839. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2840. unsigned long bytes= imp->errorInfo(NULL,0);
  2841. char string[bytes];
  2842. imp->errorInfo(string,bytes);
  2843. warning.setInformativeText(QString(string));
  2844. warning.setWindowTitle(QString(PROGRAM_NAME));
  2845. warning.exec();
  2846. /*:284*/
  2847. #line 6310 "./typica.w"
  2848. }
  2849. else
  2850. {
  2851. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2852. imp->start();
  2853. }
  2854. }
  2855. }
  2856. void DAQ::stop()
  2857. {
  2858. if(imp->useBase)
  2859. {
  2860. imp->ready= false;
  2861. imp->wait(ULONG_MAX);
  2862. imp->stopTask(imp->handle);
  2863. }
  2864. else
  2865. {
  2866. imp->ready= false;
  2867. imp->error= imp->stopTask(imp->handle);
  2868. if(imp->error)
  2869. {
  2870. /*284:*/
  2871. #line 6277 "./typica.w"
  2872. imp->ready= false;
  2873. QMessageBox warning;
  2874. warning.setStandardButtons(QMessageBox::Cancel);
  2875. warning.setIcon(QMessageBox::Warning);
  2876. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2877. unsigned long bytes= imp->errorInfo(NULL,0);
  2878. char string[bytes];
  2879. imp->errorInfo(string,bytes);
  2880. warning.setInformativeText(QString(string));
  2881. warning.setWindowTitle(QString(PROGRAM_NAME));
  2882. warning.exec();
  2883. /*:284*/
  2884. #line 6334 "./typica.w"
  2885. }
  2886. imp->error= imp->clearTask(imp->handle);
  2887. if(imp->error)
  2888. {
  2889. /*284:*/
  2890. #line 6277 "./typica.w"
  2891. imp->ready= false;
  2892. QMessageBox warning;
  2893. warning.setStandardButtons(QMessageBox::Cancel);
  2894. warning.setIcon(QMessageBox::Warning);
  2895. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2896. unsigned long bytes= imp->errorInfo(NULL,0);
  2897. char string[bytes];
  2898. imp->errorInfo(string,bytes);
  2899. warning.setInformativeText(QString(string));
  2900. warning.setWindowTitle(QString(PROGRAM_NAME));
  2901. warning.exec();
  2902. /*:284*/
  2903. #line 6339 "./typica.w"
  2904. }
  2905. }
  2906. }
  2907. /*:285*//*286:*/
  2908. #line 6349 "./typica.w"
  2909. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  2910. {
  2911. imp->device= device;
  2912. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  2913. if(imp->error)
  2914. {
  2915. /*284:*/
  2916. #line 6277 "./typica.w"
  2917. imp->ready= false;
  2918. QMessageBox warning;
  2919. warning.setStandardButtons(QMessageBox::Cancel);
  2920. warning.setIcon(QMessageBox::Warning);
  2921. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2922. unsigned long bytes= imp->errorInfo(NULL,0);
  2923. char string[bytes];
  2924. imp->errorInfo(string,bytes);
  2925. warning.setInformativeText(QString(string));
  2926. warning.setWindowTitle(QString(PROGRAM_NAME));
  2927. warning.exec();
  2928. /*:284*/
  2929. #line 6356 "./typica.w"
  2930. }
  2931. else
  2932. {
  2933. imp->ready= true;
  2934. }
  2935. }
  2936. /*:286*//*287:*/
  2937. #line 6370 "./typica.w"
  2938. Channel*DAQ::newChannel(int units,int thermocouple)
  2939. {
  2940. Channel*retval= new Channel();
  2941. imp->channelMap[imp->channels]= retval;
  2942. imp->unitMap[imp->channels]= (Units::Unit)units;
  2943. imp->channels++;
  2944. if(imp->ready)
  2945. {
  2946. if(imp->useBase)
  2947. {
  2948. imp->error= imp->createChannel(imp->handle,
  2949. QString("%1/ai%2").arg(imp->device).
  2950. arg(imp->channels-1).
  2951. toAscii().data(),
  2952. "",(double)(-1.0),(double)(100.0),
  2953. (signed long)(units),
  2954. (signed long)(thermocouple),
  2955. (signed long)(10200),(double)(0),
  2956. "");
  2957. }
  2958. else
  2959. {
  2960. imp->error= imp->createChannel(imp->handle,
  2961. QString("%1/ai%2").arg(imp->device).
  2962. arg(imp->channels-1).
  2963. toAscii().data(),
  2964. "",(double)(50.0),(double)(500.0),
  2965. (signed long)(units),
  2966. (signed long)(thermocouple),
  2967. (signed long)(10200),(double)(0),
  2968. "");
  2969. }
  2970. if(imp->error)
  2971. {
  2972. /*284:*/
  2973. #line 6277 "./typica.w"
  2974. imp->ready= false;
  2975. QMessageBox warning;
  2976. warning.setStandardButtons(QMessageBox::Cancel);
  2977. warning.setIcon(QMessageBox::Warning);
  2978. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2979. unsigned long bytes= imp->errorInfo(NULL,0);
  2980. char string[bytes];
  2981. imp->errorInfo(string,bytes);
  2982. warning.setInformativeText(QString(string));
  2983. warning.setWindowTitle(QString(PROGRAM_NAME));
  2984. warning.exec();
  2985. /*:284*/
  2986. #line 6405 "./typica.w"
  2987. }
  2988. }
  2989. return retval;
  2990. }
  2991. /*:287*//*288:*/
  2992. #line 6419 "./typica.w"
  2993. void DAQ::setClockRate(double Hz)
  2994. {
  2995. if(imp->ready)
  2996. {
  2997. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  2998. (signed long)(10280),(signed long)(10123),
  2999. (unsigned long long)(1));
  3000. if(imp->error)
  3001. {
  3002. /*284:*/
  3003. #line 6277 "./typica.w"
  3004. imp->ready= false;
  3005. QMessageBox warning;
  3006. warning.setStandardButtons(QMessageBox::Cancel);
  3007. warning.setIcon(QMessageBox::Warning);
  3008. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3009. unsigned long bytes= imp->errorInfo(NULL,0);
  3010. char string[bytes];
  3011. imp->errorInfo(string,bytes);
  3012. warning.setInformativeText(QString(string));
  3013. warning.setWindowTitle(QString(PROGRAM_NAME));
  3014. warning.exec();
  3015. /*:284*/
  3016. #line 6429 "./typica.w"
  3017. }
  3018. }
  3019. }
  3020. /*:288*//*289:*/
  3021. #line 6439 "./typica.w"
  3022. DAQ::~DAQ()
  3023. {
  3024. if(imp->useBase)
  3025. {
  3026. imp->resetDevice(imp->device.toAscii().data());
  3027. imp->clearTask(imp->handle);
  3028. }
  3029. else
  3030. {
  3031. if(imp->ready)
  3032. {
  3033. imp->ready= false;
  3034. imp->wait(ULONG_MAX);
  3035. imp->stopTask(imp->handle);
  3036. imp->resetDevice(imp->device.toAscii().data());
  3037. imp->clearTask(imp->handle);
  3038. }
  3039. }
  3040. delete imp;
  3041. }
  3042. /*:289*//*290:*/
  3043. #line 6470 "./typica.w"
  3044. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3045. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3046. unitMap(4)
  3047. {
  3048. if(driverinfo=="nidaqmxbase")
  3049. {
  3050. useBase= true;
  3051. }
  3052. else
  3053. {
  3054. useBase= false;
  3055. }
  3056. if(useBase)
  3057. {
  3058. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3059. if(!driver.load())
  3060. {
  3061. driver.setFileName("nidaqmxbase");
  3062. if(!driver.load())
  3063. {
  3064. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3065. tr("Failed to find nidaqmxbase. Please install it."));
  3066. QApplication::quit();
  3067. }
  3068. }
  3069. }
  3070. else
  3071. {
  3072. driver.setFileName("nicaiu");
  3073. if(!driver.load())
  3074. {
  3075. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3076. tr("Failed to find nidaqmx. Please install it."));
  3077. QApplication::quit();
  3078. }
  3079. }
  3080. if(useBase)
  3081. {
  3082. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3083. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3084. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3085. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3086. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3087. ==0||
  3088. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3089. 0||
  3090. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3091. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3092. 0||
  3093. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3094. {
  3095. waitForMeasurement= NULL;
  3096. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3097. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3098. QApplication::quit();
  3099. }
  3100. }
  3101. else
  3102. {
  3103. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3104. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3105. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3106. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3107. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3108. ==0||
  3109. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3110. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3111. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3112. 0||
  3113. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3114. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3115. {
  3116. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3117. tr("Failed to link a required symbol in NI-DAQmx."));
  3118. QApplication::quit();
  3119. }
  3120. }
  3121. }
  3122. DAQImplementation::~DAQImplementation()
  3123. {
  3124. driver.unload();
  3125. }
  3126. /*:290*/
  3127. #line 540 "./typica.w"
  3128. /*922:*/
  3129. #line 197 "./dataqsdk.w"
  3130. void DataqSdkDeviceImplementation::measure()
  3131. {
  3132. unsigned count= channels*40;
  3133. di_status_read(buffer,count);
  3134. QTime time= QTime::currentTime();
  3135. for(unsigned int i= 0;i<count;i++)
  3136. {
  3137. buffer[i]= buffer[i]&0xFFFC;
  3138. }
  3139. QList<int> countList;
  3140. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3141. {
  3142. QList<double> channelBuffer;
  3143. for(unsigned int j= 0;j<40;j++)
  3144. {
  3145. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3146. if(i==0)
  3147. {
  3148. countList<<buffer[i+(channels*j)];
  3149. }
  3150. }
  3151. double value= 0.0;
  3152. for(unsigned int j= 0;j<40;j++)
  3153. {
  3154. value+= channelBuffer[j];
  3155. }
  3156. value/= 40.0;
  3157. if(i==0)
  3158. {
  3159. QList<double> smoothingList;
  3160. smoothingList<<value;
  3161. QList<int> smoothingKeys= smoother.uniqueKeys();
  3162. for(int j= 0;j<smoothingKeys.size();j++)
  3163. {
  3164. if(countList.contains(smoothingKeys[j]))
  3165. {
  3166. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3167. for(int k= 0;k<keyValues.size();k++)
  3168. {
  3169. smoothingList<<keyValues[k];
  3170. }
  3171. }
  3172. else
  3173. {
  3174. smoother.remove(smoothingKeys[j]);
  3175. }
  3176. }
  3177. qSort(countList);
  3178. int lastCount= 0;
  3179. for(int j= 0;j<countList.size();j++)
  3180. {
  3181. if(j==0||countList[j]!=lastCount)
  3182. {
  3183. smoother.insert(countList[j],value);
  3184. lastCount= countList[j];
  3185. }
  3186. }
  3187. value= 0.0;
  3188. for(int j= 0;j<smoothingList.size();j++)
  3189. {
  3190. value+= smoothingList[j];
  3191. }
  3192. value/= smoothingList.size();
  3193. }
  3194. Measurement measure(value,time,unitMap[i]);
  3195. channelMap[i]->input(measure);
  3196. }
  3197. }
  3198. /*:922*//*923:*/
  3199. #line 290 "./dataqsdk.w"
  3200. void DataqSdkDeviceImplementation::run()
  3201. {
  3202. if(!ready)
  3203. {
  3204. error= 9;
  3205. return;
  3206. }
  3207. driver= new QLibrary(device);
  3208. if(!driver->load())
  3209. {
  3210. error= 1;
  3211. qDebug()<<"Failed to load driver: "<<device;
  3212. return;
  3213. }
  3214. di_open= (FPDIOPEN)driver->resolve("di_open");
  3215. di_close= (FPDICLOSE)driver->resolve("di_close");
  3216. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3217. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3218. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3219. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3220. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3221. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3222. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3223. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3224. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3225. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3226. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3227. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3228. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3229. (!di_burst_rate)||(!di_stop_scan))
  3230. {
  3231. error= 2;
  3232. return;
  3233. }
  3234. error= di_open(deviceNumber);
  3235. if(error)
  3236. {
  3237. di_close();
  3238. error= di_open(deviceNumber);
  3239. if(error)
  3240. {
  3241. error= 3;
  3242. di_close();
  3243. return;
  3244. }
  3245. }
  3246. isOpen= true;
  3247. di_maximum_rate(240.0);
  3248. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3249. &burstDivisor);
  3250. buffer= new qint16[(int)sampleRate];
  3251. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3252. for(unsigned short i= 0;i<channels;i++)
  3253. {
  3254. inlist[i].chan= i;
  3255. inlist[i].gain= 0;
  3256. inlist[i].ave= 1;
  3257. inlist[i].counter= (oversample-1);
  3258. }
  3259. error= di_list_length(channels,0);
  3260. if(error)
  3261. {
  3262. error= 4;
  3263. return;
  3264. }
  3265. error= di_inlist(inlist);
  3266. if(error)
  3267. {
  3268. error= 5;
  3269. return;
  3270. }
  3271. input_buffer= di_buffer_alloc(0,4096);
  3272. if(input_buffer==NULL)
  3273. {
  3274. error= 6;
  3275. return;
  3276. }
  3277. error= di_start_scan();
  3278. if(error)
  3279. {
  3280. error= 7;
  3281. return;
  3282. }
  3283. while(ready)
  3284. {
  3285. measure();
  3286. }
  3287. }
  3288. /*:923*//*924:*/
  3289. #line 386 "./dataqsdk.w"
  3290. void DataqSdkDevice::threadFinished()
  3291. {
  3292. if(imp->error)
  3293. {
  3294. /*925:*/
  3295. #line 400 "./dataqsdk.w"
  3296. imp->ready= false;
  3297. QMessageBox warning;
  3298. warning.setStandardButtons(QMessageBox::Cancel);
  3299. warning.setIcon(QMessageBox::Warning);
  3300. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3301. warning.setInformativeText(tr("An error occurred"));
  3302. warning.setWindowTitle(QString(PROGRAM_NAME));
  3303. warning.exec();
  3304. /*:925*/
  3305. #line 391 "./dataqsdk.w"
  3306. }
  3307. }
  3308. /*:924*//*926:*/
  3309. #line 417 "./dataqsdk.w"
  3310. void DataqSdkDevice::start()
  3311. {
  3312. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3313. imp->start();
  3314. }
  3315. /*:926*//*927:*/
  3316. #line 428 "./dataqsdk.w"
  3317. QStringList DataqSdkDevice::detectHardware()
  3318. {
  3319. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3320. QSettings::NativeFormat);
  3321. QStringList keys= deviceLookup.childKeys();
  3322. QStringList devices;
  3323. for(int i= 0;i<keys.size();i++)
  3324. {
  3325. QString value= deviceLookup.value(keys.at(i)).toString();
  3326. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3327. {
  3328. devices.append(value.split("\\").at(2));
  3329. }
  3330. }
  3331. QStringList portList;
  3332. foreach(QString device,devices)
  3333. {
  3334. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3335. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3336. portList.append(deviceEntry.value("FriendlyName").toString());
  3337. }
  3338. return portList;
  3339. }
  3340. QStringList DataqSdkDevice::detectPorts()
  3341. {
  3342. QStringList friendlyNames= detectHardware();
  3343. QStringList portList;
  3344. foreach(QString name,friendlyNames)
  3345. {
  3346. name.remove(0,name.indexOf("COM"));
  3347. name.chop(1);
  3348. portList.append(name);
  3349. }
  3350. return portList;
  3351. }
  3352. /*:927*//*928:*/
  3353. #line 473 "./dataqsdk.w"
  3354. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3355. {
  3356. bool usesAuto= false;
  3357. int autoIndex= device.toInt(&usesAuto);
  3358. QString finalizedPort;
  3359. if(usesAuto)
  3360. {
  3361. QStringList portList= detectPorts();
  3362. if(autoIndex> 0&&autoIndex<=portList.size())
  3363. {
  3364. finalizedPort= portList.at(autoIndex-1);
  3365. }
  3366. else
  3367. {
  3368. imp->error= 8;
  3369. qDebug()<<"Failed to detect port.";
  3370. }
  3371. }
  3372. else
  3373. {
  3374. finalizedPort= device;
  3375. }
  3376. int rstart= finalizedPort.indexOf("COM");
  3377. finalizedPort.remove(0,rstart+3);
  3378. bool chopFinished= false;
  3379. int finalizedPortNumber= 0;
  3380. while(finalizedPort.size()> 0&&!chopFinished)
  3381. {
  3382. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3383. if(!chopFinished)
  3384. {
  3385. finalizedPort.chop(1);
  3386. }
  3387. }
  3388. if(finalizedPortNumber<10)
  3389. {
  3390. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3391. }
  3392. else
  3393. {
  3394. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3395. }
  3396. imp->deviceNumber= 0x12C02D00;
  3397. imp->deviceNumber+= finalizedPortNumber;
  3398. imp->ready= true;
  3399. }
  3400. /*:928*//*929:*/
  3401. #line 523 "./dataqsdk.w"
  3402. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3403. {
  3404. Channel*retval= NULL;
  3405. if(imp->ready)
  3406. {
  3407. retval= new Channel();
  3408. imp->channelMap[imp->channels]= retval;
  3409. imp->unitMap[imp->channels]= scale;
  3410. imp->channels++;
  3411. }
  3412. return retval;
  3413. }
  3414. /*:929*//*930:*/
  3415. #line 547 "./dataqsdk.w"
  3416. void DataqSdkDevice::setClockRate(double Hz)
  3417. {
  3418. imp->sampleRate= Hz;
  3419. }
  3420. /*:930*//*931:*/
  3421. #line 557 "./dataqsdk.w"
  3422. DataqSdkDevice::~DataqSdkDevice()
  3423. {
  3424. if(imp->ready)
  3425. {
  3426. imp->ready= false;
  3427. }
  3428. imp->wait(ULONG_MAX);
  3429. delete imp;
  3430. }
  3431. /*:931*//*932:*/
  3432. #line 575 "./dataqsdk.w"
  3433. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3434. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3435. {
  3436. }
  3437. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3438. {
  3439. if(isOpen)
  3440. {
  3441. di_stop_scan();
  3442. di_close();
  3443. }
  3444. if(driver->isLoaded())
  3445. {
  3446. driver->unload();
  3447. }
  3448. }
  3449. /*:932*/
  3450. #line 541 "./typica.w"
  3451. /*297:*/
  3452. #line 6679 "./typica.w"
  3453. void FakeDAQImplementation::measure()
  3454. {
  3455. msleep((int)(1000/clockRate));
  3456. QTime time= QTime::currentTime();
  3457. for(int i= 0;i<channels;i++)
  3458. {
  3459. Measurement measure(qrand()%500,time);
  3460. channelMap[i]->input(measure);
  3461. }
  3462. }
  3463. /*:297*//*298:*/
  3464. #line 6693 "./typica.w"
  3465. void FakeDAQImplementation::run()
  3466. {
  3467. setPriority(QThread::TimeCriticalPriority);
  3468. while(ready)
  3469. {
  3470. measure();
  3471. }
  3472. }
  3473. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3474. channels(0),ready(false),clockRate(1)
  3475. {
  3476. }
  3477. FakeDAQImplementation::~FakeDAQImplementation()
  3478. {
  3479. }
  3480. /*:298*//*299:*/
  3481. #line 6718 "./typica.w"
  3482. void FakeDAQ::start()
  3483. {
  3484. if(imp->ready)
  3485. {
  3486. imp->start();
  3487. }
  3488. }
  3489. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3490. {
  3491. imp->ready= true;
  3492. }
  3493. Channel*FakeDAQ::newChannel(int,int)
  3494. {
  3495. Channel*retval;
  3496. if(imp->ready)
  3497. {
  3498. retval= new Channel();
  3499. imp->channelMap[imp->channels]= retval;
  3500. imp->channels++;
  3501. }
  3502. else
  3503. {
  3504. return NULL;
  3505. }
  3506. return retval;
  3507. }
  3508. void FakeDAQ::setClockRate(double Hz)
  3509. {
  3510. if(imp->ready)
  3511. {
  3512. imp->clockRate= Hz;
  3513. }
  3514. }
  3515. FakeDAQ::~FakeDAQ()
  3516. {
  3517. imp->ready= false;
  3518. imp->wait(ULONG_MAX);
  3519. delete imp;
  3520. }
  3521. /*:299*/
  3522. #line 542 "./typica.w"
  3523. /*304:*/
  3524. #line 6849 "./typica.w"
  3525. Channel::Channel():QObject(NULL)
  3526. {
  3527. }
  3528. Channel::~Channel()
  3529. {
  3530. }
  3531. void Channel::input(Measurement measurement)
  3532. {
  3533. emit newData(measurement);
  3534. }
  3535. /*:304*/
  3536. #line 543 "./typica.w"
  3537. /*320:*/
  3538. #line 7254 "./typica.w"
  3539. void TemperatureDisplay::setRelativeMode(bool relative)
  3540. {
  3541. r= relative;
  3542. }
  3543. /*:320*//*321:*/
  3544. #line 7271 "./typica.w"
  3545. void TemperatureDisplay::setValue(Measurement temperature)
  3546. {
  3547. QString number;
  3548. switch(unit)
  3549. {
  3550. case Units::Fahrenheit:
  3551. display(QString("%1'F").
  3552. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3553. 2)));
  3554. break;
  3555. case Units::Celsius:
  3556. if(!r){
  3557. display(QString("%1'C").
  3558. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3559. 2)));
  3560. }else{
  3561. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3562. display(QString("%1'C").arg(number));
  3563. }
  3564. break;
  3565. case Units::Kelvin:
  3566. if(!r){
  3567. display(QString("%1").
  3568. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3569. 2)));
  3570. }else{
  3571. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3572. display(QString("%1").arg(number));
  3573. }
  3574. break;
  3575. case Units::Rankine:
  3576. display(QString("%1'r").
  3577. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3578. 2)));
  3579. break;
  3580. case Units::Unitless:
  3581. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3582. break;
  3583. default:
  3584. switch(temperature.scale())
  3585. {
  3586. case Units::Fahrenheit:
  3587. display(QString("%1'F").
  3588. arg(number.setNum(temperature.temperature(),'f',2)));
  3589. break;
  3590. case Units::Celsius:
  3591. display(QString("%1'C").
  3592. arg(number.setNum(temperature.temperature(),'f',2)));
  3593. break;
  3594. case Units::Kelvin:
  3595. display(QString("%1").
  3596. arg(number.setNum(temperature.temperature(),'f',2)));
  3597. break;
  3598. case Units::Rankine:
  3599. display(QString("%1'r").
  3600. arg(number.setNum(temperature.temperature(),'f',2)));
  3601. break;
  3602. case Units::Unitless:
  3603. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3604. break;
  3605. }
  3606. break;
  3607. }
  3608. }
  3609. /*:321*//*322:*/
  3610. #line 7347 "./typica.w"
  3611. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3612. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3613. {
  3614. setSegmentStyle(Filled);
  3615. display("---.--'F");
  3616. }
  3617. /*:322*//*323:*/
  3618. #line 7363 "./typica.w"
  3619. void TemperatureDisplay::invalidate()
  3620. {
  3621. display("---.--'F");
  3622. }
  3623. /*:323*//*324:*/
  3624. #line 7375 "./typica.w"
  3625. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3626. {
  3627. unit= scale;
  3628. }
  3629. /*:324*//*325:*/
  3630. #line 7383 "./typica.w"
  3631. TemperatureDisplay::~TemperatureDisplay()
  3632. {
  3633. }
  3634. /*:325*/
  3635. #line 544 "./typica.w"
  3636. /*331:*/
  3637. #line 7483 "./typica.w"
  3638. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3639. {
  3640. if(measure.time()<epoch)
  3641. {
  3642. if(hasPrevious)
  3643. {
  3644. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3645. epoch.msec());
  3646. QTime jitComp(epoch.hour(),measure.time().minute(),
  3647. measure.time().second(),measure.time().msec());
  3648. int relTime= jitBase.msecsTo(jitComp);
  3649. /*332:*/
  3650. #line 7517 "./typica.w"
  3651. QTime newTime(0,0,0,0);
  3652. newTime= newTime.addMSecs(relTime);
  3653. if(newTime.hour()> 0)
  3654. {
  3655. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3656. }
  3657. Measurement rel= measure;
  3658. rel.setTime(newTime);
  3659. emit measurement(rel);
  3660. /*:332*/
  3661. #line 7495 "./typica.w"
  3662. }
  3663. else
  3664. {
  3665. Measurement rel= measure;
  3666. rel.setTime(QTime(0,0,0,0));
  3667. emit measurement(rel);
  3668. }
  3669. }
  3670. else
  3671. {
  3672. int relTime= epoch.msecsTo(measure.time());
  3673. /*332:*/
  3674. #line 7517 "./typica.w"
  3675. QTime newTime(0,0,0,0);
  3676. newTime= newTime.addMSecs(relTime);
  3677. if(newTime.hour()> 0)
  3678. {
  3679. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3680. }
  3681. Measurement rel= measure;
  3682. rel.setTime(newTime);
  3683. emit measurement(rel);
  3684. /*:332*/
  3685. #line 7507 "./typica.w"
  3686. }
  3687. hasPrevious= true;
  3688. previous= measure.time();
  3689. }
  3690. /*:331*//*333:*/
  3691. #line 7530 "./typica.w"
  3692. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3693. previous(0,0,0,0),hasPrevious(false)
  3694. {
  3695. }
  3696. QTime MeasurementTimeOffset::zeroTime()
  3697. {
  3698. return epoch;
  3699. }
  3700. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3701. {
  3702. epoch= zero;
  3703. hasPrevious= false;
  3704. }
  3705. /*:333*/
  3706. #line 545 "./typica.w"
  3707. /*343:*/
  3708. #line 7728 "./typica.w"
  3709. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3710. {
  3711. }
  3712. int ZeroEmitter::column()
  3713. {
  3714. return col;
  3715. }
  3716. double ZeroEmitter::lastTemperature()
  3717. {
  3718. return cache.temperature();
  3719. }
  3720. void ZeroEmitter::newMeasurement(Measurement measure)
  3721. {
  3722. cache= measure;
  3723. }
  3724. void ZeroEmitter::setColumn(int column)
  3725. {
  3726. col= column;
  3727. }
  3728. void ZeroEmitter::emitZero()
  3729. {
  3730. cache.setTime(QTime(0,0,0,0));
  3731. emit measurement(cache,col);
  3732. }
  3733. /*:343*/
  3734. #line 546 "./typica.w"
  3735. /*348:*/
  3736. #line 7818 "./typica.w"
  3737. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3738. {
  3739. }
  3740. int MeasurementAdapter::column()
  3741. {
  3742. return col;
  3743. }
  3744. void MeasurementAdapter::newMeasurement(Measurement measure)
  3745. {
  3746. emit measurement(measure,col);
  3747. }
  3748. void MeasurementAdapter::setColumn(int column)
  3749. {
  3750. col= column;
  3751. }
  3752. /*:348*/
  3753. #line 547 "./typica.w"
  3754. /*353:*/
  3755. #line 7940 "./typica.w"
  3756. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3757. theScene(new QGraphicsScene),
  3758. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3759. prevPoints(new QMap<int,QPointF> ),
  3760. translations(new QMap<int,double> ),
  3761. gridLinesF(new QList<QGraphicsItem*> ),
  3762. gridLinesC(new QList<QGraphicsItem*> ),
  3763. relativeGridLines(new QList<QGraphicsItem*> ),
  3764. relativeEnabled(false),
  3765. timeIndicatorEnabled(false),
  3766. timeLine(new QGraphicsLineItem),
  3767. relativeAdjuster(new LinearSplineInterpolator)
  3768. {
  3769. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3770. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3771. setScene(theScene);
  3772. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3773. QPen timePen;
  3774. timePen.setColor(QColor(160,160,164,127));
  3775. timeLine->setPen(timePen);
  3776. timeLine->setLine(0,0,0,-500);
  3777. timeLine->hide();
  3778. theScene->addItem(timeLine);
  3779. /*354:*/
  3780. #line 7980 "./typica.w"
  3781. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3782. tempaxis->setLine(-10,-500,-10,0);
  3783. theScene->addItem(tempaxis);
  3784. QGraphicsLineItem*gridLine;
  3785. QGraphicsTextItem*label;
  3786. for(int y= -100;y> -600;y-= 100)
  3787. {
  3788. gridLine= new QGraphicsLineItem;
  3789. gridLine->setLine(0,y,1200,y);
  3790. theScene->addItem(gridLine);
  3791. label= new QGraphicsTextItem;
  3792. label->setHtml(QString("%1&deg;F").arg(-y));
  3793. label->setPos(-55,y-(label->boundingRect().height()/2));
  3794. theScene->addItem(label);
  3795. gridLinesF->append(gridLine);
  3796. gridLinesF->append(label);
  3797. }
  3798. for(int degC= 50;degC<=250;degC+= 50)
  3799. {
  3800. gridLine= new QGraphicsLineItem;
  3801. int y= -(degC*(9.0/5.0)+32);
  3802. gridLine->setLine(0,y,1200,y);
  3803. gridLine->hide();
  3804. theScene->addItem(gridLine);
  3805. gridLinesC->append(gridLine);
  3806. label= new QGraphicsTextItem;
  3807. label->setHtml(QString("%1&deg;C").arg(degC));
  3808. label->setPos(-55,y-(label->boundingRect().height()/2));
  3809. label->hide();
  3810. theScene->addItem(label);
  3811. gridLinesC->append(label);
  3812. }
  3813. /*:354*/
  3814. #line 7964 "./typica.w"
  3815. ;
  3816. /*355:*/
  3817. #line 8021 "./typica.w"
  3818. QSettings settings;
  3819. if(settings.contains("settings/graph/relative/enable"))
  3820. {
  3821. if(settings.value("settings/graph/relative/enable").toBool())
  3822. {
  3823. relativeEnabled= true;
  3824. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  3825. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  3826. QMap<double,QString> relativeAxisPairs;
  3827. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  3828. foreach(QString item,relativeAxisLabels)
  3829. {
  3830. relativeAxisPairs.insert(item.toDouble(),item);
  3831. }
  3832. if(relativeAxisPairs.size()> 1)
  3833. {
  3834. double skip= 500.0/(relativeAxisPairs.size()-1);
  3835. double y= 0;
  3836. foreach(double key,relativeAxisPairs.keys())
  3837. {
  3838. gridLine= new QGraphicsLineItem;
  3839. gridLine->setLine(0,y,1205,y);
  3840. gridLine->setPen(QPen(relativeColor));
  3841. theScene->addItem(gridLine);
  3842. relativeGridLines->append(gridLine);
  3843. label= new QGraphicsTextItem;
  3844. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  3845. label->setPos(1210,y-(label->boundingRect().height()/2));
  3846. theScene->addItem(label);
  3847. relativeGridLines->append(label);
  3848. if(unit=="F")
  3849. {
  3850. relativeAdjuster->add_pair(key,-y);
  3851. }
  3852. else
  3853. {
  3854. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  3855. }
  3856. y-= skip;
  3857. }
  3858. }
  3859. }
  3860. }
  3861. /*:355*/
  3862. #line 7965 "./typica.w"
  3863. /*357:*/
  3864. #line 8098 "./typica.w"
  3865. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  3866. timeaxis->setLine(0,10,1200,10);
  3867. theScene->addItem(timeaxis);
  3868. for(int x= 0;x<1201;x+= 120)
  3869. {
  3870. QGraphicsLineItem*tick= new QGraphicsLineItem;
  3871. tick->setLine(x,0,x,20);
  3872. theScene->addItem(tick);
  3873. QGraphicsTextItem*label= new QGraphicsTextItem;
  3874. label->setPlainText(QString("%1").arg(x/60));
  3875. label->setPos(x-(label->boundingRect().width()/2),20);
  3876. theScene->addItem(label);
  3877. }
  3878. /*:357*/
  3879. #line 7966 "./typica.w"
  3880. ;
  3881. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3882. }
  3883. /*:353*//*356:*/
  3884. #line 8068 "./typica.w"
  3885. void GraphView::showF()
  3886. {
  3887. for(int i= 0;i<gridLinesF->size();i++)
  3888. {
  3889. gridLinesF->at(i)->show();
  3890. }
  3891. for(int i= 0;i<gridLinesC->size();i++)
  3892. {
  3893. gridLinesC->at(i)->hide();
  3894. }
  3895. }
  3896. void GraphView::showC()
  3897. {
  3898. for(int i= 0;i<gridLinesF->size();i++)
  3899. {
  3900. gridLinesF->at(i)->hide();
  3901. }
  3902. for(int i= 0;i<gridLinesC->size();i++)
  3903. {
  3904. gridLinesC->at(i)->show();
  3905. }
  3906. }
  3907. /*:356*//*358:*/
  3908. #line 8117 "./typica.w"
  3909. void GraphView::resizeEvent(QResizeEvent*)
  3910. {
  3911. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3912. }
  3913. /*:358*//*359:*/
  3914. #line 8131 "./typica.w"
  3915. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  3916. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  3917. {
  3918. double offset= 0;
  3919. if(measure.contains("relative"))
  3920. {
  3921. if(measure.value("relative").toBool())
  3922. {
  3923. if(relativeEnabled)
  3924. {
  3925. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  3926. }
  3927. else
  3928. {
  3929. return;
  3930. }
  3931. }
  3932. }
  3933. if(translations->contains(tempcolumn))
  3934. {
  3935. offset= translations->value(tempcolumn);
  3936. }
  3937. if(prevPoints->contains(tempcolumn))
  3938. {
  3939. /*361:*/
  3940. #line 8208 "./typica.w"
  3941. QGraphicsLineItem*segment= new QGraphicsLineItem;
  3942. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  3943. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  3944. -(prevPoints->value(tempcolumn).y()),
  3945. nextPoint.x()+offset,-(nextPoint.y()));
  3946. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  3947. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  3948. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  3949. Qt::darkYellow};
  3950. segment->setPen(p[tempcolumn%12]);
  3951. theScene->addItem(segment);
  3952. prevPoints->insert(tempcolumn,nextPoint);
  3953. if(timeIndicatorEnabled)
  3954. {
  3955. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  3956. }
  3957. /*:361*/
  3958. #line 8157 "./typica.w"
  3959. if(graphLines->contains(tempcolumn))
  3960. {
  3961. graphLines->value(tempcolumn)->append(segment);
  3962. }
  3963. else
  3964. {
  3965. QList<QGraphicsLineItem*> *newLine=
  3966. new QList<QGraphicsLineItem*> ;
  3967. newLine->append(segment);
  3968. graphLines->insert(tempcolumn,newLine);
  3969. }
  3970. }
  3971. else
  3972. {
  3973. /*360:*/
  3974. #line 8193 "./typica.w"
  3975. int x= FULLTIMETOINT(measure.time())/1000;
  3976. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  3977. if(timeIndicatorEnabled)
  3978. {
  3979. timeLine->setLine(x,0,x,-500);
  3980. }
  3981. /*:360*/
  3982. #line 8174 "./typica.w"
  3983. }
  3984. }
  3985. /*:359*//*362:*/
  3986. #line 8229 "./typica.w"
  3987. void GraphView::clear()
  3988. {
  3989. int i;
  3990. foreach(i,prevPoints->keys())
  3991. {
  3992. removeSeries(i);
  3993. }
  3994. translations->clear();
  3995. }
  3996. /*:362*//*363:*/
  3997. #line 8243 "./typica.w"
  3998. void GraphView::removeSeries(int column)
  3999. {
  4000. if(graphLines->contains(column))
  4001. {
  4002. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4003. QGraphicsLineItem*segment;
  4004. foreach(segment,*series)
  4005. {
  4006. theScene->removeItem(segment);
  4007. }
  4008. qDeleteAll(*series);
  4009. }
  4010. graphLines->remove(column);
  4011. prevPoints->remove(column);
  4012. }
  4013. /*:363*//*364:*/
  4014. #line 8262 "./typica.w"
  4015. void GraphView::setSeriesTranslation(int column,double offset)
  4016. {
  4017. if(graphLines->contains(column))
  4018. {
  4019. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4020. QGraphicsLineItem*segment;
  4021. foreach(segment,*series)
  4022. {
  4023. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4024. }
  4025. }
  4026. if(translations->contains(column))
  4027. {
  4028. translations->insert(column,offset+translations->value(column));
  4029. }
  4030. else
  4031. {
  4032. translations->insert(column,offset);
  4033. }
  4034. }
  4035. /*:364*//*365:*/
  4036. #line 8289 "./typica.w"
  4037. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4038. {
  4039. timeIndicatorEnabled= enabled;
  4040. if(enabled)
  4041. {
  4042. timeLine->show();
  4043. }
  4044. else
  4045. {
  4046. timeLine->hide();
  4047. }
  4048. }
  4049. /*:365*/
  4050. #line 548 "./typica.w"
  4051. /*371:*/
  4052. #line 8433 "./typica.w"
  4053. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4054. {
  4055. if(measure.time()!=QTime(0,0,0,0))
  4056. {
  4057. /*373:*/
  4058. #line 8507 "./typica.w"
  4059. if(lastMeasurement.contains(tempcolumn))
  4060. {
  4061. if(lastMeasurement[tempcolumn].time()<measure.time())
  4062. {
  4063. QList<QTime> timelist;
  4064. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4065. {
  4066. timelist.append(i);
  4067. }
  4068. for(int i= 0;i<timelist.size();i++)
  4069. {
  4070. Measurement synthesized= measure;
  4071. synthesized.setTime(timelist[i]);
  4072. newMeasurement(synthesized,tempcolumn);
  4073. }
  4074. }
  4075. }
  4076. /*:373*/
  4077. #line 8438 "./typica.w"
  4078. }
  4079. model_ms->newMeasurement(measure,tempcolumn);
  4080. if(lastMeasurement.contains(tempcolumn))
  4081. {
  4082. if(measure.time().second()!=
  4083. lastMeasurement.value(tempcolumn).time().second())
  4084. {
  4085. Measurement adjusted= measure;
  4086. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4087. adjusted.setTime(adjtime);
  4088. model_1s->newMeasurement(adjusted,tempcolumn);
  4089. if(adjusted.time().second()%5==0)
  4090. {
  4091. model_5s->newMeasurement(adjusted,tempcolumn);
  4092. if(adjusted.time().second()%10==0)
  4093. {
  4094. model_10s->newMeasurement(adjusted,tempcolumn);
  4095. }
  4096. if(adjusted.time().second()%15==0)
  4097. {
  4098. model_15s->newMeasurement(adjusted,tempcolumn);
  4099. if(adjusted.time().second()%30==0)
  4100. {
  4101. model_30s->newMeasurement(adjusted,tempcolumn);
  4102. if(adjusted.time().second()==0)
  4103. {
  4104. model_1m->newMeasurement(adjusted,tempcolumn);
  4105. }
  4106. }
  4107. }
  4108. }
  4109. }
  4110. /*375:*/
  4111. #line 8551 "./typica.w"
  4112. if(currentColumnSet.contains(tempcolumn))
  4113. {
  4114. int replicationcolumn;
  4115. foreach(replicationcolumn,currentColumnSet)
  4116. {
  4117. if(replicationcolumn!=tempcolumn)
  4118. {
  4119. if(lastMeasurement.contains(replicationcolumn))
  4120. {
  4121. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4122. {
  4123. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4124. synthetic.setTime(measure.time());
  4125. model_ms->newMeasurement(synthetic,replicationcolumn);
  4126. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4127. {
  4128. Measurement adjusted= synthetic;
  4129. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4130. model_1s->newMeasurement(adjusted,replicationcolumn);
  4131. if(adjusted.time().second()%5==0)
  4132. {
  4133. model_5s->newMeasurement(adjusted,replicationcolumn);
  4134. if(adjusted.time().second()%10==0)
  4135. {
  4136. model_10s->newMeasurement(adjusted,replicationcolumn);
  4137. }
  4138. if(adjusted.time().second()%15==0)
  4139. {
  4140. model_15s->newMeasurement(adjusted,replicationcolumn);
  4141. if(adjusted.time().second()%30==0)
  4142. {
  4143. model_30s->newMeasurement(adjusted,replicationcolumn);
  4144. if(adjusted.time().second()==0)
  4145. {
  4146. model_1m->newMeasurement(adjusted,replicationcolumn);
  4147. }
  4148. }
  4149. }
  4150. }
  4151. }
  4152. lastMeasurement[replicationcolumn]= synthetic;
  4153. }
  4154. }
  4155. }
  4156. }
  4157. }
  4158. /*:375*/
  4159. #line 8471 "./typica.w"
  4160. }
  4161. else
  4162. {
  4163. /*372:*/
  4164. #line 8483 "./typica.w"
  4165. MeasurementModel*m;
  4166. foreach(m,modelSet)
  4167. {
  4168. m->newMeasurement(measure,tempcolumn);
  4169. }
  4170. /*:372*/
  4171. #line 8475 "./typica.w"
  4172. }
  4173. lastMeasurement.insert(tempcolumn,measure);
  4174. }
  4175. /*:371*//*374:*/
  4176. #line 8537 "./typica.w"
  4177. void ZoomLog::addToCurrentColumnSet(int column)
  4178. {
  4179. currentColumnSet.append(column);
  4180. }
  4181. void ZoomLog::clearCurrentColumnSet()
  4182. {
  4183. currentColumnSet.clear();
  4184. }
  4185. /*:374*//*376:*/
  4186. #line 8621 "./typica.w"
  4187. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4188. int annotationcolumn)
  4189. {
  4190. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4191. MeasurementModel*m;
  4192. if(lastMeasurement.contains(tempcolumn))
  4193. {
  4194. foreach(m,modelSet)
  4195. {
  4196. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4197. }
  4198. }
  4199. foreach(m,modelSet)
  4200. {
  4201. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4202. }
  4203. }
  4204. /*:376*//*377:*/
  4205. #line 8645 "./typica.w"
  4206. void ZoomLog::centerOn(int row)
  4207. {
  4208. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4209. }
  4210. /*:377*//*378:*/
  4211. #line 8655 "./typica.w"
  4212. void ZoomLog::clear()
  4213. {
  4214. MeasurementModel*m;
  4215. foreach(m,modelSet)
  4216. {
  4217. m->clear();
  4218. }
  4219. lastMeasurement.clear();
  4220. saveTempCols.clear();
  4221. saveControlCols.clear();
  4222. saveNoteCols.clear();
  4223. }
  4224. /*:378*//*379:*/
  4225. #line 8673 "./typica.w"
  4226. QVariant ZoomLog::data(int row,int column)const
  4227. {
  4228. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4229. Qt::DisplayRole);
  4230. }
  4231. int ZoomLog::rowCount()
  4232. {
  4233. return model_ms->rowCount();
  4234. }
  4235. /*:379*//*380:*/
  4236. #line 8696 "./typica.w"
  4237. bool ZoomLog::saveXML(QIODevice*device)
  4238. {
  4239. Units::Unit prevUnits= model_ms->displayUnits();
  4240. if(prevUnits!=Units::Fahrenheit)
  4241. {
  4242. model_ms->setDisplayUnits(Units::Fahrenheit);
  4243. }
  4244. XMLOutput writer(model_ms,device,0);
  4245. int c;
  4246. foreach(c,saveTempCols)
  4247. {
  4248. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4249. toString(),c);
  4250. }
  4251. foreach(c,saveControlCols)
  4252. {
  4253. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4254. toString(),c);
  4255. }
  4256. foreach(c,saveNoteCols)
  4257. {
  4258. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4259. toString(),c);
  4260. }
  4261. bool retval= writer.output();
  4262. if(prevUnits!=Units::Fahrenheit)
  4263. {
  4264. model_ms->setDisplayUnits(prevUnits);
  4265. }
  4266. return retval;
  4267. }
  4268. /*:380*//*381:*/
  4269. #line 8732 "./typica.w"
  4270. bool ZoomLog::saveCSV(QIODevice*device)
  4271. {
  4272. CSVOutput writer(currentModel,device,0);
  4273. int c;
  4274. foreach(c,saveTempCols)
  4275. {
  4276. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4277. toString(),c);
  4278. }
  4279. foreach(c,saveControlCols)
  4280. {
  4281. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4282. toString(),c);
  4283. }
  4284. foreach(c,saveNoteCols)
  4285. {
  4286. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4287. toString(),c);
  4288. }
  4289. return writer.output();
  4290. }
  4291. /*:381*//*382:*/
  4292. #line 8761 "./typica.w"
  4293. void ZoomLog::switchLOD(MeasurementModel*m)
  4294. {
  4295. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4296. setModel(m);
  4297. currentModel= m;
  4298. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4299. }
  4300. void ZoomLog::LOD_ms()
  4301. {
  4302. switchLOD(model_ms);
  4303. }
  4304. void ZoomLog::LOD_1s()
  4305. {
  4306. switchLOD(model_1s);
  4307. }
  4308. void ZoomLog::LOD_5s()
  4309. {
  4310. switchLOD(model_5s);
  4311. }
  4312. void ZoomLog::LOD_10s()
  4313. {
  4314. switchLOD(model_10s);
  4315. }
  4316. void ZoomLog::LOD_15s()
  4317. {
  4318. switchLOD(model_15s);
  4319. }
  4320. void ZoomLog::LOD_30s()
  4321. {
  4322. switchLOD(model_30s);
  4323. }
  4324. void ZoomLog::LOD_1m()
  4325. {
  4326. switchLOD(model_1m);
  4327. }
  4328. /*:382*//*383:*/
  4329. #line 8809 "./typica.w"
  4330. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4331. {
  4332. model_ms->setDisplayUnits(scale);
  4333. model_1s->setDisplayUnits(scale);
  4334. model_5s->setDisplayUnits(scale);
  4335. model_10s->setDisplayUnits(scale);
  4336. model_15s->setDisplayUnits(scale);
  4337. model_30s->setDisplayUnits(scale);
  4338. model_1m->setDisplayUnits(scale);
  4339. }
  4340. Units::Unit ZoomLog::displayUnits()
  4341. {
  4342. return model_ms->displayUnits();
  4343. }
  4344. /*:383*//*384:*/
  4345. #line 8829 "./typica.w"
  4346. QString ZoomLog::lastTime(int series)
  4347. {
  4348. Measurement measure= lastMeasurement.value(series);
  4349. QTime time= measure.time();
  4350. return time.toString("h:mm:ss.zzz");
  4351. }
  4352. /*:384*//*385:*/
  4353. #line 8839 "./typica.w"
  4354. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4355. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4356. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4357. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4358. {
  4359. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4360. setSelectionMode(QAbstractItemView::NoSelection);
  4361. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4362. model_30s<<model_1m;
  4363. currentModel= model_30s;
  4364. setModel(currentModel);
  4365. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4366. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4367. this,SLOT(persistColumnResize(int,int,int)));
  4368. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4369. this,SLOT(restoreColumnWidths()));
  4370. }
  4371. /*:385*//*386:*/
  4372. #line 8862 "./typica.w"
  4373. void ZoomLog::setHeaderData(int section,QString text)
  4374. {
  4375. MeasurementModel*m;
  4376. foreach(m,modelSet)
  4377. {
  4378. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4379. }
  4380. }
  4381. /*:386*//*387:*/
  4382. #line 8880 "./typica.w"
  4383. void ZoomLog::addOutputTemperatureColumn(int column)
  4384. {
  4385. saveTempCols.append(column);
  4386. }
  4387. void ZoomLog::addOutputControlColumn(int column)
  4388. {
  4389. saveControlCols.append(column);
  4390. }
  4391. void ZoomLog::addOutputAnnotationColumn(int column)
  4392. {
  4393. saveNoteCols.append(column);
  4394. }
  4395. void ZoomLog::clearOutputColumns()
  4396. {
  4397. saveTempCols.clear();
  4398. saveControlCols.clear();
  4399. saveNoteCols.clear();
  4400. }
  4401. /*:387*//*388:*/
  4402. #line 8906 "./typica.w"
  4403. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4404. {
  4405. /*602:*/
  4406. #line 13011 "./typica.w"
  4407. QSettings settings;
  4408. /*603:*/
  4409. #line 13024 "./typica.w"
  4410. QWidget*topLevelWidget= this;
  4411. while(topLevelWidget->parentWidget())
  4412. {
  4413. topLevelWidget= topLevelWidget->parentWidget();
  4414. }
  4415. /*:603*/
  4416. #line 13013 "./typica.w"
  4417. settings.setValue(QString("columnWidths/%1/%2/%3").
  4418. arg(topLevelWidget->objectName()).
  4419. arg(objectName()).arg(column),
  4420. QVariant(newsize));
  4421. /*:602*/
  4422. #line 8909 "./typica.w"
  4423. }
  4424. void ZoomLog::restoreColumnWidths()
  4425. {
  4426. /*605:*/
  4427. #line 13044 "./typica.w"
  4428. QSettings settings;
  4429. /*603:*/
  4430. #line 13024 "./typica.w"
  4431. QWidget*topLevelWidget= this;
  4432. while(topLevelWidget->parentWidget())
  4433. {
  4434. topLevelWidget= topLevelWidget->parentWidget();
  4435. }
  4436. /*:603*/
  4437. #line 13046 "./typica.w"
  4438. QString baseKey=
  4439. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4440. arg(objectName());
  4441. for(int i= 0;i<model()->columnCount();i++)
  4442. {
  4443. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4444. if(settings.contains(key))
  4445. {
  4446. setColumnWidth(i,settings.value(key).toInt());
  4447. }
  4448. }
  4449. /*:605*/
  4450. #line 8914 "./typica.w"
  4451. }
  4452. void ZoomLog::setVisible(bool visibility)
  4453. {
  4454. QTableView::setVisible(visibility);
  4455. }
  4456. void ZoomLog::showEvent(QShowEvent*)
  4457. {
  4458. /*605:*/
  4459. #line 13044 "./typica.w"
  4460. QSettings settings;
  4461. /*603:*/
  4462. #line 13024 "./typica.w"
  4463. QWidget*topLevelWidget= this;
  4464. while(topLevelWidget->parentWidget())
  4465. {
  4466. topLevelWidget= topLevelWidget->parentWidget();
  4467. }
  4468. /*:603*/
  4469. #line 13046 "./typica.w"
  4470. QString baseKey=
  4471. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4472. arg(objectName());
  4473. for(int i= 0;i<model()->columnCount();i++)
  4474. {
  4475. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4476. if(settings.contains(key))
  4477. {
  4478. setColumnWidth(i,settings.value(key).toInt());
  4479. }
  4480. }
  4481. /*:605*/
  4482. #line 8924 "./typica.w"
  4483. }
  4484. /*:388*/
  4485. #line 549 "./typica.w"
  4486. /*397:*/
  4487. #line 9157 "./typica.w"
  4488. bool MeasurementList::operator<(const MeasurementList&other)const
  4489. {
  4490. return this->first().toTime()<other.first().toTime();
  4491. }
  4492. bool MeasurementList::operator==(const MeasurementList&other)const
  4493. {
  4494. return this->first().toTime()==other.first().toTime();
  4495. }
  4496. /*:397*//*398:*/
  4497. #line 9173 "./typica.w"
  4498. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4499. {
  4500. return QModelIndex();
  4501. }
  4502. /*:398*//*399:*/
  4503. #line 9183 "./typica.w"
  4504. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4505. {
  4506. if(measure.scale()==Units::Unitless)
  4507. {
  4508. controlColumns->insert(tempcolumn,true);
  4509. }
  4510. else
  4511. {
  4512. controlColumns->insert(tempcolumn,false);
  4513. }
  4514. MeasurementList*temp;
  4515. temp= new MeasurementList;
  4516. temp->append(QVariant(measure.time()));
  4517. /*400:*/
  4518. #line 9242 "./typica.w"
  4519. /*401:*/
  4520. #line 9287 "./typica.w"
  4521. QList<MeasurementList*> ::iterator i= lastInsertion;
  4522. bool quickscan= false;
  4523. if(entries->size()> 5)
  4524. {
  4525. if(**i<*temp)
  4526. {
  4527. i+= 1;
  4528. for(int j= 10;j> 0;j--)
  4529. {
  4530. if(i!=entries->end())
  4531. {
  4532. if(**i<*temp)
  4533. {
  4534. i+= 1;
  4535. }
  4536. else
  4537. {
  4538. quickscan= true;
  4539. break;
  4540. }
  4541. }
  4542. else
  4543. {
  4544. quickscan= true;
  4545. break;
  4546. }
  4547. }
  4548. }
  4549. else
  4550. {
  4551. if(**i==*temp)
  4552. {
  4553. quickscan= true;
  4554. }
  4555. }
  4556. }
  4557. /*:401*/
  4558. #line 9243 "./typica.w"
  4559. if(quickscan==false)
  4560. {
  4561. i= entries->begin();
  4562. QList<MeasurementList*> ::iterator u= entries->end();
  4563. QList<MeasurementList*> ::iterator midpoint;
  4564. int n= u-i;
  4565. int rA;
  4566. while(n> 0)
  4567. {
  4568. rA= n>>1;
  4569. midpoint= i+rA;
  4570. if(**midpoint<*temp)
  4571. {
  4572. i= midpoint+1;
  4573. n-= rA+1;
  4574. }
  4575. else
  4576. {
  4577. n= rA;
  4578. }
  4579. }
  4580. }
  4581. /*:400*/
  4582. #line 9197 "./typica.w"
  4583. MeasurementList*newEntry;
  4584. int insertion;
  4585. if(i!=entries->end())
  4586. {
  4587. insertion= entries->indexOf(*i);
  4588. if((*i)->first().toTime()==measure.time())
  4589. {
  4590. /*402:*/
  4591. #line 9329 "./typica.w"
  4592. if((*i)->size()<tempcolumn+1)
  4593. {
  4594. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4595. {
  4596. (*i)->append(QVariant());
  4597. }
  4598. }
  4599. (*i)->replace(tempcolumn,measure);
  4600. lastInsertion= i;
  4601. emit dataChanged(createIndex(insertion,tempcolumn),
  4602. createIndex(insertion,tempcolumn));
  4603. lastTemperature->insert(tempcolumn,insertion);
  4604. /*:402*/
  4605. #line 9205 "./typica.w"
  4606. }
  4607. else
  4608. {
  4609. /*403:*/
  4610. #line 9347 "./typica.w"
  4611. beginInsertRows(QModelIndex(),insertion,insertion);
  4612. newEntry= new MeasurementList;
  4613. newEntry->append(QVariant(measure.time()));
  4614. for(int j= 0;j<tempcolumn+1;j++)
  4615. {
  4616. newEntry->append(QVariant());
  4617. }
  4618. newEntry->replace(tempcolumn,measure);
  4619. lastInsertion= entries->insert(i,newEntry);
  4620. endInsertRows();
  4621. lastTemperature->insert(tempcolumn,insertion);
  4622. /*:403*/
  4623. #line 9209 "./typica.w"
  4624. }
  4625. }
  4626. else
  4627. {
  4628. /*404:*/
  4629. #line 9365 "./typica.w"
  4630. insertion= entries->size();
  4631. /*403:*/
  4632. #line 9347 "./typica.w"
  4633. beginInsertRows(QModelIndex(),insertion,insertion);
  4634. newEntry= new MeasurementList;
  4635. newEntry->append(QVariant(measure.time()));
  4636. for(int j= 0;j<tempcolumn+1;j++)
  4637. {
  4638. newEntry->append(QVariant());
  4639. }
  4640. newEntry->replace(tempcolumn,measure);
  4641. lastInsertion= entries->insert(i,newEntry);
  4642. endInsertRows();
  4643. lastTemperature->insert(tempcolumn,insertion);
  4644. /*:403*/
  4645. #line 9367 "./typica.w"
  4646. /*:404*/
  4647. #line 9214 "./typica.w"
  4648. }
  4649. if(tempcolumn>=colcount)
  4650. {
  4651. colcount= tempcolumn+1;
  4652. }
  4653. emit rowChanged(insertion);
  4654. delete temp;
  4655. }
  4656. /*:399*//*405:*/
  4657. #line 9377 "./typica.w"
  4658. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4659. int annotationColumn)
  4660. {
  4661. int r;
  4662. if(lastTemperature->contains(tempcolumn))
  4663. {
  4664. r= lastTemperature->value(tempcolumn);
  4665. }
  4666. else
  4667. {
  4668. r= 0;
  4669. }
  4670. if(r==0&&entries->size()==0)
  4671. {
  4672. /*406:*/
  4673. #line 9415 "./typica.w"
  4674. beginInsertRows(QModelIndex(),0,0);
  4675. MeasurementList*newEntry= new MeasurementList;
  4676. newEntry->append(QVariant(QTime(0,0,0,0)));
  4677. entries->append(newEntry);
  4678. endInsertRows();
  4679. /*:406*/
  4680. #line 9392 "./typica.w"
  4681. }
  4682. MeasurementList*row= entries->at(r);
  4683. if(row->size()<=annotationColumn)
  4684. {
  4685. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4686. {
  4687. row->append(QVariant());
  4688. }
  4689. }
  4690. row->replace(annotationColumn,annotation);
  4691. emit dataChanged(createIndex(r,annotationColumn),
  4692. createIndex(r,annotationColumn));
  4693. emit rowChanged(r);
  4694. if(annotationColumn> colcount-1)
  4695. {
  4696. colcount= annotationColumn+1;
  4697. }
  4698. }
  4699. /*:405*//*407:*/
  4700. #line 9426 "./typica.w"
  4701. void MeasurementModel::clear()
  4702. {
  4703. beginRemoveRows(QModelIndex(),0,entries->size());
  4704. while(entries->size()!=0)
  4705. {
  4706. MeasurementList*row= entries->takeFirst();
  4707. delete row;
  4708. }
  4709. endRemoveRows();
  4710. colcount= hData->size();
  4711. lastTemperature->clear();
  4712. reset();
  4713. }
  4714. /*:407*//*408:*/
  4715. #line 9459 "./typica.w"
  4716. bool MeasurementModel::setData(const QModelIndex&index,
  4717. const QVariant&value,int role)
  4718. {
  4719. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4720. {
  4721. return false;
  4722. }
  4723. /*409:*/
  4724. #line 9491 "./typica.w"
  4725. bool valid= false;
  4726. if(index.isValid())
  4727. {
  4728. if(index.row()<entries->size())
  4729. {
  4730. if(index.column()<colcount)
  4731. {
  4732. valid= true;
  4733. }
  4734. }
  4735. }
  4736. /*:409*/
  4737. #line 9467 "./typica.w"
  4738. if(!valid)
  4739. {
  4740. return false;
  4741. }
  4742. MeasurementList*row= entries->at(index.row());
  4743. if(index.column()>=row->size())
  4744. {
  4745. /*410:*/
  4746. #line 9508 "./typica.w"
  4747. for(int i= row->size()-1;i<index.column();i++)
  4748. {
  4749. row->append(QVariant());
  4750. }
  4751. /*:410*/
  4752. #line 9475 "./typica.w"
  4753. }
  4754. if(index.column()==0)
  4755. {
  4756. /*411:*/
  4757. #line 9523 "./typica.w"
  4758. QTime time;
  4759. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4760. {
  4761. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4762. {
  4763. return false;
  4764. }
  4765. }
  4766. row= entries->takeAt(index.row());
  4767. row->replace(index.column(),QVariant(time));
  4768. MeasurementList*temp= row;
  4769. /*400:*/
  4770. #line 9242 "./typica.w"
  4771. /*401:*/
  4772. #line 9287 "./typica.w"
  4773. QList<MeasurementList*> ::iterator i= lastInsertion;
  4774. bool quickscan= false;
  4775. if(entries->size()> 5)
  4776. {
  4777. if(**i<*temp)
  4778. {
  4779. i+= 1;
  4780. for(int j= 10;j> 0;j--)
  4781. {
  4782. if(i!=entries->end())
  4783. {
  4784. if(**i<*temp)
  4785. {
  4786. i+= 1;
  4787. }
  4788. else
  4789. {
  4790. quickscan= true;
  4791. break;
  4792. }
  4793. }
  4794. else
  4795. {
  4796. quickscan= true;
  4797. break;
  4798. }
  4799. }
  4800. }
  4801. else
  4802. {
  4803. if(**i==*temp)
  4804. {
  4805. quickscan= true;
  4806. }
  4807. }
  4808. }
  4809. /*:401*/
  4810. #line 9243 "./typica.w"
  4811. if(quickscan==false)
  4812. {
  4813. i= entries->begin();
  4814. QList<MeasurementList*> ::iterator u= entries->end();
  4815. QList<MeasurementList*> ::iterator midpoint;
  4816. int n= u-i;
  4817. int rA;
  4818. while(n> 0)
  4819. {
  4820. rA= n>>1;
  4821. midpoint= i+rA;
  4822. if(**midpoint<*temp)
  4823. {
  4824. i= midpoint+1;
  4825. n-= rA+1;
  4826. }
  4827. else
  4828. {
  4829. n= rA;
  4830. }
  4831. }
  4832. }
  4833. /*:400*/
  4834. #line 9535 "./typica.w"
  4835. entries->insert(i,row);
  4836. int newRow= entries->indexOf(*i);
  4837. if(newRow<index.row())
  4838. {
  4839. emit dataChanged(createIndex(newRow,index.column()),index);
  4840. }
  4841. else
  4842. {
  4843. emit dataChanged(index,createIndex(newRow,index.column()));
  4844. }
  4845. /*:411*/
  4846. #line 9479 "./typica.w"
  4847. }
  4848. else
  4849. {
  4850. /*412:*/
  4851. #line 9549 "./typica.w"
  4852. row->replace(index.column(),value);
  4853. emit dataChanged(index,index);
  4854. /*:412*/
  4855. #line 9483 "./typica.w"
  4856. }
  4857. return true;
  4858. }
  4859. /*:408*//*413:*/
  4860. #line 9557 "./typica.w"
  4861. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  4862. unit(Units::Fahrenheit),hData(new QStringList),
  4863. lastTemperature(new QHash<int,int> ),
  4864. controlColumns(new QHash<int,bool> )
  4865. {
  4866. colcount= 1;
  4867. entries= new QList<MeasurementList*> ;
  4868. lastInsertion= entries->begin();
  4869. hData->append(tr("Time"));
  4870. }
  4871. /*:413*//*414:*/
  4872. #line 9571 "./typica.w"
  4873. MeasurementModel::~MeasurementModel()
  4874. {
  4875. clear();
  4876. delete entries;
  4877. delete hData;
  4878. }
  4879. /*:414*//*415:*/
  4880. #line 9583 "./typica.w"
  4881. int MeasurementModel::rowCount(const QModelIndex&parent)const
  4882. {
  4883. if(parent==QModelIndex())
  4884. {
  4885. return entries->size();
  4886. }
  4887. return 0;
  4888. }
  4889. int MeasurementModel::columnCount(const QModelIndex&parent)const
  4890. {
  4891. if(parent==QModelIndex())
  4892. {
  4893. return colcount;
  4894. }
  4895. return 0;
  4896. }
  4897. /*:415*//*416:*/
  4898. #line 9610 "./typica.w"
  4899. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  4900. const QVariant&value,int)
  4901. {
  4902. if(orientation==Qt::Horizontal)
  4903. {
  4904. if(hData->size()<section+1)
  4905. {
  4906. for(int i= hData->size();i<section+1;i++)
  4907. {
  4908. if(colcount<i)
  4909. {
  4910. beginInsertColumns(QModelIndex(),i,i);
  4911. }
  4912. hData->append(QString());
  4913. if(colcount<i)
  4914. {
  4915. endInsertColumns();
  4916. }
  4917. }
  4918. }
  4919. hData->replace(section,value.toString());
  4920. emit headerDataChanged(orientation,section,section);
  4921. if(colcount<section+1)
  4922. {
  4923. colcount= section+1;
  4924. }
  4925. return true;
  4926. }
  4927. return false;
  4928. }
  4929. /*:416*//*417:*/
  4930. #line 9650 "./typica.w"
  4931. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  4932. {
  4933. beginResetModel();
  4934. unit= scale;
  4935. endResetModel();
  4936. }
  4937. Units::Unit MeasurementModel::displayUnits()
  4938. {
  4939. return unit;
  4940. }
  4941. /*:417*//*418:*/
  4942. #line 9676 "./typica.w"
  4943. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  4944. {
  4945. /*409:*/
  4946. #line 9491 "./typica.w"
  4947. bool valid= false;
  4948. if(index.isValid())
  4949. {
  4950. if(index.row()<entries->size())
  4951. {
  4952. if(index.column()<colcount)
  4953. {
  4954. valid= true;
  4955. }
  4956. }
  4957. }
  4958. /*:409*/
  4959. #line 9679 "./typica.w"
  4960. if(!valid)
  4961. {
  4962. return QVariant();
  4963. }
  4964. MeasurementList*row= entries->at(index.row());
  4965. if(role==Qt::UserRole)
  4966. {
  4967. return QVariant(row->at(index.column()));
  4968. }
  4969. if(role==Qt::DisplayRole||role==Qt::EditRole)
  4970. {
  4971. if(index.column()> row->size())
  4972. {
  4973. return QVariant();
  4974. }
  4975. else
  4976. {
  4977. if(index.column()==0)
  4978. {
  4979. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  4980. }
  4981. else if(lastTemperature->contains(index.column()))
  4982. {
  4983. QVariantMap v= row->at(index.column()).toMap();
  4984. if(!v.contains("measurement"))
  4985. {
  4986. return QVariant();
  4987. }
  4988. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  4989. {
  4990. return v.value("measurement");
  4991. }
  4992. else
  4993. {
  4994. if(v.contains("relative"))
  4995. {
  4996. if(v.value("relative").toBool())
  4997. {
  4998. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  4999. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5000. }
  5001. }
  5002. return QVariant(QString("%1").
  5003. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5004. (Units::Unit)(v.value("unit").toInt()),unit)));
  5005. }
  5006. }
  5007. return QVariant(row->at(index.column()).toString());
  5008. }
  5009. }
  5010. return QVariant();
  5011. }
  5012. /*:418*//*419:*/
  5013. #line 9735 "./typica.w"
  5014. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5015. int role)const
  5016. {
  5017. if(orientation==Qt::Horizontal)
  5018. {
  5019. if(role==Qt::DisplayRole)
  5020. {
  5021. if(section<hData->size())
  5022. {
  5023. return QVariant(hData->at(section));
  5024. }
  5025. }
  5026. }
  5027. return QVariant();
  5028. }
  5029. /*:419*//*420:*/
  5030. #line 9762 "./typica.w"
  5031. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5032. {
  5033. /*409:*/
  5034. #line 9491 "./typica.w"
  5035. bool valid= false;
  5036. if(index.isValid())
  5037. {
  5038. if(index.row()<entries->size())
  5039. {
  5040. if(index.column()<colcount)
  5041. {
  5042. valid= true;
  5043. }
  5044. }
  5045. }
  5046. /*:409*/
  5047. #line 9765 "./typica.w"
  5048. if(valid)
  5049. {
  5050. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5051. }
  5052. return 0;
  5053. }
  5054. /*:420*//*421:*/
  5055. #line 9777 "./typica.w"
  5056. QModelIndex MeasurementModel::index(int row,int column,
  5057. const QModelIndex&parent)const
  5058. {
  5059. if(parent==QModelIndex())
  5060. {
  5061. if(row<entries->size()&&entries->isEmpty()==false)
  5062. {
  5063. if(column<entries->at(row)->size())
  5064. {
  5065. return createIndex(row,column);
  5066. }
  5067. }
  5068. }
  5069. return QModelIndex();
  5070. }
  5071. /*:421*/
  5072. #line 550 "./typica.w"
  5073. /*423:*/
  5074. #line 9828 "./typica.w"
  5075. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5076. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5077. {
  5078. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5079. }
  5080. /*:423*//*424:*/
  5081. #line 9843 "./typica.w"
  5082. void AnnotationButton::annotate()
  5083. {
  5084. if(note.contains("%1"))
  5085. {
  5086. count++;
  5087. emit annotation(note.arg(count),tc,ac);
  5088. }
  5089. else
  5090. {
  5091. emit annotation(note,tc,ac);
  5092. }
  5093. }
  5094. /*:424*//*425:*/
  5095. #line 9861 "./typica.w"
  5096. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5097. {
  5098. tc= tempcolumn;
  5099. }
  5100. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5101. {
  5102. ac= annotationcolumn;
  5103. }
  5104. void AnnotationButton::setAnnotation(const QString&annotation)
  5105. {
  5106. note= annotation;
  5107. }
  5108. /*:425*//*426:*/
  5109. #line 9880 "./typica.w"
  5110. void AnnotationButton::resetCount()
  5111. {
  5112. count= 0;
  5113. }
  5114. /*:426*/
  5115. #line 551 "./typica.w"
  5116. /*431:*/
  5117. #line 9963 "./typica.w"
  5118. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5119. const QString&postt,
  5120. QWidget*parent)
  5121. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5122. {
  5123. resetChange();
  5124. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5125. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5126. }
  5127. /*:431*//*432:*/
  5128. #line 9980 "./typica.w"
  5129. void AnnotationSpinBox::resetChange()
  5130. {
  5131. change= true;
  5132. }
  5133. /*:432*//*433:*/
  5134. #line 9991 "./typica.w"
  5135. void AnnotationSpinBox::annotate()
  5136. {
  5137. if(change)
  5138. {
  5139. change= false;
  5140. emit annotation(QString("%1%2%3").arg(pretext).
  5141. arg(value()).arg(posttext),tc,ac);
  5142. }
  5143. }
  5144. /*:433*//*434:*/
  5145. #line 10004 "./typica.w"
  5146. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5147. {
  5148. tc= tempcolumn;
  5149. }
  5150. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5151. {
  5152. ac= annotationcolumn;
  5153. }
  5154. void AnnotationSpinBox::setPretext(const QString&pret)
  5155. {
  5156. pretext= pret;
  5157. }
  5158. void AnnotationSpinBox::setPosttext(const QString&postt)
  5159. {
  5160. posttext= postt;
  5161. }
  5162. /*:434*/
  5163. #line 552 "./typica.w"
  5164. /*441:*/
  5165. #line 10172 "./typica.w"
  5166. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5167. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5168. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5169. stopAction(new QAction(tr("Stop"),NULL)),
  5170. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5171. relative(QTime::currentTime()),base(QTime(0,0,0))
  5172. {
  5173. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5174. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5175. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5176. clock.setInterval(500);
  5177. clock.setSingleShot(false);
  5178. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5179. setSegmentStyle(Filled);
  5180. updateDisplay();
  5181. }
  5182. /*:441*//*442:*/
  5183. #line 10193 "./typica.w"
  5184. void TimerDisplay::updateTime()
  5185. {
  5186. QTime time;
  5187. int cseconds= 0;
  5188. int oseconds= 0;
  5189. int r= 0;
  5190. QTime nt= QTime(0,0,0);
  5191. int n= 0;
  5192. int bseconds= 0;
  5193. switch(m)
  5194. {
  5195. case TimerDisplay::CountUp:
  5196. /*443:*/
  5197. #line 10225 "./typica.w"
  5198. /*444:*/
  5199. #line 10238 "./typica.w"
  5200. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5201. time= QTime::currentTime();
  5202. cseconds= TIMETOINT(time);
  5203. oseconds= TIMETOINT(relative);
  5204. r= cseconds-oseconds;
  5205. /*:444*/
  5206. #line 10226 "./typica.w"
  5207. nt= nt.addSecs(r);
  5208. if(nt!=s)
  5209. {
  5210. s= nt;
  5211. emit valueChanged(s);
  5212. }
  5213. /*:443*/
  5214. #line 10206 "./typica.w"
  5215. ;
  5216. break;
  5217. case TimerDisplay::CountDown:
  5218. /*445:*/
  5219. #line 10250 "./typica.w"
  5220. if(s> QTime(0,0,0))
  5221. {
  5222. /*444:*/
  5223. #line 10238 "./typica.w"
  5224. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5225. time= QTime::currentTime();
  5226. cseconds= TIMETOINT(time);
  5227. oseconds= TIMETOINT(relative);
  5228. r= cseconds-oseconds;
  5229. /*:444*/
  5230. #line 10253 "./typica.w"
  5231. bseconds= TIMETOINT(base);
  5232. n= bseconds-r;
  5233. nt= nt.addSecs(n);
  5234. if(nt!=s)
  5235. {
  5236. s= nt;
  5237. emit valueChanged(s);
  5238. }
  5239. }
  5240. /*:445*/
  5241. #line 10209 "./typica.w"
  5242. ;
  5243. break;
  5244. case TimerDisplay::Clock:
  5245. /*446:*/
  5246. #line 10267 "./typica.w"
  5247. time= QTime::currentTime();
  5248. if(time!=s)
  5249. {
  5250. s= time;
  5251. emit valueChanged(s);
  5252. }
  5253. /*:446*/
  5254. #line 10212 "./typica.w"
  5255. ;
  5256. break;
  5257. default:
  5258. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5259. break;
  5260. }
  5261. updateDisplay();
  5262. }
  5263. /*:442*//*447:*/
  5264. #line 10279 "./typica.w"
  5265. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5266. void TimerDisplay::startTimer()
  5267. {
  5268. if(!running)
  5269. {
  5270. relative= QTime::currentTime();
  5271. if(ar)
  5272. {
  5273. reset();
  5274. }
  5275. else
  5276. {
  5277. relative= TIMESUBTRACT(relative,s);
  5278. }
  5279. if(m==Clock)
  5280. {
  5281. updateTime();
  5282. }
  5283. base= s;
  5284. clock.start();
  5285. running= true;
  5286. emit runStateChanged(true);
  5287. }
  5288. }
  5289. /*:447*//*448:*/
  5290. #line 10309 "./typica.w"
  5291. void TimerDisplay::stopTimer()
  5292. {
  5293. if(running)
  5294. {
  5295. clock.stop();
  5296. running= false;
  5297. emit runStateChanged(false);
  5298. }
  5299. }
  5300. /*:448*//*449:*/
  5301. #line 10322 "./typica.w"
  5302. TimerDisplay::~TimerDisplay()
  5303. {
  5304. clock.stop();
  5305. }
  5306. /*:449*//*450:*/
  5307. #line 10331 "./typica.w"
  5308. void TimerDisplay::setCountUpMode()
  5309. {
  5310. m= TimerDisplay::CountUp;
  5311. }
  5312. void TimerDisplay::setCountDownMode()
  5313. {
  5314. m= TimerDisplay::CountDown;
  5315. }
  5316. void TimerDisplay::setClockMode()
  5317. {
  5318. m= TimerDisplay::Clock;
  5319. }
  5320. /*:450*//*451:*/
  5321. #line 10349 "./typica.w"
  5322. QString TimerDisplay::value()
  5323. {
  5324. return s.toString(f);
  5325. }
  5326. QTime TimerDisplay::seconds()
  5327. {
  5328. return s;
  5329. }
  5330. TimerDisplay::TimerMode TimerDisplay::mode()
  5331. {
  5332. return m;
  5333. }
  5334. bool TimerDisplay::isRunning()
  5335. {
  5336. return running;
  5337. }
  5338. QTime TimerDisplay::resetValue()
  5339. {
  5340. return r;
  5341. }
  5342. QString TimerDisplay::displayFormat()
  5343. {
  5344. return f;
  5345. }
  5346. bool TimerDisplay::autoReset()
  5347. {
  5348. return ar;
  5349. }
  5350. /*:451*//*452:*/
  5351. #line 10387 "./typica.w"
  5352. void TimerDisplay::setTimer(QTime value)
  5353. {
  5354. if(value.isValid())
  5355. {
  5356. s= value;
  5357. updateDisplay();
  5358. emit valueChanged(value);
  5359. }
  5360. }
  5361. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5362. {
  5363. m= mode;
  5364. }
  5365. void TimerDisplay::setResetValue(QTime value)
  5366. {
  5367. r= value;
  5368. }
  5369. void TimerDisplay::setDisplayFormat(QString format)
  5370. {
  5371. f= format;
  5372. setNumDigits(format.length());
  5373. }
  5374. void TimerDisplay::setAutoReset(bool reset)
  5375. {
  5376. ar= reset;
  5377. }
  5378. /*:452*//*453:*/
  5379. #line 10422 "./typica.w"
  5380. void TimerDisplay::copyTimer()
  5381. {
  5382. QApplication::clipboard()->setText(value());
  5383. }
  5384. /*:453*//*454:*/
  5385. #line 10431 "./typica.w"
  5386. void TimerDisplay::reset()
  5387. {
  5388. if(!running)
  5389. {
  5390. s= r;
  5391. updateDisplay();
  5392. }
  5393. }
  5394. /*:454*//*455:*/
  5395. #line 10444 "./typica.w"
  5396. void TimerDisplay::updateDisplay()
  5397. {
  5398. display(value());
  5399. }
  5400. /*:455*/
  5401. #line 553 "./typica.w"
  5402. /*461:*/
  5403. #line 10538 "./typica.w"
  5404. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5405. {
  5406. int x= rect.x();
  5407. int y= rect.y();
  5408. QLayoutItem*item;
  5409. if(orientation==Qt::Horizontal)
  5410. {
  5411. /*462:*/
  5412. #line 10562 "./typica.w"
  5413. foreach(item,itemList)
  5414. {
  5415. int nextX= x+item->sizeHint().width()+spacing();
  5416. int right= x+item->sizeHint().width();
  5417. if(item==itemList.last())
  5418. {
  5419. right= rect.right();
  5420. }
  5421. int bottom= rect.bottom();
  5422. if(!testOnly)
  5423. {
  5424. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5425. }
  5426. x= nextX;
  5427. }
  5428. /*:462*/
  5429. #line 10546 "./typica.w"
  5430. }
  5431. else
  5432. {
  5433. /*463:*/
  5434. #line 10581 "./typica.w"
  5435. foreach(item,itemList)
  5436. {
  5437. int nextY= y+item->sizeHint().height()+spacing();
  5438. int bottom= y+item->sizeHint().height();
  5439. if(item==itemList.last())
  5440. {
  5441. bottom= rect.bottom();
  5442. }
  5443. int right= rect.right();
  5444. if(!testOnly)
  5445. {
  5446. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5447. }
  5448. y= nextY;
  5449. }
  5450. /*:463*/
  5451. #line 10550 "./typica.w"
  5452. }
  5453. return y;
  5454. }
  5455. /*:461*//*464:*/
  5456. #line 10605 "./typica.w"
  5457. QSize PackLayout::minimumSize()const
  5458. {
  5459. QSize size;
  5460. QLayoutItem*item;
  5461. foreach(item,itemList)
  5462. {
  5463. if(orientation==Qt::Horizontal)
  5464. {
  5465. size+= QSize(item->minimumSize().width(),0);
  5466. if(size.height()<item->minimumSize().height())
  5467. {
  5468. size.setHeight(item->minimumSize().height());
  5469. }
  5470. }
  5471. else
  5472. {
  5473. size+= QSize(0,item->minimumSize().height());
  5474. if(size.width()<item->minimumSize().width())
  5475. {
  5476. size.setWidth(item->minimumSize().width());
  5477. }
  5478. }
  5479. }
  5480. size+= QSize(2*margin(),2*margin());
  5481. return size;
  5482. }
  5483. /*:464*//*465:*/
  5484. #line 10637 "./typica.w"
  5485. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5486. QLayout(parent)
  5487. {
  5488. setMargin(margin);
  5489. setSpacing(spacing);
  5490. setOrientation(Qt::Horizontal);
  5491. }
  5492. PackLayout::PackLayout(int spacing)
  5493. {
  5494. setSpacing(spacing);
  5495. setOrientation(Qt::Horizontal);
  5496. }
  5497. /*:465*//*466:*/
  5498. #line 10655 "./typica.w"
  5499. PackLayout::~PackLayout()
  5500. {
  5501. QLayoutItem*item;
  5502. while((item= takeAt(0)))
  5503. {
  5504. delete item;
  5505. }
  5506. }
  5507. /*:466*//*467:*/
  5508. #line 10669 "./typica.w"
  5509. QLayoutItem*PackLayout::takeAt(int index)
  5510. {
  5511. if(index>=0&&index<itemList.size())
  5512. {
  5513. return itemList.takeAt(index);
  5514. }
  5515. else
  5516. {
  5517. return NULL;
  5518. }
  5519. }
  5520. /*:467*//*468:*/
  5521. #line 10685 "./typica.w"
  5522. QLayoutItem*PackLayout::itemAt(int index)const
  5523. {
  5524. if(index>=0&&index<itemList.size())
  5525. {
  5526. return itemList.at(index);
  5527. }
  5528. else
  5529. {
  5530. return NULL;
  5531. }
  5532. }
  5533. /*:468*//*469:*/
  5534. #line 10708 "./typica.w"
  5535. void PackLayout::addItem(QLayoutItem*item)
  5536. {
  5537. itemList.append(item);
  5538. }
  5539. /*:469*//*470:*/
  5540. #line 10716 "./typica.w"
  5541. int PackLayout::count()const
  5542. {
  5543. return itemList.size();
  5544. }
  5545. /*:470*//*471:*/
  5546. #line 10728 "./typica.w"
  5547. Qt::Orientations PackLayout::expandingDirections()const
  5548. {
  5549. return Qt::Vertical|Qt::Horizontal;
  5550. }
  5551. bool PackLayout::hasHeightForWidth()const
  5552. {
  5553. return false;
  5554. }
  5555. int PackLayout::heightForWidth(int width)const
  5556. {
  5557. return doLayout(QRect(0,0,width,0),true);
  5558. }
  5559. void PackLayout::setGeometry(const QRect&rect)
  5560. {
  5561. QLayout::setGeometry(rect);
  5562. doLayout(rect,false);
  5563. }
  5564. QSize PackLayout::sizeHint()const
  5565. {
  5566. return minimumSize();
  5567. }
  5568. /*:471*//*472:*/
  5569. #line 10759 "./typica.w"
  5570. void PackLayout::setOrientation(Qt::Orientations direction)
  5571. {
  5572. orientation= direction;
  5573. doLayout(geometry(),false);
  5574. }
  5575. /*:472*/
  5576. #line 554 "./typica.w"
  5577. /*474:*/
  5578. #line 10798 "./typica.w"
  5579. SceneButton::SceneButton():QGraphicsScene()
  5580. {
  5581. }
  5582. SceneButton::~SceneButton()
  5583. {
  5584. }
  5585. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5586. {
  5587. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5588. }
  5589. /*:474*/
  5590. #line 555 "./typica.w"
  5591. /*476:*/
  5592. #line 10844 "./typica.w"
  5593. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5594. Qt::Orientations orientation,
  5595. QWidget*parent,Qt::WindowFlags f):
  5596. QWidget(parent,f),label(new QGraphicsView()),
  5597. scene(new SceneButton())
  5598. {
  5599. layout= new PackLayout(this);
  5600. layout->setOrientation(orientation);
  5601. /*477:*/
  5602. #line 10864 "./typica.w"
  5603. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5604. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5605. label->setFrameShape(QFrame::NoFrame);
  5606. label->setInteractive(true);
  5607. /*:477*/
  5608. #line 10853 "./typica.w"
  5609. /*478:*/
  5610. #line 10875 "./typica.w"
  5611. scene->setBackgroundBrush(Qt::cyan);
  5612. text= scene->addText(labeltext);
  5613. if(orientation==Qt::Horizontal)
  5614. {
  5615. text->rotate(270.0);
  5616. }
  5617. label->setScene(scene);
  5618. /*:478*/
  5619. #line 10854 "./typica.w"
  5620. /*479:*/
  5621. #line 10893 "./typica.w"
  5622. if(orientation==Qt::Horizontal)
  5623. {
  5624. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5625. }
  5626. else
  5627. {
  5628. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5629. }
  5630. label->centerOn(text);
  5631. /*:479*/
  5632. #line 10855 "./typica.w"
  5633. /*480:*/
  5634. #line 10908 "./typica.w"
  5635. layout->addWidget(label);
  5636. layout->addWidget(widget);
  5637. if(orientation==Qt::Horizontal)
  5638. {
  5639. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5640. widget->sizeHint().height());
  5641. }
  5642. else
  5643. {
  5644. setMinimumSize(widget->sizeHint().width(),
  5645. widget->sizeHint().height()+label->sizeHint().height());
  5646. }
  5647. /*:480*/
  5648. #line 10856 "./typica.w"
  5649. }
  5650. /*:476*//*481:*/
  5651. #line 10925 "./typica.w"
  5652. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5653. {
  5654. scene->setBackgroundBrush(background);
  5655. }
  5656. void WidgetDecorator::setTextColor(QColor color)
  5657. {
  5658. text->setDefaultTextColor(color);
  5659. }
  5660. /*:481*//*482:*/
  5661. #line 10938 "./typica.w"
  5662. WidgetDecorator::~WidgetDecorator()
  5663. {
  5664. }
  5665. /*:482*/
  5666. #line 556 "./typica.w"
  5667. /*487:*/
  5668. #line 11037 "./typica.w"
  5669. void LogEditWindow::addTheRows()
  5670. {
  5671. QTime s= startTime->time();
  5672. while(s<endTime->time())
  5673. {
  5674. model->newMeasurement(Measurement(0,s),1);
  5675. s= s.addSecs(interval->value());
  5676. }
  5677. model->newMeasurement(Measurement(0,endTime->time()),1);
  5678. }
  5679. /*:487*//*488:*/
  5680. #line 11051 "./typica.w"
  5681. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5682. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5683. addRowsLayout(new QHBoxLayout(NULL)),
  5684. startTimeLabel(new QLabel("Start Time")),
  5685. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5686. endTimeLabel(new QLabel("End Time")),
  5687. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5688. intervalLabel(new QLabel("Interval (seconds)")),
  5689. interval(new QSpinBox()),
  5690. addRows(new QPushButton("Add Rows")),
  5691. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5692. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5693. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5694. model(new MeasurementModel()),
  5695. log(new QTableView())
  5696. {
  5697. /*489:*/
  5698. #line 11088 "./typica.w"
  5699. QSettings settings;
  5700. resize(settings.value("logSize",QSize(620,400)).toSize());
  5701. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5702. /*:489*/
  5703. #line 11068 "./typica.w"
  5704. /*490:*/
  5705. #line 11101 "./typica.w"
  5706. mainLayout->setOrientation(Qt::Vertical);
  5707. addRowsLayout->addSpacing(10);
  5708. addRowsLayout->addWidget(startTimeLabel);
  5709. addRowsLayout->addWidget(startTime);
  5710. addRowsLayout->addSpacing(10);
  5711. startTime->setDisplayFormat("mm:ss");
  5712. addRowsLayout->addWidget(endTimeLabel);
  5713. addRowsLayout->addWidget(endTime);
  5714. addRowsLayout->addSpacing(10);
  5715. endTime->setDisplayFormat("mm:ss");
  5716. addRowsLayout->addWidget(intervalLabel);
  5717. addRowsLayout->addWidget(interval);
  5718. addRowsLayout->addSpacing(10);
  5719. interval->setRange(0,60);
  5720. interval->setValue(30);
  5721. addRowsLayout->addWidget(addRows);
  5722. addRowsLayout->addSpacing(10);
  5723. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5724. /*:490*/
  5725. #line 11069 "./typica.w"
  5726. /*491:*/
  5727. #line 11124 "./typica.w"
  5728. model->setHeaderData(0,Qt::Horizontal,"Time");
  5729. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5730. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5731. model->clear();
  5732. /*:491*/
  5733. #line 11070 "./typica.w"
  5734. /*492:*/
  5735. #line 11133 "./typica.w"
  5736. log->setModel(model);
  5737. log->setColumnWidth(0,100);
  5738. log->setColumnWidth(1,100);
  5739. log->setColumnWidth(2,100);
  5740. /*:492*/
  5741. #line 11071 "./typica.w"
  5742. mainLayout->addItem(addRowsLayout);
  5743. mainLayout->addWidget(log);
  5744. centralWidget->setLayout(mainLayout);
  5745. setCentralWidget(centralWidget);
  5746. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5747. fileMenu->addAction(openXml);
  5748. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5749. fileMenu->addAction(saveXml);
  5750. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5751. fileMenu->addAction(saveCsv);
  5752. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5753. }
  5754. /*:488*//*493:*/
  5755. #line 11144 "./typica.w"
  5756. void LogEditWindow::saveXML()
  5757. {
  5758. QSettings settings;
  5759. QString lastDir= settings.value("lastDirectory").toString();
  5760. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5761. lastDir,"",0);
  5762. QFile file(filename);
  5763. XMLOutput writer(model,&file,0);
  5764. writer.addTemperatureColumn("Temperature",1);
  5765. writer.addAnnotationColumn("Annotation",2);
  5766. if(writer.output())
  5767. {
  5768. QFileInfo info(filename);
  5769. QDir directory= info.dir();
  5770. lastDir= directory.path();
  5771. settings.setValue("lastDirectory",lastDir);
  5772. }
  5773. }
  5774. void LogEditWindow::saveCSV()
  5775. {
  5776. QSettings settings;
  5777. QString lastDir= settings.value("lastDirectory").toString();
  5778. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5779. lastDir,"",0);
  5780. QFile file(filename);
  5781. CSVOutput writer(model,&file,0);
  5782. writer.addTemperatureColumn("Temperature",1);
  5783. writer.addAnnotationColumn("Annotation",2);
  5784. if(writer.output())
  5785. {
  5786. QFileInfo info(filename);
  5787. QDir directory= info.dir();
  5788. lastDir= directory.path();
  5789. settings.setValue("lastDirectory",lastDir);
  5790. }
  5791. }
  5792. /*:493*//*494:*/
  5793. #line 11187 "./typica.w"
  5794. void LogEditWindow::openXML()
  5795. {
  5796. QSettings settings;
  5797. QString lastDir= settings.value("lastDirectory").toString();
  5798. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  5799. lastDir,"",0);
  5800. if(filename.isNull())
  5801. {
  5802. return;
  5803. }
  5804. QFile file(filename);
  5805. XMLInput reader(&file,1);
  5806. connect(&reader,SIGNAL(measure(Measurement,int)),
  5807. model,SLOT(newMeasurement(Measurement,int)));
  5808. connect(&reader,SIGNAL(annotation(QString,int,int)),
  5809. model,SLOT(newAnnotation(QString,int,int)));
  5810. if(reader.input())
  5811. {
  5812. QFileInfo info(filename);
  5813. setWindowTitle(QString(tr("%1 - %2")).
  5814. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  5815. QDir directory= info.dir();
  5816. lastDir= directory.path();
  5817. settings.setValue("lastDirectory",lastDir);
  5818. }
  5819. }
  5820. /*:494*//*495:*/
  5821. #line 11218 "./typica.w"
  5822. void LogEditWindow::closeEvent(QCloseEvent*event)
  5823. {
  5824. QSettings settings;
  5825. settings.setValue("logSize",size());
  5826. settings.setValue("logPos",pos());
  5827. event->accept();
  5828. }
  5829. /*:495*/
  5830. #line 557 "./typica.w"
  5831. /*501:*/
  5832. #line 11333 "./typica.w"
  5833. bool XMLOutput::output()
  5834. {
  5835. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5836. {
  5837. return false;
  5838. }
  5839. QXmlStreamWriter xmlout(out);
  5840. xmlout.writeStartDocument("1.0");
  5841. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  5842. xmlout.writeStartElement("roastlog");
  5843. /*502:*/
  5844. #line 11366 "./typica.w"
  5845. foreach(int c,temperatureColumns.keys())
  5846. {
  5847. xmlout.writeStartElement("tempseries");
  5848. xmlout.writeAttribute("name",temperatureColumns.value(c));
  5849. xmlout.writeEndElement();
  5850. }
  5851. foreach(int c,controlColumns.keys())
  5852. {
  5853. xmlout.writeStartElement("controlseries");
  5854. xmlout.writeAttribute("name",controlColumns.value(c));
  5855. xmlout.writeEndElement();
  5856. }
  5857. foreach(int c,annotationColumns.keys())
  5858. {
  5859. xmlout.writeStartElement("noteseries");
  5860. xmlout.writeAttribute("name",annotationColumns.value(c));
  5861. xmlout.writeEndElement();
  5862. }
  5863. /*:502*/
  5864. #line 11344 "./typica.w"
  5865. xmlout.writeStartElement("roast");
  5866. bool oresult;
  5867. for(int i= 0;i<data->rowCount();i++)
  5868. {
  5869. /*503:*/
  5870. #line 11391 "./typica.w"
  5871. oresult= false;
  5872. foreach(int c,temperatureColumns.keys())
  5873. {
  5874. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5875. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5876. {
  5877. oresult= true;
  5878. break;
  5879. }
  5880. }
  5881. foreach(int c,controlColumns.keys())
  5882. {
  5883. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5884. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5885. {
  5886. oresult= true;
  5887. break;
  5888. }
  5889. }
  5890. if(oresult==false)
  5891. {
  5892. foreach(int c,annotationColumns.keys())
  5893. {
  5894. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5895. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5896. isEmpty()))
  5897. {
  5898. oresult= true;
  5899. break;
  5900. }
  5901. }
  5902. }
  5903. /*:503*/
  5904. #line 11349 "./typica.w"
  5905. if(oresult)
  5906. {
  5907. /*504:*/
  5908. #line 11430 "./typica.w"
  5909. xmlout.writeStartElement("tuple");
  5910. xmlout.writeTextElement("time",data->data(data->index(i,time),
  5911. Qt::DisplayRole).toString());
  5912. foreach(int c,temperatureColumns.keys())
  5913. {
  5914. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5915. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5916. {
  5917. xmlout.writeStartElement("temperature");
  5918. xmlout.writeAttribute("series",temperatureColumns.value(c));
  5919. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  5920. {
  5921. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  5922. {
  5923. xmlout.writeAttribute("relative","true");
  5924. }
  5925. }
  5926. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5927. toString());
  5928. xmlout.writeEndElement();
  5929. }
  5930. }
  5931. foreach(int c,controlColumns.keys())
  5932. {
  5933. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5934. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5935. {
  5936. xmlout.writeStartElement("control");
  5937. xmlout.writeAttribute("series",controlColumns.value(c));
  5938. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  5939. xmlout.writeEndElement();
  5940. }
  5941. }
  5942. foreach(int c,annotationColumns.keys())
  5943. {
  5944. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5945. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5946. {
  5947. xmlout.writeStartElement("annotation");
  5948. xmlout.writeAttribute("series",annotationColumns.value(c));
  5949. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5950. toString());
  5951. xmlout.writeEndElement();
  5952. }
  5953. }
  5954. xmlout.writeEndElement();
  5955. /*:504*/
  5956. #line 11352 "./typica.w"
  5957. }
  5958. }
  5959. xmlout.writeEndElement();
  5960. xmlout.writeEndElement();
  5961. xmlout.writeEndDocument();
  5962. out->close();
  5963. return true;
  5964. }
  5965. /*:501*//*505:*/
  5966. #line 11480 "./typica.w"
  5967. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  5968. :QObject(NULL),data(model),out(device),time(timec)
  5969. {
  5970. }
  5971. void XMLOutput::setModel(MeasurementModel*model)
  5972. {
  5973. data= model;
  5974. }
  5975. void XMLOutput::setTimeColumn(int column)
  5976. {
  5977. time= column;
  5978. }
  5979. void XMLOutput::setDevice(QIODevice*device)
  5980. {
  5981. out= device;
  5982. }
  5983. /*:505*//*506:*/
  5984. #line 11509 "./typica.w"
  5985. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  5986. {
  5987. temperatureColumns.insert(column,series);
  5988. }
  5989. void XMLOutput::addControlColumn(const QString&series,int column)
  5990. {
  5991. controlColumns.insert(column,series);
  5992. }
  5993. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  5994. {
  5995. annotationColumns.insert(column,series);
  5996. }
  5997. /*:506*/
  5998. #line 558 "./typica.w"
  5999. /*508:*/
  6000. #line 11566 "./typica.w"
  6001. bool XMLInput::input()
  6002. {
  6003. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6004. {
  6005. return false;
  6006. }
  6007. QXmlStreamReader xmlin(in);
  6008. QMap<QString,int> temperatureColumns;
  6009. QMap<QString,int> annotationColumns;
  6010. int nextColumn= firstc;
  6011. /*509:*/
  6012. #line 11597 "./typica.w"
  6013. while(!xmlin.isDTD())
  6014. {
  6015. xmlin.readNext();
  6016. }
  6017. if(xmlin.isDTD())
  6018. {
  6019. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6020. {
  6021. /*510:*/
  6022. #line 11619 "./typica.w"
  6023. emit newTemperatureColumn(firstc,"Bean");
  6024. emit newAnnotationColumn(firstc+1,"Note");
  6025. emit lastColumn(firstc+1);
  6026. /*:510*/
  6027. #line 11606 "./typica.w"
  6028. }
  6029. else
  6030. {
  6031. xmlin.readNext();
  6032. /*511:*/
  6033. #line 11628 "./typica.w"
  6034. while(xmlin.name()!="roast")
  6035. {
  6036. if(xmlin.isStartElement())
  6037. {
  6038. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6039. {
  6040. temperatureColumns.insert(xmlin.attributes().value("name").
  6041. toString(),
  6042. nextColumn);
  6043. emit newTemperatureColumn(nextColumn,
  6044. xmlin.attributes().value("name").
  6045. toString());
  6046. nextColumn++;
  6047. }
  6048. else if(xmlin.name()=="noteseries")
  6049. {
  6050. annotationColumns.insert(xmlin.attributes().value("name").
  6051. toString(),nextColumn);
  6052. emit newAnnotationColumn(nextColumn,
  6053. xmlin.attributes().value("name").
  6054. toString());
  6055. nextColumn++;
  6056. }
  6057. }
  6058. xmlin.readNext();
  6059. }
  6060. emit lastColumn(nextColumn-1);
  6061. /*:511*/
  6062. #line 11611 "./typica.w"
  6063. }
  6064. }
  6065. /*:509*/
  6066. #line 11577 "./typica.w"
  6067. QTime timeval= QTime();
  6068. double tempval= 0;
  6069. QString noteval= QString();
  6070. int column;
  6071. int counter= 0;
  6072. while(!xmlin.atEnd())
  6073. {
  6074. /*512:*/
  6075. #line 11669 "./typica.w"
  6076. xmlin.readNext();
  6077. if(xmlin.isStartElement())
  6078. {
  6079. /*513:*/
  6080. #line 11695 "./typica.w"
  6081. if(xmlin.name()=="time")
  6082. {
  6083. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6084. }
  6085. else if(xmlin.name()=="temperature")
  6086. {
  6087. column= xmlin.attributes().value("series").toString().isEmpty()?
  6088. firstc:temperatureColumns.value(xmlin.attributes().
  6089. value("series").toString());
  6090. bool relative= (xmlin.attributes().value("relative")=="true");
  6091. tempval= xmlin.readElementText().toDouble();
  6092. Measurement measurement(tempval,timeval);
  6093. if(relative)
  6094. {
  6095. measurement.insert("relative",true);
  6096. }
  6097. emit measure(measurement,column);
  6098. }
  6099. else if(xmlin.name()=="control")
  6100. {
  6101. column= xmlin.attributes().value("series").toString().isEmpty()?
  6102. firstc:temperatureColumns.value(xmlin.attributes().
  6103. value("series").toString());
  6104. tempval= xmlin.readElementText().toDouble();
  6105. Measurement measurement(tempval,timeval,Units::Unitless);
  6106. emit measure(measurement,column);
  6107. }
  6108. else if(xmlin.name()=="annotation")
  6109. {
  6110. column= xmlin.attributes().value("series").toString().isEmpty()?
  6111. firstc+1:annotationColumns.value(xmlin.attributes().
  6112. value("series").toString());
  6113. noteval= xmlin.readElementText();
  6114. if(!noteval.isEmpty())
  6115. {
  6116. emit annotation(noteval,firstc,column);
  6117. }
  6118. }
  6119. /*:513*/
  6120. #line 11673 "./typica.w"
  6121. }
  6122. counter++;
  6123. if(counter%100==0)
  6124. {
  6125. QCoreApplication::processEvents();
  6126. }
  6127. /*:512*/
  6128. #line 11585 "./typica.w"
  6129. }
  6130. return true;
  6131. }
  6132. /*:508*//*514:*/
  6133. #line 11737 "./typica.w"
  6134. XMLInput::XMLInput(QIODevice*input,int c):
  6135. firstc(c),in(input)
  6136. {
  6137. }
  6138. void XMLInput::setFirstColumn(int column)
  6139. {
  6140. firstc= column;
  6141. }
  6142. void XMLInput::setDevice(QIODevice*device)
  6143. {
  6144. in= device;
  6145. }
  6146. /*:514*/
  6147. #line 559 "./typica.w"
  6148. /*519:*/
  6149. #line 11828 "./typica.w"
  6150. bool CSVOutput::output()
  6151. {
  6152. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6153. {
  6154. return false;
  6155. }
  6156. QTextStream output(out);
  6157. /*520:*/
  6158. #line 11852 "./typica.w"
  6159. output<<"Time";
  6160. foreach(int c,temperatureColumns.keys())
  6161. {
  6162. output<<','<<temperatureColumns.value(c);
  6163. }
  6164. foreach(int c,controlColumns.keys())
  6165. {
  6166. output<<','<<controlColumns.value(c);
  6167. }
  6168. foreach(int c,annotationColumns.keys())
  6169. {
  6170. output<<','<<annotationColumns.value(c);
  6171. }
  6172. output<<'\n';
  6173. /*:520*/
  6174. #line 11836 "./typica.w"
  6175. bool oresult;
  6176. for(int i= 0;i<data->rowCount();i++)
  6177. {
  6178. /*503:*/
  6179. #line 11391 "./typica.w"
  6180. oresult= false;
  6181. foreach(int c,temperatureColumns.keys())
  6182. {
  6183. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6184. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6185. {
  6186. oresult= true;
  6187. break;
  6188. }
  6189. }
  6190. foreach(int c,controlColumns.keys())
  6191. {
  6192. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6193. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6194. {
  6195. oresult= true;
  6196. break;
  6197. }
  6198. }
  6199. if(oresult==false)
  6200. {
  6201. foreach(int c,annotationColumns.keys())
  6202. {
  6203. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6204. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6205. isEmpty()))
  6206. {
  6207. oresult= true;
  6208. break;
  6209. }
  6210. }
  6211. }
  6212. /*:503*/
  6213. #line 11840 "./typica.w"
  6214. if(oresult)
  6215. {
  6216. /*521:*/
  6217. #line 11877 "./typica.w"
  6218. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6219. foreach(int c,temperatureColumns.keys())
  6220. {
  6221. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6222. }
  6223. foreach(int c,controlColumns.keys())
  6224. {
  6225. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6226. }
  6227. foreach(int c,annotationColumns.keys())
  6228. {
  6229. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6230. }
  6231. output<<'\n';
  6232. /*:521*/
  6233. #line 11843 "./typica.w"
  6234. }
  6235. }
  6236. out->close();
  6237. return true;
  6238. }
  6239. /*:519*//*522:*/
  6240. #line 11896 "./typica.w"
  6241. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6242. data(model),out(device),time(timec)
  6243. {
  6244. }
  6245. void CSVOutput::setModel(MeasurementModel*model)
  6246. {
  6247. data= model;
  6248. }
  6249. void CSVOutput::setTimeColumn(int column)
  6250. {
  6251. time= column;
  6252. }
  6253. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6254. {
  6255. temperatureColumns.insert(column,series);
  6256. }
  6257. void CSVOutput::addControlColumn(const QString&series,int column)
  6258. {
  6259. controlColumns.insert(column,series);
  6260. }
  6261. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6262. {
  6263. annotationColumns.insert(column,series);
  6264. }
  6265. void CSVOutput::setDevice(QIODevice*device)
  6266. {
  6267. out= device;
  6268. }
  6269. #line 1 "./webview.w"
  6270. /*:522*/
  6271. #line 560 "./typica.w"
  6272. /*557:*/
  6273. #line 12157 "./typica.w"
  6274. QString SaltModel::arrayLiteral(int column,int role)const
  6275. {
  6276. QString literal= "'{";
  6277. for(int i= 0;i<rowCount();i++)
  6278. {
  6279. QString datum= data(index(i,column),role).toString();
  6280. if(!datum.isEmpty())
  6281. {
  6282. literal.append(datum);
  6283. literal.append(", ");
  6284. }
  6285. }
  6286. if(literal.size()> 2)
  6287. {
  6288. literal.chop(2);
  6289. }
  6290. literal.append("}'");
  6291. return literal;
  6292. }
  6293. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6294. {
  6295. QString literal= "'{";
  6296. for(int i= 0;i<rowCount();i++)
  6297. {
  6298. QString datum= data(index(i,column),role).toString();
  6299. if(!datum.isEmpty())
  6300. {
  6301. literal.append("\"");
  6302. literal.append(datum);
  6303. literal.append("\", ");
  6304. }
  6305. }
  6306. if(literal.size()> 2)
  6307. {
  6308. literal.chop(2);
  6309. }
  6310. literal.append("}'");
  6311. return literal;
  6312. }
  6313. /*:557*//*558:*/
  6314. #line 12201 "./typica.w"
  6315. QModelIndex SaltModel::parent(const QModelIndex&)const
  6316. {
  6317. return QModelIndex();
  6318. }
  6319. /*:558*//*559:*/
  6320. #line 12220 "./typica.w"
  6321. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6322. int role)
  6323. {
  6324. /*560:*/
  6325. #line 12251 "./typica.w"
  6326. bool valid= false;
  6327. if(index.isValid())
  6328. {
  6329. if(index.row()<modelData.size())
  6330. {
  6331. if(index.column()<colcount)
  6332. {
  6333. valid= true;
  6334. }
  6335. }
  6336. }
  6337. /*:560*/
  6338. #line 12224 "./typica.w"
  6339. if(!valid)
  6340. {
  6341. return false;
  6342. }
  6343. if(index.row()==modelData.size()-1)
  6344. {
  6345. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6346. /*561:*/
  6347. #line 12267 "./typica.w"
  6348. QList<QMap<int,QVariant> > newRow;
  6349. QMap<int,QVariant> defaults;
  6350. for(int i= 0;i<colcount;i++)
  6351. {
  6352. newRow.append(defaults);
  6353. }
  6354. modelData.append(newRow);
  6355. /*:561*/
  6356. #line 12232 "./typica.w"
  6357. endInsertRows();
  6358. }
  6359. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6360. QMap<int,QVariant> cell= row.at(index.column());
  6361. cell.insert(role,value);
  6362. if(role==Qt::EditRole)
  6363. {
  6364. cell.insert(Qt::DisplayRole,value);
  6365. }
  6366. row.replace(index.column(),cell);
  6367. modelData.replace(index.row(),row);
  6368. emit dataChanged(index,index);
  6369. return true;
  6370. }
  6371. /*:559*//*562:*/
  6372. #line 12278 "./typica.w"
  6373. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6374. {
  6375. for(int i= 0;i<columns;i++)
  6376. {
  6377. hData<<"";
  6378. }
  6379. /*561:*/
  6380. #line 12267 "./typica.w"
  6381. QList<QMap<int,QVariant> > newRow;
  6382. QMap<int,QVariant> defaults;
  6383. for(int i= 0;i<colcount;i++)
  6384. {
  6385. newRow.append(defaults);
  6386. }
  6387. modelData.append(newRow);
  6388. /*:561*/
  6389. #line 12285 "./typica.w"
  6390. }
  6391. /*:562*//*563:*/
  6392. #line 12290 "./typica.w"
  6393. SaltModel::~SaltModel()
  6394. {
  6395. }
  6396. /*:563*//*564:*/
  6397. #line 12300 "./typica.w"
  6398. int SaltModel::rowCount(const QModelIndex&parent)const
  6399. {
  6400. return(parent==QModelIndex()?modelData.size():0);
  6401. }
  6402. int SaltModel::columnCount(const QModelIndex&parent)const
  6403. {
  6404. return(parent==QModelIndex()?colcount:0);
  6405. }
  6406. /*:564*//*565:*/
  6407. #line 12313 "./typica.w"
  6408. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6409. const QVariant&value,int)
  6410. {
  6411. if(orientation==Qt::Horizontal&&section<colcount)
  6412. {
  6413. hData.replace(section,value.toString());
  6414. emit headerDataChanged(orientation,section,section);
  6415. return true;
  6416. }
  6417. return false;
  6418. }
  6419. /*:565*//*566:*/
  6420. #line 12328 "./typica.w"
  6421. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6422. {
  6423. /*560:*/
  6424. #line 12251 "./typica.w"
  6425. bool valid= false;
  6426. if(index.isValid())
  6427. {
  6428. if(index.row()<modelData.size())
  6429. {
  6430. if(index.column()<colcount)
  6431. {
  6432. valid= true;
  6433. }
  6434. }
  6435. }
  6436. /*:560*/
  6437. #line 12331 "./typica.w"
  6438. if(!valid)
  6439. {
  6440. return QVariant();
  6441. }
  6442. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6443. QMap<int,QVariant> cell= row.at(index.column());
  6444. return cell.value(role,QVariant());
  6445. }
  6446. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6447. int role)const
  6448. {
  6449. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6450. section<colcount)
  6451. {
  6452. return QVariant(hData.at(section));
  6453. }
  6454. return QVariant();
  6455. }
  6456. /*:566*//*567:*/
  6457. #line 12355 "./typica.w"
  6458. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6459. {
  6460. /*560:*/
  6461. #line 12251 "./typica.w"
  6462. bool valid= false;
  6463. if(index.isValid())
  6464. {
  6465. if(index.row()<modelData.size())
  6466. {
  6467. if(index.column()<colcount)
  6468. {
  6469. valid= true;
  6470. }
  6471. }
  6472. }
  6473. /*:560*/
  6474. #line 12358 "./typica.w"
  6475. if(valid)
  6476. {
  6477. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6478. }
  6479. return 0;
  6480. }
  6481. /*:567*//*568:*/
  6482. #line 12369 "./typica.w"
  6483. QModelIndex SaltModel::index(int row,int column,
  6484. const QModelIndex&parent)const
  6485. {
  6486. if(parent==QModelIndex())
  6487. {
  6488. if(row<modelData.size()&&column<colcount)
  6489. {
  6490. return createIndex(row,column);
  6491. }
  6492. }
  6493. return QModelIndex();
  6494. }
  6495. /*:568*//*569:*/
  6496. #line 12387 "./typica.w"
  6497. void SaltModel::clear()
  6498. {
  6499. beginResetModel();
  6500. modelData.clear();
  6501. /*561:*/
  6502. #line 12267 "./typica.w"
  6503. QList<QMap<int,QVariant> > newRow;
  6504. QMap<int,QVariant> defaults;
  6505. for(int i= 0;i<colcount;i++)
  6506. {
  6507. newRow.append(defaults);
  6508. }
  6509. modelData.append(newRow);
  6510. /*:561*/
  6511. #line 12392 "./typica.w"
  6512. endResetModel();
  6513. }
  6514. /*:569*//*570:*/
  6515. #line 12401 "./typica.w"
  6516. bool SaltModel::removeRows(int row,int count,
  6517. const QModelIndex&parent)
  6518. {
  6519. if(parent==QModelIndex())
  6520. {
  6521. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6522. {
  6523. beginRemoveRows(parent,row,row+count-1);
  6524. for(int i= 0;i<count;i++)
  6525. {
  6526. modelData.removeAt(row);
  6527. }
  6528. endRemoveRows();
  6529. if(modelData.size()==0)
  6530. {
  6531. beginInsertRows(parent,0,0);
  6532. /*561:*/
  6533. #line 12267 "./typica.w"
  6534. QList<QMap<int,QVariant> > newRow;
  6535. QMap<int,QVariant> defaults;
  6536. for(int i= 0;i<colcount;i++)
  6537. {
  6538. newRow.append(defaults);
  6539. }
  6540. modelData.append(newRow);
  6541. /*:561*/
  6542. #line 12418 "./typica.w"
  6543. endInsertRows();
  6544. }
  6545. return true;
  6546. }
  6547. }
  6548. return false;
  6549. }
  6550. /*:570*//*571:*/
  6551. #line 12432 "./typica.w"
  6552. int SaltModel::findData(const QVariant&value,int column,int role)
  6553. {
  6554. for(int i= 0;i<modelData.size();i++)
  6555. {
  6556. if(modelData.at(i).size()> column)
  6557. {
  6558. if(modelData.at(i).at(column).contains(role))
  6559. {
  6560. if(modelData.at(i).at(column).value(role)==value)
  6561. {
  6562. return i;
  6563. }
  6564. }
  6565. }
  6566. }
  6567. return-1;
  6568. }
  6569. /*:571*/
  6570. #line 561 "./typica.w"
  6571. /*573:*/
  6572. #line 12496 "./typica.w"
  6573. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6574. {
  6575. SqlComboBox*widget= new SqlComboBox();
  6576. widget->setParent(parent);
  6577. for(int i= 0;i<count();i++)
  6578. {
  6579. widget->addItem(itemText(i),itemData(i));
  6580. }
  6581. return widget;
  6582. }
  6583. /*:573*//*574:*/
  6584. #line 12513 "./typica.w"
  6585. void SqlComboBox::showData(bool show)
  6586. {
  6587. dataColumnShown= show;
  6588. }
  6589. /*:574*//*575:*/
  6590. #line 12527 "./typica.w"
  6591. void SqlComboBox::addNullOption()
  6592. {
  6593. addItem(specialNullText,specialNullData);
  6594. }
  6595. void SqlComboBox::setNullText(QString nullText)
  6596. {
  6597. specialNullText= nullText;
  6598. }
  6599. void SqlComboBox::setNullData(QVariant nullData)
  6600. {
  6601. specialNullData= nullData;
  6602. }
  6603. /*:575*//*576:*/
  6604. #line 12550 "./typica.w"
  6605. void SqlComboBox::setDataColumn(int column)
  6606. {
  6607. dataColumn= column;
  6608. }
  6609. void SqlComboBox::setDisplayColumn(int column)
  6610. {
  6611. displayColumn= column;
  6612. }
  6613. /*:576*//*577:*/
  6614. #line 12564 "./typica.w"
  6615. void SqlComboBox::addSqlOptions(QString query)
  6616. {
  6617. SqlQueryConnection h;
  6618. QSqlQuery*dbquery= h.operator->();
  6619. if(!dbquery->exec(query))
  6620. {
  6621. QSqlError error= dbquery->lastError();
  6622. qDebug()<<error.databaseText();
  6623. qDebug()<<error.driverText();
  6624. qDebug()<<error.text();
  6625. qDebug()<<dbquery->lastQuery();
  6626. }
  6627. while(dbquery->next())
  6628. {
  6629. QString displayValue(dbquery->value(displayColumn).toString());
  6630. QString dataValue(dbquery->value(dataColumn).toString());
  6631. if(dataColumnShown)
  6632. {
  6633. displayValue.append(QString(" (%1)").arg(dataValue));
  6634. }
  6635. addItem(displayValue,dataValue);
  6636. }
  6637. }
  6638. /*:577*//*578:*/
  6639. #line 12600 "./typica.w"
  6640. SqlComboBox::SqlComboBox():
  6641. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6642. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6643. {
  6644. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6645. }
  6646. SqlComboBox::~SqlComboBox()
  6647. {
  6648. }
  6649. /*:578*/
  6650. #line 562 "./typica.w"
  6651. /*580:*/
  6652. #line 12639 "./typica.w"
  6653. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6654. {
  6655. delegate= widget;
  6656. }
  6657. /*:580*//*581:*/
  6658. #line 12648 "./typica.w"
  6659. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6660. const QStyleOptionViewItem&,
  6661. const QModelIndex&)const
  6662. {
  6663. return delegate->clone(parent);
  6664. }
  6665. /*:581*//*582:*/
  6666. #line 12659 "./typica.w"
  6667. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6668. const QModelIndex&index)const
  6669. {
  6670. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6671. self->setCurrentIndex(self->findData(
  6672. index.model()->data(index,
  6673. Qt::UserRole).toString()));
  6674. }
  6675. /*:582*//*583:*/
  6676. #line 12672 "./typica.w"
  6677. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6678. QAbstractItemModel*model,
  6679. const QModelIndex&index)const
  6680. {
  6681. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6682. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6683. Qt::UserRole);
  6684. model->setData(index,self->currentText(),Qt::DisplayRole);
  6685. }
  6686. /*:583*//*584:*/
  6687. #line 12685 "./typica.w"
  6688. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6689. const QStyleOptionViewItem&option,
  6690. const QModelIndex&)const
  6691. {
  6692. editor->setGeometry(option.rect);
  6693. }
  6694. /*:584*//*585:*/
  6695. #line 12696 "./typica.w"
  6696. QSize SqlComboBoxDelegate::sizeHint()const
  6697. {
  6698. return delegate->sizeHint();
  6699. }
  6700. /*:585*//*586:*/
  6701. #line 12704 "./typica.w"
  6702. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6703. :QItemDelegate(parent)
  6704. {
  6705. }
  6706. /*:586*/
  6707. #line 563 "./typica.w"
  6708. /*549:*/
  6709. #line 11966 "./typica.w"
  6710. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6711. {
  6712. /*550:*/
  6713. #line 11981 "./typica.w"
  6714. setOrganizationName("Wilson's Coffee & Tea");
  6715. setOrganizationDomain("wilsonscoffee.com");
  6716. setApplicationName(PROGRAM_NAME);
  6717. /*:550*/
  6718. #line 11969 "./typica.w"
  6719. /*551:*/
  6720. #line 11990 "./typica.w"
  6721. QTranslator base;
  6722. if(base.load(QString("qt_%1").arg(QLocale::system().name())))
  6723. {
  6724. installTranslator(&base);
  6725. }
  6726. QTranslator app;
  6727. if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
  6728. {
  6729. installTranslator(&app);
  6730. }
  6731. /*:551*/
  6732. #line 11970 "./typica.w"
  6733. /*269:*/
  6734. #line 123 "./measurement.w"
  6735. qRegisterMetaType<Measurement> ("Measurement");
  6736. /*:269*/
  6737. #line 11971 "./typica.w"
  6738. /*757:*/
  6739. #line 15905 "./typica.w"
  6740. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6741. tr("NI DAQmx Base"),
  6742. "nidaqmxbase",NULL);
  6743. topLevelNodeInserters.append(inserter);
  6744. /*:757*//*765:*/
  6745. #line 16136 "./typica.w"
  6746. #ifdef Q_OS_WIN32
  6747. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6748. topLevelNodeInserters.append(inserter);
  6749. #endif
  6750. /*:765*//*789:*/
  6751. #line 17099 "./typica.w"
  6752. #if 0
  6753. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6754. topLevelNodeInserters.append(inserter);
  6755. #endif
  6756. /*:789*//*838:*/
  6757. #line 18612 "./typica.w"
  6758. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6759. topLevelNodeInserters.append(inserter);
  6760. #line 1 "./unsupportedserial.w"
  6761. /*:838*//*848:*/
  6762. #line 272 "./unsupportedserial.w"
  6763. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  6764. "unsupporteddevice",NULL);
  6765. topLevelNodeInserters.append(inserter);
  6766. /*:848*//*879:*/
  6767. #line 190 "./phidgets.w"
  6768. QLibrary phidgetsCheck("phidget21");
  6769. if(phidgetsCheck.load())
  6770. {
  6771. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6772. "phidgets1048",NULL);
  6773. topLevelNodeInserters.append(inserter);
  6774. phidgetsCheck.unload();
  6775. }
  6776. else
  6777. {
  6778. phidgetsCheck.setFileName("Phidget21.framework/phidget21");
  6779. if(phidgetsCheck.load())
  6780. {
  6781. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6782. "phidgets1048",NULL);
  6783. topLevelNodeInserters.append(inserter);
  6784. phidgetsCheck.unload();
  6785. }
  6786. }
  6787. /*:879*//*956:*/
  6788. #line 1241 "./dataqsdk.w"
  6789. #ifdef Q_OS_WIN32
  6790. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  6791. "dataqsdk",NULL);
  6792. topLevelNodeInserters.append(inserter);
  6793. #endif
  6794. #line 18836 "./typica.w"
  6795. #line 1 "./scales.w"
  6796. /*:956*//*981:*/
  6797. #line 495 "./scales.w"
  6798. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  6799. topLevelNodeInserters.append(inserter);
  6800. #line 18838 "./typica.w"
  6801. #line 1 "./valueannotation.w"
  6802. /*:981*/
  6803. #line 11972 "./typica.w"
  6804. }
  6805. /*:549*//*553:*/
  6806. #line 12013 "./typica.w"
  6807. QDomDocument*Application::configuration()
  6808. {
  6809. return&conf;
  6810. }
  6811. /*:553*//*554:*/
  6812. #line 12022 "./typica.w"
  6813. QSqlDatabase Application::database()
  6814. {
  6815. QString connectionName;
  6816. QSqlDatabase connection=
  6817. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  6818. do
  6819. {
  6820. connectionName= QUuid::createUuid().toString();
  6821. }while(QSqlDatabase::connectionNames().contains(connectionName));
  6822. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  6823. }
  6824. /*:554*//*692:*/
  6825. #line 14508 "./typica.w"
  6826. void Application::saveDeviceConfiguration()
  6827. {
  6828. QSettings settings;
  6829. settings.setValue("DeviceConfiguration",
  6830. QVariant(deviceConfigurationDocument.toByteArray()));
  6831. }
  6832. /*:692*//*693:*/
  6833. #line 14520 "./typica.w"
  6834. QDomDocument Application::deviceConfiguration()
  6835. {
  6836. if(deviceConfigurationDocument.isNull())
  6837. {
  6838. /*694:*/
  6839. #line 14534 "./typica.w"
  6840. QSettings settings;
  6841. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  6842. QString etext;
  6843. int eline;
  6844. int ecol;
  6845. if(document.length()==0)
  6846. {
  6847. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  6848. /*695:*/
  6849. #line 14558 "./typica.w"
  6850. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6851. emptyDocument.open(QIODevice::ReadOnly);
  6852. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6853. &etext,&eline,&ecol))
  6854. {
  6855. /*696:*/
  6856. #line 14575 "./typica.w"
  6857. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6858. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6859. qDebug()<<etext;
  6860. /*:696*/
  6861. #line 14564 "./typica.w"
  6862. }
  6863. else
  6864. {
  6865. saveDeviceConfiguration();
  6866. }
  6867. /*:695*/
  6868. #line 14543 "./typica.w"
  6869. }
  6870. else
  6871. {
  6872. if(!deviceConfigurationDocument.setContent(document,false,
  6873. &etext,&eline,&ecol))
  6874. {
  6875. /*696:*/
  6876. #line 14575 "./typica.w"
  6877. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6878. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6879. qDebug()<<etext;
  6880. /*:696*/
  6881. #line 14550 "./typica.w"
  6882. /*695:*/
  6883. #line 14558 "./typica.w"
  6884. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6885. emptyDocument.open(QIODevice::ReadOnly);
  6886. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6887. &etext,&eline,&ecol))
  6888. {
  6889. /*696:*/
  6890. #line 14575 "./typica.w"
  6891. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6892. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6893. qDebug()<<etext;
  6894. /*:696*/
  6895. #line 14564 "./typica.w"
  6896. }
  6897. else
  6898. {
  6899. saveDeviceConfiguration();
  6900. }
  6901. /*:695*/
  6902. #line 14551 "./typica.w"
  6903. }
  6904. }
  6905. /*:694*/
  6906. #line 14525 "./typica.w"
  6907. }
  6908. return deviceConfigurationDocument;
  6909. }
  6910. /*:693*//*724:*/
  6911. #line 15176 "./typica.w"
  6912. void Application::registerDeviceConfigurationWidget(QString driver,
  6913. QMetaObject widget)
  6914. {
  6915. deviceConfigurationWidgets.insert(driver,widget);
  6916. }
  6917. /*:724*//*725:*/
  6918. #line 15192 "./typica.w"
  6919. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  6920. const QModelIndex&index)
  6921. {
  6922. QVariant nodeReference= index.data(Qt::UserRole);
  6923. QDomElement referenceElement= model->referenceElement(
  6924. model->data(index,Qt::UserRole).toString());
  6925. QMetaObject metaObject=
  6926. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  6927. QWidget::staticMetaObject);
  6928. QWidget*editor;
  6929. if(metaObject.className()==QWidget::staticMetaObject.className())
  6930. {
  6931. editor= NULL;
  6932. }
  6933. else
  6934. {
  6935. editor= qobject_cast<QWidget*> (
  6936. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  6937. Q_ARG(QModelIndex,index)));
  6938. }
  6939. return editor;
  6940. }
  6941. /*:725*/
  6942. #line 564 "./typica.w"
  6943. /*595:*/
  6944. #line 12851 "./typica.w"
  6945. SqlConnectionSetup::SqlConnectionSetup():
  6946. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  6947. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  6948. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  6949. cancelButton(new QPushButton(tr("Cancel"))),
  6950. connectButton(new QPushButton(tr("Connect")))
  6951. {
  6952. driver->addItem("PostgreSQL","QPSQL");
  6953. formLayout->addRow(tr("Database driver:"),driver);
  6954. formLayout->addRow(tr("Host name:"),hostname);
  6955. formLayout->addRow(tr("Database name:"),dbname);
  6956. formLayout->addRow(tr("User name:"),user);
  6957. password->setEchoMode(QLineEdit::Password);
  6958. formLayout->addRow(tr("Password:"),password);
  6959. layout->addLayout(formLayout);
  6960. buttons->addStretch(1);
  6961. buttons->addWidget(cancelButton);
  6962. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  6963. buttons->addWidget(connectButton);
  6964. layout->addLayout(buttons);
  6965. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  6966. setLayout(layout);
  6967. setModal(true);
  6968. }
  6969. SqlConnectionSetup::~SqlConnectionSetup()
  6970. {
  6971. }
  6972. /*:595*//*596:*/
  6973. #line 12885 "./typica.w"
  6974. void SqlConnectionSetup::testConnection()
  6975. {
  6976. QSqlDatabase database=
  6977. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  6978. toString());
  6979. database.setConnectOptions("application_name=Typica");
  6980. database.setHostName(hostname->text());
  6981. database.setDatabaseName(dbname->text());
  6982. database.setUserName(user->text());
  6983. database.setPassword(password->text());
  6984. if(database.open())
  6985. {
  6986. QSettings settings;
  6987. settings.setValue("database/exists","true");
  6988. settings.setValue("database/driver",
  6989. driver->itemData(driver->currentIndex()).toString());
  6990. settings.setValue("database/hostname",hostname->text());
  6991. settings.setValue("database/dbname",dbname->text());
  6992. settings.setValue("database/user",user->text());
  6993. settings.setValue("database/password",password->text());
  6994. database.close();
  6995. accept();
  6996. }
  6997. else
  6998. {
  6999. QMessageBox::information(this,tr("Database connection failed"),
  7000. tr("Failed to connect to database."));
  7001. }
  7002. }
  7003. /*:596*/
  7004. #line 565 "./typica.w"
  7005. /*600:*/
  7006. #line 12987 "./typica.w"
  7007. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7008. {
  7009. setModel(new QSqlQueryModel);
  7010. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7011. this,SLOT(openRow(QModelIndex)));
  7012. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7013. this,SLOT(persistColumnResize(int,int,int)));
  7014. }
  7015. /*:600*//*601:*/
  7016. #line 13002 "./typica.w"
  7017. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7018. {
  7019. /*602:*/
  7020. #line 13011 "./typica.w"
  7021. QSettings settings;
  7022. /*603:*/
  7023. #line 13024 "./typica.w"
  7024. QWidget*topLevelWidget= this;
  7025. while(topLevelWidget->parentWidget())
  7026. {
  7027. topLevelWidget= topLevelWidget->parentWidget();
  7028. }
  7029. /*:603*/
  7030. #line 13013 "./typica.w"
  7031. settings.setValue(QString("columnWidths/%1/%2/%3").
  7032. arg(topLevelWidget->objectName()).
  7033. arg(objectName()).arg(column),
  7034. QVariant(newsize));
  7035. /*:602*/
  7036. #line 13005 "./typica.w"
  7037. }
  7038. /*:601*//*604:*/
  7039. #line 13034 "./typica.w"
  7040. void SqlQueryView::showEvent(QShowEvent*event)
  7041. {
  7042. /*605:*/
  7043. #line 13044 "./typica.w"
  7044. QSettings settings;
  7045. /*603:*/
  7046. #line 13024 "./typica.w"
  7047. QWidget*topLevelWidget= this;
  7048. while(topLevelWidget->parentWidget())
  7049. {
  7050. topLevelWidget= topLevelWidget->parentWidget();
  7051. }
  7052. /*:603*/
  7053. #line 13046 "./typica.w"
  7054. QString baseKey=
  7055. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7056. arg(objectName());
  7057. for(int i= 0;i<model()->columnCount();i++)
  7058. {
  7059. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7060. if(settings.contains(key))
  7061. {
  7062. setColumnWidth(i,settings.value(key).toInt());
  7063. }
  7064. }
  7065. /*:605*/
  7066. #line 13037 "./typica.w"
  7067. event->accept();
  7068. }
  7069. /*:604*//*606:*/
  7070. #line 13061 "./typica.w"
  7071. void SqlQueryView::openRow(const QModelIndex&index)
  7072. {
  7073. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7074. emit openEntryRow(index.row());
  7075. }
  7076. /*:606*//*607:*/
  7077. #line 13070 "./typica.w"
  7078. void SqlQueryView::setQuery(const QString&query)
  7079. {
  7080. QSqlDatabase database= AppInstance->database();
  7081. database.open();
  7082. QSqlQuery q(query,database);
  7083. ((QSqlQueryModel*)model())->setQuery(q);
  7084. database.close();
  7085. }
  7086. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7087. const QVariant&value,int role)
  7088. {
  7089. return model()->setHeaderData(section,orientation,value,role);
  7090. }
  7091. /*:607*//*608:*/
  7092. #line 13088 "./typica.w"
  7093. QVariant SqlQueryView::data(int row,int column,int role)
  7094. {
  7095. return model()->data(model()->index(row,column),role);
  7096. }
  7097. /*:608*/
  7098. #line 566 "./typica.w"
  7099. /*149:*/
  7100. #line 3453 "./typica.w"
  7101. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7102. {
  7103. QSqlDatabase database= AppInstance->database();
  7104. database.open();
  7105. q= new QSqlQuery(query,database);
  7106. connection= database.connectionName();
  7107. }
  7108. /*:149*//*150:*/
  7109. #line 3466 "./typica.w"
  7110. SqlQueryConnection::~SqlQueryConnection()
  7111. {
  7112. delete q;
  7113. {
  7114. QSqlDatabase database= QSqlDatabase::database(connection);
  7115. database.close();
  7116. }
  7117. QSqlDatabase::removeDatabase(connection);
  7118. }
  7119. /*:150*//*151:*/
  7120. #line 3480 "./typica.w"
  7121. QSqlQuery*SqlQueryConnection::operator->()const
  7122. {
  7123. return q;
  7124. }
  7125. /*:151*/
  7126. #line 567 "./typica.w"
  7127. /*627:*/
  7128. #line 13445 "./typica.w"
  7129. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7130. area(frame),configuration(description)
  7131. {
  7132. refresh();
  7133. }
  7134. ReportTable::~ReportTable()
  7135. {
  7136. }
  7137. /*:627*//*628:*/
  7138. #line 13461 "./typica.w"
  7139. void ReportTable::bind(QString placeholder,QVariant value)
  7140. {
  7141. bindings.insert(placeholder,value);
  7142. }
  7143. /*:628*//*629:*/
  7144. #line 13471 "./typica.w"
  7145. void ReportTable::refresh()
  7146. {
  7147. /*630:*/
  7148. #line 13492 "./typica.w"
  7149. QTextCursor cursor= area->firstCursorPosition();
  7150. while(cursor<area->lastCursorPosition())
  7151. {
  7152. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7153. }
  7154. cursor.removeSelectedText();
  7155. /*:630*/
  7156. #line 13474 "./typica.w"
  7157. int rows= 1;
  7158. int columns= 1;
  7159. int currentRow= 0;
  7160. QTextTable*table= cursor.insertTable(rows,columns);
  7161. /*631:*/
  7162. #line 13505 "./typica.w"
  7163. QTextTableFormat format= table->format();
  7164. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7165. if(configuration.hasAttribute("align"))
  7166. {
  7167. if(configuration.attribute("align")=="center")
  7168. {
  7169. format.setAlignment(Qt::AlignHCenter);
  7170. }
  7171. }
  7172. table->setFormat(format);
  7173. /*:631*/
  7174. #line 13479 "./typica.w"
  7175. /*632:*/
  7176. #line 13519 "./typica.w"
  7177. QDomNodeList children= configuration.childNodes();
  7178. for(int i= 0;i<children.count();i++)
  7179. {
  7180. QDomNode current;
  7181. QDomElement currentElement;
  7182. current= children.at(i);
  7183. if(current.isElement())
  7184. {
  7185. currentElement= current.toElement();
  7186. if(currentElement.tagName()=="query")
  7187. {
  7188. /*633:*/
  7189. #line 13546 "./typica.w"
  7190. SqlQueryConnection h;
  7191. QSqlQuery*query= h.operator->();
  7192. query->prepare(currentElement.text());
  7193. foreach(QString key,bindings.uniqueKeys())
  7194. {
  7195. if(currentElement.text().contains(key))
  7196. {
  7197. query->bindValue(key,bindings.value(key));
  7198. }
  7199. }
  7200. query->exec();
  7201. if(!query->next())
  7202. {
  7203. continue;
  7204. }
  7205. if(query->record().count()> columns)
  7206. {
  7207. table->appendColumns(query->record().count()-columns);
  7208. }
  7209. do
  7210. {
  7211. table->appendRows(1);
  7212. rows++;
  7213. currentRow++;
  7214. for(int j= 0;j<query->record().count();j++)
  7215. {
  7216. QTextTableCell cell= table->cellAt(currentRow,j);
  7217. cursor= cell.firstCursorPosition();
  7218. cursor.insertText(query->value(j).toString());
  7219. }
  7220. }while(query->next());
  7221. /*:633*/
  7222. #line 13531 "./typica.w"
  7223. }
  7224. else if(currentElement.tagName()=="row")
  7225. {
  7226. /*634:*/
  7227. #line 13586 "./typica.w"
  7228. table->appendRows(1);
  7229. currentRow++;
  7230. rows++;
  7231. QDomNodeList rowChildren= currentElement.childNodes();
  7232. int currentColumn= 0;
  7233. for(int j= 0;j<rowChildren.count();j++)
  7234. {
  7235. QDomNode node;
  7236. QDomElement nodeElement;
  7237. node= rowChildren.at(j);
  7238. if(node.isElement())
  7239. {
  7240. nodeElement= node.toElement();
  7241. if(nodeElement.tagName()=="cell")
  7242. {
  7243. if(currentColumn==columns)
  7244. {
  7245. table->appendColumns(1);
  7246. columns++;
  7247. }
  7248. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7249. cursor= cell.firstCursorPosition();
  7250. cursor.insertText(nodeElement.text());
  7251. currentColumn++;
  7252. }
  7253. }
  7254. }
  7255. /*:634*/
  7256. #line 13535 "./typica.w"
  7257. }
  7258. }
  7259. }
  7260. /*:632*/
  7261. #line 13480 "./typica.w"
  7262. if(rows> 1)
  7263. {
  7264. table->removeRows(0,1);
  7265. }
  7266. }
  7267. /*:629*/
  7268. #line 568 "./typica.w"
  7269. /*660:*/
  7270. #line 13690 "./typica.w"
  7271. FormArray::FormArray(QDomElement description):configuration(description),
  7272. maxwidth(-1),maxheight(-1)
  7273. {
  7274. setWidget(&itemContainer);
  7275. itemContainer.setLayout(&itemLayout);
  7276. }
  7277. /*:660*//*661:*/
  7278. #line 13707 "./typica.w"
  7279. void FormArray::addElements(int copies)
  7280. {
  7281. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7282. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7283. QWidget*widget;
  7284. for(int i= 0;i<copies;i++)
  7285. {
  7286. widget= new QWidget;
  7287. if(maxwidth> -1)
  7288. {
  7289. widget->setMaximumWidth(maxwidth);
  7290. }
  7291. if(maxheight> -1)
  7292. {
  7293. widget->setMaximumHeight(maxheight);
  7294. }
  7295. if(configuration.hasChildNodes())
  7296. {
  7297. widgetStack->push(widget);
  7298. populateWidget(configuration,widgetStack,layoutStack);
  7299. widgetStack->pop();
  7300. widget->setMinimumHeight(widget->sizeHint().height());
  7301. itemLayout.addWidget(widget);
  7302. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7303. {
  7304. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7305. }
  7306. else
  7307. {
  7308. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7309. +widget->sizeHint().height());
  7310. }
  7311. if(maxwidth> -1)
  7312. {
  7313. itemContainer.setMinimumWidth(maxwidth+50);
  7314. }
  7315. else
  7316. {
  7317. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7318. }
  7319. }
  7320. }
  7321. }
  7322. /*:661*//*662:*/
  7323. #line 13757 "./typica.w"
  7324. QWidget*FormArray::elementAt(int index)
  7325. {
  7326. if(index<itemLayout.count())
  7327. {
  7328. QLayoutItem*item= itemLayout.itemAt(index);
  7329. return item->widget();
  7330. }
  7331. else
  7332. {
  7333. return NULL;
  7334. }
  7335. }
  7336. /*:662*//*663:*/
  7337. #line 13774 "./typica.w"
  7338. void FormArray::removeAllElements()
  7339. {
  7340. while(itemLayout.count()> 0)
  7341. {
  7342. QLayoutItem*item;
  7343. item= itemLayout.itemAt(0);
  7344. item->widget()->hide();
  7345. itemLayout.removeWidget(item->widget());
  7346. }
  7347. itemContainer.setMinimumHeight(0);
  7348. }
  7349. /*:663*//*664:*/
  7350. #line 13790 "./typica.w"
  7351. int FormArray::elements()
  7352. {
  7353. return itemLayout.count();
  7354. }
  7355. /*:664*//*665:*/
  7356. #line 13801 "./typica.w"
  7357. void FormArray::setMaximumElementWidth(int width)
  7358. {
  7359. maxwidth= width;
  7360. }
  7361. void FormArray::setMaximumElementHeight(int height)
  7362. {
  7363. maxheight= height;
  7364. }
  7365. /*:665*/
  7366. #line 569 "./typica.w"
  7367. /*671:*/
  7368. #line 13932 "./typica.w"
  7369. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7370. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7371. {
  7372. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7373. QPointF(0,5);
  7374. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7375. QPointF(10,5);
  7376. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7377. QPointF(0,0);
  7378. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7379. initialBrush.setColor(QColor(170,170,255));
  7380. initialBrush.setStyle(Qt::SolidPattern);
  7381. finalBrush.setColor(Qt::blue);
  7382. finalBrush.setStyle(Qt::SolidPattern);
  7383. initialDecrement.setPolygon(left);
  7384. initialDecrement.setBrush(initialBrush);
  7385. initialDecrement.setPos(0,0);
  7386. scene.addItem(&initialDecrement);
  7387. initialIncrement.setPolygon(right);
  7388. initialIncrement.setBrush(initialBrush);
  7389. initialIncrement.setPos(122,0);
  7390. scene.addItem(&initialIncrement);
  7391. finalDecrement.setPolygon(left);
  7392. finalDecrement.setBrush(finalBrush);
  7393. finalDecrement.setPos(0,12);
  7394. scene.addItem(&finalDecrement);
  7395. finalIncrement.setPolygon(right);
  7396. finalIncrement.setBrush(finalBrush);
  7397. finalIncrement.setPos(122,12);
  7398. scene.addItem(&finalIncrement);
  7399. scalePath.moveTo(0,10);
  7400. scalePath.lineTo(100,10);
  7401. scalePath.moveTo(0,0);
  7402. scalePath.lineTo(0,20);
  7403. scalePath.moveTo(10,5);
  7404. scalePath.lineTo(10,15);
  7405. scalePath.moveTo(20,5);
  7406. scalePath.lineTo(20,15);
  7407. scalePath.moveTo(30,5);
  7408. scalePath.lineTo(30,15);
  7409. scalePath.moveTo(40,5);
  7410. scalePath.lineTo(40,15);
  7411. scalePath.moveTo(50,0);
  7412. scalePath.lineTo(50,20);
  7413. scalePath.moveTo(60,5);
  7414. scalePath.lineTo(60,15);
  7415. scalePath.moveTo(70,5);
  7416. scalePath.lineTo(70,15);
  7417. scalePath.moveTo(80,5);
  7418. scalePath.lineTo(80,15);
  7419. scalePath.moveTo(90,5);
  7420. scalePath.lineTo(90,15);
  7421. scalePath.moveTo(100,0);
  7422. scalePath.lineTo(100,20);
  7423. scaleLine.setPath(scalePath);
  7424. scaleLine.setPos(16,1);
  7425. scene.addItem(&scaleLine);
  7426. setScene(&scene);
  7427. initialIndicator.setPolygon(down);
  7428. initialIndicator.setBrush(initialBrush);
  7429. finalIndicator.setPolygon(up);
  7430. finalIndicator.setBrush(finalBrush);
  7431. setMinimumSize(sizeHint());
  7432. setMaximumSize(sizeHint());
  7433. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7434. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7435. setMinimumSize(sizeHint());
  7436. }
  7437. /*:671*//*672:*/
  7438. #line 14005 "./typica.w"
  7439. QSize ScaleControl::sizeHint()const
  7440. {
  7441. return QSize(140,30);
  7442. }
  7443. /*:672*//*673:*/
  7444. #line 14014 "./typica.w"
  7445. void ScaleControl::setInitialValue(double value)
  7446. {
  7447. if(value>=0&&value<=10)
  7448. {
  7449. nonScoredValue= value;
  7450. if(!initialSet)
  7451. {
  7452. scene.addItem(&initialIndicator);
  7453. }
  7454. initialSet= true;
  7455. initialIndicator.setPos(value*10+16,10);
  7456. emit initialChanged(value);
  7457. if(!finalSet)
  7458. {
  7459. setFinalValue(value);
  7460. }
  7461. }
  7462. }
  7463. void ScaleControl::setFinalValue(double value)
  7464. {
  7465. if(value>=0&&value<=10)
  7466. {
  7467. scoredValue= value;
  7468. if(!finalSet)
  7469. {
  7470. scene.addItem(&finalIndicator);
  7471. }
  7472. finalSet= true;
  7473. finalIndicator.setPos(value*10+16,11);
  7474. emit finalChanged(value);
  7475. }
  7476. }
  7477. /*:673*//*674:*/
  7478. #line 14051 "./typica.w"
  7479. double ScaleControl::initialValue(void)
  7480. {
  7481. return nonScoredValue;
  7482. }
  7483. double ScaleControl::finalValue(void)
  7484. {
  7485. return scoredValue;
  7486. }
  7487. /*:674*//*675:*/
  7488. #line 14072 "./typica.w"
  7489. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7490. {
  7491. /*676:*/
  7492. #line 14084 "./typica.w"
  7493. if(event->button()!=Qt::LeftButton)
  7494. {
  7495. event->ignore();
  7496. return;
  7497. }
  7498. /*:676*/
  7499. #line 14075 "./typica.w"
  7500. scaleDown= true;
  7501. event->accept();
  7502. }
  7503. /*:675*//*677:*/
  7504. #line 14095 "./typica.w"
  7505. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7506. {
  7507. /*676:*/
  7508. #line 14084 "./typica.w"
  7509. if(event->button()!=Qt::LeftButton)
  7510. {
  7511. event->ignore();
  7512. return;
  7513. }
  7514. /*:676*/
  7515. #line 14098 "./typica.w"
  7516. if(!scaleDown)
  7517. {
  7518. event->ignore();
  7519. return;
  7520. }
  7521. scaleDown= false;
  7522. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7523. /*678:*/
  7524. #line 14120 "./typica.w"
  7525. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7526. {
  7527. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7528. {
  7529. if(initialSet)
  7530. {
  7531. setInitialValue(nonScoredValue-0.05);
  7532. }
  7533. event->accept();
  7534. return;
  7535. }
  7536. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7537. {
  7538. if(finalSet)
  7539. {
  7540. setFinalValue(scoredValue-0.05);
  7541. event->accept();
  7542. return;
  7543. }
  7544. }
  7545. }
  7546. /*:678*/
  7547. #line 14106 "./typica.w"
  7548. /*679:*/
  7549. #line 14146 "./typica.w"
  7550. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7551. {
  7552. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7553. {
  7554. if(initialSet)
  7555. {
  7556. setInitialValue(nonScoredValue+0.05);
  7557. event->accept();
  7558. return;
  7559. }
  7560. }
  7561. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7562. {
  7563. if(finalSet)
  7564. {
  7565. setFinalValue(scoredValue+0.05);
  7566. event->accept();
  7567. return;
  7568. }
  7569. }
  7570. }
  7571. /*:679*/
  7572. #line 14107 "./typica.w"
  7573. /*680:*/
  7574. #line 14172 "./typica.w"
  7575. double relativeX= sceneCoordinate.x()-16;
  7576. if(initialSet)
  7577. {
  7578. if(relativeX>=0&&relativeX<=100)
  7579. {
  7580. setFinalValue(relativeX/10.0);
  7581. event->accept();
  7582. return;
  7583. }
  7584. }
  7585. else
  7586. {
  7587. if(relativeX>=0&&relativeX<=100)
  7588. {
  7589. setInitialValue(relativeX/10.0);
  7590. event->accept();
  7591. return;
  7592. }
  7593. }
  7594. /*:680*/
  7595. #line 14108 "./typica.w"
  7596. event->ignore();
  7597. return;
  7598. }
  7599. /*:677*/
  7600. #line 570 "./typica.w"
  7601. /*682:*/
  7602. #line 14238 "./typica.w"
  7603. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7604. valueSet(false),scaleDown(false)
  7605. {
  7606. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7607. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7608. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7609. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7610. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7611. theBrush.setColor(Qt::blue);
  7612. theBrush.setStyle(Qt::SolidPattern);
  7613. increment.setPolygon(up);
  7614. increment.setBrush(theBrush);
  7615. increment.setPos(0,0);
  7616. scene.addItem(&increment);
  7617. decrement.setPolygon(down);
  7618. decrement.setBrush(theBrush);
  7619. decrement.setPos(0,122);
  7620. scene.addItem(&decrement);
  7621. scalePath.moveTo(5,0);
  7622. scalePath.lineTo(5,100);
  7623. scalePath.moveTo(0,0);
  7624. scalePath.lineTo(10,0);
  7625. scalePath.moveTo(0,10);
  7626. scalePath.lineTo(10,10);
  7627. scalePath.moveTo(0,20);
  7628. scalePath.lineTo(10,20);
  7629. scalePath.moveTo(0,30);
  7630. scalePath.lineTo(10,30);
  7631. scalePath.moveTo(0,40);
  7632. scalePath.lineTo(10,40);
  7633. scalePath.moveTo(0,50);
  7634. scalePath.lineTo(10,50);
  7635. scalePath.moveTo(0,60);
  7636. scalePath.lineTo(10,60);
  7637. scalePath.moveTo(0,70);
  7638. scalePath.lineTo(10,70);
  7639. scalePath.moveTo(0,80);
  7640. scalePath.lineTo(10,80);
  7641. scalePath.moveTo(0,90);
  7642. scalePath.lineTo(10,90);
  7643. scalePath.moveTo(0,100);
  7644. scalePath.lineTo(10,100);
  7645. scaleLine.setPath(scalePath);
  7646. scaleLine.setPos(0,16);
  7647. scene.addItem(&scaleLine);
  7648. setScene(&scene);
  7649. indicator.setPolygon(left);
  7650. indicator.setBrush(theBrush);
  7651. setMinimumSize(sizeHint());
  7652. setMaximumSize(sizeHint());
  7653. }
  7654. /*:682*//*683:*/
  7655. #line 14293 "./typica.w"
  7656. QSize IntensityControl::sizeHint()const
  7657. {
  7658. return QSize(25,160);
  7659. }
  7660. /*:683*//*684:*/
  7661. #line 14308 "./typica.w"
  7662. void IntensityControl::setValue(double val)
  7663. {
  7664. if(val>=0&&val<=10)
  7665. {
  7666. theValue= val;
  7667. if(!valueSet)
  7668. {
  7669. scene.addItem(&indicator);
  7670. }
  7671. valueSet= true;
  7672. indicator.setPos(6,(100-(val*10))+16);
  7673. emit(valueChanged(val));
  7674. }
  7675. else if(val<1)
  7676. {
  7677. setValue(0);
  7678. }
  7679. else
  7680. {
  7681. setValue(10);
  7682. }
  7683. }
  7684. double IntensityControl::value()
  7685. {
  7686. return theValue;
  7687. }
  7688. /*:684*//*685:*/
  7689. #line 14340 "./typica.w"
  7690. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7691. {
  7692. /*676:*/
  7693. #line 14084 "./typica.w"
  7694. if(event->button()!=Qt::LeftButton)
  7695. {
  7696. event->ignore();
  7697. return;
  7698. }
  7699. /*:676*/
  7700. #line 14343 "./typica.w"
  7701. scaleDown= true;
  7702. event->accept();
  7703. }
  7704. /*:685*//*686:*/
  7705. #line 14354 "./typica.w"
  7706. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7707. {
  7708. /*676:*/
  7709. #line 14084 "./typica.w"
  7710. if(event->button()!=Qt::LeftButton)
  7711. {
  7712. event->ignore();
  7713. return;
  7714. }
  7715. /*:676*/
  7716. #line 14357 "./typica.w"
  7717. if(!scaleDown)
  7718. {
  7719. event->ignore();
  7720. return;
  7721. }
  7722. scaleDown= false;
  7723. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7724. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7725. {
  7726. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7727. {
  7728. if(valueSet)
  7729. {
  7730. setValue(theValue+0.05);
  7731. }
  7732. event->accept();
  7733. return;
  7734. }
  7735. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7736. {
  7737. if(valueSet)
  7738. {
  7739. setValue(theValue-0.05);
  7740. }
  7741. event->accept();
  7742. return;
  7743. }
  7744. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7745. {
  7746. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7747. event->accept();
  7748. return;
  7749. }
  7750. }
  7751. }
  7752. /*:686*/
  7753. #line 571 "./typica.w"
  7754. /*338:*/
  7755. #line 7626 "./typica.w"
  7756. void ThresholdDetector::newMeasurement(Measurement measure)
  7757. {
  7758. if((currentDirection==Ascending&&previousValue<threshold&&
  7759. previousValue>=0)||(currentDirection==Descending&&
  7760. previousValue> threshold&&previousValue>=0))
  7761. {
  7762. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7763. (currentDirection==Descending&&measure.temperature()<=threshold))
  7764. {
  7765. double offset= measure.time().hour()*60*60;
  7766. offset+= measure.time().minute()*60;
  7767. offset+= measure.time().second();
  7768. offset+= measure.time().msec()/1000;
  7769. emit timeForValue(offset);
  7770. }
  7771. }
  7772. previousValue= measure.temperature();
  7773. }
  7774. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7775. previousValue(-1),threshold(value),currentDirection(Ascending)
  7776. {
  7777. }
  7778. void ThresholdDetector::setThreshold(double value)
  7779. {
  7780. threshold= value;
  7781. }
  7782. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7783. {
  7784. currentDirection= direction;
  7785. }
  7786. /*:338*/
  7787. #line 572 "./typica.w"
  7788. /*768:*/
  7789. #line 16176 "./typica.w"
  7790. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  7791. lister(new QextSerialEnumerator)
  7792. {
  7793. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  7794. QextPortInfo port;
  7795. foreach(port,ports)
  7796. {
  7797. #ifdef Q_OS_WIN32
  7798. addItem(port.portName);
  7799. #else
  7800. addItem(port.physName);
  7801. #endif
  7802. }
  7803. lister->setUpNotifications();
  7804. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  7805. this,SLOT(addDevice(QextPortInfo)));
  7806. setEditable(true);
  7807. }
  7808. void PortSelector::addDevice(QextPortInfo port)
  7809. {
  7810. addItem(port.portName);
  7811. }
  7812. /*:768*/
  7813. #line 573 "./typica.w"
  7814. /*770:*/
  7815. #line 16268 "./typica.w"
  7816. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  7817. {
  7818. QMetaObject meta= BaudSelector::staticMetaObject;
  7819. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  7820. for(int i= 0;i<type.keyCount();i++)
  7821. {
  7822. addItem(QString("%1").arg(type.value(i)));
  7823. }
  7824. }
  7825. /*:770*/
  7826. #line 574 "./typica.w"
  7827. /*772:*/
  7828. #line 16306 "./typica.w"
  7829. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  7830. {
  7831. QMetaObject meta= ParitySelector::staticMetaObject;
  7832. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  7833. for(int i= 0;i<type.keyCount();i++)
  7834. {
  7835. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7836. }
  7837. }
  7838. /*:772*/
  7839. #line 575 "./typica.w"
  7840. /*774:*/
  7841. #line 16336 "./typica.w"
  7842. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  7843. {
  7844. QMetaObject meta= FlowSelector::staticMetaObject;
  7845. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  7846. for(int i= 0;i<type.keyCount();i++)
  7847. {
  7848. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7849. }
  7850. }
  7851. /*:774*/
  7852. #line 576 "./typica.w"
  7853. /*776:*/
  7854. #line 16371 "./typica.w"
  7855. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  7856. {
  7857. QMetaObject meta= StopSelector::staticMetaObject;
  7858. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  7859. for(int i= 0;i<type.keyCount();i++)
  7860. {
  7861. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7862. }
  7863. }
  7864. /*:776*/
  7865. #line 577 "./typica.w"
  7866. /*836:*/
  7867. #line 18153 "./typica.w"
  7868. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  7869. :BasicDeviceConfigurationWidget(model,index),
  7870. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  7871. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  7872. decimalQuery(new QCheckBox(tr("Enable"))),
  7873. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  7874. unitQuery(new QCheckBox(tr("Enable"))),
  7875. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  7876. valueC(new QSpinBox),fixedUnit(new QComboBox),
  7877. pVAddress(new ShortHexSpinBox),
  7878. sVEnabled(new QCheckBox(tr("Enable"))),
  7879. sVReadAddress(new ShortHexSpinBox),
  7880. deviceLimit(new QCheckBox(tr("Enable"))),
  7881. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  7882. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  7883. sVWritable(new QCheckBox(tr("Enable"))),
  7884. sVOutputAddr(new ShortHexSpinBox),
  7885. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  7886. {
  7887. QHBoxLayout*layout= new QHBoxLayout;
  7888. QWidget*form= new QWidget;
  7889. QHBoxLayout*masterLayout= new QHBoxLayout;
  7890. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  7891. QVBoxLayout*seriesLayout= new QVBoxLayout;
  7892. QFormLayout*serialSection= new QFormLayout;
  7893. serialSection->addRow(QString(tr("Port:")),port);
  7894. serialSection->addRow(QString(tr("Baud rate:")),baud);
  7895. serialSection->addRow(QString(tr("Parity:")),parity);
  7896. serialSection->addRow(QString(tr("Flow control:")),flow);
  7897. serialSection->addRow(QString(tr("Stop bits:")),stop);
  7898. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  7899. serialSectionBox->setLayout(serialSection);
  7900. portAndDeviceLayout->addWidget(serialSectionBox);
  7901. QFormLayout*deviceSection= new QFormLayout;
  7902. station->setMinimum(1);
  7903. station->setMaximum(255);
  7904. decimalPosition->setMinimum(0);
  7905. decimalPosition->setMaximum(9);
  7906. valueF->setMinimum(0);
  7907. valueF->setMaximum(0xFFFF);
  7908. valueC->setMinimum(0);
  7909. valueC->setMaximum(0xFFFF);
  7910. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  7911. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  7912. deviceSection->addRow(tr("Station:"),station);
  7913. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  7914. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  7915. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  7916. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  7917. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  7918. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  7919. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  7920. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  7921. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  7922. deviceSectionBox->setLayout(deviceSection);
  7923. portAndDeviceLayout->addWidget(deviceSectionBox);
  7924. QFormLayout*pVSection= new QFormLayout;
  7925. pVSection->addRow(tr("Value relative address:"),pVAddress);
  7926. pVSection->addRow(tr("PV column name:"),pVColumnName);
  7927. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  7928. pVSection->addRow(pVHideBox);
  7929. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  7930. processValueBox->setLayout(pVSection);
  7931. seriesLayout->addWidget(processValueBox);
  7932. QFormLayout*sVSection= new QFormLayout;
  7933. sVLower->setDecimals(1);
  7934. sVLower->setMinimum(0.0);
  7935. sVLower->setMaximum(999.9);
  7936. sVUpper->setDecimals(1);
  7937. sVUpper->setMinimum(0.0);
  7938. sVUpper->setMaximum(999.9);
  7939. sVSection->addRow(tr("Set value:"),sVEnabled);
  7940. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  7941. sVSection->addRow(tr("SV column name:"),sVColumnName);
  7942. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  7943. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  7944. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  7945. sVSection->addRow(tr("Lower limit:"),sVLower);
  7946. sVSection->addRow(tr("Upper limit:"),sVUpper);
  7947. sVSection->addRow(tr("Output set value:"),sVWritable);
  7948. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  7949. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  7950. sVSection->addRow(sVHideBox);
  7951. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  7952. setValueBox->setLayout(sVSection);
  7953. seriesLayout->addWidget(setValueBox);
  7954. masterLayout->addLayout(portAndDeviceLayout);
  7955. masterLayout->addLayout(seriesLayout);
  7956. form->setLayout(masterLayout);
  7957. /*744:*/
  7958. #line 15632 "./typica.w"
  7959. QDomElement referenceElement=
  7960. model->referenceElement(model->data(index,Qt::UserRole).toString());
  7961. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  7962. QDomElement node;
  7963. /*:744*/
  7964. #line 18243 "./typica.w"
  7965. for(int i= 0;i<configData.size();i++)
  7966. {
  7967. node= configData.at(i).toElement();
  7968. if(node.attribute("name")=="port")
  7969. {
  7970. QString portname= node.attribute("value");
  7971. int idx= port->findText(portname);
  7972. if(idx>=0)
  7973. {
  7974. port->setCurrentIndex(idx);
  7975. }
  7976. else
  7977. {
  7978. port->addItem(portname);
  7979. }
  7980. }
  7981. else if(node.attribute("name")=="baud")
  7982. {
  7983. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  7984. }
  7985. else if(node.attribute("name")=="parity")
  7986. {
  7987. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  7988. }
  7989. else if(node.attribute("name")=="flow")
  7990. {
  7991. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  7992. }
  7993. else if(node.attribute("name")=="stop")
  7994. {
  7995. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  7996. }
  7997. else if(node.attribute("name")=="station")
  7998. {
  7999. station->setValue(node.attribute("value").toInt());
  8000. }
  8001. else if(node.attribute("name")=="decimalQuery")
  8002. {
  8003. if(node.attribute("value")=="true")
  8004. {
  8005. decimalQuery->setChecked(true);
  8006. }
  8007. else
  8008. {
  8009. decimalQuery->setChecked(false);
  8010. }
  8011. }
  8012. else if(node.attribute("name")=="decimalAddress")
  8013. {
  8014. decimalAddress->setValue(node.attribute("value").toInt());
  8015. }
  8016. else if(node.attribute("name")=="decimalPosition")
  8017. {
  8018. decimalPosition->setValue(node.attribute("value").toInt());
  8019. }
  8020. else if(node.attribute("name")=="unitQuery")
  8021. {
  8022. if(node.attribute("value")=="true")
  8023. {
  8024. unitQuery->setChecked(true);
  8025. }
  8026. else
  8027. {
  8028. unitQuery->setChecked(false);
  8029. }
  8030. }
  8031. else if(node.attribute("name")=="unitAddress")
  8032. {
  8033. unitAddress->setValue(node.attribute("value").toInt());
  8034. }
  8035. else if(node.attribute("name")=="valueF")
  8036. {
  8037. valueF->setValue(node.attribute("value").toInt());
  8038. }
  8039. else if(node.attribute("name")=="valueC")
  8040. {
  8041. valueC->setValue(node.attribute("value").toInt());
  8042. }
  8043. else if(node.attribute("name")=="fixedUnit")
  8044. {
  8045. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8046. }
  8047. else if(node.attribute("name")=="pVAddress")
  8048. {
  8049. pVAddress->setValue(node.attribute("value").toInt());
  8050. }
  8051. else if(node.attribute("name")=="sVEnabled")
  8052. {
  8053. if(node.attribute("value")=="true")
  8054. {
  8055. sVEnabled->setChecked(true);
  8056. }
  8057. else
  8058. {
  8059. sVEnabled->setChecked(false);
  8060. }
  8061. }
  8062. else if(node.attribute("name")=="sVReadAddress")
  8063. {
  8064. sVReadAddress->setValue(node.attribute("value").toInt());
  8065. }
  8066. else if(node.attribute("name")=="deviceLimit")
  8067. {
  8068. if(node.attribute("value")=="true")
  8069. {
  8070. deviceLimit->setChecked(true);
  8071. }
  8072. else
  8073. {
  8074. deviceLimit->setChecked(false);
  8075. }
  8076. }
  8077. else if(node.attribute("name")=="sVLowerAddr")
  8078. {
  8079. sVLowerAddr->setValue(node.attribute("value").toInt());
  8080. }
  8081. else if(node.attribute("name")=="sVUpperAddr")
  8082. {
  8083. sVUpperAddr->setValue(node.attribute("value").toInt());
  8084. }
  8085. else if(node.attribute("name")=="sVLower")
  8086. {
  8087. sVLower->setValue(node.attribute("value").toDouble());
  8088. }
  8089. else if(node.attribute("name")=="sVUpper")
  8090. {
  8091. sVUpper->setValue(node.attribute("value").toDouble());
  8092. }
  8093. else if(node.attribute("name")=="sVWritable")
  8094. {
  8095. if(node.attribute("value")=="true")
  8096. {
  8097. sVWritable->setChecked(true);
  8098. }
  8099. else
  8100. {
  8101. sVWritable->setChecked(false);
  8102. }
  8103. }
  8104. else if(node.attribute("name")=="sVOutputAddr")
  8105. {
  8106. sVOutputAddr->setValue(node.attribute("value").toInt());
  8107. }
  8108. else if(node.attribute("name")=="pvcolname")
  8109. {
  8110. pVColumnName->setText(node.attribute("value"));
  8111. }
  8112. else if(node.attribute("name")=="svcolname")
  8113. {
  8114. sVColumnName->setText(node.attribute("value"));
  8115. }
  8116. else if(node.attribute("name")=="pvhidden")
  8117. {
  8118. pVHideBox->setChecked(node.attribute("value")=="true");
  8119. }
  8120. else if(node.attribute("name")=="svhidden")
  8121. {
  8122. sVHideBox->setChecked(node.attribute("value")=="true");
  8123. }
  8124. }
  8125. updatePort(port->currentText());
  8126. updateBaudRate(baud->currentText());
  8127. updateParity(parity->itemData(parity->currentIndex()).toString());
  8128. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8129. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8130. updateStation(station->value());
  8131. updateFixedDecimal(decimalQuery->isChecked());
  8132. updateDecimalAddress(decimalAddress->value());
  8133. updateDecimalPosition(decimalPosition->value());
  8134. updateFixedUnit(unitQuery->isChecked());
  8135. updateUnitAddress(unitAddress->value());
  8136. updateValueForF(valueF->value());
  8137. updateValueForC(valueC->value());
  8138. updateUnit(fixedUnit->currentText());
  8139. updatePVAddress(pVAddress->value());
  8140. updateSVEnabled(sVEnabled->isChecked());
  8141. updateSVReadAddress(sVReadAddress->value());
  8142. updateDeviceLimit(deviceLimit->isChecked());
  8143. updateSVLowerAddress(sVLowerAddr->value());
  8144. updateSVUpperAddress(sVUpperAddr->value());
  8145. updateSVLower(sVLower->value());
  8146. updateSVUpper(sVUpper->value());
  8147. updateSVWritable(sVWritable->isChecked());
  8148. updateSVWriteAddress(sVOutputAddr->value());
  8149. updatePVColumnName(pVColumnName->text());
  8150. updateSVColumnName(sVColumnName->text());
  8151. updatePVHidden(pVHideBox->isChecked());
  8152. updateSVHidden(sVHideBox->isChecked());
  8153. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8154. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8155. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8156. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8157. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8158. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8159. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8160. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8161. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8162. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8163. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8164. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8165. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8166. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8167. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8168. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8169. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8170. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8171. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8172. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8173. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8174. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8175. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8176. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8177. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8178. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8179. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8180. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8181. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8182. layout->addWidget(form);
  8183. setLayout(layout);
  8184. }
  8185. void ModbusConfigurator::updatePort(const QString&newPort)
  8186. {
  8187. updateAttribute("port",newPort);
  8188. }
  8189. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8190. {
  8191. updateAttribute("baud",newRate);
  8192. }
  8193. void ModbusConfigurator::updateParity(const QString&)
  8194. {
  8195. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8196. }
  8197. void ModbusConfigurator::updateFlowControl(const QString&)
  8198. {
  8199. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8200. }
  8201. void ModbusConfigurator::updateStopBits(const QString&)
  8202. {
  8203. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8204. }
  8205. void ModbusConfigurator::updateStation(int station)
  8206. {
  8207. updateAttribute("station",QString("%1").arg(station));
  8208. }
  8209. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8210. {
  8211. updateAttribute("decimalQuery",fixed?"true":"false");
  8212. }
  8213. void ModbusConfigurator::updateDecimalAddress(int address)
  8214. {
  8215. updateAttribute("decimalAddress",QString("%1").arg(address));
  8216. }
  8217. void ModbusConfigurator::updateDecimalPosition(int position)
  8218. {
  8219. updateAttribute("decimalPosition",QString("%1").arg(position));
  8220. }
  8221. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8222. {
  8223. updateAttribute("unitQuery",fixed?"true":"false");
  8224. }
  8225. void ModbusConfigurator::updateUnitAddress(int address)
  8226. {
  8227. updateAttribute("unitAddress",QString("%1").arg(address));
  8228. }
  8229. void ModbusConfigurator::updateValueForF(int value)
  8230. {
  8231. updateAttribute("valueF",QString("%1").arg(value));
  8232. }
  8233. void ModbusConfigurator::updateValueForC(int value)
  8234. {
  8235. updateAttribute("valueC",QString("%1").arg(value));
  8236. }
  8237. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8238. {
  8239. updateAttribute("fixedUnit",newUnit);
  8240. }
  8241. void ModbusConfigurator::updatePVAddress(int address)
  8242. {
  8243. updateAttribute("pVAddress",QString("%1").arg(address));
  8244. }
  8245. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8246. {
  8247. updateAttribute("sVEnabled",enabled?"true":"false");
  8248. }
  8249. void ModbusConfigurator::updateSVReadAddress(int address)
  8250. {
  8251. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8252. }
  8253. void ModbusConfigurator::updateDeviceLimit(bool query)
  8254. {
  8255. updateAttribute("deviceLimit",query?"true":"false");
  8256. }
  8257. void ModbusConfigurator::updateSVLowerAddress(int address)
  8258. {
  8259. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8260. }
  8261. void ModbusConfigurator::updateSVUpperAddress(int address)
  8262. {
  8263. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8264. }
  8265. void ModbusConfigurator::updateSVLower(double value)
  8266. {
  8267. updateAttribute("sVLower",QString("%1").arg(value));
  8268. }
  8269. void ModbusConfigurator::updateSVUpper(double value)
  8270. {
  8271. updateAttribute("sVUpper",QString("%1").arg(value));
  8272. }
  8273. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8274. {
  8275. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8276. }
  8277. void ModbusConfigurator::updateSVWriteAddress(int address)
  8278. {
  8279. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8280. }
  8281. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8282. {
  8283. updateAttribute("pvcolname",name);
  8284. }
  8285. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8286. {
  8287. updateAttribute("svcolname",name);
  8288. }
  8289. void ModbusConfigurator::updatePVHidden(bool hidden)
  8290. {
  8291. updateAttribute("pvhidden",hidden?"true":"false");
  8292. }
  8293. void ModbusConfigurator::updateSVHidden(bool hidden)
  8294. {
  8295. updateAttribute("svhidden",hidden?"true":"false");
  8296. }
  8297. /*:836*/
  8298. #line 578 "./typica.w"
  8299. /*779:*/
  8300. #line 16420 "./typica.w"
  8301. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8302. {
  8303. setMinimum(0);
  8304. setMaximum(0xFFFF);
  8305. setPrefix("0x");
  8306. setMinimumWidth(65);
  8307. }
  8308. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8309. {
  8310. if(input.size()==2)
  8311. {
  8312. return QValidator::Intermediate;
  8313. }
  8314. bool okay;
  8315. input.toInt(&okay,16);
  8316. if(okay)
  8317. {
  8318. return QValidator::Acceptable;
  8319. }
  8320. return QValidator::Invalid;
  8321. }
  8322. int ShortHexSpinBox::valueFromText(const QString&text)const
  8323. {
  8324. return text.toInt(NULL,16);
  8325. }
  8326. QString ShortHexSpinBox::textFromValue(int value)const
  8327. {
  8328. QString retval;
  8329. retval.setNum(value,16);
  8330. while(retval.size()<4)
  8331. {
  8332. retval.prepend("0");
  8333. }
  8334. return retval.toUpper();
  8335. }
  8336. /*:779*/
  8337. #line 579 "./typica.w"
  8338. /*820:*/
  8339. #line 17452 "./typica.w"
  8340. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8341. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8342. waiting(false)
  8343. {
  8344. qDebug()<<"Initializing Modbus RTU Device";
  8345. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8346. Qt::UserRole).toString());
  8347. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8348. QDomElement node;
  8349. QVariantMap attributes;
  8350. for(int i= 0;i<portConfigData.size();i++)
  8351. {
  8352. node= portConfigData.at(i).toElement();
  8353. attributes.insert(node.attribute("name"),node.attribute("value"));
  8354. }
  8355. port= new QextSerialPort(attributes.value("port").toString(),
  8356. QextSerialPort::EventDriven);
  8357. int baudRate= attributes.value("baud").toInt();
  8358. port->setBaudRate((BaudRateType)baudRate);
  8359. double temp= ((double)(1)/(double)(baudRate))*48;
  8360. delayTime= (int)(temp*3000);
  8361. messageDelayTimer->setSingleShot(true);
  8362. commTimeout->setSingleShot(true);
  8363. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8364. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8365. port->setDataBits(DATA_8);
  8366. port->setParity((ParityType)attributes.value("parity").toInt());
  8367. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8368. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8369. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8370. port->open(QIODevice::ReadWrite);
  8371. station= (char)attributes.value("station").toInt();
  8372. if(attributes.value("decimalQuery")=="true")
  8373. {
  8374. decimalPosition= 0;
  8375. QByteArray message;
  8376. message.append(station);
  8377. message.append((char)0x03);
  8378. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8379. char*addressBytes= (char*)&address;
  8380. message.append(addressBytes[1]);
  8381. message.append(addressBytes[0]);
  8382. message.append((char)0x00);
  8383. message.append((char)0x01);
  8384. queueMessage(message,this,"decimalResponse(QByteArray)");
  8385. }
  8386. else
  8387. {
  8388. decimalPosition= attributes.value("decimalPosition").toInt();
  8389. }
  8390. valueF= attributes.value("valueF").toInt();
  8391. valueC= attributes.value("valueC").toInt();
  8392. if(attributes.value("unitQuery")=="true")
  8393. {
  8394. QByteArray message;
  8395. message.append(station);
  8396. message.append((char)0x03);
  8397. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8398. char*addressBytes= (char*)&address;
  8399. message.append(addressBytes[1]);
  8400. message.append(addressBytes[0]);
  8401. message.append((char)0x00);
  8402. message.append((char)0x01);
  8403. queueMessage(message,this,"unitResponse(QByteArray)");
  8404. }
  8405. else
  8406. {
  8407. if(attributes.value("fixedUnit")=="Celsius")
  8408. {
  8409. unitIsF= false;
  8410. }
  8411. }
  8412. if(attributes.value("sVWritable")=="true")
  8413. {
  8414. if(attributes.value("deviceLimit")=="true")
  8415. {
  8416. QByteArray lmessage;
  8417. lmessage.append(station);
  8418. lmessage.append((char)0x03);
  8419. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8420. char*addressBytes= (char*)&laddress;
  8421. lmessage.append(addressBytes[1]);
  8422. lmessage.append(addressBytes[0]);
  8423. lmessage.append((char)0x00);
  8424. lmessage.append((char)0x01);
  8425. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8426. QByteArray umessage;
  8427. umessage.append(station);
  8428. umessage.append((char)0x03);
  8429. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8430. addressBytes= (char*)&uaddress;
  8431. umessage.append(addressBytes[1]);
  8432. umessage.append(addressBytes[0]);
  8433. umessage.append((char)0x00);
  8434. umessage.append((char)0x01);
  8435. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8436. }
  8437. else
  8438. {
  8439. outputSVLower= attributes.value("sVLower").toDouble();
  8440. outputSVUpper= attributes.value("sVUpper").toDouble();
  8441. }
  8442. outputSVStub.append(station);
  8443. outputSVStub.append((char)0x06);
  8444. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8445. char*addressBytes= (char*)&address;
  8446. outputSVStub.append(addressBytes[1]);
  8447. outputSVStub.append(addressBytes[0]);
  8448. }
  8449. Channel*pv= new Channel;
  8450. channels.append(pv);
  8451. pvStub.append(station);
  8452. pvStub.append((char)0x04);
  8453. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8454. char*pvac= (char*)&pvaddress;
  8455. pvStub.append(pvac[1]);
  8456. pvStub.append(pvac[0]);
  8457. pvStub.append((char)0x00);
  8458. pvStub.append((char)0x01);
  8459. svenabled= attributes.value("sVEnabled").toBool();
  8460. if(svenabled)
  8461. {
  8462. Channel*sv= new Channel;
  8463. channels.append(sv);
  8464. svStub.append(station);
  8465. svStub.append((char)0x04);
  8466. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8467. char*svac= (char*)&svaddress;
  8468. svStub.append(svac[1]);
  8469. svStub.append(svac[0]);
  8470. svStub.append((char)0x00);
  8471. svStub.append((char)0x01);
  8472. if(svaddress-pvaddress==1)
  8473. {
  8474. mStub.append(station);
  8475. mStub.append((char)0x04);
  8476. mStub.append(pvac[1]);
  8477. mStub.append(pvac[0]);
  8478. mStub.append((char)0x00);
  8479. mStub.append((char)0x02);
  8480. }
  8481. }
  8482. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8483. requestMeasurement();
  8484. }
  8485. double ModbusRTUDevice::SVLower()
  8486. {
  8487. return outputSVLower;
  8488. }
  8489. double ModbusRTUDevice::SVUpper()
  8490. {
  8491. return outputSVUpper;
  8492. }
  8493. int ModbusRTUDevice::decimals()
  8494. {
  8495. return decimalPosition;
  8496. }
  8497. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8498. {
  8499. quint16 temp;
  8500. char*tchar= (char*)&temp;
  8501. tchar[1]= response.at(3);
  8502. tchar[0]= response.at(4);
  8503. decimalPosition= temp;
  8504. emit SVDecimalChanged(decimalPosition);
  8505. qDebug()<<"Received decimal response";
  8506. }
  8507. void ModbusRTUDevice::unitResponse(QByteArray response)
  8508. {
  8509. quint16 temp;
  8510. char*tchar= (char*)&temp;
  8511. tchar[1]= response.at(3);
  8512. tchar[0]= response.at(4);
  8513. int value= temp;
  8514. if(value==valueF)
  8515. {
  8516. unitIsF= true;
  8517. }
  8518. else
  8519. {
  8520. unitIsF= false;
  8521. }
  8522. qDebug()<<"Received unit response";
  8523. }
  8524. void ModbusRTUDevice::svlResponse(QByteArray response)
  8525. {
  8526. quint16 temp;
  8527. char*tchar= (char*)&temp;
  8528. tchar[1]= response.at(3);
  8529. tchar[0]= response.at(4);
  8530. outputSVLower= (double)temp;
  8531. for(int i= 0;i<decimalPosition;i++)
  8532. {
  8533. outputSVLower/= 10;
  8534. }
  8535. emit SVLowerChanged(outputSVLower);
  8536. qDebug()<<"Received set value lower bound response";
  8537. }
  8538. void ModbusRTUDevice::svuResponse(QByteArray response)
  8539. {
  8540. quint16 temp;
  8541. char*tchar= (char*)&temp;
  8542. tchar[1]= response.at(3);
  8543. tchar[0]= response.at(4);
  8544. outputSVUpper= (double)temp;
  8545. for(int i= 0;i<decimalPosition;i++)
  8546. {
  8547. outputSVUpper/= 10;
  8548. }
  8549. emit SVUpperChanged(outputSVUpper);
  8550. qDebug()<<"Received set value upper bound response";
  8551. }
  8552. void ModbusRTUDevice::requestMeasurement()
  8553. {
  8554. if(mStub.length()> 0)
  8555. {
  8556. queueMessage(mStub,this,"mResponse(QByteArray)");
  8557. }
  8558. else
  8559. {
  8560. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8561. if(svenabled)
  8562. {
  8563. queueMessage(svStub,this,"mResponse(QByteArray)");
  8564. }
  8565. }
  8566. }
  8567. void ModbusRTUDevice::mResponse(QByteArray response)
  8568. {
  8569. QTime time= QTime::currentTime();
  8570. if(response.at(2)==0x04)
  8571. {
  8572. /*821:*/
  8573. #line 17707 "./typica.w"
  8574. quint16 pv;
  8575. quint16 sv;
  8576. char*pvBytes= (char*)&pv;
  8577. char*svBytes= (char*)&sv;
  8578. pvBytes[1]= response.at(3);
  8579. pvBytes[0]= response.at(4);
  8580. svBytes[1]= response.at(5);
  8581. svBytes[0]= response.at(6);
  8582. double pvOut= (double)pv;
  8583. double svOut= (double)sv;
  8584. for(int i= 0;i<decimalPosition;i++)
  8585. {
  8586. pvOut/= 10;
  8587. svOut/= 10;
  8588. }
  8589. if(!unitIsF)
  8590. {
  8591. pvOut= pvOut*9/5+32;
  8592. svOut= svOut*9/5+32;
  8593. }
  8594. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8595. Measurement svm(svOut,time,Units::Fahrenheit);
  8596. channels.at(0)->input(pvm);
  8597. channels.at(1)->input(svm);
  8598. /*:821*/
  8599. #line 17694 "./typica.w"
  8600. }
  8601. else
  8602. {
  8603. /*822:*/
  8604. #line 17737 "./typica.w"
  8605. quint16 value;
  8606. char*valueBytes= (char*)&value;
  8607. valueBytes[1]= response.at(3);
  8608. valueBytes[0]= response.at(4);
  8609. double valueOut= (double)value;
  8610. for(int i= 0;i<decimalPosition;i++)
  8611. {
  8612. valueOut/= 10;
  8613. }
  8614. if(!unitIsF)
  8615. {
  8616. valueOut= valueOut*9/5+32;
  8617. }
  8618. if(!svenabled)
  8619. {
  8620. Measurement vm(valueOut,time,Units::Fahrenheit);
  8621. channels.at(0)->input(vm);
  8622. }
  8623. else
  8624. {
  8625. if(readingsv)
  8626. {
  8627. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8628. Measurement svm(valueOut,time,Units::Fahrenheit);
  8629. channels.at(0)->input(pvm);
  8630. channels.at(1)->input(svm);
  8631. readingsv= false;
  8632. }
  8633. else
  8634. {
  8635. savedpv= valueOut;
  8636. readingsv= true;
  8637. }
  8638. }
  8639. /*:822*/
  8640. #line 17698 "./typica.w"
  8641. }
  8642. }
  8643. /*:820*//*823:*/
  8644. #line 17775 "./typica.w"
  8645. ModbusRTUDevice::~ModbusRTUDevice()
  8646. {
  8647. commTimeout->stop();
  8648. messageDelayTimer->stop();
  8649. port->close();
  8650. }
  8651. /*:823*//*824:*/
  8652. #line 17802 "./typica.w"
  8653. void ModbusRTUDevice::dataAvailable()
  8654. {
  8655. if(messageDelayTimer->isActive())
  8656. {
  8657. messageDelayTimer->stop();
  8658. }
  8659. responseBuffer.append(port->readAll());
  8660. /*825:*/
  8661. #line 17848 "./typica.w"
  8662. if(responseBuffer.size()<5)
  8663. {
  8664. return;
  8665. }
  8666. switch(responseBuffer.at(1))
  8667. {
  8668. case 0x01:
  8669. case 0x02:
  8670. if(responseBuffer.size()<6)
  8671. {
  8672. return;
  8673. }
  8674. responseBuffer= responseBuffer.left(6);
  8675. break;
  8676. case 0x03:
  8677. case 0x04:
  8678. if(responseBuffer.size()<5+responseBuffer.at(2))
  8679. {
  8680. return;
  8681. }
  8682. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8683. break;
  8684. case 0x05:
  8685. case 0x06:
  8686. case 0x10:
  8687. if(responseBuffer.size()<8)
  8688. {
  8689. return;
  8690. }
  8691. responseBuffer= responseBuffer.left(8);
  8692. break;
  8693. }
  8694. /*:825*/
  8695. #line 17810 "./typica.w"
  8696. commTimeout->stop();
  8697. if(calculateCRC(responseBuffer)==0)
  8698. {
  8699. QObject*object= retObjQueue.at(0);
  8700. char*method= callbackQueue.at(0);
  8701. QMetaMethod metamethod= object->metaObject()->
  8702. method(object->metaObject()->
  8703. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8704. metamethod.invoke(object,Qt::QueuedConnection,
  8705. Q_ARG(QByteArray,responseBuffer));
  8706. messageQueue.removeAt(0);
  8707. retObjQueue.removeAt(0);
  8708. callbackQueue.removeAt(0);
  8709. }
  8710. else
  8711. {
  8712. qDebug()<<"CRC failed";
  8713. }
  8714. messageDelayTimer->start(delayTime);
  8715. waiting= false;
  8716. responseBuffer.clear();
  8717. }
  8718. /*:824*//*826:*/
  8719. #line 17890 "./typica.w"
  8720. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8721. {
  8722. quint16 retval= 0xFFFF;
  8723. int i= 0;
  8724. while(i<data.size())
  8725. {
  8726. retval^= 0x00FF&(quint16)data.at(i);
  8727. for(int j= 0;j<8;j++)
  8728. {
  8729. if(retval&1)
  8730. {
  8731. retval= (retval>>1)^0xA001;
  8732. }
  8733. else
  8734. {
  8735. retval>>= 1;
  8736. }
  8737. }
  8738. i++;
  8739. }
  8740. return retval;
  8741. }
  8742. /*:826*//*827:*/
  8743. #line 17921 "./typica.w"
  8744. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8745. const char*callback)
  8746. {
  8747. messageQueue.append(request);
  8748. retObjQueue.append(object);
  8749. callbackQueue.append(const_cast<char*> (callback));
  8750. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8751. {
  8752. sendNextMessage();
  8753. }
  8754. }
  8755. void ModbusRTUDevice::sendNextMessage()
  8756. {
  8757. if(messageQueue.size()> 0&&!waiting)
  8758. {
  8759. QByteArray message= messageQueue.at(0);
  8760. quint16 crc= calculateCRC(message);
  8761. char*check= (char*)&crc;
  8762. message.append(check[0]);
  8763. message.append(check[1]);
  8764. port->write(message);
  8765. commTimeout->start(2000);
  8766. messageDelayTimer->start(delayTime);
  8767. waiting= true;
  8768. }
  8769. else
  8770. {
  8771. emit queueEmpty();
  8772. }
  8773. }
  8774. void ModbusRTUDevice::outputSV(double value)
  8775. {
  8776. for(int i= 0;i<decimalPosition;i++)
  8777. {
  8778. value*= 10;
  8779. }
  8780. quint16 outval= (quint16)value;
  8781. QByteArray message(outputSVStub);
  8782. char*valBytes= (char*)&outval;
  8783. message.append(valBytes[1]);
  8784. message.append(valBytes[0]);
  8785. queueMessage(message,this,"ignore(QByteArray)");
  8786. }
  8787. /*:827*//*828:*/
  8788. #line 17970 "./typica.w"
  8789. void ModbusRTUDevice::ignore(QByteArray)
  8790. {
  8791. return;
  8792. }
  8793. /*:828*//*829:*/
  8794. #line 17983 "./typica.w"
  8795. void ModbusRTUDevice::timeout()
  8796. {
  8797. qDebug()<<"Communications timeout.";
  8798. responseBuffer.clear();
  8799. waiting= false;
  8800. messageDelayTimer->start();
  8801. }
  8802. /*:829*/
  8803. #line 580 "./typica.w"
  8804. /*698:*/
  8805. #line 14612 "./typica.w"
  8806. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  8807. DeviceTreeModelNode*parent)
  8808. :domNode(node),rowNumber(row),parentItem(parent)
  8809. {
  8810. }
  8811. DeviceTreeModelNode::~DeviceTreeModelNode()
  8812. {
  8813. QHash<int,DeviceTreeModelNode*> ::iterator i;
  8814. for(i= children.begin();i!=children.end();i++)
  8815. {
  8816. delete i.value();
  8817. }
  8818. }
  8819. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  8820. {
  8821. return parentItem;
  8822. }
  8823. int DeviceTreeModelNode::row()
  8824. {
  8825. return rowNumber;
  8826. }
  8827. QDomNode DeviceTreeModelNode::node()const
  8828. {
  8829. return domNode;
  8830. }
  8831. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  8832. {
  8833. if(children.contains(index))
  8834. {
  8835. return children[index];
  8836. }
  8837. if(index>=0&&index<domNode.childNodes().count())
  8838. {
  8839. QDomNode childNode= domNode.childNodes().item(index);
  8840. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  8841. index,this);
  8842. children[index]= childItem;
  8843. return childItem;
  8844. }
  8845. return NULL;
  8846. }
  8847. /*:698*/
  8848. #line 581 "./typica.w"
  8849. /*700:*/
  8850. #line 14701 "./typica.w"
  8851. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  8852. :QAbstractItemModel(parent)
  8853. {
  8854. document= AppInstance->deviceConfiguration();
  8855. QDomNodeList elements= document.elementsByTagName("devices");
  8856. if(elements.size()!=1)
  8857. {
  8858. qDebug()<<"Unexpected result when loading device map.";
  8859. }
  8860. treeRoot= elements.at(0);
  8861. root= new DeviceTreeModelNode(treeRoot,0);
  8862. elements= document.elementsByTagName("references");
  8863. if(elements.size()!=1)
  8864. {
  8865. qDebug()<<"No references section. Creating.";
  8866. referenceSection= document.createElement("references");
  8867. document.appendChild(referenceSection);
  8868. }
  8869. else
  8870. {
  8871. referenceSection= elements.at(0);
  8872. }
  8873. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  8874. AppInstance,SLOT(saveDeviceConfiguration()));
  8875. connect(this,SIGNAL(modelReset()),
  8876. AppInstance,SLOT(saveDeviceConfiguration()));
  8877. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8878. AppInstance,SLOT(saveDeviceConfiguration()));
  8879. }
  8880. /*:700*//*701:*/
  8881. #line 14736 "./typica.w"
  8882. int DeviceTreeModel::columnCount(const QModelIndex&)const
  8883. {
  8884. return 1;
  8885. }
  8886. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  8887. {
  8888. if(parent.column()> 0)
  8889. {
  8890. return 0;
  8891. }
  8892. /*702:*/
  8893. #line 14755 "./typica.w"
  8894. DeviceTreeModelNode*parentItem;
  8895. if(!parent.isValid())
  8896. {
  8897. parentItem= root;
  8898. }
  8899. else
  8900. {
  8901. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8902. }
  8903. /*:702*/
  8904. #line 14748 "./typica.w"
  8905. return parentItem->node().childNodes().count();
  8906. }
  8907. /*:701*//*703:*/
  8908. #line 14769 "./typica.w"
  8909. QModelIndex DeviceTreeModel::index(int row,int column,
  8910. const QModelIndex&parent)const
  8911. {
  8912. if(!hasIndex(row,column,parent))
  8913. {
  8914. return QModelIndex();
  8915. }
  8916. /*702:*/
  8917. #line 14755 "./typica.w"
  8918. DeviceTreeModelNode*parentItem;
  8919. if(!parent.isValid())
  8920. {
  8921. parentItem= root;
  8922. }
  8923. else
  8924. {
  8925. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8926. }
  8927. /*:702*/
  8928. #line 14777 "./typica.w"
  8929. DeviceTreeModelNode*childItem= parentItem->child(row);
  8930. if(childItem)
  8931. {
  8932. return createIndex(row,column,childItem);
  8933. }
  8934. return QModelIndex();
  8935. }
  8936. /*:703*//*704:*/
  8937. #line 14788 "./typica.w"
  8938. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  8939. {
  8940. if(!child.isValid())
  8941. {
  8942. return QModelIndex();
  8943. }
  8944. DeviceTreeModelNode*childItem=
  8945. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  8946. DeviceTreeModelNode*parentItem= childItem->parent();
  8947. if(!parentItem||parentItem==root)
  8948. {
  8949. return QModelIndex();
  8950. }
  8951. return createIndex(parentItem->row(),0,parentItem);
  8952. }
  8953. /*:704*//*705:*/
  8954. #line 14807 "./typica.w"
  8955. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  8956. {
  8957. if(!index.isValid())
  8958. {
  8959. return 0;
  8960. }
  8961. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  8962. }
  8963. /*:705*//*706:*/
  8964. #line 14822 "./typica.w"
  8965. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  8966. {
  8967. if(!index.isValid())
  8968. {
  8969. return QVariant();
  8970. }
  8971. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  8972. {
  8973. return QVariant();
  8974. }
  8975. DeviceTreeModelNode*item=
  8976. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  8977. QDomNode node= item->node();
  8978. QDomElement element= node.toElement();
  8979. switch(role)
  8980. {
  8981. case Qt::DisplayRole:
  8982. case Qt::EditRole:
  8983. return QVariant(element.attribute("name"));
  8984. case Qt::UserRole:
  8985. return QVariant(element.attribute("reference"));
  8986. default:
  8987. return QVariant();
  8988. }
  8989. return QVariant();
  8990. }
  8991. /*:706*//*707:*/
  8992. #line 14854 "./typica.w"
  8993. bool DeviceTreeModel::setData(const QModelIndex&index,
  8994. const QVariant&value,int)
  8995. {
  8996. if(!index.isValid())
  8997. {
  8998. return false;
  8999. }
  9000. DeviceTreeModelNode*item=
  9001. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9002. QDomNode node= item->node();
  9003. QDomElement element= node.toElement();
  9004. element.setAttribute("name",value.toString());
  9005. emit dataChanged(index,index);
  9006. return true;
  9007. }
  9008. /*:707*//*708:*/
  9009. #line 14877 "./typica.w"
  9010. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9011. const QModelIndex&parent)
  9012. {
  9013. QString referenceID= QUuid::createUuid().toString();
  9014. /*702:*/
  9015. #line 14755 "./typica.w"
  9016. DeviceTreeModelNode*parentItem;
  9017. if(!parent.isValid())
  9018. {
  9019. parentItem= root;
  9020. }
  9021. else
  9022. {
  9023. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9024. }
  9025. /*:702*/
  9026. #line 14882 "./typica.w"
  9027. QDomNode parentNode= parentItem->node();
  9028. int newRowNumber= rowCount(parent);
  9029. beginInsertRows(parent,newRowNumber,newRowNumber);
  9030. QDomElement deviceElement= document.createElement("node");
  9031. deviceElement.setAttribute("name",name);
  9032. deviceElement.setAttribute("reference",referenceID);
  9033. parentNode.appendChild(deviceElement);
  9034. QDomElement referenceElement= document.createElement("reference");
  9035. referenceElement.setAttribute("id",referenceID);
  9036. referenceElement.setAttribute("driver",driver);
  9037. referenceSection.appendChild(referenceElement);
  9038. endInsertRows();
  9039. }
  9040. /*:708*//*709:*/
  9041. #line 14900 "./typica.w"
  9042. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9043. {
  9044. /*702:*/
  9045. #line 14755 "./typica.w"
  9046. DeviceTreeModelNode*parentItem;
  9047. if(!parent.isValid())
  9048. {
  9049. parentItem= root;
  9050. }
  9051. else
  9052. {
  9053. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9054. }
  9055. /*:702*/
  9056. #line 14903 "./typica.w"
  9057. QDomNode parentNode= parentItem->node();
  9058. QDomNodeList childNodes= parentNode.childNodes();
  9059. if(childNodes.size()<row+count)
  9060. {
  9061. return false;
  9062. }
  9063. beginRemoveRows(parent,row,row+count-1);
  9064. QList<QDomElement> removalList;
  9065. for(int i= row;i<row+count;i++)
  9066. {
  9067. removalList.append(childNodes.at(i).toElement());
  9068. }
  9069. QDomElement element;
  9070. QDomElement reference;
  9071. for(int i= 0;i<count;i++)
  9072. {
  9073. element= removalList.at(i);
  9074. if(element.hasAttribute("reference"))
  9075. {
  9076. reference= referenceElement(element.attribute("reference"));
  9077. if(!reference.isNull())
  9078. {
  9079. referenceSection.removeChild(reference);
  9080. }
  9081. }
  9082. parentNode.removeChild(element);
  9083. }
  9084. endRemoveRows();
  9085. beginResetModel();
  9086. delete root;
  9087. root= new DeviceTreeModelNode(treeRoot,0);
  9088. endResetModel();
  9089. return true;
  9090. }
  9091. /*:709*//*710:*/
  9092. #line 14942 "./typica.w"
  9093. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9094. {
  9095. QDomNodeList childNodes= referenceSection.childNodes();
  9096. QDomElement element;
  9097. for(int i= 0;i<childNodes.size();i++)
  9098. {
  9099. element= childNodes.at(i).toElement();
  9100. if(element.hasAttribute("id"))
  9101. {
  9102. if(element.attribute("id")==id)
  9103. {
  9104. return element;
  9105. }
  9106. }
  9107. }
  9108. return QDomElement();
  9109. }
  9110. /*:710*//*711:*/
  9111. #line 14963 "./typica.w"
  9112. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9113. {
  9114. return QVariant();
  9115. }
  9116. /*:711*//*712:*/
  9117. #line 14972 "./typica.w"
  9118. DeviceTreeModel::~DeviceTreeModel()
  9119. {
  9120. delete root;
  9121. }
  9122. /*:712*/
  9123. #line 582 "./typica.w"
  9124. /*739:*/
  9125. #line 15472 "./typica.w"
  9126. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9127. DeviceTreeModel*model,const QModelIndex&index)
  9128. :QWidget(NULL),deviceModel(model),currentNode(index)
  9129. {
  9130. }
  9131. /*:739*//*740:*/
  9132. #line 15484 "./typica.w"
  9133. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9134. const QString&value)
  9135. {
  9136. QDomElement referenceElement= deviceModel->referenceElement(
  9137. deviceModel->data(currentNode,Qt::UserRole).toString());
  9138. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9139. QDomElement node;
  9140. bool found= false;
  9141. for(int i= 0;i<configData.size();i++)
  9142. {
  9143. node= configData.at(i).toElement();
  9144. if(node.attribute("name")==name)
  9145. {
  9146. node.setAttribute("value",value);
  9147. found= true;
  9148. break;
  9149. }
  9150. }
  9151. if(!found)
  9152. {
  9153. node= AppInstance->deviceConfiguration().createElement("attribute");
  9154. node.setAttribute("name",name);
  9155. node.setAttribute("value",value);
  9156. referenceElement.appendChild(node);
  9157. }
  9158. AppInstance->saveDeviceConfiguration();
  9159. }
  9160. /*:740*//*741:*/
  9161. #line 15518 "./typica.w"
  9162. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9163. const QString&driver)
  9164. {
  9165. deviceModel->newNode(name,driver,currentNode);
  9166. }
  9167. /*:741*/
  9168. #line 583 "./typica.w"
  9169. /*730:*/
  9170. #line 15316 "./typica.w"
  9171. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9172. view(new QTreeView),configArea(new QScrollArea)
  9173. {
  9174. QSplitter*splitter= new QSplitter;
  9175. QWidget*leftWidget= new QWidget;
  9176. leftWidget->setMinimumWidth(200);
  9177. QVBoxLayout*left= new QVBoxLayout;
  9178. view->setAnimated(true);
  9179. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9180. document= AppInstance->deviceConfiguration();
  9181. model= new DeviceTreeModel;
  9182. view->setModel(model);
  9183. view->setTextElideMode(Qt::ElideNone);
  9184. view->expandAll();
  9185. view->resizeColumnToContents(0);
  9186. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9187. QHBoxLayout*treeButtons= new QHBoxLayout;
  9188. QToolButton*addDeviceButton= new QToolButton;
  9189. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9190. addDeviceButton->setToolTip(tr("New Roaster"));
  9191. connect(addDeviceButton,SIGNAL(clicked()),
  9192. this,SLOT(addDevice()));
  9193. QToolButton*removeNodeButton= new QToolButton;
  9194. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9195. removeNodeButton->setToolTip(tr("Delete Selection"));
  9196. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9197. treeButtons->addWidget(addDeviceButton);
  9198. treeButtons->addWidget(removeNodeButton);
  9199. left->addWidget(view);
  9200. left->addLayout(treeButtons);
  9201. leftWidget->setLayout(left);
  9202. splitter->addWidget(leftWidget);
  9203. configArea->setMinimumWidth(580);
  9204. configArea->setMinimumHeight(460);
  9205. configArea->setWidgetResizable(true);
  9206. splitter->addWidget(configArea);
  9207. QVBoxLayout*centralLayout= new QVBoxLayout;
  9208. centralLayout->addWidget(splitter);
  9209. setLayout(centralLayout);
  9210. connect(view,SIGNAL(activated(QModelIndex)),
  9211. this,SLOT(newSelection(QModelIndex)));
  9212. connect(view,SIGNAL(clicked(QModelIndex)),
  9213. this,SLOT(newSelection(QModelIndex)));
  9214. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9215. view,SLOT(expand(QModelIndex)));
  9216. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9217. this,SLOT(resizeColumn()));
  9218. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9219. this,SLOT(resizeColumn()));
  9220. }
  9221. /*:730*//*731:*/
  9222. #line 15371 "./typica.w"
  9223. void DeviceConfigurationWindow::addDevice()
  9224. {
  9225. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9226. }
  9227. /*:731*//*732:*/
  9228. #line 15379 "./typica.w"
  9229. void DeviceConfigurationWindow::removeNode()
  9230. {
  9231. QModelIndex index= view->currentIndex();
  9232. if(index.isValid())
  9233. {
  9234. int row= index.row();
  9235. QModelIndex parent= index.parent();
  9236. model->removeRow(row,parent);
  9237. }
  9238. }
  9239. /*:732*//*733:*/
  9240. #line 15395 "./typica.w"
  9241. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9242. {
  9243. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9244. if(editor)
  9245. {
  9246. configArea->setWidget(editor);
  9247. editor->show();
  9248. }
  9249. }
  9250. /*:733*//*734:*/
  9251. #line 15412 "./typica.w"
  9252. void DeviceConfigurationWindow::resizeColumn()
  9253. {
  9254. view->resizeColumnToContents(0);
  9255. }
  9256. /*:734*/
  9257. #line 584 "./typica.w"
  9258. /*754:*/
  9259. #line 15823 "./typica.w"
  9260. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9261. const QModelIndex&index):
  9262. BasicDeviceConfigurationWidget(model,index)
  9263. {
  9264. QFormLayout*layout= new QFormLayout;
  9265. QLineEdit*columnName= new QLineEdit;
  9266. layout->addRow(tr("Column Name:"),columnName);
  9267. QComboBox*typeSelector= new QComboBox;
  9268. typeSelector->addItem("J");
  9269. typeSelector->addItem("K");
  9270. typeSelector->addItem("T");
  9271. typeSelector->addItem("B");
  9272. typeSelector->addItem("E");
  9273. typeSelector->addItem("N");
  9274. typeSelector->addItem("R");
  9275. typeSelector->addItem("S");
  9276. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9277. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9278. layout->addRow(hideSeries);
  9279. setLayout(layout);
  9280. /*744:*/
  9281. #line 15632 "./typica.w"
  9282. QDomElement referenceElement=
  9283. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9284. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9285. QDomElement node;
  9286. /*:744*/
  9287. #line 15844 "./typica.w"
  9288. for(int i= 0;i<configData.size();i++)
  9289. {
  9290. node= configData.at(i).toElement();
  9291. if(node.attribute("name")=="type")
  9292. {
  9293. typeSelector->setCurrentIndex(
  9294. typeSelector->findText(node.attribute("value")));
  9295. }
  9296. else if(node.attribute("name")=="columnname")
  9297. {
  9298. columnName->setText(node.attribute("value"));
  9299. }
  9300. else if(node.attribute("name")=="hidden")
  9301. {
  9302. hideSeries->setChecked(node.attribute("value")=="true");
  9303. }
  9304. }
  9305. updateThermocoupleType(typeSelector->currentText());
  9306. updateColumnName(columnName->text());
  9307. updateHidden(hideSeries->isChecked());
  9308. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9309. this,SLOT(updateThermocoupleType(QString)));
  9310. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9311. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9312. }
  9313. /*:754*//*755:*/
  9314. #line 15874 "./typica.w"
  9315. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9316. {
  9317. updateAttribute("type",type);
  9318. }
  9319. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9320. {
  9321. updateAttribute("columnname",name);
  9322. }
  9323. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9324. {
  9325. updateAttribute("hidden",hidden?"true":"false");
  9326. }
  9327. /*:755*/
  9328. #line 585 "./typica.w"
  9329. /*750:*/
  9330. #line 15737 "./typica.w"
  9331. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9332. const QModelIndex&index)
  9333. :BasicDeviceConfigurationWidget(model,index)
  9334. {
  9335. QVBoxLayout*layout= new QVBoxLayout;
  9336. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9337. QLabel*label= new QLabel(tr("Device ID:"));
  9338. QLineEdit*deviceId= new QLineEdit;
  9339. deviceIdLayout->addWidget(label);
  9340. deviceIdLayout->addWidget(deviceId);
  9341. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9342. layout->addLayout(deviceIdLayout);
  9343. layout->addWidget(addChannelButton);
  9344. /*744:*/
  9345. #line 15632 "./typica.w"
  9346. QDomElement referenceElement=
  9347. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9348. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9349. QDomElement node;
  9350. /*:744*/
  9351. #line 15751 "./typica.w"
  9352. for(int i= 0;i<configData.size();i++)
  9353. {
  9354. node= configData.at(i).toElement();
  9355. if(node.attribute("name")=="deviceID")
  9356. {
  9357. deviceId->setText(node.attribute("value","Dev1"));
  9358. break;
  9359. }
  9360. }
  9361. updateDeviceId(deviceId->text());
  9362. connect(addChannelButton,SIGNAL(clicked()),
  9363. this,SLOT(addChannel()));
  9364. connect(deviceId,SIGNAL(textEdited(QString)),
  9365. this,SLOT(updateDeviceId(QString)));
  9366. setLayout(layout);
  9367. }
  9368. /*:750*//*751:*/
  9369. #line 15773 "./typica.w"
  9370. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9371. {
  9372. updateAttribute("deviceID",newId);
  9373. }
  9374. /*:751*//*752:*/
  9375. #line 15781 "./typica.w"
  9376. void NiDaqMxBase9211ConfWidget::addChannel()
  9377. {
  9378. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9379. }
  9380. /*:752*/
  9381. #line 586 "./typica.w"
  9382. /*748:*/
  9383. #line 15688 "./typica.w"
  9384. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9385. DeviceTreeModel*model,const QModelIndex&index):
  9386. BasicDeviceConfigurationWidget(model,index)
  9387. {
  9388. QHBoxLayout*layout= new QHBoxLayout;
  9389. QToolButton*addDeviceButton= new QToolButton;
  9390. addDeviceButton->setText(tr("Add Device"));
  9391. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9392. "nidaqmxbase9211series");
  9393. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9394. "nidaqmxbase9211series");
  9395. connect(add9211,SIGNAL(triggered(QString,QString)),
  9396. this,SLOT(insertChildNode(QString,QString)));
  9397. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9398. this,SLOT(insertChildNode(QString,QString)));
  9399. QMenu*deviceMenu= new QMenu;
  9400. deviceMenu->addAction(add9211);
  9401. deviceMenu->addAction(add9211a);
  9402. addDeviceButton->setMenu(deviceMenu);
  9403. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9404. layout->addWidget(addDeviceButton);
  9405. setLayout(layout);
  9406. }
  9407. /*:748*/
  9408. #line 587 "./typica.w"
  9409. /*615:*/
  9410. #line 13234 "./typica.w"
  9411. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9412. QObject*parent):
  9413. QAction(reportName,parent),reportFile(fileName)
  9414. {
  9415. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9416. }
  9417. /*:615*//*616:*/
  9418. #line 13250 "./typica.w"
  9419. void ReportAction::createReport()
  9420. {
  9421. QFile file(reportFile);
  9422. QDomDocument document;
  9423. if(file.open(QIODevice::ReadOnly))
  9424. {
  9425. document.setContent(&file,true);
  9426. QDomElement element= document.documentElement();
  9427. QScriptEngine*engine= AppInstance->engine;
  9428. QScriptContext*context= engine->pushContext();
  9429. QScriptValue object;
  9430. QString targetID= reportFile;
  9431. /*176:*/
  9432. #line 4126 "./typica.w"
  9433. ScriptQMainWindow*window= new ScriptQMainWindow;
  9434. window->setObjectName(targetID);
  9435. object= engine->newQObject(window);
  9436. setQMainWindowProperties(object,engine);
  9437. QWidget*central= new(QWidget);
  9438. central->setParent(window);
  9439. central->setObjectName("centralWidget");
  9440. window->setCentralWidget(central);
  9441. if(element.hasChildNodes())
  9442. {
  9443. /*177:*/
  9444. #line 4161 "./typica.w"
  9445. QStack<QWidget*> widgetStack;
  9446. QStack<QLayout*> layoutStack;
  9447. QString windowScript;
  9448. widgetStack.push(central);
  9449. QDomNodeList windowChildren= element.childNodes();
  9450. int i= 0;
  9451. while(i<windowChildren.count())
  9452. {
  9453. QDomNode current;
  9454. QDomElement element;
  9455. current= windowChildren.at(i);
  9456. if(current.isElement())
  9457. {
  9458. element= current.toElement();
  9459. if(element.tagName()=="program")
  9460. {
  9461. windowScript.append(element.text());
  9462. }
  9463. else if(element.tagName()=="layout")
  9464. {
  9465. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9466. }
  9467. else if(element.tagName()=="menu")
  9468. {
  9469. /*178:*/
  9470. #line 4208 "./typica.w"
  9471. QMenuBar*bar= window->menuBar();
  9472. bar->setParent(window);
  9473. bar->setObjectName("menuBar");
  9474. if(element.hasAttribute("name"))
  9475. {
  9476. QMenu*menu= bar->addMenu(element.attribute("name"));
  9477. menu->setParent(bar);
  9478. if(element.hasAttribute("type"))
  9479. {
  9480. if(element.attribute("type")=="reports")
  9481. {
  9482. if(element.hasAttribute("src"))
  9483. {
  9484. /*613:*/
  9485. #line 13194 "./typica.w"
  9486. QSettings settings;
  9487. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9488. toString()).
  9489. arg(element.attribute("src"));
  9490. QDir::addSearchPath("reports",reportDirectory);
  9491. QDir directory(reportDirectory);
  9492. directory.setFilter(QDir::Files);
  9493. directory.setSorting(QDir::Name);
  9494. QStringList nameFilter;
  9495. nameFilter<<"*.xml";
  9496. directory.setNameFilters(nameFilter);
  9497. QFileInfoList reportFiles= directory.entryInfoList();
  9498. for(int i= 0;i<reportFiles.size();i++)
  9499. {
  9500. QFileInfo reportFile= reportFiles.at(i);
  9501. /*617:*/
  9502. #line 13274 "./typica.w"
  9503. QString path= reportFile.absoluteFilePath();
  9504. QFile file(path);
  9505. if(file.open(QIODevice::ReadOnly))
  9506. {
  9507. QDomDocument document;
  9508. document.setContent(&file,true);
  9509. QDomElement root= document.documentElement();
  9510. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9511. if(!titleNode.isNull())
  9512. {
  9513. QDomElement titleElement= titleNode.toElement();
  9514. QString title= titleElement.text();
  9515. if(!title.isEmpty())
  9516. {
  9517. QStringList hierarchy= title.split(":->");
  9518. QMenu*insertionPoint= menu;
  9519. /*618:*/
  9520. #line 13301 "./typica.w"
  9521. for(int j= 0;j<hierarchy.size()-1;j++)
  9522. {
  9523. QObjectList menuList= insertionPoint->children();
  9524. bool menuFound= false;
  9525. for(int k= 0;k<menuList.size();k++)
  9526. {
  9527. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9528. if(currentItem)
  9529. {
  9530. if(currentItem->title()==hierarchy.at(j))
  9531. {
  9532. menuFound= true;
  9533. insertionPoint= currentItem;
  9534. break;
  9535. }
  9536. }
  9537. }
  9538. if(!menuFound)
  9539. {
  9540. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9541. }
  9542. }
  9543. /*:618*/
  9544. #line 13291 "./typica.w"
  9545. ReportAction*action= new ReportAction(path,hierarchy.last());
  9546. insertionPoint->addAction(action);
  9547. }
  9548. }
  9549. }
  9550. /*:617*/
  9551. #line 13210 "./typica.w"
  9552. }
  9553. /*:613*/
  9554. #line 4222 "./typica.w"
  9555. }
  9556. }
  9557. }
  9558. if(element.hasChildNodes())
  9559. {
  9560. /*179:*/
  9561. #line 4235 "./typica.w"
  9562. QDomNodeList menuItems= element.childNodes();
  9563. int j= 0;
  9564. while(j<menuItems.count())
  9565. {
  9566. QDomNode item= menuItems.at(j);
  9567. if(item.isElement())
  9568. {
  9569. QDomElement itemElement= item.toElement();
  9570. if(itemElement.tagName()=="item")
  9571. {
  9572. QAction*itemAction= new QAction(itemElement.text(),menu);
  9573. if(itemElement.hasAttribute("id"))
  9574. {
  9575. itemAction->setObjectName(itemElement.attribute("id"));
  9576. }
  9577. if(itemElement.hasAttribute("shortcut"))
  9578. {
  9579. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9580. }
  9581. menu->addAction(itemAction);
  9582. }
  9583. else if(itemElement.tagName()=="separator")
  9584. {
  9585. menu->addSeparator();
  9586. }
  9587. }
  9588. j++;
  9589. }
  9590. #line 1 "./helpmenu.w"
  9591. /*:179*/
  9592. #line 4228 "./typica.w"
  9593. }
  9594. }
  9595. /*:178*/
  9596. #line 4186 "./typica.w"
  9597. }
  9598. }
  9599. i++;
  9600. }
  9601. QScriptValue oldThis= context->thisObject();
  9602. context->setThisObject(object);
  9603. QScriptValue result= engine->evaluate(windowScript);
  9604. /*170:*/
  9605. #line 3943 "./typica.w"
  9606. if(engine->hasUncaughtException())
  9607. {
  9608. int line= engine->uncaughtExceptionLineNumber();
  9609. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9610. result.toString();
  9611. QString trace;
  9612. foreach(trace,engine->uncaughtExceptionBacktrace())
  9613. {
  9614. qDebug()<<trace;
  9615. }
  9616. }
  9617. /*:170*/
  9618. #line 4194 "./typica.w"
  9619. context->setThisObject(oldThis);
  9620. /*:177*/
  9621. #line 4137 "./typica.w"
  9622. }
  9623. /*180:*/
  9624. #line 9 "./helpmenu.w"
  9625. HelpMenu*helpMenu= new HelpMenu();
  9626. window->menuBar()->addMenu(helpMenu);
  9627. /*:180*/
  9628. #line 4139 "./typica.w"
  9629. window->show();
  9630. /*:176*/
  9631. #line 13263 "./typica.w"
  9632. file.close();
  9633. engine->popContext();
  9634. }
  9635. }
  9636. /*:616*/
  9637. #line 588 "./typica.w"
  9638. /*220:*/
  9639. #line 5303 "./typica.w"
  9640. NumericDelegate::NumericDelegate(QObject*parent):
  9641. QItemDelegate(parent)
  9642. {
  9643. }
  9644. /*:220*//*221:*/
  9645. #line 5315 "./typica.w"
  9646. void NumericDelegate::setEditorData(QWidget*editor,
  9647. const QModelIndex&index)const
  9648. {
  9649. QString value= index.model()->data(index,Qt::EditRole).toString();
  9650. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9651. line->setText(value);
  9652. }
  9653. /*:221*//*222:*/
  9654. #line 5330 "./typica.w"
  9655. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9656. const QModelIndex&index)const
  9657. {
  9658. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9659. model->setData(index,line->text(),Qt::EditRole);
  9660. QScriptEngine*engine= AppInstance->engine;
  9661. engine->pushContext();
  9662. QString script= QString("Number(%1)").arg(line->text());
  9663. QScriptValue result= engine->evaluate(line->text());
  9664. if(result.isNumber())
  9665. {
  9666. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9667. }
  9668. else
  9669. {
  9670. model->setData(index,QVariant(),Qt::DisplayRole);
  9671. }
  9672. engine->popContext();
  9673. }
  9674. /*:222*//*223:*/
  9675. #line 5353 "./typica.w"
  9676. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9677. const QStyleOptionViewItem&,
  9678. const QModelIndex&)const
  9679. {
  9680. return(new QLineEdit(parent));
  9681. }
  9682. /*:223*//*224:*/
  9683. #line 5364 "./typica.w"
  9684. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9685. const QStyleOptionViewItem&option,
  9686. const QModelIndex&)const
  9687. {
  9688. editor->setGeometry(option.rect);
  9689. }
  9690. /*:224*/
  9691. #line 589 "./typica.w"
  9692. /*759:*/
  9693. #line 15933 "./typica.w"
  9694. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9695. const QModelIndex&index)
  9696. :BasicDeviceConfigurationWidget(model,index)
  9697. {
  9698. QHBoxLayout*layout= new QHBoxLayout;
  9699. QToolButton*addDeviceButton= new QToolButton;
  9700. addDeviceButton->setText(tr("Add Device"));
  9701. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9702. "nidaqmx9211series");
  9703. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9704. "nidaqmxtc01");
  9705. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9706. this,SLOT(insertChildNode(QString,QString)));
  9707. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9708. this,SLOT(insertChildNode(QString,QString)));
  9709. QMenu*deviceMenu= new QMenu;
  9710. deviceMenu->addAction(add9211a);
  9711. deviceMenu->addAction(addtc01);
  9712. addDeviceButton->setMenu(deviceMenu);
  9713. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9714. layout->addWidget(addDeviceButton);
  9715. setLayout(layout);
  9716. }
  9717. /*:759*/
  9718. #line 590 "./typica.w"
  9719. /*761:*/
  9720. #line 15982 "./typica.w"
  9721. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9722. const QModelIndex&index)
  9723. :BasicDeviceConfigurationWidget(model,index)
  9724. {
  9725. QVBoxLayout*layout= new QVBoxLayout;
  9726. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9727. QLabel*label= new QLabel(tr("Device ID:"));
  9728. QLineEdit*deviceId= new QLineEdit;
  9729. deviceIdLayout->addWidget(label);
  9730. deviceIdLayout->addWidget(deviceId);
  9731. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9732. layout->addLayout(deviceIdLayout);
  9733. layout->addWidget(addChannelButton);
  9734. /*744:*/
  9735. #line 15632 "./typica.w"
  9736. QDomElement referenceElement=
  9737. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9738. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9739. QDomElement node;
  9740. /*:744*/
  9741. #line 15996 "./typica.w"
  9742. for(int i= 0;i<configData.size();i++)
  9743. {
  9744. node= configData.at(i).toElement();
  9745. if(node.attribute("name")=="deviceID")
  9746. {
  9747. deviceId->setText(node.attribute("value","Dev1"));
  9748. break;
  9749. }
  9750. }
  9751. updateDeviceId(deviceId->text());
  9752. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9753. connect(deviceId,SIGNAL(textEdited(QString)),
  9754. this,SLOT(updateDeviceId(QString)));
  9755. setLayout(layout);
  9756. }
  9757. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9758. {
  9759. updateAttribute("deviceID",newId);
  9760. }
  9761. void NiDaqMx9211ConfWidget::addChannel()
  9762. {
  9763. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9764. }
  9765. /*:761*/
  9766. #line 591 "./typica.w"
  9767. /*763:*/
  9768. #line 16047 "./typica.w"
  9769. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9770. const QModelIndex&index)
  9771. :BasicDeviceConfigurationWidget(model,index)
  9772. {
  9773. QFormLayout*layout= new QFormLayout;
  9774. QLineEdit*deviceId= new QLineEdit;
  9775. layout->addRow(tr("Device ID:"),deviceId);
  9776. QLineEdit*columnName= new QLineEdit;
  9777. layout->addRow(tr("Column Name:"),columnName);
  9778. QComboBox*typeSelector= new QComboBox;
  9779. typeSelector->addItem("J");
  9780. typeSelector->addItem("K");
  9781. typeSelector->addItem("T");
  9782. typeSelector->addItem("B");
  9783. typeSelector->addItem("E");
  9784. typeSelector->addItem("N");
  9785. typeSelector->addItem("R");
  9786. typeSelector->addItem("S");
  9787. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9788. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  9789. layout->addRow(hideSeries);
  9790. /*744:*/
  9791. #line 15632 "./typica.w"
  9792. QDomElement referenceElement=
  9793. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9794. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9795. QDomElement node;
  9796. /*:744*/
  9797. #line 16069 "./typica.w"
  9798. for(int i= 0;i<configData.size();i++)
  9799. {
  9800. node= configData.at(i).toElement();
  9801. if(node.attribute("name")=="deviceID")
  9802. {
  9803. deviceId->setText(node.attribute("value"));
  9804. }
  9805. else if(node.attribute("name")=="type")
  9806. {
  9807. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  9808. }
  9809. else if(node.attribute("name")=="columnname")
  9810. {
  9811. columnName->setText(node.attribute("value"));
  9812. }
  9813. else if(node.attribute("name")=="hidden")
  9814. {
  9815. hideSeries->setChecked(node.attribute("value")=="true");
  9816. }
  9817. }
  9818. updateDeviceId(deviceId->text());
  9819. updateThermocoupleType(typeSelector->currentText());
  9820. updateColumnName(columnName->text());
  9821. updateHidden(hideSeries->isChecked());
  9822. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  9823. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  9824. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9825. setLayout(layout);
  9826. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9827. }
  9828. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  9829. {
  9830. updateAttribute("deviceID",newId);
  9831. }
  9832. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  9833. {
  9834. updateAttribute("type",type);
  9835. }
  9836. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  9837. {
  9838. updateAttribute("columnname",name);
  9839. }
  9840. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  9841. {
  9842. updateAttribute("hidden",hidden?"true":"false");
  9843. }
  9844. /*:763*/
  9845. #line 592 "./typica.w"
  9846. /*781:*/
  9847. #line 16485 "./typica.w"
  9848. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  9849. const QModelIndex&index)
  9850. :BasicDeviceConfigurationWidget(model,index)
  9851. {
  9852. QFormLayout*layout= new QFormLayout;
  9853. QToolButton*addDeviceButton= new QToolButton;
  9854. addDeviceButton->setText(tr("Add Device"));
  9855. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  9856. "Modbus RTU Device",
  9857. "modbusrtudevice");
  9858. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  9859. this,SLOT(insertChildNode(QString,QString)));
  9860. QMenu*deviceMenu= new QMenu;
  9861. deviceMenu->addAction(addModbusRtuDevice);
  9862. addDeviceButton->setMenu(deviceMenu);
  9863. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9864. layout->addRow(QString(),addDeviceButton);
  9865. PortSelector*port= new PortSelector;
  9866. layout->addRow(tr("Port:"),port);
  9867. connect(port,SIGNAL(currentIndexChanged(QString)),
  9868. this,SLOT(updatePort(QString)));
  9869. connect(port,SIGNAL(editTextChanged(QString)),
  9870. this,SLOT(updatePort(QString)));
  9871. BaudSelector*rate= new BaudSelector;
  9872. layout->addRow(tr("Baud:"),rate);
  9873. connect(rate,SIGNAL(currentIndexChanged(QString)),
  9874. this,SLOT(updateBaudRate(QString)));
  9875. ParitySelector*parity= new ParitySelector;
  9876. layout->addRow(tr("Parity:"),parity);
  9877. connect(parity,SIGNAL(currentIndexChanged(QString)),
  9878. this,SLOT(updateParity(QString)));
  9879. FlowSelector*flow= new FlowSelector;
  9880. layout->addRow(tr("Flow Control:"),flow);
  9881. connect(flow,SIGNAL(currentIndexChanged(QString)),
  9882. this,SLOT(updateFlowControl(QString)));
  9883. StopSelector*stop= new StopSelector;
  9884. layout->addRow(tr("Stop Bits:"),stop);
  9885. connect(stop,SIGNAL(currentIndexChanged(QString)),
  9886. this,SLOT(updateStopBits(QString)));
  9887. /*744:*/
  9888. #line 15632 "./typica.w"
  9889. QDomElement referenceElement=
  9890. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9891. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9892. QDomElement node;
  9893. /*:744*/
  9894. #line 16525 "./typica.w"
  9895. for(int i= 0;i<configData.size();i++)
  9896. {
  9897. node= configData.at(i).toElement();
  9898. if(node.attribute("name")=="port")
  9899. {
  9900. int j= port->findText(node.attribute("value"));
  9901. if(j>=0)
  9902. {
  9903. port->setCurrentIndex(j);
  9904. }
  9905. else
  9906. {
  9907. port->insertItem(0,node.attribute("value"));
  9908. port->setCurrentIndex(0);
  9909. }
  9910. }
  9911. else if(node.attribute("name")=="baudrate")
  9912. {
  9913. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  9914. }
  9915. else if(node.attribute("name")=="parity")
  9916. {
  9917. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  9918. }
  9919. else if(node.attribute("name")=="flowcontrol")
  9920. {
  9921. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  9922. }
  9923. else if(node.attribute("name")=="stopbits")
  9924. {
  9925. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  9926. }
  9927. }
  9928. updatePort(port->currentText());
  9929. updateBaudRate(rate->currentText());
  9930. updateParity(parity->currentText());
  9931. updateFlowControl(flow->currentText());
  9932. updateStopBits(stop->currentText());
  9933. setLayout(layout);
  9934. }
  9935. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  9936. {
  9937. updateAttribute("port",newPort);
  9938. }
  9939. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  9940. {
  9941. updateAttribute("baudrate",newRate);
  9942. }
  9943. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  9944. {
  9945. updateAttribute("parity",newParity);
  9946. }
  9947. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  9948. {
  9949. updateAttribute("flowcontrol",newFlow);
  9950. }
  9951. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  9952. {
  9953. updateAttribute("stopbits",newStopBits);
  9954. }
  9955. /*:781*/
  9956. #line 593 "./typica.w"
  9957. /*783:*/
  9958. #line 16648 "./typica.w"
  9959. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  9960. const QModelIndex&index)
  9961. :BasicDeviceConfigurationWidget(model,index),
  9962. unitSpecificationLayout(new QStackedLayout),
  9963. decimalSpecificationLayout(new QStackedLayout)
  9964. {
  9965. QVBoxLayout*layout= new QVBoxLayout;
  9966. QToolButton*addChannelButton= new QToolButton;
  9967. addChannelButton->setText(tr("Add Channel"));
  9968. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  9969. "Temperature Process Value",
  9970. "modbustemperaturepv");
  9971. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  9972. "Temperature Set Value",
  9973. "modbustemperaturesv");
  9974. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  9975. this,SLOT(insertChildNode(QString,QString)));
  9976. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  9977. this,SLOT(insertChildNode(QString,QString)));
  9978. QMenu*channelMenu= new QMenu;
  9979. channelMenu->addAction(addTemperaturePV);
  9980. channelMenu->addAction(addTemperatureSV);
  9981. addChannelButton->setMenu(channelMenu);
  9982. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  9983. layout->addWidget(addChannelButton);
  9984. QHBoxLayout*stationLayout= new QHBoxLayout;
  9985. QLabel*stationLabel= new QLabel(tr("Station:"));
  9986. QSpinBox*stationNumber= new QSpinBox;
  9987. stationNumber->setMinimum(0);
  9988. stationNumber->setMaximum(255);
  9989. stationLayout->addWidget(stationLabel);
  9990. stationLayout->addWidget(stationNumber);
  9991. layout->addLayout(stationLayout);
  9992. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  9993. layout->addWidget(fixedUnit);
  9994. QWidget*fixedUnitPlaceholder= new QWidget(this);
  9995. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  9996. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  9997. QComboBox*fixedUnitSelector= new QComboBox;
  9998. fixedUnitSelector->addItem("Fahrenheit");
  9999. fixedUnitSelector->addItem("Celsius");
  10000. fixedUnitLayout->addWidget(fixedUnitLabel);
  10001. fixedUnitLayout->addWidget(fixedUnitSelector);
  10002. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10003. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10004. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10005. QFormLayout*queriedUnitLayout= new QFormLayout;
  10006. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10007. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10008. QSpinBox*valueF= new QSpinBox;
  10009. valueF->setMinimum(0);
  10010. valueF->setMaximum(65535);
  10011. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10012. QSpinBox*valueC= new QSpinBox;
  10013. valueC->setMinimum(0);
  10014. valueC->setMaximum(65535);
  10015. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10016. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10017. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10018. layout->addLayout(unitSpecificationLayout);
  10019. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10020. layout->addWidget(fixedPrecision);
  10021. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10022. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10023. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10024. fixedPrecisionValue->setMinimum(0);
  10025. fixedPrecisionValue->setMaximum(9);
  10026. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10027. fixedPrecisionValue);
  10028. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10029. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10030. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10031. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10032. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10033. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10034. precisionAddress);
  10035. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10036. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10037. layout->addLayout(decimalSpecificationLayout);
  10038. /*744:*/
  10039. #line 15632 "./typica.w"
  10040. QDomElement referenceElement=
  10041. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10042. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10043. QDomElement node;
  10044. /*:744*/
  10045. #line 16728 "./typica.w"
  10046. for(int i= 0;i<configData.size();i++)
  10047. {
  10048. node= configData.at(i).toElement();
  10049. if(node.attribute("name")=="station")
  10050. {
  10051. stationNumber->setValue(node.attribute("value").toInt());
  10052. }
  10053. else if(node.attribute("name")=="fixedunit")
  10054. {
  10055. if(node.attribute("value")=="true")
  10056. {
  10057. fixedUnit->setCheckState(Qt::Checked);
  10058. }
  10059. else if(node.attribute("value")=="false")
  10060. {
  10061. fixedUnit->setCheckState(Qt::Unchecked);
  10062. }
  10063. }
  10064. else if(node.attribute("name")=="fixedprecision")
  10065. {
  10066. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10067. }
  10068. else if(node.attribute("name")=="unit")
  10069. {
  10070. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10071. }
  10072. else if(node.attribute("name")=="unitaddress")
  10073. {
  10074. unitAddress->setValue(node.attribute("value").toInt());
  10075. }
  10076. else if(node.attribute("name")=="fvalue")
  10077. {
  10078. valueF->setValue(node.attribute("value").toInt());
  10079. }
  10080. else if(node.attribute("name")=="cvalue")
  10081. {
  10082. valueC->setValue(node.attribute("value").toInt());
  10083. }
  10084. else if(node.attribute("name")=="precisionaddress")
  10085. {
  10086. precisionAddress->setValue(node.attribute("value").toInt());
  10087. }
  10088. else if(node.attribute("name")=="precision")
  10089. {
  10090. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10091. }
  10092. }
  10093. updateStationNumber(stationNumber->value());
  10094. updateFixedUnit(fixedUnit->isChecked());
  10095. updateFixedDecimal(fixedPrecision->isChecked());
  10096. updateUnit(fixedUnitSelector->currentText());
  10097. updateUnitAddress(unitAddress->value());
  10098. updateValueF(valueF->value());
  10099. updateValueC(valueC->value());
  10100. updatePrecisionAddress(precisionAddress->value());
  10101. updatePrecisionValue(fixedPrecisionValue->value());
  10102. connect(stationNumber,SIGNAL(valueChanged(int)),
  10103. this,SLOT(updateStationNumber(int)));
  10104. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10105. this,SLOT(updateUnit(QString)));
  10106. connect(unitAddress,SIGNAL(valueChanged(int)),
  10107. this,SLOT(updateUnitAddress(int)));
  10108. connect(valueF,SIGNAL(valueChanged(int)),
  10109. this,SLOT(updateValueF(int)));
  10110. connect(valueC,SIGNAL(valueChanged(int)),
  10111. this,SLOT(updateValueC(int)));
  10112. connect(fixedUnit,SIGNAL(toggled(bool)),
  10113. this,SLOT(updateFixedUnit(bool)));
  10114. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10115. this,SLOT(updateFixedDecimal(bool)));
  10116. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10117. this,SLOT(updatePrecisionValue(int)));
  10118. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10119. this,SLOT(updatePrecisionAddress(int)));
  10120. setLayout(layout);
  10121. }
  10122. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10123. {
  10124. updateAttribute("station",QString("%1").arg(newStation));
  10125. }
  10126. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10127. {
  10128. if(newFixed)
  10129. {
  10130. unitSpecificationLayout->setCurrentIndex(0);
  10131. updateAttribute("fixedunit","true");
  10132. }
  10133. else
  10134. {
  10135. unitSpecificationLayout->setCurrentIndex(1);
  10136. updateAttribute("fixedunit","false");
  10137. }
  10138. }
  10139. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10140. {
  10141. if(newFixed)
  10142. {
  10143. decimalSpecificationLayout->setCurrentIndex(0);
  10144. updateAttribute("fixedprecision","true");
  10145. }
  10146. else
  10147. {
  10148. decimalSpecificationLayout->setCurrentIndex(1);
  10149. updateAttribute("fixedprecision","false");
  10150. }
  10151. }
  10152. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10153. {
  10154. updateAttribute("unit",newUnit);
  10155. }
  10156. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10157. {
  10158. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10159. }
  10160. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10161. {
  10162. updateAttribute("fvalue",QString("%1").arg(newValue));
  10163. }
  10164. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10165. {
  10166. updateAttribute("cvalue",QString("%1").arg(newValue));
  10167. }
  10168. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10169. {
  10170. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10171. }
  10172. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10173. {
  10174. updateAttribute("precision",QString("%1").arg(newValue));
  10175. }
  10176. /*:783*/
  10177. #line 594 "./typica.w"
  10178. /*785:*/
  10179. #line 16891 "./typica.w"
  10180. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10181. const QModelIndex&index)
  10182. :BasicDeviceConfigurationWidget(model,index)
  10183. {
  10184. QFormLayout*layout= new QFormLayout;
  10185. ShortHexSpinBox*address= new ShortHexSpinBox;
  10186. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10187. /*744:*/
  10188. #line 15632 "./typica.w"
  10189. QDomElement referenceElement=
  10190. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10191. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10192. QDomElement node;
  10193. /*:744*/
  10194. #line 16899 "./typica.w"
  10195. for(int i= 0;i<configData.size();i++)
  10196. {
  10197. node= configData.at(i).toElement();
  10198. if(node.attribute("name")=="address")
  10199. {
  10200. address->setValue(node.attribute("value").toInt());
  10201. break;
  10202. }
  10203. }
  10204. updateAddress(address->value());
  10205. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10206. setLayout(layout);
  10207. }
  10208. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10209. {
  10210. updateAttribute("address",QString("%1").arg(newAddress));
  10211. }
  10212. /*:785*/
  10213. #line 595 "./typica.w"
  10214. /*787:*/
  10215. #line 16947 "./typica.w"
  10216. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10217. const QModelIndex&index)
  10218. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10219. {
  10220. QVBoxLayout*layout= new QVBoxLayout;
  10221. QFormLayout*addressLayout= new QFormLayout;
  10222. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10223. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10224. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10225. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10226. layout->addLayout(addressLayout);
  10227. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10228. layout->addWidget(fixedRange);
  10229. QWidget*queriedRangePlaceholder= new QWidget(this);
  10230. QFormLayout*queriedRangeLayout= new QFormLayout;
  10231. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10232. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10233. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10234. lowerAddress);
  10235. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10236. upperAddress);
  10237. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10238. boundsLayout->addWidget(queriedRangePlaceholder);
  10239. QWidget*fixedRangePlaceholder= new QWidget(this);
  10240. QFormLayout*fixedRangeLayout= new QFormLayout;
  10241. QLineEdit*fixedLower= new QLineEdit;
  10242. QLineEdit*fixedUpper= new QLineEdit;
  10243. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10244. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10245. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10246. boundsLayout->addWidget(fixedRangePlaceholder);
  10247. layout->addLayout(boundsLayout);
  10248. /*744:*/
  10249. #line 15632 "./typica.w"
  10250. QDomElement referenceElement=
  10251. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10252. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10253. QDomElement node;
  10254. /*:744*/
  10255. #line 16980 "./typica.w"
  10256. for(int i= 0;i<configData.size();i++)
  10257. {
  10258. node= configData.at(i).toElement();
  10259. if(node.attribute("name")=="readaddress")
  10260. {
  10261. readAddress->setValue(node.attribute("value").toInt());
  10262. }
  10263. else if(node.attribute("name")=="writeaddress")
  10264. {
  10265. writeAddress->setValue(node.attribute("value").toInt());
  10266. }
  10267. else if(node.attribute("name")=="fixedrange")
  10268. {
  10269. if(node.attribute("value")=="true")
  10270. {
  10271. fixedRange->setCheckState(Qt::Checked);
  10272. }
  10273. else if(node.attribute("value")=="false")
  10274. {
  10275. fixedRange->setCheckState(Qt::Unchecked);
  10276. }
  10277. }
  10278. else if(node.attribute("name")=="fixedlower")
  10279. {
  10280. fixedLower->setText(node.attribute("value"));
  10281. }
  10282. else if(node.attribute("name")=="fixedupper")
  10283. {
  10284. fixedUpper->setText(node.attribute("value"));
  10285. }
  10286. else if(node.attribute("name")=="loweraddress")
  10287. {
  10288. lowerAddress->setValue(node.attribute("value").toInt());
  10289. }
  10290. else if(node.attribute("name")=="upperaddress")
  10291. {
  10292. upperAddress->setValue(node.attribute("value").toInt());
  10293. }
  10294. }
  10295. updateReadAddress(readAddress->value());
  10296. updateWriteAddress(writeAddress->value());
  10297. updateFixedRange(fixedRange->isChecked());
  10298. updateLower(fixedLower->text());
  10299. updateUpper(fixedUpper->text());
  10300. updateLowerAddress(lowerAddress->value());
  10301. updateUpperAddress(upperAddress->value());
  10302. connect(readAddress,SIGNAL(valueChanged(int)),
  10303. this,SLOT(updateReadAddress(int)));
  10304. connect(writeAddress,SIGNAL(valueChanged(int)),
  10305. this,SLOT(updateWriteAddress(int)));
  10306. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10307. connect(fixedLower,SIGNAL(textChanged(QString)),
  10308. this,SLOT(updateLower(QString)));
  10309. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10310. this,SLOT(updateUpper(QString)));
  10311. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10312. this,SLOT(updateLowerAddress(int)));
  10313. connect(upperAddress,SIGNAL(valueChanged(int)),
  10314. this,SLOT(updateUpperAddress(int)));
  10315. setLayout(layout);
  10316. }
  10317. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10318. {
  10319. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10320. }
  10321. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10322. {
  10323. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10324. }
  10325. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10326. {
  10327. if(fixed)
  10328. {
  10329. updateAttribute("fixedrange","true");
  10330. boundsLayout->setCurrentIndex(1);
  10331. }
  10332. else
  10333. {
  10334. updateAttribute("fixedrange","false");
  10335. boundsLayout->setCurrentIndex(0);
  10336. }
  10337. }
  10338. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10339. {
  10340. updateAttribute("fixedlower",lower);
  10341. }
  10342. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10343. {
  10344. updateAttribute("fixedupper",upper);
  10345. }
  10346. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10347. {
  10348. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10349. }
  10350. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10351. {
  10352. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10353. }
  10354. /*:787*/
  10355. #line 596 "./typica.w"
  10356. /*743:*/
  10357. #line 15554 "./typica.w"
  10358. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10359. :BasicDeviceConfigurationWidget(model,index)
  10360. {
  10361. QVBoxLayout*layout= new QVBoxLayout;
  10362. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10363. QMenu*deviceMenu= new QMenu;
  10364. NodeInserter*insertAction;
  10365. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10366. {
  10367. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10368. this,SLOT(insertChildNode(QString,QString)));
  10369. deviceMenu->addAction(insertAction);
  10370. }
  10371. addDeviceButton->setMenu(deviceMenu);
  10372. layout->addWidget(addDeviceButton);
  10373. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10374. QMenu*annotationMenu= new QMenu;
  10375. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10376. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10377. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10378. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10379. tr("Free Text"),
  10380. "freeannotation");
  10381. annotationMenu->addAction(basicButtonInserter);
  10382. annotationMenu->addAction(countingButtonInserter);
  10383. annotationMenu->addAction(spinBoxInserter);
  10384. annotationMenu->addAction(freeAnnotationInserter);
  10385. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10386. this,SLOT(insertChildNode(QString,QString)));
  10387. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10388. this,SLOT(insertChildNode(QString,QString)));
  10389. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10390. this,SLOT(insertChildNode(QString,QString)));
  10391. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10392. this,SLOT(insertChildNode(QString,QString)));
  10393. /*989:*/
  10394. #line 144 "./valueannotation.w"
  10395. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10396. tr("Value Annotation"),
  10397. "valueannotation");
  10398. annotationMenu->addAction(valueAnnotationInserter);
  10399. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10400. this,SLOT(insertChildNode(QString,QString)));
  10401. /*:989*/
  10402. #line 15590 "./typica.w"
  10403. addAnnotationControlButton->setMenu(annotationMenu);
  10404. layout->addWidget(addAnnotationControlButton);
  10405. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10406. QMenu*advancedMenu= new QMenu;
  10407. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10408. advancedMenu->addAction(linearsplineinserter);
  10409. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10410. advancedMenu->addAction(translationinserter);
  10411. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10412. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10413. /*915:*/
  10414. #line 258 "./rate.w"
  10415. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10416. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10417. advancedMenu->addAction(rateOfChangeInserter);
  10418. /*:915*/
  10419. #line 15601 "./typica.w"
  10420. advancedButton->setMenu(advancedMenu);
  10421. layout->addWidget(advancedButton);
  10422. QHBoxLayout*idLayout= new QHBoxLayout;
  10423. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10424. idLayout->addWidget(idLabel);
  10425. QSpinBox*id= new QSpinBox;
  10426. idLayout->addWidget(id);
  10427. layout->addLayout(idLayout);
  10428. /*744:*/
  10429. #line 15632 "./typica.w"
  10430. QDomElement referenceElement=
  10431. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10432. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10433. QDomElement node;
  10434. /*:744*/
  10435. #line 15610 "./typica.w"
  10436. for(int i= 0;i<configData.size();i++)
  10437. {
  10438. node= configData.at(i).toElement();
  10439. if(node.attribute("name")=="databaseid")
  10440. {
  10441. id->setValue(node.attribute("value").toInt());
  10442. break;
  10443. }
  10444. }
  10445. updateRoasterId(id->value());
  10446. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10447. setLayout(layout);
  10448. }
  10449. /*:743*//*745:*/
  10450. #line 15642 "./typica.w"
  10451. void RoasterConfWidget::updateRoasterId(int id)
  10452. {
  10453. updateAttribute("databaseid",QString("%1").arg(id));
  10454. }
  10455. /*:745*/
  10456. #line 597 "./typica.w"
  10457. /*791:*/
  10458. #line 17130 "./typica.w"
  10459. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10460. :BasicDeviceConfigurationWidget(model,index)
  10461. {
  10462. QFormLayout*layout= new QFormLayout;
  10463. QLineEdit*buttonTextEdit= new QLineEdit;
  10464. QLineEdit*annotationTextEdit= new QLineEdit;
  10465. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10466. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10467. /*744:*/
  10468. #line 15632 "./typica.w"
  10469. QDomElement referenceElement=
  10470. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10471. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10472. QDomElement node;
  10473. /*:744*/
  10474. #line 17139 "./typica.w"
  10475. for(int i= 0;i<configData.size();i++)
  10476. {
  10477. node= configData.at(i).toElement();
  10478. if(node.attribute("name")=="buttontext")
  10479. {
  10480. buttonTextEdit->setText(node.attribute("value"));
  10481. }
  10482. else if(node.attribute("name")=="annotationtext")
  10483. {
  10484. annotationTextEdit->setText(node.attribute("value"));
  10485. }
  10486. }
  10487. updateButtonText(buttonTextEdit->text());
  10488. updateAnnotationText(annotationTextEdit->text());
  10489. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10490. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10491. setLayout(layout);
  10492. }
  10493. /*:791*//*792:*/
  10494. #line 17161 "./typica.w"
  10495. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10496. {
  10497. updateAttribute("buttontext",text);
  10498. }
  10499. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10500. {
  10501. updateAttribute("annotationtext",text);
  10502. }
  10503. /*:792*//*795:*/
  10504. #line 17199 "./typica.w"
  10505. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10506. :BasicDeviceConfigurationWidget(model,index)
  10507. {
  10508. QFormLayout*layout= new QFormLayout;
  10509. QLineEdit*buttonTextEdit= new QLineEdit;
  10510. QLineEdit*annotationTextEdit= new QLineEdit;
  10511. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10512. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10513. /*744:*/
  10514. #line 15632 "./typica.w"
  10515. QDomElement referenceElement=
  10516. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10517. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10518. QDomElement node;
  10519. /*:744*/
  10520. #line 17208 "./typica.w"
  10521. for(int i= 0;i<configData.size();i++)
  10522. {
  10523. node= configData.at(i).toElement();
  10524. if(node.attribute("name")=="buttontext")
  10525. {
  10526. buttonTextEdit->setText(node.attribute("value"));
  10527. }
  10528. else if(node.attribute("name")=="annotationtext")
  10529. {
  10530. annotationTextEdit->setText(node.attribute("value"));
  10531. }
  10532. }
  10533. updateButtonText(buttonTextEdit->text());
  10534. updateAnnotationText(annotationTextEdit->text());
  10535. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10536. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10537. QTextEdit*documentation= new QTextEdit;
  10538. 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."));
  10539. documentation->setReadOnly(true);
  10540. layout->addRow("",documentation);
  10541. setLayout(layout);
  10542. }
  10543. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10544. {
  10545. updateAttribute("buttontext",text);
  10546. }
  10547. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10548. {
  10549. updateAttribute("annotationtext",text);
  10550. }
  10551. /*:795*/
  10552. #line 598 "./typica.w"
  10553. /*798:*/
  10554. #line 17276 "./typica.w"
  10555. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10556. :BasicDeviceConfigurationWidget(model,index)
  10557. {
  10558. QFormLayout*layout= new QFormLayout;
  10559. QLineEdit*labelEdit= new QLineEdit;
  10560. layout->addRow(tr("Control Label: "),labelEdit);
  10561. QLineEdit*minimumEdit= new QLineEdit;
  10562. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10563. QLineEdit*maximumEdit= new QLineEdit;
  10564. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10565. QSpinBox*precisionEdit= new QSpinBox;
  10566. precisionEdit->setMinimum(0);
  10567. precisionEdit->setMaximum(9);
  10568. layout->addRow(tr("Precision"),precisionEdit);
  10569. QLineEdit*pretext= new QLineEdit;
  10570. layout->addRow(tr("Prefix text"),pretext);
  10571. QLineEdit*posttext= new QLineEdit;
  10572. layout->addRow(tr("Suffix text"),posttext);
  10573. /*744:*/
  10574. #line 15632 "./typica.w"
  10575. QDomElement referenceElement=
  10576. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10577. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10578. QDomElement node;
  10579. /*:744*/
  10580. #line 17295 "./typica.w"
  10581. for(int i= 0;i<configData.size();i++)
  10582. {
  10583. node= configData.at(i).toElement();
  10584. if(node.attribute("name")=="label")
  10585. {
  10586. labelEdit->setText(node.attribute("value"));
  10587. }
  10588. else if(node.attribute("name")=="minimum")
  10589. {
  10590. minimumEdit->setText(node.attribute("value"));
  10591. }
  10592. else if(node.attribute("name")=="maximum")
  10593. {
  10594. maximumEdit->setText(node.attribute("value"));
  10595. }
  10596. else if(node.attribute("name")=="precision")
  10597. {
  10598. precisionEdit->setValue(node.attribute("value").toInt());
  10599. }
  10600. else if(node.attribute("name")=="pretext")
  10601. {
  10602. pretext->setText(node.attribute("value"));
  10603. }
  10604. else if(node.attribute("name")=="posttext")
  10605. {
  10606. posttext->setText(node.attribute("value"));
  10607. }
  10608. }
  10609. updateLabel(labelEdit->text());
  10610. updateMinimum(minimumEdit->text());
  10611. updateMaximum(maximumEdit->text());
  10612. updatePrecision(precisionEdit->value());
  10613. updatePretext(pretext->text());
  10614. updatePosttext(posttext->text());
  10615. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10616. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10617. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10618. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10619. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10620. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10621. setLayout(layout);
  10622. }
  10623. void NoteSpinConfWidget::updateLabel(const QString&text)
  10624. {
  10625. updateAttribute("label",text);
  10626. }
  10627. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10628. {
  10629. updateAttribute("minimum",minimum);
  10630. }
  10631. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10632. {
  10633. updateAttribute("maximum",maximum);
  10634. }
  10635. void NoteSpinConfWidget::updatePrecision(int precision)
  10636. {
  10637. updateAttribute("precision",QString("%1").arg(precision));
  10638. }
  10639. void NoteSpinConfWidget::updatePretext(const QString&text)
  10640. {
  10641. updateAttribute("pretext",text);
  10642. }
  10643. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10644. {
  10645. updateAttribute("posttext",text);
  10646. }
  10647. /*:798*/
  10648. #line 599 "./typica.w"
  10649. /*308:*/
  10650. #line 6945 "./typica.w"
  10651. LinearCalibrator::LinearCalibrator(QObject*parent):
  10652. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10653. {
  10654. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10655. }
  10656. /*:308*//*309:*/
  10657. #line 6959 "./typica.w"
  10658. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10659. {
  10660. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10661. if(clamp)
  10662. {
  10663. if(outval<Lo1)
  10664. {
  10665. outval= Lo1;
  10666. }
  10667. else if(outval> Up1)
  10668. {
  10669. outval= Up1;
  10670. }
  10671. }
  10672. if(sensitivitySetting>=0.05)
  10673. {
  10674. int temp= qRound(outval/sensitivitySetting);
  10675. outval= temp*sensitivitySetting;
  10676. }
  10677. Measurement adjusted(outval,measure.time(),measure.scale());
  10678. emit measurement(adjusted);
  10679. return adjusted;
  10680. }
  10681. /*:309*//*310:*/
  10682. #line 6986 "./typica.w"
  10683. double LinearCalibrator::measuredLower()
  10684. {
  10685. return Lo2;
  10686. }
  10687. double LinearCalibrator::measuredUpper()
  10688. {
  10689. return Up2;
  10690. }
  10691. double LinearCalibrator::mappedLower()
  10692. {
  10693. return Lo1;
  10694. }
  10695. double LinearCalibrator::mappedUpper()
  10696. {
  10697. return Up1;
  10698. }
  10699. bool LinearCalibrator::isClosedRange()
  10700. {
  10701. return clamp;
  10702. }
  10703. void LinearCalibrator::setMeasuredLower(double lower)
  10704. {
  10705. Lo2= lower;
  10706. }
  10707. void LinearCalibrator::setMeasuredUpper(double upper)
  10708. {
  10709. Up2= upper;
  10710. }
  10711. void LinearCalibrator::setMappedLower(double lower)
  10712. {
  10713. Lo1= lower;
  10714. }
  10715. void LinearCalibrator::setMappedUpper(double upper)
  10716. {
  10717. Up1= upper;
  10718. }
  10719. void LinearCalibrator::setClosedRange(bool closed)
  10720. {
  10721. clamp= closed;
  10722. }
  10723. void LinearCalibrator::setSensitivity(double sensitivity)
  10724. {
  10725. sensitivitySetting= sensitivity;
  10726. }
  10727. double LinearCalibrator::sensitivity()
  10728. {
  10729. return sensitivitySetting;
  10730. }
  10731. /*:310*/
  10732. #line 600 "./typica.w"
  10733. /*315:*/
  10734. #line 7119 "./typica.w"
  10735. void LinearSplineInterpolator::add_pair(double source,double destination)
  10736. {
  10737. pairs->insert(source,destination);
  10738. make_interpolators();
  10739. }
  10740. void LinearSplineInterpolator::make_interpolators()
  10741. {
  10742. if(pairs->size()> 1)
  10743. {
  10744. while(interpolators->size()> 0)
  10745. {
  10746. LinearCalibrator*removed= interpolators->takeFirst();
  10747. removed->deleteLater();
  10748. }
  10749. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10750. QMap<double,double> ::const_iterator j= i+1;
  10751. while(j!=pairs->constEnd())
  10752. {
  10753. LinearCalibrator*segment= new LinearCalibrator();
  10754. segment->setMeasuredLower(i.key());
  10755. segment->setMappedLower(i.value());
  10756. segment->setMeasuredUpper(j.key());
  10757. segment->setMappedUpper(j.value());
  10758. segment->setClosedRange(false);
  10759. interpolators->append(segment);
  10760. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10761. i++;
  10762. j++;
  10763. }
  10764. }
  10765. }
  10766. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  10767. QObject(parent),pairs(new QMap<double,double> ),
  10768. interpolators(new QList<LinearCalibrator*> )
  10769. {
  10770. }
  10771. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  10772. {
  10773. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10774. int index= -1;
  10775. while(i!=pairs->constEnd())
  10776. {
  10777. if(measure.temperature()<=i.key())
  10778. {
  10779. break;
  10780. }
  10781. i++;
  10782. index++;
  10783. }
  10784. if(index<0)
  10785. {
  10786. index= 0;
  10787. }
  10788. if(index>=interpolators->size())
  10789. {
  10790. index= interpolators->size()-1;
  10791. }
  10792. if(interpolators->at(index)!=NULL)
  10793. {
  10794. return interpolators->at(index)->newMeasurement(measure);
  10795. }
  10796. return Measurement();
  10797. }
  10798. /*:315*/
  10799. #line 601 "./typica.w"
  10800. /*894:*/
  10801. #line 18644 "./typica.w"
  10802. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10803. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  10804. {
  10805. QFormLayout*layout= new QFormLayout;
  10806. QLineEdit*source= new QLineEdit;
  10807. layout->addRow(tr("Source column name:"),source);
  10808. QLineEdit*destination= new QLineEdit;
  10809. layout->addRow(tr("Destination column name:"),destination);
  10810. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  10811. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  10812. QTableView*mappingTable= new QTableView;
  10813. mappingTable->setModel(tablemodel);
  10814. NumericDelegate*delegate= new NumericDelegate;
  10815. mappingTable->setItemDelegate(delegate);
  10816. layout->addRow(tr("Mapping data:"),mappingTable);
  10817. /*744:*/
  10818. #line 15632 "./typica.w"
  10819. QDomElement referenceElement=
  10820. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10821. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10822. QDomElement node;
  10823. /*:744*/
  10824. #line 18660 "./typica.w"
  10825. for(int i= 0;i<configData.size();i++)
  10826. {
  10827. node= configData.at(i).toElement();
  10828. if(node.attribute("name")=="source")
  10829. {
  10830. source->setText(node.attribute("value"));
  10831. }
  10832. else if(node.attribute("name")=="destination")
  10833. {
  10834. destination->setText(node.attribute("value"));
  10835. }
  10836. else if(node.attribute("name")=="sourcevalues")
  10837. {
  10838. /*895:*/
  10839. #line 18699 "./typica.w"
  10840. QString data= node.attribute("value");
  10841. if(data.length()> 3)
  10842. {
  10843. data.chop(2);
  10844. data= data.remove(0,2);
  10845. }
  10846. QStringList itemList= data.split(",");
  10847. /*:895*/
  10848. #line 18674 "./typica.w"
  10849. int column= 0;
  10850. /*896:*/
  10851. #line 18711 "./typica.w"
  10852. for(int i= 0;i<itemList.size();i++)
  10853. {
  10854. tablemodel->setData(tablemodel->index(i,column),
  10855. QVariant(itemList.at(i).toDouble()),
  10856. Qt::DisplayRole);
  10857. }
  10858. /*:896*/
  10859. #line 18676 "./typica.w"
  10860. }
  10861. else if(node.attribute("name")=="destinationvalues")
  10862. {
  10863. /*895:*/
  10864. #line 18699 "./typica.w"
  10865. QString data= node.attribute("value");
  10866. if(data.length()> 3)
  10867. {
  10868. data.chop(2);
  10869. data= data.remove(0,2);
  10870. }
  10871. QStringList itemList= data.split(",");
  10872. /*:895*/
  10873. #line 18681 "./typica.w"
  10874. int column= 1;
  10875. /*896:*/
  10876. #line 18711 "./typica.w"
  10877. for(int i= 0;i<itemList.size();i++)
  10878. {
  10879. tablemodel->setData(tablemodel->index(i,column),
  10880. QVariant(itemList.at(i).toDouble()),
  10881. Qt::DisplayRole);
  10882. }
  10883. /*:896*/
  10884. #line 18683 "./typica.w"
  10885. }
  10886. }
  10887. updateSourceColumn(source->text());
  10888. updateDestinationColumn(destination->text());
  10889. updateKnots();
  10890. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  10891. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  10892. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  10893. setLayout(layout);
  10894. }
  10895. /*:894*//*897:*/
  10896. #line 18722 "./typica.w"
  10897. void LinearSplineInterpolationConfWidget::updateKnots()
  10898. {
  10899. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  10900. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  10901. }
  10902. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  10903. {
  10904. updateAttribute("source",source);
  10905. }
  10906. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  10907. {
  10908. updateAttribute("destination",dest);
  10909. }
  10910. /*:897*/
  10911. #line 602 "./typica.w"
  10912. /*900:*/
  10913. #line 18765 "./typica.w"
  10914. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10915. :BasicDeviceConfigurationWidget(model,index),
  10916. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  10917. {
  10918. unitSelector->addItem("Fahrenheit");
  10919. unitSelector->addItem("Celsius");
  10920. temperatureValue->setMinimum(0);
  10921. temperatureValue->setMaximum(1000);
  10922. QFormLayout*layout= new QFormLayout;
  10923. QLineEdit*column= new QLineEdit;
  10924. layout->addRow(tr("Column to match:"),column);
  10925. layout->addRow(tr("Unit:"),unitSelector);
  10926. layout->addRow(tr("Value:"),temperatureValue);
  10927. /*744:*/
  10928. #line 15632 "./typica.w"
  10929. QDomElement referenceElement=
  10930. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10931. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10932. QDomElement node;
  10933. /*:744*/
  10934. #line 18779 "./typica.w"
  10935. for(int i= 0;i<configData.size();i++)
  10936. {
  10937. node= configData.at(i).toElement();
  10938. if(node.attribute("name")=="column")
  10939. {
  10940. column->setText(node.attribute("value"));
  10941. }
  10942. else if(node.attribute("name")=="unit")
  10943. {
  10944. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  10945. }
  10946. else if(node.attribute("name")=="value")
  10947. {
  10948. temperatureValue->setValue(node.attribute("value").toDouble());
  10949. }
  10950. }
  10951. updateMatchingColumn(column->text());
  10952. updateTemperature();
  10953. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  10954. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  10955. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  10956. setLayout(layout);
  10957. }
  10958. /*:900*//*901:*/
  10959. #line 18808 "./typica.w"
  10960. void TranslationConfWidget::updateTemperature()
  10961. {
  10962. updateAttribute("unit",unitSelector->currentText());
  10963. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  10964. if(unitSelector->currentText()=="Fahrenheit")
  10965. {
  10966. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  10967. }
  10968. else
  10969. {
  10970. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  10971. }
  10972. }
  10973. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  10974. {
  10975. updateAttribute("column",column);
  10976. }
  10977. /*:901*/
  10978. #line 603 "./typica.w"
  10979. /*801:*/
  10980. #line 24 "./freeannotation.w"
  10981. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  10982. const QModelIndex&index)
  10983. :BasicDeviceConfigurationWidget(model,index)
  10984. {
  10985. QFormLayout*layout= new QFormLayout;
  10986. QLineEdit*labelEdit= new QLineEdit;
  10987. layout->addRow(tr("Label Text:"),labelEdit);
  10988. /*744:*/
  10989. #line 15632 "./typica.w"
  10990. QDomElement referenceElement=
  10991. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10992. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10993. QDomElement node;
  10994. /*:744*/
  10995. #line 32 "./freeannotation.w"
  10996. for(int i= 0;i<configData.size();i++)
  10997. {
  10998. node= configData.at(i).toElement();
  10999. if(node.attribute("name")=="labeltext")
  11000. {
  11001. labelEdit->setText(node.attribute("value"));
  11002. }
  11003. }
  11004. updateLabel(labelEdit->text());
  11005. connect(labelEdit,SIGNAL(textEdited(QString)),
  11006. this,SLOT(updateLabel(QString)));
  11007. setLayout(layout);
  11008. }
  11009. /*:801*//*802:*/
  11010. #line 49 "./freeannotation.w"
  11011. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11012. {
  11013. updateAttribute("labeltext",text);
  11014. }
  11015. /*:802*/
  11016. #line 604 "./typica.w"
  11017. /*904:*/
  11018. #line 39 "./rate.w"
  11019. void RateOfChange::newMeasurement(Measurement measure)
  11020. {
  11021. cache.append(measure);
  11022. /*905:*/
  11023. #line 64 "./rate.w"
  11024. if(cache.size()> 2)
  11025. {
  11026. bool done= false;
  11027. while(!done)
  11028. {
  11029. if(cache.front().time().secsTo(cache.back().time())> ct)
  11030. {
  11031. cache.removeFirst();
  11032. }
  11033. else if(cache.back().time()<cache.front().time())
  11034. {
  11035. cache.removeFirst();
  11036. done= true;
  11037. }
  11038. else
  11039. {
  11040. done= true;
  11041. }
  11042. if(cache.size()<3)
  11043. {
  11044. done= true;
  11045. }
  11046. }
  11047. }
  11048. /*:905*/
  11049. #line 43 "./rate.w"
  11050. if(cache.size()>=2)
  11051. {
  11052. /*906:*/
  11053. #line 96 "./rate.w"
  11054. int N= cache.size();
  11055. double SXY= 0;
  11056. double SX= 0;
  11057. double SXX= 0;
  11058. double SY= 0;
  11059. double y;
  11060. double x;
  11061. for(int i= 0;i<N;i++)
  11062. {
  11063. y= cache.at(i).temperature();
  11064. SY+= y;
  11065. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11066. SX+= x;
  11067. SXX+= (x*x);
  11068. SXY+= (x*y);
  11069. }
  11070. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11071. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11072. value.insert("relative",true);
  11073. emit newData(value);
  11074. /*:906*/
  11075. #line 46 "./rate.w"
  11076. }
  11077. }
  11078. /*:904*//*907:*/
  11079. #line 120 "./rate.w"
  11080. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11081. {
  11082. setScaleTime(scaletime);
  11083. }
  11084. void RateOfChange::setCacheTime(int seconds)
  11085. {
  11086. ct= seconds;
  11087. }
  11088. void RateOfChange::setScaleTime(int seconds)
  11089. {
  11090. st= (seconds> 0?seconds:1);
  11091. }
  11092. /*:907*/
  11093. #line 605 "./typica.w"
  11094. /*805:*/
  11095. #line 26 "./settings.w"
  11096. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11097. {
  11098. QTabWidget*settingsTab= new QTabWidget;
  11099. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11100. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11101. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11102. settingsTab->addTab(graphSettings,tr("Graph"));
  11103. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11104. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11105. setCentralWidget(settingsTab);
  11106. }
  11107. /*:805*/
  11108. #line 606 "./typica.w"
  11109. /*810:*/
  11110. #line 27 "./graphsettings.w"
  11111. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11112. {
  11113. QTabWidget*graphCategories= new QTabWidget;
  11114. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11115. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11116. QVBoxLayout*layout= new QVBoxLayout;
  11117. layout->addWidget(graphCategories);
  11118. setLayout(layout);
  11119. }
  11120. /*:810*//*812:*/
  11121. #line 65 "./graphsettings.w"
  11122. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11123. colorEdit(new QLineEdit)
  11124. {
  11125. QSettings settings;
  11126. QVBoxLayout*layout= new QVBoxLayout;
  11127. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11128. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11129. updateEnableSetting(enable->isChecked());
  11130. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11131. layout->addWidget(enable);
  11132. QHBoxLayout*colorLayout= new QHBoxLayout;
  11133. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11134. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11135. updateColorSetting(colorEdit->text());
  11136. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11137. QToolButton*colorPickerButton= new QToolButton();
  11138. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11139. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11140. colorLayout->addWidget(colorLabel);
  11141. colorLayout->addWidget(colorEdit);
  11142. colorLayout->addWidget(colorPickerButton);
  11143. colorLayout->addStretch();
  11144. layout->addLayout(colorLayout);
  11145. QHBoxLayout*unitLayout= new QHBoxLayout;
  11146. QLabel*unitLabel= new QLabel(tr("Unit"));
  11147. QComboBox*unitSelector= new QComboBox;
  11148. unitSelector->addItem(tr("Fahrenheit"));
  11149. unitSelector->addItem(tr("Celsius"));
  11150. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11151. updateUnit(unitSelector->currentIndex());
  11152. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11153. unitLayout->addWidget(unitLabel);
  11154. unitLayout->addWidget(unitSelector);
  11155. unitLayout->addStretch();
  11156. layout->addLayout(unitLayout);
  11157. QHBoxLayout*axisLayout= new QHBoxLayout;
  11158. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11159. QLineEdit*axisEdit= new QLineEdit;
  11160. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11161. updateAxisSetting(axisEdit->text());
  11162. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11163. axisLayout->addWidget(axisLabel);
  11164. axisLayout->addWidget(axisEdit);
  11165. layout->addLayout(axisLayout);
  11166. layout->addStretch();
  11167. setLayout(layout);
  11168. }
  11169. /*:812*//*813:*/
  11170. #line 116 "./graphsettings.w"
  11171. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11172. {
  11173. QSettings settings;
  11174. settings.setValue("settings/graph/relative/enable",enabled);
  11175. }
  11176. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11177. {
  11178. QSettings settings;
  11179. settings.setValue("settings/graph/relative/color",color);
  11180. }
  11181. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11182. {
  11183. QSettings settings;
  11184. QString settingValue;
  11185. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11186. QStringList numbers;
  11187. foreach(QString text,points)
  11188. {
  11189. bool okay= false;
  11190. text.toDouble(&okay);
  11191. if(okay)
  11192. {
  11193. numbers.append(text);
  11194. }
  11195. }
  11196. numbers.removeDuplicates();
  11197. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11198. }
  11199. void GraphSettingsRelativeTab::updateUnit(int unit)
  11200. {
  11201. QSettings settings;
  11202. settings.setValue("settings/graph/relative/unit",unit);
  11203. }
  11204. /*:813*//*814:*/
  11205. #line 159 "./graphsettings.w"
  11206. void GraphSettingsRelativeTab::showColorPicker()
  11207. {
  11208. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11209. colorEdit->setText(color.name());
  11210. }
  11211. #line 62 "./settings.w"
  11212. #line 1 "./advancedsettings.w"
  11213. /*:814*/
  11214. #line 607 "./typica.w"
  11215. /*939:*/
  11216. #line 682 "./dataqsdk.w"
  11217. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11218. const QModelIndex&index)
  11219. :BasicDeviceConfigurationWidget(model,index),
  11220. deviceIdStack(new QStackedWidget)
  11221. {
  11222. QVBoxLayout*layout= new QVBoxLayout;
  11223. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11224. layout->addWidget(autoDetect);
  11225. QWidget*autoLayerWidget= new QWidget;
  11226. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11227. QLabel*autoLabel= new QLabel(tr("Device number"));
  11228. QSpinBox*autoNumber= new QSpinBox;
  11229. autoNumber->setMinimum(1);
  11230. autoNumber->setMaximum(99);
  11231. autoLayerLayout->addWidget(autoLabel);
  11232. autoLayerLayout->addWidget(autoNumber);
  11233. autoLayerWidget->setLayout(autoLayerLayout);
  11234. QWidget*fixedLayerWidget= new QWidget;
  11235. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11236. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11237. QComboBox*portSelection= new QComboBox;
  11238. portSelection->setEditable(true);
  11239. portSelection->addItems(DataqSdkDevice::detectHardware());
  11240. fixedLayerLayout->addWidget(fixedLabel);
  11241. fixedLayerLayout->addWidget(portSelection);
  11242. fixedLayerWidget->setLayout(fixedLayerLayout);
  11243. deviceIdStack->addWidget(autoLayerWidget);
  11244. deviceIdStack->addWidget(fixedLayerWidget);
  11245. layout->addWidget(deviceIdStack);
  11246. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11247. layout->addWidget(addChannelButton);
  11248. /*744:*/
  11249. #line 15632 "./typica.w"
  11250. QDomElement referenceElement=
  11251. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11252. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11253. QDomElement node;
  11254. /*:744*/
  11255. #line 714 "./dataqsdk.w"
  11256. for(int i= 0;i<configData.size();i++)
  11257. {
  11258. node= configData.at(i).toElement();
  11259. if(node.attribute("name")=="autoSelect")
  11260. {
  11261. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11262. }
  11263. else if(node.attribute("name")=="deviceNumber")
  11264. {
  11265. autoNumber->setValue(node.attribute("value").toInt());
  11266. }
  11267. else if(node.attribute("name")=="port")
  11268. {
  11269. int index= portSelection->findText(node.attribute("value"));
  11270. if(index> -1)
  11271. {
  11272. portSelection->setCurrentIndex(index);
  11273. }
  11274. else
  11275. {
  11276. portSelection->setEditText(node.attribute("value"));
  11277. }
  11278. }
  11279. }
  11280. updateAutoSelect(autoDetect->isChecked());
  11281. updateDeviceNumber(autoNumber->value());
  11282. updatePort(portSelection->currentText());
  11283. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11284. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11285. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11286. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11287. setLayout(layout);
  11288. }
  11289. /*:939*//*940:*/
  11290. #line 758 "./dataqsdk.w"
  11291. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11292. {
  11293. if(automatic)
  11294. {
  11295. updateAttribute("autoSelect","true");
  11296. deviceIdStack->setCurrentIndex(0);
  11297. }
  11298. else
  11299. {
  11300. updateAttribute("autoSelect","false");
  11301. deviceIdStack->setCurrentIndex(1);
  11302. }
  11303. }
  11304. /*:940*//*941:*/
  11305. #line 775 "./dataqsdk.w"
  11306. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11307. {
  11308. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11309. }
  11310. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11311. {
  11312. updateAttribute("port",portId);
  11313. }
  11314. /*:941*//*942:*/
  11315. #line 788 "./dataqsdk.w"
  11316. void DataqSdkDeviceConfWidget::addChannel()
  11317. {
  11318. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11319. }
  11320. /*:942*//*945:*/
  11321. #line 868 "./dataqsdk.w"
  11322. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11323. const QModelIndex&index)
  11324. :BasicDeviceConfigurationWidget(model,index),
  11325. startButton(new QPushButton(tr("Start"))),
  11326. resetButton(new QPushButton(tr("Reset"))),
  11327. stopButton(new QPushButton(tr("Stop"))),
  11328. calibrator(new LinearCalibrator),
  11329. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11330. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11331. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11332. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11333. rmCount(0),cmCount(0),
  11334. rmin(std::numeric_limits<double> ::max()),
  11335. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11336. cmin(std::numeric_limits<double> ::max()),
  11337. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11338. {
  11339. /*949:*/
  11340. #line 1107 "./dataqsdk.w"
  11341. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11342. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11343. QDomElement deviceNode;
  11344. QString configPort;
  11345. QString configAuto;
  11346. for(int i= 0;i<deviceConfigData.size();i++)
  11347. {
  11348. deviceNode= deviceConfigData.at(i).toElement();
  11349. if(deviceNode.attribute("name")=="autoSelect")
  11350. {
  11351. autoSelect= (deviceNode.attribute("value")=="true");
  11352. }
  11353. else if(deviceNode.attribute("name")=="deviceNumber")
  11354. {
  11355. configAuto= deviceNode.attribute("value");
  11356. }
  11357. else if(deviceNode.attribute("name")=="port")
  11358. {
  11359. configPort= deviceNode.attribute("value");
  11360. }
  11361. }
  11362. deviceID= autoSelect?configAuto:configPort;
  11363. channelOfInterest= index.row();
  11364. /*:949*/
  11365. #line 886 "./dataqsdk.w"
  11366. resetButton->setEnabled(false);
  11367. stopButton->setEnabled(false);
  11368. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11369. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11370. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11371. QVBoxLayout*layout= new QVBoxLayout;
  11372. QFormLayout*topLayout= new QFormLayout;
  11373. QLineEdit*columnEdit= new QLineEdit;
  11374. topLayout->addRow(tr("Column name"),columnEdit);
  11375. QComboBox*unitSelector= new QComboBox;
  11376. unitSelector->addItem(tr("Temperature"));
  11377. unitSelector->addItem(tr("Control"));
  11378. topLayout->addRow(tr("Measurement type"),unitSelector);
  11379. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11380. topLayout->addRow(smoothingBox);
  11381. layout->addLayout(topLayout);
  11382. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11383. topLayout->addRow(hideSeries);
  11384. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11385. layout->addWidget(calibrationLabel);
  11386. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11387. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11388. QLineEdit*measuredLowerEdit= new QLineEdit;
  11389. measuredLowerEdit->setText("0");
  11390. QLineEdit*measuredUpperEdit= new QLineEdit;
  11391. measuredUpperEdit->setText("10");
  11392. QLineEdit*mappedLowerEdit= new QLineEdit;
  11393. mappedLowerEdit->setText("0");
  11394. QLineEdit*mappedUpperEdit= new QLineEdit;
  11395. mappedUpperEdit->setText("10");
  11396. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11397. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11398. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11399. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11400. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11401. calibrationControlsLayout->addRow(closedBox);
  11402. QLineEdit*sensitivityEdit= new QLineEdit;
  11403. sensitivityEdit->setText("0");
  11404. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11405. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11406. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11407. deviceControlLayout->addWidget(startButton);
  11408. deviceControlLayout->addWidget(resetButton);
  11409. deviceControlLayout->addWidget(stopButton);
  11410. QFormLayout*indicatorLayout= new QFormLayout;
  11411. currentMeasurement->setReadOnly(true);
  11412. minimumMeasurement->setReadOnly(true);
  11413. maximumMeasurement->setReadOnly(true);
  11414. averageMeasurement->setReadOnly(true);
  11415. currentMapped->setReadOnly(true);
  11416. minimumMapped->setReadOnly(true);
  11417. maximumMapped->setReadOnly(true);
  11418. averageMapped->setReadOnly(true);
  11419. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11420. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11421. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11422. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11423. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11424. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11425. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11426. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11427. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11428. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11429. calibrationTestLayout->addLayout(deviceControlLayout);
  11430. calibrationTestLayout->addLayout(indicatorLayout);
  11431. calibrationLayout->addLayout(calibrationControlsLayout);
  11432. calibrationLayout->addLayout(calibrationTestLayout);
  11433. layout->addLayout(calibrationLayout);
  11434. /*744:*/
  11435. #line 15632 "./typica.w"
  11436. QDomElement referenceElement=
  11437. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11438. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11439. QDomElement node;
  11440. /*:744*/
  11441. #line 955 "./dataqsdk.w"
  11442. for(int i= 0;i<configData.size();i++)
  11443. {
  11444. node= configData.at(i).toElement();
  11445. if(node.attribute("name")=="column")
  11446. {
  11447. columnEdit->setText(node.attribute("value"));
  11448. }
  11449. else if(node.attribute("name")=="type")
  11450. {
  11451. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11452. }
  11453. else if(node.attribute("name")=="smoothing")
  11454. {
  11455. smoothingBox->setChecked(node.attribute("value")=="true");
  11456. }
  11457. else if(node.attribute("name")=="calibrationMeasuredLower")
  11458. {
  11459. measuredLowerEdit->setText(node.attribute("value"));
  11460. }
  11461. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11462. {
  11463. measuredUpperEdit->setText(node.attribute("value"));
  11464. }
  11465. else if(node.attribute("name")=="calibrationMappedLower")
  11466. {
  11467. mappedLowerEdit->setText(node.attribute("value"));
  11468. }
  11469. else if(node.attribute("name")=="calibrationMappedUpper")
  11470. {
  11471. mappedUpperEdit->setText(node.attribute("value"));
  11472. }
  11473. else if(node.attribute("name")=="calibrationClosedInterval")
  11474. {
  11475. closedBox->setChecked(node.attribute("value")=="true");
  11476. }
  11477. else if(node.attribute("name")=="calibrationSensitivity")
  11478. {
  11479. sensitivityEdit->setText(node.attribute("value"));
  11480. }
  11481. else if(node.attribute("name")=="hidden")
  11482. {
  11483. hideSeries->setChecked(node.attribute("value")=="true");
  11484. }
  11485. }
  11486. updateColumnName(columnEdit->text());
  11487. updateUnits(unitSelector->currentText());
  11488. updateSmoothingEnabled(smoothingBox->isChecked());
  11489. updateMeasuredLower(measuredLowerEdit->text());
  11490. updateMeasuredUpper(measuredUpperEdit->text());
  11491. updateMappedLower(mappedLowerEdit->text());
  11492. updateMappedUpper(mappedUpperEdit->text());
  11493. updateClosedInterval(closedBox->isChecked());
  11494. updateSensitivity(sensitivityEdit->text());
  11495. updateHidden(hideSeries->isChecked());
  11496. connect(columnEdit,SIGNAL(textChanged(QString)),
  11497. this,SLOT(updateColumnName(QString)));
  11498. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11499. this,SLOT(updateUnits(QString)));
  11500. connect(smoothingBox,SIGNAL(toggled(bool)),
  11501. this,SLOT(updateSmoothingEnabled(bool)));
  11502. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11503. this,SLOT(updateMeasuredLower(QString)));
  11504. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11505. this,SLOT(updateMappedLower(QString)));
  11506. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11507. this,SLOT(updateMeasuredUpper(QString)));
  11508. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11509. this,SLOT(updateMappedUpper(QString)));
  11510. connect(closedBox,SIGNAL(toggled(bool)),
  11511. this,SLOT(updateClosedInterval(bool)));
  11512. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11513. this,SLOT(updateSensitivity(QString)));
  11514. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11515. setLayout(layout);
  11516. }
  11517. /*:945*//*946:*/
  11518. #line 1038 "./dataqsdk.w"
  11519. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11520. {
  11521. updateAttribute("type",unit);
  11522. }
  11523. /*:946*//*947:*/
  11524. #line 1047 "./dataqsdk.w"
  11525. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11526. {
  11527. updateAttribute("calibrationMeasuredLower",value);
  11528. calibrator->setMeasuredLower(value.toDouble());
  11529. }
  11530. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11531. {
  11532. updateAttribute("calibrationMeasuredUpper",value);
  11533. calibrator->setMeasuredUpper(value.toDouble());
  11534. }
  11535. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11536. {
  11537. updateAttribute("calibrationMappedLower",value);
  11538. calibrator->setMappedLower(value.toDouble());
  11539. }
  11540. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11541. {
  11542. updateAttribute("calibrationMappedUpper",value);
  11543. calibrator->setMappedUpper(value.toDouble());
  11544. }
  11545. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11546. {
  11547. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11548. calibrator->setClosedRange(closed);
  11549. }
  11550. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11551. {
  11552. updateAttribute("smoothing",enabled?"true":"false");
  11553. }
  11554. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11555. {
  11556. updateAttribute("calibrationSensitivity",value);
  11557. calibrator->setSensitivity(value.toDouble());
  11558. }
  11559. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11560. {
  11561. updateAttribute("hidden",hidden?"true":"false");
  11562. }
  11563. /*:947*//*950:*/
  11564. #line 1136 "./dataqsdk.w"
  11565. void DataqSdkChannelConfWidget::startCalibration()
  11566. {
  11567. startButton->setEnabled(false);
  11568. stopButton->setEnabled(true);
  11569. resetButton->setEnabled(true);
  11570. calibrationDevice= new DataqSdkDevice(deviceID);
  11571. Channel*channel;
  11572. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11573. {
  11574. channel= calibrationDevice->newChannel(Units::Unitless);
  11575. }
  11576. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11577. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11578. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11579. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11580. calibrationDevice->start();
  11581. }
  11582. void DataqSdkChannelConfWidget::stopCalibration()
  11583. {
  11584. startButton->setEnabled(true);
  11585. stopButton->setEnabled(false);
  11586. resetButton->setEnabled(false);
  11587. calibrationDevice->deleteLater();
  11588. /*952:*/
  11589. #line 1181 "./dataqsdk.w"
  11590. rmCount= 0;
  11591. cmCount= 0;
  11592. rmin= std::numeric_limits<double> ::max();
  11593. rmax= std::numeric_limits<double> ::min();
  11594. rmean= 0;
  11595. cmin= std::numeric_limits<double> ::max();
  11596. cmax= std::numeric_limits<double> ::min();
  11597. cmean= 0;
  11598. /*:952*/
  11599. #line 1161 "./dataqsdk.w"
  11600. }
  11601. /*:950*//*951:*/
  11602. #line 1172 "./dataqsdk.w"
  11603. void DataqSdkChannelConfWidget::resetCalibration()
  11604. {
  11605. /*952:*/
  11606. #line 1181 "./dataqsdk.w"
  11607. rmCount= 0;
  11608. cmCount= 0;
  11609. rmin= std::numeric_limits<double> ::max();
  11610. rmax= std::numeric_limits<double> ::min();
  11611. rmean= 0;
  11612. cmin= std::numeric_limits<double> ::max();
  11613. cmax= std::numeric_limits<double> ::min();
  11614. cmean= 0;
  11615. /*:952*/
  11616. #line 1175 "./dataqsdk.w"
  11617. }
  11618. /*:951*//*953:*/
  11619. #line 1195 "./dataqsdk.w"
  11620. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11621. {
  11622. double nv= measure.temperature();
  11623. currentMeasurement->setText(QString("%1").arg(nv));
  11624. rmin= qMin(nv,rmin);
  11625. minimumMeasurement->setText(QString("%1").arg(rmin));
  11626. rmax= qMax(nv,rmax);
  11627. maximumMeasurement->setText(QString("%1").arg(rmax));
  11628. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11629. rmCount++;
  11630. averageMeasurement->setText(QString("%1").arg(rmean));
  11631. }
  11632. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11633. {
  11634. double nv= measure.temperature();
  11635. currentMapped->setText(QString("%1").arg(nv));
  11636. cmin= qMin(nv,cmin);
  11637. minimumMapped->setText(QString("%1").arg(cmin));
  11638. cmax= qMax(nv,cmax);
  11639. maximumMapped->setText(QString("%1").arg(cmax));
  11640. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11641. cmCount++;
  11642. averageMapped->setText(QString("%1").arg(cmean));
  11643. }
  11644. /*:953*//*954:*/
  11645. #line 1224 "./dataqsdk.w"
  11646. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11647. {
  11648. updateAttribute("column",value);
  11649. }
  11650. /*:954*/
  11651. #line 608 "./typica.w"
  11652. /*978:*/
  11653. #line 393 "./scales.w"
  11654. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11655. const QModelIndex&index)
  11656. :BasicDeviceConfigurationWidget(model,index),
  11657. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11658. flow(new FlowSelector),stop(new StopSelector)
  11659. {
  11660. QFormLayout*layout= new QFormLayout;
  11661. layout->addRow(tr("Port:"),port);
  11662. connect(port,SIGNAL(currentIndexChanged(QString)),
  11663. this,SLOT(updatePort(QString)));
  11664. connect(port,SIGNAL(editTextChanged(QString)),
  11665. this,SLOT(updatePort(QString)));
  11666. layout->addRow(tr("Baud:"),baud);
  11667. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11668. this,SLOT(updateBaudRate(QString)));
  11669. layout->addRow(tr("Parity:"),parity);
  11670. connect(parity,SIGNAL(currentIndexChanged(int)),
  11671. this,SLOT(updateParity(int)));
  11672. layout->addRow(tr("Flow Control:"),flow);
  11673. connect(flow,SIGNAL(currentIndexChanged(int)),
  11674. this,SLOT(updateFlowControl(int)));
  11675. layout->addRow(tr("Stop Bits:"),stop);
  11676. connect(stop,SIGNAL(currentIndexChanged(int)),
  11677. this,SLOT(updateStopBits(int)));
  11678. /*744:*/
  11679. #line 15632 "./typica.w"
  11680. QDomElement referenceElement=
  11681. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11682. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11683. QDomElement node;
  11684. /*:744*/
  11685. #line 418 "./scales.w"
  11686. for(int i= 0;i<configData.size();i++)
  11687. {
  11688. node= configData.at(i).toElement();
  11689. if(node.attribute("name")=="port")
  11690. {
  11691. int j= port->findText(node.attribute("value"));
  11692. if(j>=0)
  11693. {
  11694. port->setCurrentIndex(j);
  11695. }
  11696. else
  11697. {
  11698. port->insertItem(0,node.attribute("value"));
  11699. port->setCurrentIndex(0);
  11700. }
  11701. }
  11702. else if(node.attribute("name")=="baudrate")
  11703. {
  11704. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11705. }
  11706. else if(node.attribute("name")=="parity")
  11707. {
  11708. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11709. }
  11710. else if(node.attribute("name")=="flowcontrol")
  11711. {
  11712. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  11713. }
  11714. else if(node.attribute("name")=="stopbits")
  11715. {
  11716. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  11717. }
  11718. }
  11719. updatePort(port->currentText());
  11720. updateBaudRate(baud->currentText());
  11721. updateParity(parity->currentIndex());
  11722. updateFlowControl(flow->currentIndex());
  11723. updateStopBits(stop->currentIndex());
  11724. setLayout(layout);
  11725. }
  11726. /*:978*//*979:*/
  11727. #line 462 "./scales.w"
  11728. void SerialScaleConfWidget::updatePort(const QString&newPort)
  11729. {
  11730. updateAttribute("port",newPort);
  11731. }
  11732. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  11733. {
  11734. updateAttribute("baudrate",rate);
  11735. }
  11736. void SerialScaleConfWidget::updateParity(int index)
  11737. {
  11738. updateAttribute("parity",parity->itemData(index).toString());
  11739. }
  11740. void SerialScaleConfWidget::updateFlowControl(int index)
  11741. {
  11742. updateAttribute("flowcontrol",flow->itemData(index).toString());
  11743. }
  11744. void SerialScaleConfWidget::updateStopBits(int index)
  11745. {
  11746. updateAttribute("stopbits",stop->itemData(index).toString());
  11747. }
  11748. /*:979*/
  11749. #line 609 "./typica.w"
  11750. /*991:*/
  11751. #line 195 "./valueannotation.w"
  11752. void ValueAnnotation::newMeasurement(Measurement measure)
  11753. {
  11754. for(int i= 0;i<values.size();i++)
  11755. {
  11756. if(measure.temperature()> values.at(i)-tolerance&&
  11757. measure.temperature()<values.at(i)+tolerance)
  11758. {
  11759. if(i!=lastIndex)
  11760. {
  11761. lastIndex= i;
  11762. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  11763. }
  11764. }
  11765. }
  11766. }
  11767. /*:991*//*992:*/
  11768. #line 216 "./valueannotation.w"
  11769. void ValueAnnotation::annotate()
  11770. {
  11771. if(lastIndex> -1)
  11772. {
  11773. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  11774. }
  11775. }
  11776. /*:992*//*993:*/
  11777. #line 228 "./valueannotation.w"
  11778. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  11779. {
  11780. values.append(value);
  11781. annotations.append(annotation);
  11782. }
  11783. /*:993*//*994:*/
  11784. #line 237 "./valueannotation.w"
  11785. void ValueAnnotation::setAnnotationColumn(int column)
  11786. {
  11787. annotationColumn= column;
  11788. }
  11789. void ValueAnnotation::setTemperatureColumn(int column)
  11790. {
  11791. measurementColumn= column;
  11792. }
  11793. void ValueAnnotation::setTolerance(double epsilon)
  11794. {
  11795. tolerance= epsilon;
  11796. }
  11797. /*:994*//*995:*/
  11798. #line 255 "./valueannotation.w"
  11799. ValueAnnotation::ValueAnnotation():QObject(),
  11800. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  11801. {
  11802. }
  11803. /*:995*/
  11804. #line 610 "./typica.w"
  11805. /*983:*/
  11806. #line 33 "./valueannotation.w"
  11807. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  11808. const QModelIndex&index)
  11809. :BasicDeviceConfigurationWidget(model,index),
  11810. tablemodel(new SaltModel(2))
  11811. {
  11812. QFormLayout*layout= new QFormLayout;
  11813. QLineEdit*source= new QLineEdit;
  11814. layout->addRow(tr("Source column name:"),source);
  11815. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  11816. noteOnStart->setChecked(true);
  11817. layout->addRow(noteOnStart);
  11818. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  11819. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  11820. QTableView*annotationTable= new QTableView;
  11821. annotationTable->setModel(tablemodel);
  11822. NumericDelegate*delegate= new NumericDelegate;
  11823. annotationTable->setItemDelegateForColumn(0,delegate);
  11824. layout->addRow(tr("Annotations for values:"),annotationTable);
  11825. /*744:*/
  11826. #line 15632 "./typica.w"
  11827. QDomElement referenceElement=
  11828. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11829. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11830. QDomElement node;
  11831. /*:744*/
  11832. #line 52 "./valueannotation.w"
  11833. for(int i= 0;i<configData.size();i++)
  11834. {
  11835. node= configData.at(i).toElement();
  11836. if(node.attribute("name")=="source")
  11837. {
  11838. source->setText(node.attribute("value"));
  11839. }
  11840. else if(node.attribute("name")=="emitOnStart")
  11841. {
  11842. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  11843. }
  11844. else if(node.attribute("name")=="measuredValues")
  11845. {
  11846. /*895:*/
  11847. #line 18699 "./typica.w"
  11848. QString data= node.attribute("value");
  11849. if(data.length()> 3)
  11850. {
  11851. data.chop(2);
  11852. data= data.remove(0,2);
  11853. }
  11854. QStringList itemList= data.split(",");
  11855. /*:895*/
  11856. #line 66 "./valueannotation.w"
  11857. int column= 0;
  11858. /*896:*/
  11859. #line 18711 "./typica.w"
  11860. for(int i= 0;i<itemList.size();i++)
  11861. {
  11862. tablemodel->setData(tablemodel->index(i,column),
  11863. QVariant(itemList.at(i).toDouble()),
  11864. Qt::DisplayRole);
  11865. }
  11866. /*:896*/
  11867. #line 68 "./valueannotation.w"
  11868. }
  11869. else if(node.attribute("name")=="annotations")
  11870. {
  11871. /*984:*/
  11872. #line 89 "./valueannotation.w"
  11873. QString data= node.attribute("value");
  11874. if(data.length()> 3)
  11875. {
  11876. data.chop(2);
  11877. data= data.remove(0,2);
  11878. }
  11879. QStringList itemList= data.split(",");
  11880. for(int i= 0;i<itemList.size();i++)
  11881. {
  11882. itemList[i]= itemList[i].simplified();
  11883. }
  11884. /*:984*/
  11885. #line 72 "./valueannotation.w"
  11886. int column= 1;
  11887. /*985:*/
  11888. #line 104 "./valueannotation.w"
  11889. for(int i= 0;i<itemList.size();i++)
  11890. {
  11891. tablemodel->setData(tablemodel->index(i,column),
  11892. QVariant(itemList.at(i)),
  11893. Qt::DisplayRole);
  11894. }
  11895. /*:985*/
  11896. #line 74 "./valueannotation.w"
  11897. }
  11898. }
  11899. updateSourceColumn(source->text());
  11900. updateStart(noteOnStart->isChecked());
  11901. updateAnnotations();
  11902. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11903. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  11904. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  11905. setLayout(layout);
  11906. }
  11907. /*:983*//*986:*/
  11908. #line 115 "./valueannotation.w"
  11909. void ValueAnnotationConfWidget::updateAnnotations()
  11910. {
  11911. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11912. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11913. }
  11914. /*:986*//*987:*/
  11915. #line 125 "./valueannotation.w"
  11916. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  11917. {
  11918. updateAttribute("source",source);
  11919. }
  11920. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  11921. {
  11922. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  11923. }
  11924. /*:987*/
  11925. #line 611 "./typica.w"
  11926. /*:4*//*818:*/
  11927. #line 60 "./advancedsettings.w"
  11928. /*816:*/
  11929. #line 26 "./advancedsettings.w"
  11930. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  11931. {
  11932. QSettings settings;
  11933. QFormLayout*layout= new QFormLayout;
  11934. QCheckBox*logDiagnostics= new QCheckBox;
  11935. logDiagnostics->setCheckState(
  11936. settings.value("settings/advanced/logging",false).toBool()?
  11937. Qt::Checked:Qt::Unchecked);
  11938. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  11939. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  11940. setLayout(layout);
  11941. }
  11942. /*:816*//*817:*/
  11943. #line 43 "./advancedsettings.w"
  11944. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  11945. {
  11946. QSettings settings;
  11947. settings.setValue("settings/advanced/logging",enabled);
  11948. if(enabled)
  11949. {
  11950. qInstallMsgHandler(messageFileOutput);
  11951. }
  11952. else
  11953. {
  11954. qInstallMsgHandler(0);
  11955. }
  11956. }
  11957. /*:817*/
  11958. #line 61 "./advancedsettings.w"
  11959. #line 17377 "./typica.w"
  11960. /*:818*//*865:*/
  11961. #line 639 "./unsupportedserial.w"
  11962. /*840:*/
  11963. #line 58 "./unsupportedserial.w"
  11964. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  11965. const QModelIndex&index)
  11966. :BasicDeviceConfigurationWidget(model,index),
  11967. deviceSettingsModel(new SaltModel(2)),
  11968. scriptEditor(new QTextEdit)
  11969. {
  11970. scriptEditor->setTabStopWidth(20);
  11971. QVBoxLayout*dummyLayout= new QVBoxLayout;
  11972. QTabWidget*central= new QTabWidget;
  11973. QWidget*deviceConfigurationWidget= new QWidget;
  11974. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  11975. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11976. deviceConfigurationLayout->addWidget(addChannelButton);
  11977. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11978. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  11979. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  11980. QTableView*deviceSettingsView= new QTableView;
  11981. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  11982. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  11983. deviceSettingsView->setModel(deviceSettingsModel);
  11984. deviceConfigurationLayout->addWidget(deviceSettingsView);
  11985. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  11986. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  11987. central->addTab(scriptEditor,tr("Script"));
  11988. dummyLayout->addWidget(central);
  11989. /*744:*/
  11990. #line 15632 "./typica.w"
  11991. QDomElement referenceElement=
  11992. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11993. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11994. QDomElement node;
  11995. /*:744*/
  11996. #line 86 "./unsupportedserial.w"
  11997. for(int i= 0;i<configData.size();i++)
  11998. {
  11999. node= configData.at(i).toElement();
  12000. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12001. {
  12002. int column= 0;
  12003. if(node.attribute("name")=="values")
  12004. {
  12005. column= 1;
  12006. }
  12007. QString data= node.attribute("value");
  12008. if(data.length()> 3)
  12009. {
  12010. data.chop(2);
  12011. data= data.remove(0,2);
  12012. }
  12013. QStringList keyList= data.split(", ");
  12014. for(int j= 0;j<keyList.size();j++)
  12015. {
  12016. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12017. QVariant(keyList.at(j)),
  12018. Qt::EditRole);
  12019. }
  12020. }
  12021. else if(node.attribute("name")=="script")
  12022. {
  12023. scriptEditor->setPlainText(node.attribute("value"));
  12024. }
  12025. }
  12026. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12027. this,SLOT(updateConfiguration()));
  12028. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  12029. setLayout(dummyLayout);
  12030. }
  12031. /*:840*//*841:*/
  12032. #line 131 "./unsupportedserial.w"
  12033. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  12034. {
  12035. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12036. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12037. }
  12038. /*:841*//*842:*/
  12039. #line 144 "./unsupportedserial.w"
  12040. void UnsupportedSerialDeviceConfWidget::saveScript()
  12041. {
  12042. updateAttribute("script",scriptEditor->toPlainText());
  12043. }
  12044. /*:842*//*843:*/
  12045. #line 155 "./unsupportedserial.w"
  12046. void UnsupportedSerialDeviceConfWidget::addChannel()
  12047. {
  12048. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  12049. }
  12050. /*:843*//*845:*/
  12051. #line 183 "./unsupportedserial.w"
  12052. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  12053. const QModelIndex&index)
  12054. :BasicDeviceConfigurationWidget(model,index),
  12055. channelSettingsModel(new SaltModel(2))
  12056. {
  12057. QFormLayout*layout= new QFormLayout;
  12058. QLineEdit*columnName= new QLineEdit;
  12059. layout->addRow(tr("Column Name:"),columnName);
  12060. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12061. layout->addRow(hideSeries);
  12062. QTableView*channelSettings= new QTableView;
  12063. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  12064. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  12065. channelSettings->setModel(channelSettingsModel);
  12066. layout->addRow(channelSettings);
  12067. setLayout(layout);
  12068. /*744:*/
  12069. #line 15632 "./typica.w"
  12070. QDomElement referenceElement=
  12071. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12072. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12073. QDomElement node;
  12074. /*:744*/
  12075. #line 200 "./unsupportedserial.w"
  12076. for(int i= 0;i<configData.size();i++)
  12077. {
  12078. node= configData.at(i).toElement();
  12079. if(node.attribute("name")=="columnname")
  12080. {
  12081. columnName->setText(node.attribute("value"));
  12082. }
  12083. else if(node.attribute("name")=="hidden")
  12084. {
  12085. hideSeries->setChecked(node.attribute("value")=="true");
  12086. }
  12087. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12088. {
  12089. int column= 0;
  12090. if(node.attribute("name")=="values")
  12091. {
  12092. column= 1;
  12093. }
  12094. QString data= node.attribute("value");
  12095. if(data.length()> 3)
  12096. {
  12097. data.chop(2);
  12098. data= data.remove(0,2);
  12099. }
  12100. QStringList keyList= data.split(", ");
  12101. for(int j= 0;j<keyList.size();j++)
  12102. {
  12103. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  12104. QVariant(keyList.at(j)),
  12105. Qt::EditRole);
  12106. }
  12107. }
  12108. }
  12109. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12110. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12111. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12112. this,SLOT(updateConfiguration()));
  12113. }
  12114. /*:845*//*846:*/
  12115. #line 244 "./unsupportedserial.w"
  12116. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  12117. {
  12118. updateAttribute("columnname",value);
  12119. }
  12120. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  12121. {
  12122. updateAttribute("hidden",hidden?"true":"false");
  12123. }
  12124. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  12125. {
  12126. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12127. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12128. }
  12129. /*:846*/
  12130. #line 640 "./unsupportedserial.w"
  12131. /*853:*/
  12132. #line 371 "./unsupportedserial.w"
  12133. void JavaScriptDevice::start()
  12134. {
  12135. QScriptValue object= scriptengine->newQObject(this);
  12136. /*854:*/
  12137. #line 390 "./unsupportedserial.w"
  12138. QScriptValue settingsObject= scriptengine->newObject();
  12139. QVariantMap::const_iterator i= deviceSettings.constBegin();
  12140. while(i!=deviceSettings.constEnd())
  12141. {
  12142. settingsObject.setProperty(i.key(),i.value().toString());
  12143. i++;
  12144. }
  12145. object.setProperty("settings",settingsObject);
  12146. /*:854*/
  12147. #line 375 "./unsupportedserial.w"
  12148. /*855:*/
  12149. #line 405 "./unsupportedserial.w"
  12150. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  12151. for(int i= 0;i<channelCount();i++)
  12152. {
  12153. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  12154. QScriptValue channelSettingsObject= scriptengine->newObject();
  12155. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  12156. while(j!=channelSettings.at(i).constEnd())
  12157. {
  12158. channelSettingsObject.setProperty(j.key(),j.value().toString());
  12159. j++;
  12160. }
  12161. channelObject.setProperty("settings",channelSettingsObject);
  12162. channelsArray.setProperty(i,channelObject);
  12163. }
  12164. object.setProperty("channels",channelsArray);
  12165. /*:855*/
  12166. #line 376 "./unsupportedserial.w"
  12167. QScriptContext*context= scriptengine->currentContext();
  12168. QScriptValue oldThis= context->thisObject();
  12169. context->setThisObject(object);
  12170. QScriptValue result= scriptengine->evaluate(deviceScript);
  12171. QScriptEngine*engine= scriptengine;
  12172. /*170:*/
  12173. #line 3943 "./typica.w"
  12174. if(engine->hasUncaughtException())
  12175. {
  12176. int line= engine->uncaughtExceptionLineNumber();
  12177. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  12178. result.toString();
  12179. QString trace;
  12180. foreach(trace,engine->uncaughtExceptionBacktrace())
  12181. {
  12182. qDebug()<<trace;
  12183. }
  12184. }
  12185. /*:170*/
  12186. #line 382 "./unsupportedserial.w"
  12187. context->setThisObject(oldThis);
  12188. }
  12189. /*:853*//*858:*/
  12190. #line 446 "./unsupportedserial.w"
  12191. void JavaScriptDevice::stop()
  12192. {
  12193. emit deviceStopRequested();
  12194. }
  12195. /*:858*//*859:*/
  12196. #line 459 "./unsupportedserial.w"
  12197. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  12198. QScriptEngine*engine):
  12199. QObject(NULL),scriptengine(engine)
  12200. {
  12201. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12202. QDomElement deviceReferenceElement=
  12203. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12204. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12205. QDomElement node;
  12206. QStringList deviceKeys;
  12207. QStringList deviceValues;
  12208. for(int i= 0;i<deviceConfigData.size();i++)
  12209. {
  12210. node= deviceConfigData.at(i).toElement();
  12211. if(node.attribute("name")=="keys")
  12212. {
  12213. QString data= node.attribute("value");
  12214. if(data.length()> 3)
  12215. {
  12216. data.chop(2);
  12217. data= data.remove(0,2);
  12218. }
  12219. deviceKeys= data.split(", ");
  12220. }
  12221. else if(node.attribute("name")=="values")
  12222. {
  12223. QString data= node.attribute("value");
  12224. if(data.length()> 3)
  12225. {
  12226. data.chop(2);
  12227. data= data.remove(0,2);
  12228. }
  12229. deviceValues= data.split(", ");
  12230. }
  12231. else if(node.attribute("name")=="script")
  12232. {
  12233. deviceScript= node.attribute("value");
  12234. }
  12235. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  12236. }
  12237. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  12238. {
  12239. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  12240. }
  12241. if(model->hasChildren(index))
  12242. {
  12243. for(int i= 0;i<model->rowCount(index);i++)
  12244. {
  12245. QModelIndex channelIndex= model->index(i,0,index);
  12246. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12247. channelList.append(new Channel);
  12248. QDomElement channelReferenceElement=
  12249. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12250. QDomNodeList channelConfigData=
  12251. channelReferenceElement.elementsByTagName("attribute");
  12252. QStringList channelKeys;
  12253. QStringList channelValues;
  12254. for(int j= 0;j<channelConfigData.size();j++)
  12255. {
  12256. node= channelConfigData.at(j).toElement();
  12257. if(node.attribute("name")=="keys")
  12258. {
  12259. QString data= node.attribute("value");
  12260. if(data.length()> 3)
  12261. {
  12262. data.chop(2);
  12263. data= data.remove(0,2);
  12264. }
  12265. channelKeys= data.split(", ");
  12266. }
  12267. else if(node.attribute("name")=="values")
  12268. {
  12269. QString data= node.attribute("value");
  12270. if(data.length()> 3)
  12271. {
  12272. data.chop(2);
  12273. data= data.remove(0,2);
  12274. }
  12275. channelValues= data.split(", ");
  12276. }
  12277. else if(node.attribute("name")=="hidden")
  12278. {
  12279. hiddenState.append(node.attribute("value")=="true");
  12280. }
  12281. else if(node.attribute("name")=="columnname")
  12282. {
  12283. columnNames.append(node.attribute("value"));
  12284. }
  12285. }
  12286. QVariantMap cs;
  12287. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  12288. {
  12289. cs.insert(channelKeys[j],channelValues[j]);
  12290. }
  12291. channelSettings.append(cs);
  12292. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12293. channelUnits.append(Units::Fahrenheit);
  12294. }
  12295. }
  12296. }
  12297. /*:859*//*860:*/
  12298. #line 564 "./unsupportedserial.w"
  12299. int JavaScriptDevice::channelCount()
  12300. {
  12301. return channelList.length();
  12302. }
  12303. Channel*JavaScriptDevice::getChannel(int channel)
  12304. {
  12305. return channelList.at(channel);
  12306. }
  12307. bool JavaScriptDevice::isChannelHidden(int channel)
  12308. {
  12309. return hiddenState.at(channel);
  12310. }
  12311. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  12312. {
  12313. return channelUnits.at(channel);
  12314. }
  12315. QString JavaScriptDevice::channelColumnName(int channel)
  12316. {
  12317. if(channel>=0&&channel<columnNames.length())
  12318. {
  12319. return columnNames.at(channel);
  12320. }
  12321. return QString();
  12322. }
  12323. QString JavaScriptDevice::channelIndicatorText(int channel)
  12324. {
  12325. return indicatorTexts.at(channel);
  12326. }
  12327. /*:860*//*861:*/
  12328. #line 601 "./unsupportedserial.w"
  12329. void JavaScriptDevice::setTemperatureColumn(int tcol)
  12330. {
  12331. annotationTemperatureColumn= tcol;
  12332. }
  12333. void JavaScriptDevice::setAnnotationColumn(int ncol)
  12334. {
  12335. annotationNoteColumn= ncol;
  12336. }
  12337. /*:861*/
  12338. #line 641 "./unsupportedserial.w"
  12339. /*:865*//*888:*/
  12340. #line 437 "./phidgets.w"
  12341. /*872:*/
  12342. #line 31 "./phidgets.w"
  12343. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  12344. const QModelIndex&index)
  12345. :BasicDeviceConfigurationWidget(model,index)
  12346. {
  12347. QFormLayout*layout= new QFormLayout;
  12348. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12349. QSpinBox*sampleRate= new QSpinBox;
  12350. sampleRate->setMinimum(40);
  12351. sampleRate->setMaximum(600);
  12352. sampleRate->setSingleStep(40);
  12353. sampleRate->setValue(360);
  12354. /*744:*/
  12355. #line 15632 "./typica.w"
  12356. QDomElement referenceElement=
  12357. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12358. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12359. QDomElement node;
  12360. /*:744*/
  12361. #line 44 "./phidgets.w"
  12362. for(int i= 0;i<configData.size();i++)
  12363. {
  12364. node= configData.at(i).toElement();
  12365. if(node.attribute("name")=="sampleRate")
  12366. {
  12367. sampleRate->setValue(node.attribute("value").toInt());
  12368. }
  12369. }
  12370. updateRate(sampleRate->value());
  12371. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  12372. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12373. layout->addRow(addChannelButton);
  12374. layout->addRow(tr("Sample rate:"),sampleRate);
  12375. setLayout(layout);
  12376. }
  12377. /*:872*//*873:*/
  12378. #line 66 "./phidgets.w"
  12379. void PhidgetsTemperatureSensorConfWidget::addChannel()
  12380. {
  12381. insertChildNode(tr("Channel"),"phidgets1048channel");
  12382. }
  12383. /*:873*//*874:*/
  12384. #line 74 "./phidgets.w"
  12385. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  12386. {
  12387. updateAttribute("sampleRate",QString("%1").arg(ms));
  12388. }
  12389. /*:874*//*876:*/
  12390. #line 103 "./phidgets.w"
  12391. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  12392. DeviceTreeModel*model,const QModelIndex&index)
  12393. :BasicDeviceConfigurationWidget(model,index),
  12394. tcType(new QComboBox)
  12395. {
  12396. QFormLayout*layout= new QFormLayout;
  12397. QLineEdit*columnName= new QLineEdit;
  12398. layout->addRow(tr("Column Name:"),columnName);
  12399. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12400. layout->addRow(hideSeries);
  12401. layout->addRow(tr("Thermocouple Type:"),tcType);
  12402. tcType->addItem("Type K","1");
  12403. tcType->addItem("Type J","2");
  12404. tcType->addItem("Type E","3");
  12405. tcType->addItem("Type T","4");
  12406. QSpinBox*channel= new QSpinBox;
  12407. layout->addRow(tr("Channel:"),channel);
  12408. channel->setMinimum(0);
  12409. channel->setMaximum(3);
  12410. setLayout(layout);
  12411. /*744:*/
  12412. #line 15632 "./typica.w"
  12413. QDomElement referenceElement=
  12414. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12415. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12416. QDomElement node;
  12417. /*:744*/
  12418. #line 124 "./phidgets.w"
  12419. for(int i= 0;i<configData.size();i++)
  12420. {
  12421. node= configData.at(i).toElement();
  12422. if(node.attribute("name")=="columnname")
  12423. {
  12424. columnName->setText(node.attribute("value"));
  12425. }
  12426. else if(node.attribute("name")=="hidden")
  12427. {
  12428. hideSeries->setChecked(node.attribute("value")=="true");
  12429. }
  12430. else if(node.attribute("name")=="tctype")
  12431. {
  12432. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  12433. }
  12434. else if(node.attribute("name")=="channel")
  12435. {
  12436. channel->setValue(node.attribute("value").toInt());
  12437. }
  12438. }
  12439. updateColumnName(columnName->text());
  12440. updateHidden(hideSeries->isChecked());
  12441. updateTC(tcType->currentIndex());
  12442. updateChannel(channel->value());
  12443. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12444. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12445. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  12446. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  12447. }
  12448. /*:876*//*877:*/
  12449. #line 157 "./phidgets.w"
  12450. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  12451. {
  12452. updateAttribute("columnname",value);
  12453. }
  12454. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  12455. {
  12456. updateAttribute("hidden",hidden?"true":"false");
  12457. }
  12458. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  12459. {
  12460. updateAttribute("tctype",tcType->itemData(index).toString());
  12461. }
  12462. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  12463. {
  12464. updateAttribute("channel",QString("%1").arg(channel));
  12465. }
  12466. /*:877*//*881:*/
  12467. #line 246 "./phidgets.w"
  12468. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  12469. :QObject(NULL),driver("phidget21"),device(NULL)
  12470. {
  12471. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12472. QDomElement deviceReferenceElement=
  12473. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12474. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12475. QDomElement node;
  12476. for(int i= 0;i<deviceConfigData.size();i++)
  12477. {
  12478. node= deviceConfigData.at(i).toElement();
  12479. if(node.attribute("name")=="sampleRate")
  12480. {
  12481. sampleTimer.setInterval(node.attribute("value").toInt());
  12482. }
  12483. }
  12484. if(model->hasChildren(index))
  12485. {
  12486. for(int i= 0;i<model->rowCount(index);i++)
  12487. {
  12488. QModelIndex channelIndex= model->index(i,0,index);
  12489. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12490. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12491. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  12492. for(int j= 0;j<channelConfigData.size();j++)
  12493. {
  12494. node= channelConfigData.at(j).toElement();
  12495. if(node.attribute("name")=="channel")
  12496. {
  12497. int channelID= node.attribute("value").toInt();
  12498. channelIndices.append(channelID);
  12499. Channel*channel= new Channel;
  12500. channelList.append(channel);
  12501. channelMap.insert(channelID,channel);
  12502. }
  12503. else if(node.attribute("name")=="hidden")
  12504. {
  12505. hiddenState.append(node.attribute("value")=="true");
  12506. }
  12507. else if(node.attribute("name")=="columnname")
  12508. {
  12509. columnNames.append(node.attribute("value"));
  12510. }
  12511. else if(node.attribute("name")=="tctype")
  12512. {
  12513. tctypes.append(node.attribute("value").toInt());
  12514. }
  12515. }
  12516. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12517. }
  12518. }
  12519. }
  12520. /*:881*//*882:*/
  12521. #line 306 "./phidgets.w"
  12522. int PhidgetsTemperatureSensor::channelCount()
  12523. {
  12524. return channelList.length();
  12525. }
  12526. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  12527. {
  12528. return channelList.at(channel);
  12529. }
  12530. /*:882*//*883:*/
  12531. #line 319 "./phidgets.w"
  12532. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  12533. {
  12534. return hiddenState.at(channel);
  12535. }
  12536. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  12537. {
  12538. if(channel>=0&&channel<columnNames.length())
  12539. {
  12540. return columnNames.at(channel);
  12541. }
  12542. return QString();
  12543. }
  12544. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  12545. {
  12546. if(channel>=0&&channel<indicatorTexts.length())
  12547. {
  12548. return indicatorTexts.at(channel);
  12549. }
  12550. return QString();
  12551. }
  12552. /*:883*//*885:*/
  12553. #line 364 "./phidgets.w"
  12554. void PhidgetsTemperatureSensor::start()
  12555. {
  12556. if(!driver.load())
  12557. {
  12558. driver.setFileName("Phidget21.framework/phidget21");
  12559. if(!driver.load())
  12560. {
  12561. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  12562. tr("Failed to find phidget21. Please install it."));
  12563. return;
  12564. }
  12565. }
  12566. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  12567. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  12568. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  12569. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  12570. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  12571. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  12572. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  12573. {
  12574. QMessageBox::critical(NULL,tr("Typica: Link error"),
  12575. tr("Failed to link a required symbol in phidget21."));
  12576. return;
  12577. }
  12578. createDevice(&device);
  12579. openDevice(device,-1);
  12580. int error;
  12581. if(error= waitForOpen(device,10000))
  12582. {
  12583. closeDevice(device);
  12584. deleteDevice(device);
  12585. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  12586. tr("CPhidget_waitForAttachment returns error %n",0,error));
  12587. return;
  12588. }
  12589. for(int i= 0;i<channelIndices.length();i++)
  12590. {
  12591. setTCType(device,channelIndices.at(i),tctypes.at(i));
  12592. }
  12593. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  12594. sampleTimer.start();
  12595. }
  12596. /*:885*//*886:*/
  12597. #line 411 "./phidgets.w"
  12598. void PhidgetsTemperatureSensor::getMeasurements()
  12599. {
  12600. double value= 0.0;
  12601. QTime time= QTime::currentTime();
  12602. foreach(int i,channelIndices)
  12603. {
  12604. getTemperature(device,i,&value);
  12605. Measurement measure(value*9.0/5.0+32.0,time);
  12606. channelMap[i]->input(measure);
  12607. }
  12608. }
  12609. /*:886*//*887:*/
  12610. #line 426 "./phidgets.w"
  12611. void PhidgetsTemperatureSensor::stop()
  12612. {
  12613. sampleTimer.stop();
  12614. closeDevice(device);
  12615. deleteDevice(device);
  12616. driver.unload();
  12617. }
  12618. /*:887*/
  12619. #line 438 "./phidgets.w"
  12620. /*:888*//*916:*/
  12621. #line 265 "./rate.w"
  12622. /*912:*/
  12623. #line 191 "./rate.w"
  12624. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  12625. :BasicDeviceConfigurationWidget(model,index)
  12626. {
  12627. QFormLayout*layout= new QFormLayout;
  12628. QLineEdit*column= new QLineEdit;
  12629. layout->addRow(tr("Primary series column name:"),column);
  12630. QSpinBox*cacheTime= new QSpinBox;
  12631. cacheTime->setMinimum(0);
  12632. cacheTime->setMaximum(300);
  12633. layout->addRow(tr("Cache time:"),cacheTime);
  12634. QSpinBox*scaleTime= new QSpinBox;
  12635. scaleTime->setMinimum(1);
  12636. scaleTime->setMaximum(300);
  12637. layout->addRow(tr("Scale time:"),scaleTime);
  12638. /*744:*/
  12639. #line 15632 "./typica.w"
  12640. QDomElement referenceElement=
  12641. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12642. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12643. QDomElement node;
  12644. /*:744*/
  12645. #line 206 "./rate.w"
  12646. for(int i= 0;i<configData.size();i++)
  12647. {
  12648. node= configData.at(i).toElement();
  12649. if(node.attribute("name")=="column")
  12650. {
  12651. column->setText(node.attribute("value"));
  12652. }
  12653. else if(node.attribute("name")=="cache")
  12654. {
  12655. cacheTime->setValue(node.attribute("value").toInt());
  12656. }
  12657. else if(node.attribute("name")=="scale")
  12658. {
  12659. scaleTime->setValue(node.attribute("value").toInt());
  12660. }
  12661. }
  12662. updateColumn(column->text());
  12663. updateCacheTime(cacheTime->text());
  12664. updateScaleTime(scaleTime->text());
  12665. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  12666. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  12667. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  12668. setLayout(layout);
  12669. }
  12670. /*:912*//*913:*/
  12671. #line 235 "./rate.w"
  12672. void RateOfChangeConfWidget::updateColumn(const QString&column)
  12673. {
  12674. updateAttribute("column",column);
  12675. }
  12676. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  12677. {
  12678. updateAttribute("cache",seconds);
  12679. }
  12680. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  12681. {
  12682. updateAttribute("scale",seconds);
  12683. }
  12684. /*:913*/
  12685. #line 266 "./rate.w"
  12686. #line 18834 "./typica.w"
  12687. #line 1 "./dataqsdk.w"
  12688. /*:916*/
  12689. #line 529 "./typica.w"
  12690. /*8:*/
  12691. #line 671 "./typica.w"
  12692. template<class TYPE> TYPE getself(QScriptContext*context)
  12693. {
  12694. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  12695. return self;
  12696. }
  12697. template<> QTime getself(QScriptContext*context)
  12698. {
  12699. QTime self= context->thisObject().toVariant().toTime();
  12700. return self;
  12701. }
  12702. template<> QByteArray getself(QScriptContext*context)
  12703. {
  12704. QByteArray self= context->thisObject().toVariant().toByteArray();
  12705. return self;
  12706. }
  12707. template<> SqlQueryConnection*getself(QScriptContext*context)
  12708. {
  12709. SqlQueryConnection*self=
  12710. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  12711. return self;
  12712. }
  12713. template<> QXmlQuery*getself(QScriptContext*context)
  12714. {
  12715. QXmlQuery*self=
  12716. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  12717. return self;
  12718. }
  12719. template<> QXmlStreamWriter*getself(QScriptContext*context)
  12720. {
  12721. QXmlStreamWriter*self=
  12722. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  12723. return self;
  12724. }
  12725. template<> QXmlStreamReader*getself(QScriptContext*context)
  12726. {
  12727. QXmlStreamReader*self=
  12728. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  12729. return self;
  12730. }
  12731. /*:8*//*9:*/
  12732. #line 722 "./typica.w"
  12733. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  12734. {
  12735. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  12736. return argument;
  12737. }
  12738. template<> QString argument(int arg,QScriptContext*context)
  12739. {
  12740. return context->argument(arg).toString();
  12741. }
  12742. template<> QVariant argument(int arg,QScriptContext*context)
  12743. {
  12744. return context->argument(arg).toVariant();
  12745. }
  12746. template<> int argument(int arg,QScriptContext*context)
  12747. {
  12748. return context->argument(arg).toInt32();
  12749. }
  12750. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  12751. {
  12752. return(SqlQueryConnection*)
  12753. qscriptvalue_cast<void*> (context->argument(arg));
  12754. }
  12755. template<> QModelIndex argument(int arg,QScriptContext*context)
  12756. {
  12757. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  12758. }
  12759. template<> double argument(int arg,QScriptContext*context)
  12760. {
  12761. return(double)(context->argument(arg).toNumber());
  12762. }
  12763. template<> Units::Unit argument(int arg,QScriptContext*context)
  12764. {
  12765. return(Units::Unit)(context->argument(arg).toInt32());
  12766. }
  12767. template<> QByteArray argument(int arg,QScriptContext*context)
  12768. {
  12769. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  12770. }
  12771. /*:9*//*13:*/
  12772. #line 814 "./typica.w"
  12773. void setQObjectProperties(QScriptValue,QScriptEngine*)
  12774. {
  12775. }
  12776. /*:13*//*15:*/
  12777. #line 828 "./typica.w"
  12778. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  12779. {
  12780. }
  12781. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  12782. {
  12783. }
  12784. /*:15*//*18:*/
  12785. #line 867 "./typica.w"
  12786. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  12787. {
  12788. QScriptValue object= engine->newQObject(new QWidget);
  12789. setQWidgetProperties(object,engine);
  12790. return object;
  12791. }
  12792. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  12793. {
  12794. setQObjectProperties(value,engine);
  12795. setQPaintDeviceProperties(value,engine);
  12796. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  12797. value.setProperty("activateWindow",
  12798. engine->newFunction(QWidget_activateWindow));
  12799. }
  12800. /*:18*//*19:*/
  12801. #line 889 "./typica.w"
  12802. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  12803. {
  12804. if(context->argumentCount()==1)
  12805. {
  12806. QWidget*self= getself<QWidget*> (context);
  12807. QLayout*layout= argument<QLayout*> (0,context);
  12808. if(layout)
  12809. {
  12810. self->setLayout(layout);
  12811. }
  12812. else
  12813. {
  12814. context->throwError("Incorrect argument type passed to "
  12815. "QWidget::setLayout(). This method requires "
  12816. "a QLayout.");
  12817. }
  12818. }
  12819. else
  12820. {
  12821. context->throwError("Incorrect number of arguments passed to "
  12822. "QWidget::setLayout(). This method takes one "
  12823. "QLayout as an argument.");
  12824. }
  12825. return QScriptValue();
  12826. }
  12827. QScriptValue QWidget_activateWindow(QScriptContext*context,
  12828. QScriptEngine*)
  12829. {
  12830. QWidget*self= getself<QWidget*> (context);
  12831. self->activateWindow();
  12832. return QScriptValue();
  12833. }
  12834. /*:19*//*21:*/
  12835. #line 971 "./typica.w"
  12836. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  12837. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  12838. {
  12839. }
  12840. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  12841. {
  12842. QSettings settings;
  12843. settings.beginGroup(key);
  12844. settings.setValue("pos",pos());
  12845. settings.setValue("size",size());
  12846. settings.endGroup();
  12847. }
  12848. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  12849. {
  12850. QSettings settings;
  12851. settings.beginGroup(key);
  12852. if(settings.contains("size"))
  12853. {
  12854. resize(settings.value("size").toSize());
  12855. }
  12856. if(settings.contains("pos"))
  12857. {
  12858. move(settings.value("pos").toPoint());
  12859. }
  12860. settings.endGroup();
  12861. }
  12862. void ScriptQMainWindow::displayStatus(const QString&message)
  12863. {
  12864. statusBar()->showMessage(message);
  12865. }
  12866. void ScriptQMainWindow::showEvent(QShowEvent*event)
  12867. {
  12868. if(!event->spontaneous())
  12869. {
  12870. /*26:*/
  12871. #line 1083 "./typica.w"
  12872. QSettings settings;
  12873. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  12874. toByteArray());
  12875. /*:26*/
  12876. #line 1011 "./typica.w"
  12877. event->accept();
  12878. }
  12879. else
  12880. {
  12881. event->ignore();
  12882. }
  12883. }
  12884. void ScriptQMainWindow::show()
  12885. {
  12886. QMainWindow::show();
  12887. }
  12888. /*:21*//*22:*/
  12889. #line 1032 "./typica.w"
  12890. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  12891. {
  12892. if(isWindowModified()){
  12893. /*23:*/
  12894. #line 1046 "./typica.w"
  12895. QMessageBox::StandardButton result;
  12896. result= QMessageBox::warning(this,"Typica",closePrompt(),
  12897. QMessageBox::Ok|QMessageBox::Cancel);
  12898. if(result==QMessageBox::Cancel)
  12899. {
  12900. event->ignore();
  12901. return;
  12902. }
  12903. /*:23*/
  12904. #line 1036 "./typica.w"
  12905. }
  12906. emit aboutToClose();
  12907. /*25:*/
  12908. #line 1077 "./typica.w"
  12909. QSettings settings;
  12910. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  12911. /*:25*/
  12912. #line 1039 "./typica.w"
  12913. event->accept();
  12914. }
  12915. /*:22*//*24:*/
  12916. #line 1058 "./typica.w"
  12917. QString ScriptQMainWindow::closePrompt()
  12918. {
  12919. return cprompt;
  12920. }
  12921. void ScriptQMainWindow::setClosePrompt(QString prompt)
  12922. {
  12923. cprompt= prompt;
  12924. }
  12925. /*:24*//*29:*/
  12926. #line 1111 "./typica.w"
  12927. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  12928. {
  12929. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  12930. setQMainWindowProperties(object,engine);
  12931. return object;
  12932. }
  12933. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  12934. {
  12935. setQWidgetProperties(value,engine);
  12936. value.setProperty("setCentralWidget",
  12937. engine->newFunction(QMainWindow_setCentralWidget));
  12938. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  12939. }
  12940. /*:29*//*30:*/
  12941. #line 1133 "./typica.w"
  12942. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  12943. QScriptEngine*)
  12944. {
  12945. if(context->argumentCount()==1)
  12946. {
  12947. QMainWindow*self= getself<QMainWindow*> (context);
  12948. QWidget*widget= argument<QWidget*> (0,context);
  12949. if(widget)
  12950. {
  12951. self->setCentralWidget(widget);
  12952. }
  12953. else
  12954. {
  12955. context->throwError("Incorrect argument type passed to "
  12956. "QMainWindow::setCentralWidget(). This "
  12957. "method requires a QWidget.");
  12958. }
  12959. }
  12960. else
  12961. {
  12962. context->throwError("Incorrect number of arguments passed to "
  12963. "QMainWindow::setCentralWidget(). This method "
  12964. "takes one QWidget as an argument.");
  12965. }
  12966. return QScriptValue();
  12967. }
  12968. /*:30*//*31:*/
  12969. #line 1167 "./typica.w"
  12970. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  12971. {
  12972. QScriptValue object;
  12973. if(context->argumentCount()==0)
  12974. {
  12975. QMainWindow*self= getself<QMainWindow*> (context);
  12976. QMenuBar*bar= self->menuBar();
  12977. object= engine->newQObject(bar);
  12978. setQMenuBarProperties(object,engine);
  12979. }
  12980. else
  12981. {
  12982. context->throwError("Incorrect number of arguments passed to "
  12983. "QMainWindow::menuBar(). This method takes no "
  12984. "arguments.");
  12985. }
  12986. return object;
  12987. }
  12988. /*:31*//*33:*/
  12989. #line 1197 "./typica.w"
  12990. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  12991. {
  12992. setQWidgetProperties(value,engine);
  12993. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  12994. }
  12995. /*:33*//*34:*/
  12996. #line 1212 "./typica.w"
  12997. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  12998. {
  12999. QScriptValue object;
  13000. if(context->argumentCount()==1)
  13001. {
  13002. QMenuBar*self= getself<QMenuBar*> (context);
  13003. QString title= argument<QString> (0,context);
  13004. object= engine->newQObject(self->addMenu(title));
  13005. setQMenuProperties(object,engine);
  13006. }
  13007. else
  13008. {
  13009. context->throwError("Incorrect number of arguments passed to "
  13010. "QMenuBar::addMenu(). This method takes one "
  13011. "string as an argument.");
  13012. }
  13013. return object;
  13014. }
  13015. /*:34*//*36:*/
  13016. #line 1242 "./typica.w"
  13017. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  13018. {
  13019. setQWidgetProperties(value,engine);
  13020. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  13021. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  13022. }
  13023. /*:36*//*37:*/
  13024. #line 1252 "./typica.w"
  13025. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  13026. {
  13027. if(context->argumentCount()==1)
  13028. {
  13029. QMenu*self= getself<QMenu*> (context);
  13030. QAction*action= argument<QAction*> (0,context);
  13031. if(action)
  13032. {
  13033. self->addAction(action);
  13034. }
  13035. else
  13036. {
  13037. context->throwError("Incorrect argument type passed to "
  13038. "QMenu::addAction(). This method requires a "
  13039. "QAction.");
  13040. }
  13041. }
  13042. else
  13043. {
  13044. context->throwError("Incorrect number of arguments passed to "
  13045. "QMenu::addAction(). This method takes one "
  13046. "QAction as an argument.");
  13047. }
  13048. return QScriptValue();
  13049. }
  13050. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  13051. {
  13052. if(context->argumentCount()==0)
  13053. {
  13054. QMenu*self= getself<QMenu*> (context);
  13055. self->addSeparator();
  13056. }
  13057. else
  13058. {
  13059. context->throwError("Incorrect number of arguments passed to "
  13060. "QMenu::addSeparator(). This method takes no "
  13061. "arguments.");
  13062. }
  13063. return QScriptValue();
  13064. }
  13065. /*:37*//*40:*/
  13066. #line 1314 "./typica.w"
  13067. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  13068. {
  13069. QScriptValue object= engine->newQObject(new QFrame);
  13070. setQFrameProperties(object,engine);
  13071. return object;
  13072. }
  13073. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  13074. {
  13075. setQWidgetProperties(value,engine);
  13076. }
  13077. /*:40*//*43:*/
  13078. #line 1348 "./typica.w"
  13079. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  13080. {
  13081. QString text;
  13082. if(context->argumentCount()==1)
  13083. {
  13084. text= argument<QString> (0,context);
  13085. }
  13086. QScriptValue object= engine->newQObject(new QLabel(text));
  13087. setQLabelProperties(object,engine);
  13088. return object;
  13089. }
  13090. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  13091. {
  13092. setQFrameProperties(value,engine);
  13093. }
  13094. /*:43*//*46:*/
  13095. #line 1385 "./typica.w"
  13096. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  13097. {
  13098. QScriptValue object= engine->newQObject(new QLineEdit());
  13099. setQLineEditProperties(object,engine);
  13100. return object;
  13101. }
  13102. /*:46*//*47:*/
  13103. #line 1396 "./typica.w"
  13104. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  13105. {
  13106. setQWidgetProperties(value,engine);
  13107. }
  13108. /*:47*//*50:*/
  13109. #line 1432 "./typica.w"
  13110. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  13111. {
  13112. QScriptValue object= engine->newQObject(new QSplitter);
  13113. setQSplitterProperties(object,engine);
  13114. return object;
  13115. }
  13116. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  13117. {
  13118. setQFrameProperties(value,engine);
  13119. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  13120. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  13121. value.setProperty("restoreState",
  13122. engine->newFunction(QSplitter_restoreState));
  13123. value.setProperty("count",engine->newFunction(QSplitter_count));
  13124. }
  13125. /*:50*//*51:*/
  13126. #line 1453 "./typica.w"
  13127. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  13128. {
  13129. if(context->argumentCount()==1)
  13130. {
  13131. QSplitter*self= getself<QSplitter*> (context);
  13132. QWidget*widget= argument<QWidget*> (0,context);
  13133. if(widget)
  13134. {
  13135. self->addWidget(widget);
  13136. }
  13137. else
  13138. {
  13139. context->throwError("Incorrect argument type passed to "
  13140. "QSplitter::addWidget(). This method "
  13141. "requires a QWidget.");
  13142. }
  13143. }
  13144. else
  13145. {
  13146. context->throwError("Incorrect number of arguments passed to "
  13147. "QSplitter::addWidget(). This method takes one "
  13148. "QWidget as an argument.");
  13149. }
  13150. return QScriptValue();
  13151. }
  13152. /*:51*//*52:*/
  13153. #line 1490 "./typica.w"
  13154. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  13155. {
  13156. QSplitter*self= getself<QSplitter*> (context);
  13157. return QScriptValue(self->count());
  13158. }
  13159. /*:52*//*53:*/
  13160. #line 1503 "./typica.w"
  13161. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  13162. {
  13163. if(context->argumentCount()==1)
  13164. {
  13165. QSplitter*self= getself<QSplitter*> (context);
  13166. QString key= argument<QString> (0,context);
  13167. QSettings settings;
  13168. settings.setValue(key,self->saveState());
  13169. }
  13170. else
  13171. {
  13172. context->throwError("Incorrect number of arguments passed to "
  13173. "QSplitter::saveState(). This method takes one "
  13174. "string as an argument.");
  13175. }
  13176. return QScriptValue();
  13177. }
  13178. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  13179. {
  13180. if(context->argumentCount()==1)
  13181. {
  13182. QSplitter*self= getself<QSplitter*> (context);
  13183. QString key= argument<QString> (0,context);
  13184. QSettings settings;
  13185. self->restoreState(settings.value(key).toByteArray());
  13186. }
  13187. else
  13188. {
  13189. context->throwError("Incorrect number of arguments passed to "
  13190. "QSplitter::restoreState(). This method takes "
  13191. "one string as an argument.");
  13192. }
  13193. return QScriptValue();
  13194. }
  13195. /*:53*//*55:*/
  13196. #line 1556 "./typica.w"
  13197. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13198. {
  13199. setQLayoutItemProperties(value,engine);
  13200. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  13201. }
  13202. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13203. {
  13204. if(context->argumentCount()==1)
  13205. {
  13206. QLayout*self= getself<QLayout*> (context);
  13207. QWidget*widget= argument<QWidget*> (0,context);
  13208. if(widget)
  13209. {
  13210. self->addWidget(widget);
  13211. }
  13212. else
  13213. {
  13214. context->throwError("Incorrect argument type passed to "
  13215. "QLayout::addWidget(). This method requires "
  13216. "a QWidget.");
  13217. }
  13218. }
  13219. else
  13220. {
  13221. context->throwError("Incorrect number of arguments passed to "
  13222. "QLayout::addWidget(). This method takes one "
  13223. "QWidget as an argument.");
  13224. }
  13225. return QScriptValue();
  13226. }
  13227. /*:55*//*58:*/
  13228. #line 1623 "./typica.w"
  13229. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  13230. {
  13231. QScriptValue object=
  13232. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  13233. setQBoxLayoutProperties(object,engine);
  13234. return object;
  13235. }
  13236. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13237. {
  13238. setQLayoutProperties(value,engine);
  13239. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  13240. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  13241. }
  13242. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  13243. {
  13244. if(context->argumentCount()> 0&&context->argumentCount()<3)
  13245. {
  13246. QBoxLayout*self= getself<QBoxLayout*> (context);
  13247. QLayout*layout= argument<QLayout*> (0,context);
  13248. int stretch= 0;
  13249. if(context->argumentCount()==2)
  13250. {
  13251. stretch= argument<int> (1,context);
  13252. }
  13253. if(layout)
  13254. {
  13255. self->addLayout(layout,stretch);
  13256. }
  13257. else
  13258. {
  13259. context->throwError("Incorrect argument type passed to "
  13260. "QLayout::addLayout(). This method requires "
  13261. "a QLayout.");
  13262. }
  13263. }
  13264. else
  13265. {
  13266. context->throwError("Incorrect number of arguments passed to "
  13267. "QLayout::addLayout(). This method takes one "
  13268. "QLayout as an argument and optionally one integer.");
  13269. }
  13270. return QScriptValue();
  13271. }
  13272. /*:58*//*59:*/
  13273. #line 1674 "./typica.w"
  13274. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13275. {
  13276. if(context->argumentCount()> 0&&context->argumentCount()<4)
  13277. {
  13278. QBoxLayout*self= getself<QBoxLayout*> (context);
  13279. QWidget*widget= argument<QWidget*> (0,context);
  13280. int stretch= 0;
  13281. Qt::Alignment alignment= 0;
  13282. if(context->argumentCount()> 1)
  13283. {
  13284. stretch= argument<int> (1,context);
  13285. }
  13286. if(context->argumentCount()> 2)
  13287. {
  13288. alignment= (Qt::Alignment)(argument<int> (2,context));
  13289. }
  13290. if(widget)
  13291. {
  13292. self->addWidget(widget,stretch,alignment);
  13293. }
  13294. else
  13295. {
  13296. context->throwError("Incorrect argument type passed to "
  13297. "QBoxLayout::addWidget(). This method requires "
  13298. "a QWidget.");
  13299. }
  13300. }
  13301. else
  13302. {
  13303. context->throwError("Incorrect number of arguments passed to "
  13304. "QBoxLayout::addWidget(). This method takes one "
  13305. "QWidget and optionally up to two integers as "
  13306. "arguments.");
  13307. }
  13308. return QScriptValue();
  13309. }
  13310. /*:59*//*62:*/
  13311. #line 1738 "./typica.w"
  13312. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  13313. {
  13314. QScriptValue object= engine->newQObject(new QAction(NULL));
  13315. setQActionProperties(object,engine);
  13316. return object;
  13317. }
  13318. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  13319. {
  13320. setQObjectProperties(value,engine);
  13321. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  13322. }
  13323. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  13324. {
  13325. if(context->argumentCount()==1)
  13326. {
  13327. QAction*self= getself<QAction*> (context);
  13328. self->setShortcut(argument<QString> (0,context));
  13329. }
  13330. else
  13331. {
  13332. context->throwError("Incorrect number of arguments passed to "
  13333. "QAction::setShortcut(). This method takes one "
  13334. "string as an argument.");
  13335. }
  13336. return QScriptValue();
  13337. }
  13338. /*:62*//*65:*/
  13339. #line 1796 "./typica.w"
  13340. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  13341. QScriptEngine*engine)
  13342. {
  13343. QScriptValue retval;
  13344. if(context->argumentCount()==3)
  13345. {
  13346. QWidget*widget= argument<QWidget*> (0,context);
  13347. if(widget)
  13348. {
  13349. QString caption= argument<QString> (1,context);
  13350. QString dir= argument<QString> (2,context);
  13351. retval= QScriptValue(engine,
  13352. QFileDialog::getOpenFileName(widget,caption,
  13353. dir,"",0,0));
  13354. setQFileDialogProperties(retval,engine);
  13355. }
  13356. else
  13357. {
  13358. context->throwError("Incorrect argument type passed to "
  13359. "QFileDialog::getOpenFileName(). The first "
  13360. "argument to this method must be a QWidget.");
  13361. }
  13362. }
  13363. else
  13364. {
  13365. context->throwError("Incorrect number of arguments passed to "
  13366. "QFileDialog::getOpenFileName(). This method "
  13367. "takes one QWidget followed by two strings for a "
  13368. "total of three arguments.");
  13369. }
  13370. return retval;
  13371. }
  13372. /*:65*//*66:*/
  13373. #line 1832 "./typica.w"
  13374. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  13375. QScriptEngine*engine)
  13376. {
  13377. QScriptValue retval;
  13378. if(context->argumentCount()==3)
  13379. {
  13380. QWidget*widget= argument<QWidget*> (0,context);
  13381. if(widget)
  13382. {
  13383. QString caption= argument<QString> (1,context);
  13384. QString dir= argument<QString> (2,context);
  13385. retval= QScriptValue(engine,
  13386. QFileDialog::getSaveFileName(widget,caption,
  13387. dir,"",0,0));
  13388. setQFileDialogProperties(retval,engine);
  13389. }
  13390. else
  13391. {
  13392. context->throwError("Incorrect argument type passed to "
  13393. "QFileDialog::getSaveFileName(). The first "
  13394. "argument to this method must be a QWidget.");
  13395. }
  13396. }
  13397. else
  13398. {
  13399. context->throwError("Incorrect number of arguments passed to "
  13400. "QFileDialog::getSaveFileName(). This method "
  13401. "takes one QWidget followed by two strings for a "
  13402. "total of three arguments.");
  13403. }
  13404. return retval;
  13405. }
  13406. /*:66*//*67:*/
  13407. #line 1869 "./typica.w"
  13408. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  13409. {
  13410. setQDialogProperties(value,engine);
  13411. }
  13412. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  13413. {
  13414. setQWidgetProperties(value,engine);
  13415. }
  13416. /*:67*//*70:*/
  13417. #line 1907 "./typica.w"
  13418. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  13419. {
  13420. QScriptValue object=
  13421. engine->newQObject(new QFile(argument<QString> (0,context)));
  13422. setQFileProperties(object,engine);
  13423. return object;
  13424. }
  13425. /*:70*//*71:*/
  13426. #line 1918 "./typica.w"
  13427. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  13428. {
  13429. setQIODeviceProperties(value,engine);
  13430. value.setProperty("remove",engine->newFunction(QFile_remove));
  13431. }
  13432. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  13433. {
  13434. QFile*self= getself<QFile*> (context);
  13435. bool retval= self->remove();
  13436. return QScriptValue(engine,retval);
  13437. }
  13438. /*:71*//*72:*/
  13439. #line 1940 "./typica.w"
  13440. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  13441. {
  13442. setQObjectProperties(value,engine);
  13443. value.setProperty("open",engine->newFunction(QIODevice_open));
  13444. value.setProperty("close",engine->newFunction(QIODevice_close));
  13445. value.setProperty("readToString",
  13446. engine->newFunction(QIODevice_readToString));
  13447. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  13448. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  13449. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  13450. }
  13451. /*:72*//*73:*/
  13452. #line 1958 "./typica.w"
  13453. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  13454. {
  13455. QIODevice*self= getself<QIODevice*> (context);
  13456. bool retval= false;
  13457. if(context->argumentCount()==1)
  13458. {
  13459. switch(argument<int> (0,context))
  13460. {
  13461. case 1:
  13462. retval= self->open(QIODevice::ReadOnly);
  13463. break;
  13464. case 2:
  13465. retval= self->open(QIODevice::WriteOnly);
  13466. break;
  13467. case 3:
  13468. retval= self->open(QIODevice::ReadWrite);
  13469. break;
  13470. default:
  13471. break;
  13472. }
  13473. }
  13474. else
  13475. {
  13476. retval= self->open(QIODevice::ReadWrite);
  13477. }
  13478. return QScriptValue(retval);
  13479. }
  13480. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  13481. {
  13482. QIODevice*self= getself<QIODevice*> (context);
  13483. self->close();
  13484. return QScriptValue();
  13485. }
  13486. /*:73*//*74:*/
  13487. #line 1998 "./typica.w"
  13488. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  13489. {
  13490. QIODevice*self= getself<QIODevice*> (context);
  13491. self->reset();
  13492. return QScriptValue(QString(self->readAll()));
  13493. }
  13494. /*:74*//*75:*/
  13495. #line 2014 "./typica.w"
  13496. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  13497. {
  13498. QIODevice*self= getself<QIODevice*> (context);
  13499. if(context->argumentCount()==1)
  13500. {
  13501. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  13502. }
  13503. context->throwError("Incorrect number of arguments passed to "
  13504. "QIODevice::putChar()");
  13505. return QScriptValue();
  13506. }
  13507. /*:75*//*76:*/
  13508. #line 2032 "./typica.w"
  13509. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  13510. {
  13511. QIODevice*self= getself<QIODevice*> (context);
  13512. if(context->argumentCount()==1)
  13513. {
  13514. self->write(argument<QString> (0,context).toUtf8());
  13515. }
  13516. else
  13517. {
  13518. context->throwError("Incorrect number of arguments passed to "
  13519. "QIODevice::writeString()");
  13520. }
  13521. return QScriptValue();
  13522. }
  13523. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  13524. {
  13525. QIODevice*self= getself<QIODevice*> (context);
  13526. if(context->argumentCount()==1)
  13527. {
  13528. self->write(argument<QByteArray> (0,context));
  13529. }
  13530. else
  13531. {
  13532. context->throwError("Incorrect number of arguments passed to "
  13533. "QIODevice::writeBytes()");
  13534. }
  13535. return QScriptValue();
  13536. }
  13537. /*:76*//*79:*/
  13538. #line 2089 "./typica.w"
  13539. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  13540. {
  13541. QScriptValue object= engine->newQObject(new QProcess);
  13542. setQProcessProperties(object,engine);
  13543. return object;
  13544. }
  13545. /*:79*//*80:*/
  13546. #line 2100 "./typica.w"
  13547. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  13548. {
  13549. setQIODeviceProperties(value,engine);
  13550. value.setProperty("execute",engine->newFunction(QProcess_execute));
  13551. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  13552. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  13553. value.setProperty("start",engine->newFunction(QProcess_start));
  13554. }
  13555. /*:80*//*81:*/
  13556. #line 2114 "./typica.w"
  13557. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  13558. {
  13559. QProcess*self= getself<QProcess*> (context);
  13560. QString program= argument<QString> (0,context);
  13561. QStringList arguments= QStringList();
  13562. if(context->argumentCount()> 1){
  13563. arguments= argument<QVariant> (1,context).toStringList();
  13564. }
  13565. int retval= self->execute(program,arguments);
  13566. return QScriptValue(retval);
  13567. }
  13568. /*:81*//*82:*/
  13569. #line 2129 "./typica.w"
  13570. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  13571. {
  13572. QProcess*self= getself<QProcess*> (context);
  13573. QString program= argument<QString> (0,context);
  13574. QStringList arguments= QStringList();
  13575. if(context->argumentCount()> 1){
  13576. arguments= argument<QVariant> (1,context).toStringList();
  13577. }
  13578. QString workingDirectory= "";
  13579. if(context->argumentCount()> 2){
  13580. workingDirectory= argument<QString> (2,context);
  13581. }
  13582. bool retval;
  13583. switch(context->argumentCount())
  13584. {
  13585. case 1:
  13586. retval= self->startDetached(program);
  13587. break;
  13588. case 2:
  13589. retval= self->startDetached(program,arguments);
  13590. break;
  13591. case 3:
  13592. retval= self->startDetached(program,arguments,workingDirectory);
  13593. break;
  13594. default:
  13595. retval= false;
  13596. }
  13597. return QScriptValue(retval);
  13598. }
  13599. /*:82*//*83:*/
  13600. #line 2162 "./typica.w"
  13601. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  13602. {
  13603. QProcess*self= getself<QProcess*> (context);
  13604. QString directory= argument<QString> (0,context);
  13605. self->setWorkingDirectory(directory);
  13606. return QScriptValue();
  13607. }
  13608. /*:83*//*84:*/
  13609. #line 2174 "./typica.w"
  13610. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  13611. {
  13612. QProcess*self= getself<QProcess*> (context);
  13613. QString program= argument<QString> (0,context);
  13614. QStringList arguments= QStringList();
  13615. if(context->argumentCount()> 1){
  13616. arguments= argument<QVariant> (1,context).toStringList();
  13617. }
  13618. self->start(program,arguments);
  13619. return QScriptValue();
  13620. }
  13621. /*:84*//*86:*/
  13622. #line 2200 "./typica.w"
  13623. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  13624. {
  13625. QScriptValue object= engine->newVariant(QVariant(bytes));
  13626. setQByteArrayProperties(object,engine);
  13627. return object;
  13628. }
  13629. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  13630. {
  13631. bytes= value.toVariant().toByteArray();
  13632. }
  13633. /*:86*//*88:*/
  13634. #line 2223 "./typica.w"
  13635. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  13636. {
  13637. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  13638. setQByteArrayProperties(object,engine);
  13639. return object;
  13640. }
  13641. /*:88*//*89:*/
  13642. #line 2234 "./typica.w"
  13643. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  13644. {
  13645. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  13646. }
  13647. /*:89*//*90:*/
  13648. #line 2243 "./typica.w"
  13649. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  13650. {
  13651. QByteArray self= getself<QByteArray> (context);
  13652. QByteArray retval;
  13653. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  13654. return engine->toScriptValue<QByteArray> (retval);
  13655. }
  13656. /*:90*//*93:*/
  13657. #line 2274 "./typica.w"
  13658. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  13659. {
  13660. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  13661. QScriptValue object= engine->newQObject(new QBuffer(array));
  13662. setQBufferProperties(object,engine);
  13663. return object;
  13664. }
  13665. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  13666. {
  13667. setQIODeviceProperties(value,engine);
  13668. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  13669. }
  13670. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  13671. {
  13672. QBuffer*self= getself<QBuffer*> (context);
  13673. self->setData(argument<QString> (0,context).toAscii());
  13674. return QScriptValue();
  13675. }
  13676. /*:93*//*96:*/
  13677. #line 2323 "./typica.w"
  13678. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  13679. {
  13680. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  13681. setXQueryProperties(object,engine);
  13682. return object;
  13683. }
  13684. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  13685. {
  13686. QXmlQuery*self= getself<QXmlQuery*> (context);
  13687. delete self;
  13688. return QScriptValue();
  13689. }
  13690. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  13691. {
  13692. value.setProperty("bind",engine->newFunction(XQuery_bind));
  13693. value.setProperty("exec",engine->newFunction(XQuery_exec));
  13694. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  13695. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  13696. }
  13697. /*:96*//*97:*/
  13698. #line 2349 "./typica.w"
  13699. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  13700. {
  13701. QXmlQuery*self= getself<QXmlQuery*> (context);
  13702. QIODevice*buffer= argument<QIODevice*> (1,context);
  13703. self->bindVariable(argument<QString> (0,context),buffer);
  13704. return QScriptValue();
  13705. }
  13706. /*:97*//*98:*/
  13707. #line 2360 "./typica.w"
  13708. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  13709. {
  13710. QXmlQuery*self= getself<QXmlQuery*> (context);
  13711. self->setQuery(argument<QString> (0,context));
  13712. return QScriptValue();
  13713. }
  13714. /*:98*//*99:*/
  13715. #line 2370 "./typica.w"
  13716. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  13717. {
  13718. QXmlQuery*self= getself<QXmlQuery*> (context);
  13719. QString result;
  13720. self->evaluateTo(&result);
  13721. return QScriptValue(result);
  13722. }
  13723. /*:99*//*102:*/
  13724. #line 2425 "./typica.w"
  13725. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  13726. {
  13727. QXmlStreamWriter*retval;
  13728. if(context->argumentCount()==1)
  13729. {
  13730. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  13731. }
  13732. else
  13733. {
  13734. retval= new QXmlStreamWriter;
  13735. }
  13736. QScriptValue object= engine->toScriptValue<void*> (retval);
  13737. setXmlWriterProperties(object,engine);
  13738. return object;
  13739. }
  13740. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  13741. {
  13742. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  13743. value.setProperty("writeAttribute",
  13744. engine->newFunction(XmlWriter_writeAttribute));
  13745. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  13746. value.setProperty("writeCharacters",
  13747. engine->newFunction(XmlWriter_writeCharacters));
  13748. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  13749. value.setProperty("writeEmptyElement",
  13750. engine->newFunction(XmlWriter_writeEmptyElement));
  13751. value.setProperty("writeEndDocument",
  13752. engine->newFunction(XmlWriter_writeEndDocument));
  13753. value.setProperty("writeEndElement",
  13754. engine->newFunction(XmlWriter_writeEndElement));
  13755. value.setProperty("writeEntityReference",
  13756. engine->newFunction(XmlWriter_writeEntityReference));
  13757. value.setProperty("writeProcessingInstruction",
  13758. engine->newFunction(XmlWriter_writeProcessingInstruction));
  13759. value.setProperty("writeStartDocument",
  13760. engine->newFunction(XmlWriter_writeStartDocument));
  13761. value.setProperty("writeStartElement",
  13762. engine->newFunction(XmlWriter_writeStartElement));
  13763. value.setProperty("writeTextElement",
  13764. engine->newFunction(XmlWriter_writeTextElement));
  13765. }
  13766. /*:102*//*103:*/
  13767. #line 2472 "./typica.w"
  13768. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  13769. {
  13770. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13771. QIODevice*device= argument<QIODevice*> (0,context);
  13772. self->setDevice(device);
  13773. return QScriptValue();
  13774. }
  13775. /*:103*//*104:*/
  13776. #line 2486 "./typica.w"
  13777. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  13778. QScriptEngine*)
  13779. {
  13780. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13781. self->writeStartDocument(argument<QString> (0,context));
  13782. return QScriptValue();
  13783. }
  13784. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  13785. QScriptEngine*)
  13786. {
  13787. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13788. self->writeEndDocument();
  13789. return QScriptValue();
  13790. }
  13791. /*:104*//*105:*/
  13792. #line 2505 "./typica.w"
  13793. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  13794. {
  13795. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13796. self->writeDTD(argument<QString> (0,context));
  13797. return QScriptValue();
  13798. }
  13799. /*:105*//*106:*/
  13800. #line 2516 "./typica.w"
  13801. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  13802. QScriptEngine*)
  13803. {
  13804. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13805. self->writeStartElement(argument<QString> (0,context));
  13806. return QScriptValue();
  13807. }
  13808. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  13809. {
  13810. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13811. self->writeAttribute(argument<QString> (0,context),
  13812. argument<QString> (1,context));
  13813. return QScriptValue();
  13814. }
  13815. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  13816. {
  13817. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13818. self->writeCharacters(argument<QString> (0,context));
  13819. return QScriptValue();
  13820. }
  13821. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  13822. {
  13823. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13824. self->writeEndElement();
  13825. return QScriptValue();
  13826. }
  13827. /*:106*//*107:*/
  13828. #line 2552 "./typica.w"
  13829. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  13830. QScriptEngine*)
  13831. {
  13832. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13833. self->writeEmptyElement(argument<QString> (0,context));
  13834. return QScriptValue();
  13835. }
  13836. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  13837. QScriptEngine*)
  13838. {
  13839. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13840. self->writeTextElement(argument<QString> (0,context),
  13841. argument<QString> (1,context));
  13842. return QScriptValue();
  13843. }
  13844. /*:107*//*108:*/
  13845. #line 2573 "./typica.w"
  13846. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  13847. {
  13848. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13849. self->writeCDATA(argument<QString> (0,context));
  13850. return QScriptValue();
  13851. }
  13852. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  13853. QScriptEngine*)
  13854. {
  13855. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13856. self->writeEntityReference(argument<QString> (0,context));
  13857. return QScriptValue();
  13858. }
  13859. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  13860. QScriptEngine*)
  13861. {
  13862. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13863. self->writeProcessingInstruction(argument<QString> (0,context),
  13864. argument<QString> (1,context));
  13865. return QScriptValue();
  13866. }
  13867. /*:108*//*111:*/
  13868. #line 2632 "./typica.w"
  13869. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  13870. {
  13871. QXmlStreamReader*retval=
  13872. new QXmlStreamReader(argument<QIODevice*> (0,context));
  13873. QScriptValue object= engine->toScriptValue<void*> (retval);
  13874. setXmlReaderProperties(object,engine);
  13875. return object;
  13876. }
  13877. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  13878. {
  13879. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  13880. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  13881. value.setProperty("hasAttribute",
  13882. engine->newFunction(XmlReader_hasAttribute));
  13883. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  13884. value.setProperty("isStartElement",
  13885. engine->newFunction(XmlReader_isStartElement));
  13886. value.setProperty("name",engine->newFunction(XmlReader_name));
  13887. value.setProperty("readElementText",
  13888. engine->newFunction(XmlReader_readElementText));
  13889. value.setProperty("readNext",
  13890. engine->newFunction(XmlReader_readNext));
  13891. value.setProperty("text",engine->newFunction(XmlReader_text));
  13892. }
  13893. /*:111*//*112:*/
  13894. #line 2662 "./typica.w"
  13895. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  13896. {
  13897. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13898. QString retval=
  13899. self->attributes().value(argument<QString> (0,context)).toString();
  13900. return QScriptValue(retval);
  13901. }
  13902. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  13903. {
  13904. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13905. bool retval=
  13906. self->attributes().hasAttribute(argument<QString> (0,context));
  13907. return QScriptValue(retval);
  13908. }
  13909. /*:112*//*113:*/
  13910. #line 2682 "./typica.w"
  13911. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  13912. {
  13913. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13914. return QScriptValue(self->atEnd());
  13915. }
  13916. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  13917. {
  13918. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13919. return QScriptValue(self->isDTD());
  13920. }
  13921. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  13922. {
  13923. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13924. return QScriptValue(self->isStartElement());
  13925. }
  13926. /*:113*//*114:*/
  13927. #line 2703 "./typica.w"
  13928. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  13929. {
  13930. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13931. self->readNext();
  13932. return QScriptValue();
  13933. }
  13934. /*:114*//*115:*/
  13935. #line 2713 "./typica.w"
  13936. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  13937. {
  13938. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13939. return QScriptValue(self->name().toString());
  13940. }
  13941. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  13942. {
  13943. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13944. return QScriptValue(self->readElementText());
  13945. }
  13946. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  13947. {
  13948. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13949. return QScriptValue(self->text().toString());
  13950. }
  13951. /*:115*//*118:*/
  13952. #line 2755 "./typica.w"
  13953. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  13954. {
  13955. setQObjectProperties(value,engine);
  13956. value.setProperty("value",engine->newFunction(QSettings_value));
  13957. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  13958. }
  13959. /*:118*//*119:*/
  13960. #line 2767 "./typica.w"
  13961. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  13962. {
  13963. QScriptValue object;
  13964. if(context->argumentCount()==1||context->argumentCount()==2)
  13965. {
  13966. QSettings settings;
  13967. QString key= argument<QString> (0,context);
  13968. QVariant value;
  13969. QVariant retval;
  13970. if(context->argumentCount()> 1)
  13971. {
  13972. value= argument<QVariant> (1,context);
  13973. retval= settings.value(key,value);
  13974. }
  13975. else
  13976. {
  13977. retval= settings.value(key);
  13978. }
  13979. object= engine->newVariant(retval);
  13980. }
  13981. else
  13982. {
  13983. context->throwError("Incorrect number of arguments passed to "
  13984. "QSettings::value(). This method takes one "
  13985. "string and one optional variant type.");
  13986. }
  13987. return object;
  13988. }
  13989. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  13990. {
  13991. if(context->argumentCount()==2)
  13992. {
  13993. QSettings settings;
  13994. QString key= argument<QString> (0,context);
  13995. QVariant value= argument<QVariant> (1,context);
  13996. settings.setValue(key,value);
  13997. }
  13998. else
  13999. {
  14000. context->throwError("Incorrect number of arguments passed to "
  14001. "QSettings::setValue(). This method takes one "
  14002. "string and one variant type for a total of two "
  14003. "arguments.");
  14004. }
  14005. return QScriptValue();
  14006. }
  14007. /*:119*//*122:*/
  14008. #line 2836 "./typica.w"
  14009. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  14010. {
  14011. QScriptValue object= engine->newQObject(new QLCDNumber());
  14012. setQLCDNumberProperties(object,engine);
  14013. return object;
  14014. }
  14015. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  14016. {
  14017. setQFrameProperties(value,engine);
  14018. }
  14019. /*:122*//*125:*/
  14020. #line 2894 "./typica.w"
  14021. QScriptValue constructQTime(QScriptContext*context,
  14022. QScriptEngine*engine)
  14023. {
  14024. QScriptValue object;
  14025. if(context->argumentCount()==0||
  14026. (context->argumentCount()>=2&&context->argumentCount()<=4))
  14027. {
  14028. int arg1= 0;
  14029. int arg2= 0;
  14030. int arg3= 0;
  14031. int arg4= 0;
  14032. switch(context->argumentCount())
  14033. {
  14034. case 4:
  14035. arg4= argument<int> (3,context);
  14036. case 3:
  14037. arg3= argument<int> (2,context);
  14038. case 2:
  14039. arg2= argument<int> (1,context);
  14040. arg1= argument<int> (0,context);
  14041. default:
  14042. break;
  14043. }
  14044. if(context->argumentCount())
  14045. {
  14046. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  14047. arg4));
  14048. }
  14049. else
  14050. {
  14051. object= engine->toScriptValue<QTime> (QTime());
  14052. }
  14053. setQTimeProperties(object,engine);
  14054. }
  14055. else
  14056. {
  14057. context->throwError("Incorrect number of arguments passed to "
  14058. "QTime::QTime(). This method takes zero, two, "
  14059. "three, or four integer arguments.");
  14060. }
  14061. return object;
  14062. }
  14063. /*:125*//*126:*/
  14064. #line 2942 "./typica.w"
  14065. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  14066. {
  14067. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  14068. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  14069. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  14070. value.setProperty("hour",engine->newFunction(QTime_hour));
  14071. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  14072. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  14073. value.setProperty("minute",engine->newFunction(QTime_minute));
  14074. value.setProperty("msec",engine->newFunction(QTime_msec));
  14075. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  14076. value.setProperty("restart",engine->newFunction(QTime_restart));
  14077. value.setProperty("second",engine->newFunction(QTime_second));
  14078. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  14079. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  14080. value.setProperty("start",engine->newFunction(QTime_start));
  14081. value.setProperty("toString",engine->newFunction(QTime_toString));
  14082. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  14083. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  14084. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  14085. }
  14086. /*:126*//*127:*/
  14087. #line 2971 "./typica.w"
  14088. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  14089. {
  14090. QTime self= getself<QTime> (context);
  14091. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  14092. (self.second()*1000)+self.msec();
  14093. return QScriptValue(retval);
  14094. }
  14095. /*:127*//*128:*/
  14096. #line 2985 "./typica.w"
  14097. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  14098. {
  14099. QTime time;
  14100. QScriptValue retval;
  14101. if(context->argumentCount()==1)
  14102. {
  14103. QTime self= getself<QTime> (context);
  14104. time= self.addMSecs(argument<int> (0,context));
  14105. retval= engine->toScriptValue<QTime> (time);
  14106. setQTimeProperties(retval,engine);
  14107. }
  14108. else
  14109. {
  14110. context->throwError("Incorrect number of arguments passed to "
  14111. "QTime::addMSecs(). This method takes one "
  14112. "integer as an argument.");
  14113. }
  14114. return retval;
  14115. }
  14116. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  14117. {
  14118. QTime time;
  14119. QScriptValue retval;
  14120. if(context->argumentCount()==1)
  14121. {
  14122. QTime self= getself<QTime> (context);
  14123. time= self.addSecs(argument<int> (0,context));
  14124. retval= engine->toScriptValue<QTime> (time);
  14125. setQTimeProperties(retval,engine);
  14126. }
  14127. else
  14128. {
  14129. context->throwError("Incorrect number of arguments passed to "
  14130. "QTime::addSecs(). This method takes one "
  14131. "integer as an argument.");
  14132. }
  14133. return retval;
  14134. }
  14135. /*:128*//*129:*/
  14136. #line 3028 "./typica.w"
  14137. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  14138. {
  14139. QScriptValue retval;
  14140. if(context->argumentCount()==0)
  14141. {
  14142. QTime self= getself<QTime> (context);
  14143. retval= QScriptValue(engine,self.elapsed());
  14144. }
  14145. else
  14146. {
  14147. context->throwError("Incorrect number of arguments passed to "
  14148. "QTime::elapsed(). This method takes no "
  14149. "arguments.");
  14150. }
  14151. return retval;
  14152. }
  14153. /*:129*//*130:*/
  14154. #line 3049 "./typica.w"
  14155. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  14156. {
  14157. QScriptValue retval;
  14158. if(context->argumentCount()==0)
  14159. {
  14160. QTime self= getself<QTime> (context);
  14161. retval= QScriptValue(engine,self.hour());
  14162. }
  14163. else
  14164. {
  14165. context->throwError("Incorrect number of arguments passed to "
  14166. "QTime::hour(). This method takes no "
  14167. "arguments.");
  14168. }
  14169. return retval;
  14170. }
  14171. /*:130*//*131:*/
  14172. #line 3069 "./typica.w"
  14173. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  14174. {
  14175. QScriptValue retval;
  14176. if(context->argumentCount()==0)
  14177. {
  14178. QTime self= getself<QTime> (context);
  14179. retval= QScriptValue(engine,self.minute());
  14180. }
  14181. else
  14182. {
  14183. context->throwError("Incorrect number of arguments passed to "
  14184. "QTime::minute(). This method takes no "
  14185. "arguments.");
  14186. }
  14187. return retval;
  14188. }
  14189. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  14190. {
  14191. QScriptValue retval;
  14192. if(context->argumentCount()==0)
  14193. {
  14194. QTime self= getself<QTime> (context);
  14195. retval= QScriptValue(engine,self.second());
  14196. }
  14197. else
  14198. {
  14199. context->throwError("Incorrect number of arguments passed to "
  14200. "QTime::second(). This method takes no "
  14201. "arguments.");
  14202. }
  14203. return retval;
  14204. }
  14205. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  14206. {
  14207. QScriptValue retval;
  14208. if(context->argumentCount()==0)
  14209. {
  14210. QTime self= getself<QTime> (context);
  14211. retval= QScriptValue(engine,self.msec());
  14212. }
  14213. else
  14214. {
  14215. context->throwError("Incorrect number of arguments passed to "
  14216. "QTime::msec(). This method takes no "
  14217. "arguments.");
  14218. }
  14219. return retval;
  14220. }
  14221. /*:131*//*132:*/
  14222. #line 3125 "./typica.w"
  14223. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  14224. {
  14225. QScriptValue retval;
  14226. if(context->argumentCount()==0)
  14227. {
  14228. QTime self= getself<QTime> (context);
  14229. retval= QScriptValue(engine,self.isNull());
  14230. }
  14231. else
  14232. {
  14233. context->throwError("Incorrect number of arguments passed to "
  14234. "QTime::isNull(). This method takes no "
  14235. "arguments.");
  14236. }
  14237. return retval;
  14238. }
  14239. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  14240. {
  14241. QScriptValue retval;
  14242. if(context->argumentCount()==0)
  14243. {
  14244. QTime self= getself<QTime> (context);
  14245. retval= QScriptValue(engine,self.isValid());
  14246. }
  14247. else
  14248. {
  14249. context->throwError("Incorrect number of arguments passed to "
  14250. "QTime::isValid(). This method takes no "
  14251. "arguments.");
  14252. }
  14253. return retval;
  14254. }
  14255. /*:132*//*133:*/
  14256. #line 3163 "./typica.w"
  14257. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  14258. {
  14259. QScriptValue retval;
  14260. if(context->argumentCount()==1)
  14261. {
  14262. QTime self= getself<QTime> (context);
  14263. QTime arg= argument<QVariant> (0,context).toTime();
  14264. retval= QScriptValue(engine,self.msecsTo(arg));
  14265. }
  14266. else
  14267. {
  14268. context->throwError("Incorrect number of arguments passed to "
  14269. "QTime::msecsTo(). This method takes one QTime.");
  14270. }
  14271. return retval;
  14272. }
  14273. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  14274. {
  14275. QScriptValue retval;
  14276. if(context->argumentCount()==1)
  14277. {
  14278. QTime self= getself<QTime> (context);
  14279. QTime arg= argument<QVariant> (0,context).toTime();
  14280. retval= QScriptValue(engine,self.secsTo(arg));
  14281. }
  14282. else
  14283. {
  14284. context->throwError("Incorrect number of arguments passed to "
  14285. "QTime::secsTo(). This method takes one QTime.");
  14286. }
  14287. return retval;
  14288. }
  14289. /*:133*//*134:*/
  14290. #line 3202 "./typica.w"
  14291. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  14292. {
  14293. QScriptValue retval;
  14294. if(context->argumentCount()==0)
  14295. {
  14296. QTime self= getself<QTime> (context);
  14297. retval= QScriptValue(engine,self.restart());
  14298. }
  14299. else
  14300. {
  14301. context->throwError("Incorrect number of arguments passed to "
  14302. "QTime::restart(). This method takes no "
  14303. "arguments.");
  14304. }
  14305. return retval;
  14306. }
  14307. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  14308. {
  14309. if(context->argumentCount()==0)
  14310. {
  14311. QTime self= getself<QTime> (context);
  14312. self.start();
  14313. }
  14314. else
  14315. {
  14316. context->throwError("Incorrect number of arguments passed to "
  14317. "QTime::start(). This method takes no arguments.");
  14318. }
  14319. return QScriptValue();
  14320. }
  14321. /*:134*//*135:*/
  14322. #line 3238 "./typica.w"
  14323. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  14324. {
  14325. QScriptValue retval;
  14326. if(context->argumentCount()==3||context->argumentCount()==4)
  14327. {
  14328. QTime self= getself<QTime> (context);
  14329. int arg1= 0;
  14330. int arg2= 0;
  14331. int arg3= 0;
  14332. int arg4= 0;
  14333. switch(context->argumentCount())
  14334. {
  14335. case 4:
  14336. arg4= argument<int> (3,context);
  14337. case 3:
  14338. arg3= argument<int> (2,context);
  14339. arg2= argument<int> (1,context);
  14340. arg1= argument<int> (0,context);
  14341. default:
  14342. break;
  14343. }
  14344. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  14345. }
  14346. else
  14347. {
  14348. context->throwError("Incorrect number of arguments passed to "
  14349. "QTime::setHMS(). This method takes three or "
  14350. "four integer arguments.");
  14351. }
  14352. return retval;
  14353. }
  14354. /*:135*//*136:*/
  14355. #line 3274 "./typica.w"
  14356. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  14357. {
  14358. QScriptValue retval;
  14359. if(context->argumentCount()==1)
  14360. {
  14361. QTime self= getself<QTime> (context);
  14362. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  14363. }
  14364. else
  14365. {
  14366. context->throwError("Incorrect number of arguments passed to "
  14367. "QTime::toString(). This method takes one QString "
  14368. "as an argument.");
  14369. }
  14370. return retval;
  14371. }
  14372. /*:136*//*137:*/
  14373. #line 3295 "./typica.w"
  14374. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  14375. {
  14376. QScriptValue object;
  14377. object= engine->toScriptValue<QTime> (QTime::currentTime());
  14378. setQTimeProperties(object,engine);
  14379. return object;
  14380. }
  14381. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  14382. {
  14383. QScriptValue object;
  14384. if(context->argumentCount()==2)
  14385. {
  14386. QString time= argument<QString> (0,context);
  14387. QString format= argument<QString> (1,context);
  14388. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  14389. setQTimeProperties(object,engine);
  14390. }
  14391. else
  14392. {
  14393. context->throwError("Incorrect number of arguments passed to "
  14394. "QTime::fromString(). This method takes two "
  14395. "string arguments.");
  14396. }
  14397. return object;
  14398. }
  14399. /*:137*//*138:*/
  14400. #line 3326 "./typica.w"
  14401. template<> QTime argument(int arg,QScriptContext*context)
  14402. {
  14403. return qscriptvalue_cast<QTime> (context->argument(arg));
  14404. }
  14405. /*:138*//*140:*/
  14406. #line 3344 "./typica.w"
  14407. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  14408. {
  14409. setQFrameProperties(value,engine);
  14410. }
  14411. /*:140*//*142:*/
  14412. #line 3358 "./typica.w"
  14413. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  14414. {
  14415. setQAbstractScrollAreaProperties(value,engine);
  14416. }
  14417. /*:142*//*144:*/
  14418. #line 3372 "./typica.w"
  14419. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  14420. {
  14421. setQAbstractScrollAreaProperties(value,engine);
  14422. }
  14423. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  14424. {
  14425. setQAbstractItemViewProperties(value,engine);
  14426. }
  14427. /*:144*//*147:*/
  14428. #line 3405 "./typica.w"
  14429. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  14430. {
  14431. QScriptValue object= engine->newQObject(new QPushButton());
  14432. setQPushButtonProperties(object,engine);
  14433. return object;
  14434. }
  14435. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  14436. {
  14437. setQAbstractButtonProperties(value,engine);
  14438. }
  14439. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  14440. {
  14441. setQWidgetProperties(value,engine);
  14442. }
  14443. /*:147*//*154:*/
  14444. #line 3517 "./typica.w"
  14445. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  14446. {
  14447. SqlQueryConnection*obj= new SqlQueryConnection();
  14448. QScriptValue object=
  14449. engine->toScriptValue<void*> (obj);
  14450. setQSqlQueryProperties(object,engine);
  14451. return object;
  14452. }
  14453. /*:154*//*155:*/
  14454. #line 3530 "./typica.w"
  14455. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  14456. {
  14457. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  14458. value.setProperty("bindFileData",
  14459. engine->newFunction(QSqlQuery_bindFileData));
  14460. value.setProperty("bindDeviceData",
  14461. engine->newFunction(QSqlQuery_bindDeviceData));
  14462. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  14463. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  14464. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  14465. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  14466. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  14467. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  14468. }
  14469. /*:155*//*156:*/
  14470. #line 3548 "./typica.w"
  14471. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  14472. {
  14473. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  14474. QScriptValue retval;
  14475. if(context->argumentCount()==1)
  14476. {
  14477. retval= QScriptValue(engine,
  14478. q->exec(argument<QString> (0,context)));
  14479. }
  14480. else
  14481. {
  14482. retval= QScriptValue(engine,q->exec());
  14483. }
  14484. if(q->lastError().isValid())
  14485. {
  14486. qDebug()<<q->lastQuery();
  14487. qDebug()<<q->lastError().text();
  14488. }
  14489. return retval;
  14490. }
  14491. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  14492. {
  14493. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14494. return QScriptValue(query->lastQuery());
  14495. }
  14496. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  14497. {
  14498. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14499. return QScriptValue(engine,query->next());
  14500. }
  14501. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  14502. {
  14503. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14504. return QScriptValue(engine,
  14505. query->value(argument<int> (0,context)).toString());
  14506. }
  14507. /*:156*//*157:*/
  14508. #line 3592 "./typica.w"
  14509. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  14510. {
  14511. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14512. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  14513. }
  14514. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  14515. {
  14516. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14517. query->bindValue(argument<QString> (0,context),
  14518. argument<QVariant> (1,context));
  14519. return QScriptValue();
  14520. }
  14521. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  14522. QScriptEngine*)
  14523. {
  14524. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14525. QString placeholder= argument<QString> (0,context);
  14526. QString filename= argument<QString> (1,context);
  14527. QFile file(filename);
  14528. QByteArray data;
  14529. if(file.open(QIODevice::ReadOnly))
  14530. {
  14531. data= file.readAll();
  14532. file.close();
  14533. }
  14534. query->bindValue(placeholder,data);
  14535. return QScriptValue();
  14536. }
  14537. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  14538. QScriptEngine*)
  14539. {
  14540. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  14541. QString placeholder= argument<QString> (0,context);
  14542. QIODevice*device= argument<QIODevice*> (1,context);
  14543. device->reset();
  14544. QByteArray data;
  14545. data= device->readAll();
  14546. query->bindValue(placeholder,data);
  14547. return QScriptValue();
  14548. }
  14549. /*:157*//*158:*/
  14550. #line 3644 "./typica.w"
  14551. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  14552. {
  14553. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  14554. delete query;
  14555. return QScriptValue::UndefinedValue;
  14556. }
  14557. /*:158*//*161:*/
  14558. #line 3689 "./typica.w"
  14559. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  14560. {
  14561. QFileInfo info(argument<QString> (0,context));
  14562. QScriptValue retval(engine,info.baseName());
  14563. return retval;
  14564. }
  14565. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  14566. {
  14567. QFileInfo info(argument<QString> (0,context));
  14568. QDir dir= info.dir();
  14569. QScriptValue retval(engine,dir.path());
  14570. return retval;
  14571. }
  14572. /*:161*//*162:*/
  14573. #line 3708 "./typica.w"
  14574. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  14575. {
  14576. SqlQueryConnection h;
  14577. QSqlQuery*query= h.operator->();
  14578. QString q= "SELECT file FROM files WHERE id = :file";
  14579. query->prepare(q);
  14580. query->bindValue(":file",argument<int> (0,context));
  14581. query->exec();
  14582. query->next();
  14583. QByteArray array= query->value(0).toByteArray();
  14584. QFile file(argument<QString> (1,context));
  14585. file.open(QIODevice::WriteOnly);
  14586. file.write(array);
  14587. file.close();
  14588. return QScriptValue();
  14589. }
  14590. /*:162*//*163:*/
  14591. #line 3729 "./typica.w"
  14592. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  14593. {
  14594. QString source= argument<QString> (0,context);
  14595. source.remove(0,1);
  14596. source.chop(1);
  14597. QStringList elements= source.split(",");
  14598. QString element;
  14599. QScriptValue dest= engine->newArray(elements.size());
  14600. int i= 0;
  14601. foreach(element,elements)
  14602. {
  14603. if(element.startsWith("\"")&&element.endsWith("\""))
  14604. {
  14605. element.chop(1);
  14606. element= element.remove(0,1);
  14607. }
  14608. dest.setProperty(i,QScriptValue(engine,element));
  14609. i++;
  14610. }
  14611. return dest;
  14612. }
  14613. /*:163*//*164:*/
  14614. #line 3755 "./typica.w"
  14615. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  14616. {
  14617. QString font= argument<QString> (0,context);
  14618. QString classname;
  14619. if(context->argumentCount()> 1)
  14620. {
  14621. classname= argument<QString> (1,context);
  14622. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  14623. }
  14624. else
  14625. {
  14626. QApplication::setFont(QFont(font));
  14627. }
  14628. return QScriptValue();
  14629. }
  14630. /*:164*//*165:*/
  14631. #line 3775 "./typica.w"
  14632. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  14633. {
  14634. SqlQueryConnection h;
  14635. QSqlQuery*query= h.operator->();
  14636. QString q= "SELECT file FROM files WHERE id = :file";
  14637. query->prepare(q);
  14638. query->bindValue(":file",argument<int> (0,context));
  14639. query->exec();
  14640. query->next();
  14641. QByteArray array= query->value(0).toByteArray();
  14642. QBuffer buffer(&array);
  14643. buffer.open(QIODevice::ReadOnly);
  14644. QXmlQuery xquery;
  14645. xquery.bindVariable("profile",&buffer);
  14646. QString xq;
  14647. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  14648. xquery.setQuery(xq);
  14649. QString result;
  14650. xquery.evaluateTo(&result);
  14651. return QScriptValue(result);
  14652. }
  14653. /*:165*//*166:*/
  14654. #line 3802 "./typica.w"
  14655. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  14656. {
  14657. QWidget::setTabOrder(argument<QWidget*> (0,context),
  14658. argument<QWidget*> (1,context));
  14659. return QScriptValue();
  14660. }
  14661. /*:166*//*173:*/
  14662. #line 4047 "./typica.w"
  14663. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  14664. {
  14665. QString targetID= argument<QString> (0,context);
  14666. QDomNode element;
  14667. QScriptValue object;
  14668. /*175:*/
  14669. #line 4094 "./typica.w"
  14670. QDomNodeList windows=
  14671. AppInstance->configuration()->documentElement().elementsByTagName("window");
  14672. QDomNode nullNode;
  14673. int i= 0;
  14674. element= nullNode;
  14675. while(i<windows.count())
  14676. {
  14677. element= windows.at(i);
  14678. QDomNamedNodeMap attributes= element.attributes();
  14679. if(attributes.contains("id"))
  14680. {
  14681. if(attributes.namedItem("id").toAttr().value()==targetID)
  14682. {
  14683. break;
  14684. }
  14685. }
  14686. element= nullNode;
  14687. i++;
  14688. }
  14689. /*:175*/
  14690. #line 4053 "./typica.w"
  14691. if(!element.isNull())
  14692. {
  14693. /*176:*/
  14694. #line 4126 "./typica.w"
  14695. ScriptQMainWindow*window= new ScriptQMainWindow;
  14696. window->setObjectName(targetID);
  14697. object= engine->newQObject(window);
  14698. setQMainWindowProperties(object,engine);
  14699. QWidget*central= new(QWidget);
  14700. central->setParent(window);
  14701. central->setObjectName("centralWidget");
  14702. window->setCentralWidget(central);
  14703. if(element.hasChildNodes())
  14704. {
  14705. /*177:*/
  14706. #line 4161 "./typica.w"
  14707. QStack<QWidget*> widgetStack;
  14708. QStack<QLayout*> layoutStack;
  14709. QString windowScript;
  14710. widgetStack.push(central);
  14711. QDomNodeList windowChildren= element.childNodes();
  14712. int i= 0;
  14713. while(i<windowChildren.count())
  14714. {
  14715. QDomNode current;
  14716. QDomElement element;
  14717. current= windowChildren.at(i);
  14718. if(current.isElement())
  14719. {
  14720. element= current.toElement();
  14721. if(element.tagName()=="program")
  14722. {
  14723. windowScript.append(element.text());
  14724. }
  14725. else if(element.tagName()=="layout")
  14726. {
  14727. addLayoutToWidget(element,&widgetStack,&layoutStack);
  14728. }
  14729. else if(element.tagName()=="menu")
  14730. {
  14731. /*178:*/
  14732. #line 4208 "./typica.w"
  14733. QMenuBar*bar= window->menuBar();
  14734. bar->setParent(window);
  14735. bar->setObjectName("menuBar");
  14736. if(element.hasAttribute("name"))
  14737. {
  14738. QMenu*menu= bar->addMenu(element.attribute("name"));
  14739. menu->setParent(bar);
  14740. if(element.hasAttribute("type"))
  14741. {
  14742. if(element.attribute("type")=="reports")
  14743. {
  14744. if(element.hasAttribute("src"))
  14745. {
  14746. /*613:*/
  14747. #line 13194 "./typica.w"
  14748. QSettings settings;
  14749. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  14750. toString()).
  14751. arg(element.attribute("src"));
  14752. QDir::addSearchPath("reports",reportDirectory);
  14753. QDir directory(reportDirectory);
  14754. directory.setFilter(QDir::Files);
  14755. directory.setSorting(QDir::Name);
  14756. QStringList nameFilter;
  14757. nameFilter<<"*.xml";
  14758. directory.setNameFilters(nameFilter);
  14759. QFileInfoList reportFiles= directory.entryInfoList();
  14760. for(int i= 0;i<reportFiles.size();i++)
  14761. {
  14762. QFileInfo reportFile= reportFiles.at(i);
  14763. /*617:*/
  14764. #line 13274 "./typica.w"
  14765. QString path= reportFile.absoluteFilePath();
  14766. QFile file(path);
  14767. if(file.open(QIODevice::ReadOnly))
  14768. {
  14769. QDomDocument document;
  14770. document.setContent(&file,true);
  14771. QDomElement root= document.documentElement();
  14772. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  14773. if(!titleNode.isNull())
  14774. {
  14775. QDomElement titleElement= titleNode.toElement();
  14776. QString title= titleElement.text();
  14777. if(!title.isEmpty())
  14778. {
  14779. QStringList hierarchy= title.split(":->");
  14780. QMenu*insertionPoint= menu;
  14781. /*618:*/
  14782. #line 13301 "./typica.w"
  14783. for(int j= 0;j<hierarchy.size()-1;j++)
  14784. {
  14785. QObjectList menuList= insertionPoint->children();
  14786. bool menuFound= false;
  14787. for(int k= 0;k<menuList.size();k++)
  14788. {
  14789. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  14790. if(currentItem)
  14791. {
  14792. if(currentItem->title()==hierarchy.at(j))
  14793. {
  14794. menuFound= true;
  14795. insertionPoint= currentItem;
  14796. break;
  14797. }
  14798. }
  14799. }
  14800. if(!menuFound)
  14801. {
  14802. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  14803. }
  14804. }
  14805. /*:618*/
  14806. #line 13291 "./typica.w"
  14807. ReportAction*action= new ReportAction(path,hierarchy.last());
  14808. insertionPoint->addAction(action);
  14809. }
  14810. }
  14811. }
  14812. /*:617*/
  14813. #line 13210 "./typica.w"
  14814. }
  14815. /*:613*/
  14816. #line 4222 "./typica.w"
  14817. }
  14818. }
  14819. }
  14820. if(element.hasChildNodes())
  14821. {
  14822. /*179:*/
  14823. #line 4235 "./typica.w"
  14824. QDomNodeList menuItems= element.childNodes();
  14825. int j= 0;
  14826. while(j<menuItems.count())
  14827. {
  14828. QDomNode item= menuItems.at(j);
  14829. if(item.isElement())
  14830. {
  14831. QDomElement itemElement= item.toElement();
  14832. if(itemElement.tagName()=="item")
  14833. {
  14834. QAction*itemAction= new QAction(itemElement.text(),menu);
  14835. if(itemElement.hasAttribute("id"))
  14836. {
  14837. itemAction->setObjectName(itemElement.attribute("id"));
  14838. }
  14839. if(itemElement.hasAttribute("shortcut"))
  14840. {
  14841. itemAction->setShortcut(itemElement.attribute("shortcut"));
  14842. }
  14843. menu->addAction(itemAction);
  14844. }
  14845. else if(itemElement.tagName()=="separator")
  14846. {
  14847. menu->addSeparator();
  14848. }
  14849. }
  14850. j++;
  14851. }
  14852. #line 1 "./helpmenu.w"
  14853. /*:179*/
  14854. #line 4228 "./typica.w"
  14855. }
  14856. }
  14857. /*:178*/
  14858. #line 4186 "./typica.w"
  14859. }
  14860. }
  14861. i++;
  14862. }
  14863. QScriptValue oldThis= context->thisObject();
  14864. context->setThisObject(object);
  14865. QScriptValue result= engine->evaluate(windowScript);
  14866. /*170:*/
  14867. #line 3943 "./typica.w"
  14868. if(engine->hasUncaughtException())
  14869. {
  14870. int line= engine->uncaughtExceptionLineNumber();
  14871. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  14872. result.toString();
  14873. QString trace;
  14874. foreach(trace,engine->uncaughtExceptionBacktrace())
  14875. {
  14876. qDebug()<<trace;
  14877. }
  14878. }
  14879. /*:170*/
  14880. #line 4194 "./typica.w"
  14881. context->setThisObject(oldThis);
  14882. /*:177*/
  14883. #line 4137 "./typica.w"
  14884. }
  14885. /*180:*/
  14886. #line 9 "./helpmenu.w"
  14887. HelpMenu*helpMenu= new HelpMenu();
  14888. window->menuBar()->addMenu(helpMenu);
  14889. /*:180*/
  14890. #line 4139 "./typica.w"
  14891. window->show();
  14892. /*:176*/
  14893. #line 4056 "./typica.w"
  14894. }
  14895. return object;
  14896. }
  14897. /*:173*//*174:*/
  14898. #line 4067 "./typica.w"
  14899. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  14900. {
  14901. QString targetID= argument<QString> (0,context);
  14902. QFile file(QString("reports:%1").arg(targetID));
  14903. QScriptValue object;
  14904. if(file.open(QIODevice::ReadOnly))
  14905. {
  14906. QDomDocument document;
  14907. document.setContent(&file,true);
  14908. QDomElement element= document.documentElement();
  14909. if(!element.isNull())
  14910. {
  14911. /*176:*/
  14912. #line 4126 "./typica.w"
  14913. ScriptQMainWindow*window= new ScriptQMainWindow;
  14914. window->setObjectName(targetID);
  14915. object= engine->newQObject(window);
  14916. setQMainWindowProperties(object,engine);
  14917. QWidget*central= new(QWidget);
  14918. central->setParent(window);
  14919. central->setObjectName("centralWidget");
  14920. window->setCentralWidget(central);
  14921. if(element.hasChildNodes())
  14922. {
  14923. /*177:*/
  14924. #line 4161 "./typica.w"
  14925. QStack<QWidget*> widgetStack;
  14926. QStack<QLayout*> layoutStack;
  14927. QString windowScript;
  14928. widgetStack.push(central);
  14929. QDomNodeList windowChildren= element.childNodes();
  14930. int i= 0;
  14931. while(i<windowChildren.count())
  14932. {
  14933. QDomNode current;
  14934. QDomElement element;
  14935. current= windowChildren.at(i);
  14936. if(current.isElement())
  14937. {
  14938. element= current.toElement();
  14939. if(element.tagName()=="program")
  14940. {
  14941. windowScript.append(element.text());
  14942. }
  14943. else if(element.tagName()=="layout")
  14944. {
  14945. addLayoutToWidget(element,&widgetStack,&layoutStack);
  14946. }
  14947. else if(element.tagName()=="menu")
  14948. {
  14949. /*178:*/
  14950. #line 4208 "./typica.w"
  14951. QMenuBar*bar= window->menuBar();
  14952. bar->setParent(window);
  14953. bar->setObjectName("menuBar");
  14954. if(element.hasAttribute("name"))
  14955. {
  14956. QMenu*menu= bar->addMenu(element.attribute("name"));
  14957. menu->setParent(bar);
  14958. if(element.hasAttribute("type"))
  14959. {
  14960. if(element.attribute("type")=="reports")
  14961. {
  14962. if(element.hasAttribute("src"))
  14963. {
  14964. /*613:*/
  14965. #line 13194 "./typica.w"
  14966. QSettings settings;
  14967. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  14968. toString()).
  14969. arg(element.attribute("src"));
  14970. QDir::addSearchPath("reports",reportDirectory);
  14971. QDir directory(reportDirectory);
  14972. directory.setFilter(QDir::Files);
  14973. directory.setSorting(QDir::Name);
  14974. QStringList nameFilter;
  14975. nameFilter<<"*.xml";
  14976. directory.setNameFilters(nameFilter);
  14977. QFileInfoList reportFiles= directory.entryInfoList();
  14978. for(int i= 0;i<reportFiles.size();i++)
  14979. {
  14980. QFileInfo reportFile= reportFiles.at(i);
  14981. /*617:*/
  14982. #line 13274 "./typica.w"
  14983. QString path= reportFile.absoluteFilePath();
  14984. QFile file(path);
  14985. if(file.open(QIODevice::ReadOnly))
  14986. {
  14987. QDomDocument document;
  14988. document.setContent(&file,true);
  14989. QDomElement root= document.documentElement();
  14990. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  14991. if(!titleNode.isNull())
  14992. {
  14993. QDomElement titleElement= titleNode.toElement();
  14994. QString title= titleElement.text();
  14995. if(!title.isEmpty())
  14996. {
  14997. QStringList hierarchy= title.split(":->");
  14998. QMenu*insertionPoint= menu;
  14999. /*618:*/
  15000. #line 13301 "./typica.w"
  15001. for(int j= 0;j<hierarchy.size()-1;j++)
  15002. {
  15003. QObjectList menuList= insertionPoint->children();
  15004. bool menuFound= false;
  15005. for(int k= 0;k<menuList.size();k++)
  15006. {
  15007. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  15008. if(currentItem)
  15009. {
  15010. if(currentItem->title()==hierarchy.at(j))
  15011. {
  15012. menuFound= true;
  15013. insertionPoint= currentItem;
  15014. break;
  15015. }
  15016. }
  15017. }
  15018. if(!menuFound)
  15019. {
  15020. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  15021. }
  15022. }
  15023. /*:618*/
  15024. #line 13291 "./typica.w"
  15025. ReportAction*action= new ReportAction(path,hierarchy.last());
  15026. insertionPoint->addAction(action);
  15027. }
  15028. }
  15029. }
  15030. /*:617*/
  15031. #line 13210 "./typica.w"
  15032. }
  15033. /*:613*/
  15034. #line 4222 "./typica.w"
  15035. }
  15036. }
  15037. }
  15038. if(element.hasChildNodes())
  15039. {
  15040. /*179:*/
  15041. #line 4235 "./typica.w"
  15042. QDomNodeList menuItems= element.childNodes();
  15043. int j= 0;
  15044. while(j<menuItems.count())
  15045. {
  15046. QDomNode item= menuItems.at(j);
  15047. if(item.isElement())
  15048. {
  15049. QDomElement itemElement= item.toElement();
  15050. if(itemElement.tagName()=="item")
  15051. {
  15052. QAction*itemAction= new QAction(itemElement.text(),menu);
  15053. if(itemElement.hasAttribute("id"))
  15054. {
  15055. itemAction->setObjectName(itemElement.attribute("id"));
  15056. }
  15057. if(itemElement.hasAttribute("shortcut"))
  15058. {
  15059. itemAction->setShortcut(itemElement.attribute("shortcut"));
  15060. }
  15061. menu->addAction(itemAction);
  15062. }
  15063. else if(itemElement.tagName()=="separator")
  15064. {
  15065. menu->addSeparator();
  15066. }
  15067. }
  15068. j++;
  15069. }
  15070. #line 1 "./helpmenu.w"
  15071. /*:179*/
  15072. #line 4228 "./typica.w"
  15073. }
  15074. }
  15075. /*:178*/
  15076. #line 4186 "./typica.w"
  15077. }
  15078. }
  15079. i++;
  15080. }
  15081. QScriptValue oldThis= context->thisObject();
  15082. context->setThisObject(object);
  15083. QScriptValue result= engine->evaluate(windowScript);
  15084. /*170:*/
  15085. #line 3943 "./typica.w"
  15086. if(engine->hasUncaughtException())
  15087. {
  15088. int line= engine->uncaughtExceptionLineNumber();
  15089. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  15090. result.toString();
  15091. QString trace;
  15092. foreach(trace,engine->uncaughtExceptionBacktrace())
  15093. {
  15094. qDebug()<<trace;
  15095. }
  15096. }
  15097. /*:170*/
  15098. #line 4194 "./typica.w"
  15099. context->setThisObject(oldThis);
  15100. /*:177*/
  15101. #line 4137 "./typica.w"
  15102. }
  15103. /*180:*/
  15104. #line 9 "./helpmenu.w"
  15105. HelpMenu*helpMenu= new HelpMenu();
  15106. window->menuBar()->addMenu(helpMenu);
  15107. /*:180*/
  15108. #line 4139 "./typica.w"
  15109. window->show();
  15110. /*:176*/
  15111. #line 4080 "./typica.w"
  15112. }
  15113. file.close();
  15114. }
  15115. return object;
  15116. }
  15117. /*:174*//*193:*/
  15118. #line 4279 "./typica.w"
  15119. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  15120. QStack<QLayout*> *layoutStack)
  15121. {
  15122. if(element.hasAttribute("type"))
  15123. {
  15124. /*194:*/
  15125. #line 4300 "./typica.w"
  15126. QLayout*layout;
  15127. QString layoutType= element.attribute("type");
  15128. if(layoutType=="horizontal")
  15129. {
  15130. layout= new QHBoxLayout;
  15131. layoutStack->push(layout);
  15132. populateBoxLayout(element,widgetStack,layoutStack);
  15133. }
  15134. else if(layoutType=="vertical")
  15135. {
  15136. layout= new QVBoxLayout;
  15137. layoutStack->push(layout);
  15138. populateBoxLayout(element,widgetStack,layoutStack);
  15139. }
  15140. else if(layoutType=="grid")
  15141. {
  15142. layout= new QGridLayout;
  15143. layoutStack->push(layout);
  15144. populateGridLayout(element,widgetStack,layoutStack);
  15145. }
  15146. else if(layoutType=="stack")
  15147. {
  15148. layout= new QStackedLayout;
  15149. layoutStack->push(layout);
  15150. populateStackedLayout(element,widgetStack,layoutStack);
  15151. }
  15152. if(element.hasAttribute("id"))
  15153. {
  15154. layout->setObjectName(element.attribute("id"));
  15155. }
  15156. if(element.hasAttribute("spacing"))
  15157. {
  15158. layout->setSpacing(element.attribute("spacing").toInt());
  15159. }
  15160. if(element.hasAttribute("margin"))
  15161. {
  15162. int m= element.attribute("margin").toInt();
  15163. layout->setContentsMargins(m,m,m,m);
  15164. }
  15165. /*:194*/
  15166. #line 4285 "./typica.w"
  15167. QWidget*widget= widgetStack->top();
  15168. if(layout)
  15169. {
  15170. widget->setLayout(layout);
  15171. }
  15172. layoutStack->pop();
  15173. }
  15174. }
  15175. /*:193*//*195:*/
  15176. #line 4347 "./typica.w"
  15177. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15178. QStack<QLayout*> *layoutStack)
  15179. {
  15180. QDomNodeList children= element.childNodes();
  15181. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  15182. for(int i= 0;i<children.count();i++)
  15183. {
  15184. QDomNode current;
  15185. QDomElement currentElement;
  15186. current= children.at(i);
  15187. if(current.isElement())
  15188. {
  15189. currentElement= current.toElement();
  15190. if(currentElement.tagName()=="page")
  15191. {
  15192. QWidget*widget= new QWidget;
  15193. layout->addWidget(widget);
  15194. widgetStack->push(widget);
  15195. populateWidget(currentElement,widgetStack,layoutStack);
  15196. widgetStack->pop();
  15197. }
  15198. }
  15199. }
  15200. }
  15201. /*:195*//*196:*/
  15202. #line 4379 "./typica.w"
  15203. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15204. QStack<QLayout*> *layoutStack)
  15205. {
  15206. QDomNodeList children= element.childNodes();
  15207. int row= -1;
  15208. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  15209. for(int i= 0;i<children.count();i++)
  15210. {
  15211. QDomNode current;
  15212. QDomElement currentElement;
  15213. current= children.at(i);
  15214. if(current.isElement())
  15215. {
  15216. currentElement= current.toElement();
  15217. if(currentElement.tagName()=="row")
  15218. {
  15219. row++;
  15220. if(currentElement.hasAttribute("height"))
  15221. {
  15222. layout->setRowMinimumHeight(row,
  15223. currentElement.attribute("height").toInt());
  15224. }
  15225. if(currentElement.hasAttribute("stretch"))
  15226. {
  15227. layout->setRowStretch(row,
  15228. currentElement.attribute("stretch").toInt());
  15229. }
  15230. /*197:*/
  15231. #line 4435 "./typica.w"
  15232. int column= -1;
  15233. QDomNodeList rowChildren= currentElement.childNodes();
  15234. for(int j= 0;j<rowChildren.count();j++)
  15235. {
  15236. QDomNode columnNode;
  15237. QDomElement columnElement;
  15238. columnNode= rowChildren.at(j);
  15239. if(columnNode.isElement())
  15240. {
  15241. columnElement= columnNode.toElement();
  15242. if(columnElement.tagName()=="column")
  15243. {
  15244. column++;
  15245. if(columnElement.hasAttribute("column"))
  15246. {
  15247. column= columnElement.attribute("column").toInt();
  15248. }
  15249. if(columnElement.hasAttribute("width"))
  15250. {
  15251. layout->setColumnMinimumWidth(column,
  15252. columnElement.attribute("width").toInt());
  15253. }
  15254. if(columnElement.hasAttribute("stretch"))
  15255. {
  15256. layout->setColumnStretch(column,
  15257. columnElement.attribute("stretch").toInt());
  15258. }
  15259. int hspan= 1;
  15260. int vspan= 1;
  15261. if(columnElement.hasAttribute("rowspan"))
  15262. {
  15263. vspan= columnElement.attribute("rowspan").toInt();
  15264. }
  15265. if(columnElement.hasAttribute("colspan"))
  15266. {
  15267. hspan= columnElement.attribute("colspan").toInt();
  15268. }
  15269. QHBoxLayout*cell= new QHBoxLayout;
  15270. layout->addLayout(cell,row,column,vspan,hspan);
  15271. layoutStack->push(cell);
  15272. populateBoxLayout(columnElement,widgetStack,layoutStack);
  15273. layoutStack->pop();
  15274. }
  15275. }
  15276. }
  15277. /*:197*/
  15278. #line 4407 "./typica.w"
  15279. }
  15280. }
  15281. }
  15282. }
  15283. /*:196*//*198:*/
  15284. #line 4485 "./typica.w"
  15285. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15286. QStack<QLayout*> *layoutStack)
  15287. {
  15288. QDomNodeList children= element.childNodes();
  15289. for(int i= 0;i<children.count();i++)
  15290. {
  15291. QDomNode current;
  15292. QDomElement currentElement;
  15293. current= children.at(i);
  15294. if(current.isElement())
  15295. {
  15296. currentElement= current.toElement();
  15297. if(currentElement.tagName()=="button")
  15298. {
  15299. addButtonToLayout(currentElement,widgetStack,layoutStack);
  15300. }
  15301. else if(currentElement.tagName()=="calendar")
  15302. {
  15303. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  15304. }
  15305. else if(currentElement.tagName()=="decoration")
  15306. {
  15307. addDecorationToLayout(currentElement,widgetStack,
  15308. layoutStack);
  15309. }
  15310. else if(currentElement.tagName()=="layout")
  15311. {
  15312. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  15313. }
  15314. else if(currentElement.tagName()=="splitter")
  15315. {
  15316. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  15317. }
  15318. else if(currentElement.tagName()=="label")
  15319. {
  15320. QBoxLayout*layout=
  15321. qobject_cast<QBoxLayout*> (layoutStack->top());
  15322. QLabel*label= new QLabel(currentElement.text());
  15323. layout->addWidget(label);
  15324. }
  15325. else if(currentElement.tagName()=="lcdtemperature")
  15326. {
  15327. addTemperatureDisplayToLayout(currentElement,widgetStack,
  15328. layoutStack);
  15329. }
  15330. else if(currentElement.tagName()=="lcdtimer")
  15331. {
  15332. addTimerDisplayToLayout(currentElement,widgetStack,
  15333. layoutStack);
  15334. }
  15335. else if(currentElement.tagName()=="line")
  15336. {
  15337. addLineToLayout(currentElement,widgetStack,layoutStack);
  15338. }
  15339. else if(currentElement.tagName()=="report")
  15340. {
  15341. addReportToLayout(currentElement,widgetStack,layoutStack);
  15342. }
  15343. else if(currentElement.tagName()=="sqldrop")
  15344. {
  15345. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  15346. }
  15347. else if(currentElement.tagName()=="sqltablearray")
  15348. {
  15349. addSaltToLayout(currentElement,widgetStack,layoutStack);
  15350. }
  15351. else if(currentElement.tagName()=="sqlview")
  15352. {
  15353. addSqlQueryViewToLayout(currentElement,widgetStack,
  15354. layoutStack);
  15355. }
  15356. else if(currentElement.tagName()=="textarea")
  15357. {
  15358. addTextToLayout(currentElement,widgetStack,layoutStack);
  15359. }
  15360. else if(currentElement.tagName()=="spinbox")
  15361. {
  15362. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  15363. }
  15364. else if(currentElement.tagName()=="formarray")
  15365. {
  15366. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  15367. }
  15368. else if(currentElement.tagName()=="hscale")
  15369. {
  15370. addScaleControlToLayout(currentElement,widgetStack,
  15371. layoutStack);
  15372. }
  15373. else if(currentElement.tagName()=="vscale")
  15374. {
  15375. addIntensityControlToLayout(currentElement,widgetStack,
  15376. layoutStack);
  15377. }
  15378. else if(currentElement.tagName()=="webview")
  15379. {
  15380. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  15381. }
  15382. else if(currentElement.tagName()=="stretch")
  15383. {
  15384. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15385. layout->addStretch();
  15386. }
  15387. /*655:*/
  15388. #line 442 "./daterangeselector.w"
  15389. else if(currentElement.tagName()=="daterange")
  15390. {
  15391. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  15392. }
  15393. /*:655*/
  15394. #line 4588 "./typica.w"
  15395. }
  15396. }
  15397. }
  15398. /*:198*//*199:*/
  15399. #line 4596 "./typica.w"
  15400. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15401. QStack<QLayout*> *layoutStack)
  15402. {
  15403. QLayout*targetLayout= layoutStack->pop();
  15404. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  15405. if(element.hasAttribute("type"))
  15406. {
  15407. /*194:*/
  15408. #line 4300 "./typica.w"
  15409. QLayout*layout;
  15410. QString layoutType= element.attribute("type");
  15411. if(layoutType=="horizontal")
  15412. {
  15413. layout= new QHBoxLayout;
  15414. layoutStack->push(layout);
  15415. populateBoxLayout(element,widgetStack,layoutStack);
  15416. }
  15417. else if(layoutType=="vertical")
  15418. {
  15419. layout= new QVBoxLayout;
  15420. layoutStack->push(layout);
  15421. populateBoxLayout(element,widgetStack,layoutStack);
  15422. }
  15423. else if(layoutType=="grid")
  15424. {
  15425. layout= new QGridLayout;
  15426. layoutStack->push(layout);
  15427. populateGridLayout(element,widgetStack,layoutStack);
  15428. }
  15429. else if(layoutType=="stack")
  15430. {
  15431. layout= new QStackedLayout;
  15432. layoutStack->push(layout);
  15433. populateStackedLayout(element,widgetStack,layoutStack);
  15434. }
  15435. if(element.hasAttribute("id"))
  15436. {
  15437. layout->setObjectName(element.attribute("id"));
  15438. }
  15439. if(element.hasAttribute("spacing"))
  15440. {
  15441. layout->setSpacing(element.attribute("spacing").toInt());
  15442. }
  15443. if(element.hasAttribute("margin"))
  15444. {
  15445. int m= element.attribute("margin").toInt();
  15446. layout->setContentsMargins(m,m,m,m);
  15447. }
  15448. /*:194*/
  15449. #line 4604 "./typica.w"
  15450. boxLayout->addLayout(layout);
  15451. layoutStack->pop();
  15452. }
  15453. layoutStack->push(targetLayout);
  15454. }
  15455. /*:199*//*200:*/
  15456. #line 4615 "./typica.w"
  15457. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15458. QStack<QLayout*> *layoutStack)
  15459. {
  15460. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15461. QSplitter*splitter= new(QSplitter);
  15462. layout->addWidget(splitter);
  15463. /*201:*/
  15464. #line 4628 "./typica.w"
  15465. QString orientation= element.attribute("type");
  15466. if(orientation=="horizontal")
  15467. {
  15468. splitter->setOrientation(Qt::Horizontal);
  15469. }
  15470. else if(orientation=="vertical")
  15471. {
  15472. splitter->setOrientation(Qt::Vertical);
  15473. }
  15474. QString id= element.attribute("id");
  15475. if(!id.isEmpty())
  15476. {
  15477. splitter->setObjectName(id);
  15478. }
  15479. if(element.hasChildNodes())
  15480. {
  15481. widgetStack->push(splitter);
  15482. populateSplitter(element,widgetStack,layoutStack);
  15483. widgetStack->pop();
  15484. }
  15485. /*:201*/
  15486. #line 4622 "./typica.w"
  15487. }
  15488. /*:200*//*202:*/
  15489. #line 4654 "./typica.w"
  15490. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15491. QStack<QLayout*> *layoutStack)
  15492. {
  15493. QDomNodeList children= element.childNodes();
  15494. for(int i= 0;i<children.count();i++)
  15495. {
  15496. QDomNode current;
  15497. QDomElement currentElement;
  15498. current= children.at(i);
  15499. if(current.isElement())
  15500. {
  15501. currentElement= current.toElement();
  15502. if(currentElement.tagName()=="decoration")
  15503. {
  15504. addDecorationToSplitter(currentElement,widgetStack,
  15505. layoutStack);
  15506. }
  15507. else if(currentElement.tagName()=="graph")
  15508. {
  15509. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  15510. }
  15511. else if(currentElement.tagName()=="splitter")
  15512. {
  15513. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  15514. }
  15515. else if(currentElement.tagName()=="lcdtemperature")
  15516. {
  15517. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  15518. layoutStack);
  15519. }
  15520. else if(currentElement.tagName()=="lcdtimer")
  15521. {
  15522. addTimerDisplayToSplitter(currentElement,widgetStack,
  15523. layoutStack);
  15524. }
  15525. else if(currentElement.tagName()=="measurementtable")
  15526. {
  15527. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  15528. }
  15529. else if(currentElement.tagName()=="widget")
  15530. {
  15531. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  15532. }
  15533. }
  15534. }
  15535. }
  15536. /*:202*//*203:*/
  15537. #line 4704 "./typica.w"
  15538. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15539. QStack<QLayout*> *layoutStack)
  15540. {
  15541. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  15542. QSplitter*splitter= new(QSplitter);
  15543. splitter->setParent(parent);
  15544. parent->addWidget(splitter);
  15545. /*201:*/
  15546. #line 4628 "./typica.w"
  15547. QString orientation= element.attribute("type");
  15548. if(orientation=="horizontal")
  15549. {
  15550. splitter->setOrientation(Qt::Horizontal);
  15551. }
  15552. else if(orientation=="vertical")
  15553. {
  15554. splitter->setOrientation(Qt::Vertical);
  15555. }
  15556. QString id= element.attribute("id");
  15557. if(!id.isEmpty())
  15558. {
  15559. splitter->setObjectName(id);
  15560. }
  15561. if(element.hasChildNodes())
  15562. {
  15563. widgetStack->push(splitter);
  15564. populateSplitter(element,widgetStack,layoutStack);
  15565. widgetStack->pop();
  15566. }
  15567. /*:201*/
  15568. #line 4712 "./typica.w"
  15569. }
  15570. /*:203*//*204:*/
  15571. #line 4721 "./typica.w"
  15572. void addTemperatureDisplayToSplitter(QDomElement element,
  15573. QStack<QWidget*> *widgetStack,
  15574. QStack<QLayout*> *)
  15575. {
  15576. TemperatureDisplay*display= new(TemperatureDisplay);
  15577. if(element.hasAttribute("id"))
  15578. {
  15579. display->setObjectName(element.attribute("id"));
  15580. }
  15581. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15582. splitter->addWidget(display);
  15583. }
  15584. void addTemperatureDisplayToLayout(QDomElement element,
  15585. QStack<QWidget*> *,
  15586. QStack<QLayout*> *layoutStack)
  15587. {
  15588. TemperatureDisplay*display= new(TemperatureDisplay);
  15589. if(element.hasAttribute("id"))
  15590. {
  15591. display->setObjectName(element.attribute("id"));
  15592. }
  15593. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15594. layout->addWidget(display);
  15595. }
  15596. /*:204*//*205:*/
  15597. #line 4752 "./typica.w"
  15598. void addTimerDisplayToSplitter(QDomElement element,
  15599. QStack<QWidget*> *widgetStack,
  15600. QStack<QLayout*> *)
  15601. {
  15602. TimerDisplay*display= new(TimerDisplay);
  15603. if(element.hasAttribute("id"))
  15604. {
  15605. display->setObjectName(element.attribute("id"));
  15606. }
  15607. if(element.hasAttribute("format"))
  15608. {
  15609. display->setDisplayFormat(element.attribute("format"));
  15610. }
  15611. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15612. splitter->addWidget(display);
  15613. }
  15614. void addTimerDisplayToLayout(QDomElement element,
  15615. QStack<QWidget*> *,
  15616. QStack<QLayout*> *layoutStack)
  15617. {
  15618. TimerDisplay*display= new(TimerDisplay);
  15619. if(element.hasAttribute("id"))
  15620. {
  15621. display->setObjectName(element.attribute("id"));
  15622. }
  15623. if(element.hasAttribute("format"))
  15624. {
  15625. display->setDisplayFormat(element.attribute("format"));
  15626. }
  15627. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15628. layout->addWidget(display);
  15629. }
  15630. /*:205*//*206:*/
  15631. #line 4790 "./typica.w"
  15632. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  15633. QStack<QLayout*> *layoutStack)
  15634. {
  15635. /*207:*/
  15636. #line 4811 "./typica.w"
  15637. QString labelText= element.attribute("name");
  15638. Qt::Orientations orientation= Qt::Horizontal;
  15639. if(element.hasAttribute("type"))
  15640. {
  15641. if(element.attribute("type")=="horizontal")
  15642. {
  15643. orientation= Qt::Horizontal;
  15644. }
  15645. else if(element.attribute("type")=="vertical")
  15646. {
  15647. orientation= Qt::Vertical;
  15648. }
  15649. }
  15650. /*208:*/
  15651. #line 4836 "./typica.w"
  15652. QWidget*theWidget= NULL;
  15653. QDomNodeList children= element.childNodes();
  15654. for(int i= 0;i<children.count();i++)
  15655. {
  15656. QDomNode item= children.at(i);
  15657. if(item.isElement())
  15658. {
  15659. QDomElement itemElement= item.toElement();
  15660. if(itemElement.tagName()=="lcdtemperature")
  15661. {
  15662. TemperatureDisplay*display= new TemperatureDisplay;
  15663. if(itemElement.hasAttribute("id"))
  15664. {
  15665. display->setObjectName(itemElement.attribute("id"));
  15666. }
  15667. theWidget= display;
  15668. }
  15669. else if(itemElement.tagName()=="lcdtimer")
  15670. {
  15671. TimerDisplay*display= new TimerDisplay;
  15672. if(itemElement.hasAttribute("id"))
  15673. {
  15674. display->setObjectName(itemElement.attribute("id"));
  15675. }
  15676. if(itemElement.hasAttribute("format"))
  15677. {
  15678. display->setDisplayFormat(itemElement.attribute("format"));
  15679. }
  15680. theWidget= display;
  15681. }
  15682. }
  15683. }
  15684. /*:208*/
  15685. #line 4825 "./typica.w"
  15686. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  15687. orientation);
  15688. if(element.hasAttribute("id"))
  15689. {
  15690. decoration->setObjectName(element.attribute("id"));
  15691. }
  15692. /*:207*/
  15693. #line 4794 "./typica.w"
  15694. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15695. layout->addWidget(decoration);
  15696. }
  15697. void addDecorationToSplitter(QDomElement element,
  15698. QStack<QWidget*> *widgetStack,
  15699. QStack<QLayout*> *)
  15700. {
  15701. /*207:*/
  15702. #line 4811 "./typica.w"
  15703. QString labelText= element.attribute("name");
  15704. Qt::Orientations orientation= Qt::Horizontal;
  15705. if(element.hasAttribute("type"))
  15706. {
  15707. if(element.attribute("type")=="horizontal")
  15708. {
  15709. orientation= Qt::Horizontal;
  15710. }
  15711. else if(element.attribute("type")=="vertical")
  15712. {
  15713. orientation= Qt::Vertical;
  15714. }
  15715. }
  15716. /*208:*/
  15717. #line 4836 "./typica.w"
  15718. QWidget*theWidget= NULL;
  15719. QDomNodeList children= element.childNodes();
  15720. for(int i= 0;i<children.count();i++)
  15721. {
  15722. QDomNode item= children.at(i);
  15723. if(item.isElement())
  15724. {
  15725. QDomElement itemElement= item.toElement();
  15726. if(itemElement.tagName()=="lcdtemperature")
  15727. {
  15728. TemperatureDisplay*display= new TemperatureDisplay;
  15729. if(itemElement.hasAttribute("id"))
  15730. {
  15731. display->setObjectName(itemElement.attribute("id"));
  15732. }
  15733. theWidget= display;
  15734. }
  15735. else if(itemElement.tagName()=="lcdtimer")
  15736. {
  15737. TimerDisplay*display= new TimerDisplay;
  15738. if(itemElement.hasAttribute("id"))
  15739. {
  15740. display->setObjectName(itemElement.attribute("id"));
  15741. }
  15742. if(itemElement.hasAttribute("format"))
  15743. {
  15744. display->setDisplayFormat(itemElement.attribute("format"));
  15745. }
  15746. theWidget= display;
  15747. }
  15748. }
  15749. }
  15750. /*:208*/
  15751. #line 4825 "./typica.w"
  15752. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  15753. orientation);
  15754. if(element.hasAttribute("id"))
  15755. {
  15756. decoration->setObjectName(element.attribute("id"));
  15757. }
  15758. /*:207*/
  15759. #line 4803 "./typica.w"
  15760. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15761. splitter->addWidget(decoration);
  15762. }
  15763. /*:206*//*209:*/
  15764. #line 4875 "./typica.w"
  15765. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15766. QStack<QLayout*> *layoutStack)
  15767. {
  15768. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15769. QWidget*widget= new QWidget;
  15770. if(element.hasAttribute("id"))
  15771. {
  15772. widget->setObjectName(element.attribute("id"));
  15773. }
  15774. splitter->addWidget(widget);
  15775. if(element.hasChildNodes())
  15776. {
  15777. widgetStack->push(widget);
  15778. populateWidget(element,widgetStack,layoutStack);
  15779. widgetStack->pop();
  15780. }
  15781. }
  15782. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  15783. QStack<QLayout*> *layoutStack)
  15784. {
  15785. QDomNodeList children= element.childNodes();
  15786. for(int i= 0;i<children.count();i++)
  15787. {
  15788. QDomNode current;
  15789. QDomElement currentElement;
  15790. current= children.at(i);
  15791. if(current.isElement())
  15792. {
  15793. currentElement= current.toElement();
  15794. if(currentElement.tagName()=="layout")
  15795. {
  15796. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  15797. }
  15798. }
  15799. }
  15800. }
  15801. /*:209*//*210:*/
  15802. #line 4918 "./typica.w"
  15803. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  15804. QStack<QLayout*> *layoutStack)
  15805. {
  15806. QAbstractButton*button= NULL;
  15807. QString text= element.attribute("name");
  15808. if(element.hasAttribute("type"))
  15809. {
  15810. QString type= element.attribute("type");
  15811. if(type=="annotation")
  15812. {
  15813. AnnotationButton*abutton= new AnnotationButton(text);
  15814. if(element.hasAttribute("annotation"))
  15815. {
  15816. abutton->setAnnotation(element.attribute("annotation"));
  15817. }
  15818. if(element.hasAttribute("series"))
  15819. {
  15820. abutton->setTemperatureColumn(element.attribute("series").
  15821. toInt());
  15822. }
  15823. if(element.hasAttribute("column"))
  15824. {
  15825. abutton->setAnnotationColumn(element.attribute("column").
  15826. toInt());
  15827. }
  15828. button= abutton;
  15829. }
  15830. else if(type=="check")
  15831. {
  15832. button= new QCheckBox(text);
  15833. }
  15834. else if(type=="push")
  15835. {
  15836. button= new QPushButton(text);
  15837. }
  15838. }
  15839. if(element.hasAttribute("id"))
  15840. {
  15841. button->setObjectName(element.attribute("id"));
  15842. }
  15843. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15844. layout->addWidget(button);
  15845. }
  15846. /*:210*//*211:*/
  15847. #line 4970 "./typica.w"
  15848. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  15849. QStack<QLayout*> *layoutStack)
  15850. {
  15851. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  15852. if(element.hasAttribute("pretext"))
  15853. {
  15854. box->setPretext(element.attribute("pretext"));
  15855. }
  15856. if(element.hasAttribute("posttext"))
  15857. {
  15858. box->setPosttext(element.attribute("posttext"));
  15859. }
  15860. if(element.hasAttribute("series"))
  15861. {
  15862. box->setTemperatureColumn(element.attribute("series").toInt());
  15863. }
  15864. if(element.hasAttribute("column"))
  15865. {
  15866. box->setAnnotationColumn(element.attribute("column").toInt());
  15867. }
  15868. if(element.hasAttribute("min"))
  15869. {
  15870. box->setMinimum(element.attribute("min").toDouble());
  15871. }
  15872. if(element.hasAttribute("max"))
  15873. {
  15874. box->setMaximum(element.attribute("max").toDouble());
  15875. }
  15876. if(element.hasAttribute("decimals"))
  15877. {
  15878. box->setDecimals(element.attribute("decimals").toInt());
  15879. }
  15880. if(element.hasAttribute("step"))
  15881. {
  15882. box->setSingleStep(element.attribute("step").toDouble());
  15883. }
  15884. if(element.hasAttribute("id"))
  15885. {
  15886. box->setObjectName(element.attribute("id"));
  15887. }
  15888. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15889. layout->addWidget(box);
  15890. }
  15891. /*:211*//*212:*/
  15892. #line 5026 "./typica.w"
  15893. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15894. QStack<QLayout*> *)
  15895. {
  15896. ZoomLog*widget= new ZoomLog;
  15897. if(!widget)
  15898. {
  15899. qDebug()<<"Error constructing widget!";
  15900. }
  15901. if(element.hasAttribute("id"))
  15902. {
  15903. widget->setObjectName(element.attribute("id"));
  15904. }
  15905. if(element.hasChildNodes())
  15906. {
  15907. QDomNodeList children= element.childNodes();
  15908. int column= 0;
  15909. for(int i= 0;i<children.count();i++)
  15910. {
  15911. QDomNode current;
  15912. QDomElement currentElement;
  15913. current= children.at(i);
  15914. if(current.isElement())
  15915. {
  15916. currentElement= current.toElement();
  15917. if(currentElement.tagName()=="column")
  15918. {
  15919. QString text= currentElement.text();
  15920. widget->setHeaderData(column,text);
  15921. column++;
  15922. }
  15923. }
  15924. }
  15925. }
  15926. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15927. if(splitter)
  15928. {
  15929. splitter->addWidget(widget);
  15930. }
  15931. else
  15932. {
  15933. qDebug()<<"Splitter not found at top of widget stack!";
  15934. }
  15935. }
  15936. /*:212*//*213:*/
  15937. #line 5074 "./typica.w"
  15938. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15939. QStack<QLayout*> *)
  15940. {
  15941. GraphView*view= new GraphView;
  15942. if(element.hasAttribute("id"))
  15943. {
  15944. view->setObjectName(element.attribute("id"));
  15945. }
  15946. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15947. splitter->addWidget(view);
  15948. }
  15949. /*:213*//*214:*/
  15950. #line 5091 "./typica.w"
  15951. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  15952. QStack<QLayout*> *layoutStack)
  15953. {
  15954. SqlComboBox*box= new SqlComboBox();
  15955. if(element.hasAttribute("data"))
  15956. {
  15957. box->setDataColumn(element.attribute("data").toInt());
  15958. }
  15959. if(element.hasAttribute("display"))
  15960. {
  15961. box->setDisplayColumn(element.attribute("display").toInt());
  15962. }
  15963. if(element.hasAttribute("showdata"))
  15964. {
  15965. if(element.attribute("showdata")=="true")
  15966. {
  15967. box->showData(true);
  15968. }
  15969. }
  15970. if(element.hasAttribute("editable"))
  15971. {
  15972. if(element.attribute("editable")=="true")
  15973. {
  15974. box->setEditable(true);
  15975. }
  15976. }
  15977. if(element.hasChildNodes())
  15978. {
  15979. QDomNodeList children= element.childNodes();
  15980. for(int i= 0;i<children.count();i++)
  15981. {
  15982. QDomNode current;
  15983. QDomElement currentElement;
  15984. current= children.at(i);
  15985. if(current.isElement())
  15986. {
  15987. currentElement= current.toElement();
  15988. if(currentElement.tagName()=="null")
  15989. {
  15990. box->addNullOption();
  15991. }
  15992. else if(currentElement.tagName()=="query")
  15993. {
  15994. box->addSqlOptions(currentElement.text());
  15995. }
  15996. }
  15997. }
  15998. }
  15999. if(element.hasAttribute("id"))
  16000. {
  16001. box->setObjectName(element.attribute("id"));
  16002. }
  16003. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16004. layout->addWidget(box);
  16005. }
  16006. /*:214*//*215:*/
  16007. #line 5170 "./typica.w"
  16008. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  16009. QStack<QLayout*> *layoutStack)
  16010. {
  16011. QTableView*view= new QTableView;
  16012. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  16013. SaltModel*model= new SaltModel(element.childNodes().count());
  16014. if(element.hasAttribute("id"))
  16015. {
  16016. view->setObjectName(element.attribute("id"));
  16017. }
  16018. if(element.hasChildNodes())
  16019. {
  16020. QDomNodeList children= element.childNodes();
  16021. int currentColumn= 0;
  16022. for(int i= 0;i<children.count();i++)
  16023. {
  16024. QDomNode current;
  16025. QDomElement currentElement;
  16026. current= children.at(i);
  16027. if(current.isElement())
  16028. {
  16029. currentElement= current.toElement();
  16030. if(currentElement.tagName()=="column")
  16031. {
  16032. if(currentElement.hasAttribute("name"))
  16033. {
  16034. model->setHeaderData(currentColumn,Qt::Horizontal,
  16035. currentElement.attribute("name"));
  16036. }
  16037. if(currentElement.hasAttribute("delegate"))
  16038. {
  16039. /*216:*/
  16040. #line 5218 "./typica.w"
  16041. if(currentElement.attribute("delegate")=="sql")
  16042. {
  16043. /*217:*/
  16044. #line 5234 "./typica.w"
  16045. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  16046. SqlComboBox*widget= new SqlComboBox();
  16047. if(currentElement.hasAttribute("nulltext"))
  16048. {
  16049. widget->setNullText(currentElement.attribute("nulltext"));
  16050. }
  16051. if(currentElement.hasAttribute("nulldata"))
  16052. {
  16053. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  16054. }
  16055. if(currentElement.hasAttribute("null"))
  16056. {
  16057. if(currentElement.attribute("null")=="true")
  16058. {
  16059. widget->addNullOption();
  16060. }
  16061. }
  16062. if(currentElement.hasAttribute("showdata"))
  16063. {
  16064. if(currentElement.attribute("showdata")=="true")
  16065. {
  16066. widget->showData(true);
  16067. }
  16068. }
  16069. if(currentElement.hasAttribute("data"))
  16070. {
  16071. widget->setDataColumn(currentElement.attribute("data").toInt());
  16072. }
  16073. if(currentElement.hasAttribute("display"))
  16074. {
  16075. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  16076. }
  16077. widget->addSqlOptions(currentElement.text());
  16078. delegate->setWidget(widget);
  16079. view->setItemDelegateForColumn(currentColumn,delegate);
  16080. /*:217*/
  16081. #line 5221 "./typica.w"
  16082. }
  16083. else if(currentElement.attribute("delegate")=="numeric")
  16084. {
  16085. /*218:*/
  16086. #line 5275 "./typica.w"
  16087. NumericDelegate*delegate= new NumericDelegate;
  16088. view->setItemDelegateForColumn(currentColumn,delegate);
  16089. /*:218*/
  16090. #line 5225 "./typica.w"
  16091. }
  16092. /*:216*/
  16093. #line 5202 "./typica.w"
  16094. }
  16095. currentColumn++;
  16096. }
  16097. }
  16098. }
  16099. }
  16100. view->setModel(model);
  16101. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16102. layout->addWidget(view);
  16103. }
  16104. /*:215*//*225:*/
  16105. #line 5385 "./typica.w"
  16106. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  16107. QStack<QLayout*> *layoutStack)
  16108. {
  16109. QLineEdit*widget= new QLineEdit(element.text());
  16110. if(element.hasAttribute("id"))
  16111. {
  16112. widget->setObjectName(element.attribute("id"));
  16113. }
  16114. if(element.hasAttribute("writable"))
  16115. {
  16116. if(element.attribute("writable")=="false")
  16117. {
  16118. widget->setReadOnly(true);
  16119. }
  16120. }
  16121. if(element.hasAttribute("validator"))
  16122. {
  16123. if(element.attribute("validator")=="numeric")
  16124. {
  16125. widget->setValidator(new QDoubleValidator(NULL));
  16126. }
  16127. else if(element.attribute("validator")=="integer")
  16128. {
  16129. widget->setValidator(new QIntValidator(NULL));
  16130. }
  16131. else if(element.attribute("validator")=="expression"&&
  16132. element.hasAttribute("expression"))
  16133. {
  16134. widget->setValidator(new QRegExpValidator(
  16135. QRegExp(element.attribute("expression")),
  16136. NULL));
  16137. }
  16138. }
  16139. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16140. layout->addWidget(widget);
  16141. }
  16142. /*:225*//*226:*/
  16143. #line 5426 "./typica.w"
  16144. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  16145. QStack<QLayout*> *layoutStack)
  16146. {
  16147. QTextEdit*widget= new QTextEdit;
  16148. if(element.hasAttribute("id"))
  16149. {
  16150. widget->setObjectName(element.attribute("id"));
  16151. }
  16152. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16153. layout->addWidget(widget);
  16154. }
  16155. /*:226*//*227:*/
  16156. #line 5443 "./typica.w"
  16157. void addSqlQueryViewToLayout(QDomElement element,
  16158. QStack<QWidget*> *,
  16159. QStack<QLayout*> *layoutStack)
  16160. {
  16161. SqlQueryView*view= new SqlQueryView;
  16162. if(element.hasAttribute("id"))
  16163. {
  16164. view->setObjectName(element.attribute("id"));
  16165. }
  16166. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16167. layout->addWidget(view);
  16168. }
  16169. /*:227*//*228:*/
  16170. #line 5460 "./typica.w"
  16171. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  16172. QStack<QLayout*> *layoutStack)
  16173. {
  16174. QWidget*widget;
  16175. if(element.hasAttribute("time"))
  16176. {
  16177. if(element.attribute("time")=="true")
  16178. {
  16179. QDateTimeEdit*edit= new QDateTimeEdit;
  16180. edit->setDateTime(QDateTime::currentDateTime());
  16181. edit->setCalendarPopup(true);
  16182. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  16183. widget= qobject_cast<QWidget*> (edit);
  16184. }
  16185. else
  16186. {
  16187. QDateEdit*edit= new QDateEdit;
  16188. edit->setDate(QDate::currentDate());
  16189. edit->setCalendarPopup(true);
  16190. edit->setDisplayFormat("yyyy-MM-dd");
  16191. widget= qobject_cast<QWidget*> (edit);
  16192. }
  16193. }
  16194. else
  16195. {
  16196. QDateEdit*edit= new QDateEdit;
  16197. edit->setDate(QDate::currentDate());
  16198. edit->setCalendarPopup(true);
  16199. edit->setDisplayFormat("yyyy-MM-dd");
  16200. widget= qobject_cast<QWidget*> (edit);
  16201. }
  16202. if(element.hasAttribute("id"))
  16203. {
  16204. widget->setObjectName(element.attribute("id"));
  16205. }
  16206. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16207. layout->addWidget(widget);
  16208. }
  16209. /*:228*//*229:*/
  16210. #line 5503 "./typica.w"
  16211. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  16212. {
  16213. setQDateTimeEditProperties(value,engine);
  16214. }
  16215. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  16216. {
  16217. setQAbstractSpinBoxProperties(value,engine);
  16218. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  16219. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  16220. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  16221. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  16222. }
  16223. /*:229*//*230:*/
  16224. #line 5523 "./typica.w"
  16225. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  16226. {
  16227. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16228. if(context->argumentCount()==3)
  16229. {
  16230. self->setDate(QDate(argument<int> (0,context),
  16231. argument<int> (1,context),
  16232. argument<int> (2,context)));
  16233. }
  16234. else
  16235. {
  16236. context->throwError("Incorrect number of arguments passed to "
  16237. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  16238. "specifying the year, month, and day.");
  16239. }
  16240. return QScriptValue();
  16241. }
  16242. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  16243. {
  16244. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16245. return QScriptValue(self->date().day());
  16246. }
  16247. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  16248. {
  16249. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16250. return QScriptValue(self->date().month());
  16251. }
  16252. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  16253. {
  16254. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  16255. return QScriptValue(self->date().year());
  16256. }
  16257. /*:230*//*234:*/
  16258. #line 5590 "./typica.w"
  16259. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  16260. {
  16261. QObject*parent= argument<QObject*> (0,context);
  16262. QString name= argument<QString> (1,context);
  16263. QObject*object= parent->findChild<QObject*> (name);
  16264. QScriptValue value;
  16265. if(object)
  16266. {
  16267. value= engine->newQObject(object);
  16268. QString className= object->metaObject()->className();
  16269. /*235:*/
  16270. #line 5608 "./typica.w"
  16271. if(className=="TemperatureDisplay")
  16272. {
  16273. setTemperatureDisplayProperties(value,engine);
  16274. }
  16275. else if(className=="TimerDisplay")
  16276. {
  16277. setTimerDisplayProperties(value,engine);
  16278. }
  16279. else if(className=="QAction")
  16280. {
  16281. setQActionProperties(value,engine);
  16282. }
  16283. else if(className=="QBoxLayout")
  16284. {
  16285. setQBoxLayoutProperties(value,engine);
  16286. }
  16287. else if(className=="QDateEdit")
  16288. {
  16289. setQDateEditProperties(value,engine);
  16290. }
  16291. else if(className=="QDateTimeEdit")
  16292. {
  16293. setQDateTimeEditProperties(value,engine);
  16294. }
  16295. else if(className=="QFrame")
  16296. {
  16297. setQFrameProperties(value,engine);
  16298. }
  16299. else if(className=="QHBoxLayout")
  16300. {
  16301. setQBoxLayoutProperties(value,engine);
  16302. }
  16303. else if(className=="QLCDNumber")
  16304. {
  16305. setQLCDNumberProperties(value,engine);
  16306. }
  16307. else if(className=="QMenu")
  16308. {
  16309. setQMenuProperties(value,engine);
  16310. }
  16311. else if(className=="QMenuBar")
  16312. {
  16313. setQMenuBarProperties(value,engine);
  16314. }
  16315. else if(className=="QPushButton")
  16316. {
  16317. setQPushButtonProperties(value,engine);
  16318. }
  16319. else if(className=="QSplitter")
  16320. {
  16321. setQSplitterProperties(value,engine);
  16322. }
  16323. else if(className=="QTableView")
  16324. {
  16325. if(object->property("tabletype").isValid())
  16326. {
  16327. if(object->property("tabletype").toString()=="SaltTable")
  16328. {
  16329. setSaltTableProperties(value,engine);
  16330. }
  16331. }
  16332. }
  16333. else if(className=="QVBoxLayout")
  16334. {
  16335. setQBoxLayoutProperties(value,engine);
  16336. }
  16337. else if(className=="QWidget")
  16338. {
  16339. setQWidgetProperties(value,engine);
  16340. }
  16341. else if(className=="ScriptQMainWindow")
  16342. {
  16343. setQMainWindowProperties(value,engine);
  16344. }
  16345. else if(className=="SqlComboBox")
  16346. {
  16347. setSqlComboBoxProperties(value,engine);
  16348. }
  16349. else if(className=="SqlQueryView")
  16350. {
  16351. setSqlQueryViewProperties(value,engine);
  16352. }
  16353. else if(className=="ZoomLog")
  16354. {
  16355. setZoomLogProperties(value,engine);
  16356. }
  16357. else if(className=="QTextEdit")
  16358. {
  16359. setQTextEditProperties(value,engine);
  16360. }
  16361. else if(className=="QWebView")
  16362. {
  16363. setQWebViewProperties(value,engine);
  16364. }
  16365. else if(className=="QLineEdit")
  16366. {
  16367. setQLineEditProperties(value,engine);
  16368. }
  16369. /*:235*/
  16370. #line 5601 "./typica.w"
  16371. }
  16372. return value;
  16373. }
  16374. /*:234*//*237:*/
  16375. #line 5737 "./typica.w"
  16376. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  16377. {
  16378. QTableView*self= getself<QTableView*> (context);
  16379. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16380. QString datum;
  16381. double total= 0.0;
  16382. int column= argument<int> (0,context);
  16383. int role= argument<int> (1,context);
  16384. for(int i= 0;i<model->rowCount();i++)
  16385. {
  16386. datum= model->data(model->index(i,column),role).toString();
  16387. if(!datum.isEmpty())
  16388. {
  16389. total+= datum.toDouble();
  16390. }
  16391. }
  16392. return QScriptValue(engine,total);
  16393. }
  16394. /*:237*//*238:*/
  16395. #line 5761 "./typica.w"
  16396. QScriptValue SaltTable_columnArray(QScriptContext*context,
  16397. QScriptEngine*engine)
  16398. {
  16399. QTableView*self= getself<QTableView*> (context);
  16400. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16401. int column= argument<int> (0,context);
  16402. int role= argument<int> (1,context);
  16403. QString literal= model->arrayLiteral(column,role);
  16404. return QScriptValue(engine,literal);
  16405. }
  16406. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  16407. QScriptEngine*engine)
  16408. {
  16409. QTableView*self= getself<QTableView*> (context);
  16410. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16411. int column= argument<int> (0,context);
  16412. int role= argument<int> (1,context);
  16413. QString literal= model->quotedArrayLiteral(column,role);
  16414. return QScriptValue(engine,literal);
  16415. }
  16416. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  16417. QScriptEngine*engine)
  16418. {
  16419. QTableView*self= getself<QTableView*> (context);
  16420. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16421. int column= argument<int> (0,context);
  16422. int role= argument<int> (1,context);
  16423. QString literal= model->arrayLiteral(column,role);
  16424. literal.chop(1);
  16425. literal= literal.remove(0,1);
  16426. return QScriptValue(engine,literal);
  16427. }
  16428. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  16429. QScriptEngine*engine)
  16430. {
  16431. QTableView*self= getself<QTableView*> (context);
  16432. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16433. int column= argument<int> (0,context);
  16434. int role= argument<int> (1,context);
  16435. QString literal= model->quotedArrayLiteral(column,role);
  16436. literal.chop(1);
  16437. literal= literal.remove(0,1);
  16438. return QScriptValue(engine,literal);
  16439. }
  16440. /*:238*//*239:*/
  16441. #line 5813 "./typica.w"
  16442. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  16443. {
  16444. QTableView*self= getself<QTableView*> (context);
  16445. QScriptValue value= engine->newQObject(self->model());
  16446. return value;
  16447. }
  16448. /*:239*//*240:*/
  16449. #line 5827 "./typica.w"
  16450. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  16451. {
  16452. QTableView*self= getself<QTableView*> (context);
  16453. int row= argument<int> (0,context);
  16454. int column= argument<int> (1,context);
  16455. QVariant value= argument<QVariant> (2,context);
  16456. int role= argument<int> (3,context);
  16457. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16458. QModelIndex cell= model->index(row,column);
  16459. model->setData(cell,value,role);
  16460. self->update(cell);
  16461. return QScriptValue();
  16462. }
  16463. /*:240*//*241:*/
  16464. #line 5845 "./typica.w"
  16465. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  16466. {
  16467. QTableView*self= getself<QTableView*> (context);
  16468. int row= argument<int> (0,context);
  16469. int column= argument<int> (1,context);
  16470. int role= argument<int> (2,context);
  16471. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16472. QModelIndex cell= model->index(row,column);
  16473. QVariant value= model->data(cell,role);
  16474. QScriptValue retval= engine->newVariant(value);
  16475. retval.setProperty("value",QScriptValue(value.toString()));
  16476. return retval;
  16477. }
  16478. /*:241*//*242:*/
  16479. #line 5865 "./typica.w"
  16480. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  16481. {
  16482. QTableView*self= getself<QTableView*> (context);
  16483. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16484. model->clear();
  16485. return QScriptValue();
  16486. }
  16487. /*:242*//*243:*/
  16488. #line 5877 "./typica.w"
  16489. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  16490. {
  16491. QTableView*self= getself<QTableView*> (context);
  16492. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16493. int row= argument<int> (0,context);
  16494. return engine->newVariant(model->removeRow(row));
  16495. }
  16496. /*:243*//*244:*/
  16497. #line 5890 "./typica.w"
  16498. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  16499. {
  16500. QTableView*self= getself<QTableView*> (context);
  16501. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16502. QVariant value= argument<QVariant> (0,context);
  16503. int column= argument<int> (1,context);
  16504. return engine->newVariant(model->findData(value,column));
  16505. }
  16506. /*:244*//*245:*/
  16507. #line 5903 "./typica.w"
  16508. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  16509. {
  16510. setQWidgetProperties(value,engine);
  16511. value.setProperty("columnArray",
  16512. engine->newFunction(SaltTable_columnArray));
  16513. value.setProperty("quotedColumnArray",
  16514. engine->newFunction(SaltTable_quotedColumnArray));
  16515. value.setProperty("bindableColumnArray",
  16516. engine->newFunction(SaltTable_bindableColumnArray));
  16517. value.setProperty("bindableQuotedColumnArray",
  16518. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  16519. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  16520. value.setProperty("data",engine->newFunction(SaltTable_data));
  16521. value.setProperty("model",engine->newFunction(SaltTable_model));
  16522. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  16523. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  16524. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  16525. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  16526. }
  16527. /*:245*//*247:*/
  16528. #line 5940 "./typica.w"
  16529. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16530. {
  16531. setQComboBoxProperties(value,engine);
  16532. }
  16533. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16534. {
  16535. setQWidgetProperties(value,engine);
  16536. value.setProperty("currentData",
  16537. engine->newFunction(QComboBox_currentData));
  16538. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  16539. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  16540. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  16541. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  16542. }
  16543. QScriptValue QComboBox_currentData(QScriptContext*context,
  16544. QScriptEngine*engine)
  16545. {
  16546. QComboBox*self= getself<QComboBox*> (context);
  16547. return QScriptValue(engine,
  16548. self->itemData(self->currentIndex()).toString());
  16549. }
  16550. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  16551. {
  16552. QComboBox*self= getself<QComboBox*> (context);
  16553. self->addItem(argument<QString> (0,context));
  16554. return QScriptValue();
  16555. }
  16556. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  16557. {
  16558. QComboBox*self= getself<QComboBox*> (context);
  16559. self->setModel(argument<QAbstractItemModel*> (0,context));
  16560. return QScriptValue();
  16561. }
  16562. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  16563. {
  16564. QComboBox*self= getself<QComboBox*> (context);
  16565. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  16566. }
  16567. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  16568. {
  16569. QComboBox*self= getself<QComboBox*> (context);
  16570. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  16571. }
  16572. #line 1 "./abouttypica.w"
  16573. /*:247*//*260:*/
  16574. #line 388 "./units.w"
  16575. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  16576. {
  16577. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  16578. argument<Units::Unit> (1,context),
  16579. argument<Units::Unit> (2,context)));
  16580. }
  16581. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  16582. QScriptEngine*)
  16583. {
  16584. return QScriptValue(Units::convertRelativeTemperature(
  16585. argument<double> (0,context),
  16586. argument<Units::Unit> (1,context),
  16587. argument<Units::Unit> (2,context)));
  16588. }
  16589. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  16590. {
  16591. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  16592. }
  16593. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  16594. {
  16595. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  16596. argument<Units::Unit> (1,context),
  16597. argument<Units::Unit> (2,context)));
  16598. }
  16599. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  16600. {
  16601. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  16602. }
  16603. /*:260*//*263:*/
  16604. #line 436 "./units.w"
  16605. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  16606. {
  16607. return engine->newVariant(QVariant(value));
  16608. }
  16609. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  16610. {
  16611. value= sv.toVariant().value<Units::Unit> ();
  16612. }
  16613. /*:263*//*273:*/
  16614. #line 149 "./measurement.w"
  16615. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  16616. {
  16617. QScriptValue object;
  16618. if(context->argumentCount()==2||context->argumentCount()==3)
  16619. {
  16620. double measurement= argument<double> (0,context);
  16621. QTime timestamp= argument<QTime> (1,context);
  16622. Units::Unit unit= Units::Fahrenheit;
  16623. if(context->argumentCount()==3)
  16624. {
  16625. unit= argument<Units::Unit> (2,context);
  16626. }
  16627. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  16628. setMeasurementProperties(object,engine);
  16629. }
  16630. else
  16631. {
  16632. context->throwError("Incorrect number of arguments passed to "
  16633. "Measurement::Measurement(). This method takes two "
  16634. "or three arguments.");
  16635. }
  16636. return object;
  16637. }
  16638. /*:273*//*274:*/
  16639. #line 176 "./measurement.w"
  16640. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  16641. {
  16642. }
  16643. /*:274*//*275:*/
  16644. #line 184 "./measurement.w"
  16645. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  16646. {
  16647. QVariant var;
  16648. var.setValue(measurement);
  16649. return engine->newVariant(var);
  16650. }
  16651. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  16652. {
  16653. measurement= value.toVariant().value<Measurement> ();
  16654. }
  16655. #line 6009 "./typica.w"
  16656. /*:275*//*293:*/
  16657. #line 6586 "./typica.w"
  16658. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  16659. {
  16660. QScriptValue object;
  16661. if(context->argumentCount()==1)
  16662. {
  16663. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  16664. QScriptEngine::ScriptOwnership);
  16665. setDAQProperties(object,engine);
  16666. }
  16667. else if(context->argumentCount()==2)
  16668. {
  16669. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  16670. argument<QString> (1,context)),
  16671. QScriptEngine::ScriptOwnership);
  16672. setDAQProperties(object,engine);
  16673. }
  16674. else
  16675. {
  16676. context->throwError("Incorrect number of arguments passed to DAQ"
  16677. "constructor. The DAQ constructor takes one"
  16678. "string as an argument specifying a device name."
  16679. "Example: Dev1");
  16680. }
  16681. return object;
  16682. }
  16683. /*:293*//*294:*/
  16684. #line 6616 "./typica.w"
  16685. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  16686. {
  16687. setQObjectProperties(value,engine);
  16688. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  16689. }
  16690. /*:294*//*295:*/
  16691. #line 6626 "./typica.w"
  16692. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  16693. {
  16694. DAQ*self= getself<DAQ*> (context);
  16695. QScriptValue object;
  16696. if(self)
  16697. {
  16698. object=
  16699. engine->newQObject(self->newChannel(argument<int> (0,context),
  16700. argument<int> (1,context)));
  16701. setChannelProperties(object,engine);
  16702. }
  16703. return object;
  16704. }
  16705. /*:295*//*302:*/
  16706. #line 6782 "./typica.w"
  16707. QScriptValue constructFakeDAQ(QScriptContext*context,
  16708. QScriptEngine*engine)
  16709. {
  16710. QScriptValue object;
  16711. if(context->argumentCount()==1)
  16712. {
  16713. object=
  16714. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  16715. QScriptEngine::ScriptOwnership);
  16716. setFakeDAQProperties(object,engine);
  16717. }
  16718. else
  16719. {
  16720. context->throwError("Incorrect number of arguments passed to DAQ"
  16721. "constructor. The DAQ constructor takes one"
  16722. "string as an argument specifying a device name."
  16723. "Example: Dev1");
  16724. }
  16725. return object;
  16726. }
  16727. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  16728. {
  16729. setQObjectProperties(value,engine);
  16730. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  16731. }
  16732. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  16733. {
  16734. FakeDAQ*self= getself<FakeDAQ*> (context);
  16735. QScriptValue object;
  16736. if(self)
  16737. {
  16738. object=
  16739. engine->newQObject(self->newChannel(argument<int> (0,context),
  16740. argument<int> (1,context)));
  16741. setChannelProperties(object,engine);
  16742. }
  16743. return object;
  16744. }
  16745. /*:302*//*306:*/
  16746. #line 6873 "./typica.w"
  16747. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  16748. {
  16749. setQObjectProperties(value,engine);
  16750. }
  16751. /*:306*//*313:*/
  16752. #line 7065 "./typica.w"
  16753. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  16754. {
  16755. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  16756. setLinearCalibratorProperties(object,engine);
  16757. return object;
  16758. }
  16759. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  16760. {
  16761. setQObjectProperties(value,engine);
  16762. }
  16763. /*:313*//*318:*/
  16764. #line 7203 "./typica.w"
  16765. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  16766. {
  16767. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  16768. setLinearSplineInterpolatorProperties(object,engine);
  16769. return object;
  16770. }
  16771. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  16772. {
  16773. setQObjectProperties(value,engine);
  16774. }
  16775. /*:318*//*328:*/
  16776. #line 7409 "./typica.w"
  16777. QScriptValue constructTemperatureDisplay(QScriptContext*,
  16778. QScriptEngine*engine)
  16779. {
  16780. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  16781. setTemperatureDisplayProperties(object,engine);
  16782. return object;
  16783. }
  16784. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  16785. {
  16786. setQLCDNumberProperties(value,engine);
  16787. value.setProperty("setDisplayUnits",
  16788. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  16789. }
  16790. /*:328*//*329:*/
  16791. #line 7433 "./typica.w"
  16792. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  16793. {
  16794. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  16795. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  16796. return QScriptValue();
  16797. }
  16798. /*:329*//*336:*/
  16799. #line 7570 "./typica.w"
  16800. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  16801. QScriptEngine*engine)
  16802. {
  16803. QScriptValue object=
  16804. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  16805. setMeasurementTimeOffsetProperties(object,engine);
  16806. return object;
  16807. }
  16808. void setMeasurementTimeOffsetProperties(QScriptValue value,
  16809. QScriptEngine*engine)
  16810. {
  16811. setQObjectProperties(value,engine);
  16812. }
  16813. /*:336*//*341:*/
  16814. #line 7679 "./typica.w"
  16815. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  16816. {
  16817. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  16818. return object;
  16819. }
  16820. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  16821. {
  16822. setQObjectProperties(value,engine);
  16823. }
  16824. /*:341*//*346:*/
  16825. #line 7776 "./typica.w"
  16826. QScriptValue constructZeroEmitter(QScriptContext*context,
  16827. QScriptEngine*engine)
  16828. {
  16829. QScriptValue object=
  16830. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  16831. setZeroEmitterProperties(object,engine);
  16832. return object;
  16833. }
  16834. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  16835. {
  16836. setQObjectProperties(value,engine);
  16837. }
  16838. /*:346*//*351:*/
  16839. #line 7856 "./typica.w"
  16840. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  16841. QScriptEngine*engine)
  16842. {
  16843. QScriptValue object=
  16844. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  16845. setMeasurementAdapterProperties(object,engine);
  16846. return object;
  16847. }
  16848. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  16849. {
  16850. setQObjectProperties(value,engine);
  16851. }
  16852. /*:351*//*368:*/
  16853. #line 8318 "./typica.w"
  16854. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  16855. {
  16856. QScriptValue object= engine->newQObject(new GraphView);
  16857. setGraphViewProperties(object,engine);
  16858. return object;
  16859. }
  16860. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  16861. {
  16862. setQGraphicsViewProperties(value,engine);
  16863. }
  16864. /*:368*//*391:*/
  16865. #line 8956 "./typica.w"
  16866. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  16867. {
  16868. QScriptValue object= engine->newQObject(new ZoomLog);
  16869. setZoomLogProperties(object,engine);
  16870. return object;
  16871. }
  16872. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  16873. {
  16874. setQTableViewProperties(value,engine);
  16875. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  16876. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  16877. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  16878. value.setProperty("restoreState",
  16879. engine->newFunction(ZoomLog_restoreState));
  16880. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  16881. value.setProperty("saveTemporary",
  16882. engine->newFunction(ZoomLog_saveTemporary));
  16883. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  16884. }
  16885. /*:391*//*392:*/
  16886. #line 8983 "./typica.w"
  16887. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  16888. {
  16889. ZoomLog*self= getself<ZoomLog*> (context);
  16890. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  16891. return QScriptValue(engine,retval);
  16892. }
  16893. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  16894. {
  16895. ZoomLog*self= getself<ZoomLog*> (context);
  16896. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  16897. return QScriptValue(engine,retval);
  16898. }
  16899. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  16900. QScriptEngine*engine)
  16901. {
  16902. ZoomLog*self= getself<ZoomLog*> (context);
  16903. QString filename= QDir::tempPath();
  16904. filename.append("/");
  16905. filename.append(QUuid::createUuid().toString());
  16906. filename.append(".xml");
  16907. QFile*file= new QFile(filename);
  16908. self->saveXML(file);
  16909. file->close();
  16910. delete file;
  16911. return QScriptValue(engine,filename);
  16912. }
  16913. /*:392*//*393:*/
  16914. #line 9031 "./typica.w"
  16915. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  16916. {
  16917. ZoomLog*self= getself<ZoomLog*> (context);
  16918. QString key= argument<QString> (0,context);
  16919. int columns= argument<int> (1,context);
  16920. QSettings settings;
  16921. for(int i= 0;i<columns;i++)
  16922. {
  16923. if(self->columnWidth(i))
  16924. {
  16925. settings.beginGroup(key);
  16926. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  16927. settings.endGroup();
  16928. }
  16929. }
  16930. return QScriptValue();
  16931. }
  16932. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  16933. {
  16934. ZoomLog*self= getself<ZoomLog*> (context);
  16935. QString key= argument<QString> (0,context);
  16936. int columns= argument<int> (1,context);
  16937. QSettings settings;
  16938. for(int i= 0;i<columns;i++)
  16939. {
  16940. settings.beginGroup(key);
  16941. self->setColumnWidth(i,
  16942. settings.value(QString("%1").arg(i),80).toInt());
  16943. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  16944. {
  16945. self->setColumnWidth(i,80);
  16946. }
  16947. settings.endGroup();
  16948. }
  16949. return QScriptValue();
  16950. }
  16951. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  16952. {
  16953. ZoomLog*self= getself<ZoomLog*> (context);
  16954. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  16955. }
  16956. /*:393*//*394:*/
  16957. #line 9084 "./typica.w"
  16958. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  16959. {
  16960. ZoomLog*self= getself<ZoomLog*> (context);
  16961. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  16962. return QScriptValue();
  16963. }
  16964. /*:394*//*429:*/
  16965. #line 9904 "./typica.w"
  16966. QScriptValue constructAnnotationButton(QScriptContext*context,
  16967. QScriptEngine*engine)
  16968. {
  16969. QScriptValue object=
  16970. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  16971. setAnnotationButtonProperties(object,engine);
  16972. return object;
  16973. }
  16974. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  16975. {
  16976. setQPushButtonProperties(value,engine);
  16977. }
  16978. /*:429*//*437:*/
  16979. #line 10047 "./typica.w"
  16980. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  16981. QScriptEngine*engine)
  16982. {
  16983. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  16984. argument<QString> (0,context),argument<QString> (1,context)));
  16985. setAnnotationSpinBoxProperties(object,engine);
  16986. return object;
  16987. }
  16988. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16989. {
  16990. setQDoubleSpinBoxProperties(value,engine);
  16991. }
  16992. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16993. {
  16994. setQAbstractSpinBoxProperties(value,engine);
  16995. }
  16996. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16997. {
  16998. setQWidgetProperties(value,engine);
  16999. }
  17000. /*:437*//*458:*/
  17001. #line 10466 "./typica.w"
  17002. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  17003. {
  17004. QScriptValue object= engine->newQObject(new TimerDisplay);
  17005. setTimerDisplayProperties(object,engine);
  17006. return object;
  17007. }
  17008. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  17009. {
  17010. setQLCDNumberProperties(value,engine);
  17011. }
  17012. /*:458*//*485:*/
  17013. #line 10961 "./typica.w"
  17014. QScriptValue constructWidgetDecorator(QScriptContext*context,
  17015. QScriptEngine*engine)
  17016. {
  17017. QWidget*widget= argument<QWidget*> (0,context);
  17018. QString text= argument<QString> (1,context);
  17019. Qt::Orientations orientation;
  17020. switch(argument<int> (2,context))
  17021. {
  17022. case 2:
  17023. orientation= Qt::Vertical;
  17024. break;
  17025. default:
  17026. orientation= Qt::Horizontal;
  17027. break;
  17028. }
  17029. QScriptValue object=
  17030. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  17031. setWidgetDecoratorProperties(object,engine);
  17032. return object;
  17033. }
  17034. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  17035. {
  17036. setQWidgetProperties(value,engine);
  17037. }
  17038. /*:485*//*498:*/
  17039. #line 11242 "./typica.w"
  17040. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  17041. {
  17042. QScriptValue object= engine->newQObject(new LogEditWindow);
  17043. return object;
  17044. }
  17045. /*:498*//*517:*/
  17046. #line 11770 "./typica.w"
  17047. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  17048. {
  17049. QIODevice*device= argument<QIODevice*> (0,context);
  17050. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  17051. argument<int> (1,context)));
  17052. object.setProperty("input",engine->newFunction(XMLInput_input));
  17053. return object;
  17054. }
  17055. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  17056. {
  17057. XMLInput*self= getself<XMLInput*> (context);
  17058. self->input();
  17059. return QScriptValue();
  17060. }
  17061. /*:517*//*531:*/
  17062. #line 157 "./webview.w"
  17063. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  17064. {
  17065. QScriptValue object= engine->newQObject(new TypicaWebView);
  17066. setQWebViewProperties(object,engine);
  17067. return object;
  17068. }
  17069. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  17070. {
  17071. setQWidgetProperties(value,engine);
  17072. }
  17073. /*:531*//*532:*/
  17074. #line 174 "./webview.w"
  17075. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  17076. QStack<QLayout*> *layoutStack)
  17077. {
  17078. TypicaWebView*view= new TypicaWebView;
  17079. if(element.hasAttribute("id"))
  17080. {
  17081. view->setObjectName(element.attribute("id"));
  17082. }
  17083. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17084. layout->addWidget(view);
  17085. }
  17086. /*:532*//*537:*/
  17087. #line 225 "./webview.w"
  17088. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  17089. {
  17090. QVariant var;
  17091. var.setValue(element);
  17092. QScriptValue object= engine->newVariant(var);
  17093. return object;
  17094. }
  17095. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  17096. {
  17097. element= value.toVariant().value<QWebElement> ();
  17098. }
  17099. /*:537*//*542:*/
  17100. #line 290 "./webview.w"
  17101. template<> QWebElement argument(int arg,QScriptContext*context)
  17102. {
  17103. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  17104. }
  17105. /*:542*//*543:*/
  17106. #line 299 "./webview.w"
  17107. QScriptValue constructWebElement(QScriptContext*context,
  17108. QScriptEngine*engine)
  17109. {
  17110. QWebElement element= argument<QWebElement> (0,context);
  17111. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  17112. return object;
  17113. }
  17114. /*:543*//*611:*/
  17115. #line 13115 "./typica.w"
  17116. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  17117. {
  17118. QScriptValue object= engine->newQObject(new SqlQueryView);
  17119. setSqlQueryViewProperties(object,engine);
  17120. return object;
  17121. }
  17122. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  17123. {
  17124. setQTableViewProperties(value,engine);
  17125. value.setProperty("setHeaderData",
  17126. engine->newFunction(SqlQueryView_setHeaderData));
  17127. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  17128. }
  17129. /*:611*//*612:*/
  17130. #line 13133 "./typica.w"
  17131. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  17132. {
  17133. SqlQueryView*self= getself<SqlQueryView*> (context);
  17134. QString query= argument<QString> (0,context);
  17135. self->setQuery(query);
  17136. self->reset();
  17137. return QScriptValue();
  17138. }
  17139. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  17140. QScriptEngine*)
  17141. {
  17142. SqlQueryView*self= getself<SqlQueryView*> (context);
  17143. int section= argument<int> (0,context);
  17144. QString data= argument<QString> (1,context);
  17145. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  17146. return QScriptValue();
  17147. }
  17148. /*:612*//*620:*/
  17149. #line 13340 "./typica.w"
  17150. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  17151. QStack<QLayout*> *layoutStack)
  17152. {
  17153. QTextEdit*widget= new QTextEdit;
  17154. if(element.hasAttribute("id"))
  17155. {
  17156. widget->setObjectName(element.attribute("id"));
  17157. }
  17158. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17159. layout->addWidget(widget);
  17160. QTextDocument*document= new QTextDocument;
  17161. QFont defaultFont;
  17162. defaultFont.setPointSize(11);
  17163. document->setDefaultFont(defaultFont);
  17164. QTextCursor cursor(document);
  17165. /*621:*/
  17166. #line 13363 "./typica.w"
  17167. QDomNodeList children= element.childNodes();
  17168. for(int i= 0;i<children.count();i++)
  17169. {
  17170. QDomNode current;
  17171. QDomElement currentElement;
  17172. current= children.at(i);
  17173. if(current.isElement())
  17174. {
  17175. currentElement= current.toElement();
  17176. /*622:*/
  17177. #line 13380 "./typica.w"
  17178. if(currentElement.tagName()=="style")
  17179. {
  17180. document->setDefaultStyleSheet(currentElement.text());
  17181. }
  17182. /*:622*//*623:*/
  17183. #line 13391 "./typica.w"
  17184. if(currentElement.tagName()=="html")
  17185. {
  17186. cursor.insertHtml(currentElement.text());
  17187. }
  17188. /*:623*//*624:*/
  17189. #line 13401 "./typica.w"
  17190. if(currentElement.tagName()=="text")
  17191. {
  17192. cursor.insertText(currentElement.text());
  17193. }
  17194. /*:624*//*625:*/
  17195. #line 13411 "./typica.w"
  17196. if(currentElement.tagName()=="table")
  17197. {
  17198. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  17199. ReportTable*table= new ReportTable(frame,currentElement);
  17200. table->setParent(widget);
  17201. if(currentElement.hasAttribute("id"))
  17202. {
  17203. table->setObjectName(currentElement.attribute("id"));
  17204. }
  17205. }
  17206. /*:625*/
  17207. #line 13373 "./typica.w"
  17208. }
  17209. }
  17210. /*:621*/
  17211. #line 13356 "./typica.w"
  17212. widget->setDocument(document);
  17213. }
  17214. /*:620*//*636:*/
  17215. #line 13624 "./typica.w"
  17216. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  17217. {
  17218. QTextEdit*self= getself<QTextEdit*> (context);
  17219. QTextDocument*document= self->document();
  17220. QPrinter printer;
  17221. QPrintDialog printwindow(&printer,self);
  17222. if(printwindow.exec()!=QDialog::Accepted)
  17223. {
  17224. return QScriptValue();
  17225. }
  17226. document->print(&printer);
  17227. return QScriptValue();
  17228. }
  17229. /*:636*//*637:*/
  17230. #line 13642 "./typica.w"
  17231. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  17232. {
  17233. setQAbstractScrollAreaProperties(value,engine);
  17234. value.setProperty("print",engine->newFunction(QTextEdit_print));
  17235. }
  17236. #line 1 "./daterangeselector.w"
  17237. /*:637*//*656:*/
  17238. #line 452 "./daterangeselector.w"
  17239. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  17240. QStack<QLayout*> *layoutStack)
  17241. {
  17242. DateRangeSelector*widget= new DateRangeSelector;
  17243. if(element.hasAttribute("id"))
  17244. {
  17245. widget->setObjectName(element.attribute("id"));
  17246. }
  17247. if(element.hasAttribute("initial"))
  17248. {
  17249. widget->setCurrentIndex(element.attribute("initial").toInt());
  17250. }
  17251. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17252. layout->addWidget(widget);
  17253. }
  17254. /*:656*//*667:*/
  17255. #line 13822 "./typica.w"
  17256. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  17257. QStack<QLayout*> *layoutStack)
  17258. {
  17259. FormArray*widget= new FormArray(element);
  17260. if(element.hasAttribute("id"))
  17261. {
  17262. widget->setObjectName(element.attribute("id"));
  17263. }
  17264. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17265. layout->addWidget(widget);
  17266. }
  17267. /*:667*//*688:*/
  17268. #line 14409 "./typica.w"
  17269. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  17270. QStack<QLayout*> *layoutStack)
  17271. {
  17272. ScaleControl*scale= new ScaleControl;
  17273. if(element.hasAttribute("id"))
  17274. {
  17275. scale->setObjectName(element.attribute("id"));
  17276. }
  17277. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17278. layout->addWidget(scale);
  17279. }
  17280. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  17281. QStack<QLayout*> *layoutStack)
  17282. {
  17283. IntensityControl*scale= new IntensityControl;
  17284. if(element.hasAttribute("id"))
  17285. {
  17286. scale->setObjectName(element.attribute("id"));
  17287. }
  17288. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17289. layout->addWidget(scale);
  17290. }
  17291. /*:688*//*714:*/
  17292. #line 14999 "./typica.w"
  17293. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  17294. {
  17295. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  17296. setDeviceTreeModelProperties(object,engine);
  17297. return object;
  17298. }
  17299. /*:714*//*716:*/
  17300. #line 15022 "./typica.w"
  17301. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  17302. {
  17303. setQAbstractItemModelProperties(value,engine);
  17304. value.setProperty("referenceElement",
  17305. engine->newFunction(DeviceTreeModel_referenceElement));
  17306. }
  17307. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  17308. {
  17309. setQObjectProperties(value,engine);
  17310. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  17311. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  17312. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  17313. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  17314. }
  17315. /*:716*//*717:*/
  17316. #line 15049 "./typica.w"
  17317. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  17318. QScriptEngine*engine)
  17319. {
  17320. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  17321. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  17322. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  17323. QDomElement node;
  17324. QVariantMap retval;
  17325. retval.insert("driver",referenceElement.attribute("driver"));
  17326. for(int i= 0;i<configData.size();i++)
  17327. {
  17328. node= configData.at(i).toElement();
  17329. retval.insert(node.attribute("name"),node.attribute("value"));
  17330. }
  17331. return engine->toScriptValue(retval);
  17332. }
  17333. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  17334. {
  17335. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17336. QModelIndex index= argument<QModelIndex> (0,context);
  17337. int role= argument<int> (1,context);
  17338. return engine->toScriptValue(model->data(index,role));
  17339. }
  17340. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  17341. {
  17342. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17343. int row= 0;
  17344. int column= 0;
  17345. QModelIndex index;
  17346. if(context->argumentCount()> 1)
  17347. {
  17348. row= argument<int> (0,context);
  17349. column= argument<int> (1,context);
  17350. }
  17351. if(context->argumentCount()> 2)
  17352. {
  17353. index= argument<QModelIndex> (2,context);
  17354. }
  17355. QModelIndex retval= model->index(row,column,index);
  17356. return engine->toScriptValue(retval);
  17357. }
  17358. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  17359. QScriptEngine*)
  17360. {
  17361. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17362. QModelIndex index;
  17363. if(context->argumentCount()==1)
  17364. {
  17365. index= argument<QModelIndex> (0,context);
  17366. }
  17367. return QScriptValue(model->rowCount(index));
  17368. }
  17369. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  17370. QScriptEngine*engine)
  17371. {
  17372. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  17373. QModelIndex index;
  17374. if(context->argumentCount()==1)
  17375. {
  17376. index= argument<QModelIndex> (0,context);
  17377. }
  17378. return QScriptValue(engine,model->hasChildren(index));
  17379. }
  17380. /*:717*//*720:*/
  17381. #line 15133 "./typica.w"
  17382. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  17383. {
  17384. QVariant var;
  17385. var.setValue(index);
  17386. QScriptValue object= engine->newVariant(var);
  17387. return object;
  17388. }
  17389. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  17390. {
  17391. index= value.toVariant().value<QModelIndex> ();
  17392. }
  17393. /*:720*//*736:*/
  17394. #line 15431 "./typica.w"
  17395. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  17396. QScriptEngine*engine)
  17397. {
  17398. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  17399. return object;
  17400. }
  17401. /*:736*//*807:*/
  17402. #line 47 "./settings.w"
  17403. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  17404. {
  17405. QScriptValue object= engine->newQObject(new SettingsWindow);
  17406. return object;
  17407. }
  17408. /*:807*//*832:*/
  17409. #line 18011 "./typica.w"
  17410. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  17411. {
  17412. QScriptValue object;
  17413. if(context->argumentCount()==2)
  17414. {
  17415. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  17416. argument<QModelIndex> (1,context)),
  17417. QScriptEngine::ScriptOwnership);
  17418. setModbusRTUDeviceProperties(object,engine);
  17419. }
  17420. else
  17421. {
  17422. context->throwError("Incorrect number of arguments passed to "
  17423. "ModbusRTUDevice constructor. This takes the configuration model "
  17424. "and an index.");
  17425. }
  17426. return object;
  17427. }
  17428. /*:832*//*833:*/
  17429. #line 18033 "./typica.w"
  17430. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  17431. {
  17432. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  17433. QScriptValue object;
  17434. if(self)
  17435. {
  17436. if(self->channels.size()> 0)
  17437. {
  17438. object= engine->newQObject(self->channels.at(0));
  17439. setChannelProperties(object,engine);
  17440. }
  17441. }
  17442. return object;
  17443. }
  17444. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  17445. {
  17446. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  17447. QScriptValue object;
  17448. if(self)
  17449. {
  17450. if(self->channels.size()> 1)
  17451. {
  17452. object= engine->newQObject(self->channels.at(1));
  17453. setChannelProperties(object,engine);
  17454. }
  17455. }
  17456. return object;
  17457. }
  17458. /*:833*//*834:*/
  17459. #line 18066 "./typica.w"
  17460. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17461. {
  17462. setQObjectProperties(value,engine);
  17463. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  17464. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  17465. }
  17466. /*:834*//*852:*/
  17467. #line 357 "./unsupportedserial.w"
  17468. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  17469. {
  17470. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  17471. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  17472. QScriptValue object= engine->newQObject(device);
  17473. setQObjectProperties(object,engine);
  17474. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  17475. return object;
  17476. }
  17477. /*:852*//*857:*/
  17478. #line 430 "./unsupportedserial.w"
  17479. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  17480. {
  17481. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  17482. QScriptValue object;
  17483. if(self)
  17484. {
  17485. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  17486. setChannelProperties(object,engine);
  17487. }
  17488. return object;
  17489. }
  17490. /*:857*//*864:*/
  17491. #line 630 "./unsupportedserial.w"
  17492. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  17493. {
  17494. return engine->toScriptValue<QTime> (QTime::currentTime());
  17495. }
  17496. /*:864*//*868:*/
  17497. #line 667 "./unsupportedserial.w"
  17498. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  17499. {
  17500. QScriptValue object= engine->newQObject(new QextSerialPort());
  17501. setSerialPortProperties(object,engine);
  17502. return object;
  17503. }
  17504. /*:868*//*869:*/
  17505. #line 678 "./unsupportedserial.w"
  17506. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  17507. {
  17508. setQIODeviceProperties(value,engine);
  17509. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  17510. }
  17511. /*:869*//*870:*/
  17512. #line 687 "./unsupportedserial.w"
  17513. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  17514. {
  17515. QextSerialPort*self= getself<QextSerialPort*> (context);
  17516. self->flush();
  17517. return QScriptValue();
  17518. }
  17519. #line 18617 "./typica.w"
  17520. #line 1 "./phidgets.w"
  17521. /*:870*//*891:*/
  17522. #line 456 "./phidgets.w"
  17523. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  17524. {
  17525. if(context->argumentCount()!=1)
  17526. {
  17527. context->throwError("Incorrect number of arguments passed to "
  17528. "PhidgetsTemperatureSensor constructor. This takes "
  17529. "a QModelIndex.");
  17530. }
  17531. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  17532. setQObjectProperties(object,engine);
  17533. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  17534. return object;
  17535. }
  17536. /*:891*//*892:*/
  17537. #line 473 "./phidgets.w"
  17538. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  17539. {
  17540. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  17541. QScriptValue object;
  17542. if(self)
  17543. {
  17544. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  17545. setChannelProperties(object,engine);
  17546. }
  17547. return object;
  17548. }
  17549. #line 18619 "./typica.w"
  17550. /*:892*//*910:*/
  17551. #line 151 "./rate.w"
  17552. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  17553. {
  17554. int cachetime= 1;
  17555. int scaletime= 1;
  17556. if(context->argumentCount()> 0)
  17557. {
  17558. cachetime= argument<int> (0,context);
  17559. if(context->argumentCount()> 1)
  17560. {
  17561. scaletime= argument<int> (1,context);
  17562. }
  17563. }
  17564. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  17565. setRateOfChangeProperties(object,engine);
  17566. return object;
  17567. }
  17568. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  17569. {
  17570. setQObjectProperties(value,engine);
  17571. }
  17572. /*:910*//*935:*/
  17573. #line 614 "./dataqsdk.w"
  17574. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  17575. {
  17576. QScriptValue object;
  17577. if(context->argumentCount()==1)
  17578. {
  17579. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  17580. QScriptEngine::ScriptOwnership);
  17581. setDataqSdkDeviceProperties(object,engine);
  17582. }
  17583. else
  17584. {
  17585. context->throwError("Incorrect number of arguments passed to "
  17586. "DataqSdkDevice. The constructor takes one string "
  17587. "as an argument specifying a device name. "
  17588. "Example: Dev1");
  17589. }
  17590. return object;
  17591. }
  17592. /*:935*//*936:*/
  17593. #line 637 "./dataqsdk.w"
  17594. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17595. {
  17596. setQObjectProperties(value,engine);
  17597. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  17598. }
  17599. /*:936*//*937:*/
  17600. #line 647 "./dataqsdk.w"
  17601. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  17602. {
  17603. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  17604. QScriptValue object;
  17605. if(self)
  17606. {
  17607. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  17608. setChannelProperties(object,engine);
  17609. }
  17610. return object;
  17611. }
  17612. /*:937*//*962:*/
  17613. #line 80 "./scales.w"
  17614. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  17615. {
  17616. QScriptValue object;
  17617. QString labelText= "";
  17618. if(context->argumentCount()==1)
  17619. {
  17620. labelText= argument<QString> (0,context);
  17621. }
  17622. object= engine->newQObject(new DragLabel(labelText));
  17623. setDragLabelProperties(object,engine);
  17624. return object;
  17625. }
  17626. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  17627. {
  17628. setQLabelProperties(value,engine);
  17629. }
  17630. /*:962*//*972:*/
  17631. #line 272 "./scales.w"
  17632. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  17633. {
  17634. return engine->newVariant(QVariant((int)(value)));
  17635. }
  17636. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  17637. {
  17638. value= (BaudRateType)(sv.toVariant().toInt());
  17639. }
  17640. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  17641. {
  17642. return engine->newVariant(QVariant((int)(value)));
  17643. }
  17644. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  17645. {
  17646. value= (DataBitsType)(sv.toVariant().toInt());
  17647. }
  17648. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  17649. {
  17650. return engine->newVariant(QVariant((int)(value)));
  17651. }
  17652. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  17653. {
  17654. value= (ParityType)(sv.toVariant().toInt());
  17655. }
  17656. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  17657. {
  17658. return engine->newVariant(QVariant((int)(value)));
  17659. }
  17660. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  17661. {
  17662. value= (StopBitsType)(sv.toVariant().toInt());
  17663. }
  17664. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  17665. {
  17666. return engine->newVariant(QVariant((int)(value)));
  17667. }
  17668. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  17669. {
  17670. value= (FlowType)(sv.toVariant().toInt());
  17671. }
  17672. /*:972*//*975:*/
  17673. #line 341 "./scales.w"
  17674. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  17675. {
  17676. setQIODeviceProperties(value,engine);
  17677. }
  17678. /*:975*//*976:*/
  17679. #line 349 "./scales.w"
  17680. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  17681. {
  17682. QScriptValue object;
  17683. if(context->argumentCount()==1)
  17684. {
  17685. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  17686. setSerialScaleProperties(object,engine);
  17687. }
  17688. else
  17689. {
  17690. context->throwError("Incorrect number of arguments passed to "
  17691. "SerialScale. The constructor takes one string "
  17692. "as an argument specifying a port name.");
  17693. }
  17694. return object;
  17695. }
  17696. /*:976*//*998:*/
  17697. #line 278 "./valueannotation.w"
  17698. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  17699. {
  17700. QScriptValue object= engine->newQObject(new ValueAnnotation);
  17701. setValueAnnotationProperties(object,engine);
  17702. return object;
  17703. }
  17704. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  17705. {
  17706. setQObjectProperties(value,engine);
  17707. }
  17708. #line 18840 "./typica.w"
  17709. /*:998*/
  17710. #line 530 "./typica.w"
  17711. /*590:*/
  17712. #line 12758 "./typica.w"
  17713. void messageFileOutput(QtMsgType type,const char*msg)
  17714. {
  17715. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  17716. output.open(QIODevice::WriteOnly|QIODevice::Append);
  17717. QTextStream outstream(&output);
  17718. outstream<<msg<<"\r\n";
  17719. }
  17720. /*:590*/
  17721. #line 531 "./typica.w"
  17722. /*587:*/
  17723. #line 12719 "./typica.w"
  17724. int main(int argc,char**argv)
  17725. {
  17726. int*c= &argc;
  17727. Application app(*c,argv);
  17728. QSettings settings;
  17729. /*588:*/
  17730. #line 12745 "./typica.w"
  17731. if(settings.value("settings/advanced/logging",false).toBool())
  17732. {
  17733. qInstallMsgHandler(messageFileOutput);
  17734. }
  17735. /*:588*/
  17736. #line 12725 "./typica.w"
  17737. /*591:*/
  17738. #line 12771 "./typica.w"
  17739. QStringList themeSearchPath= QIcon::themeSearchPaths();
  17740. themeSearchPath.append(":/resources/icons/tango");
  17741. QIcon::setThemeSearchPaths(themeSearchPath);
  17742. QIcon::setThemeName(":/resources/icons/tango");
  17743. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  17744. /*:591*/
  17745. #line 12726 "./typica.w"
  17746. /*592:*/
  17747. #line 12791 "./typica.w"
  17748. QFile entypo(":/resources/fonts/entypo.ttf");
  17749. entypo.open(QIODevice::ReadOnly);
  17750. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  17751. entypo.close();
  17752. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  17753. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  17754. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  17755. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  17756. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  17757. /*:592*/
  17758. #line 12727 "./typica.w"
  17759. /*746:*/
  17760. #line 15651 "./typica.w"
  17761. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  17762. /*:746*//*756:*/
  17763. #line 15893 "./typica.w"
  17764. app.registerDeviceConfigurationWidget("nidaqmxbase",
  17765. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  17766. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  17767. NiDaqMxBase9211ConfWidget::staticMetaObject);
  17768. app.registerDeviceConfigurationWidget("ni9211seriestc",
  17769. Ni9211TcConfWidget::staticMetaObject);
  17770. /*:756*//*764:*/
  17771. #line 16124 "./typica.w"
  17772. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  17773. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  17774. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  17775. /*:764*//*788:*/
  17776. #line 17089 "./typica.w"
  17777. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  17778. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  17779. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  17780. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  17781. /*:788*//*793:*/
  17782. #line 17174 "./typica.w"
  17783. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  17784. /*:793*//*796:*/
  17785. #line 17244 "./typica.w"
  17786. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  17787. /*:796*//*799:*/
  17788. #line 17371 "./typica.w"
  17789. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  17790. #line 1 "./freeannotation.w"
  17791. /*:799*//*803:*/
  17792. #line 57 "./freeannotation.w"
  17793. app.registerDeviceConfigurationWidget("freeannotation",
  17794. FreeAnnotationConfWidget::staticMetaObject);
  17795. #line 17375 "./typica.w"
  17796. #line 1 "./settings.w"
  17797. /*:803*//*837:*/
  17798. #line 18607 "./typica.w"
  17799. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  17800. /*:837*//*847:*/
  17801. #line 264 "./unsupportedserial.w"
  17802. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  17803. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  17804. app.registerDeviceConfigurationWidget("unsupporteddevice",
  17805. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  17806. /*:847*//*878:*/
  17807. #line 181 "./phidgets.w"
  17808. app.registerDeviceConfigurationWidget("phidgets1048",
  17809. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  17810. app.registerDeviceConfigurationWidget("phidgets1048channel",
  17811. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  17812. /*:878*//*898:*/
  17813. #line 18741 "./typica.w"
  17814. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  17815. /*:898*//*902:*/
  17816. #line 18830 "./typica.w"
  17817. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  17818. #line 1 "./rate.w"
  17819. /*:902*//*914:*/
  17820. #line 253 "./rate.w"
  17821. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  17822. /*:914*//*955:*/
  17823. #line 1233 "./dataqsdk.w"
  17824. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  17825. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  17826. DataqSdkChannelConfWidget::staticMetaObject);
  17827. /*:955*//*980:*/
  17828. #line 490 "./scales.w"
  17829. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  17830. /*:980*//*988:*/
  17831. #line 138 "./valueannotation.w"
  17832. app.registerDeviceConfigurationWidget("valueannotation",
  17833. ValueAnnotationConfWidget::staticMetaObject);
  17834. /*:988*/
  17835. #line 12729 "./typica.w"
  17836. /*593:*/
  17837. #line 12808 "./typica.w"
  17838. if(settings.value("database/exists","false").toString()=="true")
  17839. {
  17840. /*598:*/
  17841. #line 12930 "./typica.w"
  17842. QSqlDatabase database=
  17843. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  17844. database.setConnectOptions("application_name=Typica");
  17845. database.setHostName(settings.value("database/hostname").toString());
  17846. database.setDatabaseName(settings.value("database/dbname").toString());
  17847. database.setUserName(settings.value("database/user").toString());
  17848. database.setPassword(settings.value("database/password").toString());
  17849. if(!database.open())
  17850. {
  17851. settings.setValue("database/exists","false");
  17852. }
  17853. else
  17854. {
  17855. database.close();
  17856. }
  17857. /*:598*/
  17858. #line 12811 "./typica.w"
  17859. }
  17860. if(settings.value("database/exists","false").toString()=="false")
  17861. {
  17862. /*597:*/
  17863. #line 12921 "./typica.w"
  17864. SqlConnectionSetup dialog;
  17865. dialog.exec();
  17866. /*:597*/
  17867. #line 12815 "./typica.w"
  17868. }
  17869. /*:593*/
  17870. #line 12730 "./typica.w"
  17871. /*167:*/
  17872. #line 3836 "./typica.w"
  17873. QStringList arguments= QCoreApplication::arguments();
  17874. int position= arguments.indexOf("-c");
  17875. QString filename= QString();
  17876. if(position!=-1)
  17877. {
  17878. if(arguments.size()>=position+1)
  17879. {
  17880. filename= arguments.at(position+1);
  17881. }
  17882. }
  17883. if(filename.isEmpty())
  17884. {
  17885. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  17886. settings.value("config","").toString());
  17887. }
  17888. QDir directory;
  17889. if(!filename.isEmpty())
  17890. {
  17891. QFile file(filename);
  17892. QFileInfo info(filename);
  17893. directory= info.dir();
  17894. settings.setValue("config",directory.path());
  17895. if(file.open(QIODevice::ReadOnly))
  17896. {
  17897. app.configuration()->setContent(&file,true);
  17898. }
  17899. }
  17900. /*168:*/
  17901. #line 3870 "./typica.w"
  17902. QDomElement root= app.configuration()->documentElement();
  17903. QDomNodeList children= root.childNodes();
  17904. QString replacementDoc;
  17905. QDomDocument includedDoc;
  17906. QDomDocumentFragment fragment;
  17907. for(int i= 0;i<children.size();i++)
  17908. {
  17909. QDomNode currentNode= children.at(i);
  17910. QDomElement currentElement;
  17911. if(currentNode.nodeName()=="include")
  17912. {
  17913. currentElement= currentNode.toElement();
  17914. if(currentElement.hasAttribute("src"))
  17915. {
  17916. replacementDoc= directory.path();
  17917. replacementDoc.append('/');
  17918. replacementDoc.append(currentElement.attribute("src"));
  17919. QFile doc(replacementDoc);
  17920. if(doc.open(QIODevice::ReadOnly))
  17921. {
  17922. includedDoc.setContent(&doc,true);
  17923. fragment= includedDoc.createDocumentFragment();
  17924. fragment.appendChild(includedDoc.documentElement());
  17925. root.replaceChild(fragment,currentNode);
  17926. doc.close();
  17927. }
  17928. }
  17929. }
  17930. }
  17931. /*:168*/
  17932. #line 3864 "./typica.w"
  17933. /*:167*/
  17934. #line 12731 "./typica.w"
  17935. /*7:*/
  17936. #line 659 "./typica.w"
  17937. QScriptEngine*engine= new QScriptEngine;
  17938. QScriptValue constructor;
  17939. QScriptValue value;
  17940. /*:7*//*17:*/
  17941. #line 856 "./typica.w"
  17942. constructor= engine->newFunction(constructQWidget);
  17943. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  17944. engine->globalObject().setProperty("QWidget",value);
  17945. /*:17*//*28:*/
  17946. #line 1102 "./typica.w"
  17947. constructor= engine->newFunction(constructQMainWindow);
  17948. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  17949. constructor);
  17950. engine->globalObject().setProperty("QMainWindow",value);
  17951. /*:28*//*39:*/
  17952. #line 1307 "./typica.w"
  17953. constructor= engine->newFunction(constructQFrame);
  17954. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  17955. engine->globalObject().setProperty("QFrame",value);
  17956. /*:39*//*42:*/
  17957. #line 1340 "./typica.w"
  17958. constructor= engine->newFunction(constructQLabel);
  17959. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  17960. engine->globalObject().setProperty("QLabel",value);
  17961. /*:42*//*45:*/
  17962. #line 1378 "./typica.w"
  17963. constructor= engine->newFunction(constructQLineEdit);
  17964. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  17965. engine->globalObject().setProperty("QLineEdit",value);
  17966. /*:45*//*49:*/
  17967. #line 1425 "./typica.w"
  17968. constructor= engine->newFunction(constructQSplitter);
  17969. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  17970. engine->globalObject().setProperty("QSplitter",value);
  17971. /*:49*//*57:*/
  17972. #line 1614 "./typica.w"
  17973. constructor= engine->newFunction(constructQBoxLayout);
  17974. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  17975. engine->globalObject().setProperty("QBoxLayout",value);
  17976. /*:57*//*61:*/
  17977. #line 1726 "./typica.w"
  17978. constructor= engine->newFunction(constructQAction);
  17979. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  17980. engine->globalObject().setProperty("QAction",value);
  17981. /*:61*//*64:*/
  17982. #line 1785 "./typica.w"
  17983. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  17984. value.setProperty("getOpenFileName",
  17985. engine->newFunction(QFileDialog_getOpenFileName));
  17986. value.setProperty("getSaveFileName",
  17987. engine->newFunction(QFileDialog_getSaveFileName));
  17988. engine->globalObject().setProperty("QFileDialog",value);
  17989. /*:64*//*69:*/
  17990. #line 1900 "./typica.w"
  17991. constructor= engine->newFunction(constructQFile);
  17992. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  17993. engine->globalObject().setProperty("QFile",value);
  17994. /*:69*//*78:*/
  17995. #line 2082 "./typica.w"
  17996. constructor= engine->newFunction(constructQProcess);
  17997. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  17998. engine->globalObject().setProperty("QProcess",value);
  17999. /*:78*//*87:*/
  18000. #line 2216 "./typica.w"
  18001. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  18002. constructor= engine->newFunction(constructQByteArray);
  18003. engine->globalObject().setProperty("QByteArray",constructor);
  18004. /*:87*//*92:*/
  18005. #line 2267 "./typica.w"
  18006. constructor= engine->newFunction(constructQBuffer);
  18007. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  18008. engine->globalObject().setProperty("QBuffer",value);
  18009. /*:92*//*95:*/
  18010. #line 2316 "./typica.w"
  18011. constructor= engine->newFunction(constructXQuery);
  18012. engine->globalObject().setProperty("XQuery",constructor);
  18013. /*:95*//*101:*/
  18014. #line 2418 "./typica.w"
  18015. constructor= engine->newFunction(constructXmlWriter);
  18016. engine->globalObject().setProperty("XmlWriter",constructor);
  18017. /*:101*//*110:*/
  18018. #line 2624 "./typica.w"
  18019. constructor= engine->newFunction(constructXmlReader);
  18020. engine->globalObject().setProperty("XmlReader",constructor);
  18021. /*:110*//*117:*/
  18022. #line 2748 "./typica.w"
  18023. value= engine->newQObject(&settings);
  18024. setQSettingsProperties(value,engine);
  18025. engine->globalObject().setProperty("QSettings",value);
  18026. /*:117*//*121:*/
  18027. #line 2829 "./typica.w"
  18028. constructor= engine->newFunction(constructQLCDNumber);
  18029. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  18030. engine->globalObject().setProperty("QLCDNumber",value);
  18031. /*:121*//*124:*/
  18032. #line 2885 "./typica.w"
  18033. constructor= engine->newFunction(constructQTime);
  18034. engine->globalObject().setProperty("QTime",constructor);
  18035. /*:124*//*146:*/
  18036. #line 3398 "./typica.w"
  18037. constructor= engine->newFunction(constructQPushButton);
  18038. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  18039. engine->globalObject().setProperty("QPushButton",value);
  18040. /*:146*//*153:*/
  18041. #line 3509 "./typica.w"
  18042. constructor= engine->newFunction(constructQSqlQuery);
  18043. engine->globalObject().setProperty("QSqlQuery",constructor);
  18044. /*:153*//*160:*/
  18045. #line 3672 "./typica.w"
  18046. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  18047. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  18048. engine->globalObject().setProperty("sqlToArray",
  18049. engine->newFunction(sqlToArray));
  18050. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  18051. engine->globalObject().setProperty("annotationFromRecord",
  18052. engine->newFunction(annotationFromRecord));
  18053. engine->globalObject().setProperty("setTabOrder",
  18054. engine->newFunction(setTabOrder));
  18055. engine->globalObject().setProperty("saveFileFromDatabase",
  18056. engine->newFunction(saveFileFromDatabase));
  18057. /*:160*//*172:*/
  18058. #line 4037 "./typica.w"
  18059. engine->globalObject().setProperty("createWindow",
  18060. engine->newFunction(createWindow));
  18061. engine->globalObject().setProperty("createReport",
  18062. engine->newFunction(createReport));
  18063. /*:172*//*233:*/
  18064. #line 5582 "./typica.w"
  18065. engine->globalObject().setProperty("findChildObject",
  18066. engine->newFunction(findChildObject));
  18067. /*:233*//*259:*/
  18068. #line 376 "./units.w"
  18069. value= engine->newQMetaObject(&Units::staticMetaObject);
  18070. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  18071. value.setProperty("convertRelativeTemperature",
  18072. engine->newFunction(Units_convertRelativeTemperature));
  18073. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  18074. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  18075. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  18076. engine->globalObject().setProperty("Units",value);
  18077. /*:259*//*264:*/
  18078. #line 449 "./units.w"
  18079. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  18080. #line 6002 "./typica.w"
  18081. /*:264*//*272:*/
  18082. #line 141 "./measurement.w"
  18083. constructor= engine->newFunction(constructMeasurement);
  18084. engine->globalObject().setProperty("Measurement",constructor);
  18085. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  18086. /*:272*//*292:*/
  18087. #line 6572 "./typica.w"
  18088. constructor= engine->newFunction(constructDAQ);
  18089. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  18090. value.setProperty("Fahrenheit",Units::Fahrenheit);
  18091. value.setProperty("Celsius",Units::Celsius);
  18092. value.setProperty("Kelvin",Units::Kelvin);
  18093. value.setProperty("Rankine",Units::Rankine);
  18094. engine->globalObject().setProperty("DAQ",value);
  18095. /*:292*//*301:*/
  18096. #line 6774 "./typica.w"
  18097. constructor= engine->newFunction(constructFakeDAQ);
  18098. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  18099. engine->globalObject().setProperty("FakeDAQ",value);
  18100. /*:301*//*312:*/
  18101. #line 7057 "./typica.w"
  18102. constructor= engine->newFunction(constructLinearCalibrator);
  18103. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  18104. constructor);
  18105. engine->globalObject().setProperty("LinearCalibrator",value);
  18106. /*:312*//*317:*/
  18107. #line 7196 "./typica.w"
  18108. constructor= engine->newFunction(constructLinearSplineInterpolator);
  18109. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  18110. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  18111. /*:317*//*327:*/
  18112. #line 7401 "./typica.w"
  18113. constructor= engine->newFunction(constructTemperatureDisplay);
  18114. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  18115. constructor);
  18116. engine->globalObject().setProperty("TemperatureDisplay",value);
  18117. /*:327*//*335:*/
  18118. #line 7559 "./typica.w"
  18119. constructor= engine->newFunction(constructMeasurementTimeOffset);
  18120. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  18121. constructor);
  18122. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  18123. /*:335*//*340:*/
  18124. #line 7670 "./typica.w"
  18125. constructor= engine->newFunction(constructThresholdDetector);
  18126. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  18127. engine->globalObject().setProperty("ThresholdDetector",value);
  18128. /*:340*//*345:*/
  18129. #line 7769 "./typica.w"
  18130. constructor= engine->newFunction(constructZeroEmitter);
  18131. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  18132. engine->globalObject().setProperty("ZeroEmitter",value);
  18133. /*:345*//*350:*/
  18134. #line 7848 "./typica.w"
  18135. constructor= engine->newFunction(constructMeasurementAdapter);
  18136. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  18137. constructor);
  18138. engine->globalObject().setProperty("MeasurementAdapter",value);
  18139. /*:350*//*367:*/
  18140. #line 8311 "./typica.w"
  18141. constructor= engine->newFunction(constructGraphView);
  18142. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  18143. engine->globalObject().setProperty("GraphView",value);
  18144. /*:367*//*390:*/
  18145. #line 8948 "./typica.w"
  18146. constructor= engine->newFunction(constructZoomLog);
  18147. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  18148. engine->globalObject().setProperty("ZoomLog",value);
  18149. /*:390*//*428:*/
  18150. #line 9896 "./typica.w"
  18151. constructor= engine->newFunction(constructAnnotationButton);
  18152. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  18153. constructor);
  18154. engine->globalObject().setProperty("AnnotationButton",value);
  18155. /*:428*//*436:*/
  18156. #line 10038 "./typica.w"
  18157. constructor= engine->newFunction(constructAnnotationSpinBox);
  18158. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  18159. constructor);
  18160. engine->globalObject().setProperty("AnnotationSpinBox",value);
  18161. /*:436*//*457:*/
  18162. #line 10459 "./typica.w"
  18163. constructor= engine->newFunction(constructTimerDisplay);
  18164. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  18165. engine->globalObject().setProperty("TimerDisplay",value);
  18166. /*:457*//*484:*/
  18167. #line 10953 "./typica.w"
  18168. constructor= engine->newFunction(constructWidgetDecorator);
  18169. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  18170. engine->globalObject().setProperty("WidgetDecorator",value);
  18171. /*:484*//*497:*/
  18172. #line 11235 "./typica.w"
  18173. constructor= engine->newFunction(constructLogEditWindow);
  18174. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  18175. engine->globalObject().setProperty("LogEditWindow",value);
  18176. /*:497*//*516:*/
  18177. #line 11763 "./typica.w"
  18178. constructor= engine->newFunction(constructXMLInput);
  18179. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  18180. engine->globalObject().setProperty("XMLInput",value);
  18181. /*:516*//*530:*/
  18182. #line 149 "./webview.w"
  18183. constructor= engine->newFunction(constructWebView);
  18184. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  18185. engine->globalObject().setProperty("WebView",value);
  18186. /*:530*//*538:*/
  18187. #line 241 "./webview.w"
  18188. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  18189. /*:538*//*541:*/
  18190. #line 283 "./webview.w"
  18191. constructor= engine->newFunction(constructWebElement);
  18192. engine->globalObject().setProperty("WebElement",constructor);
  18193. /*:541*//*552:*/
  18194. #line 12006 "./typica.w"
  18195. value= engine->newQObject(AppInstance);
  18196. engine->globalObject().setProperty("Application",value);
  18197. /*:552*//*610:*/
  18198. #line 13107 "./typica.w"
  18199. constructor= engine->newFunction(constructSqlQueryView);
  18200. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  18201. engine->globalObject().setProperty("SqlQueryView",value);
  18202. /*:610*//*715:*/
  18203. #line 15009 "./typica.w"
  18204. constructor= engine->newFunction(constructDeviceTreeModel);
  18205. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  18206. constructor);
  18207. engine->globalObject().setProperty("DeviceTreeModel",value);
  18208. /*:715*//*721:*/
  18209. #line 15149 "./typica.w"
  18210. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  18211. /*:721*//*737:*/
  18212. #line 15441 "./typica.w"
  18213. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  18214. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  18215. constructor);
  18216. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  18217. /*:737*//*808:*/
  18218. #line 56 "./settings.w"
  18219. constructor= engine->newFunction(constructSettingsWindow);
  18220. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  18221. engine->globalObject().setProperty("SettingsWindow",value);
  18222. #line 1 "./graphsettings.w"
  18223. /*:808*//*831:*/
  18224. #line 18002 "./typica.w"
  18225. constructor= engine->newFunction(constructModbusRTUDevice);
  18226. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  18227. engine->globalObject().setProperty("ModbusRTUDevice",value);
  18228. /*:831*//*851:*/
  18229. #line 350 "./unsupportedserial.w"
  18230. engine->globalObject().setProperty("createDevice",
  18231. engine->newFunction(createDevice));
  18232. /*:851*//*863:*/
  18233. #line 622 "./unsupportedserial.w"
  18234. engine->globalObject().setProperty("getMeasurementTimestamp",
  18235. engine->newFunction(getMeasurementTimestamp));
  18236. /*:863*//*867:*/
  18237. #line 658 "./unsupportedserial.w"
  18238. constructor= engine->newFunction(constructSerialPort);
  18239. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  18240. engine->globalObject().setProperty("SerialPort",value);
  18241. /*:867*//*889:*/
  18242. #line 443 "./phidgets.w"
  18243. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  18244. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  18245. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  18246. /*:889*//*909:*/
  18247. #line 144 "./rate.w"
  18248. constructor= engine->newFunction(constructRateOfChange);
  18249. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  18250. engine->globalObject().setProperty("RateOfChange",value);
  18251. /*:909*//*934:*/
  18252. #line 604 "./dataqsdk.w"
  18253. constructor= engine->newFunction(constructDataqSdkDevice);
  18254. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  18255. engine->globalObject().setProperty("DataqSdkDevice",value);
  18256. /*:934*//*961:*/
  18257. #line 73 "./scales.w"
  18258. constructor= engine->newFunction(constructDragLabel);
  18259. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  18260. engine->globalObject().setProperty("DragLabel",value);
  18261. /*:961*//*969:*/
  18262. #line 239 "./scales.w"
  18263. constructor= engine->newFunction(constructSerialScale);
  18264. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  18265. engine->globalObject().setProperty("SerialScale",value);
  18266. /*:969*//*973:*/
  18267. #line 325 "./scales.w"
  18268. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  18269. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  18270. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  18271. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  18272. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  18273. /*:973*//*997:*/
  18274. #line 271 "./valueannotation.w"
  18275. constructor= engine->newFunction(constructValueAnnotation);
  18276. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  18277. engine->globalObject().setProperty("ValueAnnotation",value);
  18278. /*:997*/
  18279. #line 12732 "./typica.w"
  18280. app.engine= engine;
  18281. /*169:*/
  18282. #line 3918 "./typica.w"
  18283. QString styleText;
  18284. QString programText;
  18285. QDomElement currentElement;
  18286. for(int i= 0;i<children.size();i++)
  18287. {
  18288. QDomNode currentNode= children.at(i);
  18289. if(currentNode.nodeName()=="style")
  18290. {
  18291. currentElement= currentNode.toElement();
  18292. styleText.append(currentElement.text());
  18293. }
  18294. else if(currentNode.nodeName()=="program")
  18295. {
  18296. currentElement= currentNode.toElement();
  18297. programText.append(currentElement.text());
  18298. }
  18299. }
  18300. app.setStyleSheet(styleText);
  18301. QScriptValue result= engine->evaluate(programText);
  18302. /*170:*/
  18303. #line 3943 "./typica.w"
  18304. if(engine->hasUncaughtException())
  18305. {
  18306. int line= engine->uncaughtExceptionLineNumber();
  18307. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18308. result.toString();
  18309. QString trace;
  18310. foreach(trace,engine->uncaughtExceptionBacktrace())
  18311. {
  18312. qDebug()<<trace;
  18313. }
  18314. }
  18315. /*:170*/
  18316. #line 3938 "./typica.w"
  18317. /*:169*/
  18318. #line 12734 "./typica.w"
  18319. int retval= app.exec();
  18320. delete engine;
  18321. return retval;
  18322. }
  18323. /*:587*/
  18324. #line 532 "./typica.w"
  18325. #include "moc_typica.cpp"
  18326. /*:3*/