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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061
  1. /*16:*/
  2. #line 757 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*18:*/
  5. #line 849 "./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. /*:18*//*19:*/
  16. #line 864 "./typica.w"
  17. #include "helpmenu.h"
  18. /*:19*//*247:*/
  19. #line 5783 "./typica.w"
  20. #include "units.h"
  21. #line 1 "./measurement.w"
  22. /*:247*//*510:*/
  23. #line 192 "./webview.w"
  24. #include "webview.h"
  25. /*:510*//*523:*/
  26. #line 370 "./webview.w"
  27. #include "webelement.h"
  28. #line 11713 "./typica.w"
  29. /*:523*//*715:*/
  30. #line 15794 "./typica.w"
  31. #include "qextserialport.h"
  32. #include "qextserialenumerator.h"
  33. /*:715*//*810:*/
  34. #line 124 "./dataqsdk.w"
  35. #ifdef Q_OS_WIN32
  36. #include <windef.h>
  37. #else
  38. #define PASCAL
  39. #endif
  40. /*:810*//*834:*/
  41. #line 862 "./dataqsdk.w"
  42. #include <limits>
  43. /*:834*//*849:*/
  44. #line 62 "./scales.w"
  45. #include "draglabel.h"
  46. /*:849*//*864:*/
  47. #line 335 "./scales.w"
  48. #include "scale.h"
  49. /*:864*/
  50. #line 760 "./typica.w"
  51. /*33:*/
  52. #line 1168 "./typica.w"
  53. class ScriptQMainWindow:public QMainWindow
  54. {
  55. Q_OBJECT
  56. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  57. public:
  58. ScriptQMainWindow();
  59. QString closePrompt();
  60. public slots:
  61. void show();
  62. void saveSizeAndPosition(const QString&key);
  63. void restoreSizeAndPosition(const QString&key);
  64. void displayStatus(const QString&message= QString());
  65. void setClosePrompt(QString prompt);
  66. protected:
  67. void closeEvent(QCloseEvent*event);
  68. void showEvent(QShowEvent*event);
  69. signals:
  70. void aboutToClose(void);
  71. private:
  72. QString cprompt;
  73. };
  74. /*:33*//*143:*/
  75. #line 3366 "./typica.w"
  76. class SqlQueryConnection:public QSqlQuery
  77. {
  78. public:
  79. SqlQueryConnection(const QString&query= QString());
  80. ~SqlQueryConnection();
  81. QSqlQuery*operator->();
  82. private:
  83. QString connection;
  84. QSqlQuery*q;
  85. };
  86. /*:143*//*204:*/
  87. #line 5145 "./typica.w"
  88. class NumericDelegate:public QItemDelegate
  89. {
  90. Q_OBJECT
  91. public:
  92. NumericDelegate(QObject*parent= NULL);
  93. QWidget*createEditor(QWidget*parent,
  94. const QStyleOptionViewItem&option,
  95. const QModelIndex&index)const;
  96. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  97. void setModelData(QWidget*editor,QAbstractItemModel*model,
  98. const QModelIndex&index)const;
  99. void updateEditorGeometry(QWidget*editor,
  100. const QStyleOptionViewItem&option,
  101. const QModelIndex&index)const;
  102. };
  103. /*:204*//*243:*/
  104. #line 433 "./units.w"
  105. Q_DECLARE_METATYPE(Units::Unit)
  106. /*:243*//*248:*/
  107. #line 19 "./measurement.w"
  108. class Measurement:public QVariantMap
  109. {
  110. public:
  111. Measurement(double temperature= 0,QTime time= QTime(),
  112. Units::Unit sc= Units::Fahrenheit);
  113. Measurement(double temperature);
  114. double temperature()const;
  115. QTime time()const;
  116. void setTemperature(double temperature);
  117. void setTime(QTime time);
  118. void setUnit(Units::Unit scale);
  119. Units::Unit scale()const;
  120. Measurement toFahrenheit();
  121. Measurement toCelsius();
  122. Measurement toKelvin();
  123. Measurement toRankine();
  124. };
  125. /*:248*//*253:*/
  126. #line 5847 "./typica.w"
  127. class Channel;
  128. class DAQImplementation;
  129. class DAQ:public QObject
  130. {
  131. Q_OBJECT
  132. Q_ENUMS(ThermocoupleType)
  133. DAQImplementation*imp;
  134. private slots:
  135. void threadFinished();
  136. public:
  137. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  138. ~DAQ();
  139. Channel*newChannel(int units,int thermocouple);
  140. Q_INVOKABLE void setClockRate(double Hz);
  141. Q_INVOKABLE void start();
  142. Q_INVOKABLE void stop();
  143. enum ThermocoupleType
  144. {
  145. TypeJ= 10072,
  146. TypeK= 10073,
  147. TypeN= 10077,
  148. TypeR= 10082,
  149. TypeS= 10085,
  150. TypeT= 10086,
  151. TypeB= 10047,
  152. TypeE= 10055
  153. };
  154. };
  155. /*:253*//*254:*/
  156. #line 5885 "./typica.w"
  157. class DAQImplementation:public QThread
  158. {
  159. Q_OBJECT
  160. public:
  161. DAQImplementation(const QString&driverinfo);
  162. ~DAQImplementation();
  163. void run();
  164. void measure();
  165. /*255:*/
  166. #line 5905 "./typica.w"
  167. typedef int(*daqfp)(...);
  168. daqfp read;
  169. daqfp errorInfo;
  170. daqfp startTask;
  171. daqfp createTask;
  172. daqfp createChannel;
  173. daqfp setClock;
  174. daqfp stopTask;
  175. daqfp clearTask;
  176. daqfp resetDevice;
  177. daqfp waitForMeasurement;
  178. /*:255*/
  179. #line 5894 "./typica.w"
  180. /*256:*/
  181. #line 5921 "./typica.w"
  182. bool useBase;
  183. QString device;
  184. QVector<Channel*> channelMap;
  185. unsigned int handle;
  186. int error;
  187. int channels;
  188. bool ready;
  189. QLibrary driver;
  190. QVector<Units::Unit> unitMap;
  191. /*:256*/
  192. #line 5895 "./typica.w"
  193. };
  194. /*:254*//*272:*/
  195. #line 6425 "./typica.w"
  196. class FakeDAQImplementation:public QThread
  197. {
  198. Q_OBJECT
  199. public:
  200. FakeDAQImplementation();
  201. ~FakeDAQImplementation();
  202. void run();
  203. void measure();
  204. QVector<Channel*> channelMap;
  205. int channels;
  206. bool ready;
  207. double clockRate;
  208. };
  209. class FakeDAQ:public QObject
  210. {
  211. Q_OBJECT
  212. FakeDAQImplementation*imp;
  213. public:
  214. FakeDAQ(QString device);
  215. ~FakeDAQ();
  216. Channel*newChannel(int units,int thermocouple);
  217. Q_INVOKABLE void setClockRate(double Hz);
  218. Q_INVOKABLE void start();
  219. };
  220. /*:272*//*279:*/
  221. #line 6612 "./typica.w"
  222. class Channel:public QObject
  223. {
  224. Q_OBJECT
  225. public:
  226. Channel();
  227. ~Channel();
  228. public slots:
  229. void input(Measurement measurement);
  230. signals:
  231. void newData(Measurement);
  232. };
  233. /*:279*//*283:*/
  234. #line 6679 "./typica.w"
  235. class LinearCalibrator:public QObject
  236. {
  237. Q_OBJECT
  238. Q_PROPERTY(double measuredLower READ measuredLower
  239. WRITE setMeasuredLower)
  240. Q_PROPERTY(double measuredUpper READ measuredUpper
  241. WRITE setMeasuredUpper)
  242. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  243. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  244. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  245. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  246. public:
  247. LinearCalibrator(QObject*parent= NULL);
  248. double measuredLower();
  249. double measuredUpper();
  250. double mappedLower();
  251. double mappedUpper();
  252. bool isClosedRange();
  253. double sensitivity();
  254. public slots:
  255. void setMeasuredLower(double lower);
  256. void setMeasuredUpper(double upper);
  257. void setMappedLower(double lower);
  258. void setMappedUpper(double upper);
  259. void setClosedRange(bool closed);
  260. void setSensitivity(double sensitivity);
  261. Measurement newMeasurement(Measurement measure);
  262. signals:
  263. void measurement(Measurement measure);
  264. void newData(Measurement measure);
  265. private:
  266. double Lo1;
  267. double Lo2;
  268. double Up1;
  269. double Up2;
  270. double sensitivitySetting;
  271. bool clamp;
  272. };
  273. /*:283*//*290:*/
  274. #line 6875 "./typica.w"
  275. class LinearSplineInterpolator:public QObject
  276. {
  277. Q_OBJECT
  278. public:
  279. LinearSplineInterpolator(QObject*parent= NULL);
  280. Q_INVOKABLE void add_pair(double source,double destination);
  281. public slots:
  282. Measurement newMeasurement(Measurement measure);
  283. signals:
  284. void newData(Measurement measure);
  285. private:
  286. void make_interpolators();
  287. QMap<double,double> *pairs;
  288. QList<LinearCalibrator*> *interpolators;
  289. };
  290. /*:290*//*295:*/
  291. #line 7011 "./typica.w"
  292. class TemperatureDisplay:public QLCDNumber
  293. {
  294. Q_OBJECT
  295. int unit;
  296. bool r;
  297. public:
  298. TemperatureDisplay(QWidget*parent= NULL);
  299. ~TemperatureDisplay();
  300. public slots:
  301. void setValue(Measurement temperature);
  302. void invalidate();
  303. void setDisplayUnits(Units::Unit scale);
  304. void setRelativeMode(bool relative);
  305. };
  306. /*:295*//*306:*/
  307. #line 7227 "./typica.w"
  308. class MeasurementTimeOffset:public QObject
  309. {
  310. Q_OBJECT
  311. QTime epoch;
  312. QTime previous;
  313. bool hasPrevious;
  314. public:
  315. MeasurementTimeOffset(QTime zero);
  316. QTime zeroTime();
  317. public slots:
  318. void newMeasurement(Measurement measure);
  319. void setZeroTime(QTime zero);
  320. signals:
  321. void measurement(Measurement measure);
  322. };
  323. /*:306*//*313:*/
  324. #line 7379 "./typica.w"
  325. class ThresholdDetector:public QObject
  326. {
  327. Q_OBJECT
  328. Q_ENUMS(EdgeDirection)
  329. public:
  330. enum EdgeDirection{
  331. Ascending,Descending
  332. };
  333. ThresholdDetector(double value);
  334. public slots:
  335. void newMeasurement(Measurement measure);
  336. void setThreshold(double value);
  337. void setEdgeDirection(EdgeDirection direction);
  338. signals:
  339. void timeForValue(double);
  340. private:
  341. double previousValue;
  342. double threshold;
  343. EdgeDirection currentDirection;
  344. };
  345. /*:313*//*318:*/
  346. #line 7485 "./typica.w"
  347. class ZeroEmitter:public QObject
  348. {
  349. Q_OBJECT
  350. Q_PROPERTY(int column READ column WRITE setColumn)
  351. Measurement cache;
  352. int col;
  353. public:
  354. ZeroEmitter(int tempcolumn= 1);
  355. int column();
  356. double lastTemperature();
  357. public slots:
  358. void newMeasurement(Measurement measure);
  359. void setColumn(int column);
  360. void emitZero();
  361. signals:
  362. void measurement(Measurement measure,int tempcolumn);
  363. };
  364. /*:318*//*323:*/
  365. #line 7579 "./typica.w"
  366. class MeasurementAdapter:public QObject
  367. {
  368. Q_OBJECT
  369. int col;
  370. public:
  371. MeasurementAdapter(int tempcolumn);
  372. int column();
  373. public slots:
  374. void newMeasurement(Measurement measure);
  375. void setColumn(int column);
  376. signals:
  377. void measurement(Measurement measure,int tempcolumn);
  378. };
  379. /*:323*//*328:*/
  380. #line 7668 "./typica.w"
  381. class GraphView:public QGraphicsView
  382. {
  383. Q_OBJECT
  384. QGraphicsScene*theScene;
  385. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  386. QMap<int,QPointF> *prevPoints;
  387. QMap<int,double> *translations;
  388. QList<QGraphicsItem*> *gridLinesF;
  389. QList<QGraphicsItem*> *gridLinesC;
  390. QList<QGraphicsItem*> *relativeGridLines;
  391. bool relativeEnabled;
  392. bool timeIndicatorEnabled;
  393. QGraphicsLineItem*timeLine;
  394. LinearSplineInterpolator*relativeAdjuster;
  395. public:
  396. GraphView(QWidget*parent= NULL);
  397. void removeSeries(int column);
  398. protected:
  399. void resizeEvent(QResizeEvent*event);
  400. public slots:
  401. void newMeasurement(Measurement measure,int tempcolumn);
  402. void setSeriesTranslation(int column,double offset);
  403. void setTimeIndicatorEnabled(bool enabled);
  404. void clear();
  405. void showF();
  406. void showC();
  407. };
  408. /*:328*//*345:*/
  409. #line 8133 "./typica.w"
  410. class MeasurementModel;
  411. class ZoomLog:public QTableView
  412. {
  413. Q_OBJECT
  414. /*346:*/
  415. #line 8182 "./typica.w"
  416. MeasurementModel*model_ms;
  417. MeasurementModel*model_1s;
  418. MeasurementModel*model_5s;
  419. MeasurementModel*model_10s;
  420. MeasurementModel*model_15s;
  421. MeasurementModel*model_30s;
  422. MeasurementModel*model_1m;
  423. QList<MeasurementModel*> modelSet;
  424. QHash<int,Measurement> lastMeasurement;
  425. MeasurementModel*currentModel;
  426. QList<int> saveTempCols;
  427. QList<int> saveControlCols;
  428. QList<int> saveNoteCols;
  429. QList<int> currentColumnSet;
  430. /*:346*/
  431. #line 8138 "./typica.w"
  432. void switchLOD(MeasurementModel*m);
  433. private slots:
  434. void centerOn(int row);
  435. void persistColumnResize(int column,int oldsize,int newsize);
  436. void restoreColumnWidths();
  437. public:
  438. ZoomLog();
  439. QVariant data(int row,int column)const;
  440. int rowCount();
  441. bool saveXML(QIODevice*device);
  442. bool saveCSV(QIODevice*device);
  443. QString lastTime(int series);
  444. Q_INVOKABLE Units::Unit displayUnits();
  445. public slots:
  446. void setVisible(bool visibility);
  447. void setHeaderData(int section,QString text);
  448. void LOD_ms();
  449. void LOD_1s();
  450. void LOD_5s();
  451. void LOD_10s();
  452. void LOD_15s();
  453. void LOD_30s();
  454. void LOD_1m();
  455. void newMeasurement(Measurement measure,int tempcolumn);
  456. void newAnnotation(QString annotation,int tempcolumn,
  457. int annotationcolumn);
  458. void clear();
  459. void addOutputTemperatureColumn(int column);
  460. void addOutputControlColumn(int column);
  461. void addOutputAnnotationColumn(int column);
  462. void clearOutputColumns();
  463. void setDisplayUnits(Units::Unit scale);
  464. void addToCurrentColumnSet(int column);
  465. void clearCurrentColumnSet();
  466. protected:
  467. virtual void showEvent(QShowEvent*event);
  468. };
  469. /*:345*//*371:*/
  470. #line 8878 "./typica.w"
  471. class MeasurementList;
  472. class MeasurementModel:public QAbstractItemModel
  473. {
  474. Q_OBJECT
  475. Units::Unit unit;
  476. QList<MeasurementList*> *entries;
  477. QStringList*hData;
  478. int colcount;
  479. QHash<int,int> *lastTemperature;
  480. QList<MeasurementList*> ::iterator lastInsertion;
  481. QHash<int,bool> *controlColumns;
  482. public:
  483. MeasurementModel(QObject*parent= NULL);
  484. ~MeasurementModel();
  485. int rowCount(const QModelIndex&parent= QModelIndex())const;
  486. int columnCount(const QModelIndex&parent= QModelIndex())const;
  487. bool setHeaderData(int section,Qt::Orientation orientation,
  488. const QVariant&value,int role= Qt::DisplayRole);
  489. QVariant data(const QModelIndex&index,int role)const;
  490. bool setData(const QModelIndex&index,const QVariant&value,
  491. int role= Qt::EditRole);
  492. Qt::ItemFlags flags(const QModelIndex&index)const;
  493. QVariant headerData(int section,Qt::Orientation orientation,
  494. int role= Qt::DisplayRole)const;
  495. QModelIndex index(int row,int column,
  496. const QModelIndex&parent= QModelIndex())const;
  497. QModelIndex parent(const QModelIndex&index)const;
  498. Units::Unit displayUnits();
  499. public slots:
  500. void newMeasurement(Measurement measure,int tempcolumn);
  501. void newAnnotation(QString annotation,int tempcolumn,
  502. int annotationColumn);
  503. void clear();
  504. void setDisplayUnits(Units::Unit scale);
  505. signals:
  506. void rowChanged(int);
  507. };
  508. /*:371*//*372:*/
  509. #line 8922 "./typica.w"
  510. class MeasurementList:public QVariantList
  511. {
  512. public:
  513. bool operator<(const MeasurementList&other)const;
  514. bool operator==(const MeasurementList&other)const;
  515. };
  516. /*:372*//*398:*/
  517. #line 9577 "./typica.w"
  518. class AnnotationButton:public QPushButton
  519. {
  520. Q_OBJECT
  521. QString note;
  522. int tc;
  523. int ac;
  524. int count;
  525. public:
  526. AnnotationButton(const QString&text,QWidget*parent= NULL);
  527. public slots:
  528. void setAnnotation(const QString&annotation);
  529. void setTemperatureColumn(int tempcolumn);
  530. void setAnnotationColumn(int annotationcolumn);
  531. void annotate();
  532. void resetCount();
  533. signals:
  534. void annotation(QString annotation,int tempcolumn,
  535. int notecolumn);
  536. };
  537. /*:398*//*406:*/
  538. #line 9702 "./typica.w"
  539. class AnnotationSpinBox:public QDoubleSpinBox
  540. {
  541. Q_OBJECT
  542. QString pretext;
  543. QString posttext;
  544. int tc;
  545. int ac;
  546. bool change;
  547. public:
  548. AnnotationSpinBox(const QString&pret,const QString&postt,
  549. QWidget*parent= NULL);
  550. public slots:
  551. void setPretext(const QString&pret);
  552. void setPosttext(const QString&postt);
  553. void setTemperatureColumn(int tempcolumn);
  554. void setAnnotationColumn(int annotationcolumn);
  555. void annotate();
  556. void resetChange();
  557. signals:
  558. void annotation(QString annotation,int tempcolumn,
  559. int notecolumn);
  560. };
  561. /*:406*//*414:*/
  562. #line 9861 "./typica.w"
  563. class TimerDisplay:public QLCDNumber
  564. {
  565. Q_OBJECT
  566. /*415:*/
  567. #line 9911 "./typica.w"
  568. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  569. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  570. Q_PROPERTY(bool running READ isRunning)
  571. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  572. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  573. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  574. /*:415*/
  575. #line 9865 "./typica.w"
  576. private slots:
  577. void updateTime();
  578. void setCountUpMode();
  579. void setCountDownMode();
  580. void setClockMode();
  581. public:
  582. TimerDisplay(QWidget*parent= NULL);
  583. ~TimerDisplay();
  584. enum TimerMode
  585. {
  586. CountUp,
  587. CountDown,
  588. Clock
  589. };
  590. QString value();
  591. QTime seconds();
  592. TimerMode mode();
  593. bool isRunning();
  594. QTime resetValue();
  595. QString displayFormat();
  596. bool autoReset();
  597. public slots:
  598. void setTimer(QTime value= QTime(0,0,0));
  599. void setMode(TimerMode mode);
  600. void startTimer();
  601. void stopTimer();
  602. void copyTimer();
  603. void setResetValue(QTime value= QTime(0,0,0));
  604. void reset();
  605. void setDisplayFormat(QString format);
  606. void setAutoReset(bool reset);
  607. void updateDisplay();
  608. signals:
  609. void valueChanged(QTime);
  610. void runStateChanged(bool);
  611. private:
  612. /*416:*/
  613. #line 9921 "./typica.w"
  614. QTime s;
  615. QTime r;
  616. QTimer clock;
  617. TimerDisplay::TimerMode m;
  618. bool running;
  619. bool ar;
  620. QAction*startAction;
  621. QAction*stopAction;
  622. QAction*resetAction;
  623. QString f;
  624. QTime relative;
  625. QTime base;
  626. /*:416*/
  627. #line 9902 "./typica.w"
  628. };
  629. /*:414*//*436:*/
  630. #line 10280 "./typica.w"
  631. class PackLayout:public QLayout
  632. {
  633. int doLayout(const QRect&rect,bool testOnly)const;
  634. QList<QLayoutItem*> itemList;
  635. Qt::Orientations orientation;
  636. public:
  637. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  638. PackLayout(int spacing= -1);
  639. ~PackLayout();
  640. void addItem(QLayoutItem*item);
  641. Qt::Orientations expandingDirections()const;
  642. bool hasHeightForWidth()const;
  643. int heightForWidth(int width)const;
  644. int count()const;
  645. QLayoutItem*itemAt(int index)const;
  646. QSize minimumSize()const;
  647. void setGeometry(const QRect&rect);
  648. void setOrientation(Qt::Orientations direction);
  649. QSize sizeHint()const;
  650. QLayoutItem*takeAt(int index);
  651. };
  652. /*:436*//*449:*/
  653. #line 10558 "./typica.w"
  654. class SceneButton:public QGraphicsScene
  655. {
  656. Q_OBJECT
  657. public:
  658. SceneButton();
  659. ~SceneButton();
  660. protected:
  661. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  662. signals:
  663. void clicked(QPoint pos);
  664. };
  665. /*:449*//*451:*/
  666. #line 10600 "./typica.w"
  667. class WidgetDecorator:public QWidget
  668. {
  669. Q_OBJECT
  670. PackLayout*layout;
  671. QGraphicsView*label;
  672. QGraphicsTextItem*text;
  673. SceneButton*scene;
  674. public:
  675. WidgetDecorator(QWidget*widget,const QString&labeltext,
  676. Qt::Orientations orientation= Qt::Horizontal,
  677. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  678. ~WidgetDecorator();
  679. void setBackgroundBrush(QBrush background);
  680. void setTextColor(QColor color);
  681. };
  682. /*:451*//*462:*/
  683. #line 10775 "./typica.w"
  684. class LogEditWindow:public QMainWindow
  685. {
  686. Q_OBJECT
  687. QWidget*centralWidget;
  688. PackLayout*mainLayout;
  689. QHBoxLayout*addRowsLayout;
  690. QLabel*startTimeLabel;
  691. QTimeEdit*startTime;
  692. QLabel*endTimeLabel;
  693. QTimeEdit*endTime;
  694. QLabel*intervalLabel;
  695. QSpinBox*interval;
  696. QPushButton*addRows;
  697. QAction*saveXml;
  698. QAction*saveCsv;
  699. QAction*openXml;
  700. MeasurementModel*model;
  701. QTableView*log;
  702. private slots:
  703. void addTheRows();
  704. void saveXML();
  705. void saveCSV();
  706. void openXML();
  707. protected:
  708. void closeEvent(QCloseEvent*event);
  709. public:
  710. LogEditWindow();
  711. };
  712. /*:462*//*476:*/
  713. #line 11083 "./typica.w"
  714. class XMLOutput:public QObject
  715. {
  716. Q_OBJECT
  717. MeasurementModel*data;
  718. QIODevice*out;
  719. int time;
  720. QMap<int,QString> temperatureColumns;
  721. QMap<int,QString> controlColumns;
  722. QMap<int,QString> annotationColumns;
  723. public:
  724. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  725. void addTemperatureColumn(const QString&series,int column);
  726. void addControlColumn(const QString&series,int column);
  727. void addAnnotationColumn(const QString&series,int column);
  728. void setModel(MeasurementModel*model);
  729. void setTimeColumn(int column);
  730. void setDevice(QIODevice*device);
  731. bool output();
  732. };
  733. /*:476*//*483:*/
  734. #line 11319 "./typica.w"
  735. class XMLInput:public QObject
  736. {
  737. Q_OBJECT
  738. int firstc;
  739. QIODevice*in;
  740. public:
  741. XMLInput(QIODevice*input,int c);
  742. void setFirstColumn(int column);
  743. void setDevice(QIODevice*device);
  744. bool input();
  745. signals:
  746. void measure(Measurement,int);
  747. void annotation(QString,int,int);
  748. void newTemperatureColumn(int,QString);
  749. void newAnnotationColumn(int,QString);
  750. void lastColumn(int);
  751. };
  752. /*:483*//*494:*/
  753. #line 11578 "./typica.w"
  754. class CSVOutput
  755. {
  756. MeasurementModel*data;
  757. QIODevice*out;
  758. int time;
  759. QMap<int,QString> temperatureColumns;
  760. QMap<int,QString> controlColumns;
  761. QMap<int,QString> annotationColumns;
  762. public:
  763. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  764. void addTemperatureColumn(const QString&series,int column);
  765. void addControlColumn(const QString&series,int column);
  766. void addAnnotationColumn(const QString&series,int column);
  767. void setModel(MeasurementModel*model);
  768. void setTimeColumn(int column);
  769. void setDevice(QIODevice*device);
  770. bool output();
  771. };
  772. /*:494*//*524:*/
  773. #line 11721 "./typica.w"
  774. #define AppInstance (qobject_cast<Application *> (qApp))
  775. class NodeInserter;
  776. class DeviceTreeModel;
  777. class Application:public QApplication
  778. {
  779. Q_OBJECT
  780. public:
  781. Application(int&argc,char**argv);
  782. QDomDocument*configuration();
  783. /*639:*/
  784. #line 14140 "./typica.w"
  785. QDomDocument deviceConfiguration();
  786. /*:639*//*672:*/
  787. #line 14813 "./typica.w"
  788. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  789. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  790. const QModelIndex&index);
  791. /*:672*//*677:*/
  792. #line 14917 "./typica.w"
  793. QList<NodeInserter*> topLevelNodeInserters;
  794. /*:677*/
  795. #line 11732 "./typica.w"
  796. QSqlDatabase database();
  797. QScriptEngine*engine;
  798. public slots:
  799. /*640:*/
  800. #line 14147 "./typica.w"
  801. void saveDeviceConfiguration();
  802. /*:640*/
  803. #line 11736 "./typica.w"
  804. private:
  805. /*638:*/
  806. #line 14131 "./typica.w"
  807. QDomDocument deviceConfigurationDocument;
  808. /*:638*//*671:*/
  809. #line 14807 "./typica.w"
  810. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  811. /*:671*/
  812. #line 11738 "./typica.w"
  813. QDomDocument conf;
  814. };
  815. /*:524*//*532:*/
  816. #line 11862 "./typica.w"
  817. class SaltModel:public QAbstractItemModel
  818. {
  819. Q_OBJECT
  820. QList<QList<QMap<int,QVariant> > > modelData;
  821. QStringList hData;
  822. int colcount;
  823. public:
  824. SaltModel(int columns);
  825. ~SaltModel();
  826. int rowCount(const QModelIndex&parent= QModelIndex())const;
  827. int columnCount(const QModelIndex&parent= QModelIndex())const;
  828. bool setHeaderData(int section,Qt::Orientation orientation,
  829. const QVariant&value,int role= Qt::DisplayRole);
  830. QVariant data(const QModelIndex&index,int role)const;
  831. bool setData(const QModelIndex&index,const QVariant&value,
  832. int role= Qt::EditRole);
  833. Qt::ItemFlags flags(const QModelIndex&index)const;
  834. QVariant headerData(int section,Qt::Orientation orientation,
  835. int role= Qt::DisplayRole)const;
  836. QModelIndex index(int row,int column,
  837. const QModelIndex&parent= QModelIndex())const;
  838. QModelIndex parent(const QModelIndex&index)const;
  839. QString arrayLiteral(int column,int role)const;
  840. QString quotedArrayLiteral(int column,int role)const;
  841. };
  842. /*:532*//*545:*/
  843. #line 12175 "./typica.w"
  844. class SqlComboBox:public QComboBox
  845. {
  846. Q_OBJECT
  847. int dataColumn;
  848. int displayColumn;
  849. bool dataColumnShown;
  850. public:
  851. SqlComboBox();
  852. ~SqlComboBox();
  853. SqlComboBox*clone(QWidget*parent);
  854. public slots:
  855. void addNullOption();
  856. void addSqlOptions(QString query);
  857. void setDataColumn(int column);
  858. void setDisplayColumn(int column);
  859. void showData(bool show);
  860. };
  861. /*:545*//*552:*/
  862. #line 12304 "./typica.w"
  863. class SqlComboBoxDelegate:public QItemDelegate
  864. {
  865. Q_OBJECT
  866. SqlComboBox*delegate;
  867. public:
  868. SqlComboBoxDelegate(QObject*parent= NULL);
  869. QWidget*createEditor(QWidget*parent,
  870. const QStyleOptionViewItem&option,
  871. const QModelIndex&index)const;
  872. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  873. void setModelData(QWidget*editor,QAbstractItemModel*model,
  874. const QModelIndex&index)const;
  875. void setWidget(SqlComboBox*widget);
  876. virtual QSize sizeHint()const;
  877. void updateEditorGeometry(QWidget*editor,
  878. const QStyleOptionViewItem&option,
  879. const QModelIndex&index)const;
  880. };
  881. /*:552*//*564:*/
  882. #line 12486 "./typica.w"
  883. class SqlConnectionSetup:public QDialog
  884. {
  885. Q_OBJECT
  886. public:
  887. SqlConnectionSetup();
  888. ~SqlConnectionSetup();
  889. public slots:
  890. void testConnection();
  891. private:
  892. QFormLayout*formLayout;
  893. QComboBox*driver;
  894. QLineEdit*hostname;
  895. QLineEdit*dbname;
  896. QLineEdit*user;
  897. QLineEdit*password;
  898. QVBoxLayout*layout;
  899. QHBoxLayout*buttons;
  900. QPushButton*cancelButton;
  901. QPushButton*connectButton;
  902. };
  903. /*:564*//*569:*/
  904. #line 12616 "./typica.w"
  905. class SqlQueryView:public QTableView
  906. {
  907. Q_OBJECT
  908. public:
  909. SqlQueryView(QWidget*parent= NULL);
  910. void setQuery(const QString&query);
  911. bool setHeaderData(int section,Qt::Orientation orientation,
  912. const QVariant&value,int role);
  913. Q_INVOKABLE QVariant data(int row,int column,
  914. int role= Qt::DisplayRole);
  915. signals:
  916. void openEntry(QString key);
  917. void openEntryRow(int row);
  918. protected:
  919. virtual void showEvent(QShowEvent*event);
  920. private slots:
  921. void openRow(const QModelIndex&index);
  922. void persistColumnResize(int column,int oldsize,int newsize);
  923. };
  924. /*:569*//*584:*/
  925. #line 12864 "./typica.w"
  926. class ReportAction:public QAction
  927. {
  928. Q_OBJECT
  929. public:
  930. ReportAction(const QString&fileName,const QString&reportName,
  931. QObject*parent= NULL);
  932. private slots:
  933. void createReport();
  934. private:
  935. QString reportFile;
  936. };
  937. /*:584*//*596:*/
  938. #line 13073 "./typica.w"
  939. class ReportTable:public QObject
  940. {
  941. Q_OBJECT
  942. QTextFrame*area;
  943. QDomElement configuration;
  944. QMap<QString,QVariant> bindings;
  945. public:
  946. ReportTable(QTextFrame*frame,QDomElement description);
  947. ~ReportTable();
  948. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  949. public slots:
  950. void refresh();
  951. };
  952. /*:596*//*608:*/
  953. #line 13309 "./typica.w"
  954. class FormArray:public QScrollArea
  955. {
  956. Q_OBJECT
  957. QDomElement configuration;
  958. QWidget itemContainer;
  959. QVBoxLayout itemLayout;
  960. int maxwidth;
  961. int maxheight;
  962. public:
  963. FormArray(QDomElement description);
  964. Q_INVOKABLE QWidget*elementAt(int index);
  965. Q_INVOKABLE int elements();
  966. public slots:
  967. void addElements(int copies= 1);
  968. void removeAllElements();
  969. void setMaximumElementWidth(int width);
  970. void setMaximumElementHeight(int height);
  971. };
  972. /*:608*//*618:*/
  973. #line 13525 "./typica.w"
  974. class ScaleControl:public QGraphicsView
  975. {
  976. Q_OBJECT
  977. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  978. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  979. /*619:*/
  980. #line 13551 "./typica.w"
  981. QGraphicsScene scene;
  982. QGraphicsPolygonItem initialDecrement;
  983. QGraphicsPolygonItem initialIncrement;
  984. QGraphicsPolygonItem finalDecrement;
  985. QGraphicsPolygonItem finalIncrement;
  986. QGraphicsPolygonItem initialIndicator;
  987. QGraphicsPolygonItem finalIndicator;
  988. QGraphicsPathItem scaleLine;
  989. QPolygonF left;
  990. QPolygonF right;
  991. QPolygonF down;
  992. QPolygonF up;
  993. QPainterPath scalePath;
  994. QBrush initialBrush;
  995. QBrush finalBrush;
  996. double nonScoredValue;
  997. double scoredValue;
  998. bool initialSet;
  999. bool finalSet;
  1000. bool scaleDown;
  1001. /*:619*/
  1002. #line 13531 "./typica.w"
  1003. public:
  1004. ScaleControl();
  1005. double initialValue(void);
  1006. double finalValue(void);
  1007. virtual QSize sizeHint()const;
  1008. public slots:
  1009. void setInitialValue(double value);
  1010. void setFinalValue(double value);
  1011. signals:
  1012. void initialChanged(double);
  1013. void finalChanged(double);
  1014. protected:
  1015. virtual void mousePressEvent(QMouseEvent*event);
  1016. virtual void mouseReleaseEvent(QMouseEvent*event);
  1017. };
  1018. /*:618*//*630:*/
  1019. #line 13848 "./typica.w"
  1020. class IntensityControl:public QGraphicsView
  1021. {
  1022. Q_OBJECT
  1023. Q_PROPERTY(double value READ value WRITE setValue)
  1024. QGraphicsScene scene;
  1025. QGraphicsPolygonItem decrement;
  1026. QGraphicsPolygonItem increment;
  1027. QGraphicsPolygonItem indicator;
  1028. QGraphicsPathItem scaleLine;
  1029. QPolygonF left;
  1030. QPolygonF up;
  1031. QPolygonF down;
  1032. QPainterPath scalePath;
  1033. QBrush theBrush;
  1034. double theValue;
  1035. bool valueSet;
  1036. bool scaleDown;
  1037. public:
  1038. IntensityControl();
  1039. double value();
  1040. virtual QSize sizeHint()const;
  1041. public slots:
  1042. void setValue(double val);
  1043. signals:
  1044. void valueChanged(double);
  1045. protected:
  1046. virtual void mousePressEvent(QMouseEvent*event);
  1047. virtual void mouseReleaseEvent(QMouseEvent*event);
  1048. };
  1049. /*:630*//*646:*/
  1050. #line 14236 "./typica.w"
  1051. class DeviceTreeModelNode
  1052. {
  1053. public:
  1054. DeviceTreeModelNode(QDomNode&node,int row,
  1055. DeviceTreeModelNode*parent= NULL);
  1056. ~DeviceTreeModelNode();
  1057. DeviceTreeModelNode*child(int index);
  1058. DeviceTreeModelNode*parent();
  1059. QDomNode node()const;
  1060. int row();
  1061. private:
  1062. QDomNode domNode;
  1063. QHash<int,DeviceTreeModelNode*> children;
  1064. int rowNumber;
  1065. DeviceTreeModelNode*parentItem;
  1066. };
  1067. /*:646*//*648:*/
  1068. #line 14311 "./typica.w"
  1069. class DeviceTreeModel:public QAbstractItemModel
  1070. {
  1071. Q_OBJECT
  1072. public:
  1073. DeviceTreeModel(QObject*parent= NULL);
  1074. ~DeviceTreeModel();
  1075. QVariant data(const QModelIndex&index,int role)const;
  1076. Qt::ItemFlags flags(const QModelIndex&index)const;
  1077. QVariant headerData(int section,Qt::Orientation orientation,
  1078. int role= Qt::DisplayRole)const;
  1079. QModelIndex index(int row,int column,
  1080. const QModelIndex&parent= QModelIndex())const;
  1081. QModelIndex parent(const QModelIndex&child)const;
  1082. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1083. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1084. bool setData(const QModelIndex&index,const QVariant&value,
  1085. int role);
  1086. bool removeRows(int row,int count,const QModelIndex&parent);
  1087. QDomElement referenceElement(const QString&id);
  1088. public slots:
  1089. void newNode(const QString&name,const QString&driver,
  1090. const QModelIndex&parent);
  1091. private:
  1092. QDomDocument document;
  1093. DeviceTreeModelNode*root;
  1094. QDomNode referenceSection;
  1095. QDomNode treeRoot;
  1096. };
  1097. /*:648*//*667:*/
  1098. #line 14765 "./typica.w"
  1099. Q_DECLARE_METATYPE(QModelIndex)
  1100. /*:667*//*675:*/
  1101. #line 14872 "./typica.w"
  1102. class NodeInserter:public QAction
  1103. {
  1104. Q_OBJECT
  1105. public:
  1106. NodeInserter(const QString&title,const QString&name,
  1107. const QString&driver,QObject*parent= NULL);
  1108. signals:
  1109. void triggered(QString name,QString driver);
  1110. private slots:
  1111. void onTriggered();
  1112. private:
  1113. QString defaultNodeName;
  1114. QString driverString;
  1115. };
  1116. /*:675*//*678:*/
  1117. #line 14927 "./typica.w"
  1118. class DeviceConfigurationWindow:public QWidget
  1119. {
  1120. Q_OBJECT
  1121. public:
  1122. DeviceConfigurationWindow();
  1123. public slots:
  1124. void addDevice();
  1125. void removeNode();
  1126. void newSelection(const QModelIndex&index);
  1127. private slots:
  1128. void resizeColumn();
  1129. private:
  1130. QDomDocument document;
  1131. DeviceTreeModel*model;
  1132. QTreeView*view;
  1133. QScrollArea*configArea;
  1134. };
  1135. /*:678*//*687:*/
  1136. #line 15096 "./typica.w"
  1137. class BasicDeviceConfigurationWidget:public QWidget
  1138. {
  1139. Q_OBJECT
  1140. public:
  1141. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1142. const QModelIndex&index);
  1143. public slots:
  1144. void insertChildNode(const QString&name,const QString&driver);
  1145. void updateAttribute(const QString&name,const QString&value);
  1146. protected:
  1147. DeviceTreeModel*deviceModel;
  1148. QModelIndex currentNode;
  1149. };
  1150. /*:687*//*691:*/
  1151. #line 15181 "./typica.w"
  1152. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1153. {
  1154. Q_OBJECT
  1155. public:
  1156. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1157. const QModelIndex&index);
  1158. private slots:
  1159. void updateRoasterId(int id);
  1160. };
  1161. /*:691*//*696:*/
  1162. #line 15316 "./typica.w"
  1163. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1164. {
  1165. Q_OBJECT
  1166. public:
  1167. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1168. const QModelIndex&index);
  1169. };
  1170. /*:696*//*698:*/
  1171. #line 15362 "./typica.w"
  1172. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1173. {
  1174. Q_OBJECT
  1175. public:
  1176. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1177. const QModelIndex&index);
  1178. private slots:
  1179. void addChannel();
  1180. void updateDeviceId(const QString&newId);
  1181. };
  1182. /*:698*//*702:*/
  1183. #line 15448 "./typica.w"
  1184. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1185. {
  1186. Q_OBJECT
  1187. public:
  1188. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1189. const QModelIndex&index);
  1190. private slots:
  1191. void updateThermocoupleType(const QString&type);
  1192. void updateColumnName(const QString&name);
  1193. void updateHidden(bool hidden);
  1194. };
  1195. /*:702*//*707:*/
  1196. #line 15564 "./typica.w"
  1197. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1198. {
  1199. Q_OBJECT
  1200. public:
  1201. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1202. const QModelIndex&index);
  1203. };
  1204. /*:707*//*709:*/
  1205. #line 15605 "./typica.w"
  1206. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1207. {
  1208. Q_OBJECT
  1209. public:
  1210. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1211. const QModelIndex&index);
  1212. private slots:
  1213. void addChannel();
  1214. void updateDeviceId(const QString&newId);
  1215. };
  1216. /*:709*//*711:*/
  1217. #line 15674 "./typica.w"
  1218. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1219. {
  1220. Q_OBJECT
  1221. public:
  1222. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1223. const QModelIndex&index);
  1224. private slots:
  1225. void updateDeviceId(const QString&newId);
  1226. void updateThermocoupleType(const QString&type);
  1227. void updateColumnName(const QString&name);
  1228. void updateHidden(bool hidden);
  1229. };
  1230. /*:711*//*716:*/
  1231. #line 15805 "./typica.w"
  1232. class PortSelector:public QComboBox
  1233. {
  1234. Q_OBJECT
  1235. public:
  1236. PortSelector(QWidget*parent= NULL);
  1237. private slots:
  1238. void addDevice(QextPortInfo port);
  1239. private:
  1240. QextSerialEnumerator*lister;
  1241. };
  1242. /*:716*//*718:*/
  1243. #line 15853 "./typica.w"
  1244. class BaudSelector:public QComboBox
  1245. {
  1246. Q_OBJECT
  1247. Q_ENUMS(BaudRateType)
  1248. public:
  1249. BaudSelector(QWidget*parent= NULL);
  1250. enum BaudRateType
  1251. {
  1252. #if defined(Q_OS_UNIX) || defined(qdoc)
  1253. BAUD50= 50,
  1254. BAUD75= 75,
  1255. BAUD134= 134,
  1256. BAUD150= 150,
  1257. BAUD200= 200,
  1258. BAUD1800= 1800,
  1259. #if defined(B76800) || defined(qdoc)
  1260. BAUD76800= 76800,
  1261. #endif
  1262. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1263. BAUD230400= 230400,
  1264. BAUD460800= 460800,
  1265. BAUD500000= 500000,
  1266. BAUD576000= 576000,
  1267. BAUD921600= 921600,
  1268. BAUD1000000= 1000000,
  1269. BAUD1152000= 1152000,
  1270. BAUD1500000= 1500000,
  1271. BAUD2000000= 2000000,
  1272. BAUD2500000= 2500000,
  1273. BAUD3000000= 3000000,
  1274. BAUD3500000= 3500000,
  1275. BAUD4000000= 4000000,
  1276. #endif
  1277. #endif
  1278. #if defined(Q_OS_WIN) || defined(qdoc)
  1279. BAUD14400= 14400,
  1280. BAUD56000= 56000,
  1281. BAUD128000= 128000,
  1282. BAUD256000= 256000,
  1283. #endif
  1284. BAUD110= 110,
  1285. BAUD300= 300,
  1286. BAUD600= 600,
  1287. BAUD1200= 1200,
  1288. BAUD2400= 2400,
  1289. BAUD4800= 4800,
  1290. BAUD9600= 9600,
  1291. BAUD19200= 19200,
  1292. BAUD38400= 38400,
  1293. BAUD57600= 57600,
  1294. BAUD115200= 115200
  1295. };
  1296. };
  1297. /*:718*//*720:*/
  1298. #line 15924 "./typica.w"
  1299. class ParitySelector:public QComboBox
  1300. {
  1301. Q_OBJECT
  1302. Q_ENUMS(ParityType)
  1303. public:
  1304. ParitySelector(QWidget*parent= NULL);
  1305. enum ParityType
  1306. {
  1307. PAR_NONE,
  1308. PAR_ODD,
  1309. PAR_EVEN,
  1310. #if defined(Q_OS_WIN) || defined(qdoc)
  1311. PAR_MARK,
  1312. #endif
  1313. PAR_SPACE
  1314. };
  1315. };
  1316. /*:720*//*722:*/
  1317. #line 15962 "./typica.w"
  1318. class FlowSelector:public QComboBox
  1319. {
  1320. Q_OBJECT
  1321. Q_ENUMS(FlowType)
  1322. public:
  1323. FlowSelector(QWidget*parent= NULL);
  1324. enum FlowType
  1325. {
  1326. FLOW_OFF,
  1327. FLOW_HARDWARE,
  1328. FLOW_XONXOFF
  1329. };
  1330. };
  1331. /*:722*//*724:*/
  1332. #line 15995 "./typica.w"
  1333. class StopSelector:public QComboBox
  1334. {
  1335. Q_OBJECT
  1336. Q_ENUMS(StopBitsType)
  1337. public:
  1338. StopSelector(QWidget*parent= NULL);
  1339. enum StopBitsType
  1340. {
  1341. STOP_1,
  1342. #if defined(Q_OS_WIN) || defined(qdoc)
  1343. STOP_1_5,
  1344. #endif
  1345. STOP_2
  1346. };
  1347. };
  1348. /*:724*//*727:*/
  1349. #line 16048 "./typica.w"
  1350. class ShortHexSpinBox:public QSpinBox
  1351. {
  1352. Q_OBJECT
  1353. public:
  1354. ShortHexSpinBox(QWidget*parent= NULL);
  1355. virtual QValidator::State validate(QString&input,int&pos)const;
  1356. protected:
  1357. virtual int valueFromText(const QString&text)const;
  1358. virtual QString textFromValue(int value)const;
  1359. };
  1360. /*:727*//*729:*/
  1361. #line 16110 "./typica.w"
  1362. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1363. {
  1364. Q_OBJECT
  1365. public:
  1366. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1367. const QModelIndex&index);
  1368. private slots:
  1369. void updatePort(const QString&newPort);
  1370. void updateBaudRate(const QString&newRate);
  1371. void updateParity(const QString&newParity);
  1372. void updateFlowControl(const QString&newFlow);
  1373. void updateStopBits(const QString&newStopBits);
  1374. };
  1375. /*:729*//*731:*/
  1376. #line 16261 "./typica.w"
  1377. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1378. {
  1379. Q_OBJECT
  1380. public:
  1381. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1382. const QModelIndex&index);
  1383. private slots:
  1384. void updateStationNumber(int newStation);
  1385. void updateFixedUnit(bool newFixed);
  1386. void updateFixedDecimal(bool newFixed);
  1387. void updateUnit(const QString&newUnit);
  1388. void updateUnitAddress(int newAddress);
  1389. void updateValueF(int newValue);
  1390. void updateValueC(int newValue);
  1391. void updatePrecisionAddress(int newAddress);
  1392. void updatePrecisionValue(int newValue);
  1393. private:
  1394. QStackedLayout*unitSpecificationLayout;
  1395. QStackedLayout*decimalSpecificationLayout;
  1396. };
  1397. /*:731*//*733:*/
  1398. #line 16520 "./typica.w"
  1399. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1400. {
  1401. Q_OBJECT
  1402. public:
  1403. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1404. const QModelIndex&index);
  1405. private slots:
  1406. void updateAddress(int newAddress);
  1407. };
  1408. /*:733*//*735:*/
  1409. #line 16566 "./typica.w"
  1410. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1411. {
  1412. Q_OBJECT
  1413. public:
  1414. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1415. const QModelIndex&index);
  1416. private slots:
  1417. void updateReadAddress(int newAddress);
  1418. void updateWriteAddress(int newAddress);
  1419. void updateFixedRange(bool fixed);
  1420. void updateLower(const QString&lower);
  1421. void updateUpper(const QString&upper);
  1422. void updateLowerAddress(int newAddress);
  1423. void updateUpperAddress(int newAddress);
  1424. private:
  1425. QStackedLayout*boundsLayout;
  1426. };
  1427. /*:735*//*739:*/
  1428. #line 16760 "./typica.w"
  1429. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1430. {
  1431. Q_OBJECT
  1432. public:
  1433. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1434. private slots:
  1435. void updateButtonText(const QString&text);
  1436. void updateAnnotationText(const QString&text);
  1437. };
  1438. /*:739*//*743:*/
  1439. #line 16828 "./typica.w"
  1440. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1441. {
  1442. Q_OBJECT
  1443. public:
  1444. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1445. private slots:
  1446. void updateButtonText(const QString&text);
  1447. void updateAnnotationText(const QString&text);
  1448. };
  1449. /*:743*//*746:*/
  1450. #line 16902 "./typica.w"
  1451. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1452. {
  1453. Q_OBJECT
  1454. public:
  1455. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1456. private slots:
  1457. void updateLabel(const QString&text);
  1458. void updateMinimum(const QString&minimum);
  1459. void updateMaximum(const QString&maximum);
  1460. void updatePrecision(int precision);
  1461. void updatePretext(const QString&text);
  1462. void updatePosttext(const QString&text);
  1463. };
  1464. /*:746*//*749:*/
  1465. #line 12 "./freeannotation.w"
  1466. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1467. {
  1468. Q_OBJECT
  1469. public:
  1470. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1471. private slots:
  1472. void updateLabel(const QString&text);
  1473. };
  1474. /*:749*//*753:*/
  1475. #line 11 "./settings.w"
  1476. class SettingsWindow:public QMainWindow
  1477. {
  1478. Q_OBJECT
  1479. public:
  1480. SettingsWindow();
  1481. };
  1482. /*:753*//*758:*/
  1483. #line 8 "./graphsettings.w"
  1484. class GraphSettingsWidget:public QWidget
  1485. {
  1486. Q_OBJECT
  1487. public:
  1488. GraphSettingsWidget();
  1489. };
  1490. /*:758*//*760:*/
  1491. #line 44 "./graphsettings.w"
  1492. class GraphSettingsRelativeTab:public QWidget
  1493. {
  1494. Q_OBJECT
  1495. public:
  1496. GraphSettingsRelativeTab();
  1497. public slots:
  1498. void updateEnableSetting(bool enable);
  1499. void updateColorSetting(const QString&color);
  1500. void updateAxisSetting(const QString&gridList);
  1501. void updateUnit(int unit);
  1502. void showColorPicker();
  1503. private:
  1504. QLineEdit*colorEdit;
  1505. };
  1506. /*:760*//*764:*/
  1507. #line 17027 "./typica.w"
  1508. class ModbusRTUDevice:public QObject
  1509. {
  1510. Q_OBJECT
  1511. public:
  1512. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1513. ~ModbusRTUDevice();
  1514. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1515. Q_INVOKABLE double SVLower();
  1516. Q_INVOKABLE double SVUpper();
  1517. Q_INVOKABLE int decimals();
  1518. QList<Channel*> channels;
  1519. public slots:
  1520. void outputSV(double sv);
  1521. signals:
  1522. void SVLowerChanged(double);
  1523. void SVUpperChanged(double);
  1524. void SVDecimalChanged(int);
  1525. void queueEmpty();
  1526. private slots:
  1527. void dataAvailable();
  1528. void sendNextMessage();
  1529. void decimalResponse(QByteArray response);
  1530. void unitResponse(QByteArray response);
  1531. void svlResponse(QByteArray response);
  1532. void svuResponse(QByteArray response);
  1533. void requestMeasurement();
  1534. void mResponse(QByteArray response);
  1535. void ignore(QByteArray response);
  1536. private:
  1537. QextSerialPort*port;
  1538. QByteArray responseBuffer;
  1539. QList<QByteArray> messageQueue;
  1540. QList<QObject*> retObjQueue;
  1541. QList<char*> callbackQueue;
  1542. quint16 calculateCRC(QByteArray data);
  1543. QTimer*messageDelayTimer;
  1544. int delayTime;
  1545. char station;
  1546. int decimalPosition;
  1547. int valueF;
  1548. int valueC;
  1549. bool unitIsF;
  1550. double outputSVLower;
  1551. double outputSVUpper;
  1552. QByteArray outputSVStub;
  1553. QByteArray pvStub;
  1554. QByteArray svStub;
  1555. QByteArray mStub;
  1556. quint16 pvaddress;
  1557. quint16 svaddress;
  1558. bool svenabled;
  1559. bool readingsv;
  1560. double savedpv;
  1561. bool waiting;
  1562. };
  1563. /*:764*//*779:*/
  1564. #line 17699 "./typica.w"
  1565. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1566. {
  1567. Q_OBJECT
  1568. public:
  1569. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1570. private slots:
  1571. void updatePort(const QString&newPort);
  1572. void updateBaudRate(const QString&newRate);
  1573. void updateParity(const QString&newParity);
  1574. void updateFlowControl(const QString&newFlow);
  1575. void updateStopBits(const QString&newStopBits);
  1576. void updateStation(int station);
  1577. void updateFixedDecimal(bool fixed);
  1578. void updateDecimalAddress(int address);
  1579. void updateDecimalPosition(int position);
  1580. void updateFixedUnit(bool fixed);
  1581. void updateUnitAddress(int address);
  1582. void updateValueForF(int value);
  1583. void updateValueForC(int value);
  1584. void updateUnit(const QString&newUnit);
  1585. void updatePVAddress(int address);
  1586. void updateSVEnabled(bool enabled);
  1587. void updateSVReadAddress(int address);
  1588. void updateDeviceLimit(bool query);
  1589. void updateSVLowerAddress(int address);
  1590. void updateSVUpperAddress(int address);
  1591. void updateSVLower(double value);
  1592. void updateSVUpper(double value);
  1593. void updateSVWritable(bool canWriteSV);
  1594. void updateSVWriteAddress(int address);
  1595. void updatePVColumnName(const QString&name);
  1596. void updateSVColumnName(const QString&name);
  1597. void updatePVHidden(bool hidden);
  1598. void updateSVHidden(bool hidden);
  1599. private:
  1600. PortSelector*port;
  1601. BaudSelector*baud;
  1602. ParitySelector*parity;
  1603. FlowSelector*flow;
  1604. StopSelector*stop;
  1605. QSpinBox*station;
  1606. QCheckBox*decimalQuery;
  1607. ShortHexSpinBox*decimalAddress;
  1608. QSpinBox*decimalPosition;
  1609. QCheckBox*unitQuery;
  1610. ShortHexSpinBox*unitAddress;
  1611. QSpinBox*valueF;
  1612. QSpinBox*valueC;
  1613. QComboBox*fixedUnit;
  1614. ShortHexSpinBox*pVAddress;
  1615. QCheckBox*sVEnabled;
  1616. ShortHexSpinBox*sVReadAddress;
  1617. QCheckBox*deviceLimit;
  1618. ShortHexSpinBox*sVLowerAddr;
  1619. ShortHexSpinBox*sVUpperAddr;
  1620. QDoubleSpinBox*sVLower;
  1621. QDoubleSpinBox*sVUpper;
  1622. QCheckBox*sVWritable;
  1623. ShortHexSpinBox*sVOutputAddr;
  1624. QLineEdit*pVColumnName;
  1625. QLineEdit*sVColumnName;
  1626. };
  1627. /*:779*//*783:*/
  1628. #line 18233 "./typica.w"
  1629. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1630. {
  1631. Q_OBJECT
  1632. public:
  1633. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1634. const QModelIndex&index);
  1635. private slots:
  1636. void updateSourceColumn(const QString&source);
  1637. void updateDestinationColumn(const QString&dest);
  1638. void updateKnots();
  1639. private:
  1640. SaltModel*tablemodel;
  1641. };
  1642. /*:783*//*789:*/
  1643. #line 18357 "./typica.w"
  1644. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1645. {
  1646. Q_OBJECT
  1647. public:
  1648. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1649. private slots:
  1650. void updateMatchingColumn(const QString&column);
  1651. void updateTemperature();
  1652. private:
  1653. QDoubleSpinBox*temperatureValue;
  1654. QComboBox*unitSelector;
  1655. };
  1656. /*:789*//*793:*/
  1657. #line 16 "./rate.w"
  1658. class RateOfChange:public QObject
  1659. {
  1660. Q_OBJECT
  1661. public:
  1662. RateOfChange(int cachetime= 1,int scaletime= 1);
  1663. public slots:
  1664. void newMeasurement(Measurement measure);
  1665. void setCacheTime(int seconds);
  1666. void setScaleTime(int seconds);
  1667. signals:
  1668. void newData(Measurement measure);
  1669. private:
  1670. int ct;
  1671. int st;
  1672. QList<Measurement> cache;
  1673. QMap<double,double> smoothCache;
  1674. };
  1675. /*:793*//*801:*/
  1676. #line 196 "./rate.w"
  1677. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1678. {
  1679. Q_OBJECT
  1680. public:
  1681. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1682. private slots:
  1683. void updateColumn(const QString&column);
  1684. void updateCacheTime(const QString&seconds);
  1685. void updateScaleTime(const QString&seconds);
  1686. };
  1687. /*:801*//*807:*/
  1688. #line 19 "./dataqsdk.w"
  1689. class DataqSdkDeviceImplementation;
  1690. class DataqSdkDevice:public QObject
  1691. {
  1692. Q_OBJECT
  1693. DataqSdkDeviceImplementation*imp;
  1694. private slots:
  1695. void threadFinished();
  1696. public:
  1697. DataqSdkDevice(QString device);
  1698. ~DataqSdkDevice();
  1699. Channel*newChannel(Units::Unit scale);
  1700. Q_INVOKABLE void setClockRate(double Hz);
  1701. Q_INVOKABLE void start();
  1702. static QStringList detectPorts();
  1703. static QStringList detectHardware();
  1704. };
  1705. /*:807*//*808:*/
  1706. #line 49 "./dataqsdk.w"
  1707. class DataqSdkDeviceImplementation:public QThread
  1708. {
  1709. Q_OBJECT
  1710. public:
  1711. DataqSdkDeviceImplementation();
  1712. ~DataqSdkDeviceImplementation();
  1713. void run();
  1714. /*809:*/
  1715. #line 70 "./dataqsdk.w"
  1716. typedef struct di_inlist_struct{
  1717. unsigned short chan;
  1718. unsigned short diff;
  1719. unsigned short gain;
  1720. unsigned short unipolar;
  1721. unsigned short dig_out_enable;
  1722. unsigned short dig_out;
  1723. unsigned short ave;
  1724. unsigned short counter;
  1725. }DI_INLIST_STRUCT;
  1726. typedef int(PASCAL*FPDIOPEN)(unsigned);
  1727. typedef int(PASCAL*FPDICLOSE)(void);
  1728. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  1729. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  1730. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  1731. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  1732. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  1733. typedef int(PASCAL*FPDISTARTSCAN)(void);
  1734. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  1735. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  1736. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  1737. typedef int(PASCAL*FPDISTOPSCAN)(void);
  1738. FPDIOPEN di_open;
  1739. FPDICLOSE di_close;
  1740. FPDISAMPLERATE di_sample_rate;
  1741. FPDIMAXIMUMRATE di_maximum_rate;
  1742. FPDILISTLENGTH di_list_length;
  1743. FPDIINLIST di_inlist;
  1744. FPDIBUFFERALLOC di_buffer_alloc;
  1745. FPDISTARTSCAN di_start_scan;
  1746. FPDISTATUSREAD di_status_read;
  1747. FPDIBUFFERSTATUS di_buffer_status;
  1748. FPDIBURSTRATE di_burst_rate;
  1749. FPDISTOPSCAN di_stop_scan;
  1750. /*:809*/
  1751. #line 57 "./dataqsdk.w"
  1752. /*811:*/
  1753. #line 134 "./dataqsdk.w"
  1754. bool isOpen;
  1755. double sampleRate;
  1756. long oversample;
  1757. long burstDivisor;
  1758. QString device;
  1759. unsigned deviceNumber;
  1760. QVector<Channel*> channelMap;
  1761. int error;
  1762. int channels;
  1763. bool ready;
  1764. QLibrary*driver;
  1765. QVector<Units::Unit> unitMap;
  1766. int*input_buffer;
  1767. QTimer*eventClock;
  1768. QMultiMap<int,double> smoother;
  1769. /*:811*/
  1770. #line 58 "./dataqsdk.w"
  1771. public slots:
  1772. void measure();
  1773. private:
  1774. qint16*buffer;
  1775. };
  1776. /*:808*//*828:*/
  1777. #line 663 "./dataqsdk.w"
  1778. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  1779. {
  1780. Q_OBJECT
  1781. public:
  1782. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  1783. const QModelIndex&index);
  1784. private slots:
  1785. void updateAutoSelect(bool automatic);
  1786. void updateDeviceNumber(int deviceNumber);
  1787. void updatePort(QString portId);
  1788. void addChannel();
  1789. private:
  1790. QStackedWidget*deviceIdStack;
  1791. };
  1792. /*:828*//*833:*/
  1793. #line 808 "./dataqsdk.w"
  1794. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  1795. {
  1796. Q_OBJECT
  1797. public:
  1798. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  1799. const QModelIndex&index);
  1800. private slots:
  1801. void updateUnits(const QString&unit);
  1802. void updateColumnName(const QString&value);
  1803. void updateMeasuredLower(const QString&value);
  1804. void updateMeasuredUpper(const QString&value);
  1805. void updateMappedLower(const QString&value);
  1806. void updateMappedUpper(const QString&value);
  1807. void updateClosedInterval(bool closed);
  1808. void updateSmoothingEnabled(bool enabled);
  1809. void updateSensitivity(const QString&value);
  1810. void startCalibration();
  1811. void stopCalibration();
  1812. void resetCalibration();
  1813. void updateInput(Measurement measure);
  1814. void updateOutput(Measurement measure);
  1815. void updateHidden(bool hidden);
  1816. private:
  1817. QPushButton*startButton;
  1818. QPushButton*resetButton;
  1819. QPushButton*stopButton;
  1820. /*838:*/
  1821. #line 1098 "./dataqsdk.w"
  1822. bool autoSelect;
  1823. QString deviceID;
  1824. int channelOfInterest;
  1825. /*:838*/
  1826. #line 835 "./dataqsdk.w"
  1827. DataqSdkDevice*calibrationDevice;
  1828. LinearCalibrator*calibrator;
  1829. QLineEdit*currentMeasurement;
  1830. QLineEdit*minimumMeasurement;
  1831. QLineEdit*maximumMeasurement;
  1832. QLineEdit*averageMeasurement;
  1833. QLineEdit*currentMapped;
  1834. QLineEdit*minimumMapped;
  1835. QLineEdit*maximumMapped;
  1836. QLineEdit*averageMapped;
  1837. int rmCount;
  1838. int cmCount;
  1839. double rmin;
  1840. double rmax;
  1841. double rmean;
  1842. double cmin;
  1843. double cmax;
  1844. double cmean;
  1845. };
  1846. /*:833*//*860:*/
  1847. #line 247 "./scales.w"
  1848. Q_DECLARE_METATYPE(BaudRateType)
  1849. Q_DECLARE_METATYPE(DataBitsType)
  1850. Q_DECLARE_METATYPE(ParityType)
  1851. Q_DECLARE_METATYPE(StopBitsType)
  1852. Q_DECLARE_METATYPE(FlowType)
  1853. /*:860*//*867:*/
  1854. #line 370 "./scales.w"
  1855. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  1856. {
  1857. Q_OBJECT
  1858. public:
  1859. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  1860. const QModelIndex&index);
  1861. private slots:
  1862. void updatePort(const QString&newPort);
  1863. void updateBaudRate(const QString&rate);
  1864. void updateParity(int index);
  1865. void updateFlowControl(int index);
  1866. void updateStopBits(int index);
  1867. private:
  1868. PortSelector*port;
  1869. BaudSelector*baud;
  1870. ParitySelector*parity;
  1871. FlowSelector*flow;
  1872. StopSelector*stop;
  1873. };
  1874. /*:867*//*872:*/
  1875. #line 14 "./valueannotation.w"
  1876. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1877. {
  1878. Q_OBJECT
  1879. public:
  1880. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  1881. const QModelIndex&index);
  1882. private slots:
  1883. void updateSourceColumn(const QString&source);
  1884. void updateAnnotations();
  1885. void updateStart(bool noteOnStart);
  1886. private:
  1887. SaltModel*tablemodel;
  1888. };
  1889. /*:872*//*880:*/
  1890. #line 165 "./valueannotation.w"
  1891. class ValueAnnotation:public QObject
  1892. {
  1893. Q_OBJECT
  1894. public:
  1895. ValueAnnotation();
  1896. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  1897. public slots:
  1898. void newMeasurement(Measurement measure);
  1899. void annotate();
  1900. void setAnnotationColumn(int column);
  1901. void setTemperatureColumn(int column);
  1902. void setTolerance(double epsilon);
  1903. signals:
  1904. void annotation(QString annotation,int tempcolumn,int notecolumn);
  1905. private:
  1906. int lastIndex;
  1907. int annotationColumn;
  1908. int measurementColumn;
  1909. QList<double> values;
  1910. QStringList annotations;
  1911. double tolerance;
  1912. };
  1913. /*:880*/
  1914. #line 761 "./typica.w"
  1915. /*25:*/
  1916. #line 1029 "./typica.w"
  1917. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  1918. /*:25*//*27:*/
  1919. #line 1044 "./typica.w"
  1920. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  1921. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  1922. /*:27*//*29:*/
  1923. #line 1069 "./typica.w"
  1924. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  1925. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  1926. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  1927. QScriptValue QWidget_activateWindow(QScriptContext*context,
  1928. QScriptEngine*engine);
  1929. /*:29*//*40:*/
  1930. #line 1313 "./typica.w"
  1931. QScriptValue constructQMainWindow(QScriptContext*context,
  1932. QScriptEngine*engine);
  1933. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  1934. QScriptEngine*engine);
  1935. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  1936. QScriptEngine*engine);
  1937. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  1938. /*:40*//*45:*/
  1939. #line 1412 "./typica.w"
  1940. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  1941. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  1942. /*:45*//*48:*/
  1943. #line 1457 "./typica.w"
  1944. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  1945. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  1946. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  1947. /*:48*//*51:*/
  1948. #line 1523 "./typica.w"
  1949. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  1950. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  1951. /*:51*//*54:*/
  1952. #line 1556 "./typica.w"
  1953. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  1954. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  1955. /*:54*//*57:*/
  1956. #line 1594 "./typica.w"
  1957. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  1958. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  1959. /*:57*//*61:*/
  1960. #line 1633 "./typica.w"
  1961. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  1962. QScriptValue QSplitter_addWidget(QScriptContext*context,
  1963. QScriptEngine*engine);
  1964. QScriptValue QSplitter_saveState(QScriptContext*context,
  1965. QScriptEngine*engine);
  1966. QScriptValue QSplitter_restoreState(QScriptContext*context,
  1967. QScriptEngine*engine);
  1968. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  1969. /*:61*//*66:*/
  1970. #line 1752 "./typica.w"
  1971. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  1972. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  1973. /*:66*//*68:*/
  1974. #line 1807 "./typica.w"
  1975. QScriptValue constructQBoxLayout(QScriptContext*context,
  1976. QScriptEngine*engine);
  1977. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  1978. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  1979. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  1980. /*:68*//*72:*/
  1981. #line 1920 "./typica.w"
  1982. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  1983. QScriptValue QAction_setShortcut(QScriptContext*context,
  1984. QScriptEngine*engine);
  1985. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  1986. /*:72*//*75:*/
  1987. #line 1976 "./typica.w"
  1988. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  1989. QScriptEngine*engine);
  1990. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  1991. QScriptEngine*engine);
  1992. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  1993. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  1994. /*:75*//*80:*/
  1995. #line 2087 "./typica.w"
  1996. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  1997. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  1998. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  1999. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2000. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2001. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2002. QScriptValue QIODevice_readToString(QScriptContext*context,
  2003. QScriptEngine*engine);
  2004. /*:80*//*87:*/
  2005. #line 2209 "./typica.w"
  2006. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2007. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2008. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2009. /*:87*//*90:*/
  2010. #line 2254 "./typica.w"
  2011. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2012. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2013. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2014. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2015. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2016. /*:90*//*96:*/
  2017. #line 2327 "./typica.w"
  2018. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2019. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2020. QScriptEngine*engine);
  2021. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2022. QScriptEngine*engine);
  2023. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2024. QScriptEngine*engine);
  2025. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2026. QScriptEngine*engine);
  2027. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2028. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2029. QScriptEngine*engine);
  2030. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2031. QScriptEngine*engine);
  2032. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2033. QScriptEngine*engine);
  2034. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2035. QScriptEngine*engine);
  2036. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2037. QScriptEngine*engine);
  2038. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2039. QScriptEngine*engine);
  2040. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2041. QScriptEngine*engine);
  2042. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2043. QScriptEngine*engine);
  2044. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2045. /*:96*//*105:*/
  2046. #line 2545 "./typica.w"
  2047. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2048. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2049. QScriptValue XmlReader_attribute(QScriptContext*context,
  2050. QScriptEngine*engine);
  2051. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2052. QScriptEngine*engine);
  2053. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2054. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2055. QScriptEngine*engine);
  2056. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2057. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2058. QScriptEngine*engine);
  2059. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2060. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2061. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2062. /*:105*//*112:*/
  2063. #line 2680 "./typica.w"
  2064. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2065. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2066. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2067. /*:112*//*116:*/
  2068. #line 2762 "./typica.w"
  2069. QScriptValue constructQLCDNumber(QScriptContext*context,
  2070. QScriptEngine*engine);
  2071. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2072. /*:116*//*119:*/
  2073. #line 2800 "./typica.w"
  2074. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2075. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2076. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2077. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2078. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2079. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2080. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2081. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2082. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2083. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2084. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2085. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2086. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2087. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2088. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2089. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2090. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2091. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2092. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2093. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2094. /*:119*//*134:*/
  2095. #line 3269 "./typica.w"
  2096. void setQAbstractScrollAreaProperties(QScriptValue value,
  2097. QScriptEngine*engine);
  2098. /*:134*//*136:*/
  2099. #line 3284 "./typica.w"
  2100. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2101. /*:136*//*138:*/
  2102. #line 3297 "./typica.w"
  2103. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2104. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2105. /*:138*//*140:*/
  2106. #line 3321 "./typica.w"
  2107. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2108. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2109. QScriptValue constructQPushButton(QScriptContext*context,
  2110. QScriptEngine*engine);
  2111. /*:140*//*147:*/
  2112. #line 3420 "./typica.w"
  2113. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2114. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2115. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2116. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2117. QScriptEngine*engine);
  2118. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2119. QScriptEngine*engine);
  2120. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2121. QScriptEngine*engine);
  2122. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2123. QScriptEngine*engine);
  2124. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2125. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2126. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2127. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2128. /*:147*//*154:*/
  2129. #line 3590 "./typica.w"
  2130. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2131. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2132. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2133. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2134. QScriptValue annotationFromRecord(QScriptContext*context,
  2135. QScriptEngine*engine);
  2136. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2137. /*:154*//*165:*/
  2138. #line 3873 "./typica.w"
  2139. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2140. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2141. QStack<QLayout*> *layoutStack);
  2142. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2143. QStack<QLayout*> *layoutStack);
  2144. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2145. QStack<QLayout*> *layoutStack);
  2146. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2147. QStack<QLayout*> *layoutStack);
  2148. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2149. QStack<QLayout*> *layoutStack);
  2150. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2151. QStack<QLayout*> *layoutStack);
  2152. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2153. QStack<QLayout*> *layoutStack);
  2154. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2155. QStack<QLayout*> *layoutStack);
  2156. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2157. QStack<QLayout*> *layoutStack);
  2158. void addTemperatureDisplayToSplitter(QDomElement element,
  2159. QStack<QWidget*> *widgetStack,
  2160. QStack<QLayout*> *layoutStack);
  2161. void addTemperatureDisplayToLayout(QDomElement element,
  2162. QStack<QWidget*> *widgetStack,
  2163. QStack<QLayout*> *layoutStack);
  2164. void addTimerDisplayToSplitter(QDomElement element,
  2165. QStack<QWidget*> *widgetStack,
  2166. QStack<QLayout*> *layoutStack);
  2167. void addTimerDisplayToLayout(QDomElement element,
  2168. QStack<QWidget*> *widgetStack,
  2169. QStack<QLayout*> *layoutStack);
  2170. void addDecorationToSplitter(QDomElement element,
  2171. QStack<QWidget*> *widgetStack,
  2172. QStack<QLayout*> *layoutStack);
  2173. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2174. QStack<QLayout*> *layoutStack);
  2175. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2176. QStack<QLayout*> *layoutStack);
  2177. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2178. QStack<QLayout*> *layoutStack);
  2179. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2180. QStack<QLayout*> *layoutStack);
  2181. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2182. QStack<QLayout*> *layoutStack);
  2183. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2184. QStack<QLayout*> *layoutStack);
  2185. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2186. QStack<QLayout*> *layoutStack);
  2187. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2188. QStack<QLayout*> *layoutStack);
  2189. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2190. QStack<QLayout*> *layoutStack);
  2191. void addSqlQueryViewToLayout(QDomElement element,
  2192. QStack<QWidget*> *widgetStack,
  2193. QStack<QLayout*> *layoutStack);
  2194. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2195. QStack<QLayout*> *layoutStack);
  2196. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2197. QStack<QLayout*> *layoutStack);
  2198. /*:165*//*216:*/
  2199. #line 5398 "./typica.w"
  2200. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2201. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2202. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2203. QScriptEngine*engine);
  2204. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2205. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2206. QScriptEngine*engine);
  2207. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2208. /*:216*//*217:*/
  2209. #line 5413 "./typica.w"
  2210. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2211. /*:217*//*221:*/
  2212. #line 5544 "./typica.w"
  2213. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2214. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2215. QScriptEngine*engine);
  2216. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2217. QScriptEngine*engine);
  2218. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2219. QScriptEngine*engine);
  2220. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2221. QScriptEngine*engine);
  2222. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2223. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2224. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2225. QScriptEngine*engine);
  2226. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2227. /*:221*//*228:*/
  2228. #line 5714 "./typica.w"
  2229. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2230. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2231. QScriptValue QComboBox_currentData(QScriptContext*context,
  2232. QScriptEngine*engine);
  2233. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2234. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2235. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2236. /*:228*//*240:*/
  2237. #line 374 "./units.w"
  2238. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2239. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2240. QScriptEngine*engine);
  2241. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2242. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2243. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2244. /*:240*//*244:*/
  2245. #line 438 "./units.w"
  2246. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2247. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2248. /*:244*//*267:*/
  2249. #line 6340 "./typica.w"
  2250. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2251. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2252. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2253. /*:267*//*276:*/
  2254. #line 6545 "./typica.w"
  2255. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2256. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2257. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2258. /*:276*//*281:*/
  2259. #line 6646 "./typica.w"
  2260. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2261. /*:281*//*287:*/
  2262. #line 6828 "./typica.w"
  2263. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2264. QScriptEngine*engine);
  2265. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2266. /*:287*//*292:*/
  2267. #line 6968 "./typica.w"
  2268. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2269. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2270. /*:292*//*302:*/
  2271. #line 7170 "./typica.w"
  2272. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2273. QScriptEngine*engine);
  2274. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2275. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2276. QScriptEngine*engine);
  2277. /*:302*//*310:*/
  2278. #line 7329 "./typica.w"
  2279. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2280. QScriptEngine*engine);
  2281. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2282. QScriptEngine*engine);
  2283. /*:310*//*315:*/
  2284. #line 7442 "./typica.w"
  2285. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2286. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2287. /*:315*//*320:*/
  2288. #line 7540 "./typica.w"
  2289. QScriptValue constructZeroEmitter(QScriptContext*context,
  2290. QScriptEngine*engine);
  2291. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2292. /*:320*//*325:*/
  2293. #line 7619 "./typica.w"
  2294. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2295. QScriptEngine*engine);
  2296. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2297. /*:325*//*342:*/
  2298. #line 8083 "./typica.w"
  2299. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2300. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2301. /*:342*//*365:*/
  2302. #line 8710 "./typica.w"
  2303. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2304. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2305. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2306. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2307. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2308. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2309. QScriptEngine*engine);
  2310. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2311. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2312. QScriptEngine*engnie);
  2313. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2314. QScriptEngine*engine);
  2315. /*:365*//*403:*/
  2316. #line 9664 "./typica.w"
  2317. QScriptValue constructAnnotationButton(QScriptContext*context,
  2318. QScriptEngine*engine);
  2319. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2320. /*:403*//*411:*/
  2321. #line 9804 "./typica.w"
  2322. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2323. QScriptEngine*engine);
  2324. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2325. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2326. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2327. /*:411*//*432:*/
  2328. #line 10227 "./typica.w"
  2329. QScriptValue constructTimerDisplay(QScriptContext*context,
  2330. QScriptEngine*engine);
  2331. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2332. /*:432*//*459:*/
  2333. #line 10721 "./typica.w"
  2334. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2335. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2336. QScriptEngine*engine);
  2337. /*:459*//*472:*/
  2338. #line 11004 "./typica.w"
  2339. QScriptValue constructLogEditWindow(QScriptContext*context,
  2340. QScriptEngine*engine);
  2341. /*:472*//*491:*/
  2342. #line 11536 "./typica.w"
  2343. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2344. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2345. /*:491*//*509:*/
  2346. #line 184 "./webview.w"
  2347. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2348. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2349. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2350. QStack<QLayout*> *layoutStack);
  2351. /*:509*//*512:*/
  2352. #line 214 "./webview.w"
  2353. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2354. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2355. /*:512*//*516:*/
  2356. #line 272 "./webview.w"
  2357. QScriptValue constructWebElement(QScriptContext*context,
  2358. QScriptEngine*engine);
  2359. /*:516*//*579:*/
  2360. #line 12751 "./typica.w"
  2361. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2362. QScriptValue constructSqlQueryView(QScriptContext*context,
  2363. QScriptEngine*engine);
  2364. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2365. QScriptEngine*engine);
  2366. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2367. QScriptEngine*engine);
  2368. /*:579*//*589:*/
  2369. #line 12980 "./typica.w"
  2370. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2371. QStack<QLayout*> *layoutStack);
  2372. /*:589*//*605:*/
  2373. #line 13264 "./typica.w"
  2374. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2375. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2376. /*:605*//*615:*/
  2377. #line 13459 "./typica.w"
  2378. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2379. QStack<QLayout*> *layoutStack);
  2380. /*:615*//*636:*/
  2381. #line 14043 "./typica.w"
  2382. void addScaleControlToLayout(QDomElement element,
  2383. QStack<QWidget*> *widgetStack,
  2384. QStack<QLayout*> *layoutStack);
  2385. void addIntensityControlToLayout(QDomElement element,
  2386. QStack<QWidget*> *widgetStack,
  2387. QStack<QLayout*> *layoutStack);
  2388. /*:636*//*662:*/
  2389. #line 14629 "./typica.w"
  2390. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2391. QScriptEngine*engine);
  2392. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2393. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2394. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2395. QScriptEngine*engine);
  2396. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2397. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2398. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2399. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2400. /*:662*//*668:*/
  2401. #line 14771 "./typica.w"
  2402. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2403. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2404. /*:668*//*684:*/
  2405. #line 15068 "./typica.w"
  2406. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2407. QScriptEngine*engine);
  2408. /*:684*//*755:*/
  2409. #line 37 "./settings.w"
  2410. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2411. /*:755*//*774:*/
  2412. #line 17606 "./typica.w"
  2413. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2414. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2415. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2416. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2417. /*:774*//*798:*/
  2418. #line 157 "./rate.w"
  2419. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2420. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2421. /*:798*//*823:*/
  2422. #line 597 "./dataqsdk.w"
  2423. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2424. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2425. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2426. /*:823*//*850:*/
  2427. #line 67 "./scales.w"
  2428. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2429. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2430. /*:850*//*858:*/
  2431. #line 233 "./scales.w"
  2432. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2433. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2434. /*:858*//*861:*/
  2435. #line 258 "./scales.w"
  2436. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2437. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2438. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2439. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2440. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2441. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2442. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2443. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2444. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2445. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2446. /*:861*//*886:*/
  2447. #line 265 "./valueannotation.w"
  2448. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2449. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2450. /*:886*/
  2451. #line 762 "./typica.w"
  2452. /*17:*/
  2453. #line 770 "./typica.w"
  2454. /*676:*/
  2455. #line 14892 "./typica.w"
  2456. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2457. const QString&driver,QObject*parent):
  2458. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2459. {
  2460. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2461. }
  2462. void NodeInserter::onTriggered()
  2463. {
  2464. emit triggered(defaultNodeName,driverString);
  2465. }
  2466. /*:676*/
  2467. #line 771 "./typica.w"
  2468. /*249:*/
  2469. #line 40 "./measurement.w"
  2470. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2471. {
  2472. insert("measurement",temperature);
  2473. insert("time",time);
  2474. insert("unit",sc);
  2475. }
  2476. Measurement::Measurement(double temperature)
  2477. {
  2478. insert("measurement",temperature);
  2479. insert("time",QTime::currentTime());
  2480. insert("unit",Units::Fahrenheit);
  2481. }
  2482. void Measurement::setTemperature(double temperature)
  2483. {
  2484. insert("measurement",temperature);
  2485. }
  2486. void Measurement::setTime(QTime time)
  2487. {
  2488. insert("time",time);
  2489. }
  2490. void Measurement::setUnit(Units::Unit scale)
  2491. {
  2492. insert("unit",scale);
  2493. }
  2494. double Measurement::temperature()const
  2495. {
  2496. return value("measurement").toDouble();
  2497. }
  2498. QTime Measurement::time()const
  2499. {
  2500. return value("time").toTime();
  2501. }
  2502. Units::Unit Measurement::scale()const
  2503. {
  2504. return(Units::Unit)(value("unit").toInt());
  2505. }
  2506. /*:249*//*250:*/
  2507. #line 88 "./measurement.w"
  2508. Measurement Measurement::toFahrenheit()
  2509. {
  2510. return Measurement(Units::convertTemperature(this->temperature(),
  2511. this->scale(),Units::Fahrenheit),
  2512. this->time(),Units::Fahrenheit);
  2513. }
  2514. Measurement Measurement::toCelsius()
  2515. {
  2516. return Measurement(Units::convertTemperature(this->temperature(),
  2517. this->scale(),Units::Celsius),
  2518. this->time(),Units::Celsius);
  2519. }
  2520. Measurement Measurement::toKelvin()
  2521. {
  2522. return Measurement(Units::convertTemperature(this->temperature(),
  2523. this->scale(),Units::Kelvin),
  2524. this->time(),Units::Kelvin);
  2525. }
  2526. Measurement Measurement::toRankine()
  2527. {
  2528. return Measurement(Units::convertTemperature(this->temperature(),
  2529. this->scale(),Units::Rankine),
  2530. this->time(),Units::Rankine);
  2531. }
  2532. /*:250*/
  2533. #line 772 "./typica.w"
  2534. /*257:*/
  2535. #line 5946 "./typica.w"
  2536. void DAQImplementation::measure()
  2537. {
  2538. int samplesRead= 0;
  2539. double buffer[channels];
  2540. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2541. (unsigned long)(0),buffer,(unsigned long)(channels),
  2542. &samplesRead,(signed long)(0));
  2543. if(error)
  2544. {
  2545. ready= false;
  2546. }
  2547. else
  2548. {
  2549. if(samplesRead)
  2550. {
  2551. QTime time= QTime::currentTime();
  2552. for(int i= 0;i<samplesRead;i++)
  2553. {
  2554. for(int j= 0;j<channels;j++)
  2555. {
  2556. Measurement measure(buffer[j+(i*channels)],time,
  2557. unitMap[j]);
  2558. channelMap[j]->input(measure);
  2559. }
  2560. }
  2561. }
  2562. }
  2563. }
  2564. /*:257*//*258:*/
  2565. #line 5988 "./typica.w"
  2566. void DAQImplementation::run()
  2567. {
  2568. setPriority(QThread::TimeCriticalPriority);
  2569. while(ready)
  2570. {
  2571. measure();
  2572. }
  2573. }
  2574. /*:258*//*259:*/
  2575. #line 6004 "./typica.w"
  2576. void DAQ::threadFinished()
  2577. {
  2578. if(imp->error)
  2579. {
  2580. /*260:*/
  2581. #line 6055 "./typica.w"
  2582. imp->ready= false;
  2583. QMessageBox warning;
  2584. warning.setStandardButtons(QMessageBox::Cancel);
  2585. warning.setIcon(QMessageBox::Warning);
  2586. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2587. unsigned long bytes= imp->errorInfo(NULL,0);
  2588. char string[bytes];
  2589. imp->errorInfo(string,bytes);
  2590. warning.setInformativeText(QString(string));
  2591. warning.setWindowTitle(QString(PROGRAM_NAME));
  2592. warning.exec();
  2593. /*:260*/
  2594. #line 6009 "./typica.w"
  2595. }
  2596. }
  2597. /*:259*//*261:*/
  2598. #line 6080 "./typica.w"
  2599. void DAQ::start()
  2600. {
  2601. if(imp->ready)
  2602. {
  2603. imp->error= imp->startTask(imp->handle);
  2604. if(imp->error)
  2605. {
  2606. /*260:*/
  2607. #line 6055 "./typica.w"
  2608. imp->ready= false;
  2609. QMessageBox warning;
  2610. warning.setStandardButtons(QMessageBox::Cancel);
  2611. warning.setIcon(QMessageBox::Warning);
  2612. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2613. unsigned long bytes= imp->errorInfo(NULL,0);
  2614. char string[bytes];
  2615. imp->errorInfo(string,bytes);
  2616. warning.setInformativeText(QString(string));
  2617. warning.setWindowTitle(QString(PROGRAM_NAME));
  2618. warning.exec();
  2619. /*:260*/
  2620. #line 6088 "./typica.w"
  2621. }
  2622. else
  2623. {
  2624. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2625. imp->start();
  2626. }
  2627. }
  2628. }
  2629. void DAQ::stop()
  2630. {
  2631. if(imp->useBase)
  2632. {
  2633. imp->ready= false;
  2634. imp->wait(ULONG_MAX);
  2635. imp->stopTask(imp->handle);
  2636. }
  2637. else
  2638. {
  2639. imp->ready= false;
  2640. imp->error= imp->stopTask(imp->handle);
  2641. if(imp->error)
  2642. {
  2643. /*260:*/
  2644. #line 6055 "./typica.w"
  2645. imp->ready= false;
  2646. QMessageBox warning;
  2647. warning.setStandardButtons(QMessageBox::Cancel);
  2648. warning.setIcon(QMessageBox::Warning);
  2649. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2650. unsigned long bytes= imp->errorInfo(NULL,0);
  2651. char string[bytes];
  2652. imp->errorInfo(string,bytes);
  2653. warning.setInformativeText(QString(string));
  2654. warning.setWindowTitle(QString(PROGRAM_NAME));
  2655. warning.exec();
  2656. /*:260*/
  2657. #line 6112 "./typica.w"
  2658. }
  2659. imp->error= imp->clearTask(imp->handle);
  2660. if(imp->error)
  2661. {
  2662. /*260:*/
  2663. #line 6055 "./typica.w"
  2664. imp->ready= false;
  2665. QMessageBox warning;
  2666. warning.setStandardButtons(QMessageBox::Cancel);
  2667. warning.setIcon(QMessageBox::Warning);
  2668. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2669. unsigned long bytes= imp->errorInfo(NULL,0);
  2670. char string[bytes];
  2671. imp->errorInfo(string,bytes);
  2672. warning.setInformativeText(QString(string));
  2673. warning.setWindowTitle(QString(PROGRAM_NAME));
  2674. warning.exec();
  2675. /*:260*/
  2676. #line 6117 "./typica.w"
  2677. }
  2678. }
  2679. }
  2680. /*:261*//*262:*/
  2681. #line 6127 "./typica.w"
  2682. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  2683. {
  2684. imp->device= device;
  2685. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  2686. if(imp->error)
  2687. {
  2688. /*260:*/
  2689. #line 6055 "./typica.w"
  2690. imp->ready= false;
  2691. QMessageBox warning;
  2692. warning.setStandardButtons(QMessageBox::Cancel);
  2693. warning.setIcon(QMessageBox::Warning);
  2694. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2695. unsigned long bytes= imp->errorInfo(NULL,0);
  2696. char string[bytes];
  2697. imp->errorInfo(string,bytes);
  2698. warning.setInformativeText(QString(string));
  2699. warning.setWindowTitle(QString(PROGRAM_NAME));
  2700. warning.exec();
  2701. /*:260*/
  2702. #line 6134 "./typica.w"
  2703. }
  2704. else
  2705. {
  2706. imp->ready= true;
  2707. }
  2708. }
  2709. /*:262*//*263:*/
  2710. #line 6148 "./typica.w"
  2711. Channel*DAQ::newChannel(int units,int thermocouple)
  2712. {
  2713. Channel*retval= new Channel();
  2714. imp->channelMap[imp->channels]= retval;
  2715. imp->unitMap[imp->channels]= (Units::Unit)units;
  2716. imp->channels++;
  2717. if(imp->ready)
  2718. {
  2719. if(imp->useBase)
  2720. {
  2721. imp->error= imp->createChannel(imp->handle,
  2722. QString("%1/ai%2").arg(imp->device).
  2723. arg(imp->channels-1).
  2724. toAscii().data(),
  2725. "",(double)(-1.0),(double)(100.0),
  2726. (signed long)(units),
  2727. (signed long)(thermocouple),
  2728. (signed long)(10200),(double)(0),
  2729. "");
  2730. }
  2731. else
  2732. {
  2733. imp->error= imp->createChannel(imp->handle,
  2734. QString("%1/ai%2").arg(imp->device).
  2735. arg(imp->channels-1).
  2736. toAscii().data(),
  2737. "",(double)(50.0),(double)(500.0),
  2738. (signed long)(units),
  2739. (signed long)(thermocouple),
  2740. (signed long)(10200),(double)(0),
  2741. "");
  2742. }
  2743. if(imp->error)
  2744. {
  2745. /*260:*/
  2746. #line 6055 "./typica.w"
  2747. imp->ready= false;
  2748. QMessageBox warning;
  2749. warning.setStandardButtons(QMessageBox::Cancel);
  2750. warning.setIcon(QMessageBox::Warning);
  2751. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2752. unsigned long bytes= imp->errorInfo(NULL,0);
  2753. char string[bytes];
  2754. imp->errorInfo(string,bytes);
  2755. warning.setInformativeText(QString(string));
  2756. warning.setWindowTitle(QString(PROGRAM_NAME));
  2757. warning.exec();
  2758. /*:260*/
  2759. #line 6183 "./typica.w"
  2760. }
  2761. }
  2762. return retval;
  2763. }
  2764. /*:263*//*264:*/
  2765. #line 6197 "./typica.w"
  2766. void DAQ::setClockRate(double Hz)
  2767. {
  2768. if(imp->ready)
  2769. {
  2770. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  2771. (signed long)(10280),(signed long)(10123),
  2772. (unsigned long long)(1));
  2773. if(imp->error)
  2774. {
  2775. /*260:*/
  2776. #line 6055 "./typica.w"
  2777. imp->ready= false;
  2778. QMessageBox warning;
  2779. warning.setStandardButtons(QMessageBox::Cancel);
  2780. warning.setIcon(QMessageBox::Warning);
  2781. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2782. unsigned long bytes= imp->errorInfo(NULL,0);
  2783. char string[bytes];
  2784. imp->errorInfo(string,bytes);
  2785. warning.setInformativeText(QString(string));
  2786. warning.setWindowTitle(QString(PROGRAM_NAME));
  2787. warning.exec();
  2788. /*:260*/
  2789. #line 6207 "./typica.w"
  2790. }
  2791. }
  2792. }
  2793. /*:264*//*265:*/
  2794. #line 6217 "./typica.w"
  2795. DAQ::~DAQ()
  2796. {
  2797. if(imp->useBase)
  2798. {
  2799. imp->resetDevice(imp->device.toAscii().data());
  2800. imp->clearTask(imp->handle);
  2801. }
  2802. else
  2803. {
  2804. if(imp->ready)
  2805. {
  2806. imp->ready= false;
  2807. imp->wait(ULONG_MAX);
  2808. imp->stopTask(imp->handle);
  2809. imp->resetDevice(imp->device.toAscii().data());
  2810. imp->clearTask(imp->handle);
  2811. }
  2812. }
  2813. delete imp;
  2814. }
  2815. /*:265*//*266:*/
  2816. #line 6248 "./typica.w"
  2817. DAQImplementation::DAQImplementation(const QString&driverinfo)
  2818. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  2819. unitMap(4)
  2820. {
  2821. if(driverinfo=="nidaqmxbase")
  2822. {
  2823. useBase= true;
  2824. }
  2825. else
  2826. {
  2827. useBase= false;
  2828. }
  2829. if(useBase)
  2830. {
  2831. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  2832. if(!driver.load())
  2833. {
  2834. driver.setFileName("nidaqmxbase");
  2835. if(!driver.load())
  2836. {
  2837. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2838. tr("Failed to find nidaqmxbase. Please install it."));
  2839. QApplication::quit();
  2840. }
  2841. }
  2842. }
  2843. else
  2844. {
  2845. driver.setFileName("nicaiu");
  2846. if(!driver.load())
  2847. {
  2848. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2849. tr("Failed to find nidaqmx. Please install it."));
  2850. QApplication::quit();
  2851. }
  2852. }
  2853. if(useBase)
  2854. {
  2855. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  2856. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  2857. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  2858. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  2859. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  2860. ==0||
  2861. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  2862. 0||
  2863. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  2864. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  2865. 0||
  2866. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  2867. {
  2868. waitForMeasurement= NULL;
  2869. QMessageBox::critical(NULL,tr("Typica: Link error"),
  2870. tr("Failed to link a required symbol in NI-DAQmxBase."));
  2871. QApplication::quit();
  2872. }
  2873. }
  2874. else
  2875. {
  2876. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  2877. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  2878. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  2879. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  2880. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  2881. ==0||
  2882. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  2883. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  2884. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  2885. 0||
  2886. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  2887. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  2888. {
  2889. QMessageBox::critical(NULL,tr("Typica: Link error"),
  2890. tr("Failed to link a required symbol in NI-DAQmx."));
  2891. QApplication::quit();
  2892. }
  2893. }
  2894. }
  2895. DAQImplementation::~DAQImplementation()
  2896. {
  2897. driver.unload();
  2898. }
  2899. /*:266*/
  2900. #line 773 "./typica.w"
  2901. /*812:*/
  2902. #line 197 "./dataqsdk.w"
  2903. void DataqSdkDeviceImplementation::measure()
  2904. {
  2905. unsigned count= channels*40;
  2906. di_status_read(buffer,count);
  2907. QTime time= QTime::currentTime();
  2908. for(unsigned int i= 0;i<count;i++)
  2909. {
  2910. buffer[i]= buffer[i]&0xFFFC;
  2911. }
  2912. QList<int> countList;
  2913. for(unsigned int i= 0;i<(unsigned)channels;i++)
  2914. {
  2915. QList<double> channelBuffer;
  2916. for(unsigned int j= 0;j<40;j++)
  2917. {
  2918. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  2919. if(i==0)
  2920. {
  2921. countList<<buffer[i+(channels*j)];
  2922. }
  2923. }
  2924. double value= 0.0;
  2925. for(unsigned int j= 0;j<40;j++)
  2926. {
  2927. value+= channelBuffer[j];
  2928. }
  2929. value/= 40.0;
  2930. if(i==0)
  2931. {
  2932. QList<double> smoothingList;
  2933. smoothingList<<value;
  2934. QList<int> smoothingKeys= smoother.uniqueKeys();
  2935. for(int j= 0;j<smoothingKeys.size();j++)
  2936. {
  2937. if(countList.contains(smoothingKeys[j]))
  2938. {
  2939. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  2940. for(int k= 0;k<keyValues.size();k++)
  2941. {
  2942. smoothingList<<keyValues[k];
  2943. }
  2944. }
  2945. else
  2946. {
  2947. smoother.remove(smoothingKeys[j]);
  2948. }
  2949. }
  2950. qSort(countList);
  2951. int lastCount= 0;
  2952. for(int j= 0;j<countList.size();j++)
  2953. {
  2954. if(j==0||countList[j]!=lastCount)
  2955. {
  2956. smoother.insert(countList[j],value);
  2957. lastCount= countList[j];
  2958. }
  2959. }
  2960. value= 0.0;
  2961. for(int j= 0;j<smoothingList.size();j++)
  2962. {
  2963. value+= smoothingList[j];
  2964. }
  2965. value/= smoothingList.size();
  2966. }
  2967. Measurement measure(value,time,unitMap[i]);
  2968. channelMap[i]->input(measure);
  2969. }
  2970. }
  2971. /*:812*//*813:*/
  2972. #line 290 "./dataqsdk.w"
  2973. void DataqSdkDeviceImplementation::run()
  2974. {
  2975. if(!ready)
  2976. {
  2977. error= 9;
  2978. return;
  2979. }
  2980. driver= new QLibrary(device);
  2981. if(!driver->load())
  2982. {
  2983. error= 1;
  2984. qDebug()<<"Failed to load driver: "<<device;
  2985. return;
  2986. }
  2987. di_open= (FPDIOPEN)driver->resolve("di_open");
  2988. di_close= (FPDICLOSE)driver->resolve("di_close");
  2989. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  2990. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  2991. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  2992. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  2993. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  2994. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  2995. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  2996. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  2997. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  2998. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  2999. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3000. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3001. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3002. (!di_burst_rate)||(!di_stop_scan))
  3003. {
  3004. error= 2;
  3005. return;
  3006. }
  3007. error= di_open(deviceNumber);
  3008. if(error)
  3009. {
  3010. di_close();
  3011. error= di_open(deviceNumber);
  3012. if(error)
  3013. {
  3014. error= 3;
  3015. di_close();
  3016. return;
  3017. }
  3018. }
  3019. isOpen= true;
  3020. di_maximum_rate(240.0);
  3021. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3022. &burstDivisor);
  3023. buffer= new qint16[(int)sampleRate];
  3024. di_inlist_struct inlist[16]= {{0}};
  3025. for(unsigned short i= 0;i<channels;i++)
  3026. {
  3027. inlist[i].chan= i;
  3028. inlist[i].gain= 0;
  3029. inlist[i].ave= 1;
  3030. inlist[i].counter= (oversample-1);
  3031. }
  3032. error= di_list_length(channels,0);
  3033. if(error)
  3034. {
  3035. error= 4;
  3036. return;
  3037. }
  3038. error= di_inlist(inlist);
  3039. if(error)
  3040. {
  3041. error= 5;
  3042. return;
  3043. }
  3044. input_buffer= di_buffer_alloc(0,4096);
  3045. if(input_buffer==NULL)
  3046. {
  3047. error= 6;
  3048. return;
  3049. }
  3050. error= di_start_scan();
  3051. if(error)
  3052. {
  3053. error= 7;
  3054. return;
  3055. }
  3056. while(ready)
  3057. {
  3058. measure();
  3059. }
  3060. }
  3061. /*:813*//*814:*/
  3062. #line 386 "./dataqsdk.w"
  3063. void DataqSdkDevice::threadFinished()
  3064. {
  3065. if(imp->error)
  3066. {
  3067. /*815:*/
  3068. #line 400 "./dataqsdk.w"
  3069. imp->ready= false;
  3070. QMessageBox warning;
  3071. warning.setStandardButtons(QMessageBox::Cancel);
  3072. warning.setIcon(QMessageBox::Warning);
  3073. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3074. warning.setInformativeText(tr("An error occurred"));
  3075. warning.setWindowTitle(QString(PROGRAM_NAME));
  3076. warning.exec();
  3077. /*:815*/
  3078. #line 391 "./dataqsdk.w"
  3079. }
  3080. }
  3081. /*:814*//*816:*/
  3082. #line 417 "./dataqsdk.w"
  3083. void DataqSdkDevice::start()
  3084. {
  3085. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3086. imp->start();
  3087. }
  3088. /*:816*//*817:*/
  3089. #line 428 "./dataqsdk.w"
  3090. QStringList DataqSdkDevice::detectHardware()
  3091. {
  3092. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3093. QSettings::NativeFormat);
  3094. QStringList keys= deviceLookup.childKeys();
  3095. QStringList devices;
  3096. for(int i= 0;i<keys.size();i++)
  3097. {
  3098. QString value= deviceLookup.value(keys.at(i)).toString();
  3099. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3100. {
  3101. devices.append(value.split("\\").at(2));
  3102. }
  3103. }
  3104. QStringList portList;
  3105. foreach(QString device,devices)
  3106. {
  3107. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3108. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3109. portList.append(deviceEntry.value("FriendlyName").toString());
  3110. }
  3111. return portList;
  3112. }
  3113. QStringList DataqSdkDevice::detectPorts()
  3114. {
  3115. QStringList friendlyNames= detectHardware();
  3116. QStringList portList;
  3117. foreach(QString name,friendlyNames)
  3118. {
  3119. name.remove(0,name.indexOf("COM"));
  3120. name.chop(1);
  3121. portList.append(name);
  3122. }
  3123. return portList;
  3124. }
  3125. /*:817*//*818:*/
  3126. #line 473 "./dataqsdk.w"
  3127. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3128. {
  3129. bool usesAuto= false;
  3130. int autoIndex= device.toInt(&usesAuto);
  3131. QString finalizedPort;
  3132. if(usesAuto)
  3133. {
  3134. QStringList portList= detectPorts();
  3135. if(autoIndex> 0&&autoIndex<=portList.size())
  3136. {
  3137. finalizedPort= portList.at(autoIndex-1);
  3138. }
  3139. else
  3140. {
  3141. imp->error= 8;
  3142. qDebug()<<"Failed to detect port.";
  3143. }
  3144. }
  3145. else
  3146. {
  3147. finalizedPort= device;
  3148. }
  3149. int rstart= finalizedPort.indexOf("COM");
  3150. finalizedPort.remove(0,rstart+3);
  3151. bool chopFinished= false;
  3152. int finalizedPortNumber;
  3153. while(finalizedPort.size()> 0&&!chopFinished)
  3154. {
  3155. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3156. if(!chopFinished)
  3157. {
  3158. finalizedPort.chop(1);
  3159. }
  3160. }
  3161. if(finalizedPortNumber<10)
  3162. {
  3163. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3164. }
  3165. else
  3166. {
  3167. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3168. }
  3169. imp->deviceNumber= 0x12C02D00;
  3170. imp->deviceNumber+= finalizedPortNumber;
  3171. imp->ready= true;
  3172. }
  3173. /*:818*//*819:*/
  3174. #line 523 "./dataqsdk.w"
  3175. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3176. {
  3177. Channel*retval= NULL;
  3178. if(imp->ready)
  3179. {
  3180. retval= new Channel();
  3181. imp->channelMap[imp->channels]= retval;
  3182. imp->unitMap[imp->channels]= scale;
  3183. imp->channels++;
  3184. }
  3185. return retval;
  3186. }
  3187. /*:819*//*820:*/
  3188. #line 547 "./dataqsdk.w"
  3189. void DataqSdkDevice::setClockRate(double Hz)
  3190. {
  3191. imp->sampleRate= Hz;
  3192. }
  3193. /*:820*//*821:*/
  3194. #line 557 "./dataqsdk.w"
  3195. DataqSdkDevice::~DataqSdkDevice()
  3196. {
  3197. if(imp->ready)
  3198. {
  3199. imp->ready= false;
  3200. }
  3201. imp->wait(ULONG_MAX);
  3202. delete imp;
  3203. }
  3204. /*:821*//*822:*/
  3205. #line 575 "./dataqsdk.w"
  3206. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3207. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3208. {
  3209. }
  3210. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3211. {
  3212. if(isOpen)
  3213. {
  3214. di_stop_scan();
  3215. di_close();
  3216. }
  3217. if(driver->isLoaded())
  3218. {
  3219. driver->unload();
  3220. }
  3221. }
  3222. /*:822*/
  3223. #line 774 "./typica.w"
  3224. /*273:*/
  3225. #line 6457 "./typica.w"
  3226. void FakeDAQImplementation::measure()
  3227. {
  3228. msleep((int)(1000/clockRate));
  3229. QTime time= QTime::currentTime();
  3230. for(int i= 0;i<channels;i++)
  3231. {
  3232. Measurement measure(qrand()%500,time);
  3233. channelMap[i]->input(measure);
  3234. }
  3235. }
  3236. /*:273*//*274:*/
  3237. #line 6471 "./typica.w"
  3238. void FakeDAQImplementation::run()
  3239. {
  3240. setPriority(QThread::TimeCriticalPriority);
  3241. while(ready)
  3242. {
  3243. measure();
  3244. }
  3245. }
  3246. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3247. channels(0),ready(false),clockRate(1)
  3248. {
  3249. }
  3250. FakeDAQImplementation::~FakeDAQImplementation()
  3251. {
  3252. }
  3253. /*:274*//*275:*/
  3254. #line 6496 "./typica.w"
  3255. void FakeDAQ::start()
  3256. {
  3257. if(imp->ready)
  3258. {
  3259. imp->start();
  3260. }
  3261. }
  3262. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3263. {
  3264. imp->ready= true;
  3265. }
  3266. Channel*FakeDAQ::newChannel(int,int)
  3267. {
  3268. Channel*retval;
  3269. if(imp->ready)
  3270. {
  3271. retval= new Channel();
  3272. imp->channelMap[imp->channels]= retval;
  3273. imp->channels++;
  3274. }
  3275. else
  3276. {
  3277. return NULL;
  3278. }
  3279. return retval;
  3280. }
  3281. void FakeDAQ::setClockRate(double Hz)
  3282. {
  3283. if(imp->ready)
  3284. {
  3285. imp->clockRate= Hz;
  3286. }
  3287. }
  3288. FakeDAQ::~FakeDAQ()
  3289. {
  3290. imp->ready= false;
  3291. imp->wait(ULONG_MAX);
  3292. delete imp;
  3293. }
  3294. /*:275*/
  3295. #line 775 "./typica.w"
  3296. /*280:*/
  3297. #line 6627 "./typica.w"
  3298. Channel::Channel():QObject(NULL)
  3299. {
  3300. }
  3301. Channel::~Channel()
  3302. {
  3303. }
  3304. void Channel::input(Measurement measurement)
  3305. {
  3306. emit newData(measurement);
  3307. }
  3308. /*:280*/
  3309. #line 776 "./typica.w"
  3310. /*296:*/
  3311. #line 7032 "./typica.w"
  3312. void TemperatureDisplay::setRelativeMode(bool relative)
  3313. {
  3314. r= relative;
  3315. }
  3316. /*:296*//*297:*/
  3317. #line 7049 "./typica.w"
  3318. void TemperatureDisplay::setValue(Measurement temperature)
  3319. {
  3320. QString number;
  3321. switch(unit)
  3322. {
  3323. case Units::Fahrenheit:
  3324. display(QString("%1'F").
  3325. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3326. 2)));
  3327. break;
  3328. case Units::Celsius:
  3329. if(!r){
  3330. display(QString("%1'C").
  3331. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3332. 2)));
  3333. }else{
  3334. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3335. display(QString("%1'C").arg(number));
  3336. }
  3337. break;
  3338. case Units::Kelvin:
  3339. if(!r){
  3340. display(QString("%1").
  3341. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3342. 2)));
  3343. }else{
  3344. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3345. display(QString("%1").arg(number));
  3346. }
  3347. break;
  3348. case Units::Rankine:
  3349. display(QString("%1'r").
  3350. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3351. 2)));
  3352. break;
  3353. case Units::Unitless:
  3354. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3355. break;
  3356. default:
  3357. switch(temperature.scale())
  3358. {
  3359. case Units::Fahrenheit:
  3360. display(QString("%1'F").
  3361. arg(number.setNum(temperature.temperature(),'f',2)));
  3362. break;
  3363. case Units::Celsius:
  3364. display(QString("%1'C").
  3365. arg(number.setNum(temperature.temperature(),'f',2)));
  3366. break;
  3367. case Units::Kelvin:
  3368. display(QString("%1").
  3369. arg(number.setNum(temperature.temperature(),'f',2)));
  3370. break;
  3371. case Units::Rankine:
  3372. display(QString("%1'r").
  3373. arg(number.setNum(temperature.temperature(),'f',2)));
  3374. break;
  3375. case Units::Unitless:
  3376. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3377. break;
  3378. }
  3379. break;
  3380. }
  3381. }
  3382. /*:297*//*298:*/
  3383. #line 7125 "./typica.w"
  3384. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3385. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3386. {
  3387. setSegmentStyle(Filled);
  3388. display("---.--'F");
  3389. }
  3390. /*:298*//*299:*/
  3391. #line 7141 "./typica.w"
  3392. void TemperatureDisplay::invalidate()
  3393. {
  3394. display("---.--'F");
  3395. }
  3396. /*:299*//*300:*/
  3397. #line 7153 "./typica.w"
  3398. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3399. {
  3400. unit= scale;
  3401. }
  3402. /*:300*//*301:*/
  3403. #line 7161 "./typica.w"
  3404. TemperatureDisplay::~TemperatureDisplay()
  3405. {
  3406. }
  3407. /*:301*/
  3408. #line 777 "./typica.w"
  3409. /*307:*/
  3410. #line 7261 "./typica.w"
  3411. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3412. {
  3413. if(measure.time()<epoch)
  3414. {
  3415. if(hasPrevious)
  3416. {
  3417. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3418. epoch.msec());
  3419. QTime jitComp(epoch.hour(),measure.time().minute(),
  3420. measure.time().second(),measure.time().msec());
  3421. int relTime= jitBase.msecsTo(jitComp);
  3422. /*308:*/
  3423. #line 7295 "./typica.w"
  3424. QTime newTime(0,0,0,0);
  3425. newTime= newTime.addMSecs(relTime);
  3426. if(newTime.hour()> 0)
  3427. {
  3428. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3429. }
  3430. Measurement rel= measure;
  3431. rel.setTime(newTime);
  3432. emit measurement(rel);
  3433. /*:308*/
  3434. #line 7273 "./typica.w"
  3435. }
  3436. else
  3437. {
  3438. Measurement rel= measure;
  3439. rel.setTime(QTime(0,0,0,0));
  3440. emit measurement(rel);
  3441. }
  3442. }
  3443. else
  3444. {
  3445. int relTime= epoch.msecsTo(measure.time());
  3446. /*308:*/
  3447. #line 7295 "./typica.w"
  3448. QTime newTime(0,0,0,0);
  3449. newTime= newTime.addMSecs(relTime);
  3450. if(newTime.hour()> 0)
  3451. {
  3452. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3453. }
  3454. Measurement rel= measure;
  3455. rel.setTime(newTime);
  3456. emit measurement(rel);
  3457. /*:308*/
  3458. #line 7285 "./typica.w"
  3459. }
  3460. hasPrevious= true;
  3461. previous= measure.time();
  3462. }
  3463. /*:307*//*309:*/
  3464. #line 7308 "./typica.w"
  3465. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3466. previous(0,0,0,0),hasPrevious(false)
  3467. {
  3468. }
  3469. QTime MeasurementTimeOffset::zeroTime()
  3470. {
  3471. return epoch;
  3472. }
  3473. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3474. {
  3475. epoch= zero;
  3476. hasPrevious= false;
  3477. }
  3478. /*:309*/
  3479. #line 778 "./typica.w"
  3480. /*319:*/
  3481. #line 7506 "./typica.w"
  3482. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3483. {
  3484. }
  3485. int ZeroEmitter::column()
  3486. {
  3487. return col;
  3488. }
  3489. double ZeroEmitter::lastTemperature()
  3490. {
  3491. return cache.temperature();
  3492. }
  3493. void ZeroEmitter::newMeasurement(Measurement measure)
  3494. {
  3495. cache= measure;
  3496. }
  3497. void ZeroEmitter::setColumn(int column)
  3498. {
  3499. col= column;
  3500. }
  3501. void ZeroEmitter::emitZero()
  3502. {
  3503. cache.setTime(QTime(0,0,0,0));
  3504. emit measurement(cache,col);
  3505. }
  3506. /*:319*/
  3507. #line 779 "./typica.w"
  3508. /*324:*/
  3509. #line 7596 "./typica.w"
  3510. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3511. {
  3512. }
  3513. int MeasurementAdapter::column()
  3514. {
  3515. return col;
  3516. }
  3517. void MeasurementAdapter::newMeasurement(Measurement measure)
  3518. {
  3519. emit measurement(measure,col);
  3520. }
  3521. void MeasurementAdapter::setColumn(int column)
  3522. {
  3523. col= column;
  3524. }
  3525. /*:324*/
  3526. #line 780 "./typica.w"
  3527. /*329:*/
  3528. #line 7718 "./typica.w"
  3529. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3530. theScene(new QGraphicsScene),
  3531. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3532. prevPoints(new QMap<int,QPointF> ),
  3533. translations(new QMap<int,double> ),
  3534. gridLinesF(new QList<QGraphicsItem*> ),
  3535. gridLinesC(new QList<QGraphicsItem*> ),
  3536. relativeGridLines(new QList<QGraphicsItem*> ),
  3537. relativeEnabled(false),
  3538. timeIndicatorEnabled(false),
  3539. timeLine(new QGraphicsLineItem),
  3540. relativeAdjuster(new LinearSplineInterpolator)
  3541. {
  3542. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3543. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3544. setScene(theScene);
  3545. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3546. QPen timePen;
  3547. timePen.setColor(QColor(160,160,164,127));
  3548. timeLine->setPen(timePen);
  3549. timeLine->setLine(0,0,0,-500);
  3550. timeLine->hide();
  3551. theScene->addItem(timeLine);
  3552. /*330:*/
  3553. #line 7758 "./typica.w"
  3554. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3555. tempaxis->setLine(-10,-500,-10,0);
  3556. theScene->addItem(tempaxis);
  3557. QGraphicsLineItem*gridLine;
  3558. QGraphicsTextItem*label;
  3559. for(int y= -100;y> -600;y-= 100)
  3560. {
  3561. gridLine= new QGraphicsLineItem;
  3562. gridLine->setLine(0,y,1200,y);
  3563. theScene->addItem(gridLine);
  3564. label= new QGraphicsTextItem;
  3565. label->setHtml(QString("%1&deg;F").arg(-y));
  3566. label->setPos(-55,y-(label->boundingRect().height()/2));
  3567. theScene->addItem(label);
  3568. gridLinesF->append(gridLine);
  3569. gridLinesF->append(label);
  3570. }
  3571. for(int degC= 50;degC<=250;degC+= 50)
  3572. {
  3573. gridLine= new QGraphicsLineItem;
  3574. int y= -(degC*(9.0/5.0)+32);
  3575. gridLine->setLine(0,y,1200,y);
  3576. gridLine->hide();
  3577. theScene->addItem(gridLine);
  3578. gridLinesC->append(gridLine);
  3579. label= new QGraphicsTextItem;
  3580. label->setHtml(QString("%1&deg;C").arg(degC));
  3581. label->setPos(-55,y-(label->boundingRect().height()/2));
  3582. label->hide();
  3583. theScene->addItem(label);
  3584. gridLinesC->append(label);
  3585. }
  3586. /*:330*/
  3587. #line 7742 "./typica.w"
  3588. ;
  3589. /*331:*/
  3590. #line 7799 "./typica.w"
  3591. QSettings settings;
  3592. if(settings.contains("settings/graph/relative/enable"))
  3593. {
  3594. if(settings.value("settings/graph/relative/enable").toBool())
  3595. {
  3596. relativeEnabled= true;
  3597. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  3598. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  3599. QMap<double,QString> relativeAxisPairs;
  3600. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  3601. foreach(QString item,relativeAxisLabels)
  3602. {
  3603. relativeAxisPairs.insert(item.toDouble(),item);
  3604. }
  3605. if(relativeAxisPairs.size()> 1)
  3606. {
  3607. double skip= 500.0/(relativeAxisPairs.size()-1);
  3608. double y= 0;
  3609. foreach(double key,relativeAxisPairs.keys())
  3610. {
  3611. gridLine= new QGraphicsLineItem;
  3612. gridLine->setLine(0,y,1205,y);
  3613. gridLine->setPen(QPen(relativeColor));
  3614. theScene->addItem(gridLine);
  3615. relativeGridLines->append(gridLine);
  3616. label= new QGraphicsTextItem;
  3617. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  3618. label->setPos(1210,y-(label->boundingRect().height()/2));
  3619. theScene->addItem(label);
  3620. relativeGridLines->append(label);
  3621. if(unit=="F")
  3622. {
  3623. relativeAdjuster->add_pair(key,-y);
  3624. }
  3625. else
  3626. {
  3627. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  3628. }
  3629. y-= skip;
  3630. }
  3631. }
  3632. }
  3633. }
  3634. /*:331*/
  3635. #line 7743 "./typica.w"
  3636. /*333:*/
  3637. #line 7876 "./typica.w"
  3638. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  3639. timeaxis->setLine(0,10,1200,10);
  3640. theScene->addItem(timeaxis);
  3641. for(int x= 0;x<1201;x+= 120)
  3642. {
  3643. QGraphicsLineItem*tick= new QGraphicsLineItem;
  3644. tick->setLine(x,0,x,20);
  3645. theScene->addItem(tick);
  3646. QGraphicsTextItem*label= new QGraphicsTextItem;
  3647. label->setPlainText(QString("%1").arg(x/60));
  3648. label->setPos(x-(label->boundingRect().width()/2),20);
  3649. theScene->addItem(label);
  3650. }
  3651. /*:333*/
  3652. #line 7744 "./typica.w"
  3653. ;
  3654. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3655. }
  3656. /*:329*//*332:*/
  3657. #line 7846 "./typica.w"
  3658. void GraphView::showF()
  3659. {
  3660. for(int i= 0;i<gridLinesF->size();i++)
  3661. {
  3662. gridLinesF->at(i)->show();
  3663. }
  3664. for(int i= 0;i<gridLinesC->size();i++)
  3665. {
  3666. gridLinesC->at(i)->hide();
  3667. }
  3668. }
  3669. void GraphView::showC()
  3670. {
  3671. for(int i= 0;i<gridLinesF->size();i++)
  3672. {
  3673. gridLinesF->at(i)->hide();
  3674. }
  3675. for(int i= 0;i<gridLinesC->size();i++)
  3676. {
  3677. gridLinesC->at(i)->show();
  3678. }
  3679. }
  3680. /*:332*//*334:*/
  3681. #line 7895 "./typica.w"
  3682. void GraphView::resizeEvent(QResizeEvent*)
  3683. {
  3684. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3685. }
  3686. /*:334*//*335:*/
  3687. #line 7909 "./typica.w"
  3688. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  3689. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  3690. {
  3691. double offset= 0;
  3692. if(measure.contains("relative"))
  3693. {
  3694. if(measure.value("relative").toBool())
  3695. {
  3696. if(relativeEnabled)
  3697. {
  3698. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  3699. }
  3700. else
  3701. {
  3702. return;
  3703. }
  3704. }
  3705. }
  3706. if(translations->contains(tempcolumn))
  3707. {
  3708. offset= translations->value(tempcolumn);
  3709. }
  3710. if(prevPoints->contains(tempcolumn))
  3711. {
  3712. /*337:*/
  3713. #line 7986 "./typica.w"
  3714. QGraphicsLineItem*segment= new QGraphicsLineItem;
  3715. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  3716. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  3717. -(prevPoints->value(tempcolumn).y()),
  3718. nextPoint.x()+offset,-(nextPoint.y()));
  3719. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  3720. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  3721. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  3722. Qt::darkYellow};
  3723. segment->setPen(p[tempcolumn%12]);
  3724. theScene->addItem(segment);
  3725. prevPoints->insert(tempcolumn,nextPoint);
  3726. if(timeIndicatorEnabled)
  3727. {
  3728. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  3729. }
  3730. /*:337*/
  3731. #line 7935 "./typica.w"
  3732. if(graphLines->contains(tempcolumn))
  3733. {
  3734. graphLines->value(tempcolumn)->append(segment);
  3735. }
  3736. else
  3737. {
  3738. QList<QGraphicsLineItem*> *newLine=
  3739. new QList<QGraphicsLineItem*> ;
  3740. newLine->append(segment);
  3741. graphLines->insert(tempcolumn,newLine);
  3742. }
  3743. }
  3744. else
  3745. {
  3746. /*336:*/
  3747. #line 7971 "./typica.w"
  3748. int x= FULLTIMETOINT(measure.time())/1000;
  3749. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  3750. if(timeIndicatorEnabled)
  3751. {
  3752. timeLine->setLine(x,0,x,-500);
  3753. }
  3754. /*:336*/
  3755. #line 7952 "./typica.w"
  3756. }
  3757. }
  3758. /*:335*//*338:*/
  3759. #line 8007 "./typica.w"
  3760. void GraphView::clear()
  3761. {
  3762. int i;
  3763. foreach(i,prevPoints->keys())
  3764. {
  3765. removeSeries(i);
  3766. }
  3767. translations->clear();
  3768. }
  3769. /*:338*//*339:*/
  3770. #line 8021 "./typica.w"
  3771. void GraphView::removeSeries(int column)
  3772. {
  3773. if(graphLines->contains(column))
  3774. {
  3775. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3776. QGraphicsLineItem*segment;
  3777. foreach(segment,*series)
  3778. {
  3779. theScene->removeItem(segment);
  3780. }
  3781. qDeleteAll(*series);
  3782. }
  3783. graphLines->remove(column);
  3784. prevPoints->remove(column);
  3785. }
  3786. /*:339*//*340:*/
  3787. #line 8040 "./typica.w"
  3788. void GraphView::setSeriesTranslation(int column,double offset)
  3789. {
  3790. if(graphLines->contains(column))
  3791. {
  3792. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3793. QGraphicsLineItem*segment;
  3794. foreach(segment,*series)
  3795. {
  3796. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  3797. }
  3798. }
  3799. if(translations->contains(column))
  3800. {
  3801. translations->insert(column,offset+translations->value(column));
  3802. }
  3803. else
  3804. {
  3805. translations->insert(column,offset);
  3806. }
  3807. }
  3808. /*:340*//*341:*/
  3809. #line 8067 "./typica.w"
  3810. void GraphView::setTimeIndicatorEnabled(bool enabled)
  3811. {
  3812. timeIndicatorEnabled= enabled;
  3813. if(enabled)
  3814. {
  3815. timeLine->show();
  3816. }
  3817. else
  3818. {
  3819. timeLine->hide();
  3820. }
  3821. }
  3822. /*:341*/
  3823. #line 781 "./typica.w"
  3824. /*347:*/
  3825. #line 8211 "./typica.w"
  3826. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  3827. {
  3828. if(measure.time()!=QTime(0,0,0,0))
  3829. {
  3830. /*349:*/
  3831. #line 8285 "./typica.w"
  3832. if(lastMeasurement.contains(tempcolumn))
  3833. {
  3834. if(lastMeasurement[tempcolumn].time()<measure.time())
  3835. {
  3836. QList<QTime> timelist;
  3837. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  3838. {
  3839. timelist.append(i);
  3840. }
  3841. for(int i= 0;i<timelist.size();i++)
  3842. {
  3843. Measurement synthesized= measure;
  3844. synthesized.setTime(timelist[i]);
  3845. newMeasurement(synthesized,tempcolumn);
  3846. }
  3847. }
  3848. }
  3849. /*:349*/
  3850. #line 8216 "./typica.w"
  3851. }
  3852. model_ms->newMeasurement(measure,tempcolumn);
  3853. if(lastMeasurement.contains(tempcolumn))
  3854. {
  3855. if(measure.time().second()!=
  3856. lastMeasurement.value(tempcolumn).time().second())
  3857. {
  3858. Measurement adjusted= measure;
  3859. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  3860. adjusted.setTime(adjtime);
  3861. model_1s->newMeasurement(adjusted,tempcolumn);
  3862. if(adjusted.time().second()%5==0)
  3863. {
  3864. model_5s->newMeasurement(adjusted,tempcolumn);
  3865. if(adjusted.time().second()%10==0)
  3866. {
  3867. model_10s->newMeasurement(adjusted,tempcolumn);
  3868. }
  3869. if(adjusted.time().second()%15==0)
  3870. {
  3871. model_15s->newMeasurement(adjusted,tempcolumn);
  3872. if(adjusted.time().second()%30==0)
  3873. {
  3874. model_30s->newMeasurement(adjusted,tempcolumn);
  3875. if(adjusted.time().second()==0)
  3876. {
  3877. model_1m->newMeasurement(adjusted,tempcolumn);
  3878. }
  3879. }
  3880. }
  3881. }
  3882. }
  3883. /*351:*/
  3884. #line 8329 "./typica.w"
  3885. if(currentColumnSet.contains(tempcolumn))
  3886. {
  3887. int replicationcolumn;
  3888. foreach(replicationcolumn,currentColumnSet)
  3889. {
  3890. if(replicationcolumn!=tempcolumn)
  3891. {
  3892. if(lastMeasurement.contains(replicationcolumn))
  3893. {
  3894. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  3895. {
  3896. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  3897. synthetic.setTime(measure.time());
  3898. model_ms->newMeasurement(synthetic,replicationcolumn);
  3899. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  3900. {
  3901. Measurement adjusted= synthetic;
  3902. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  3903. model_1s->newMeasurement(adjusted,replicationcolumn);
  3904. if(adjusted.time().second()%5==0)
  3905. {
  3906. model_5s->newMeasurement(adjusted,replicationcolumn);
  3907. if(adjusted.time().second()%10==0)
  3908. {
  3909. model_10s->newMeasurement(adjusted,replicationcolumn);
  3910. }
  3911. if(adjusted.time().second()%15==0)
  3912. {
  3913. model_15s->newMeasurement(adjusted,replicationcolumn);
  3914. if(adjusted.time().second()%30==0)
  3915. {
  3916. model_30s->newMeasurement(adjusted,replicationcolumn);
  3917. if(adjusted.time().second()==0)
  3918. {
  3919. model_1m->newMeasurement(adjusted,replicationcolumn);
  3920. }
  3921. }
  3922. }
  3923. }
  3924. }
  3925. lastMeasurement[replicationcolumn]= synthetic;
  3926. }
  3927. }
  3928. }
  3929. }
  3930. }
  3931. /*:351*/
  3932. #line 8249 "./typica.w"
  3933. }
  3934. else
  3935. {
  3936. /*348:*/
  3937. #line 8261 "./typica.w"
  3938. MeasurementModel*m;
  3939. foreach(m,modelSet)
  3940. {
  3941. m->newMeasurement(measure,tempcolumn);
  3942. }
  3943. /*:348*/
  3944. #line 8253 "./typica.w"
  3945. }
  3946. lastMeasurement.insert(tempcolumn,measure);
  3947. }
  3948. /*:347*//*350:*/
  3949. #line 8315 "./typica.w"
  3950. void ZoomLog::addToCurrentColumnSet(int column)
  3951. {
  3952. currentColumnSet.append(column);
  3953. }
  3954. void ZoomLog::clearCurrentColumnSet()
  3955. {
  3956. currentColumnSet.clear();
  3957. }
  3958. /*:350*//*352:*/
  3959. #line 8399 "./typica.w"
  3960. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  3961. int annotationcolumn)
  3962. {
  3963. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  3964. MeasurementModel*m;
  3965. if(lastMeasurement.contains(tempcolumn))
  3966. {
  3967. foreach(m,modelSet)
  3968. {
  3969. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  3970. }
  3971. }
  3972. foreach(m,modelSet)
  3973. {
  3974. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  3975. }
  3976. }
  3977. /*:352*//*353:*/
  3978. #line 8423 "./typica.w"
  3979. void ZoomLog::centerOn(int row)
  3980. {
  3981. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  3982. }
  3983. /*:353*//*354:*/
  3984. #line 8433 "./typica.w"
  3985. void ZoomLog::clear()
  3986. {
  3987. MeasurementModel*m;
  3988. foreach(m,modelSet)
  3989. {
  3990. m->clear();
  3991. }
  3992. lastMeasurement.clear();
  3993. saveTempCols.clear();
  3994. saveControlCols.clear();
  3995. saveNoteCols.clear();
  3996. }
  3997. /*:354*//*355:*/
  3998. #line 8451 "./typica.w"
  3999. QVariant ZoomLog::data(int row,int column)const
  4000. {
  4001. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4002. Qt::DisplayRole);
  4003. }
  4004. int ZoomLog::rowCount()
  4005. {
  4006. return model_ms->rowCount();
  4007. }
  4008. /*:355*//*356:*/
  4009. #line 8474 "./typica.w"
  4010. bool ZoomLog::saveXML(QIODevice*device)
  4011. {
  4012. Units::Unit prevUnits= model_ms->displayUnits();
  4013. if(prevUnits!=Units::Fahrenheit)
  4014. {
  4015. model_ms->setDisplayUnits(Units::Fahrenheit);
  4016. }
  4017. XMLOutput writer(model_ms,device,0);
  4018. int c;
  4019. foreach(c,saveTempCols)
  4020. {
  4021. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4022. toString(),c);
  4023. }
  4024. foreach(c,saveControlCols)
  4025. {
  4026. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4027. toString(),c);
  4028. }
  4029. foreach(c,saveNoteCols)
  4030. {
  4031. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4032. toString(),c);
  4033. }
  4034. bool retval= writer.output();
  4035. if(prevUnits!=Units::Fahrenheit)
  4036. {
  4037. model_ms->setDisplayUnits(prevUnits);
  4038. }
  4039. return retval;
  4040. }
  4041. /*:356*//*357:*/
  4042. #line 8510 "./typica.w"
  4043. bool ZoomLog::saveCSV(QIODevice*device)
  4044. {
  4045. CSVOutput writer(currentModel,device,0);
  4046. int c;
  4047. foreach(c,saveTempCols)
  4048. {
  4049. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4050. toString(),c);
  4051. }
  4052. foreach(c,saveControlCols)
  4053. {
  4054. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4055. toString(),c);
  4056. }
  4057. foreach(c,saveNoteCols)
  4058. {
  4059. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4060. toString(),c);
  4061. }
  4062. return writer.output();
  4063. }
  4064. /*:357*//*358:*/
  4065. #line 8539 "./typica.w"
  4066. void ZoomLog::switchLOD(MeasurementModel*m)
  4067. {
  4068. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4069. setModel(m);
  4070. currentModel= m;
  4071. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4072. }
  4073. void ZoomLog::LOD_ms()
  4074. {
  4075. switchLOD(model_ms);
  4076. }
  4077. void ZoomLog::LOD_1s()
  4078. {
  4079. switchLOD(model_1s);
  4080. }
  4081. void ZoomLog::LOD_5s()
  4082. {
  4083. switchLOD(model_5s);
  4084. }
  4085. void ZoomLog::LOD_10s()
  4086. {
  4087. switchLOD(model_10s);
  4088. }
  4089. void ZoomLog::LOD_15s()
  4090. {
  4091. switchLOD(model_15s);
  4092. }
  4093. void ZoomLog::LOD_30s()
  4094. {
  4095. switchLOD(model_30s);
  4096. }
  4097. void ZoomLog::LOD_1m()
  4098. {
  4099. switchLOD(model_1m);
  4100. }
  4101. /*:358*//*359:*/
  4102. #line 8587 "./typica.w"
  4103. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4104. {
  4105. model_ms->setDisplayUnits(scale);
  4106. model_1s->setDisplayUnits(scale);
  4107. model_5s->setDisplayUnits(scale);
  4108. model_10s->setDisplayUnits(scale);
  4109. model_15s->setDisplayUnits(scale);
  4110. model_30s->setDisplayUnits(scale);
  4111. model_1m->setDisplayUnits(scale);
  4112. }
  4113. Units::Unit ZoomLog::displayUnits()
  4114. {
  4115. return model_ms->displayUnits();
  4116. }
  4117. /*:359*//*360:*/
  4118. #line 8607 "./typica.w"
  4119. QString ZoomLog::lastTime(int series)
  4120. {
  4121. Measurement measure= lastMeasurement.value(series);
  4122. QTime time= measure.time();
  4123. return time.toString("h:mm:ss.zzz");
  4124. }
  4125. /*:360*//*361:*/
  4126. #line 8617 "./typica.w"
  4127. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4128. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4129. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4130. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4131. {
  4132. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4133. setSelectionMode(QAbstractItemView::NoSelection);
  4134. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4135. model_30s<<model_1m;
  4136. currentModel= model_30s;
  4137. setModel(currentModel);
  4138. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4139. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4140. this,SLOT(persistColumnResize(int,int,int)));
  4141. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4142. this,SLOT(restoreColumnWidths()));
  4143. }
  4144. /*:361*//*362:*/
  4145. #line 8640 "./typica.w"
  4146. void ZoomLog::setHeaderData(int section,QString text)
  4147. {
  4148. MeasurementModel*m;
  4149. foreach(m,modelSet)
  4150. {
  4151. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4152. }
  4153. }
  4154. /*:362*//*363:*/
  4155. #line 8658 "./typica.w"
  4156. void ZoomLog::addOutputTemperatureColumn(int column)
  4157. {
  4158. saveTempCols.append(column);
  4159. }
  4160. void ZoomLog::addOutputControlColumn(int column)
  4161. {
  4162. saveControlCols.append(column);
  4163. }
  4164. void ZoomLog::addOutputAnnotationColumn(int column)
  4165. {
  4166. saveNoteCols.append(column);
  4167. }
  4168. void ZoomLog::clearOutputColumns()
  4169. {
  4170. saveTempCols.clear();
  4171. saveControlCols.clear();
  4172. saveNoteCols.clear();
  4173. }
  4174. /*:363*//*364:*/
  4175. #line 8684 "./typica.w"
  4176. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4177. {
  4178. /*572:*/
  4179. #line 12665 "./typica.w"
  4180. QSettings settings;
  4181. /*573:*/
  4182. #line 12678 "./typica.w"
  4183. QWidget*topLevelWidget= this;
  4184. while(topLevelWidget->parentWidget())
  4185. {
  4186. topLevelWidget= topLevelWidget->parentWidget();
  4187. }
  4188. /*:573*/
  4189. #line 12667 "./typica.w"
  4190. settings.setValue(QString("columnWidths/%1/%2/%3").
  4191. arg(topLevelWidget->objectName()).
  4192. arg(objectName()).arg(column),
  4193. QVariant(newsize));
  4194. /*:572*/
  4195. #line 8687 "./typica.w"
  4196. }
  4197. void ZoomLog::restoreColumnWidths()
  4198. {
  4199. /*575:*/
  4200. #line 12698 "./typica.w"
  4201. QSettings settings;
  4202. /*573:*/
  4203. #line 12678 "./typica.w"
  4204. QWidget*topLevelWidget= this;
  4205. while(topLevelWidget->parentWidget())
  4206. {
  4207. topLevelWidget= topLevelWidget->parentWidget();
  4208. }
  4209. /*:573*/
  4210. #line 12700 "./typica.w"
  4211. QString baseKey=
  4212. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4213. arg(objectName());
  4214. for(int i= 0;i<model()->columnCount();i++)
  4215. {
  4216. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4217. if(settings.contains(key))
  4218. {
  4219. setColumnWidth(i,settings.value(key).toInt());
  4220. }
  4221. }
  4222. /*:575*/
  4223. #line 8692 "./typica.w"
  4224. }
  4225. void ZoomLog::setVisible(bool visibility)
  4226. {
  4227. QTableView::setVisible(visibility);
  4228. }
  4229. void ZoomLog::showEvent(QShowEvent*)
  4230. {
  4231. /*575:*/
  4232. #line 12698 "./typica.w"
  4233. QSettings settings;
  4234. /*573:*/
  4235. #line 12678 "./typica.w"
  4236. QWidget*topLevelWidget= this;
  4237. while(topLevelWidget->parentWidget())
  4238. {
  4239. topLevelWidget= topLevelWidget->parentWidget();
  4240. }
  4241. /*:573*/
  4242. #line 12700 "./typica.w"
  4243. QString baseKey=
  4244. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4245. arg(objectName());
  4246. for(int i= 0;i<model()->columnCount();i++)
  4247. {
  4248. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4249. if(settings.contains(key))
  4250. {
  4251. setColumnWidth(i,settings.value(key).toInt());
  4252. }
  4253. }
  4254. /*:575*/
  4255. #line 8702 "./typica.w"
  4256. }
  4257. /*:364*/
  4258. #line 782 "./typica.w"
  4259. /*373:*/
  4260. #line 8935 "./typica.w"
  4261. bool MeasurementList::operator<(const MeasurementList&other)const
  4262. {
  4263. return this->first().toTime()<other.first().toTime();
  4264. }
  4265. bool MeasurementList::operator==(const MeasurementList&other)const
  4266. {
  4267. return this->first().toTime()==other.first().toTime();
  4268. }
  4269. /*:373*//*374:*/
  4270. #line 8951 "./typica.w"
  4271. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4272. {
  4273. return QModelIndex();
  4274. }
  4275. /*:374*//*375:*/
  4276. #line 8961 "./typica.w"
  4277. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4278. {
  4279. if(measure.scale()==Units::Unitless)
  4280. {
  4281. controlColumns->insert(tempcolumn,true);
  4282. }
  4283. else
  4284. {
  4285. controlColumns->insert(tempcolumn,false);
  4286. }
  4287. MeasurementList*temp;
  4288. temp= new MeasurementList;
  4289. temp->append(QVariant(measure.time()));
  4290. /*376:*/
  4291. #line 9020 "./typica.w"
  4292. /*377:*/
  4293. #line 9065 "./typica.w"
  4294. QList<MeasurementList*> ::iterator i= lastInsertion;
  4295. bool quickscan= false;
  4296. if(entries->size()> 5)
  4297. {
  4298. if(**i<*temp)
  4299. {
  4300. i+= 1;
  4301. for(int j= 10;j> 0;j--)
  4302. {
  4303. if(i!=entries->end())
  4304. {
  4305. if(**i<*temp)
  4306. {
  4307. i+= 1;
  4308. }
  4309. else
  4310. {
  4311. quickscan= true;
  4312. break;
  4313. }
  4314. }
  4315. else
  4316. {
  4317. quickscan= true;
  4318. break;
  4319. }
  4320. }
  4321. }
  4322. else
  4323. {
  4324. if(**i==*temp)
  4325. {
  4326. quickscan= true;
  4327. }
  4328. }
  4329. }
  4330. /*:377*/
  4331. #line 9021 "./typica.w"
  4332. if(quickscan==false)
  4333. {
  4334. i= entries->begin();
  4335. QList<MeasurementList*> ::iterator u= entries->end();
  4336. QList<MeasurementList*> ::iterator midpoint;
  4337. int n= u-i;
  4338. int rA;
  4339. while(n> 0)
  4340. {
  4341. rA= n>>1;
  4342. midpoint= i+rA;
  4343. if(**midpoint<*temp)
  4344. {
  4345. i= midpoint+1;
  4346. n-= rA+1;
  4347. }
  4348. else
  4349. {
  4350. n= rA;
  4351. }
  4352. }
  4353. }
  4354. /*:376*/
  4355. #line 8975 "./typica.w"
  4356. MeasurementList*newEntry;
  4357. int insertion;
  4358. if(i!=entries->end())
  4359. {
  4360. insertion= entries->indexOf(*i);
  4361. if((*i)->first().toTime()==measure.time())
  4362. {
  4363. /*378:*/
  4364. #line 9107 "./typica.w"
  4365. if((*i)->size()<tempcolumn+1)
  4366. {
  4367. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4368. {
  4369. (*i)->append(QVariant());
  4370. }
  4371. }
  4372. (*i)->replace(tempcolumn,measure);
  4373. lastInsertion= i;
  4374. emit dataChanged(createIndex(insertion,tempcolumn),
  4375. createIndex(insertion,tempcolumn));
  4376. lastTemperature->insert(tempcolumn,insertion);
  4377. /*:378*/
  4378. #line 8983 "./typica.w"
  4379. }
  4380. else
  4381. {
  4382. /*379:*/
  4383. #line 9125 "./typica.w"
  4384. beginInsertRows(QModelIndex(),insertion,insertion);
  4385. newEntry= new MeasurementList;
  4386. newEntry->append(QVariant(measure.time()));
  4387. for(int j= 0;j<tempcolumn+1;j++)
  4388. {
  4389. newEntry->append(QVariant());
  4390. }
  4391. newEntry->replace(tempcolumn,measure);
  4392. lastInsertion= entries->insert(i,newEntry);
  4393. endInsertRows();
  4394. lastTemperature->insert(tempcolumn,insertion);
  4395. /*:379*/
  4396. #line 8987 "./typica.w"
  4397. }
  4398. }
  4399. else
  4400. {
  4401. /*380:*/
  4402. #line 9143 "./typica.w"
  4403. insertion= entries->size();
  4404. /*379:*/
  4405. #line 9125 "./typica.w"
  4406. beginInsertRows(QModelIndex(),insertion,insertion);
  4407. newEntry= new MeasurementList;
  4408. newEntry->append(QVariant(measure.time()));
  4409. for(int j= 0;j<tempcolumn+1;j++)
  4410. {
  4411. newEntry->append(QVariant());
  4412. }
  4413. newEntry->replace(tempcolumn,measure);
  4414. lastInsertion= entries->insert(i,newEntry);
  4415. endInsertRows();
  4416. lastTemperature->insert(tempcolumn,insertion);
  4417. /*:379*/
  4418. #line 9145 "./typica.w"
  4419. /*:380*/
  4420. #line 8992 "./typica.w"
  4421. }
  4422. if(tempcolumn>=colcount)
  4423. {
  4424. colcount= tempcolumn+1;
  4425. }
  4426. emit rowChanged(insertion);
  4427. delete temp;
  4428. }
  4429. /*:375*//*381:*/
  4430. #line 9155 "./typica.w"
  4431. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4432. int annotationColumn)
  4433. {
  4434. int r;
  4435. if(lastTemperature->contains(tempcolumn))
  4436. {
  4437. r= lastTemperature->value(tempcolumn);
  4438. }
  4439. else
  4440. {
  4441. r= 0;
  4442. }
  4443. if(r==0&&entries->size()==0)
  4444. {
  4445. /*382:*/
  4446. #line 9193 "./typica.w"
  4447. beginInsertRows(QModelIndex(),0,0);
  4448. MeasurementList*newEntry= new MeasurementList;
  4449. newEntry->append(QVariant(QTime(0,0,0,0)));
  4450. entries->append(newEntry);
  4451. endInsertRows();
  4452. /*:382*/
  4453. #line 9170 "./typica.w"
  4454. }
  4455. MeasurementList*row= entries->at(r);
  4456. if(row->size()<=annotationColumn)
  4457. {
  4458. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4459. {
  4460. row->append(QVariant());
  4461. }
  4462. }
  4463. row->replace(annotationColumn,annotation);
  4464. emit dataChanged(createIndex(r,annotationColumn),
  4465. createIndex(r,annotationColumn));
  4466. emit rowChanged(r);
  4467. if(annotationColumn> colcount-1)
  4468. {
  4469. colcount= annotationColumn+1;
  4470. }
  4471. }
  4472. /*:381*//*383:*/
  4473. #line 9204 "./typica.w"
  4474. void MeasurementModel::clear()
  4475. {
  4476. beginRemoveRows(QModelIndex(),0,entries->size());
  4477. while(entries->size()!=0)
  4478. {
  4479. MeasurementList*row= entries->takeFirst();
  4480. delete row;
  4481. }
  4482. endRemoveRows();
  4483. colcount= hData->size();
  4484. lastTemperature->clear();
  4485. reset();
  4486. }
  4487. /*:383*//*384:*/
  4488. #line 9237 "./typica.w"
  4489. bool MeasurementModel::setData(const QModelIndex&index,
  4490. const QVariant&value,int role)
  4491. {
  4492. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4493. {
  4494. return false;
  4495. }
  4496. /*385:*/
  4497. #line 9269 "./typica.w"
  4498. bool valid= false;
  4499. if(index.isValid())
  4500. {
  4501. if(index.row()<entries->size())
  4502. {
  4503. if(index.column()<colcount)
  4504. {
  4505. valid= true;
  4506. }
  4507. }
  4508. }
  4509. /*:385*/
  4510. #line 9245 "./typica.w"
  4511. if(!valid)
  4512. {
  4513. return false;
  4514. }
  4515. MeasurementList*row= entries->at(index.row());
  4516. if(index.column()>=row->size())
  4517. {
  4518. /*386:*/
  4519. #line 9286 "./typica.w"
  4520. for(int i= row->size()-1;i<index.column();i++)
  4521. {
  4522. row->append(QVariant());
  4523. }
  4524. /*:386*/
  4525. #line 9253 "./typica.w"
  4526. }
  4527. if(index.column()==0)
  4528. {
  4529. /*387:*/
  4530. #line 9301 "./typica.w"
  4531. QTime time;
  4532. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4533. {
  4534. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4535. {
  4536. return false;
  4537. }
  4538. }
  4539. row= entries->takeAt(index.row());
  4540. row->replace(index.column(),QVariant(time));
  4541. MeasurementList*temp= row;
  4542. /*376:*/
  4543. #line 9020 "./typica.w"
  4544. /*377:*/
  4545. #line 9065 "./typica.w"
  4546. QList<MeasurementList*> ::iterator i= lastInsertion;
  4547. bool quickscan= false;
  4548. if(entries->size()> 5)
  4549. {
  4550. if(**i<*temp)
  4551. {
  4552. i+= 1;
  4553. for(int j= 10;j> 0;j--)
  4554. {
  4555. if(i!=entries->end())
  4556. {
  4557. if(**i<*temp)
  4558. {
  4559. i+= 1;
  4560. }
  4561. else
  4562. {
  4563. quickscan= true;
  4564. break;
  4565. }
  4566. }
  4567. else
  4568. {
  4569. quickscan= true;
  4570. break;
  4571. }
  4572. }
  4573. }
  4574. else
  4575. {
  4576. if(**i==*temp)
  4577. {
  4578. quickscan= true;
  4579. }
  4580. }
  4581. }
  4582. /*:377*/
  4583. #line 9021 "./typica.w"
  4584. if(quickscan==false)
  4585. {
  4586. i= entries->begin();
  4587. QList<MeasurementList*> ::iterator u= entries->end();
  4588. QList<MeasurementList*> ::iterator midpoint;
  4589. int n= u-i;
  4590. int rA;
  4591. while(n> 0)
  4592. {
  4593. rA= n>>1;
  4594. midpoint= i+rA;
  4595. if(**midpoint<*temp)
  4596. {
  4597. i= midpoint+1;
  4598. n-= rA+1;
  4599. }
  4600. else
  4601. {
  4602. n= rA;
  4603. }
  4604. }
  4605. }
  4606. /*:376*/
  4607. #line 9313 "./typica.w"
  4608. entries->insert(i,row);
  4609. int newRow= entries->indexOf(*i);
  4610. if(newRow<index.row())
  4611. {
  4612. emit dataChanged(createIndex(newRow,index.column()),index);
  4613. }
  4614. else
  4615. {
  4616. emit dataChanged(index,createIndex(newRow,index.column()));
  4617. }
  4618. /*:387*/
  4619. #line 9257 "./typica.w"
  4620. }
  4621. else
  4622. {
  4623. /*388:*/
  4624. #line 9327 "./typica.w"
  4625. row->replace(index.column(),value);
  4626. emit dataChanged(index,index);
  4627. /*:388*/
  4628. #line 9261 "./typica.w"
  4629. }
  4630. return true;
  4631. }
  4632. /*:384*//*389:*/
  4633. #line 9335 "./typica.w"
  4634. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  4635. unit(Units::Fahrenheit),hData(new QStringList),
  4636. lastTemperature(new QHash<int,int> ),
  4637. controlColumns(new QHash<int,bool> )
  4638. {
  4639. colcount= 1;
  4640. entries= new QList<MeasurementList*> ;
  4641. lastInsertion= entries->begin();
  4642. hData->append(tr("Time"));
  4643. }
  4644. /*:389*//*390:*/
  4645. #line 9349 "./typica.w"
  4646. MeasurementModel::~MeasurementModel()
  4647. {
  4648. clear();
  4649. delete entries;
  4650. delete hData;
  4651. }
  4652. /*:390*//*391:*/
  4653. #line 9361 "./typica.w"
  4654. int MeasurementModel::rowCount(const QModelIndex&parent)const
  4655. {
  4656. if(parent==QModelIndex())
  4657. {
  4658. return entries->size();
  4659. }
  4660. return 0;
  4661. }
  4662. int MeasurementModel::columnCount(const QModelIndex&parent)const
  4663. {
  4664. if(parent==QModelIndex())
  4665. {
  4666. return colcount;
  4667. }
  4668. return 0;
  4669. }
  4670. /*:391*//*392:*/
  4671. #line 9388 "./typica.w"
  4672. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  4673. const QVariant&value,int)
  4674. {
  4675. if(orientation==Qt::Horizontal)
  4676. {
  4677. if(hData->size()<section+1)
  4678. {
  4679. for(int i= hData->size();i<section+1;i++)
  4680. {
  4681. if(colcount<i)
  4682. {
  4683. beginInsertColumns(QModelIndex(),i,i);
  4684. }
  4685. hData->append(QString());
  4686. if(colcount<i)
  4687. {
  4688. endInsertColumns();
  4689. }
  4690. }
  4691. }
  4692. hData->replace(section,value.toString());
  4693. emit headerDataChanged(orientation,section,section);
  4694. if(colcount<section+1)
  4695. {
  4696. colcount= section+1;
  4697. }
  4698. return true;
  4699. }
  4700. return false;
  4701. }
  4702. /*:392*//*393:*/
  4703. #line 9428 "./typica.w"
  4704. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  4705. {
  4706. beginResetModel();
  4707. unit= scale;
  4708. endResetModel();
  4709. }
  4710. Units::Unit MeasurementModel::displayUnits()
  4711. {
  4712. return unit;
  4713. }
  4714. /*:393*//*394:*/
  4715. #line 9454 "./typica.w"
  4716. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  4717. {
  4718. /*385:*/
  4719. #line 9269 "./typica.w"
  4720. bool valid= false;
  4721. if(index.isValid())
  4722. {
  4723. if(index.row()<entries->size())
  4724. {
  4725. if(index.column()<colcount)
  4726. {
  4727. valid= true;
  4728. }
  4729. }
  4730. }
  4731. /*:385*/
  4732. #line 9457 "./typica.w"
  4733. if(!valid)
  4734. {
  4735. return QVariant();
  4736. }
  4737. MeasurementList*row= entries->at(index.row());
  4738. if(role==Qt::UserRole)
  4739. {
  4740. return QVariant(row->at(index.column()));
  4741. }
  4742. if(role==Qt::DisplayRole||role==Qt::EditRole)
  4743. {
  4744. if(index.column()> row->size())
  4745. {
  4746. return QVariant();
  4747. }
  4748. else
  4749. {
  4750. if(index.column()==0)
  4751. {
  4752. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  4753. }
  4754. else if(lastTemperature->contains(index.column()))
  4755. {
  4756. QVariantMap v= row->at(index.column()).toMap();
  4757. if(!v.contains("measurement"))
  4758. {
  4759. return QVariant();
  4760. }
  4761. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  4762. {
  4763. return v.value("measurement");
  4764. }
  4765. else
  4766. {
  4767. if(v.contains("relative"))
  4768. {
  4769. if(v.value("relative")==true)
  4770. {
  4771. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  4772. }
  4773. }
  4774. return QVariant(QString("%1").arg(Units::convertTemperature(v.value("measurement").toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  4775. }
  4776. }
  4777. return QVariant(row->at(index.column()).toString());
  4778. }
  4779. }
  4780. return QVariant();
  4781. }
  4782. /*:394*//*395:*/
  4783. #line 9510 "./typica.w"
  4784. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  4785. int role)const
  4786. {
  4787. if(orientation==Qt::Horizontal)
  4788. {
  4789. if(role==Qt::DisplayRole)
  4790. {
  4791. if(section<hData->size())
  4792. {
  4793. return QVariant(hData->at(section));
  4794. }
  4795. }
  4796. }
  4797. return QVariant();
  4798. }
  4799. /*:395*//*396:*/
  4800. #line 9537 "./typica.w"
  4801. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  4802. {
  4803. /*385:*/
  4804. #line 9269 "./typica.w"
  4805. bool valid= false;
  4806. if(index.isValid())
  4807. {
  4808. if(index.row()<entries->size())
  4809. {
  4810. if(index.column()<colcount)
  4811. {
  4812. valid= true;
  4813. }
  4814. }
  4815. }
  4816. /*:385*/
  4817. #line 9540 "./typica.w"
  4818. if(valid)
  4819. {
  4820. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  4821. }
  4822. return 0;
  4823. }
  4824. /*:396*//*397:*/
  4825. #line 9552 "./typica.w"
  4826. QModelIndex MeasurementModel::index(int row,int column,
  4827. const QModelIndex&parent)const
  4828. {
  4829. if(parent==QModelIndex())
  4830. {
  4831. if(row<entries->size()&&entries->isEmpty()==false)
  4832. {
  4833. if(column<entries->at(row)->size())
  4834. {
  4835. return createIndex(row,column);
  4836. }
  4837. }
  4838. }
  4839. return QModelIndex();
  4840. }
  4841. /*:397*/
  4842. #line 783 "./typica.w"
  4843. /*399:*/
  4844. #line 9603 "./typica.w"
  4845. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  4846. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  4847. {
  4848. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  4849. }
  4850. /*:399*//*400:*/
  4851. #line 9618 "./typica.w"
  4852. void AnnotationButton::annotate()
  4853. {
  4854. if(note.contains("%1"))
  4855. {
  4856. count++;
  4857. emit annotation(note.arg(count),tc,ac);
  4858. }
  4859. else
  4860. {
  4861. emit annotation(note,tc,ac);
  4862. }
  4863. }
  4864. /*:400*//*401:*/
  4865. #line 9636 "./typica.w"
  4866. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  4867. {
  4868. tc= tempcolumn;
  4869. }
  4870. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  4871. {
  4872. ac= annotationcolumn;
  4873. }
  4874. void AnnotationButton::setAnnotation(const QString&annotation)
  4875. {
  4876. note= annotation;
  4877. }
  4878. /*:401*//*402:*/
  4879. #line 9655 "./typica.w"
  4880. void AnnotationButton::resetCount()
  4881. {
  4882. count= 0;
  4883. }
  4884. /*:402*/
  4885. #line 784 "./typica.w"
  4886. /*407:*/
  4887. #line 9738 "./typica.w"
  4888. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  4889. const QString&postt,
  4890. QWidget*parent)
  4891. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  4892. {
  4893. resetChange();
  4894. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  4895. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  4896. }
  4897. /*:407*//*408:*/
  4898. #line 9755 "./typica.w"
  4899. void AnnotationSpinBox::resetChange()
  4900. {
  4901. change= true;
  4902. }
  4903. /*:408*//*409:*/
  4904. #line 9766 "./typica.w"
  4905. void AnnotationSpinBox::annotate()
  4906. {
  4907. if(change)
  4908. {
  4909. change= false;
  4910. emit annotation(QString("%1%2%3").arg(pretext).
  4911. arg(value()).arg(posttext),tc,ac);
  4912. }
  4913. }
  4914. /*:409*//*410:*/
  4915. #line 9779 "./typica.w"
  4916. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  4917. {
  4918. tc= tempcolumn;
  4919. }
  4920. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  4921. {
  4922. ac= annotationcolumn;
  4923. }
  4924. void AnnotationSpinBox::setPretext(const QString&pret)
  4925. {
  4926. pretext= pret;
  4927. }
  4928. void AnnotationSpinBox::setPosttext(const QString&postt)
  4929. {
  4930. posttext= postt;
  4931. }
  4932. /*:410*/
  4933. #line 785 "./typica.w"
  4934. /*417:*/
  4935. #line 9947 "./typica.w"
  4936. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  4937. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  4938. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  4939. stopAction(new QAction(tr("Stop"),NULL)),
  4940. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  4941. relative(QTime::currentTime()),base(QTime(0,0,0))
  4942. {
  4943. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  4944. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  4945. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  4946. clock.setInterval(500);
  4947. clock.setSingleShot(false);
  4948. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  4949. setSegmentStyle(Filled);
  4950. updateDisplay();
  4951. }
  4952. /*:417*//*418:*/
  4953. #line 9968 "./typica.w"
  4954. void TimerDisplay::updateTime()
  4955. {
  4956. QTime time;
  4957. int cseconds= 0;
  4958. int oseconds= 0;
  4959. int r= 0;
  4960. QTime nt= QTime(0,0,0);
  4961. int n= 0;
  4962. int bseconds= 0;
  4963. switch(m)
  4964. {
  4965. case TimerDisplay::CountUp:
  4966. /*419:*/
  4967. #line 10000 "./typica.w"
  4968. /*420:*/
  4969. #line 10013 "./typica.w"
  4970. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  4971. time= QTime::currentTime();
  4972. cseconds= TIMETOINT(time);
  4973. oseconds= TIMETOINT(relative);
  4974. r= cseconds-oseconds;
  4975. /*:420*/
  4976. #line 10001 "./typica.w"
  4977. nt= nt.addSecs(r);
  4978. if(nt!=s)
  4979. {
  4980. s= nt;
  4981. emit valueChanged(s);
  4982. }
  4983. /*:419*/
  4984. #line 9981 "./typica.w"
  4985. ;
  4986. break;
  4987. case TimerDisplay::CountDown:
  4988. /*421:*/
  4989. #line 10025 "./typica.w"
  4990. if(s> QTime(0,0,0))
  4991. {
  4992. /*420:*/
  4993. #line 10013 "./typica.w"
  4994. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  4995. time= QTime::currentTime();
  4996. cseconds= TIMETOINT(time);
  4997. oseconds= TIMETOINT(relative);
  4998. r= cseconds-oseconds;
  4999. /*:420*/
  5000. #line 10028 "./typica.w"
  5001. bseconds= TIMETOINT(base);
  5002. n= bseconds-r;
  5003. nt= nt.addSecs(n);
  5004. if(nt!=s)
  5005. {
  5006. s= nt;
  5007. emit valueChanged(s);
  5008. }
  5009. }
  5010. /*:421*/
  5011. #line 9984 "./typica.w"
  5012. ;
  5013. break;
  5014. case TimerDisplay::Clock:
  5015. /*422:*/
  5016. #line 10042 "./typica.w"
  5017. time= QTime::currentTime();
  5018. if(time!=s)
  5019. {
  5020. s= time;
  5021. emit valueChanged(s);
  5022. }
  5023. /*:422*/
  5024. #line 9987 "./typica.w"
  5025. ;
  5026. break;
  5027. default:
  5028. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5029. break;
  5030. }
  5031. updateDisplay();
  5032. }
  5033. /*:418*//*423:*/
  5034. #line 10054 "./typica.w"
  5035. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5036. void TimerDisplay::startTimer()
  5037. {
  5038. if(!running)
  5039. {
  5040. relative= QTime::currentTime();
  5041. if(ar)
  5042. {
  5043. reset();
  5044. }
  5045. else
  5046. {
  5047. relative= TIMESUBTRACT(relative,s);
  5048. }
  5049. if(m==Clock)
  5050. {
  5051. updateTime();
  5052. }
  5053. base= s;
  5054. clock.start();
  5055. running= true;
  5056. emit runStateChanged(true);
  5057. }
  5058. }
  5059. /*:423*//*424:*/
  5060. #line 10084 "./typica.w"
  5061. void TimerDisplay::stopTimer()
  5062. {
  5063. if(running)
  5064. {
  5065. clock.stop();
  5066. running= false;
  5067. emit runStateChanged(false);
  5068. }
  5069. }
  5070. /*:424*//*425:*/
  5071. #line 10097 "./typica.w"
  5072. TimerDisplay::~TimerDisplay()
  5073. {
  5074. clock.stop();
  5075. }
  5076. /*:425*//*426:*/
  5077. #line 10106 "./typica.w"
  5078. void TimerDisplay::setCountUpMode()
  5079. {
  5080. m= TimerDisplay::CountUp;
  5081. }
  5082. void TimerDisplay::setCountDownMode()
  5083. {
  5084. m= TimerDisplay::CountDown;
  5085. }
  5086. void TimerDisplay::setClockMode()
  5087. {
  5088. m= TimerDisplay::Clock;
  5089. }
  5090. /*:426*//*427:*/
  5091. #line 10124 "./typica.w"
  5092. QString TimerDisplay::value()
  5093. {
  5094. return s.toString(f);
  5095. }
  5096. QTime TimerDisplay::seconds()
  5097. {
  5098. return s;
  5099. }
  5100. TimerDisplay::TimerMode TimerDisplay::mode()
  5101. {
  5102. return m;
  5103. }
  5104. bool TimerDisplay::isRunning()
  5105. {
  5106. return running;
  5107. }
  5108. QTime TimerDisplay::resetValue()
  5109. {
  5110. return r;
  5111. }
  5112. QString TimerDisplay::displayFormat()
  5113. {
  5114. return f;
  5115. }
  5116. bool TimerDisplay::autoReset()
  5117. {
  5118. return ar;
  5119. }
  5120. /*:427*//*428:*/
  5121. #line 10162 "./typica.w"
  5122. void TimerDisplay::setTimer(QTime value)
  5123. {
  5124. if(value.isValid())
  5125. {
  5126. s= value;
  5127. updateDisplay();
  5128. emit valueChanged(value);
  5129. }
  5130. }
  5131. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5132. {
  5133. m= mode;
  5134. }
  5135. void TimerDisplay::setResetValue(QTime value)
  5136. {
  5137. r= value;
  5138. }
  5139. void TimerDisplay::setDisplayFormat(QString format)
  5140. {
  5141. f= format;
  5142. setNumDigits(format.length());
  5143. }
  5144. void TimerDisplay::setAutoReset(bool reset)
  5145. {
  5146. ar= reset;
  5147. }
  5148. /*:428*//*429:*/
  5149. #line 10197 "./typica.w"
  5150. void TimerDisplay::copyTimer()
  5151. {
  5152. QApplication::clipboard()->setText(value());
  5153. }
  5154. /*:429*//*430:*/
  5155. #line 10206 "./typica.w"
  5156. void TimerDisplay::reset()
  5157. {
  5158. if(!running)
  5159. {
  5160. s= r;
  5161. updateDisplay();
  5162. }
  5163. }
  5164. /*:430*//*431:*/
  5165. #line 10219 "./typica.w"
  5166. void TimerDisplay::updateDisplay()
  5167. {
  5168. display(value());
  5169. }
  5170. /*:431*/
  5171. #line 786 "./typica.w"
  5172. /*437:*/
  5173. #line 10313 "./typica.w"
  5174. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5175. {
  5176. int x= rect.x();
  5177. int y= rect.y();
  5178. QLayoutItem*item;
  5179. if(orientation==Qt::Horizontal)
  5180. {
  5181. /*438:*/
  5182. #line 10337 "./typica.w"
  5183. foreach(item,itemList)
  5184. {
  5185. int nextX= x+item->sizeHint().width()+spacing();
  5186. int right= x+item->sizeHint().width();
  5187. if(item==itemList.last())
  5188. {
  5189. right= rect.right();
  5190. }
  5191. int bottom= rect.bottom();
  5192. if(!testOnly)
  5193. {
  5194. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5195. }
  5196. x= nextX;
  5197. }
  5198. /*:438*/
  5199. #line 10321 "./typica.w"
  5200. }
  5201. else
  5202. {
  5203. /*439:*/
  5204. #line 10356 "./typica.w"
  5205. foreach(item,itemList)
  5206. {
  5207. int nextY= y+item->sizeHint().height()+spacing();
  5208. int bottom= y+item->sizeHint().height();
  5209. if(item==itemList.last())
  5210. {
  5211. bottom= rect.bottom();
  5212. }
  5213. int right= rect.right();
  5214. if(!testOnly)
  5215. {
  5216. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5217. }
  5218. y= nextY;
  5219. }
  5220. /*:439*/
  5221. #line 10325 "./typica.w"
  5222. }
  5223. return y;
  5224. }
  5225. /*:437*//*440:*/
  5226. #line 10380 "./typica.w"
  5227. QSize PackLayout::minimumSize()const
  5228. {
  5229. QSize size;
  5230. QLayoutItem*item;
  5231. foreach(item,itemList)
  5232. {
  5233. if(orientation==Qt::Horizontal)
  5234. {
  5235. size+= QSize(item->minimumSize().width(),0);
  5236. if(size.height()<item->minimumSize().height())
  5237. {
  5238. size.setHeight(item->minimumSize().height());
  5239. }
  5240. }
  5241. else
  5242. {
  5243. size+= QSize(0,item->minimumSize().height());
  5244. if(size.width()<item->minimumSize().width())
  5245. {
  5246. size.setWidth(item->minimumSize().width());
  5247. }
  5248. }
  5249. }
  5250. size+= QSize(2*margin(),2*margin());
  5251. return size;
  5252. }
  5253. /*:440*//*441:*/
  5254. #line 10412 "./typica.w"
  5255. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5256. QLayout(parent)
  5257. {
  5258. setMargin(margin);
  5259. setSpacing(spacing);
  5260. setOrientation(Qt::Horizontal);
  5261. }
  5262. PackLayout::PackLayout(int spacing)
  5263. {
  5264. setSpacing(spacing);
  5265. setOrientation(Qt::Horizontal);
  5266. }
  5267. /*:441*//*442:*/
  5268. #line 10430 "./typica.w"
  5269. PackLayout::~PackLayout()
  5270. {
  5271. QLayoutItem*item;
  5272. while((item= takeAt(0)))
  5273. {
  5274. delete item;
  5275. }
  5276. }
  5277. /*:442*//*443:*/
  5278. #line 10444 "./typica.w"
  5279. QLayoutItem*PackLayout::takeAt(int index)
  5280. {
  5281. if(index>=0&&index<itemList.size())
  5282. {
  5283. return itemList.takeAt(index);
  5284. }
  5285. else
  5286. {
  5287. return NULL;
  5288. }
  5289. }
  5290. /*:443*//*444:*/
  5291. #line 10460 "./typica.w"
  5292. QLayoutItem*PackLayout::itemAt(int index)const
  5293. {
  5294. if(index>=0&&index<itemList.size())
  5295. {
  5296. return itemList.at(index);
  5297. }
  5298. else
  5299. {
  5300. return NULL;
  5301. }
  5302. }
  5303. /*:444*//*445:*/
  5304. #line 10483 "./typica.w"
  5305. void PackLayout::addItem(QLayoutItem*item)
  5306. {
  5307. itemList.append(item);
  5308. }
  5309. /*:445*//*446:*/
  5310. #line 10491 "./typica.w"
  5311. int PackLayout::count()const
  5312. {
  5313. return itemList.size();
  5314. }
  5315. /*:446*//*447:*/
  5316. #line 10503 "./typica.w"
  5317. Qt::Orientations PackLayout::expandingDirections()const
  5318. {
  5319. return Qt::Vertical|Qt::Horizontal;
  5320. }
  5321. bool PackLayout::hasHeightForWidth()const
  5322. {
  5323. return false;
  5324. }
  5325. int PackLayout::heightForWidth(int width)const
  5326. {
  5327. return doLayout(QRect(0,0,width,0),true);
  5328. }
  5329. void PackLayout::setGeometry(const QRect&rect)
  5330. {
  5331. QLayout::setGeometry(rect);
  5332. doLayout(rect,false);
  5333. }
  5334. QSize PackLayout::sizeHint()const
  5335. {
  5336. return minimumSize();
  5337. }
  5338. /*:447*//*448:*/
  5339. #line 10534 "./typica.w"
  5340. void PackLayout::setOrientation(Qt::Orientations direction)
  5341. {
  5342. orientation= direction;
  5343. doLayout(geometry(),false);
  5344. }
  5345. /*:448*/
  5346. #line 787 "./typica.w"
  5347. /*450:*/
  5348. #line 10573 "./typica.w"
  5349. SceneButton::SceneButton():QGraphicsScene()
  5350. {
  5351. }
  5352. SceneButton::~SceneButton()
  5353. {
  5354. }
  5355. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5356. {
  5357. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5358. }
  5359. /*:450*/
  5360. #line 788 "./typica.w"
  5361. /*452:*/
  5362. #line 10619 "./typica.w"
  5363. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5364. Qt::Orientations orientation,
  5365. QWidget*parent,Qt::WindowFlags f):
  5366. QWidget(parent,f),label(new QGraphicsView()),
  5367. scene(new SceneButton())
  5368. {
  5369. layout= new PackLayout(this);
  5370. layout->setOrientation(orientation);
  5371. /*453:*/
  5372. #line 10639 "./typica.w"
  5373. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5374. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5375. label->setFrameShape(QFrame::NoFrame);
  5376. label->setInteractive(true);
  5377. /*:453*/
  5378. #line 10628 "./typica.w"
  5379. /*454:*/
  5380. #line 10650 "./typica.w"
  5381. scene->setBackgroundBrush(Qt::cyan);
  5382. text= scene->addText(labeltext);
  5383. if(orientation==Qt::Horizontal)
  5384. {
  5385. text->rotate(270.0);
  5386. }
  5387. label->setScene(scene);
  5388. /*:454*/
  5389. #line 10629 "./typica.w"
  5390. /*455:*/
  5391. #line 10668 "./typica.w"
  5392. if(orientation==Qt::Horizontal)
  5393. {
  5394. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5395. }
  5396. else
  5397. {
  5398. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5399. }
  5400. label->centerOn(text);
  5401. /*:455*/
  5402. #line 10630 "./typica.w"
  5403. /*456:*/
  5404. #line 10683 "./typica.w"
  5405. layout->addWidget(label);
  5406. layout->addWidget(widget);
  5407. if(orientation==Qt::Horizontal)
  5408. {
  5409. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5410. widget->sizeHint().height());
  5411. }
  5412. else
  5413. {
  5414. setMinimumSize(widget->sizeHint().width(),
  5415. widget->sizeHint().height()+label->sizeHint().height());
  5416. }
  5417. /*:456*/
  5418. #line 10631 "./typica.w"
  5419. }
  5420. /*:452*//*457:*/
  5421. #line 10700 "./typica.w"
  5422. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5423. {
  5424. scene->setBackgroundBrush(background);
  5425. }
  5426. void WidgetDecorator::setTextColor(QColor color)
  5427. {
  5428. text->setDefaultTextColor(color);
  5429. }
  5430. /*:457*//*458:*/
  5431. #line 10713 "./typica.w"
  5432. WidgetDecorator::~WidgetDecorator()
  5433. {
  5434. }
  5435. /*:458*/
  5436. #line 789 "./typica.w"
  5437. /*463:*/
  5438. #line 10812 "./typica.w"
  5439. void LogEditWindow::addTheRows()
  5440. {
  5441. QTime s= startTime->time();
  5442. while(s<endTime->time())
  5443. {
  5444. model->newMeasurement(Measurement(0,s),1);
  5445. s= s.addSecs(interval->value());
  5446. }
  5447. model->newMeasurement(Measurement(0,endTime->time()),1);
  5448. }
  5449. /*:463*//*464:*/
  5450. #line 10826 "./typica.w"
  5451. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5452. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5453. addRowsLayout(new QHBoxLayout(NULL)),
  5454. startTimeLabel(new QLabel("Start Time")),
  5455. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5456. endTimeLabel(new QLabel("End Time")),
  5457. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5458. intervalLabel(new QLabel("Interval (seconds)")),
  5459. interval(new QSpinBox()),
  5460. addRows(new QPushButton("Add Rows")),
  5461. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5462. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5463. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5464. model(new MeasurementModel()),
  5465. log(new QTableView())
  5466. {
  5467. /*465:*/
  5468. #line 10863 "./typica.w"
  5469. QSettings settings;
  5470. resize(settings.value("logSize",QSize(620,400)).toSize());
  5471. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5472. /*:465*/
  5473. #line 10843 "./typica.w"
  5474. /*466:*/
  5475. #line 10876 "./typica.w"
  5476. mainLayout->setOrientation(Qt::Vertical);
  5477. addRowsLayout->addSpacing(10);
  5478. addRowsLayout->addWidget(startTimeLabel);
  5479. addRowsLayout->addWidget(startTime);
  5480. addRowsLayout->addSpacing(10);
  5481. startTime->setDisplayFormat("mm:ss");
  5482. addRowsLayout->addWidget(endTimeLabel);
  5483. addRowsLayout->addWidget(endTime);
  5484. addRowsLayout->addSpacing(10);
  5485. endTime->setDisplayFormat("mm:ss");
  5486. addRowsLayout->addWidget(intervalLabel);
  5487. addRowsLayout->addWidget(interval);
  5488. addRowsLayout->addSpacing(10);
  5489. interval->setRange(0,60);
  5490. interval->setValue(30);
  5491. addRowsLayout->addWidget(addRows);
  5492. addRowsLayout->addSpacing(10);
  5493. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5494. /*:466*/
  5495. #line 10844 "./typica.w"
  5496. /*467:*/
  5497. #line 10899 "./typica.w"
  5498. model->setHeaderData(0,Qt::Horizontal,"Time");
  5499. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5500. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5501. model->clear();
  5502. /*:467*/
  5503. #line 10845 "./typica.w"
  5504. /*468:*/
  5505. #line 10908 "./typica.w"
  5506. log->setModel(model);
  5507. log->setColumnWidth(0,100);
  5508. log->setColumnWidth(1,100);
  5509. log->setColumnWidth(2,100);
  5510. /*:468*/
  5511. #line 10846 "./typica.w"
  5512. mainLayout->addItem(addRowsLayout);
  5513. mainLayout->addWidget(log);
  5514. centralWidget->setLayout(mainLayout);
  5515. setCentralWidget(centralWidget);
  5516. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5517. fileMenu->addAction(openXml);
  5518. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5519. fileMenu->addAction(saveXml);
  5520. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5521. fileMenu->addAction(saveCsv);
  5522. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5523. }
  5524. /*:464*//*469:*/
  5525. #line 10919 "./typica.w"
  5526. void LogEditWindow::saveXML()
  5527. {
  5528. QSettings settings;
  5529. QString lastDir= settings.value("lastDirectory").toString();
  5530. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5531. lastDir,"",0);
  5532. QFile file(filename);
  5533. XMLOutput writer(model,&file,0);
  5534. writer.addTemperatureColumn("Temperature",1);
  5535. writer.addAnnotationColumn("Annotation",2);
  5536. if(writer.output())
  5537. {
  5538. QFileInfo info(filename);
  5539. QDir directory= info.dir();
  5540. lastDir= directory.path();
  5541. settings.setValue("lastDirectory",lastDir);
  5542. }
  5543. }
  5544. void LogEditWindow::saveCSV()
  5545. {
  5546. QSettings settings;
  5547. QString lastDir= settings.value("lastDirectory").toString();
  5548. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5549. lastDir,"",0);
  5550. QFile file(filename);
  5551. CSVOutput writer(model,&file,0);
  5552. writer.addTemperatureColumn("Temperature",1);
  5553. writer.addAnnotationColumn("Annotation",2);
  5554. if(writer.output())
  5555. {
  5556. QFileInfo info(filename);
  5557. QDir directory= info.dir();
  5558. lastDir= directory.path();
  5559. settings.setValue("lastDirectory",lastDir);
  5560. }
  5561. }
  5562. /*:469*//*470:*/
  5563. #line 10962 "./typica.w"
  5564. void LogEditWindow::openXML()
  5565. {
  5566. QSettings settings;
  5567. QString lastDir= settings.value("lastDirectory").toString();
  5568. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  5569. lastDir,"",0);
  5570. if(filename.isNull())
  5571. {
  5572. return;
  5573. }
  5574. QFile file(filename);
  5575. XMLInput reader(&file,1);
  5576. connect(&reader,SIGNAL(measure(Measurement,int)),
  5577. model,SLOT(newMeasurement(Measurement,int)));
  5578. connect(&reader,SIGNAL(annotation(QString,int,int)),
  5579. model,SLOT(newAnnotation(QString,int,int)));
  5580. if(reader.input())
  5581. {
  5582. QFileInfo info(filename);
  5583. setWindowTitle(QString(tr("%1 - %2")).
  5584. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  5585. QDir directory= info.dir();
  5586. lastDir= directory.path();
  5587. settings.setValue("lastDirectory",lastDir);
  5588. }
  5589. }
  5590. /*:470*//*471:*/
  5591. #line 10993 "./typica.w"
  5592. void LogEditWindow::closeEvent(QCloseEvent*event)
  5593. {
  5594. QSettings settings;
  5595. settings.setValue("logSize",size());
  5596. settings.setValue("logPos",pos());
  5597. event->accept();
  5598. }
  5599. /*:471*/
  5600. #line 790 "./typica.w"
  5601. /*477:*/
  5602. #line 11108 "./typica.w"
  5603. bool XMLOutput::output()
  5604. {
  5605. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5606. {
  5607. return false;
  5608. }
  5609. QXmlStreamWriter xmlout(out);
  5610. xmlout.writeStartDocument("1.0");
  5611. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  5612. xmlout.writeStartElement("roastlog");
  5613. /*478:*/
  5614. #line 11141 "./typica.w"
  5615. foreach(int c,temperatureColumns.keys())
  5616. {
  5617. xmlout.writeStartElement("tempseries");
  5618. xmlout.writeAttribute("name",temperatureColumns.value(c));
  5619. xmlout.writeEndElement();
  5620. }
  5621. foreach(int c,controlColumns.keys())
  5622. {
  5623. xmlout.writeStartElement("controlseries");
  5624. xmlout.writeAttribute("name",controlColumns.value(c));
  5625. xmlout.writeEndElement();
  5626. }
  5627. foreach(int c,annotationColumns.keys())
  5628. {
  5629. xmlout.writeStartElement("noteseries");
  5630. xmlout.writeAttribute("name",annotationColumns.value(c));
  5631. xmlout.writeEndElement();
  5632. }
  5633. /*:478*/
  5634. #line 11119 "./typica.w"
  5635. xmlout.writeStartElement("roast");
  5636. bool oresult;
  5637. for(int i= 0;i<data->rowCount();i++)
  5638. {
  5639. /*479:*/
  5640. #line 11166 "./typica.w"
  5641. oresult= false;
  5642. foreach(int c,temperatureColumns.keys())
  5643. {
  5644. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5645. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5646. {
  5647. oresult= true;
  5648. break;
  5649. }
  5650. }
  5651. foreach(int c,controlColumns.keys())
  5652. {
  5653. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5654. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5655. {
  5656. oresult= true;
  5657. break;
  5658. }
  5659. }
  5660. if(oresult==false)
  5661. {
  5662. foreach(int c,annotationColumns.keys())
  5663. {
  5664. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5665. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5666. isEmpty()))
  5667. {
  5668. oresult= true;
  5669. break;
  5670. }
  5671. }
  5672. }
  5673. /*:479*/
  5674. #line 11124 "./typica.w"
  5675. if(oresult)
  5676. {
  5677. /*480:*/
  5678. #line 11205 "./typica.w"
  5679. xmlout.writeStartElement("tuple");
  5680. xmlout.writeTextElement("time",data->data(data->index(i,time),
  5681. Qt::DisplayRole).toString());
  5682. foreach(int c,temperatureColumns.keys())
  5683. {
  5684. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5685. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5686. {
  5687. xmlout.writeStartElement("temperature");
  5688. xmlout.writeAttribute("series",temperatureColumns.value(c));
  5689. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  5690. {
  5691. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool()==true)
  5692. {
  5693. xmlout.writeAttribute("relative","true");
  5694. }
  5695. }
  5696. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5697. toString());
  5698. xmlout.writeEndElement();
  5699. }
  5700. }
  5701. foreach(int c,controlColumns.keys())
  5702. {
  5703. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5704. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5705. {
  5706. xmlout.writeStartElement("control");
  5707. xmlout.writeAttribute("series",controlColumns.value(c));
  5708. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  5709. xmlout.writeEndElement();
  5710. }
  5711. }
  5712. foreach(int c,annotationColumns.keys())
  5713. {
  5714. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5715. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5716. {
  5717. xmlout.writeStartElement("annotation");
  5718. xmlout.writeAttribute("series",annotationColumns.value(c));
  5719. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5720. toString());
  5721. xmlout.writeEndElement();
  5722. }
  5723. }
  5724. xmlout.writeEndElement();
  5725. /*:480*/
  5726. #line 11127 "./typica.w"
  5727. }
  5728. }
  5729. xmlout.writeEndElement();
  5730. xmlout.writeEndElement();
  5731. xmlout.writeEndDocument();
  5732. out->close();
  5733. return true;
  5734. }
  5735. /*:477*//*481:*/
  5736. #line 11255 "./typica.w"
  5737. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  5738. :QObject(NULL),data(model),out(device),time(timec)
  5739. {
  5740. }
  5741. void XMLOutput::setModel(MeasurementModel*model)
  5742. {
  5743. data= model;
  5744. }
  5745. void XMLOutput::setTimeColumn(int column)
  5746. {
  5747. time= column;
  5748. }
  5749. void XMLOutput::setDevice(QIODevice*device)
  5750. {
  5751. out= device;
  5752. }
  5753. /*:481*//*482:*/
  5754. #line 11284 "./typica.w"
  5755. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  5756. {
  5757. temperatureColumns.insert(column,series);
  5758. }
  5759. void XMLOutput::addControlColumn(const QString&series,int column)
  5760. {
  5761. controlColumns.insert(column,series);
  5762. }
  5763. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  5764. {
  5765. annotationColumns.insert(column,series);
  5766. }
  5767. /*:482*/
  5768. #line 791 "./typica.w"
  5769. /*484:*/
  5770. #line 11341 "./typica.w"
  5771. bool XMLInput::input()
  5772. {
  5773. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  5774. {
  5775. return false;
  5776. }
  5777. QXmlStreamReader xmlin(in);
  5778. QMap<QString,int> temperatureColumns;
  5779. QMap<QString,int> annotationColumns;
  5780. int nextColumn= firstc;
  5781. /*485:*/
  5782. #line 11372 "./typica.w"
  5783. while(!xmlin.isDTD())
  5784. {
  5785. xmlin.readNext();
  5786. }
  5787. if(xmlin.isDTD())
  5788. {
  5789. if(xmlin.text()=="<!DOCTYPE roastlog>")
  5790. {
  5791. /*486:*/
  5792. #line 11394 "./typica.w"
  5793. emit newTemperatureColumn(firstc,"Bean");
  5794. emit newAnnotationColumn(firstc+1,"Note");
  5795. emit lastColumn(firstc+1);
  5796. /*:486*/
  5797. #line 11381 "./typica.w"
  5798. }
  5799. else
  5800. {
  5801. xmlin.readNext();
  5802. /*487:*/
  5803. #line 11403 "./typica.w"
  5804. while(xmlin.name()!="roast")
  5805. {
  5806. if(xmlin.isStartElement())
  5807. {
  5808. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  5809. {
  5810. temperatureColumns.insert(xmlin.attributes().value("name").
  5811. toString(),
  5812. nextColumn);
  5813. emit newTemperatureColumn(nextColumn,
  5814. xmlin.attributes().value("name").
  5815. toString());
  5816. nextColumn++;
  5817. }
  5818. else if(xmlin.name()=="noteseries")
  5819. {
  5820. annotationColumns.insert(xmlin.attributes().value("name").
  5821. toString(),nextColumn);
  5822. emit newAnnotationColumn(nextColumn,
  5823. xmlin.attributes().value("name").
  5824. toString());
  5825. nextColumn++;
  5826. }
  5827. }
  5828. xmlin.readNext();
  5829. }
  5830. emit lastColumn(nextColumn-1);
  5831. /*:487*/
  5832. #line 11386 "./typica.w"
  5833. }
  5834. }
  5835. /*:485*/
  5836. #line 11352 "./typica.w"
  5837. QTime timeval= QTime();
  5838. double tempval= 0;
  5839. QString noteval= QString();
  5840. int column;
  5841. int counter= 0;
  5842. while(!xmlin.atEnd())
  5843. {
  5844. /*488:*/
  5845. #line 11444 "./typica.w"
  5846. xmlin.readNext();
  5847. if(xmlin.isStartElement())
  5848. {
  5849. /*489:*/
  5850. #line 11470 "./typica.w"
  5851. if(xmlin.name()=="time")
  5852. {
  5853. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  5854. }
  5855. else if(xmlin.name()=="temperature")
  5856. {
  5857. column= xmlin.attributes().value("series").toString().isEmpty()?
  5858. firstc:temperatureColumns.value(xmlin.attributes().
  5859. value("series").toString());
  5860. bool relative= false;
  5861. if(xmlin.attributes().value("relative")=="true")
  5862. {
  5863. relative= true;
  5864. }
  5865. tempval= xmlin.readElementText().toDouble();
  5866. Measurement measurement(tempval,timeval);
  5867. if(relative)
  5868. {
  5869. measurement.insert("relative",true);
  5870. }
  5871. emit measure(measurement,column);
  5872. }
  5873. else if(xmlin.name()=="control")
  5874. {
  5875. column= xmlin.attributes().value("series").toString().isEmpty()?
  5876. firstc:temperatureColumns.value(xmlin.attributes().
  5877. value("series").toString());
  5878. tempval= xmlin.readElementText().toDouble();
  5879. Measurement measurement(tempval,timeval,Units::Unitless);
  5880. emit measure(measurement,column);
  5881. }
  5882. else if(xmlin.name()=="annotation")
  5883. {
  5884. column= xmlin.attributes().value("series").toString().isEmpty()?
  5885. firstc+1:annotationColumns.value(xmlin.attributes().
  5886. value("series").toString());
  5887. noteval= xmlin.readElementText();
  5888. if(!noteval.isEmpty())
  5889. {
  5890. emit annotation(noteval,firstc,column);
  5891. }
  5892. }
  5893. /*:489*/
  5894. #line 11448 "./typica.w"
  5895. }
  5896. counter++;
  5897. if(counter%100==0)
  5898. {
  5899. QCoreApplication::processEvents();
  5900. }
  5901. /*:488*/
  5902. #line 11360 "./typica.w"
  5903. }
  5904. return true;
  5905. }
  5906. /*:484*//*490:*/
  5907. #line 11516 "./typica.w"
  5908. XMLInput::XMLInput(QIODevice*input,int c):
  5909. firstc(c),in(input)
  5910. {
  5911. }
  5912. void XMLInput::setFirstColumn(int column)
  5913. {
  5914. firstc= column;
  5915. }
  5916. void XMLInput::setDevice(QIODevice*device)
  5917. {
  5918. in= device;
  5919. }
  5920. /*:490*/
  5921. #line 792 "./typica.w"
  5922. /*495:*/
  5923. #line 11607 "./typica.w"
  5924. bool CSVOutput::output()
  5925. {
  5926. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5927. {
  5928. return false;
  5929. }
  5930. QTextStream output(out);
  5931. /*496:*/
  5932. #line 11631 "./typica.w"
  5933. output<<"Time";
  5934. foreach(int c,temperatureColumns.keys())
  5935. {
  5936. output<<','<<temperatureColumns.value(c);
  5937. }
  5938. foreach(int c,controlColumns.keys())
  5939. {
  5940. output<<','<<controlColumns.value(c);
  5941. }
  5942. foreach(int c,annotationColumns.keys())
  5943. {
  5944. output<<','<<annotationColumns.value(c);
  5945. }
  5946. output<<'\n';
  5947. /*:496*/
  5948. #line 11615 "./typica.w"
  5949. bool oresult;
  5950. for(int i= 0;i<data->rowCount();i++)
  5951. {
  5952. /*479:*/
  5953. #line 11166 "./typica.w"
  5954. oresult= false;
  5955. foreach(int c,temperatureColumns.keys())
  5956. {
  5957. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5958. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5959. {
  5960. oresult= true;
  5961. break;
  5962. }
  5963. }
  5964. foreach(int c,controlColumns.keys())
  5965. {
  5966. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5967. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5968. {
  5969. oresult= true;
  5970. break;
  5971. }
  5972. }
  5973. if(oresult==false)
  5974. {
  5975. foreach(int c,annotationColumns.keys())
  5976. {
  5977. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5978. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5979. isEmpty()))
  5980. {
  5981. oresult= true;
  5982. break;
  5983. }
  5984. }
  5985. }
  5986. /*:479*/
  5987. #line 11619 "./typica.w"
  5988. if(oresult)
  5989. {
  5990. /*497:*/
  5991. #line 11656 "./typica.w"
  5992. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  5993. foreach(int c,temperatureColumns.keys())
  5994. {
  5995. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  5996. }
  5997. foreach(int c,controlColumns.keys())
  5998. {
  5999. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6000. }
  6001. foreach(int c,annotationColumns.keys())
  6002. {
  6003. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6004. }
  6005. output<<'\n';
  6006. /*:497*/
  6007. #line 11622 "./typica.w"
  6008. }
  6009. }
  6010. out->close();
  6011. return true;
  6012. }
  6013. /*:495*//*498:*/
  6014. #line 11675 "./typica.w"
  6015. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6016. data(model),out(device),time(timec)
  6017. {
  6018. }
  6019. void CSVOutput::setModel(MeasurementModel*model)
  6020. {
  6021. data= model;
  6022. }
  6023. void CSVOutput::setTimeColumn(int column)
  6024. {
  6025. time= column;
  6026. }
  6027. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6028. {
  6029. temperatureColumns.insert(column,series);
  6030. }
  6031. void CSVOutput::addControlColumn(const QString&series,int column)
  6032. {
  6033. controlColumns.insert(column,series);
  6034. }
  6035. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6036. {
  6037. annotationColumns.insert(column,series);
  6038. }
  6039. void CSVOutput::setDevice(QIODevice*device)
  6040. {
  6041. out= device;
  6042. }
  6043. #line 1 "./webview.w"
  6044. /*:498*/
  6045. #line 793 "./typica.w"
  6046. /*533:*/
  6047. #line 11931 "./typica.w"
  6048. QString SaltModel::arrayLiteral(int column,int role)const
  6049. {
  6050. QString literal= "'{";
  6051. for(int i= 0;i<rowCount();i++)
  6052. {
  6053. QString datum= data(index(i,column),role).toString();
  6054. if(!datum.isEmpty())
  6055. {
  6056. literal.append(datum);
  6057. literal.append(", ");
  6058. }
  6059. }
  6060. if(literal.size()> 2)
  6061. {
  6062. literal.chop(2);
  6063. }
  6064. literal.append("}'");
  6065. return literal;
  6066. }
  6067. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6068. {
  6069. QString literal= "'{";
  6070. for(int i= 0;i<rowCount();i++)
  6071. {
  6072. QString datum= data(index(i,column),role).toString();
  6073. if(!datum.isEmpty())
  6074. {
  6075. literal.append("\"");
  6076. literal.append(datum);
  6077. literal.append("\", ");
  6078. }
  6079. }
  6080. if(literal.size()> 2)
  6081. {
  6082. literal.chop(2);
  6083. }
  6084. literal.append("}'");
  6085. return literal;
  6086. }
  6087. /*:533*//*534:*/
  6088. #line 11975 "./typica.w"
  6089. QModelIndex SaltModel::parent(const QModelIndex&)const
  6090. {
  6091. return QModelIndex();
  6092. }
  6093. /*:534*//*535:*/
  6094. #line 11994 "./typica.w"
  6095. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6096. int role)
  6097. {
  6098. /*536:*/
  6099. #line 12025 "./typica.w"
  6100. bool valid= false;
  6101. if(index.isValid())
  6102. {
  6103. if(index.row()<modelData.size())
  6104. {
  6105. if(index.column()<colcount)
  6106. {
  6107. valid= true;
  6108. }
  6109. }
  6110. }
  6111. /*:536*/
  6112. #line 11998 "./typica.w"
  6113. if(!valid)
  6114. {
  6115. return false;
  6116. }
  6117. if(index.row()==modelData.size()-1)
  6118. {
  6119. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6120. /*537:*/
  6121. #line 12041 "./typica.w"
  6122. QList<QMap<int,QVariant> > newRow;
  6123. QMap<int,QVariant> defaults;
  6124. for(int i= 0;i<colcount;i++)
  6125. {
  6126. newRow.append(defaults);
  6127. }
  6128. modelData.append(newRow);
  6129. /*:537*/
  6130. #line 12006 "./typica.w"
  6131. endInsertRows();
  6132. }
  6133. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6134. QMap<int,QVariant> cell= row.at(index.column());
  6135. cell.insert(role,value);
  6136. if(role==Qt::EditRole)
  6137. {
  6138. cell.insert(Qt::DisplayRole,value);
  6139. }
  6140. row.replace(index.column(),cell);
  6141. modelData.replace(index.row(),row);
  6142. emit dataChanged(index,index);
  6143. return true;
  6144. }
  6145. /*:535*//*538:*/
  6146. #line 12052 "./typica.w"
  6147. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6148. {
  6149. for(int i= 0;i<columns;i++)
  6150. {
  6151. hData<<"";
  6152. }
  6153. /*537:*/
  6154. #line 12041 "./typica.w"
  6155. QList<QMap<int,QVariant> > newRow;
  6156. QMap<int,QVariant> defaults;
  6157. for(int i= 0;i<colcount;i++)
  6158. {
  6159. newRow.append(defaults);
  6160. }
  6161. modelData.append(newRow);
  6162. /*:537*/
  6163. #line 12059 "./typica.w"
  6164. }
  6165. /*:538*//*539:*/
  6166. #line 12064 "./typica.w"
  6167. SaltModel::~SaltModel()
  6168. {
  6169. }
  6170. /*:539*//*540:*/
  6171. #line 12074 "./typica.w"
  6172. int SaltModel::rowCount(const QModelIndex&parent)const
  6173. {
  6174. return(parent==QModelIndex()?modelData.size():0);
  6175. }
  6176. int SaltModel::columnCount(const QModelIndex&parent)const
  6177. {
  6178. return(parent==QModelIndex()?colcount:0);
  6179. }
  6180. /*:540*//*541:*/
  6181. #line 12087 "./typica.w"
  6182. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6183. const QVariant&value,int)
  6184. {
  6185. if(orientation==Qt::Horizontal&&section<colcount)
  6186. {
  6187. hData.replace(section,value.toString());
  6188. emit headerDataChanged(orientation,section,section);
  6189. return true;
  6190. }
  6191. return false;
  6192. }
  6193. /*:541*//*542:*/
  6194. #line 12102 "./typica.w"
  6195. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6196. {
  6197. /*536:*/
  6198. #line 12025 "./typica.w"
  6199. bool valid= false;
  6200. if(index.isValid())
  6201. {
  6202. if(index.row()<modelData.size())
  6203. {
  6204. if(index.column()<colcount)
  6205. {
  6206. valid= true;
  6207. }
  6208. }
  6209. }
  6210. /*:536*/
  6211. #line 12105 "./typica.w"
  6212. if(!valid)
  6213. {
  6214. return QVariant();
  6215. }
  6216. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6217. QMap<int,QVariant> cell= row.at(index.column());
  6218. return cell.value(role,QVariant());
  6219. }
  6220. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6221. int role)const
  6222. {
  6223. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6224. section<colcount)
  6225. {
  6226. return QVariant(hData.at(section));
  6227. }
  6228. return QVariant();
  6229. }
  6230. /*:542*//*543:*/
  6231. #line 12129 "./typica.w"
  6232. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6233. {
  6234. /*536:*/
  6235. #line 12025 "./typica.w"
  6236. bool valid= false;
  6237. if(index.isValid())
  6238. {
  6239. if(index.row()<modelData.size())
  6240. {
  6241. if(index.column()<colcount)
  6242. {
  6243. valid= true;
  6244. }
  6245. }
  6246. }
  6247. /*:536*/
  6248. #line 12132 "./typica.w"
  6249. if(valid)
  6250. {
  6251. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6252. }
  6253. return 0;
  6254. }
  6255. /*:543*//*544:*/
  6256. #line 12143 "./typica.w"
  6257. QModelIndex SaltModel::index(int row,int column,
  6258. const QModelIndex&parent)const
  6259. {
  6260. if(parent==QModelIndex())
  6261. {
  6262. if(row<modelData.size()&&column<colcount)
  6263. {
  6264. return createIndex(row,column);
  6265. }
  6266. }
  6267. return QModelIndex();
  6268. }
  6269. /*:544*/
  6270. #line 794 "./typica.w"
  6271. /*546:*/
  6272. #line 12198 "./typica.w"
  6273. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6274. {
  6275. SqlComboBox*widget= new SqlComboBox();
  6276. widget->setParent(parent);
  6277. for(int i= 0;i<count();i++)
  6278. {
  6279. widget->addItem(itemText(i),itemData(i));
  6280. }
  6281. return widget;
  6282. }
  6283. /*:546*//*547:*/
  6284. #line 12215 "./typica.w"
  6285. void SqlComboBox::showData(bool show)
  6286. {
  6287. dataColumnShown= show;
  6288. }
  6289. /*:547*//*548:*/
  6290. #line 12226 "./typica.w"
  6291. void SqlComboBox::addNullOption()
  6292. {
  6293. addItem(tr("Unknown"),QVariant(QVariant::String));
  6294. }
  6295. /*:548*//*549:*/
  6296. #line 12239 "./typica.w"
  6297. void SqlComboBox::setDataColumn(int column)
  6298. {
  6299. dataColumn= column;
  6300. }
  6301. void SqlComboBox::setDisplayColumn(int column)
  6302. {
  6303. displayColumn= column;
  6304. }
  6305. /*:549*//*550:*/
  6306. #line 12253 "./typica.w"
  6307. void SqlComboBox::addSqlOptions(QString query)
  6308. {
  6309. SqlQueryConnection*dbquery= new SqlQueryConnection;
  6310. if(!dbquery->exec(query))
  6311. {
  6312. QSqlError error= dbquery->lastError();
  6313. qDebug()<<error.databaseText();
  6314. qDebug()<<error.driverText();
  6315. qDebug()<<error.text();
  6316. qDebug()<<dbquery->lastQuery();
  6317. }
  6318. while(dbquery->next())
  6319. {
  6320. QString displayValue(dbquery->value(displayColumn).toString());
  6321. QString dataValue(dbquery->value(dataColumn).toString());
  6322. if(dataColumnShown)
  6323. {
  6324. displayValue.append(QString(" (%1)").arg(dataValue));
  6325. }
  6326. addItem(displayValue,dataValue);
  6327. }
  6328. delete dbquery;
  6329. }
  6330. /*:550*//*551:*/
  6331. #line 12289 "./typica.w"
  6332. SqlComboBox::SqlComboBox():
  6333. dataColumn(0),displayColumn(0),dataColumnShown(false)
  6334. {
  6335. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6336. }
  6337. SqlComboBox::~SqlComboBox()
  6338. {
  6339. }
  6340. /*:551*/
  6341. #line 795 "./typica.w"
  6342. /*553:*/
  6343. #line 12327 "./typica.w"
  6344. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6345. {
  6346. delegate= widget;
  6347. }
  6348. /*:553*//*554:*/
  6349. #line 12336 "./typica.w"
  6350. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6351. const QStyleOptionViewItem&,
  6352. const QModelIndex&)const
  6353. {
  6354. return delegate->clone(parent);
  6355. }
  6356. /*:554*//*555:*/
  6357. #line 12347 "./typica.w"
  6358. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6359. const QModelIndex&index)const
  6360. {
  6361. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6362. self->setCurrentIndex(self->findData(
  6363. index.model()->data(index,
  6364. Qt::UserRole).toString()));
  6365. }
  6366. /*:555*//*556:*/
  6367. #line 12360 "./typica.w"
  6368. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6369. QAbstractItemModel*model,
  6370. const QModelIndex&index)const
  6371. {
  6372. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6373. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6374. Qt::UserRole);
  6375. model->setData(index,self->currentText(),Qt::DisplayRole);
  6376. }
  6377. /*:556*//*557:*/
  6378. #line 12373 "./typica.w"
  6379. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6380. const QStyleOptionViewItem&option,
  6381. const QModelIndex&)const
  6382. {
  6383. editor->setGeometry(option.rect);
  6384. }
  6385. /*:557*//*558:*/
  6386. #line 12384 "./typica.w"
  6387. QSize SqlComboBoxDelegate::sizeHint()const
  6388. {
  6389. return delegate->sizeHint();
  6390. }
  6391. /*:558*//*559:*/
  6392. #line 12392 "./typica.w"
  6393. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6394. :QItemDelegate(parent)
  6395. {
  6396. }
  6397. /*:559*/
  6398. #line 796 "./typica.w"
  6399. /*525:*/
  6400. #line 11745 "./typica.w"
  6401. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6402. {
  6403. /*526:*/
  6404. #line 11760 "./typica.w"
  6405. setOrganizationName("Wilson's Coffee & Tea");
  6406. setOrganizationDomain("wilsonscoffee.com");
  6407. setApplicationName(PROGRAM_NAME);
  6408. /*:526*/
  6409. #line 11748 "./typica.w"
  6410. /*527:*/
  6411. #line 11769 "./typica.w"
  6412. QTranslator base;
  6413. if(base.load(QString("qt_%1").arg(QLocale::system().name())))
  6414. {
  6415. installTranslator(&base);
  6416. }
  6417. QTranslator app;
  6418. if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
  6419. {
  6420. installTranslator(&app);
  6421. }
  6422. /*:527*/
  6423. #line 11749 "./typica.w"
  6424. /*251:*/
  6425. #line 123 "./measurement.w"
  6426. qRegisterMetaType<Measurement> ("Measurement");
  6427. #line 5787 "./typica.w"
  6428. /*:251*/
  6429. #line 11750 "./typica.w"
  6430. /*706:*/
  6431. #line 15548 "./typica.w"
  6432. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6433. tr("NI DAQmx Base"),
  6434. "nidaqmxbase",NULL);
  6435. topLevelNodeInserters.append(inserter);
  6436. /*:706*//*714:*/
  6437. #line 15779 "./typica.w"
  6438. #ifdef Q_OS_WIN32
  6439. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6440. topLevelNodeInserters.append(inserter);
  6441. #endif
  6442. /*:714*//*738:*/
  6443. #line 16742 "./typica.w"
  6444. #if 0
  6445. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6446. topLevelNodeInserters.append(inserter);
  6447. #endif
  6448. /*:738*//*782:*/
  6449. #line 18224 "./typica.w"
  6450. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6451. topLevelNodeInserters.append(inserter);
  6452. /*:782*//*846:*/
  6453. #line 1241 "./dataqsdk.w"
  6454. #ifdef Q_OS_WIN32
  6455. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  6456. "dataqsdk",NULL);
  6457. topLevelNodeInserters.append(inserter);
  6458. #endif
  6459. #line 18444 "./typica.w"
  6460. #line 1 "./scales.w"
  6461. /*:846*//*871:*/
  6462. #line 495 "./scales.w"
  6463. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  6464. topLevelNodeInserters.append(inserter);
  6465. #line 18446 "./typica.w"
  6466. #line 1 "./valueannotation.w"
  6467. /*:871*/
  6468. #line 11751 "./typica.w"
  6469. }
  6470. /*:525*//*529:*/
  6471. #line 11792 "./typica.w"
  6472. QDomDocument*Application::configuration()
  6473. {
  6474. return&conf;
  6475. }
  6476. /*:529*//*530:*/
  6477. #line 11801 "./typica.w"
  6478. QSqlDatabase Application::database()
  6479. {
  6480. QString connectionName;
  6481. QSqlDatabase connection= QSqlDatabase::database();
  6482. do
  6483. {
  6484. connectionName= QUuid::createUuid().toString();
  6485. }while(QSqlDatabase::connectionNames().contains(connectionName));
  6486. return QSqlDatabase::cloneDatabase(connection,connectionName);
  6487. }
  6488. /*:530*//*641:*/
  6489. #line 14152 "./typica.w"
  6490. void Application::saveDeviceConfiguration()
  6491. {
  6492. QSettings settings;
  6493. settings.setValue("DeviceConfiguration",
  6494. QVariant(deviceConfigurationDocument.toByteArray()));
  6495. }
  6496. /*:641*//*642:*/
  6497. #line 14164 "./typica.w"
  6498. QDomDocument Application::deviceConfiguration()
  6499. {
  6500. if(deviceConfigurationDocument.isNull())
  6501. {
  6502. /*643:*/
  6503. #line 14178 "./typica.w"
  6504. QSettings settings;
  6505. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  6506. QString etext;
  6507. int eline;
  6508. int ecol;
  6509. if(document.length()==0)
  6510. {
  6511. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  6512. /*644:*/
  6513. #line 14202 "./typica.w"
  6514. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6515. emptyDocument.open(QIODevice::ReadOnly);
  6516. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6517. &etext,&eline,&ecol))
  6518. {
  6519. /*645:*/
  6520. #line 14219 "./typica.w"
  6521. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6522. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6523. qDebug()<<etext;
  6524. /*:645*/
  6525. #line 14208 "./typica.w"
  6526. }
  6527. else
  6528. {
  6529. saveDeviceConfiguration();
  6530. }
  6531. /*:644*/
  6532. #line 14187 "./typica.w"
  6533. }
  6534. else
  6535. {
  6536. if(!deviceConfigurationDocument.setContent(document,false,
  6537. &etext,&eline,&ecol))
  6538. {
  6539. /*645:*/
  6540. #line 14219 "./typica.w"
  6541. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6542. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6543. qDebug()<<etext;
  6544. /*:645*/
  6545. #line 14194 "./typica.w"
  6546. /*644:*/
  6547. #line 14202 "./typica.w"
  6548. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6549. emptyDocument.open(QIODevice::ReadOnly);
  6550. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6551. &etext,&eline,&ecol))
  6552. {
  6553. /*645:*/
  6554. #line 14219 "./typica.w"
  6555. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6556. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6557. qDebug()<<etext;
  6558. /*:645*/
  6559. #line 14208 "./typica.w"
  6560. }
  6561. else
  6562. {
  6563. saveDeviceConfiguration();
  6564. }
  6565. /*:644*/
  6566. #line 14195 "./typica.w"
  6567. }
  6568. }
  6569. /*:643*/
  6570. #line 14169 "./typica.w"
  6571. }
  6572. return deviceConfigurationDocument;
  6573. }
  6574. /*:642*//*673:*/
  6575. #line 14820 "./typica.w"
  6576. void Application::registerDeviceConfigurationWidget(QString driver,
  6577. QMetaObject widget)
  6578. {
  6579. deviceConfigurationWidgets.insert(driver,widget);
  6580. }
  6581. /*:673*//*674:*/
  6582. #line 14836 "./typica.w"
  6583. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  6584. const QModelIndex&index)
  6585. {
  6586. QVariant nodeReference= index.data(Qt::UserRole);
  6587. QDomElement referenceElement= model->referenceElement(
  6588. model->data(index,Qt::UserRole).toString());
  6589. QMetaObject metaObject=
  6590. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  6591. QWidget::staticMetaObject);
  6592. QWidget*editor;
  6593. if(metaObject.className()==QWidget::staticMetaObject.className())
  6594. {
  6595. editor= NULL;
  6596. }
  6597. else
  6598. {
  6599. editor= qobject_cast<QWidget*> (
  6600. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  6601. Q_ARG(QModelIndex,index)));
  6602. }
  6603. return editor;
  6604. }
  6605. /*:674*/
  6606. #line 797 "./typica.w"
  6607. /*565:*/
  6608. #line 12510 "./typica.w"
  6609. SqlConnectionSetup::SqlConnectionSetup():
  6610. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  6611. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  6612. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  6613. cancelButton(new QPushButton(tr("Cancel"))),
  6614. connectButton(new QPushButton(tr("Connect")))
  6615. {
  6616. driver->addItem("PostgreSQL","QPSQL");
  6617. formLayout->addRow(tr("Database driver:"),driver);
  6618. formLayout->addRow(tr("Host name:"),hostname);
  6619. formLayout->addRow(tr("Database name:"),dbname);
  6620. formLayout->addRow(tr("User name:"),user);
  6621. password->setEchoMode(QLineEdit::Password);
  6622. formLayout->addRow(tr("Password:"),password);
  6623. layout->addLayout(formLayout);
  6624. buttons->addStretch(1);
  6625. buttons->addWidget(cancelButton);
  6626. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  6627. buttons->addWidget(connectButton);
  6628. layout->addLayout(buttons);
  6629. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  6630. setLayout(layout);
  6631. setModal(true);
  6632. }
  6633. SqlConnectionSetup::~SqlConnectionSetup()
  6634. {
  6635. }
  6636. /*:565*//*566:*/
  6637. #line 12544 "./typica.w"
  6638. void SqlConnectionSetup::testConnection()
  6639. {
  6640. QSqlDatabase database=
  6641. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  6642. toString());
  6643. database.setConnectOptions("application_name=Typica");
  6644. database.setHostName(hostname->text());
  6645. database.setDatabaseName(dbname->text());
  6646. database.setUserName(user->text());
  6647. database.setPassword(password->text());
  6648. if(database.open())
  6649. {
  6650. QSettings settings;
  6651. settings.setValue("database/exists","true");
  6652. settings.setValue("database/driver",
  6653. driver->itemData(driver->currentIndex()).toString());
  6654. settings.setValue("database/hostname",hostname->text());
  6655. settings.setValue("database/dbname",dbname->text());
  6656. settings.setValue("database/user",user->text());
  6657. settings.setValue("database/password",password->text());
  6658. accept();
  6659. }
  6660. else
  6661. {
  6662. QMessageBox::information(this,tr("Database connection failed"),
  6663. tr("Failed to connect to database."));
  6664. }
  6665. }
  6666. /*:566*/
  6667. #line 798 "./typica.w"
  6668. /*570:*/
  6669. #line 12641 "./typica.w"
  6670. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  6671. {
  6672. setModel(new QSqlQueryModel);
  6673. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  6674. this,SLOT(openRow(QModelIndex)));
  6675. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  6676. this,SLOT(persistColumnResize(int,int,int)));
  6677. }
  6678. /*:570*//*571:*/
  6679. #line 12656 "./typica.w"
  6680. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  6681. {
  6682. /*572:*/
  6683. #line 12665 "./typica.w"
  6684. QSettings settings;
  6685. /*573:*/
  6686. #line 12678 "./typica.w"
  6687. QWidget*topLevelWidget= this;
  6688. while(topLevelWidget->parentWidget())
  6689. {
  6690. topLevelWidget= topLevelWidget->parentWidget();
  6691. }
  6692. /*:573*/
  6693. #line 12667 "./typica.w"
  6694. settings.setValue(QString("columnWidths/%1/%2/%3").
  6695. arg(topLevelWidget->objectName()).
  6696. arg(objectName()).arg(column),
  6697. QVariant(newsize));
  6698. /*:572*/
  6699. #line 12659 "./typica.w"
  6700. }
  6701. /*:571*//*574:*/
  6702. #line 12688 "./typica.w"
  6703. void SqlQueryView::showEvent(QShowEvent*event)
  6704. {
  6705. /*575:*/
  6706. #line 12698 "./typica.w"
  6707. QSettings settings;
  6708. /*573:*/
  6709. #line 12678 "./typica.w"
  6710. QWidget*topLevelWidget= this;
  6711. while(topLevelWidget->parentWidget())
  6712. {
  6713. topLevelWidget= topLevelWidget->parentWidget();
  6714. }
  6715. /*:573*/
  6716. #line 12700 "./typica.w"
  6717. QString baseKey=
  6718. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  6719. arg(objectName());
  6720. for(int i= 0;i<model()->columnCount();i++)
  6721. {
  6722. QString key= QString("%1/%2").arg(baseKey).arg(i);
  6723. if(settings.contains(key))
  6724. {
  6725. setColumnWidth(i,settings.value(key).toInt());
  6726. }
  6727. }
  6728. /*:575*/
  6729. #line 12691 "./typica.w"
  6730. event->accept();
  6731. }
  6732. /*:574*//*576:*/
  6733. #line 12715 "./typica.w"
  6734. void SqlQueryView::openRow(const QModelIndex&index)
  6735. {
  6736. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  6737. emit openEntryRow(index.row());
  6738. }
  6739. /*:576*//*577:*/
  6740. #line 12726 "./typica.w"
  6741. void SqlQueryView::setQuery(const QString&query)
  6742. {
  6743. QSqlDatabase database= AppInstance->database();
  6744. database.open();
  6745. QSqlQuery q(query,database);
  6746. ((QSqlQueryModel*)model())->setQuery(q);
  6747. }
  6748. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  6749. const QVariant&value,int role)
  6750. {
  6751. return model()->setHeaderData(section,orientation,value,role);
  6752. }
  6753. /*:577*//*578:*/
  6754. #line 12743 "./typica.w"
  6755. QVariant SqlQueryView::data(int row,int column,int role)
  6756. {
  6757. return model()->data(model()->index(row,column),role);
  6758. }
  6759. /*:578*/
  6760. #line 799 "./typica.w"
  6761. /*144:*/
  6762. #line 3384 "./typica.w"
  6763. SqlQueryConnection::SqlQueryConnection(const QString&query)
  6764. {
  6765. QSqlDatabase database= AppInstance->database();
  6766. database.open();
  6767. q= new QSqlQuery(query,database);
  6768. connection= database.connectionName();
  6769. }
  6770. /*:144*//*145:*/
  6771. #line 3397 "./typica.w"
  6772. SqlQueryConnection::~SqlQueryConnection()
  6773. {
  6774. delete q;
  6775. {
  6776. QSqlDatabase database= QSqlDatabase::database(connection);
  6777. database.close();
  6778. }
  6779. QSqlDatabase::removeDatabase(connection);
  6780. }
  6781. /*:145*//*146:*/
  6782. #line 3411 "./typica.w"
  6783. QSqlQuery*SqlQueryConnection::operator->()
  6784. {
  6785. return q;
  6786. }
  6787. /*:146*/
  6788. #line 800 "./typica.w"
  6789. /*597:*/
  6790. #line 13092 "./typica.w"
  6791. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  6792. area(frame),configuration(description)
  6793. {
  6794. refresh();
  6795. }
  6796. ReportTable::~ReportTable()
  6797. {
  6798. }
  6799. /*:597*//*598:*/
  6800. #line 13108 "./typica.w"
  6801. void ReportTable::bind(QString placeholder,QVariant value)
  6802. {
  6803. bindings.insert(placeholder,value);
  6804. }
  6805. /*:598*//*599:*/
  6806. #line 13118 "./typica.w"
  6807. void ReportTable::refresh()
  6808. {
  6809. /*600:*/
  6810. #line 13139 "./typica.w"
  6811. QTextCursor cursor= area->firstCursorPosition();
  6812. while(cursor<area->lastCursorPosition())
  6813. {
  6814. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  6815. }
  6816. cursor.removeSelectedText();
  6817. /*:600*/
  6818. #line 13121 "./typica.w"
  6819. int rows= 1;
  6820. int columns= 1;
  6821. int currentRow= 0;
  6822. QTextTable*table= cursor.insertTable(rows,columns);
  6823. /*601:*/
  6824. #line 13152 "./typica.w"
  6825. QTextTableFormat format= table->format();
  6826. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  6827. if(configuration.hasAttribute("align"))
  6828. {
  6829. if(configuration.attribute("align")=="center")
  6830. {
  6831. format.setAlignment(Qt::AlignHCenter);
  6832. }
  6833. }
  6834. table->setFormat(format);
  6835. /*:601*/
  6836. #line 13126 "./typica.w"
  6837. /*602:*/
  6838. #line 13166 "./typica.w"
  6839. QDomNodeList children= configuration.childNodes();
  6840. for(int i= 0;i<children.count();i++)
  6841. {
  6842. QDomNode current;
  6843. QDomElement currentElement;
  6844. current= children.at(i);
  6845. if(current.isElement())
  6846. {
  6847. currentElement= current.toElement();
  6848. if(currentElement.tagName()=="query")
  6849. {
  6850. /*603:*/
  6851. #line 13193 "./typica.w"
  6852. SqlQueryConnection query;
  6853. query.prepare(currentElement.text());
  6854. foreach(QString key,bindings.uniqueKeys())
  6855. {
  6856. if(currentElement.text().contains(key))
  6857. {
  6858. query.bindValue(key,bindings.value(key));
  6859. }
  6860. }
  6861. query.exec();
  6862. if(!query.next())
  6863. {
  6864. continue;
  6865. }
  6866. if(query.record().count()> columns)
  6867. {
  6868. table->appendColumns(query.record().count()-columns);
  6869. }
  6870. do
  6871. {
  6872. table->appendRows(1);
  6873. rows++;
  6874. currentRow++;
  6875. for(int j= 0;j<query.record().count();j++)
  6876. {
  6877. QTextTableCell cell= table->cellAt(currentRow,j);
  6878. cursor= cell.firstCursorPosition();
  6879. cursor.insertText(query.value(j).toString());
  6880. }
  6881. }while(query.next());
  6882. /*:603*/
  6883. #line 13178 "./typica.w"
  6884. }
  6885. else if(currentElement.tagName()=="row")
  6886. {
  6887. /*604:*/
  6888. #line 13232 "./typica.w"
  6889. table->appendRows(1);
  6890. currentRow++;
  6891. rows++;
  6892. QDomNodeList rowChildren= currentElement.childNodes();
  6893. int currentColumn= 0;
  6894. for(int j= 0;j<rowChildren.count();j++)
  6895. {
  6896. QDomNode node;
  6897. QDomElement nodeElement;
  6898. node= rowChildren.at(j);
  6899. if(node.isElement())
  6900. {
  6901. nodeElement= node.toElement();
  6902. if(nodeElement.tagName()=="cell")
  6903. {
  6904. if(currentColumn==columns)
  6905. {
  6906. table->appendColumns(1);
  6907. columns++;
  6908. }
  6909. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  6910. cursor= cell.firstCursorPosition();
  6911. cursor.insertText(nodeElement.text());
  6912. currentColumn++;
  6913. }
  6914. }
  6915. }
  6916. /*:604*/
  6917. #line 13182 "./typica.w"
  6918. }
  6919. }
  6920. }
  6921. /*:602*/
  6922. #line 13127 "./typica.w"
  6923. if(rows> 1)
  6924. {
  6925. table->removeRows(0,1);
  6926. }
  6927. }
  6928. /*:599*/
  6929. #line 801 "./typica.w"
  6930. /*609:*/
  6931. #line 13334 "./typica.w"
  6932. FormArray::FormArray(QDomElement description):configuration(description),
  6933. maxwidth(-1),maxheight(-1)
  6934. {
  6935. setWidget(&itemContainer);
  6936. itemContainer.setLayout(&itemLayout);
  6937. }
  6938. /*:609*//*610:*/
  6939. #line 13351 "./typica.w"
  6940. void FormArray::addElements(int copies)
  6941. {
  6942. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  6943. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  6944. QWidget*widget;
  6945. for(int i= 0;i<copies;i++)
  6946. {
  6947. widget= new QWidget;
  6948. if(maxwidth> -1)
  6949. {
  6950. widget->setMaximumWidth(maxwidth);
  6951. }
  6952. if(maxheight> -1)
  6953. {
  6954. widget->setMaximumHeight(maxheight);
  6955. }
  6956. if(configuration.hasChildNodes())
  6957. {
  6958. widgetStack->push(widget);
  6959. populateWidget(configuration,widgetStack,layoutStack);
  6960. widgetStack->pop();
  6961. widget->setMinimumHeight(widget->sizeHint().height());
  6962. itemLayout.addWidget(widget);
  6963. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  6964. {
  6965. itemContainer.setMinimumHeight(maxheight*elements()+50);
  6966. }
  6967. else
  6968. {
  6969. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  6970. +widget->sizeHint().height());
  6971. }
  6972. if(maxwidth> -1)
  6973. {
  6974. itemContainer.setMinimumWidth(maxwidth+50);
  6975. }
  6976. else
  6977. {
  6978. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  6979. }
  6980. }
  6981. }
  6982. }
  6983. /*:610*//*611:*/
  6984. #line 13401 "./typica.w"
  6985. QWidget*FormArray::elementAt(int index)
  6986. {
  6987. if(index<itemLayout.count())
  6988. {
  6989. QLayoutItem*item= itemLayout.itemAt(index);
  6990. return item->widget();
  6991. }
  6992. else
  6993. {
  6994. return NULL;
  6995. }
  6996. }
  6997. /*:611*//*612:*/
  6998. #line 13418 "./typica.w"
  6999. void FormArray::removeAllElements()
  7000. {
  7001. while(itemLayout.count()> 0)
  7002. {
  7003. QLayoutItem*item;
  7004. item= itemLayout.itemAt(0);
  7005. item->widget()->hide();
  7006. itemLayout.removeWidget(item->widget());
  7007. }
  7008. itemContainer.setMinimumHeight(0);
  7009. }
  7010. /*:612*//*613:*/
  7011. #line 13434 "./typica.w"
  7012. int FormArray::elements()
  7013. {
  7014. return itemLayout.count();
  7015. }
  7016. /*:613*//*614:*/
  7017. #line 13445 "./typica.w"
  7018. void FormArray::setMaximumElementWidth(int width)
  7019. {
  7020. maxwidth= width;
  7021. }
  7022. void FormArray::setMaximumElementHeight(int height)
  7023. {
  7024. maxheight= height;
  7025. }
  7026. /*:614*/
  7027. #line 802 "./typica.w"
  7028. /*620:*/
  7029. #line 13576 "./typica.w"
  7030. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7031. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7032. {
  7033. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7034. QPointF(0,5);
  7035. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7036. QPointF(10,5);
  7037. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7038. QPointF(0,0);
  7039. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7040. initialBrush.setColor(QColor(170,170,255));
  7041. initialBrush.setStyle(Qt::SolidPattern);
  7042. finalBrush.setColor(Qt::blue);
  7043. finalBrush.setStyle(Qt::SolidPattern);
  7044. initialDecrement.setPolygon(left);
  7045. initialDecrement.setBrush(initialBrush);
  7046. initialDecrement.setPos(0,0);
  7047. scene.addItem(&initialDecrement);
  7048. initialIncrement.setPolygon(right);
  7049. initialIncrement.setBrush(initialBrush);
  7050. initialIncrement.setPos(122,0);
  7051. scene.addItem(&initialIncrement);
  7052. finalDecrement.setPolygon(left);
  7053. finalDecrement.setBrush(finalBrush);
  7054. finalDecrement.setPos(0,12);
  7055. scene.addItem(&finalDecrement);
  7056. finalIncrement.setPolygon(right);
  7057. finalIncrement.setBrush(finalBrush);
  7058. finalIncrement.setPos(122,12);
  7059. scene.addItem(&finalIncrement);
  7060. scalePath.moveTo(0,10);
  7061. scalePath.lineTo(100,10);
  7062. scalePath.moveTo(0,0);
  7063. scalePath.lineTo(0,20);
  7064. scalePath.moveTo(10,5);
  7065. scalePath.lineTo(10,15);
  7066. scalePath.moveTo(20,5);
  7067. scalePath.lineTo(20,15);
  7068. scalePath.moveTo(30,5);
  7069. scalePath.lineTo(30,15);
  7070. scalePath.moveTo(40,5);
  7071. scalePath.lineTo(40,15);
  7072. scalePath.moveTo(50,0);
  7073. scalePath.lineTo(50,20);
  7074. scalePath.moveTo(60,5);
  7075. scalePath.lineTo(60,15);
  7076. scalePath.moveTo(70,5);
  7077. scalePath.lineTo(70,15);
  7078. scalePath.moveTo(80,5);
  7079. scalePath.lineTo(80,15);
  7080. scalePath.moveTo(90,5);
  7081. scalePath.lineTo(90,15);
  7082. scalePath.moveTo(100,0);
  7083. scalePath.lineTo(100,20);
  7084. scaleLine.setPath(scalePath);
  7085. scaleLine.setPos(16,1);
  7086. scene.addItem(&scaleLine);
  7087. setScene(&scene);
  7088. initialIndicator.setPolygon(down);
  7089. initialIndicator.setBrush(initialBrush);
  7090. finalIndicator.setPolygon(up);
  7091. finalIndicator.setBrush(finalBrush);
  7092. setMinimumSize(sizeHint());
  7093. setMaximumSize(sizeHint());
  7094. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7095. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7096. setMinimumSize(sizeHint());
  7097. }
  7098. /*:620*//*621:*/
  7099. #line 13649 "./typica.w"
  7100. QSize ScaleControl::sizeHint()const
  7101. {
  7102. return QSize(140,30);
  7103. }
  7104. /*:621*//*622:*/
  7105. #line 13658 "./typica.w"
  7106. void ScaleControl::setInitialValue(double value)
  7107. {
  7108. if(value>=0&&value<=10)
  7109. {
  7110. nonScoredValue= value;
  7111. if(!initialSet)
  7112. {
  7113. scene.addItem(&initialIndicator);
  7114. }
  7115. initialSet= true;
  7116. initialIndicator.setPos(value*10+16,10);
  7117. emit initialChanged(value);
  7118. if(!finalSet)
  7119. {
  7120. setFinalValue(value);
  7121. }
  7122. }
  7123. }
  7124. void ScaleControl::setFinalValue(double value)
  7125. {
  7126. if(value>=0&&value<=10)
  7127. {
  7128. scoredValue= value;
  7129. if(!finalSet)
  7130. {
  7131. scene.addItem(&finalIndicator);
  7132. }
  7133. finalSet= true;
  7134. finalIndicator.setPos(value*10+16,11);
  7135. emit finalChanged(value);
  7136. }
  7137. }
  7138. /*:622*//*623:*/
  7139. #line 13695 "./typica.w"
  7140. double ScaleControl::initialValue(void)
  7141. {
  7142. return nonScoredValue;
  7143. }
  7144. double ScaleControl::finalValue(void)
  7145. {
  7146. return scoredValue;
  7147. }
  7148. /*:623*//*624:*/
  7149. #line 13716 "./typica.w"
  7150. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7151. {
  7152. /*625:*/
  7153. #line 13728 "./typica.w"
  7154. if(event->button()!=Qt::LeftButton)
  7155. {
  7156. event->ignore();
  7157. return;
  7158. }
  7159. /*:625*/
  7160. #line 13719 "./typica.w"
  7161. scaleDown= true;
  7162. event->accept();
  7163. }
  7164. /*:624*//*626:*/
  7165. #line 13739 "./typica.w"
  7166. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7167. {
  7168. /*625:*/
  7169. #line 13728 "./typica.w"
  7170. if(event->button()!=Qt::LeftButton)
  7171. {
  7172. event->ignore();
  7173. return;
  7174. }
  7175. /*:625*/
  7176. #line 13742 "./typica.w"
  7177. if(!scaleDown)
  7178. {
  7179. event->ignore();
  7180. return;
  7181. }
  7182. scaleDown= false;
  7183. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7184. /*627:*/
  7185. #line 13764 "./typica.w"
  7186. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7187. {
  7188. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7189. {
  7190. if(initialSet)
  7191. {
  7192. setInitialValue(nonScoredValue-0.05);
  7193. }
  7194. event->accept();
  7195. return;
  7196. }
  7197. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7198. {
  7199. if(finalSet)
  7200. {
  7201. setFinalValue(scoredValue-0.05);
  7202. event->accept();
  7203. return;
  7204. }
  7205. }
  7206. }
  7207. /*:627*/
  7208. #line 13750 "./typica.w"
  7209. /*628:*/
  7210. #line 13790 "./typica.w"
  7211. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7212. {
  7213. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7214. {
  7215. if(initialSet)
  7216. {
  7217. setInitialValue(nonScoredValue+0.05);
  7218. event->accept();
  7219. return;
  7220. }
  7221. }
  7222. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7223. {
  7224. if(finalSet)
  7225. {
  7226. setFinalValue(scoredValue+0.05);
  7227. event->accept();
  7228. return;
  7229. }
  7230. }
  7231. }
  7232. /*:628*/
  7233. #line 13751 "./typica.w"
  7234. /*629:*/
  7235. #line 13816 "./typica.w"
  7236. double relativeX= sceneCoordinate.x()-16;
  7237. if(initialSet)
  7238. {
  7239. if(relativeX>=0&&relativeX<=100)
  7240. {
  7241. setFinalValue(relativeX/10.0);
  7242. event->accept();
  7243. return;
  7244. }
  7245. }
  7246. else
  7247. {
  7248. if(relativeX>=0&&relativeX<=100)
  7249. {
  7250. setInitialValue(relativeX/10.0);
  7251. event->accept();
  7252. return;
  7253. }
  7254. }
  7255. /*:629*/
  7256. #line 13752 "./typica.w"
  7257. event->ignore();
  7258. return;
  7259. }
  7260. /*:626*/
  7261. #line 803 "./typica.w"
  7262. /*631:*/
  7263. #line 13882 "./typica.w"
  7264. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7265. valueSet(false),scaleDown(false)
  7266. {
  7267. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7268. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7269. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7270. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7271. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7272. theBrush.setColor(Qt::blue);
  7273. theBrush.setStyle(Qt::SolidPattern);
  7274. increment.setPolygon(up);
  7275. increment.setBrush(theBrush);
  7276. increment.setPos(0,0);
  7277. scene.addItem(&increment);
  7278. decrement.setPolygon(down);
  7279. decrement.setBrush(theBrush);
  7280. decrement.setPos(0,122);
  7281. scene.addItem(&decrement);
  7282. scalePath.moveTo(5,0);
  7283. scalePath.lineTo(5,100);
  7284. scalePath.moveTo(0,0);
  7285. scalePath.lineTo(10,0);
  7286. scalePath.moveTo(0,10);
  7287. scalePath.lineTo(10,10);
  7288. scalePath.moveTo(0,20);
  7289. scalePath.lineTo(10,20);
  7290. scalePath.moveTo(0,30);
  7291. scalePath.lineTo(10,30);
  7292. scalePath.moveTo(0,40);
  7293. scalePath.lineTo(10,40);
  7294. scalePath.moveTo(0,50);
  7295. scalePath.lineTo(10,50);
  7296. scalePath.moveTo(0,60);
  7297. scalePath.lineTo(10,60);
  7298. scalePath.moveTo(0,70);
  7299. scalePath.lineTo(10,70);
  7300. scalePath.moveTo(0,80);
  7301. scalePath.lineTo(10,80);
  7302. scalePath.moveTo(0,90);
  7303. scalePath.lineTo(10,90);
  7304. scalePath.moveTo(0,100);
  7305. scalePath.lineTo(10,100);
  7306. scaleLine.setPath(scalePath);
  7307. scaleLine.setPos(0,16);
  7308. scene.addItem(&scaleLine);
  7309. setScene(&scene);
  7310. indicator.setPolygon(left);
  7311. indicator.setBrush(theBrush);
  7312. setMinimumSize(sizeHint());
  7313. setMaximumSize(sizeHint());
  7314. }
  7315. /*:631*//*632:*/
  7316. #line 13937 "./typica.w"
  7317. QSize IntensityControl::sizeHint()const
  7318. {
  7319. return QSize(25,160);
  7320. }
  7321. /*:632*//*633:*/
  7322. #line 13952 "./typica.w"
  7323. void IntensityControl::setValue(double val)
  7324. {
  7325. if(val>=0&&val<=10)
  7326. {
  7327. theValue= val;
  7328. if(!valueSet)
  7329. {
  7330. scene.addItem(&indicator);
  7331. }
  7332. valueSet= true;
  7333. indicator.setPos(6,(100-(val*10))+16);
  7334. emit(valueChanged(val));
  7335. }
  7336. else if(val<1)
  7337. {
  7338. setValue(0);
  7339. }
  7340. else
  7341. {
  7342. setValue(10);
  7343. }
  7344. }
  7345. double IntensityControl::value()
  7346. {
  7347. return theValue;
  7348. }
  7349. /*:633*//*634:*/
  7350. #line 13984 "./typica.w"
  7351. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7352. {
  7353. /*625:*/
  7354. #line 13728 "./typica.w"
  7355. if(event->button()!=Qt::LeftButton)
  7356. {
  7357. event->ignore();
  7358. return;
  7359. }
  7360. /*:625*/
  7361. #line 13987 "./typica.w"
  7362. scaleDown= true;
  7363. event->accept();
  7364. }
  7365. /*:634*//*635:*/
  7366. #line 13998 "./typica.w"
  7367. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7368. {
  7369. /*625:*/
  7370. #line 13728 "./typica.w"
  7371. if(event->button()!=Qt::LeftButton)
  7372. {
  7373. event->ignore();
  7374. return;
  7375. }
  7376. /*:625*/
  7377. #line 14001 "./typica.w"
  7378. if(!scaleDown)
  7379. {
  7380. event->ignore();
  7381. return;
  7382. }
  7383. scaleDown= false;
  7384. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7385. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7386. {
  7387. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7388. {
  7389. if(valueSet)
  7390. {
  7391. setValue(theValue+0.05);
  7392. }
  7393. event->accept();
  7394. return;
  7395. }
  7396. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7397. {
  7398. if(valueSet)
  7399. {
  7400. setValue(theValue-0.05);
  7401. }
  7402. event->accept();
  7403. return;
  7404. }
  7405. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7406. {
  7407. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7408. event->accept();
  7409. return;
  7410. }
  7411. }
  7412. }
  7413. /*:635*/
  7414. #line 804 "./typica.w"
  7415. /*314:*/
  7416. #line 7404 "./typica.w"
  7417. void ThresholdDetector::newMeasurement(Measurement measure)
  7418. {
  7419. if((currentDirection==Ascending&&previousValue<threshold&&
  7420. previousValue>=0)||(currentDirection==Descending&&
  7421. previousValue> threshold&&previousValue>=0))
  7422. {
  7423. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7424. (currentDirection==Descending&&measure.temperature()<=threshold))
  7425. {
  7426. double offset= measure.time().hour()*60*60;
  7427. offset+= measure.time().minute()*60;
  7428. offset+= measure.time().second();
  7429. offset+= measure.time().msec()/1000;
  7430. emit timeForValue(offset);
  7431. }
  7432. }
  7433. previousValue= measure.temperature();
  7434. }
  7435. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7436. previousValue(-1),threshold(value),currentDirection(Ascending)
  7437. {
  7438. }
  7439. void ThresholdDetector::setThreshold(double value)
  7440. {
  7441. threshold= value;
  7442. }
  7443. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7444. {
  7445. currentDirection= direction;
  7446. }
  7447. /*:314*/
  7448. #line 805 "./typica.w"
  7449. /*717:*/
  7450. #line 15819 "./typica.w"
  7451. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  7452. lister(new QextSerialEnumerator)
  7453. {
  7454. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  7455. QextPortInfo port;
  7456. foreach(port,ports)
  7457. {
  7458. #ifdef Q_OS_WIN32
  7459. addItem(port.portName);
  7460. #else
  7461. addItem(port.physName);
  7462. #endif
  7463. }
  7464. lister->setUpNotifications();
  7465. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  7466. this,SLOT(addDevice(QextPortInfo)));
  7467. setEditable(true);
  7468. }
  7469. void PortSelector::addDevice(QextPortInfo port)
  7470. {
  7471. addItem(port.portName);
  7472. }
  7473. /*:717*/
  7474. #line 806 "./typica.w"
  7475. /*719:*/
  7476. #line 15911 "./typica.w"
  7477. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  7478. {
  7479. QMetaObject meta= BaudSelector::staticMetaObject;
  7480. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  7481. for(int i= 0;i<type.keyCount();i++)
  7482. {
  7483. addItem(QString("%1").arg(type.value(i)));
  7484. }
  7485. }
  7486. /*:719*/
  7487. #line 807 "./typica.w"
  7488. /*721:*/
  7489. #line 15949 "./typica.w"
  7490. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  7491. {
  7492. QMetaObject meta= ParitySelector::staticMetaObject;
  7493. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  7494. for(int i= 0;i<type.keyCount();i++)
  7495. {
  7496. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7497. }
  7498. }
  7499. /*:721*/
  7500. #line 808 "./typica.w"
  7501. /*723:*/
  7502. #line 15979 "./typica.w"
  7503. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  7504. {
  7505. QMetaObject meta= FlowSelector::staticMetaObject;
  7506. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  7507. for(int i= 0;i<type.keyCount();i++)
  7508. {
  7509. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7510. }
  7511. }
  7512. /*:723*/
  7513. #line 809 "./typica.w"
  7514. /*725:*/
  7515. #line 16014 "./typica.w"
  7516. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  7517. {
  7518. QMetaObject meta= StopSelector::staticMetaObject;
  7519. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  7520. for(int i= 0;i<type.keyCount();i++)
  7521. {
  7522. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7523. }
  7524. }
  7525. /*:725*/
  7526. #line 810 "./typica.w"
  7527. /*780:*/
  7528. #line 17765 "./typica.w"
  7529. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  7530. :BasicDeviceConfigurationWidget(model,index),
  7531. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  7532. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  7533. decimalQuery(new QCheckBox(tr("Enable"))),
  7534. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  7535. unitQuery(new QCheckBox(tr("Enable"))),
  7536. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  7537. valueC(new QSpinBox),fixedUnit(new QComboBox),
  7538. pVAddress(new ShortHexSpinBox),
  7539. sVEnabled(new QCheckBox(tr("Enable"))),
  7540. sVReadAddress(new ShortHexSpinBox),
  7541. deviceLimit(new QCheckBox(tr("Enable"))),
  7542. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  7543. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  7544. sVWritable(new QCheckBox(tr("Enable"))),
  7545. sVOutputAddr(new ShortHexSpinBox),
  7546. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  7547. {
  7548. QHBoxLayout*layout= new QHBoxLayout;
  7549. QWidget*form= new QWidget;
  7550. QHBoxLayout*masterLayout= new QHBoxLayout;
  7551. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  7552. QVBoxLayout*seriesLayout= new QVBoxLayout;
  7553. QFormLayout*serialSection= new QFormLayout;
  7554. serialSection->addRow(QString(tr("Port:")),port);
  7555. serialSection->addRow(QString(tr("Baud rate:")),baud);
  7556. serialSection->addRow(QString(tr("Parity:")),parity);
  7557. serialSection->addRow(QString(tr("Flow control:")),flow);
  7558. serialSection->addRow(QString(tr("Stop bits:")),stop);
  7559. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  7560. serialSectionBox->setLayout(serialSection);
  7561. portAndDeviceLayout->addWidget(serialSectionBox);
  7562. QFormLayout*deviceSection= new QFormLayout;
  7563. station->setMinimum(1);
  7564. station->setMaximum(255);
  7565. decimalPosition->setMinimum(0);
  7566. decimalPosition->setMaximum(9);
  7567. valueF->setMinimum(0);
  7568. valueF->setMaximum(0xFFFF);
  7569. valueC->setMinimum(0);
  7570. valueC->setMaximum(0xFFFF);
  7571. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  7572. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  7573. deviceSection->addRow(tr("Station:"),station);
  7574. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  7575. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  7576. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  7577. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  7578. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  7579. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  7580. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  7581. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  7582. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  7583. deviceSectionBox->setLayout(deviceSection);
  7584. portAndDeviceLayout->addWidget(deviceSectionBox);
  7585. QFormLayout*pVSection= new QFormLayout;
  7586. pVSection->addRow(tr("Value relative address:"),pVAddress);
  7587. pVSection->addRow(tr("PV column name:"),pVColumnName);
  7588. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  7589. pVSection->addRow(pVHideBox);
  7590. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  7591. processValueBox->setLayout(pVSection);
  7592. seriesLayout->addWidget(processValueBox);
  7593. QFormLayout*sVSection= new QFormLayout;
  7594. sVLower->setDecimals(1);
  7595. sVLower->setMinimum(0.0);
  7596. sVLower->setMaximum(999.9);
  7597. sVUpper->setDecimals(1);
  7598. sVUpper->setMinimum(0.0);
  7599. sVUpper->setMaximum(999.9);
  7600. sVSection->addRow(tr("Set value:"),sVEnabled);
  7601. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  7602. sVSection->addRow(tr("SV column name:"),sVColumnName);
  7603. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  7604. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  7605. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  7606. sVSection->addRow(tr("Lower limit:"),sVLower);
  7607. sVSection->addRow(tr("Upper limit:"),sVUpper);
  7608. sVSection->addRow(tr("Output set value:"),sVWritable);
  7609. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  7610. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  7611. sVSection->addRow(sVHideBox);
  7612. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  7613. setValueBox->setLayout(sVSection);
  7614. seriesLayout->addWidget(setValueBox);
  7615. masterLayout->addLayout(portAndDeviceLayout);
  7616. masterLayout->addLayout(seriesLayout);
  7617. form->setLayout(masterLayout);
  7618. /*693:*/
  7619. #line 15275 "./typica.w"
  7620. QDomElement referenceElement=
  7621. model->referenceElement(model->data(index,Qt::UserRole).toString());
  7622. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  7623. QDomElement node;
  7624. /*:693*/
  7625. #line 17855 "./typica.w"
  7626. for(int i= 0;i<configData.size();i++)
  7627. {
  7628. node= configData.at(i).toElement();
  7629. if(node.attribute("name")=="port")
  7630. {
  7631. QString portname= node.attribute("value");
  7632. int idx= port->findText(portname);
  7633. if(idx>=0)
  7634. {
  7635. port->setCurrentIndex(idx);
  7636. }
  7637. else
  7638. {
  7639. port->addItem(portname);
  7640. }
  7641. }
  7642. else if(node.attribute("name")=="baud")
  7643. {
  7644. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  7645. }
  7646. else if(node.attribute("name")=="parity")
  7647. {
  7648. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  7649. }
  7650. else if(node.attribute("name")=="flow")
  7651. {
  7652. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  7653. }
  7654. else if(node.attribute("name")=="stop")
  7655. {
  7656. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  7657. }
  7658. else if(node.attribute("name")=="station")
  7659. {
  7660. station->setValue(node.attribute("value").toInt());
  7661. }
  7662. else if(node.attribute("name")=="decimalQuery")
  7663. {
  7664. if(node.attribute("value")=="true")
  7665. {
  7666. decimalQuery->setChecked(true);
  7667. }
  7668. else
  7669. {
  7670. decimalQuery->setChecked(false);
  7671. }
  7672. }
  7673. else if(node.attribute("name")=="decimalAddress")
  7674. {
  7675. decimalAddress->setValue(node.attribute("value").toInt());
  7676. }
  7677. else if(node.attribute("name")=="decimalPosition")
  7678. {
  7679. decimalPosition->setValue(node.attribute("value").toInt());
  7680. }
  7681. else if(node.attribute("name")=="unitQuery")
  7682. {
  7683. if(node.attribute("value")=="true")
  7684. {
  7685. unitQuery->setChecked(true);
  7686. }
  7687. else
  7688. {
  7689. unitQuery->setChecked(false);
  7690. }
  7691. }
  7692. else if(node.attribute("name")=="unitAddress")
  7693. {
  7694. unitAddress->setValue(node.attribute("value").toInt());
  7695. }
  7696. else if(node.attribute("name")=="valueF")
  7697. {
  7698. valueF->setValue(node.attribute("value").toInt());
  7699. }
  7700. else if(node.attribute("name")=="valueC")
  7701. {
  7702. valueC->setValue(node.attribute("value").toInt());
  7703. }
  7704. else if(node.attribute("name")=="fixedUnit")
  7705. {
  7706. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  7707. }
  7708. else if(node.attribute("name")=="pVAddress")
  7709. {
  7710. pVAddress->setValue(node.attribute("value").toInt());
  7711. }
  7712. else if(node.attribute("name")=="sVEnabled")
  7713. {
  7714. if(node.attribute("value")=="true")
  7715. {
  7716. sVEnabled->setChecked(true);
  7717. }
  7718. else
  7719. {
  7720. sVEnabled->setChecked(false);
  7721. }
  7722. }
  7723. else if(node.attribute("name")=="sVReadAddress")
  7724. {
  7725. sVReadAddress->setValue(node.attribute("value").toInt());
  7726. }
  7727. else if(node.attribute("name")=="deviceLimit")
  7728. {
  7729. if(node.attribute("value")=="true")
  7730. {
  7731. deviceLimit->setChecked(true);
  7732. }
  7733. else
  7734. {
  7735. deviceLimit->setChecked(false);
  7736. }
  7737. }
  7738. else if(node.attribute("name")=="sVLowerAddr")
  7739. {
  7740. sVLowerAddr->setValue(node.attribute("value").toInt());
  7741. }
  7742. else if(node.attribute("name")=="sVUpperAddr")
  7743. {
  7744. sVUpperAddr->setValue(node.attribute("value").toInt());
  7745. }
  7746. else if(node.attribute("name")=="sVLower")
  7747. {
  7748. sVLower->setValue(node.attribute("value").toDouble());
  7749. }
  7750. else if(node.attribute("name")=="sVUpper")
  7751. {
  7752. sVUpper->setValue(node.attribute("value").toDouble());
  7753. }
  7754. else if(node.attribute("name")=="sVWritable")
  7755. {
  7756. if(node.attribute("value")=="true")
  7757. {
  7758. sVWritable->setChecked(true);
  7759. }
  7760. else
  7761. {
  7762. sVWritable->setChecked(false);
  7763. }
  7764. }
  7765. else if(node.attribute("name")=="sVOutputAddr")
  7766. {
  7767. sVOutputAddr->setValue(node.attribute("value").toInt());
  7768. }
  7769. else if(node.attribute("name")=="pvcolname")
  7770. {
  7771. pVColumnName->setText(node.attribute("value"));
  7772. }
  7773. else if(node.attribute("name")=="svcolname")
  7774. {
  7775. sVColumnName->setText(node.attribute("value"));
  7776. }
  7777. else if(node.attribute("name")=="pvhidden")
  7778. {
  7779. pVHideBox->setChecked(node.attribute("value")=="true");
  7780. }
  7781. else if(node.attribute("name")=="svhidden")
  7782. {
  7783. sVHideBox->setChecked(node.attribute("value")=="true");
  7784. }
  7785. }
  7786. updatePort(port->currentText());
  7787. updateBaudRate(baud->currentText());
  7788. updateParity(parity->itemData(parity->currentIndex()).toString());
  7789. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  7790. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  7791. updateStation(station->value());
  7792. updateFixedDecimal(decimalQuery->isChecked());
  7793. updateDecimalAddress(decimalAddress->value());
  7794. updateDecimalPosition(decimalPosition->value());
  7795. updateFixedUnit(unitQuery->isChecked());
  7796. updateUnitAddress(unitAddress->value());
  7797. updateValueForF(valueF->value());
  7798. updateValueForC(valueC->value());
  7799. updateUnit(fixedUnit->currentText());
  7800. updatePVAddress(pVAddress->value());
  7801. updateSVEnabled(sVEnabled->isChecked());
  7802. updateSVReadAddress(sVReadAddress->value());
  7803. updateDeviceLimit(deviceLimit->isChecked());
  7804. updateSVLowerAddress(sVLowerAddr->value());
  7805. updateSVUpperAddress(sVUpperAddr->value());
  7806. updateSVLower(sVLower->value());
  7807. updateSVUpper(sVUpper->value());
  7808. updateSVWritable(sVWritable->isChecked());
  7809. updateSVWriteAddress(sVOutputAddr->value());
  7810. updatePVColumnName(pVColumnName->text());
  7811. updateSVColumnName(sVColumnName->text());
  7812. updatePVHidden(pVHideBox->isChecked());
  7813. updateSVHidden(sVHideBox->isChecked());
  7814. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  7815. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  7816. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  7817. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  7818. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  7819. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  7820. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  7821. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  7822. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  7823. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  7824. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  7825. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  7826. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  7827. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  7828. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  7829. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  7830. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  7831. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  7832. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  7833. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  7834. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  7835. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  7836. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  7837. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  7838. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  7839. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  7840. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  7841. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  7842. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  7843. layout->addWidget(form);
  7844. setLayout(layout);
  7845. }
  7846. void ModbusConfigurator::updatePort(const QString&newPort)
  7847. {
  7848. updateAttribute("port",newPort);
  7849. }
  7850. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  7851. {
  7852. updateAttribute("baud",newRate);
  7853. }
  7854. void ModbusConfigurator::updateParity(const QString&)
  7855. {
  7856. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  7857. }
  7858. void ModbusConfigurator::updateFlowControl(const QString&)
  7859. {
  7860. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  7861. }
  7862. void ModbusConfigurator::updateStopBits(const QString&)
  7863. {
  7864. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  7865. }
  7866. void ModbusConfigurator::updateStation(int station)
  7867. {
  7868. updateAttribute("station",QString("%1").arg(station));
  7869. }
  7870. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  7871. {
  7872. updateAttribute("decimalQuery",fixed?"true":"false");
  7873. }
  7874. void ModbusConfigurator::updateDecimalAddress(int address)
  7875. {
  7876. updateAttribute("decimalAddress",QString("%1").arg(address));
  7877. }
  7878. void ModbusConfigurator::updateDecimalPosition(int position)
  7879. {
  7880. updateAttribute("decimalPosition",QString("%1").arg(position));
  7881. }
  7882. void ModbusConfigurator::updateFixedUnit(bool fixed)
  7883. {
  7884. updateAttribute("unitQuery",fixed?"true":"false");
  7885. }
  7886. void ModbusConfigurator::updateUnitAddress(int address)
  7887. {
  7888. updateAttribute("unitAddress",QString("%1").arg(address));
  7889. }
  7890. void ModbusConfigurator::updateValueForF(int value)
  7891. {
  7892. updateAttribute("valueF",QString("%1").arg(value));
  7893. }
  7894. void ModbusConfigurator::updateValueForC(int value)
  7895. {
  7896. updateAttribute("valueC",QString("%1").arg(value));
  7897. }
  7898. void ModbusConfigurator::updateUnit(const QString&newUnit)
  7899. {
  7900. updateAttribute("fixedUnit",newUnit);
  7901. }
  7902. void ModbusConfigurator::updatePVAddress(int address)
  7903. {
  7904. updateAttribute("pVAddress",QString("%1").arg(address));
  7905. }
  7906. void ModbusConfigurator::updateSVEnabled(bool enabled)
  7907. {
  7908. updateAttribute("sVEnabled",enabled?"true":"false");
  7909. }
  7910. void ModbusConfigurator::updateSVReadAddress(int address)
  7911. {
  7912. updateAttribute("sVReadAddress",QString("%1").arg(address));
  7913. }
  7914. void ModbusConfigurator::updateDeviceLimit(bool query)
  7915. {
  7916. updateAttribute("deviceLimit",query?"true":"false");
  7917. }
  7918. void ModbusConfigurator::updateSVLowerAddress(int address)
  7919. {
  7920. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  7921. }
  7922. void ModbusConfigurator::updateSVUpperAddress(int address)
  7923. {
  7924. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  7925. }
  7926. void ModbusConfigurator::updateSVLower(double value)
  7927. {
  7928. updateAttribute("sVLower",QString("%1").arg(value));
  7929. }
  7930. void ModbusConfigurator::updateSVUpper(double value)
  7931. {
  7932. updateAttribute("sVUpper",QString("%1").arg(value));
  7933. }
  7934. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  7935. {
  7936. updateAttribute("sVWritable",canWriteSV?"true":"false");
  7937. }
  7938. void ModbusConfigurator::updateSVWriteAddress(int address)
  7939. {
  7940. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  7941. }
  7942. void ModbusConfigurator::updatePVColumnName(const QString&name)
  7943. {
  7944. updateAttribute("pvcolname",name);
  7945. }
  7946. void ModbusConfigurator::updateSVColumnName(const QString&name)
  7947. {
  7948. updateAttribute("svcolname",name);
  7949. }
  7950. void ModbusConfigurator::updatePVHidden(bool hidden)
  7951. {
  7952. updateAttribute("pvhidden",hidden?"true":"false");
  7953. }
  7954. void ModbusConfigurator::updateSVHidden(bool hidden)
  7955. {
  7956. updateAttribute("svhidden",hidden?"true":"false");
  7957. }
  7958. /*:780*/
  7959. #line 811 "./typica.w"
  7960. /*728:*/
  7961. #line 16063 "./typica.w"
  7962. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  7963. {
  7964. setMinimum(0);
  7965. setMaximum(0xFFFF);
  7966. setPrefix("0x");
  7967. setMinimumWidth(65);
  7968. }
  7969. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  7970. {
  7971. if(input.size()==2)
  7972. {
  7973. return QValidator::Intermediate;
  7974. }
  7975. bool okay;
  7976. input.toInt(&okay,16);
  7977. if(okay)
  7978. {
  7979. return QValidator::Acceptable;
  7980. }
  7981. return QValidator::Invalid;
  7982. }
  7983. int ShortHexSpinBox::valueFromText(const QString&text)const
  7984. {
  7985. return text.toInt(NULL,16);
  7986. }
  7987. QString ShortHexSpinBox::textFromValue(int value)const
  7988. {
  7989. QString retval;
  7990. retval.setNum(value,16);
  7991. while(retval.size()<4)
  7992. {
  7993. retval.prepend("0");
  7994. }
  7995. return retval.toUpper();
  7996. }
  7997. /*:728*/
  7998. #line 812 "./typica.w"
  7999. /*765:*/
  8000. #line 17093 "./typica.w"
  8001. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8002. :QObject(NULL),messageDelayTimer(new QTimer),unitIsF(true),readingsv(false),
  8003. waiting(false)
  8004. {
  8005. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8006. Qt::UserRole).toString());
  8007. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8008. QDomElement node;
  8009. QVariantMap attributes;
  8010. for(int i= 0;i<portConfigData.size();i++)
  8011. {
  8012. node= portConfigData.at(i).toElement();
  8013. attributes.insert(node.attribute("name"),node.attribute("value"));
  8014. }
  8015. port= new QextSerialPort(attributes.value("port").toString(),
  8016. QextSerialPort::EventDriven);
  8017. int baudRate= attributes.value("baud").toInt();
  8018. port->setBaudRate((BaudRateType)baudRate);
  8019. double temp= ((double)(1)/(double)(baudRate))*48;
  8020. delayTime= (int)(temp*3000);
  8021. messageDelayTimer->setSingleShot(true);
  8022. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8023. port->setDataBits(DATA_8);
  8024. port->setParity((ParityType)attributes.value("parity").toInt());
  8025. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8026. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8027. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8028. port->open(QIODevice::ReadWrite);
  8029. station= (char)attributes.value("station").toInt();
  8030. if(attributes.value("decimalQuery")=="true")
  8031. {
  8032. decimalPosition= 0;
  8033. QByteArray message;
  8034. message.append(station);
  8035. message.append((char)0x03);
  8036. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8037. char*addressBytes= (char*)&address;
  8038. message.append(addressBytes[1]);
  8039. message.append(addressBytes[0]);
  8040. message.append((char)0x00);
  8041. message.append((char)0x01);
  8042. queueMessage(message,this,"decimalResponse(QByteArray)");
  8043. }
  8044. else
  8045. {
  8046. decimalPosition= attributes.value("decimalPosition").toInt();
  8047. }
  8048. valueF= attributes.value("valueF").toInt();
  8049. valueC= attributes.value("valueC").toInt();
  8050. if(attributes.value("unitQuery")=="true")
  8051. {
  8052. QByteArray message;
  8053. message.append(station);
  8054. message.append((char)0x03);
  8055. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8056. char*addressBytes= (char*)&address;
  8057. message.append(addressBytes[1]);
  8058. message.append(addressBytes[0]);
  8059. message.append((char)0x00);
  8060. message.append((char)0x01);
  8061. queueMessage(message,this,"unitResponse(QByteArray)");
  8062. }
  8063. else
  8064. {
  8065. if(attributes.value("fixedUnit")=="Celsius")
  8066. {
  8067. unitIsF= false;
  8068. }
  8069. }
  8070. if(attributes.value("sVWritable")=="true")
  8071. {
  8072. if(attributes.value("deviceLimit")=="true")
  8073. {
  8074. QByteArray lmessage;
  8075. lmessage.append(station);
  8076. lmessage.append((char)0x03);
  8077. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8078. char*addressBytes= (char*)&laddress;
  8079. lmessage.append(addressBytes[1]);
  8080. lmessage.append(addressBytes[0]);
  8081. lmessage.append((char)0x00);
  8082. lmessage.append((char)0x01);
  8083. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8084. QByteArray umessage;
  8085. umessage.append(station);
  8086. umessage.append((char)0x03);
  8087. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8088. addressBytes= (char*)&uaddress;
  8089. umessage.append(addressBytes[1]);
  8090. umessage.append(addressBytes[0]);
  8091. umessage.append((char)0x00);
  8092. umessage.append((char)0x01);
  8093. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8094. }
  8095. else
  8096. {
  8097. outputSVLower= attributes.value("sVLower").toDouble();
  8098. outputSVUpper= attributes.value("sVUpper").toDouble();
  8099. }
  8100. outputSVStub.append(station);
  8101. outputSVStub.append((char)0x06);
  8102. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8103. char*addressBytes= (char*)&address;
  8104. outputSVStub.append(addressBytes[1]);
  8105. outputSVStub.append(addressBytes[0]);
  8106. }
  8107. Channel*pv= new Channel;
  8108. channels.append(pv);
  8109. pvStub.append(station);
  8110. pvStub.append((char)0x04);
  8111. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8112. char*pvac= (char*)&pvaddress;
  8113. pvStub.append(pvac[1]);
  8114. pvStub.append(pvac[0]);
  8115. pvStub.append((char)0x00);
  8116. pvStub.append((char)0x01);
  8117. svenabled= attributes.value("sVEnabled").toBool();
  8118. if(svenabled)
  8119. {
  8120. Channel*sv= new Channel;
  8121. channels.append(sv);
  8122. svStub.append(station);
  8123. svStub.append((char)0x04);
  8124. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8125. char*svac= (char*)&svaddress;
  8126. svStub.append(svac[1]);
  8127. svStub.append(svac[0]);
  8128. svStub.append((char)0x00);
  8129. svStub.append((char)0x01);
  8130. if(svaddress-pvaddress==1)
  8131. {
  8132. mStub.append(station);
  8133. mStub.append((char)0x04);
  8134. mStub.append(pvac[1]);
  8135. mStub.append(pvac[0]);
  8136. mStub.append((char)0x00);
  8137. mStub.append((char)0x02);
  8138. }
  8139. }
  8140. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8141. requestMeasurement();
  8142. }
  8143. double ModbusRTUDevice::SVLower()
  8144. {
  8145. return outputSVLower;
  8146. }
  8147. double ModbusRTUDevice::SVUpper()
  8148. {
  8149. return outputSVUpper;
  8150. }
  8151. int ModbusRTUDevice::decimals()
  8152. {
  8153. return decimalPosition;
  8154. }
  8155. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8156. {
  8157. quint16 temp;
  8158. char*tchar= (char*)&temp;
  8159. tchar[1]= response.at(3);
  8160. tchar[0]= response.at(4);
  8161. decimalPosition= temp;
  8162. emit SVDecimalChanged(decimalPosition);
  8163. qDebug()<<"Received decimal response";
  8164. }
  8165. void ModbusRTUDevice::unitResponse(QByteArray response)
  8166. {
  8167. quint16 temp;
  8168. char*tchar= (char*)&temp;
  8169. tchar[1]= response.at(3);
  8170. tchar[0]= response.at(4);
  8171. int value= temp;
  8172. if(value==valueF)
  8173. {
  8174. unitIsF= true;
  8175. }
  8176. else
  8177. {
  8178. unitIsF= false;
  8179. }
  8180. }
  8181. void ModbusRTUDevice::svlResponse(QByteArray response)
  8182. {
  8183. quint16 temp;
  8184. char*tchar= (char*)&temp;
  8185. tchar[1]= response.at(3);
  8186. tchar[0]= response.at(4);
  8187. outputSVLower= (double)temp;
  8188. for(int i= 0;i<decimalPosition;i++)
  8189. {
  8190. outputSVLower/= 10;
  8191. }
  8192. emit SVLowerChanged(outputSVLower);
  8193. }
  8194. void ModbusRTUDevice::svuResponse(QByteArray response)
  8195. {
  8196. quint16 temp;
  8197. char*tchar= (char*)&temp;
  8198. tchar[1]= response.at(3);
  8199. tchar[0]= response.at(4);
  8200. outputSVUpper= (double)temp;
  8201. for(int i= 0;i<decimalPosition;i++)
  8202. {
  8203. outputSVUpper/= 10;
  8204. }
  8205. emit SVUpperChanged(outputSVUpper);
  8206. }
  8207. void ModbusRTUDevice::requestMeasurement()
  8208. {
  8209. if(mStub.length()> 0)
  8210. {
  8211. queueMessage(mStub,this,"mResponse(QByteArray)");
  8212. }
  8213. else
  8214. {
  8215. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8216. if(svenabled)
  8217. {
  8218. queueMessage(svStub,this,"mResponse(QByteArray)");
  8219. }
  8220. }
  8221. }
  8222. void ModbusRTUDevice::mResponse(QByteArray response)
  8223. {
  8224. QTime time= QTime::currentTime();
  8225. if(response.at(2)==0x04)
  8226. {
  8227. /*766:*/
  8228. #line 17342 "./typica.w"
  8229. quint16 pv;
  8230. quint16 sv;
  8231. char*pvBytes= (char*)&pv;
  8232. char*svBytes= (char*)&sv;
  8233. pvBytes[1]= response.at(3);
  8234. pvBytes[0]= response.at(4);
  8235. svBytes[1]= response.at(5);
  8236. svBytes[0]= response.at(6);
  8237. double pvOut= (double)pv;
  8238. double svOut= (double)sv;
  8239. for(int i= 0;i<decimalPosition;i++)
  8240. {
  8241. pvOut/= 10;
  8242. svOut/= 10;
  8243. }
  8244. if(!unitIsF)
  8245. {
  8246. pvOut= pvOut*9/5+32;
  8247. svOut= svOut*9/5+32;
  8248. }
  8249. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8250. Measurement svm(svOut,time,Units::Fahrenheit);
  8251. channels.at(0)->input(pvm);
  8252. channels.at(1)->input(svm);
  8253. /*:766*/
  8254. #line 17329 "./typica.w"
  8255. }
  8256. else
  8257. {
  8258. /*767:*/
  8259. #line 17372 "./typica.w"
  8260. quint16 value;
  8261. char*valueBytes= (char*)&value;
  8262. valueBytes[1]= response.at(3);
  8263. valueBytes[0]= response.at(4);
  8264. double valueOut= (double)value;
  8265. for(int i= 0;i<decimalPosition;i++)
  8266. {
  8267. valueOut/= 10;
  8268. }
  8269. if(!unitIsF)
  8270. {
  8271. valueOut= valueOut*9/5+32;
  8272. }
  8273. if(!svenabled)
  8274. {
  8275. Measurement vm(valueOut,time,Units::Fahrenheit);
  8276. channels.at(0)->input(vm);
  8277. }
  8278. else
  8279. {
  8280. if(readingsv)
  8281. {
  8282. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8283. Measurement svm(valueOut,time,Units::Fahrenheit);
  8284. channels.at(0)->input(pvm);
  8285. channels.at(1)->input(svm);
  8286. readingsv= false;
  8287. }
  8288. else
  8289. {
  8290. savedpv= valueOut;
  8291. readingsv= true;
  8292. }
  8293. }
  8294. /*:767*/
  8295. #line 17333 "./typica.w"
  8296. }
  8297. }
  8298. /*:765*//*768:*/
  8299. #line 17410 "./typica.w"
  8300. ModbusRTUDevice::~ModbusRTUDevice()
  8301. {
  8302. messageDelayTimer->stop();
  8303. port->close();
  8304. }
  8305. /*:768*//*769:*/
  8306. #line 17432 "./typica.w"
  8307. void ModbusRTUDevice::dataAvailable()
  8308. {
  8309. if(messageDelayTimer->isActive())
  8310. {
  8311. messageDelayTimer->stop();
  8312. }
  8313. responseBuffer.append(port->readAll());
  8314. /*770:*/
  8315. #line 17477 "./typica.w"
  8316. if(responseBuffer.size()<5)
  8317. {
  8318. return;
  8319. }
  8320. switch(responseBuffer.at(1))
  8321. {
  8322. case 0x01:
  8323. case 0x02:
  8324. if(responseBuffer.size()<6)
  8325. {
  8326. return;
  8327. }
  8328. responseBuffer= responseBuffer.left(6);
  8329. break;
  8330. case 0x03:
  8331. case 0x04:
  8332. if(responseBuffer.size()<5+responseBuffer.at(2))
  8333. {
  8334. return;
  8335. }
  8336. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8337. break;
  8338. case 0x05:
  8339. case 0x06:
  8340. case 0x10:
  8341. if(responseBuffer.size()<8)
  8342. {
  8343. return;
  8344. }
  8345. responseBuffer= responseBuffer.left(8);
  8346. break;
  8347. }
  8348. /*:770*/
  8349. #line 17440 "./typica.w"
  8350. if(calculateCRC(responseBuffer)==0)
  8351. {
  8352. QObject*object= retObjQueue.at(0);
  8353. char*method= callbackQueue.at(0);
  8354. QMetaMethod metamethod= object->metaObject()->
  8355. method(object->metaObject()->
  8356. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8357. metamethod.invoke(object,Qt::QueuedConnection,
  8358. Q_ARG(QByteArray,responseBuffer));
  8359. messageQueue.removeAt(0);
  8360. retObjQueue.removeAt(0);
  8361. callbackQueue.removeAt(0);
  8362. messageDelayTimer->start(delayTime);
  8363. }
  8364. else
  8365. {
  8366. qDebug()<<"CRC failed";
  8367. }
  8368. waiting= false;
  8369. responseBuffer.clear();
  8370. }
  8371. /*:769*//*771:*/
  8372. #line 17519 "./typica.w"
  8373. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8374. {
  8375. quint16 retval= 0xFFFF;
  8376. int i= 0;
  8377. while(i<data.size())
  8378. {
  8379. retval^= 0x00FF&(quint16)data.at(i);
  8380. for(int j= 0;j<8;j++)
  8381. {
  8382. if(retval&1)
  8383. {
  8384. retval= (retval>>1)^0xA001;
  8385. }
  8386. else
  8387. {
  8388. retval>>= 1;
  8389. }
  8390. }
  8391. i++;
  8392. }
  8393. return retval;
  8394. }
  8395. /*:771*//*772:*/
  8396. #line 17550 "./typica.w"
  8397. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8398. const char*callback)
  8399. {
  8400. messageQueue.append(request);
  8401. retObjQueue.append(object);
  8402. callbackQueue.append(const_cast<char*> (callback));
  8403. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8404. {
  8405. sendNextMessage();
  8406. }
  8407. }
  8408. void ModbusRTUDevice::sendNextMessage()
  8409. {
  8410. if(messageQueue.size()> 0&&!waiting)
  8411. {
  8412. QByteArray message= messageQueue.at(0);
  8413. quint16 crc= calculateCRC(message);
  8414. char*check= (char*)&crc;
  8415. message.append(check[0]);
  8416. message.append(check[1]);
  8417. port->write(message);
  8418. messageDelayTimer->start(delayTime);
  8419. waiting= true;
  8420. }
  8421. else
  8422. {
  8423. emit queueEmpty();
  8424. }
  8425. }
  8426. void ModbusRTUDevice::outputSV(double value)
  8427. {
  8428. for(int i= 0;i<decimalPosition;i++)
  8429. {
  8430. value*= 10;
  8431. }
  8432. quint16 outval= (quint16)value;
  8433. QByteArray message(outputSVStub);
  8434. char*valBytes= (char*)&outval;
  8435. message.append(valBytes[1]);
  8436. message.append(valBytes[0]);
  8437. queueMessage(message,this,"ignore(QByteArray)");
  8438. }
  8439. /*:772*//*773:*/
  8440. #line 17598 "./typica.w"
  8441. void ModbusRTUDevice::ignore(QByteArray)
  8442. {
  8443. return;
  8444. }
  8445. /*:773*/
  8446. #line 813 "./typica.w"
  8447. /*647:*/
  8448. #line 14256 "./typica.w"
  8449. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  8450. DeviceTreeModelNode*parent)
  8451. :domNode(node),rowNumber(row),parentItem(parent)
  8452. {
  8453. }
  8454. DeviceTreeModelNode::~DeviceTreeModelNode()
  8455. {
  8456. QHash<int,DeviceTreeModelNode*> ::iterator i;
  8457. for(i= children.begin();i!=children.end();i++)
  8458. {
  8459. delete i.value();
  8460. }
  8461. }
  8462. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  8463. {
  8464. return parentItem;
  8465. }
  8466. int DeviceTreeModelNode::row()
  8467. {
  8468. return rowNumber;
  8469. }
  8470. QDomNode DeviceTreeModelNode::node()const
  8471. {
  8472. return domNode;
  8473. }
  8474. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  8475. {
  8476. if(children.contains(index))
  8477. {
  8478. return children[index];
  8479. }
  8480. if(index>=0&&index<domNode.childNodes().count())
  8481. {
  8482. QDomNode childNode= domNode.childNodes().item(index);
  8483. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  8484. index,this);
  8485. children[index]= childItem;
  8486. return childItem;
  8487. }
  8488. return NULL;
  8489. }
  8490. /*:647*/
  8491. #line 814 "./typica.w"
  8492. /*649:*/
  8493. #line 14345 "./typica.w"
  8494. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  8495. :QAbstractItemModel(parent)
  8496. {
  8497. document= AppInstance->deviceConfiguration();
  8498. QDomNodeList elements= document.elementsByTagName("devices");
  8499. if(elements.size()!=1)
  8500. {
  8501. qDebug()<<"Unexpected result when loading device map.";
  8502. }
  8503. treeRoot= elements.at(0);
  8504. root= new DeviceTreeModelNode(treeRoot,0);
  8505. elements= document.elementsByTagName("references");
  8506. if(elements.size()!=1)
  8507. {
  8508. qDebug()<<"No references section. Creating.";
  8509. referenceSection= document.createElement("references");
  8510. document.appendChild(referenceSection);
  8511. }
  8512. else
  8513. {
  8514. referenceSection= elements.at(0);
  8515. }
  8516. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  8517. AppInstance,SLOT(saveDeviceConfiguration()));
  8518. connect(this,SIGNAL(modelReset()),
  8519. AppInstance,SLOT(saveDeviceConfiguration()));
  8520. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8521. AppInstance,SLOT(saveDeviceConfiguration()));
  8522. }
  8523. /*:649*//*650:*/
  8524. #line 14380 "./typica.w"
  8525. int DeviceTreeModel::columnCount(const QModelIndex&)const
  8526. {
  8527. return 1;
  8528. }
  8529. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  8530. {
  8531. if(parent.column()> 0)
  8532. {
  8533. return 0;
  8534. }
  8535. /*651:*/
  8536. #line 14399 "./typica.w"
  8537. DeviceTreeModelNode*parentItem;
  8538. if(!parent.isValid())
  8539. {
  8540. parentItem= root;
  8541. }
  8542. else
  8543. {
  8544. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8545. }
  8546. /*:651*/
  8547. #line 14392 "./typica.w"
  8548. return parentItem->node().childNodes().count();
  8549. }
  8550. /*:650*//*652:*/
  8551. #line 14413 "./typica.w"
  8552. QModelIndex DeviceTreeModel::index(int row,int column,
  8553. const QModelIndex&parent)const
  8554. {
  8555. if(!hasIndex(row,column,parent))
  8556. {
  8557. return QModelIndex();
  8558. }
  8559. /*651:*/
  8560. #line 14399 "./typica.w"
  8561. DeviceTreeModelNode*parentItem;
  8562. if(!parent.isValid())
  8563. {
  8564. parentItem= root;
  8565. }
  8566. else
  8567. {
  8568. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8569. }
  8570. /*:651*/
  8571. #line 14421 "./typica.w"
  8572. DeviceTreeModelNode*childItem= parentItem->child(row);
  8573. if(childItem)
  8574. {
  8575. return createIndex(row,column,childItem);
  8576. }
  8577. return QModelIndex();
  8578. }
  8579. /*:652*//*653:*/
  8580. #line 14432 "./typica.w"
  8581. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  8582. {
  8583. if(!child.isValid())
  8584. {
  8585. return QModelIndex();
  8586. }
  8587. DeviceTreeModelNode*childItem=
  8588. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  8589. DeviceTreeModelNode*parentItem= childItem->parent();
  8590. if(!parentItem||parentItem==root)
  8591. {
  8592. return QModelIndex();
  8593. }
  8594. return createIndex(parentItem->row(),0,parentItem);
  8595. }
  8596. /*:653*//*654:*/
  8597. #line 14451 "./typica.w"
  8598. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  8599. {
  8600. if(!index.isValid())
  8601. {
  8602. return 0;
  8603. }
  8604. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  8605. }
  8606. /*:654*//*655:*/
  8607. #line 14466 "./typica.w"
  8608. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  8609. {
  8610. if(!index.isValid())
  8611. {
  8612. return QVariant();
  8613. }
  8614. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  8615. {
  8616. return QVariant();
  8617. }
  8618. DeviceTreeModelNode*item=
  8619. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  8620. QDomNode node= item->node();
  8621. QDomElement element= node.toElement();
  8622. switch(role)
  8623. {
  8624. case Qt::DisplayRole:
  8625. case Qt::EditRole:
  8626. return QVariant(element.attribute("name"));
  8627. case Qt::UserRole:
  8628. return QVariant(element.attribute("reference"));
  8629. default:
  8630. return QVariant();
  8631. }
  8632. return QVariant();
  8633. }
  8634. /*:655*//*656:*/
  8635. #line 14498 "./typica.w"
  8636. bool DeviceTreeModel::setData(const QModelIndex&index,
  8637. const QVariant&value,int)
  8638. {
  8639. if(!index.isValid())
  8640. {
  8641. return false;
  8642. }
  8643. DeviceTreeModelNode*item=
  8644. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  8645. QDomNode node= item->node();
  8646. QDomElement element= node.toElement();
  8647. element.setAttribute("name",value.toString());
  8648. emit dataChanged(index,index);
  8649. return true;
  8650. }
  8651. /*:656*//*657:*/
  8652. #line 14521 "./typica.w"
  8653. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  8654. const QModelIndex&parent)
  8655. {
  8656. QString referenceID= QUuid::createUuid().toString();
  8657. /*651:*/
  8658. #line 14399 "./typica.w"
  8659. DeviceTreeModelNode*parentItem;
  8660. if(!parent.isValid())
  8661. {
  8662. parentItem= root;
  8663. }
  8664. else
  8665. {
  8666. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8667. }
  8668. /*:651*/
  8669. #line 14526 "./typica.w"
  8670. QDomNode parentNode= parentItem->node();
  8671. int newRowNumber= rowCount(parent);
  8672. beginInsertRows(parent,newRowNumber,newRowNumber);
  8673. QDomElement deviceElement= document.createElement("node");
  8674. deviceElement.setAttribute("name",name);
  8675. deviceElement.setAttribute("reference",referenceID);
  8676. parentNode.appendChild(deviceElement);
  8677. QDomElement referenceElement= document.createElement("reference");
  8678. referenceElement.setAttribute("id",referenceID);
  8679. referenceElement.setAttribute("driver",driver);
  8680. referenceSection.appendChild(referenceElement);
  8681. endInsertRows();
  8682. }
  8683. /*:657*//*658:*/
  8684. #line 14544 "./typica.w"
  8685. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  8686. {
  8687. /*651:*/
  8688. #line 14399 "./typica.w"
  8689. DeviceTreeModelNode*parentItem;
  8690. if(!parent.isValid())
  8691. {
  8692. parentItem= root;
  8693. }
  8694. else
  8695. {
  8696. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8697. }
  8698. /*:651*/
  8699. #line 14547 "./typica.w"
  8700. QDomNode parentNode= parentItem->node();
  8701. QDomNodeList childNodes= parentNode.childNodes();
  8702. if(childNodes.size()<row+count)
  8703. {
  8704. return false;
  8705. }
  8706. beginRemoveRows(parent,row,row+count-1);
  8707. QList<QDomElement> removalList;
  8708. for(int i= row;i<row+count;i++)
  8709. {
  8710. removalList.append(childNodes.at(i).toElement());
  8711. }
  8712. QDomElement element;
  8713. QDomElement reference;
  8714. for(int i= 0;i<count;i++)
  8715. {
  8716. element= removalList.at(i);
  8717. if(element.hasAttribute("reference"))
  8718. {
  8719. reference= referenceElement(element.attribute("reference"));
  8720. if(!reference.isNull())
  8721. {
  8722. referenceSection.removeChild(reference);
  8723. }
  8724. }
  8725. parentNode.removeChild(element);
  8726. }
  8727. endRemoveRows();
  8728. beginResetModel();
  8729. delete root;
  8730. root= new DeviceTreeModelNode(treeRoot,0);
  8731. endResetModel();
  8732. return true;
  8733. }
  8734. /*:658*//*659:*/
  8735. #line 14586 "./typica.w"
  8736. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  8737. {
  8738. QDomNodeList childNodes= referenceSection.childNodes();
  8739. QDomElement element;
  8740. for(int i= 0;i<childNodes.size();i++)
  8741. {
  8742. element= childNodes.at(i).toElement();
  8743. if(element.hasAttribute("id"))
  8744. {
  8745. if(element.attribute("id")==id)
  8746. {
  8747. return element;
  8748. }
  8749. }
  8750. }
  8751. return QDomElement();
  8752. }
  8753. /*:659*//*660:*/
  8754. #line 14607 "./typica.w"
  8755. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  8756. {
  8757. return QVariant();
  8758. }
  8759. /*:660*//*661:*/
  8760. #line 14616 "./typica.w"
  8761. DeviceTreeModel::~DeviceTreeModel()
  8762. {
  8763. delete root;
  8764. }
  8765. /*:661*/
  8766. #line 815 "./typica.w"
  8767. /*688:*/
  8768. #line 15115 "./typica.w"
  8769. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  8770. DeviceTreeModel*model,const QModelIndex&index)
  8771. :QWidget(NULL),deviceModel(model),currentNode(index)
  8772. {
  8773. }
  8774. /*:688*//*689:*/
  8775. #line 15127 "./typica.w"
  8776. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  8777. const QString&value)
  8778. {
  8779. QDomElement referenceElement= deviceModel->referenceElement(
  8780. deviceModel->data(currentNode,Qt::UserRole).toString());
  8781. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8782. QDomElement node;
  8783. bool found= false;
  8784. for(int i= 0;i<configData.size();i++)
  8785. {
  8786. node= configData.at(i).toElement();
  8787. if(node.attribute("name")==name)
  8788. {
  8789. node.setAttribute("value",value);
  8790. found= true;
  8791. break;
  8792. }
  8793. }
  8794. if(!found)
  8795. {
  8796. node= AppInstance->deviceConfiguration().createElement("attribute");
  8797. node.setAttribute("name",name);
  8798. node.setAttribute("value",value);
  8799. referenceElement.appendChild(node);
  8800. }
  8801. AppInstance->saveDeviceConfiguration();
  8802. }
  8803. /*:689*//*690:*/
  8804. #line 15161 "./typica.w"
  8805. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  8806. const QString&driver)
  8807. {
  8808. deviceModel->newNode(name,driver,currentNode);
  8809. }
  8810. /*:690*/
  8811. #line 816 "./typica.w"
  8812. /*679:*/
  8813. #line 14960 "./typica.w"
  8814. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  8815. view(new QTreeView),configArea(new QScrollArea)
  8816. {
  8817. QSplitter*splitter= new QSplitter;
  8818. QWidget*leftWidget= new QWidget;
  8819. leftWidget->setMinimumWidth(200);
  8820. QVBoxLayout*left= new QVBoxLayout;
  8821. view->setAnimated(true);
  8822. view->setSelectionMode(QAbstractItemView::SingleSelection);
  8823. document= AppInstance->deviceConfiguration();
  8824. model= new DeviceTreeModel;
  8825. view->setModel(model);
  8826. view->setTextElideMode(Qt::ElideNone);
  8827. view->expandAll();
  8828. view->resizeColumnToContents(0);
  8829. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  8830. QHBoxLayout*treeButtons= new QHBoxLayout;
  8831. QToolButton*addDeviceButton= new QToolButton;
  8832. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  8833. addDeviceButton->setToolTip(tr("New Roaster"));
  8834. connect(addDeviceButton,SIGNAL(clicked()),
  8835. this,SLOT(addDevice()));
  8836. QToolButton*removeNodeButton= new QToolButton;
  8837. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  8838. removeNodeButton->setToolTip(tr("Delete Selection"));
  8839. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  8840. treeButtons->addWidget(addDeviceButton);
  8841. treeButtons->addWidget(removeNodeButton);
  8842. left->addWidget(view);
  8843. left->addLayout(treeButtons);
  8844. leftWidget->setLayout(left);
  8845. splitter->addWidget(leftWidget);
  8846. configArea->setMinimumWidth(580);
  8847. configArea->setMinimumHeight(460);
  8848. splitter->addWidget(configArea);
  8849. QVBoxLayout*centralLayout= new QVBoxLayout;
  8850. centralLayout->addWidget(splitter);
  8851. setLayout(centralLayout);
  8852. connect(view,SIGNAL(activated(QModelIndex)),
  8853. this,SLOT(newSelection(QModelIndex)));
  8854. connect(view,SIGNAL(clicked(QModelIndex)),
  8855. this,SLOT(newSelection(QModelIndex)));
  8856. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8857. view,SLOT(expand(QModelIndex)));
  8858. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8859. this,SLOT(resizeColumn()));
  8860. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  8861. this,SLOT(resizeColumn()));
  8862. }
  8863. /*:679*//*680:*/
  8864. #line 15014 "./typica.w"
  8865. void DeviceConfigurationWindow::addDevice()
  8866. {
  8867. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  8868. }
  8869. /*:680*//*681:*/
  8870. #line 15022 "./typica.w"
  8871. void DeviceConfigurationWindow::removeNode()
  8872. {
  8873. QModelIndex index= view->currentIndex();
  8874. if(index.isValid())
  8875. {
  8876. int row= index.row();
  8877. QModelIndex parent= index.parent();
  8878. model->removeRow(row,parent);
  8879. }
  8880. }
  8881. /*:681*//*682:*/
  8882. #line 15038 "./typica.w"
  8883. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  8884. {
  8885. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  8886. if(editor)
  8887. {
  8888. configArea->setWidget(editor);
  8889. editor->show();
  8890. }
  8891. }
  8892. /*:682*//*683:*/
  8893. #line 15055 "./typica.w"
  8894. void DeviceConfigurationWindow::resizeColumn()
  8895. {
  8896. view->resizeColumnToContents(0);
  8897. }
  8898. /*:683*/
  8899. #line 817 "./typica.w"
  8900. /*703:*/
  8901. #line 15466 "./typica.w"
  8902. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  8903. const QModelIndex&index):
  8904. BasicDeviceConfigurationWidget(model,index)
  8905. {
  8906. QFormLayout*layout= new QFormLayout;
  8907. QLineEdit*columnName= new QLineEdit;
  8908. layout->addRow(tr("Column Name:"),columnName);
  8909. QComboBox*typeSelector= new QComboBox;
  8910. typeSelector->addItem("J");
  8911. typeSelector->addItem("K");
  8912. typeSelector->addItem("T");
  8913. typeSelector->addItem("B");
  8914. typeSelector->addItem("E");
  8915. typeSelector->addItem("N");
  8916. typeSelector->addItem("R");
  8917. typeSelector->addItem("S");
  8918. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  8919. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  8920. layout->addRow(hideSeries);
  8921. setLayout(layout);
  8922. /*693:*/
  8923. #line 15275 "./typica.w"
  8924. QDomElement referenceElement=
  8925. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8926. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8927. QDomElement node;
  8928. /*:693*/
  8929. #line 15487 "./typica.w"
  8930. for(int i= 0;i<configData.size();i++)
  8931. {
  8932. node= configData.at(i).toElement();
  8933. if(node.attribute("name")=="type")
  8934. {
  8935. typeSelector->setCurrentIndex(
  8936. typeSelector->findText(node.attribute("value")));
  8937. }
  8938. else if(node.attribute("name")=="columnname")
  8939. {
  8940. columnName->setText(node.attribute("value"));
  8941. }
  8942. else if(node.attribute("name")=="hidden")
  8943. {
  8944. hideSeries->setChecked(node.attribute("value")=="true");
  8945. }
  8946. }
  8947. updateThermocoupleType(typeSelector->currentText());
  8948. updateColumnName(columnName->text());
  8949. updateHidden(hideSeries->isChecked());
  8950. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  8951. this,SLOT(updateThermocoupleType(QString)));
  8952. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  8953. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  8954. }
  8955. /*:703*//*704:*/
  8956. #line 15517 "./typica.w"
  8957. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  8958. {
  8959. updateAttribute("type",type);
  8960. }
  8961. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  8962. {
  8963. updateAttribute("columnname",name);
  8964. }
  8965. void Ni9211TcConfWidget::updateHidden(bool hidden)
  8966. {
  8967. updateAttribute("hidden",hidden?"true":"false");
  8968. }
  8969. /*:704*/
  8970. #line 818 "./typica.w"
  8971. /*699:*/
  8972. #line 15380 "./typica.w"
  8973. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  8974. const QModelIndex&index)
  8975. :BasicDeviceConfigurationWidget(model,index)
  8976. {
  8977. QVBoxLayout*layout= new QVBoxLayout;
  8978. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  8979. QLabel*label= new QLabel(tr("Device ID:"));
  8980. QLineEdit*deviceId= new QLineEdit;
  8981. deviceIdLayout->addWidget(label);
  8982. deviceIdLayout->addWidget(deviceId);
  8983. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  8984. layout->addLayout(deviceIdLayout);
  8985. layout->addWidget(addChannelButton);
  8986. /*693:*/
  8987. #line 15275 "./typica.w"
  8988. QDomElement referenceElement=
  8989. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8990. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8991. QDomElement node;
  8992. /*:693*/
  8993. #line 15394 "./typica.w"
  8994. for(int i= 0;i<configData.size();i++)
  8995. {
  8996. node= configData.at(i).toElement();
  8997. if(node.attribute("name")=="deviceID")
  8998. {
  8999. deviceId->setText(node.attribute("value","Dev1"));
  9000. break;
  9001. }
  9002. }
  9003. updateDeviceId(deviceId->text());
  9004. connect(addChannelButton,SIGNAL(clicked()),
  9005. this,SLOT(addChannel()));
  9006. connect(deviceId,SIGNAL(textEdited(QString)),
  9007. this,SLOT(updateDeviceId(QString)));
  9008. setLayout(layout);
  9009. }
  9010. /*:699*//*700:*/
  9011. #line 15416 "./typica.w"
  9012. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9013. {
  9014. updateAttribute("deviceID",newId);
  9015. }
  9016. /*:700*//*701:*/
  9017. #line 15424 "./typica.w"
  9018. void NiDaqMxBase9211ConfWidget::addChannel()
  9019. {
  9020. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9021. }
  9022. /*:701*/
  9023. #line 819 "./typica.w"
  9024. /*697:*/
  9025. #line 15331 "./typica.w"
  9026. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9027. DeviceTreeModel*model,const QModelIndex&index):
  9028. BasicDeviceConfigurationWidget(model,index)
  9029. {
  9030. QHBoxLayout*layout= new QHBoxLayout;
  9031. QToolButton*addDeviceButton= new QToolButton;
  9032. addDeviceButton->setText(tr("Add Device"));
  9033. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9034. "nidaqmxbase9211series");
  9035. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9036. "nidaqmxbase9211series");
  9037. connect(add9211,SIGNAL(triggered(QString,QString)),
  9038. this,SLOT(insertChildNode(QString,QString)));
  9039. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9040. this,SLOT(insertChildNode(QString,QString)));
  9041. QMenu*deviceMenu= new QMenu;
  9042. deviceMenu->addAction(add9211);
  9043. deviceMenu->addAction(add9211a);
  9044. addDeviceButton->setMenu(deviceMenu);
  9045. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9046. layout->addWidget(addDeviceButton);
  9047. setLayout(layout);
  9048. }
  9049. /*:697*/
  9050. #line 820 "./typica.w"
  9051. /*585:*/
  9052. #line 12881 "./typica.w"
  9053. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9054. QObject*parent):
  9055. QAction(reportName,parent),reportFile(fileName)
  9056. {
  9057. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9058. }
  9059. /*:585*//*586:*/
  9060. #line 12897 "./typica.w"
  9061. void ReportAction::createReport()
  9062. {
  9063. QFile file(reportFile);
  9064. QDomDocument document;
  9065. if(file.open(QIODevice::ReadOnly))
  9066. {
  9067. document.setContent(&file,true);
  9068. QDomElement element= document.documentElement();
  9069. QScriptEngine*engine= AppInstance->engine;
  9070. QScriptContext*context= engine->pushContext();
  9071. QScriptValue object;
  9072. QString targetID= reportFile;
  9073. /*169:*/
  9074. #line 3998 "./typica.w"
  9075. ScriptQMainWindow*window= new ScriptQMainWindow;
  9076. window->setObjectName(targetID);
  9077. object= engine->newQObject(window);
  9078. setQMainWindowProperties(object,engine);
  9079. QWidget*central= new(QWidget);
  9080. central->setParent(window);
  9081. central->setObjectName("centralWidget");
  9082. window->setCentralWidget(central);
  9083. if(element.hasChildNodes())
  9084. {
  9085. /*170:*/
  9086. #line 4033 "./typica.w"
  9087. QStack<QWidget*> widgetStack;
  9088. QStack<QLayout*> layoutStack;
  9089. QString windowScript;
  9090. widgetStack.push(central);
  9091. QDomNodeList windowChildren= element.childNodes();
  9092. int i= 0;
  9093. while(i<windowChildren.count())
  9094. {
  9095. QDomNode current;
  9096. QDomElement element;
  9097. current= windowChildren.at(i);
  9098. if(current.isElement())
  9099. {
  9100. element= current.toElement();
  9101. if(element.tagName()=="program")
  9102. {
  9103. windowScript.append(element.text());
  9104. }
  9105. else if(element.tagName()=="layout")
  9106. {
  9107. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9108. }
  9109. else if(element.tagName()=="menu")
  9110. {
  9111. /*171:*/
  9112. #line 4080 "./typica.w"
  9113. QMenuBar*bar= window->menuBar();
  9114. bar->setParent(window);
  9115. bar->setObjectName("menuBar");
  9116. if(element.hasAttribute("name"))
  9117. {
  9118. QMenu*menu= bar->addMenu(element.attribute("name"));
  9119. menu->setParent(bar);
  9120. if(element.hasAttribute("type"))
  9121. {
  9122. if(element.attribute("type")=="reports")
  9123. {
  9124. if(element.hasAttribute("src"))
  9125. {
  9126. /*583:*/
  9127. #line 12844 "./typica.w"
  9128. QSettings settings;
  9129. QDir directory(QString("%1/%2").arg(settings.value("config").toString()).
  9130. arg(element.attribute("src")));
  9131. directory.setFilter(QDir::Files);
  9132. directory.setSorting(QDir::Name);
  9133. QStringList nameFilter;
  9134. nameFilter<<"*.xml";
  9135. directory.setNameFilters(nameFilter);
  9136. QFileInfoList reportFiles= directory.entryInfoList();
  9137. for(int i= 0;i<reportFiles.size();i++)
  9138. {
  9139. QFileInfo reportFile= reportFiles.at(i);
  9140. /*587:*/
  9141. #line 12921 "./typica.w"
  9142. QString path= reportFile.absoluteFilePath();
  9143. QFile file(path);
  9144. if(file.open(QIODevice::ReadOnly))
  9145. {
  9146. QDomDocument document;
  9147. document.setContent(&file,true);
  9148. QDomElement root= document.documentElement();
  9149. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9150. if(!titleNode.isNull())
  9151. {
  9152. QDomElement titleElement= titleNode.toElement();
  9153. QString title= titleElement.text();
  9154. if(!title.isEmpty())
  9155. {
  9156. QStringList hierarchy= title.split(":->");
  9157. QMenu*insertionPoint= menu;
  9158. /*588:*/
  9159. #line 12948 "./typica.w"
  9160. for(int j= 0;j<hierarchy.size()-1;j++)
  9161. {
  9162. QObjectList menuList= insertionPoint->children();
  9163. bool menuFound= false;
  9164. for(int k= 0;k<menuList.size();k++)
  9165. {
  9166. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9167. if(currentItem)
  9168. {
  9169. if(currentItem->title()==hierarchy.at(j))
  9170. {
  9171. menuFound= true;
  9172. insertionPoint= currentItem;
  9173. break;
  9174. }
  9175. }
  9176. }
  9177. if(!menuFound)
  9178. {
  9179. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9180. }
  9181. }
  9182. /*:588*/
  9183. #line 12938 "./typica.w"
  9184. ReportAction*action= new ReportAction(path,hierarchy.last());
  9185. insertionPoint->addAction(action);
  9186. }
  9187. }
  9188. }
  9189. /*:587*/
  9190. #line 12857 "./typica.w"
  9191. }
  9192. /*:583*/
  9193. #line 4094 "./typica.w"
  9194. }
  9195. }
  9196. }
  9197. if(element.hasChildNodes())
  9198. {
  9199. /*172:*/
  9200. #line 4107 "./typica.w"
  9201. QDomNodeList menuItems= element.childNodes();
  9202. int j= 0;
  9203. while(j<menuItems.count())
  9204. {
  9205. QDomNode item= menuItems.at(j);
  9206. if(item.isElement())
  9207. {
  9208. QDomElement itemElement= item.toElement();
  9209. if(itemElement.tagName()=="item")
  9210. {
  9211. QAction*itemAction= new QAction(itemElement.text(),menu);
  9212. if(itemElement.hasAttribute("id"))
  9213. {
  9214. itemAction->setObjectName(itemElement.attribute("id"));
  9215. }
  9216. if(itemElement.hasAttribute("shortcut"))
  9217. {
  9218. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9219. }
  9220. menu->addAction(itemAction);
  9221. }
  9222. else if(itemElement.tagName()=="separator")
  9223. {
  9224. menu->addSeparator();
  9225. }
  9226. }
  9227. j++;
  9228. }
  9229. #line 1 "./helpmenu.w"
  9230. /*:172*/
  9231. #line 4100 "./typica.w"
  9232. }
  9233. }
  9234. /*:171*/
  9235. #line 4058 "./typica.w"
  9236. }
  9237. }
  9238. i++;
  9239. }
  9240. QScriptValue oldThis= context->thisObject();
  9241. context->setThisObject(object);
  9242. QScriptValue result= engine->evaluate(windowScript);
  9243. /*164:*/
  9244. #line 3847 "./typica.w"
  9245. if(engine->hasUncaughtException())
  9246. {
  9247. int line= engine->uncaughtExceptionLineNumber();
  9248. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9249. result.toString();
  9250. QString trace;
  9251. foreach(trace,engine->uncaughtExceptionBacktrace())
  9252. {
  9253. qDebug()<<trace;
  9254. }
  9255. }
  9256. /*:164*/
  9257. #line 4066 "./typica.w"
  9258. context->setThisObject(oldThis);
  9259. /*:170*/
  9260. #line 4009 "./typica.w"
  9261. }
  9262. /*173:*/
  9263. #line 9 "./helpmenu.w"
  9264. HelpMenu*helpMenu= new HelpMenu();
  9265. window->menuBar()->addMenu(helpMenu);
  9266. /*:173*/
  9267. #line 4011 "./typica.w"
  9268. window->show();
  9269. /*:169*/
  9270. #line 12910 "./typica.w"
  9271. file.close();
  9272. engine->popContext();
  9273. }
  9274. }
  9275. /*:586*/
  9276. #line 821 "./typica.w"
  9277. /*205:*/
  9278. #line 5164 "./typica.w"
  9279. NumericDelegate::NumericDelegate(QObject*parent):
  9280. QItemDelegate(parent)
  9281. {
  9282. }
  9283. /*:205*//*206:*/
  9284. #line 5176 "./typica.w"
  9285. void NumericDelegate::setEditorData(QWidget*editor,
  9286. const QModelIndex&index)const
  9287. {
  9288. QString value= index.model()->data(index,Qt::EditRole).toString();
  9289. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9290. line->setText(value);
  9291. }
  9292. /*:206*//*207:*/
  9293. #line 5191 "./typica.w"
  9294. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9295. const QModelIndex&index)const
  9296. {
  9297. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9298. model->setData(index,line->text(),Qt::EditRole);
  9299. QScriptEngine*engine= AppInstance->engine;
  9300. engine->pushContext();
  9301. QString script= QString("Number(%1)").arg(line->text());
  9302. QScriptValue result= engine->evaluate(line->text());
  9303. if(result.isNumber())
  9304. {
  9305. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9306. }
  9307. else
  9308. {
  9309. model->setData(index,QVariant(),Qt::DisplayRole);
  9310. }
  9311. engine->popContext();
  9312. }
  9313. /*:207*//*208:*/
  9314. #line 5214 "./typica.w"
  9315. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9316. const QStyleOptionViewItem&,
  9317. const QModelIndex&)const
  9318. {
  9319. return(new QLineEdit(parent));
  9320. }
  9321. /*:208*//*209:*/
  9322. #line 5225 "./typica.w"
  9323. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9324. const QStyleOptionViewItem&option,
  9325. const QModelIndex&)const
  9326. {
  9327. editor->setGeometry(option.rect);
  9328. }
  9329. /*:209*/
  9330. #line 822 "./typica.w"
  9331. /*708:*/
  9332. #line 15576 "./typica.w"
  9333. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9334. const QModelIndex&index)
  9335. :BasicDeviceConfigurationWidget(model,index)
  9336. {
  9337. QHBoxLayout*layout= new QHBoxLayout;
  9338. QToolButton*addDeviceButton= new QToolButton;
  9339. addDeviceButton->setText(tr("Add Device"));
  9340. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9341. "nidaqmx9211series");
  9342. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9343. "nidaqmxtc01");
  9344. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9345. this,SLOT(insertChildNode(QString,QString)));
  9346. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9347. this,SLOT(insertChildNode(QString,QString)));
  9348. QMenu*deviceMenu= new QMenu;
  9349. deviceMenu->addAction(add9211a);
  9350. deviceMenu->addAction(addtc01);
  9351. addDeviceButton->setMenu(deviceMenu);
  9352. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9353. layout->addWidget(addDeviceButton);
  9354. setLayout(layout);
  9355. }
  9356. /*:708*/
  9357. #line 823 "./typica.w"
  9358. /*710:*/
  9359. #line 15625 "./typica.w"
  9360. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9361. const QModelIndex&index)
  9362. :BasicDeviceConfigurationWidget(model,index)
  9363. {
  9364. QVBoxLayout*layout= new QVBoxLayout;
  9365. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9366. QLabel*label= new QLabel(tr("Device ID:"));
  9367. QLineEdit*deviceId= new QLineEdit;
  9368. deviceIdLayout->addWidget(label);
  9369. deviceIdLayout->addWidget(deviceId);
  9370. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9371. layout->addLayout(deviceIdLayout);
  9372. layout->addWidget(addChannelButton);
  9373. /*693:*/
  9374. #line 15275 "./typica.w"
  9375. QDomElement referenceElement=
  9376. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9377. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9378. QDomElement node;
  9379. /*:693*/
  9380. #line 15639 "./typica.w"
  9381. for(int i= 0;i<configData.size();i++)
  9382. {
  9383. node= configData.at(i).toElement();
  9384. if(node.attribute("name")=="deviceID")
  9385. {
  9386. deviceId->setText(node.attribute("value","Dev1"));
  9387. break;
  9388. }
  9389. }
  9390. updateDeviceId(deviceId->text());
  9391. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9392. connect(deviceId,SIGNAL(textEdited(QString)),
  9393. this,SLOT(updateDeviceId(QString)));
  9394. setLayout(layout);
  9395. }
  9396. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9397. {
  9398. updateAttribute("deviceID",newId);
  9399. }
  9400. void NiDaqMx9211ConfWidget::addChannel()
  9401. {
  9402. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9403. }
  9404. /*:710*/
  9405. #line 824 "./typica.w"
  9406. /*712:*/
  9407. #line 15690 "./typica.w"
  9408. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9409. const QModelIndex&index)
  9410. :BasicDeviceConfigurationWidget(model,index)
  9411. {
  9412. QFormLayout*layout= new QFormLayout;
  9413. QLineEdit*deviceId= new QLineEdit;
  9414. layout->addRow(tr("Device ID:"),deviceId);
  9415. QLineEdit*columnName= new QLineEdit;
  9416. layout->addRow(tr("Column Name:"),columnName);
  9417. QComboBox*typeSelector= new QComboBox;
  9418. typeSelector->addItem("J");
  9419. typeSelector->addItem("K");
  9420. typeSelector->addItem("T");
  9421. typeSelector->addItem("B");
  9422. typeSelector->addItem("E");
  9423. typeSelector->addItem("N");
  9424. typeSelector->addItem("R");
  9425. typeSelector->addItem("S");
  9426. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9427. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  9428. layout->addRow(hideSeries);
  9429. /*693:*/
  9430. #line 15275 "./typica.w"
  9431. QDomElement referenceElement=
  9432. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9433. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9434. QDomElement node;
  9435. /*:693*/
  9436. #line 15712 "./typica.w"
  9437. for(int i= 0;i<configData.size();i++)
  9438. {
  9439. node= configData.at(i).toElement();
  9440. if(node.attribute("name")=="deviceID")
  9441. {
  9442. deviceId->setText(node.attribute("value"));
  9443. }
  9444. else if(node.attribute("name")=="type")
  9445. {
  9446. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  9447. }
  9448. else if(node.attribute("name")=="columnname")
  9449. {
  9450. columnName->setText(node.attribute("value"));
  9451. }
  9452. else if(node.attribute("name")=="hidden")
  9453. {
  9454. hideSeries->setChecked(node.attribute("value")=="true");
  9455. }
  9456. }
  9457. updateDeviceId(deviceId->text());
  9458. updateThermocoupleType(typeSelector->currentText());
  9459. updateColumnName(columnName->text());
  9460. updateHidden(hideSeries->isChecked());
  9461. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  9462. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  9463. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9464. setLayout(layout);
  9465. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9466. }
  9467. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  9468. {
  9469. updateAttribute("deviceID",newId);
  9470. }
  9471. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  9472. {
  9473. updateAttribute("type",type);
  9474. }
  9475. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  9476. {
  9477. updateAttribute("columnname",name);
  9478. }
  9479. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  9480. {
  9481. updateAttribute("hidden",hidden?"true":"false");
  9482. }
  9483. /*:712*/
  9484. #line 825 "./typica.w"
  9485. /*730:*/
  9486. #line 16128 "./typica.w"
  9487. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  9488. const QModelIndex&index)
  9489. :BasicDeviceConfigurationWidget(model,index)
  9490. {
  9491. QFormLayout*layout= new QFormLayout;
  9492. QToolButton*addDeviceButton= new QToolButton;
  9493. addDeviceButton->setText(tr("Add Device"));
  9494. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  9495. "Modbus RTU Device",
  9496. "modbusrtudevice");
  9497. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  9498. this,SLOT(insertChildNode(QString,QString)));
  9499. QMenu*deviceMenu= new QMenu;
  9500. deviceMenu->addAction(addModbusRtuDevice);
  9501. addDeviceButton->setMenu(deviceMenu);
  9502. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9503. layout->addRow(QString(),addDeviceButton);
  9504. PortSelector*port= new PortSelector;
  9505. layout->addRow(tr("Port:"),port);
  9506. connect(port,SIGNAL(currentIndexChanged(QString)),
  9507. this,SLOT(updatePort(QString)));
  9508. connect(port,SIGNAL(editTextChanged(QString)),
  9509. this,SLOT(updatePort(QString)));
  9510. BaudSelector*rate= new BaudSelector;
  9511. layout->addRow(tr("Baud:"),rate);
  9512. connect(rate,SIGNAL(currentIndexChanged(QString)),
  9513. this,SLOT(updateBaudRate(QString)));
  9514. ParitySelector*parity= new ParitySelector;
  9515. layout->addRow(tr("Parity:"),parity);
  9516. connect(parity,SIGNAL(currentIndexChanged(QString)),
  9517. this,SLOT(updateParity(QString)));
  9518. FlowSelector*flow= new FlowSelector;
  9519. layout->addRow(tr("Flow Control:"),flow);
  9520. connect(flow,SIGNAL(currentIndexChanged(QString)),
  9521. this,SLOT(updateFlowControl(QString)));
  9522. StopSelector*stop= new StopSelector;
  9523. layout->addRow(tr("Stop Bits:"),stop);
  9524. connect(stop,SIGNAL(currentIndexChanged(QString)),
  9525. this,SLOT(updateStopBits(QString)));
  9526. /*693:*/
  9527. #line 15275 "./typica.w"
  9528. QDomElement referenceElement=
  9529. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9530. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9531. QDomElement node;
  9532. /*:693*/
  9533. #line 16168 "./typica.w"
  9534. for(int i= 0;i<configData.size();i++)
  9535. {
  9536. node= configData.at(i).toElement();
  9537. if(node.attribute("name")=="port")
  9538. {
  9539. int j= port->findText(node.attribute("value"));
  9540. if(j>=0)
  9541. {
  9542. port->setCurrentIndex(j);
  9543. }
  9544. else
  9545. {
  9546. port->insertItem(0,node.attribute("value"));
  9547. port->setCurrentIndex(0);
  9548. }
  9549. }
  9550. else if(node.attribute("name")=="baudrate")
  9551. {
  9552. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  9553. }
  9554. else if(node.attribute("name")=="parity")
  9555. {
  9556. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  9557. }
  9558. else if(node.attribute("name")=="flowcontrol")
  9559. {
  9560. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  9561. }
  9562. else if(node.attribute("name")=="stopbits")
  9563. {
  9564. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  9565. }
  9566. }
  9567. updatePort(port->currentText());
  9568. updateBaudRate(rate->currentText());
  9569. updateParity(parity->currentText());
  9570. updateFlowControl(flow->currentText());
  9571. updateStopBits(stop->currentText());
  9572. setLayout(layout);
  9573. }
  9574. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  9575. {
  9576. updateAttribute("port",newPort);
  9577. }
  9578. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  9579. {
  9580. updateAttribute("baudrate",newRate);
  9581. }
  9582. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  9583. {
  9584. updateAttribute("parity",newParity);
  9585. }
  9586. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  9587. {
  9588. updateAttribute("flowcontrol",newFlow);
  9589. }
  9590. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  9591. {
  9592. updateAttribute("stopbits",newStopBits);
  9593. }
  9594. /*:730*/
  9595. #line 826 "./typica.w"
  9596. /*732:*/
  9597. #line 16291 "./typica.w"
  9598. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  9599. const QModelIndex&index)
  9600. :BasicDeviceConfigurationWidget(model,index),
  9601. unitSpecificationLayout(new QStackedLayout),
  9602. decimalSpecificationLayout(new QStackedLayout)
  9603. {
  9604. QVBoxLayout*layout= new QVBoxLayout;
  9605. QToolButton*addChannelButton= new QToolButton;
  9606. addChannelButton->setText(tr("Add Channel"));
  9607. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  9608. "Temperature Process Value",
  9609. "modbustemperaturepv");
  9610. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  9611. "Temperature Set Value",
  9612. "modbustemperaturesv");
  9613. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  9614. this,SLOT(insertChildNode(QString,QString)));
  9615. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  9616. this,SLOT(insertChildNode(QString,QString)));
  9617. QMenu*channelMenu= new QMenu;
  9618. channelMenu->addAction(addTemperaturePV);
  9619. channelMenu->addAction(addTemperatureSV);
  9620. addChannelButton->setMenu(channelMenu);
  9621. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  9622. layout->addWidget(addChannelButton);
  9623. QHBoxLayout*stationLayout= new QHBoxLayout;
  9624. QLabel*stationLabel= new QLabel(tr("Station:"));
  9625. QSpinBox*stationNumber= new QSpinBox;
  9626. stationNumber->setMinimum(0);
  9627. stationNumber->setMaximum(255);
  9628. stationLayout->addWidget(stationLabel);
  9629. stationLayout->addWidget(stationNumber);
  9630. layout->addLayout(stationLayout);
  9631. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  9632. layout->addWidget(fixedUnit);
  9633. QWidget*fixedUnitPlaceholder= new QWidget(this);
  9634. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  9635. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  9636. QComboBox*fixedUnitSelector= new QComboBox;
  9637. fixedUnitSelector->addItem("Fahrenheit");
  9638. fixedUnitSelector->addItem("Celsius");
  9639. fixedUnitLayout->addWidget(fixedUnitLabel);
  9640. fixedUnitLayout->addWidget(fixedUnitSelector);
  9641. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  9642. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  9643. QWidget*queriedUnitPlaceholder= new QWidget(this);
  9644. QFormLayout*queriedUnitLayout= new QFormLayout;
  9645. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  9646. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  9647. QSpinBox*valueF= new QSpinBox;
  9648. valueF->setMinimum(0);
  9649. valueF->setMaximum(65535);
  9650. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  9651. QSpinBox*valueC= new QSpinBox;
  9652. valueC->setMinimum(0);
  9653. valueC->setMaximum(65535);
  9654. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  9655. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  9656. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  9657. layout->addLayout(unitSpecificationLayout);
  9658. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  9659. layout->addWidget(fixedPrecision);
  9660. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  9661. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  9662. QSpinBox*fixedPrecisionValue= new QSpinBox;
  9663. fixedPrecisionValue->setMinimum(0);
  9664. fixedPrecisionValue->setMaximum(9);
  9665. fixedPrecisionLayout->addRow("Places after the decimal point:",
  9666. fixedPrecisionValue);
  9667. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  9668. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  9669. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  9670. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  9671. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  9672. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  9673. precisionAddress);
  9674. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  9675. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  9676. layout->addLayout(decimalSpecificationLayout);
  9677. /*693:*/
  9678. #line 15275 "./typica.w"
  9679. QDomElement referenceElement=
  9680. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9681. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9682. QDomElement node;
  9683. /*:693*/
  9684. #line 16371 "./typica.w"
  9685. for(int i= 0;i<configData.size();i++)
  9686. {
  9687. node= configData.at(i).toElement();
  9688. if(node.attribute("name")=="station")
  9689. {
  9690. stationNumber->setValue(node.attribute("value").toInt());
  9691. }
  9692. else if(node.attribute("name")=="fixedunit")
  9693. {
  9694. if(node.attribute("value")=="true")
  9695. {
  9696. fixedUnit->setCheckState(Qt::Checked);
  9697. }
  9698. else if(node.attribute("value")=="false")
  9699. {
  9700. fixedUnit->setCheckState(Qt::Unchecked);
  9701. }
  9702. }
  9703. else if(node.attribute("name")=="fixedprecision")
  9704. {
  9705. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  9706. }
  9707. else if(node.attribute("name")=="unit")
  9708. {
  9709. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  9710. }
  9711. else if(node.attribute("name")=="unitaddress")
  9712. {
  9713. unitAddress->setValue(node.attribute("value").toInt());
  9714. }
  9715. else if(node.attribute("name")=="fvalue")
  9716. {
  9717. valueF->setValue(node.attribute("value").toInt());
  9718. }
  9719. else if(node.attribute("name")=="cvalue")
  9720. {
  9721. valueC->setValue(node.attribute("value").toInt());
  9722. }
  9723. else if(node.attribute("name")=="precisionaddress")
  9724. {
  9725. precisionAddress->setValue(node.attribute("value").toInt());
  9726. }
  9727. else if(node.attribute("name")=="precision")
  9728. {
  9729. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  9730. }
  9731. }
  9732. updateStationNumber(stationNumber->value());
  9733. updateFixedUnit(fixedUnit->isChecked());
  9734. updateFixedDecimal(fixedPrecision->isChecked());
  9735. updateUnit(fixedUnitSelector->currentText());
  9736. updateUnitAddress(unitAddress->value());
  9737. updateValueF(valueF->value());
  9738. updateValueC(valueC->value());
  9739. updatePrecisionAddress(precisionAddress->value());
  9740. updatePrecisionValue(fixedPrecisionValue->value());
  9741. connect(stationNumber,SIGNAL(valueChanged(int)),
  9742. this,SLOT(updateStationNumber(int)));
  9743. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  9744. this,SLOT(updateUnit(QString)));
  9745. connect(unitAddress,SIGNAL(valueChanged(int)),
  9746. this,SLOT(updateUnitAddress(int)));
  9747. connect(valueF,SIGNAL(valueChanged(int)),
  9748. this,SLOT(updateValueF(int)));
  9749. connect(valueC,SIGNAL(valueChanged(int)),
  9750. this,SLOT(updateValueC(int)));
  9751. connect(fixedUnit,SIGNAL(toggled(bool)),
  9752. this,SLOT(updateFixedUnit(bool)));
  9753. connect(fixedPrecision,SIGNAL(toggled(bool)),
  9754. this,SLOT(updateFixedDecimal(bool)));
  9755. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  9756. this,SLOT(updatePrecisionValue(int)));
  9757. connect(precisionAddress,SIGNAL(valueChanged(int)),
  9758. this,SLOT(updatePrecisionAddress(int)));
  9759. setLayout(layout);
  9760. }
  9761. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  9762. {
  9763. updateAttribute("station",QString("%1").arg(newStation));
  9764. }
  9765. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  9766. {
  9767. if(newFixed)
  9768. {
  9769. unitSpecificationLayout->setCurrentIndex(0);
  9770. updateAttribute("fixedunit","true");
  9771. }
  9772. else
  9773. {
  9774. unitSpecificationLayout->setCurrentIndex(1);
  9775. updateAttribute("fixedunit","false");
  9776. }
  9777. }
  9778. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  9779. {
  9780. if(newFixed)
  9781. {
  9782. decimalSpecificationLayout->setCurrentIndex(0);
  9783. updateAttribute("fixedprecision","true");
  9784. }
  9785. else
  9786. {
  9787. decimalSpecificationLayout->setCurrentIndex(1);
  9788. updateAttribute("fixedprecision","false");
  9789. }
  9790. }
  9791. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  9792. {
  9793. updateAttribute("unit",newUnit);
  9794. }
  9795. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  9796. {
  9797. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  9798. }
  9799. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  9800. {
  9801. updateAttribute("fvalue",QString("%1").arg(newValue));
  9802. }
  9803. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  9804. {
  9805. updateAttribute("cvalue",QString("%1").arg(newValue));
  9806. }
  9807. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  9808. {
  9809. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  9810. }
  9811. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  9812. {
  9813. updateAttribute("precision",QString("%1").arg(newValue));
  9814. }
  9815. /*:732*/
  9816. #line 827 "./typica.w"
  9817. /*734:*/
  9818. #line 16534 "./typica.w"
  9819. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  9820. const QModelIndex&index)
  9821. :BasicDeviceConfigurationWidget(model,index)
  9822. {
  9823. QFormLayout*layout= new QFormLayout;
  9824. ShortHexSpinBox*address= new ShortHexSpinBox;
  9825. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  9826. /*693:*/
  9827. #line 15275 "./typica.w"
  9828. QDomElement referenceElement=
  9829. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9830. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9831. QDomElement node;
  9832. /*:693*/
  9833. #line 16542 "./typica.w"
  9834. for(int i= 0;i<configData.size();i++)
  9835. {
  9836. node= configData.at(i).toElement();
  9837. if(node.attribute("name")=="address")
  9838. {
  9839. address->setValue(node.attribute("value").toInt());
  9840. break;
  9841. }
  9842. }
  9843. updateAddress(address->value());
  9844. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  9845. setLayout(layout);
  9846. }
  9847. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  9848. {
  9849. updateAttribute("address",QString("%1").arg(newAddress));
  9850. }
  9851. /*:734*/
  9852. #line 828 "./typica.w"
  9853. /*736:*/
  9854. #line 16590 "./typica.w"
  9855. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  9856. const QModelIndex&index)
  9857. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  9858. {
  9859. QVBoxLayout*layout= new QVBoxLayout;
  9860. QFormLayout*addressLayout= new QFormLayout;
  9861. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  9862. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  9863. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  9864. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  9865. layout->addLayout(addressLayout);
  9866. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  9867. layout->addWidget(fixedRange);
  9868. QWidget*queriedRangePlaceholder= new QWidget(this);
  9869. QFormLayout*queriedRangeLayout= new QFormLayout;
  9870. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  9871. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  9872. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  9873. lowerAddress);
  9874. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  9875. upperAddress);
  9876. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  9877. boundsLayout->addWidget(queriedRangePlaceholder);
  9878. QWidget*fixedRangePlaceholder= new QWidget(this);
  9879. QFormLayout*fixedRangeLayout= new QFormLayout;
  9880. QLineEdit*fixedLower= new QLineEdit;
  9881. QLineEdit*fixedUpper= new QLineEdit;
  9882. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  9883. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  9884. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  9885. boundsLayout->addWidget(fixedRangePlaceholder);
  9886. layout->addLayout(boundsLayout);
  9887. /*693:*/
  9888. #line 15275 "./typica.w"
  9889. QDomElement referenceElement=
  9890. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9891. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9892. QDomElement node;
  9893. /*:693*/
  9894. #line 16623 "./typica.w"
  9895. for(int i= 0;i<configData.size();i++)
  9896. {
  9897. node= configData.at(i).toElement();
  9898. if(node.attribute("name")=="readaddress")
  9899. {
  9900. readAddress->setValue(node.attribute("value").toInt());
  9901. }
  9902. else if(node.attribute("name")=="writeaddress")
  9903. {
  9904. writeAddress->setValue(node.attribute("value").toInt());
  9905. }
  9906. else if(node.attribute("name")=="fixedrange")
  9907. {
  9908. if(node.attribute("value")=="true")
  9909. {
  9910. fixedRange->setCheckState(Qt::Checked);
  9911. }
  9912. else if(node.attribute("value")=="false")
  9913. {
  9914. fixedRange->setCheckState(Qt::Unchecked);
  9915. }
  9916. }
  9917. else if(node.attribute("name")=="fixedlower")
  9918. {
  9919. fixedLower->setText(node.attribute("value"));
  9920. }
  9921. else if(node.attribute("name")=="fixedupper")
  9922. {
  9923. fixedUpper->setText(node.attribute("value"));
  9924. }
  9925. else if(node.attribute("name")=="loweraddress")
  9926. {
  9927. lowerAddress->setValue(node.attribute("value").toInt());
  9928. }
  9929. else if(node.attribute("name")=="upperaddress")
  9930. {
  9931. upperAddress->setValue(node.attribute("value").toInt());
  9932. }
  9933. }
  9934. updateReadAddress(readAddress->value());
  9935. updateWriteAddress(writeAddress->value());
  9936. updateFixedRange(fixedRange->isChecked());
  9937. updateLower(fixedLower->text());
  9938. updateUpper(fixedUpper->text());
  9939. updateLowerAddress(lowerAddress->value());
  9940. updateUpperAddress(upperAddress->value());
  9941. connect(readAddress,SIGNAL(valueChanged(int)),
  9942. this,SLOT(updateReadAddress(int)));
  9943. connect(writeAddress,SIGNAL(valueChanged(int)),
  9944. this,SLOT(updateWriteAddress(int)));
  9945. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  9946. connect(fixedLower,SIGNAL(textChanged(QString)),
  9947. this,SLOT(updateLower(QString)));
  9948. connect(fixedUpper,SIGNAL(textChanged(QString)),
  9949. this,SLOT(updateUpper(QString)));
  9950. connect(lowerAddress,SIGNAL(valueChanged(int)),
  9951. this,SLOT(updateLowerAddress(int)));
  9952. connect(upperAddress,SIGNAL(valueChanged(int)),
  9953. this,SLOT(updateUpperAddress(int)));
  9954. setLayout(layout);
  9955. }
  9956. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  9957. {
  9958. updateAttribute("readaddress",QString("%1").arg(newAddress));
  9959. }
  9960. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  9961. {
  9962. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  9963. }
  9964. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  9965. {
  9966. if(fixed)
  9967. {
  9968. updateAttribute("fixedrange","true");
  9969. boundsLayout->setCurrentIndex(1);
  9970. }
  9971. else
  9972. {
  9973. updateAttribute("fixedrange","false");
  9974. boundsLayout->setCurrentIndex(0);
  9975. }
  9976. }
  9977. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  9978. {
  9979. updateAttribute("fixedlower",lower);
  9980. }
  9981. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  9982. {
  9983. updateAttribute("fixedupper",upper);
  9984. }
  9985. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  9986. {
  9987. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  9988. }
  9989. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  9990. {
  9991. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  9992. }
  9993. /*:736*/
  9994. #line 829 "./typica.w"
  9995. /*692:*/
  9996. #line 15197 "./typica.w"
  9997. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9998. :BasicDeviceConfigurationWidget(model,index)
  9999. {
  10000. QVBoxLayout*layout= new QVBoxLayout;
  10001. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10002. QMenu*deviceMenu= new QMenu;
  10003. NodeInserter*insertAction;
  10004. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10005. {
  10006. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10007. this,SLOT(insertChildNode(QString,QString)));
  10008. deviceMenu->addAction(insertAction);
  10009. }
  10010. addDeviceButton->setMenu(deviceMenu);
  10011. layout->addWidget(addDeviceButton);
  10012. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10013. QMenu*annotationMenu= new QMenu;
  10014. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10015. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10016. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10017. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10018. tr("Free Text"),
  10019. "freeannotation");
  10020. annotationMenu->addAction(basicButtonInserter);
  10021. annotationMenu->addAction(countingButtonInserter);
  10022. annotationMenu->addAction(spinBoxInserter);
  10023. annotationMenu->addAction(freeAnnotationInserter);
  10024. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10025. this,SLOT(insertChildNode(QString,QString)));
  10026. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10027. this,SLOT(insertChildNode(QString,QString)));
  10028. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10029. this,SLOT(insertChildNode(QString,QString)));
  10030. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10031. this,SLOT(insertChildNode(QString,QString)));
  10032. /*879:*/
  10033. #line 144 "./valueannotation.w"
  10034. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10035. tr("Value Annotation"),
  10036. "valueannotation");
  10037. annotationMenu->addAction(valueAnnotationInserter);
  10038. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10039. this,SLOT(insertChildNode(QString,QString)));
  10040. /*:879*/
  10041. #line 15233 "./typica.w"
  10042. addAnnotationControlButton->setMenu(annotationMenu);
  10043. layout->addWidget(addAnnotationControlButton);
  10044. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10045. QMenu*advancedMenu= new QMenu;
  10046. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10047. advancedMenu->addAction(linearsplineinserter);
  10048. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10049. advancedMenu->addAction(translationinserter);
  10050. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10051. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10052. /*805:*/
  10053. #line 277 "./rate.w"
  10054. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10055. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10056. advancedMenu->addAction(rateOfChangeInserter);
  10057. /*:805*/
  10058. #line 15244 "./typica.w"
  10059. advancedButton->setMenu(advancedMenu);
  10060. layout->addWidget(advancedButton);
  10061. QHBoxLayout*idLayout= new QHBoxLayout;
  10062. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10063. idLayout->addWidget(idLabel);
  10064. QSpinBox*id= new QSpinBox;
  10065. idLayout->addWidget(id);
  10066. layout->addLayout(idLayout);
  10067. /*693:*/
  10068. #line 15275 "./typica.w"
  10069. QDomElement referenceElement=
  10070. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10071. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10072. QDomElement node;
  10073. /*:693*/
  10074. #line 15253 "./typica.w"
  10075. for(int i= 0;i<configData.size();i++)
  10076. {
  10077. node= configData.at(i).toElement();
  10078. if(node.attribute("name")=="databaseid")
  10079. {
  10080. id->setValue(node.attribute("value").toInt());
  10081. break;
  10082. }
  10083. }
  10084. updateRoasterId(id->value());
  10085. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10086. setLayout(layout);
  10087. }
  10088. /*:692*//*694:*/
  10089. #line 15285 "./typica.w"
  10090. void RoasterConfWidget::updateRoasterId(int id)
  10091. {
  10092. updateAttribute("databaseid",QString("%1").arg(id));
  10093. }
  10094. /*:694*/
  10095. #line 830 "./typica.w"
  10096. /*740:*/
  10097. #line 16773 "./typica.w"
  10098. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10099. :BasicDeviceConfigurationWidget(model,index)
  10100. {
  10101. QFormLayout*layout= new QFormLayout;
  10102. QLineEdit*buttonTextEdit= new QLineEdit;
  10103. QLineEdit*annotationTextEdit= new QLineEdit;
  10104. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10105. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10106. /*693:*/
  10107. #line 15275 "./typica.w"
  10108. QDomElement referenceElement=
  10109. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10110. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10111. QDomElement node;
  10112. /*:693*/
  10113. #line 16782 "./typica.w"
  10114. for(int i= 0;i<configData.size();i++)
  10115. {
  10116. node= configData.at(i).toElement();
  10117. if(node.attribute("name")=="buttontext")
  10118. {
  10119. buttonTextEdit->setText(node.attribute("value"));
  10120. }
  10121. else if(node.attribute("name")=="annotationtext")
  10122. {
  10123. annotationTextEdit->setText(node.attribute("value"));
  10124. }
  10125. }
  10126. updateButtonText(buttonTextEdit->text());
  10127. updateAnnotationText(annotationTextEdit->text());
  10128. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10129. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10130. setLayout(layout);
  10131. }
  10132. /*:740*//*741:*/
  10133. #line 16804 "./typica.w"
  10134. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10135. {
  10136. updateAttribute("buttontext",text);
  10137. }
  10138. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10139. {
  10140. updateAttribute("annotationtext",text);
  10141. }
  10142. /*:741*//*744:*/
  10143. #line 16842 "./typica.w"
  10144. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10145. :BasicDeviceConfigurationWidget(model,index)
  10146. {
  10147. QFormLayout*layout= new QFormLayout;
  10148. QLineEdit*buttonTextEdit= new QLineEdit;
  10149. QLineEdit*annotationTextEdit= new QLineEdit;
  10150. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10151. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10152. /*693:*/
  10153. #line 15275 "./typica.w"
  10154. QDomElement referenceElement=
  10155. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10156. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10157. QDomElement node;
  10158. /*:693*/
  10159. #line 16851 "./typica.w"
  10160. for(int i= 0;i<configData.size();i++)
  10161. {
  10162. node= configData.at(i).toElement();
  10163. if(node.attribute("name")=="buttontext")
  10164. {
  10165. buttonTextEdit->setText(node.attribute("value"));
  10166. }
  10167. else if(node.attribute("name")=="annotationtext")
  10168. {
  10169. annotationTextEdit->setText(node.attribute("value"));
  10170. }
  10171. }
  10172. updateButtonText(buttonTextEdit->text());
  10173. updateAnnotationText(annotationTextEdit->text());
  10174. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10175. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10176. QTextEdit*documentation= new QTextEdit;
  10177. 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."));
  10178. documentation->setReadOnly(true);
  10179. layout->addRow("",documentation);
  10180. setLayout(layout);
  10181. }
  10182. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10183. {
  10184. updateAttribute("buttontext",text);
  10185. }
  10186. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10187. {
  10188. updateAttribute("annotationtext",text);
  10189. }
  10190. /*:744*/
  10191. #line 831 "./typica.w"
  10192. /*747:*/
  10193. #line 16919 "./typica.w"
  10194. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10195. :BasicDeviceConfigurationWidget(model,index)
  10196. {
  10197. QFormLayout*layout= new QFormLayout;
  10198. QLineEdit*labelEdit= new QLineEdit;
  10199. layout->addRow(tr("Control Label: "),labelEdit);
  10200. QLineEdit*minimumEdit= new QLineEdit;
  10201. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10202. QLineEdit*maximumEdit= new QLineEdit;
  10203. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10204. QSpinBox*precisionEdit= new QSpinBox;
  10205. precisionEdit->setMinimum(0);
  10206. precisionEdit->setMaximum(9);
  10207. layout->addRow(tr("Precision"),precisionEdit);
  10208. QLineEdit*pretext= new QLineEdit;
  10209. layout->addRow(tr("Prefix text"),pretext);
  10210. QLineEdit*posttext= new QLineEdit;
  10211. layout->addRow(tr("Suffix text"),posttext);
  10212. /*693:*/
  10213. #line 15275 "./typica.w"
  10214. QDomElement referenceElement=
  10215. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10216. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10217. QDomElement node;
  10218. /*:693*/
  10219. #line 16938 "./typica.w"
  10220. for(int i= 0;i<configData.size();i++)
  10221. {
  10222. node= configData.at(i).toElement();
  10223. if(node.attribute("name")=="label")
  10224. {
  10225. labelEdit->setText(node.attribute("value"));
  10226. }
  10227. else if(node.attribute("name")=="minimum")
  10228. {
  10229. minimumEdit->setText(node.attribute("value"));
  10230. }
  10231. else if(node.attribute("name")=="maximum")
  10232. {
  10233. maximumEdit->setText(node.attribute("value"));
  10234. }
  10235. else if(node.attribute("name")=="precision")
  10236. {
  10237. precisionEdit->setValue(node.attribute("value").toInt());
  10238. }
  10239. else if(node.attribute("name")=="pretext")
  10240. {
  10241. pretext->setText(node.attribute("value"));
  10242. }
  10243. else if(node.attribute("name")=="posttext")
  10244. {
  10245. posttext->setText(node.attribute("value"));
  10246. }
  10247. }
  10248. updateLabel(labelEdit->text());
  10249. updateMinimum(minimumEdit->text());
  10250. updateMaximum(maximumEdit->text());
  10251. updatePrecision(precisionEdit->value());
  10252. updatePretext(pretext->text());
  10253. updatePosttext(posttext->text());
  10254. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10255. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10256. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10257. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10258. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10259. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10260. setLayout(layout);
  10261. }
  10262. void NoteSpinConfWidget::updateLabel(const QString&text)
  10263. {
  10264. updateAttribute("label",text);
  10265. }
  10266. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10267. {
  10268. updateAttribute("minimum",minimum);
  10269. }
  10270. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10271. {
  10272. updateAttribute("maximum",maximum);
  10273. }
  10274. void NoteSpinConfWidget::updatePrecision(int precision)
  10275. {
  10276. updateAttribute("precision",QString("%1").arg(precision));
  10277. }
  10278. void NoteSpinConfWidget::updatePretext(const QString&text)
  10279. {
  10280. updateAttribute("pretext",text);
  10281. }
  10282. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10283. {
  10284. updateAttribute("posttext",text);
  10285. }
  10286. /*:747*/
  10287. #line 832 "./typica.w"
  10288. /*284:*/
  10289. #line 6723 "./typica.w"
  10290. LinearCalibrator::LinearCalibrator(QObject*parent):
  10291. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10292. {
  10293. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10294. }
  10295. /*:284*//*285:*/
  10296. #line 6737 "./typica.w"
  10297. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10298. {
  10299. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10300. if(clamp)
  10301. {
  10302. if(outval<Lo1)
  10303. {
  10304. outval= Lo1;
  10305. }
  10306. else if(outval> Up1)
  10307. {
  10308. outval= Up1;
  10309. }
  10310. }
  10311. if(sensitivitySetting>=0.05)
  10312. {
  10313. int temp= qRound(outval/sensitivitySetting);
  10314. outval= temp*sensitivitySetting;
  10315. }
  10316. Measurement adjusted(outval,measure.time(),measure.scale());
  10317. emit measurement(adjusted);
  10318. return adjusted;
  10319. }
  10320. /*:285*//*286:*/
  10321. #line 6764 "./typica.w"
  10322. double LinearCalibrator::measuredLower()
  10323. {
  10324. return Lo2;
  10325. }
  10326. double LinearCalibrator::measuredUpper()
  10327. {
  10328. return Up2;
  10329. }
  10330. double LinearCalibrator::mappedLower()
  10331. {
  10332. return Lo1;
  10333. }
  10334. double LinearCalibrator::mappedUpper()
  10335. {
  10336. return Up1;
  10337. }
  10338. bool LinearCalibrator::isClosedRange()
  10339. {
  10340. return clamp;
  10341. }
  10342. void LinearCalibrator::setMeasuredLower(double lower)
  10343. {
  10344. Lo2= lower;
  10345. }
  10346. void LinearCalibrator::setMeasuredUpper(double upper)
  10347. {
  10348. Up2= upper;
  10349. }
  10350. void LinearCalibrator::setMappedLower(double lower)
  10351. {
  10352. Lo1= lower;
  10353. }
  10354. void LinearCalibrator::setMappedUpper(double upper)
  10355. {
  10356. Up1= upper;
  10357. }
  10358. void LinearCalibrator::setClosedRange(bool closed)
  10359. {
  10360. clamp= closed;
  10361. }
  10362. void LinearCalibrator::setSensitivity(double sensitivity)
  10363. {
  10364. sensitivitySetting= sensitivity;
  10365. }
  10366. double LinearCalibrator::sensitivity()
  10367. {
  10368. return sensitivitySetting;
  10369. }
  10370. /*:286*/
  10371. #line 833 "./typica.w"
  10372. /*291:*/
  10373. #line 6897 "./typica.w"
  10374. void LinearSplineInterpolator::add_pair(double source,double destination)
  10375. {
  10376. pairs->insert(source,destination);
  10377. make_interpolators();
  10378. }
  10379. void LinearSplineInterpolator::make_interpolators()
  10380. {
  10381. if(pairs->size()> 1)
  10382. {
  10383. while(interpolators->size()> 0)
  10384. {
  10385. LinearCalibrator*removed= interpolators->takeFirst();
  10386. removed->deleteLater();
  10387. }
  10388. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10389. QMap<double,double> ::const_iterator j= i+1;
  10390. while(j!=pairs->constEnd())
  10391. {
  10392. LinearCalibrator*segment= new LinearCalibrator();
  10393. segment->setMeasuredLower(i.key());
  10394. segment->setMappedLower(i.value());
  10395. segment->setMeasuredUpper(j.key());
  10396. segment->setMappedUpper(j.value());
  10397. segment->setClosedRange(false);
  10398. interpolators->append(segment);
  10399. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10400. i++;
  10401. j++;
  10402. }
  10403. }
  10404. }
  10405. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  10406. QObject(parent),pairs(new QMap<double,double> ),
  10407. interpolators(new QList<LinearCalibrator*> )
  10408. {
  10409. }
  10410. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  10411. {
  10412. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10413. int index= -1;
  10414. while(i!=pairs->constEnd())
  10415. {
  10416. if(measure.temperature()<=i.key())
  10417. {
  10418. break;
  10419. }
  10420. i++;
  10421. index++;
  10422. }
  10423. if(index<0)
  10424. {
  10425. index= 0;
  10426. }
  10427. if(index>=interpolators->size())
  10428. {
  10429. index= interpolators->size()-1;
  10430. }
  10431. if(interpolators->at(index)!=NULL)
  10432. {
  10433. return interpolators->at(index)->newMeasurement(measure);
  10434. }
  10435. return Measurement();
  10436. }
  10437. /*:291*/
  10438. #line 834 "./typica.w"
  10439. /*784:*/
  10440. #line 18252 "./typica.w"
  10441. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10442. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  10443. {
  10444. QFormLayout*layout= new QFormLayout;
  10445. QLineEdit*source= new QLineEdit;
  10446. layout->addRow(tr("Source column name:"),source);
  10447. QLineEdit*destination= new QLineEdit;
  10448. layout->addRow(tr("Destination column name:"),destination);
  10449. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  10450. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  10451. QTableView*mappingTable= new QTableView;
  10452. mappingTable->setModel(tablemodel);
  10453. NumericDelegate*delegate= new NumericDelegate;
  10454. mappingTable->setItemDelegate(delegate);
  10455. layout->addRow(tr("Mapping data:"),mappingTable);
  10456. /*693:*/
  10457. #line 15275 "./typica.w"
  10458. QDomElement referenceElement=
  10459. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10460. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10461. QDomElement node;
  10462. /*:693*/
  10463. #line 18268 "./typica.w"
  10464. for(int i= 0;i<configData.size();i++)
  10465. {
  10466. node= configData.at(i).toElement();
  10467. if(node.attribute("name")=="source")
  10468. {
  10469. source->setText(node.attribute("value"));
  10470. }
  10471. else if(node.attribute("name")=="destination")
  10472. {
  10473. destination->setText(node.attribute("value"));
  10474. }
  10475. else if(node.attribute("name")=="sourcevalues")
  10476. {
  10477. /*785:*/
  10478. #line 18307 "./typica.w"
  10479. QString data= node.attribute("value");
  10480. if(data.length()> 3)
  10481. {
  10482. data.chop(2);
  10483. data= data.remove(0,2);
  10484. }
  10485. QStringList itemList= data.split(",");
  10486. /*:785*/
  10487. #line 18282 "./typica.w"
  10488. int column= 0;
  10489. /*786:*/
  10490. #line 18319 "./typica.w"
  10491. for(int i= 0;i<itemList.size();i++)
  10492. {
  10493. tablemodel->setData(tablemodel->index(i,column),
  10494. QVariant(itemList.at(i).toDouble()),
  10495. Qt::DisplayRole);
  10496. }
  10497. /*:786*/
  10498. #line 18284 "./typica.w"
  10499. }
  10500. else if(node.attribute("name")=="destinationvalues")
  10501. {
  10502. /*785:*/
  10503. #line 18307 "./typica.w"
  10504. QString data= node.attribute("value");
  10505. if(data.length()> 3)
  10506. {
  10507. data.chop(2);
  10508. data= data.remove(0,2);
  10509. }
  10510. QStringList itemList= data.split(",");
  10511. /*:785*/
  10512. #line 18289 "./typica.w"
  10513. int column= 1;
  10514. /*786:*/
  10515. #line 18319 "./typica.w"
  10516. for(int i= 0;i<itemList.size();i++)
  10517. {
  10518. tablemodel->setData(tablemodel->index(i,column),
  10519. QVariant(itemList.at(i).toDouble()),
  10520. Qt::DisplayRole);
  10521. }
  10522. /*:786*/
  10523. #line 18291 "./typica.w"
  10524. }
  10525. }
  10526. updateSourceColumn(source->text());
  10527. updateDestinationColumn(destination->text());
  10528. updateKnots();
  10529. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  10530. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  10531. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  10532. setLayout(layout);
  10533. }
  10534. /*:784*//*787:*/
  10535. #line 18330 "./typica.w"
  10536. void LinearSplineInterpolationConfWidget::updateKnots()
  10537. {
  10538. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  10539. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  10540. }
  10541. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  10542. {
  10543. updateAttribute("source",source);
  10544. }
  10545. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  10546. {
  10547. updateAttribute("destination",dest);
  10548. }
  10549. /*:787*/
  10550. #line 835 "./typica.w"
  10551. /*790:*/
  10552. #line 18373 "./typica.w"
  10553. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10554. :BasicDeviceConfigurationWidget(model,index),
  10555. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  10556. {
  10557. unitSelector->addItem("Fahrenheit");
  10558. unitSelector->addItem("Celsius");
  10559. temperatureValue->setMinimum(0);
  10560. temperatureValue->setMaximum(1000);
  10561. QFormLayout*layout= new QFormLayout;
  10562. QLineEdit*column= new QLineEdit;
  10563. layout->addRow(tr("Column to match:"),column);
  10564. layout->addRow(tr("Unit:"),unitSelector);
  10565. layout->addRow(tr("Value:"),temperatureValue);
  10566. /*693:*/
  10567. #line 15275 "./typica.w"
  10568. QDomElement referenceElement=
  10569. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10570. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10571. QDomElement node;
  10572. /*:693*/
  10573. #line 18387 "./typica.w"
  10574. for(int i= 0;i<configData.size();i++)
  10575. {
  10576. node= configData.at(i).toElement();
  10577. if(node.attribute("name")=="column")
  10578. {
  10579. column->setText(node.attribute("value"));
  10580. }
  10581. else if(node.attribute("name")=="unit")
  10582. {
  10583. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  10584. }
  10585. else if(node.attribute("name")=="value")
  10586. {
  10587. temperatureValue->setValue(node.attribute("value").toDouble());
  10588. }
  10589. }
  10590. updateMatchingColumn(column->text());
  10591. updateTemperature();
  10592. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  10593. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  10594. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  10595. setLayout(layout);
  10596. }
  10597. /*:790*//*791:*/
  10598. #line 18416 "./typica.w"
  10599. void TranslationConfWidget::updateTemperature()
  10600. {
  10601. updateAttribute("unit",unitSelector->currentText());
  10602. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  10603. if(unitSelector->currentText()=="Fahrenheit")
  10604. {
  10605. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  10606. }
  10607. else
  10608. {
  10609. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  10610. }
  10611. }
  10612. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  10613. {
  10614. updateAttribute("column",column);
  10615. }
  10616. /*:791*/
  10617. #line 836 "./typica.w"
  10618. /*750:*/
  10619. #line 24 "./freeannotation.w"
  10620. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  10621. const QModelIndex&index)
  10622. :BasicDeviceConfigurationWidget(model,index)
  10623. {
  10624. QFormLayout*layout= new QFormLayout;
  10625. QLineEdit*labelEdit= new QLineEdit;
  10626. layout->addRow(tr("Label Text:"),labelEdit);
  10627. /*693:*/
  10628. #line 15275 "./typica.w"
  10629. QDomElement referenceElement=
  10630. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10631. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10632. QDomElement node;
  10633. /*:693*/
  10634. #line 32 "./freeannotation.w"
  10635. for(int i= 0;i<configData.size();i++)
  10636. {
  10637. node= configData.at(i).toElement();
  10638. if(node.attribute("name")=="labeltext")
  10639. {
  10640. labelEdit->setText(node.attribute("value"));
  10641. }
  10642. }
  10643. updateLabel(labelEdit->text());
  10644. connect(labelEdit,SIGNAL(textEdited(QString)),
  10645. this,SLOT(updateLabel(QString)));
  10646. setLayout(layout);
  10647. }
  10648. /*:750*//*751:*/
  10649. #line 49 "./freeannotation.w"
  10650. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  10651. {
  10652. updateAttribute("labeltext",text);
  10653. }
  10654. /*:751*/
  10655. #line 837 "./typica.w"
  10656. /*794:*/
  10657. #line 40 "./rate.w"
  10658. void RateOfChange::newMeasurement(Measurement measure)
  10659. {
  10660. cache.append(measure);
  10661. /*795:*/
  10662. #line 65 "./rate.w"
  10663. if(cache.size()> 2)
  10664. {
  10665. bool done= false;
  10666. while(!done)
  10667. {
  10668. if(cache.front().time().secsTo(cache.back().time())> ct)
  10669. {
  10670. cache.removeFirst();
  10671. }
  10672. else if(cache.back().time()<cache.front().time())
  10673. {
  10674. cache.removeFirst();
  10675. done= true;
  10676. }
  10677. else
  10678. {
  10679. done= true;
  10680. }
  10681. if(cache.size()<3)
  10682. {
  10683. done= true;
  10684. }
  10685. }
  10686. }
  10687. /*:795*/
  10688. #line 44 "./rate.w"
  10689. if(cache.size()>=2)
  10690. {
  10691. /*796:*/
  10692. #line 100 "./rate.w"
  10693. QList<double> rates;
  10694. for(int i= 1;i<cache.size();i++)
  10695. {
  10696. double mdiff= cache.at(i).temperature()-cache.at(i-1).temperature();
  10697. double tdiff= (double)(cache.at(i-1).time().msecsTo(cache.at(i).time()))/1000.0;
  10698. rates.append(mdiff/tdiff);
  10699. }
  10700. double acc= 0.0;
  10701. for(int i= 0;i<rates.size();i++)
  10702. {
  10703. acc+= rates.at(i);
  10704. }
  10705. double pavg= acc/= rates.size();
  10706. double v2= pavg*st;
  10707. double refm= cache.back().temperature()-cache.front().temperature();
  10708. double reft= (double)(cache.front().time().msecsTo(cache.back().time()))/1000.0;
  10709. double ref= refm/reft;
  10710. Measurement value(v2,cache.back().time(),cache.back().scale());
  10711. value.insert("relative",true);
  10712. emit newData(value);
  10713. double calcdiff= ref-pavg;
  10714. if(calcdiff<0)
  10715. {
  10716. calcdiff= -calcdiff;
  10717. }
  10718. if(pavg<0)
  10719. {
  10720. pavg= -pavg;
  10721. }
  10722. if(calcdiff> (pavg*0.2))
  10723. {
  10724. Measurement save= cache.back();
  10725. cache.clear();
  10726. cache.append(save);
  10727. }
  10728. /*:796*/
  10729. #line 47 "./rate.w"
  10730. }
  10731. }
  10732. /*:794*//*797:*/
  10733. #line 139 "./rate.w"
  10734. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  10735. {
  10736. setScaleTime(scaletime);
  10737. }
  10738. void RateOfChange::setCacheTime(int seconds)
  10739. {
  10740. ct= seconds;
  10741. }
  10742. void RateOfChange::setScaleTime(int seconds)
  10743. {
  10744. st= (seconds> 0?seconds:1);
  10745. }
  10746. /*:797*/
  10747. #line 838 "./typica.w"
  10748. /*754:*/
  10749. #line 23 "./settings.w"
  10750. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  10751. {
  10752. QTabWidget*settingsTab= new QTabWidget;
  10753. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  10754. settingsTab->addTab(deviceSettings,tr("Roasters"));
  10755. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  10756. settingsTab->addTab(graphSettings,tr("Graph"));
  10757. setCentralWidget(settingsTab);
  10758. }
  10759. /*:754*/
  10760. #line 839 "./typica.w"
  10761. /*759:*/
  10762. #line 25 "./graphsettings.w"
  10763. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  10764. {
  10765. QTabWidget*graphCategories= new QTabWidget;
  10766. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  10767. graphCategories->addTab(relative,tr("Relative Temperatures"));
  10768. QVBoxLayout*layout= new QVBoxLayout;
  10769. layout->addWidget(graphCategories);
  10770. setLayout(layout);
  10771. }
  10772. /*:759*//*761:*/
  10773. #line 63 "./graphsettings.w"
  10774. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  10775. colorEdit(new QLineEdit)
  10776. {
  10777. QSettings settings;
  10778. QVBoxLayout*layout= new QVBoxLayout;
  10779. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  10780. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  10781. updateEnableSetting(enable->isChecked());
  10782. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  10783. layout->addWidget(enable);
  10784. QHBoxLayout*colorLayout= new QHBoxLayout;
  10785. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  10786. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  10787. updateColorSetting(colorEdit->text());
  10788. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  10789. QToolButton*colorPickerButton= new QToolButton();
  10790. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  10791. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  10792. colorLayout->addWidget(colorLabel);
  10793. colorLayout->addWidget(colorEdit);
  10794. colorLayout->addWidget(colorPickerButton);
  10795. colorLayout->addStretch();
  10796. layout->addLayout(colorLayout);
  10797. QHBoxLayout*unitLayout= new QHBoxLayout;
  10798. QLabel*unitLabel= new QLabel(tr("Unit"));
  10799. QComboBox*unitSelector= new QComboBox;
  10800. unitSelector->addItem(tr("Fahrenheit"));
  10801. unitSelector->addItem(tr("Celsius"));
  10802. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  10803. updateUnit(unitSelector->currentIndex());
  10804. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  10805. unitLayout->addWidget(unitLabel);
  10806. unitLayout->addWidget(unitSelector);
  10807. unitLayout->addStretch();
  10808. layout->addLayout(unitLayout);
  10809. QHBoxLayout*axisLayout= new QHBoxLayout;
  10810. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  10811. QLineEdit*axisEdit= new QLineEdit;
  10812. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  10813. updateAxisSetting(axisEdit->text());
  10814. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  10815. axisLayout->addWidget(axisLabel);
  10816. axisLayout->addWidget(axisEdit);
  10817. layout->addLayout(axisLayout);
  10818. layout->addStretch();
  10819. setLayout(layout);
  10820. }
  10821. /*:761*//*762:*/
  10822. #line 114 "./graphsettings.w"
  10823. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  10824. {
  10825. QSettings settings;
  10826. settings.setValue("settings/graph/relative/enable",enabled);
  10827. }
  10828. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  10829. {
  10830. QSettings settings;
  10831. settings.setValue("settings/graph/relative/color",color);
  10832. }
  10833. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  10834. {
  10835. QSettings settings;
  10836. QString settingValue;
  10837. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  10838. QStringList numbers;
  10839. foreach(QString text,points)
  10840. {
  10841. bool okay= false;
  10842. text.toDouble(&okay);
  10843. if(okay)
  10844. {
  10845. numbers.append(text);
  10846. }
  10847. }
  10848. numbers.removeDuplicates();
  10849. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  10850. }
  10851. void GraphSettingsRelativeTab::updateUnit(int unit)
  10852. {
  10853. QSettings settings;
  10854. settings.setValue("settings/graph/relative/unit",unit);
  10855. }
  10856. /*:762*//*763:*/
  10857. #line 157 "./graphsettings.w"
  10858. void GraphSettingsRelativeTab::showColorPicker()
  10859. {
  10860. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  10861. colorEdit->setText(color.name());
  10862. }
  10863. #line 17020 "./typica.w"
  10864. /*:763*/
  10865. #line 840 "./typica.w"
  10866. /*829:*/
  10867. #line 682 "./dataqsdk.w"
  10868. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  10869. const QModelIndex&index)
  10870. :BasicDeviceConfigurationWidget(model,index),
  10871. deviceIdStack(new QStackedWidget)
  10872. {
  10873. QVBoxLayout*layout= new QVBoxLayout;
  10874. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  10875. layout->addWidget(autoDetect);
  10876. QWidget*autoLayerWidget= new QWidget;
  10877. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  10878. QLabel*autoLabel= new QLabel(tr("Device number"));
  10879. QSpinBox*autoNumber= new QSpinBox;
  10880. autoNumber->setMinimum(1);
  10881. autoNumber->setMaximum(99);
  10882. autoLayerLayout->addWidget(autoLabel);
  10883. autoLayerLayout->addWidget(autoNumber);
  10884. autoLayerWidget->setLayout(autoLayerLayout);
  10885. QWidget*fixedLayerWidget= new QWidget;
  10886. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  10887. QLabel*fixedLabel= new QLabel(tr("Device port"));
  10888. QComboBox*portSelection= new QComboBox;
  10889. portSelection->setEditable(true);
  10890. portSelection->addItems(DataqSdkDevice::detectHardware());
  10891. fixedLayerLayout->addWidget(fixedLabel);
  10892. fixedLayerLayout->addWidget(portSelection);
  10893. fixedLayerWidget->setLayout(fixedLayerLayout);
  10894. deviceIdStack->addWidget(autoLayerWidget);
  10895. deviceIdStack->addWidget(fixedLayerWidget);
  10896. layout->addWidget(deviceIdStack);
  10897. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10898. layout->addWidget(addChannelButton);
  10899. /*693:*/
  10900. #line 15275 "./typica.w"
  10901. QDomElement referenceElement=
  10902. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10903. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10904. QDomElement node;
  10905. /*:693*/
  10906. #line 714 "./dataqsdk.w"
  10907. for(int i= 0;i<configData.size();i++)
  10908. {
  10909. node= configData.at(i).toElement();
  10910. if(node.attribute("name")=="autoSelect")
  10911. {
  10912. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  10913. }
  10914. else if(node.attribute("name")=="deviceNumber")
  10915. {
  10916. autoNumber->setValue(node.attribute("value").toInt());
  10917. }
  10918. else if(node.attribute("name")=="port")
  10919. {
  10920. int index= portSelection->findText(node.attribute("value"));
  10921. if(index> -1)
  10922. {
  10923. portSelection->setCurrentIndex(index);
  10924. }
  10925. else
  10926. {
  10927. portSelection->setEditText(node.attribute("value"));
  10928. }
  10929. }
  10930. }
  10931. updateAutoSelect(autoDetect->isChecked());
  10932. updateDeviceNumber(autoNumber->value());
  10933. updatePort(portSelection->currentText());
  10934. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  10935. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  10936. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  10937. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10938. setLayout(layout);
  10939. }
  10940. /*:829*//*830:*/
  10941. #line 758 "./dataqsdk.w"
  10942. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  10943. {
  10944. if(automatic)
  10945. {
  10946. updateAttribute("autoSelect","true");
  10947. deviceIdStack->setCurrentIndex(0);
  10948. }
  10949. else
  10950. {
  10951. updateAttribute("autoSelect","false");
  10952. deviceIdStack->setCurrentIndex(1);
  10953. }
  10954. }
  10955. /*:830*//*831:*/
  10956. #line 775 "./dataqsdk.w"
  10957. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  10958. {
  10959. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  10960. }
  10961. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  10962. {
  10963. updateAttribute("port",portId);
  10964. }
  10965. /*:831*//*832:*/
  10966. #line 788 "./dataqsdk.w"
  10967. void DataqSdkDeviceConfWidget::addChannel()
  10968. {
  10969. insertChildNode(tr("Channel"),"dataqsdkchannel");
  10970. }
  10971. /*:832*//*835:*/
  10972. #line 868 "./dataqsdk.w"
  10973. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  10974. const QModelIndex&index)
  10975. :BasicDeviceConfigurationWidget(model,index),
  10976. startButton(new QPushButton(tr("Start"))),
  10977. resetButton(new QPushButton(tr("Reset"))),
  10978. stopButton(new QPushButton(tr("Stop"))),
  10979. calibrator(new LinearCalibrator),
  10980. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  10981. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  10982. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  10983. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  10984. rmCount(0),cmCount(0),
  10985. rmin(std::numeric_limits<double> ::max()),
  10986. rmax(std::numeric_limits<double> ::min()),rmean(0),
  10987. cmin(std::numeric_limits<double> ::max()),
  10988. cmax(std::numeric_limits<double> ::min()),cmean(0)
  10989. {
  10990. /*839:*/
  10991. #line 1107 "./dataqsdk.w"
  10992. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  10993. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  10994. QDomElement deviceNode;
  10995. QString configPort;
  10996. QString configAuto;
  10997. for(int i= 0;i<deviceConfigData.size();i++)
  10998. {
  10999. deviceNode= deviceConfigData.at(i).toElement();
  11000. if(deviceNode.attribute("name")=="autoSelect")
  11001. {
  11002. autoSelect= (deviceNode.attribute("value")=="true");
  11003. }
  11004. else if(deviceNode.attribute("name")=="deviceNumber")
  11005. {
  11006. configAuto= deviceNode.attribute("value");
  11007. }
  11008. else if(deviceNode.attribute("name")=="port")
  11009. {
  11010. configPort= deviceNode.attribute("value");
  11011. }
  11012. }
  11013. deviceID= autoSelect?configAuto:configPort;
  11014. channelOfInterest= index.row();
  11015. /*:839*/
  11016. #line 886 "./dataqsdk.w"
  11017. resetButton->setEnabled(false);
  11018. stopButton->setEnabled(false);
  11019. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11020. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11021. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11022. QVBoxLayout*layout= new QVBoxLayout;
  11023. QFormLayout*topLayout= new QFormLayout;
  11024. QLineEdit*columnEdit= new QLineEdit;
  11025. topLayout->addRow(tr("Column name"),columnEdit);
  11026. QComboBox*unitSelector= new QComboBox;
  11027. unitSelector->addItem(tr("Temperature"));
  11028. unitSelector->addItem(tr("Control"));
  11029. topLayout->addRow(tr("Measurement type"),unitSelector);
  11030. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11031. topLayout->addRow(smoothingBox);
  11032. layout->addLayout(topLayout);
  11033. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11034. topLayout->addRow(hideSeries);
  11035. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11036. layout->addWidget(calibrationLabel);
  11037. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11038. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11039. QLineEdit*measuredLowerEdit= new QLineEdit;
  11040. measuredLowerEdit->setText("0");
  11041. QLineEdit*measuredUpperEdit= new QLineEdit;
  11042. measuredUpperEdit->setText("10");
  11043. QLineEdit*mappedLowerEdit= new QLineEdit;
  11044. mappedLowerEdit->setText("0");
  11045. QLineEdit*mappedUpperEdit= new QLineEdit;
  11046. mappedUpperEdit->setText("10");
  11047. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11048. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11049. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11050. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11051. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11052. calibrationControlsLayout->addRow(closedBox);
  11053. QLineEdit*sensitivityEdit= new QLineEdit;
  11054. sensitivityEdit->setText("0");
  11055. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11056. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11057. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11058. deviceControlLayout->addWidget(startButton);
  11059. deviceControlLayout->addWidget(resetButton);
  11060. deviceControlLayout->addWidget(stopButton);
  11061. QFormLayout*indicatorLayout= new QFormLayout;
  11062. currentMeasurement->setReadOnly(true);
  11063. minimumMeasurement->setReadOnly(true);
  11064. maximumMeasurement->setReadOnly(true);
  11065. averageMeasurement->setReadOnly(true);
  11066. currentMapped->setReadOnly(true);
  11067. minimumMapped->setReadOnly(true);
  11068. maximumMapped->setReadOnly(true);
  11069. averageMapped->setReadOnly(true);
  11070. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11071. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11072. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11073. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11074. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11075. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11076. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11077. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11078. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11079. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11080. calibrationTestLayout->addLayout(deviceControlLayout);
  11081. calibrationTestLayout->addLayout(indicatorLayout);
  11082. calibrationLayout->addLayout(calibrationControlsLayout);
  11083. calibrationLayout->addLayout(calibrationTestLayout);
  11084. layout->addLayout(calibrationLayout);
  11085. /*693:*/
  11086. #line 15275 "./typica.w"
  11087. QDomElement referenceElement=
  11088. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11089. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11090. QDomElement node;
  11091. /*:693*/
  11092. #line 955 "./dataqsdk.w"
  11093. for(int i= 0;i<configData.size();i++)
  11094. {
  11095. node= configData.at(i).toElement();
  11096. if(node.attribute("name")=="column")
  11097. {
  11098. columnEdit->setText(node.attribute("value"));
  11099. }
  11100. else if(node.attribute("name")=="type")
  11101. {
  11102. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11103. }
  11104. else if(node.attribute("name")=="smoothing")
  11105. {
  11106. smoothingBox->setChecked(node.attribute("value")=="true");
  11107. }
  11108. else if(node.attribute("name")=="calibrationMeasuredLower")
  11109. {
  11110. measuredLowerEdit->setText(node.attribute("value"));
  11111. }
  11112. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11113. {
  11114. measuredUpperEdit->setText(node.attribute("value"));
  11115. }
  11116. else if(node.attribute("name")=="calibrationMappedLower")
  11117. {
  11118. mappedLowerEdit->setText(node.attribute("value"));
  11119. }
  11120. else if(node.attribute("name")=="calibrationMappedUpper")
  11121. {
  11122. mappedUpperEdit->setText(node.attribute("value"));
  11123. }
  11124. else if(node.attribute("name")=="calibrationClosedInterval")
  11125. {
  11126. closedBox->setChecked(node.attribute("value")=="true");
  11127. }
  11128. else if(node.attribute("name")=="calibrationSensitivity")
  11129. {
  11130. sensitivityEdit->setText(node.attribute("value"));
  11131. }
  11132. else if(node.attribute("name")=="hidden")
  11133. {
  11134. hideSeries->setChecked(node.attribute("value")=="true");
  11135. }
  11136. }
  11137. updateColumnName(columnEdit->text());
  11138. updateUnits(unitSelector->currentText());
  11139. updateSmoothingEnabled(smoothingBox->isChecked());
  11140. updateMeasuredLower(measuredLowerEdit->text());
  11141. updateMeasuredUpper(measuredUpperEdit->text());
  11142. updateMappedLower(mappedLowerEdit->text());
  11143. updateMappedUpper(mappedUpperEdit->text());
  11144. updateClosedInterval(closedBox->isChecked());
  11145. updateSensitivity(sensitivityEdit->text());
  11146. updateHidden(hideSeries->isChecked());
  11147. connect(columnEdit,SIGNAL(textChanged(QString)),
  11148. this,SLOT(updateColumnName(QString)));
  11149. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11150. this,SLOT(updateUnits(QString)));
  11151. connect(smoothingBox,SIGNAL(toggled(bool)),
  11152. this,SLOT(updateSmoothingEnabled(bool)));
  11153. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11154. this,SLOT(updateMeasuredLower(QString)));
  11155. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11156. this,SLOT(updateMappedLower(QString)));
  11157. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11158. this,SLOT(updateMeasuredUpper(QString)));
  11159. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11160. this,SLOT(updateMappedUpper(QString)));
  11161. connect(closedBox,SIGNAL(toggled(bool)),
  11162. this,SLOT(updateClosedInterval(bool)));
  11163. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11164. this,SLOT(updateSensitivity(QString)));
  11165. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11166. setLayout(layout);
  11167. }
  11168. /*:835*//*836:*/
  11169. #line 1038 "./dataqsdk.w"
  11170. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11171. {
  11172. updateAttribute("type",unit);
  11173. }
  11174. /*:836*//*837:*/
  11175. #line 1047 "./dataqsdk.w"
  11176. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11177. {
  11178. updateAttribute("calibrationMeasuredLower",value);
  11179. calibrator->setMeasuredLower(value.toDouble());
  11180. }
  11181. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11182. {
  11183. updateAttribute("calibrationMeasuredUpper",value);
  11184. calibrator->setMeasuredUpper(value.toDouble());
  11185. }
  11186. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11187. {
  11188. updateAttribute("calibrationMappedLower",value);
  11189. calibrator->setMappedLower(value.toDouble());
  11190. }
  11191. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11192. {
  11193. updateAttribute("calibrationMappedUpper",value);
  11194. calibrator->setMappedUpper(value.toDouble());
  11195. }
  11196. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11197. {
  11198. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11199. calibrator->setClosedRange(closed);
  11200. }
  11201. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11202. {
  11203. updateAttribute("smoothing",enabled?"true":"false");
  11204. }
  11205. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11206. {
  11207. updateAttribute("calibrationSensitivity",value);
  11208. calibrator->setSensitivity(value.toDouble());
  11209. }
  11210. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11211. {
  11212. updateAttribute("hidden",hidden?"true":"false");
  11213. }
  11214. /*:837*//*840:*/
  11215. #line 1136 "./dataqsdk.w"
  11216. void DataqSdkChannelConfWidget::startCalibration()
  11217. {
  11218. startButton->setEnabled(false);
  11219. stopButton->setEnabled(true);
  11220. resetButton->setEnabled(true);
  11221. calibrationDevice= new DataqSdkDevice(deviceID);
  11222. Channel*channel;
  11223. for(int i= 0;i<=channelOfInterest;i++)
  11224. {
  11225. channel= calibrationDevice->newChannel(Units::Unitless);
  11226. }
  11227. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11228. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11229. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11230. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11231. calibrationDevice->start();
  11232. }
  11233. void DataqSdkChannelConfWidget::stopCalibration()
  11234. {
  11235. startButton->setEnabled(true);
  11236. stopButton->setEnabled(false);
  11237. resetButton->setEnabled(false);
  11238. calibrationDevice->deleteLater();
  11239. /*842:*/
  11240. #line 1181 "./dataqsdk.w"
  11241. rmCount= 0;
  11242. cmCount= 0;
  11243. rmin= std::numeric_limits<double> ::max();
  11244. rmax= std::numeric_limits<double> ::min();
  11245. rmean= 0;
  11246. cmin= std::numeric_limits<double> ::max();
  11247. cmax= std::numeric_limits<double> ::min();
  11248. cmean= 0;
  11249. /*:842*/
  11250. #line 1161 "./dataqsdk.w"
  11251. }
  11252. /*:840*//*841:*/
  11253. #line 1172 "./dataqsdk.w"
  11254. void DataqSdkChannelConfWidget::resetCalibration()
  11255. {
  11256. /*842:*/
  11257. #line 1181 "./dataqsdk.w"
  11258. rmCount= 0;
  11259. cmCount= 0;
  11260. rmin= std::numeric_limits<double> ::max();
  11261. rmax= std::numeric_limits<double> ::min();
  11262. rmean= 0;
  11263. cmin= std::numeric_limits<double> ::max();
  11264. cmax= std::numeric_limits<double> ::min();
  11265. cmean= 0;
  11266. /*:842*/
  11267. #line 1175 "./dataqsdk.w"
  11268. }
  11269. /*:841*//*843:*/
  11270. #line 1195 "./dataqsdk.w"
  11271. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11272. {
  11273. double nv= measure.temperature();
  11274. currentMeasurement->setText(QString("%1").arg(nv));
  11275. rmin= qMin(nv,rmin);
  11276. minimumMeasurement->setText(QString("%1").arg(rmin));
  11277. rmax= qMax(nv,rmax);
  11278. maximumMeasurement->setText(QString("%1").arg(rmax));
  11279. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11280. rmCount++;
  11281. averageMeasurement->setText(QString("%1").arg(rmean));
  11282. }
  11283. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11284. {
  11285. double nv= measure.temperature();
  11286. currentMapped->setText(QString("%1").arg(nv));
  11287. cmin= qMin(nv,cmin);
  11288. minimumMapped->setText(QString("%1").arg(cmin));
  11289. cmax= qMax(nv,cmax);
  11290. maximumMapped->setText(QString("%1").arg(cmax));
  11291. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11292. cmCount++;
  11293. averageMapped->setText(QString("%1").arg(cmean));
  11294. }
  11295. /*:843*//*844:*/
  11296. #line 1224 "./dataqsdk.w"
  11297. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11298. {
  11299. updateAttribute("column",value);
  11300. }
  11301. /*:844*/
  11302. #line 841 "./typica.w"
  11303. /*868:*/
  11304. #line 393 "./scales.w"
  11305. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11306. const QModelIndex&index)
  11307. :BasicDeviceConfigurationWidget(model,index),
  11308. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11309. flow(new FlowSelector),stop(new StopSelector)
  11310. {
  11311. QFormLayout*layout= new QFormLayout;
  11312. layout->addRow(tr("Port:"),port);
  11313. connect(port,SIGNAL(currentIndexChanged(QString)),
  11314. this,SLOT(updatePort(QString)));
  11315. connect(port,SIGNAL(editTextChanged(QString)),
  11316. this,SLOT(updatePort(QString)));
  11317. layout->addRow(tr("Baud:"),baud);
  11318. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11319. this,SLOT(updateBaudRate(QString)));
  11320. layout->addRow(tr("Parity:"),parity);
  11321. connect(parity,SIGNAL(currentIndexChanged(int)),
  11322. this,SLOT(updateParity(int)));
  11323. layout->addRow(tr("Flow Control:"),flow);
  11324. connect(flow,SIGNAL(currentIndexChanged(int)),
  11325. this,SLOT(updateFlowControl(int)));
  11326. layout->addRow(tr("Stop Bits:"),stop);
  11327. connect(stop,SIGNAL(currentIndexChanged(int)),
  11328. this,SLOT(updateStopBits(int)));
  11329. /*693:*/
  11330. #line 15275 "./typica.w"
  11331. QDomElement referenceElement=
  11332. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11333. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11334. QDomElement node;
  11335. /*:693*/
  11336. #line 418 "./scales.w"
  11337. for(int i= 0;i<configData.size();i++)
  11338. {
  11339. node= configData.at(i).toElement();
  11340. if(node.attribute("name")=="port")
  11341. {
  11342. int j= port->findText(node.attribute("value"));
  11343. if(j>=0)
  11344. {
  11345. port->setCurrentIndex(j);
  11346. }
  11347. else
  11348. {
  11349. port->insertItem(0,node.attribute("value"));
  11350. port->setCurrentIndex(0);
  11351. }
  11352. }
  11353. else if(node.attribute("name")=="baudrate")
  11354. {
  11355. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11356. }
  11357. else if(node.attribute("name")=="parity")
  11358. {
  11359. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11360. }
  11361. else if(node.attribute("name")=="flowcontrol")
  11362. {
  11363. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  11364. }
  11365. else if(node.attribute("name")=="stopbits")
  11366. {
  11367. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  11368. }
  11369. }
  11370. updatePort(port->currentText());
  11371. updateBaudRate(baud->currentText());
  11372. updateParity(parity->currentIndex());
  11373. updateFlowControl(flow->currentIndex());
  11374. updateStopBits(stop->currentIndex());
  11375. setLayout(layout);
  11376. }
  11377. /*:868*//*869:*/
  11378. #line 462 "./scales.w"
  11379. void SerialScaleConfWidget::updatePort(const QString&newPort)
  11380. {
  11381. updateAttribute("port",newPort);
  11382. }
  11383. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  11384. {
  11385. updateAttribute("baudrate",rate);
  11386. }
  11387. void SerialScaleConfWidget::updateParity(int index)
  11388. {
  11389. updateAttribute("parity",parity->itemData(index).toString());
  11390. }
  11391. void SerialScaleConfWidget::updateFlowControl(int index)
  11392. {
  11393. updateAttribute("flowcontrol",flow->itemData(index).toString());
  11394. }
  11395. void SerialScaleConfWidget::updateStopBits(int index)
  11396. {
  11397. updateAttribute("stopbits",stop->itemData(index).toString());
  11398. }
  11399. /*:869*/
  11400. #line 842 "./typica.w"
  11401. /*881:*/
  11402. #line 195 "./valueannotation.w"
  11403. void ValueAnnotation::newMeasurement(Measurement measure)
  11404. {
  11405. for(int i= 0;i<values.size();i++)
  11406. {
  11407. if(measure.temperature()> values.at(i)-tolerance&&
  11408. measure.temperature()<values.at(i)+tolerance)
  11409. {
  11410. if(i!=lastIndex)
  11411. {
  11412. lastIndex= i;
  11413. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  11414. }
  11415. }
  11416. }
  11417. }
  11418. /*:881*//*882:*/
  11419. #line 216 "./valueannotation.w"
  11420. void ValueAnnotation::annotate()
  11421. {
  11422. if(lastIndex> -1)
  11423. {
  11424. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  11425. }
  11426. }
  11427. /*:882*//*883:*/
  11428. #line 228 "./valueannotation.w"
  11429. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  11430. {
  11431. values.append(value);
  11432. annotations.append(annotation);
  11433. }
  11434. /*:883*//*884:*/
  11435. #line 237 "./valueannotation.w"
  11436. void ValueAnnotation::setAnnotationColumn(int column)
  11437. {
  11438. annotationColumn= column;
  11439. }
  11440. void ValueAnnotation::setTemperatureColumn(int column)
  11441. {
  11442. measurementColumn= column;
  11443. }
  11444. void ValueAnnotation::setTolerance(double epsilon)
  11445. {
  11446. tolerance= epsilon;
  11447. }
  11448. /*:884*//*885:*/
  11449. #line 255 "./valueannotation.w"
  11450. ValueAnnotation::ValueAnnotation():QObject(),
  11451. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  11452. {
  11453. }
  11454. /*:885*/
  11455. #line 843 "./typica.w"
  11456. /*873:*/
  11457. #line 33 "./valueannotation.w"
  11458. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  11459. const QModelIndex&index)
  11460. :BasicDeviceConfigurationWidget(model,index),
  11461. tablemodel(new SaltModel(2))
  11462. {
  11463. QFormLayout*layout= new QFormLayout;
  11464. QLineEdit*source= new QLineEdit;
  11465. layout->addRow(tr("Source column name:"),source);
  11466. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  11467. noteOnStart->setChecked(true);
  11468. layout->addRow(noteOnStart);
  11469. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  11470. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  11471. QTableView*annotationTable= new QTableView;
  11472. annotationTable->setModel(tablemodel);
  11473. NumericDelegate*delegate= new NumericDelegate;
  11474. annotationTable->setItemDelegateForColumn(0,delegate);
  11475. layout->addRow(tr("Annotations for values:"),annotationTable);
  11476. /*693:*/
  11477. #line 15275 "./typica.w"
  11478. QDomElement referenceElement=
  11479. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11480. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11481. QDomElement node;
  11482. /*:693*/
  11483. #line 52 "./valueannotation.w"
  11484. for(int i= 0;i<configData.size();i++)
  11485. {
  11486. node= configData.at(i).toElement();
  11487. if(node.attribute("name")=="source")
  11488. {
  11489. source->setText(node.attribute("value"));
  11490. }
  11491. else if(node.attribute("name")=="emitOnStart")
  11492. {
  11493. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  11494. }
  11495. else if(node.attribute("name")=="measuredValues")
  11496. {
  11497. /*785:*/
  11498. #line 18307 "./typica.w"
  11499. QString data= node.attribute("value");
  11500. if(data.length()> 3)
  11501. {
  11502. data.chop(2);
  11503. data= data.remove(0,2);
  11504. }
  11505. QStringList itemList= data.split(",");
  11506. /*:785*/
  11507. #line 66 "./valueannotation.w"
  11508. int column= 0;
  11509. /*786:*/
  11510. #line 18319 "./typica.w"
  11511. for(int i= 0;i<itemList.size();i++)
  11512. {
  11513. tablemodel->setData(tablemodel->index(i,column),
  11514. QVariant(itemList.at(i).toDouble()),
  11515. Qt::DisplayRole);
  11516. }
  11517. /*:786*/
  11518. #line 68 "./valueannotation.w"
  11519. }
  11520. else if(node.attribute("name")=="annotations")
  11521. {
  11522. /*874:*/
  11523. #line 89 "./valueannotation.w"
  11524. QString data= node.attribute("value");
  11525. if(data.length()> 3)
  11526. {
  11527. data.chop(2);
  11528. data= data.remove(0,2);
  11529. }
  11530. QStringList itemList= data.split(",");
  11531. for(int i= 0;i<itemList.size();i++)
  11532. {
  11533. itemList[i]= itemList[i].simplified();
  11534. }
  11535. /*:874*/
  11536. #line 72 "./valueannotation.w"
  11537. int column= 1;
  11538. /*875:*/
  11539. #line 104 "./valueannotation.w"
  11540. for(int i= 0;i<itemList.size();i++)
  11541. {
  11542. tablemodel->setData(tablemodel->index(i,column),
  11543. QVariant(itemList.at(i)),
  11544. Qt::DisplayRole);
  11545. }
  11546. /*:875*/
  11547. #line 74 "./valueannotation.w"
  11548. }
  11549. }
  11550. updateSourceColumn(source->text());
  11551. updateStart(noteOnStart->isChecked());
  11552. updateAnnotations();
  11553. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11554. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  11555. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  11556. setLayout(layout);
  11557. }
  11558. /*:873*//*876:*/
  11559. #line 115 "./valueannotation.w"
  11560. void ValueAnnotationConfWidget::updateAnnotations()
  11561. {
  11562. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11563. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11564. }
  11565. /*:876*//*877:*/
  11566. #line 125 "./valueannotation.w"
  11567. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  11568. {
  11569. updateAttribute("source",source);
  11570. }
  11571. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  11572. {
  11573. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  11574. }
  11575. /*:877*/
  11576. #line 844 "./typica.w"
  11577. /*:17*//*806:*/
  11578. #line 284 "./rate.w"
  11579. /*802:*/
  11580. #line 210 "./rate.w"
  11581. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11582. :BasicDeviceConfigurationWidget(model,index)
  11583. {
  11584. QFormLayout*layout= new QFormLayout;
  11585. QLineEdit*column= new QLineEdit;
  11586. layout->addRow(tr("Primary series column name:"),column);
  11587. QSpinBox*cacheTime= new QSpinBox;
  11588. cacheTime->setMinimum(0);
  11589. cacheTime->setMaximum(300);
  11590. layout->addRow(tr("Cache time:"),cacheTime);
  11591. QSpinBox*scaleTime= new QSpinBox;
  11592. scaleTime->setMinimum(1);
  11593. scaleTime->setMaximum(300);
  11594. layout->addRow(tr("Scale time:"),scaleTime);
  11595. /*693:*/
  11596. #line 15275 "./typica.w"
  11597. QDomElement referenceElement=
  11598. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11599. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11600. QDomElement node;
  11601. /*:693*/
  11602. #line 225 "./rate.w"
  11603. for(int i= 0;i<configData.size();i++)
  11604. {
  11605. node= configData.at(i).toElement();
  11606. if(node.attribute("name")=="column")
  11607. {
  11608. column->setText(node.attribute("value"));
  11609. }
  11610. else if(node.attribute("name")=="cache")
  11611. {
  11612. cacheTime->setValue(node.attribute("value").toInt());
  11613. }
  11614. else if(node.attribute("name")=="scale")
  11615. {
  11616. scaleTime->setValue(node.attribute("value").toInt());
  11617. }
  11618. }
  11619. updateColumn(column->text());
  11620. updateCacheTime(cacheTime->text());
  11621. updateScaleTime(scaleTime->text());
  11622. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  11623. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  11624. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  11625. setLayout(layout);
  11626. }
  11627. /*:802*//*803:*/
  11628. #line 254 "./rate.w"
  11629. void RateOfChangeConfWidget::updateColumn(const QString&column)
  11630. {
  11631. updateAttribute("column",column);
  11632. }
  11633. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  11634. {
  11635. updateAttribute("cache",seconds);
  11636. }
  11637. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  11638. {
  11639. updateAttribute("scale",seconds);
  11640. }
  11641. /*:803*/
  11642. #line 285 "./rate.w"
  11643. #line 18442 "./typica.w"
  11644. #line 1 "./dataqsdk.w"
  11645. /*:806*/
  11646. #line 763 "./typica.w"
  11647. /*21:*/
  11648. #line 904 "./typica.w"
  11649. template<class TYPE> TYPE getself(QScriptContext*context)
  11650. {
  11651. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  11652. return self;
  11653. }
  11654. template<> QTime getself(QScriptContext*context)
  11655. {
  11656. QTime self= context->thisObject().toVariant().toTime();
  11657. return self;
  11658. }
  11659. template<> SqlQueryConnection*getself(QScriptContext*context)
  11660. {
  11661. SqlQueryConnection*self=
  11662. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  11663. return self;
  11664. }
  11665. template<> QXmlQuery*getself(QScriptContext*context)
  11666. {
  11667. QXmlQuery*self=
  11668. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  11669. return self;
  11670. }
  11671. template<> QXmlStreamWriter*getself(QScriptContext*context)
  11672. {
  11673. QXmlStreamWriter*self=
  11674. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  11675. return self;
  11676. }
  11677. template<> QXmlStreamReader*getself(QScriptContext*context)
  11678. {
  11679. QXmlStreamReader*self=
  11680. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  11681. return self;
  11682. }
  11683. /*:21*//*22:*/
  11684. #line 949 "./typica.w"
  11685. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  11686. {
  11687. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  11688. return argument;
  11689. }
  11690. template<> QString argument(int arg,QScriptContext*context)
  11691. {
  11692. return context->argument(arg).toString();
  11693. }
  11694. template<> QVariant argument(int arg,QScriptContext*context)
  11695. {
  11696. return context->argument(arg).toVariant();
  11697. }
  11698. template<> int argument(int arg,QScriptContext*context)
  11699. {
  11700. return context->argument(arg).toInt32();
  11701. }
  11702. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  11703. {
  11704. return(SqlQueryConnection*)
  11705. qscriptvalue_cast<void*> (context->argument(arg));
  11706. }
  11707. template<> QModelIndex argument(int arg,QScriptContext*context)
  11708. {
  11709. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  11710. }
  11711. template<> double argument(int arg,QScriptContext*context)
  11712. {
  11713. return(double)(context->argument(arg).toNumber());
  11714. }
  11715. template<> Units::Unit argument(int arg,QScriptContext*context)
  11716. {
  11717. return(Units::Unit)(context->argument(arg).toInt32());
  11718. }
  11719. /*:22*//*26:*/
  11720. #line 1036 "./typica.w"
  11721. void setQObjectProperties(QScriptValue,QScriptEngine*)
  11722. {
  11723. }
  11724. /*:26*//*28:*/
  11725. #line 1050 "./typica.w"
  11726. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  11727. {
  11728. }
  11729. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  11730. {
  11731. }
  11732. /*:28*//*31:*/
  11733. #line 1089 "./typica.w"
  11734. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  11735. {
  11736. QScriptValue object= engine->newQObject(new QWidget);
  11737. setQWidgetProperties(object,engine);
  11738. return object;
  11739. }
  11740. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  11741. {
  11742. setQObjectProperties(value,engine);
  11743. setQPaintDeviceProperties(value,engine);
  11744. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  11745. value.setProperty("activateWindow",
  11746. engine->newFunction(QWidget_activateWindow));
  11747. }
  11748. /*:31*//*32:*/
  11749. #line 1111 "./typica.w"
  11750. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  11751. {
  11752. if(context->argumentCount()==1)
  11753. {
  11754. QWidget*self= getself<QWidget*> (context);
  11755. QLayout*layout= argument<QLayout*> (0,context);
  11756. if(layout)
  11757. {
  11758. self->setLayout(layout);
  11759. }
  11760. else
  11761. {
  11762. context->throwError("Incorrect argument type passed to "
  11763. "QWidget::setLayout(). This method requires "
  11764. "a QLayout.");
  11765. }
  11766. }
  11767. else
  11768. {
  11769. context->throwError("Incorrect number of arguments passed to "
  11770. "QWidget::setLayout(). This method takes one "
  11771. "QLayout as an argument.");
  11772. }
  11773. return QScriptValue();
  11774. }
  11775. QScriptValue QWidget_activateWindow(QScriptContext*context,
  11776. QScriptEngine*)
  11777. {
  11778. QWidget*self= getself<QWidget*> (context);
  11779. self->activateWindow();
  11780. return QScriptValue();
  11781. }
  11782. /*:32*//*34:*/
  11783. #line 1193 "./typica.w"
  11784. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  11785. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  11786. {
  11787. }
  11788. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  11789. {
  11790. QSettings settings;
  11791. settings.beginGroup(key);
  11792. settings.setValue("pos",pos());
  11793. settings.setValue("size",size());
  11794. settings.endGroup();
  11795. }
  11796. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  11797. {
  11798. QSettings settings;
  11799. settings.beginGroup(key);
  11800. if(settings.contains("size"))
  11801. {
  11802. resize(settings.value("size").toSize());
  11803. }
  11804. if(settings.contains("pos"))
  11805. {
  11806. move(settings.value("pos").toPoint());
  11807. }
  11808. settings.endGroup();
  11809. }
  11810. void ScriptQMainWindow::displayStatus(const QString&message)
  11811. {
  11812. statusBar()->showMessage(message);
  11813. }
  11814. void ScriptQMainWindow::showEvent(QShowEvent*event)
  11815. {
  11816. if(!event->spontaneous())
  11817. {
  11818. /*39:*/
  11819. #line 1305 "./typica.w"
  11820. QSettings settings;
  11821. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  11822. toByteArray());
  11823. /*:39*/
  11824. #line 1233 "./typica.w"
  11825. event->accept();
  11826. }
  11827. else
  11828. {
  11829. event->ignore();
  11830. }
  11831. }
  11832. void ScriptQMainWindow::show()
  11833. {
  11834. QMainWindow::show();
  11835. }
  11836. /*:34*//*35:*/
  11837. #line 1254 "./typica.w"
  11838. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  11839. {
  11840. if(isWindowModified()){
  11841. /*36:*/
  11842. #line 1268 "./typica.w"
  11843. QMessageBox::StandardButton result;
  11844. result= QMessageBox::warning(this,"Typica",closePrompt(),
  11845. QMessageBox::Ok|QMessageBox::Cancel);
  11846. if(result==QMessageBox::Cancel)
  11847. {
  11848. event->ignore();
  11849. return;
  11850. }
  11851. /*:36*/
  11852. #line 1258 "./typica.w"
  11853. }
  11854. emit aboutToClose();
  11855. /*38:*/
  11856. #line 1299 "./typica.w"
  11857. QSettings settings;
  11858. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  11859. /*:38*/
  11860. #line 1261 "./typica.w"
  11861. event->accept();
  11862. }
  11863. /*:35*//*37:*/
  11864. #line 1280 "./typica.w"
  11865. QString ScriptQMainWindow::closePrompt()
  11866. {
  11867. return cprompt;
  11868. }
  11869. void ScriptQMainWindow::setClosePrompt(QString prompt)
  11870. {
  11871. cprompt= prompt;
  11872. }
  11873. /*:37*//*42:*/
  11874. #line 1333 "./typica.w"
  11875. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  11876. {
  11877. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  11878. setQMainWindowProperties(object,engine);
  11879. return object;
  11880. }
  11881. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  11882. {
  11883. setQWidgetProperties(value,engine);
  11884. value.setProperty("setCentralWidget",
  11885. engine->newFunction(QMainWindow_setCentralWidget));
  11886. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  11887. }
  11888. /*:42*//*43:*/
  11889. #line 1355 "./typica.w"
  11890. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  11891. QScriptEngine*)
  11892. {
  11893. if(context->argumentCount()==1)
  11894. {
  11895. QMainWindow*self= getself<QMainWindow*> (context);
  11896. QWidget*widget= argument<QWidget*> (0,context);
  11897. if(widget)
  11898. {
  11899. self->setCentralWidget(widget);
  11900. }
  11901. else
  11902. {
  11903. context->throwError("Incorrect argument type passed to "
  11904. "QMainWindow::setCentralWidget(). This "
  11905. "method requires a QWidget.");
  11906. }
  11907. }
  11908. else
  11909. {
  11910. context->throwError("Incorrect number of arguments passed to "
  11911. "QMainWindow::setCentralWidget(). This method "
  11912. "takes one QWidget as an argument.");
  11913. }
  11914. return QScriptValue();
  11915. }
  11916. /*:43*//*44:*/
  11917. #line 1389 "./typica.w"
  11918. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  11919. {
  11920. QScriptValue object;
  11921. if(context->argumentCount()==0)
  11922. {
  11923. QMainWindow*self= getself<QMainWindow*> (context);
  11924. QMenuBar*bar= self->menuBar();
  11925. object= engine->newQObject(bar);
  11926. setQMenuBarProperties(object,engine);
  11927. }
  11928. else
  11929. {
  11930. context->throwError("Incorrect number of arguments passed to "
  11931. "QMainWindow::menuBar(). This method takes no "
  11932. "arguments.");
  11933. }
  11934. return object;
  11935. }
  11936. /*:44*//*46:*/
  11937. #line 1419 "./typica.w"
  11938. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  11939. {
  11940. setQWidgetProperties(value,engine);
  11941. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  11942. }
  11943. /*:46*//*47:*/
  11944. #line 1434 "./typica.w"
  11945. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  11946. {
  11947. QScriptValue object;
  11948. if(context->argumentCount()==1)
  11949. {
  11950. QMenuBar*self= getself<QMenuBar*> (context);
  11951. QString title= argument<QString> (0,context);
  11952. object= engine->newQObject(self->addMenu(title));
  11953. setQMenuProperties(object,engine);
  11954. }
  11955. else
  11956. {
  11957. context->throwError("Incorrect number of arguments passed to "
  11958. "QMenuBar::addMenu(). This method takes one "
  11959. "string as an argument.");
  11960. }
  11961. return object;
  11962. }
  11963. /*:47*//*49:*/
  11964. #line 1464 "./typica.w"
  11965. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  11966. {
  11967. setQWidgetProperties(value,engine);
  11968. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  11969. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  11970. }
  11971. /*:49*//*50:*/
  11972. #line 1474 "./typica.w"
  11973. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  11974. {
  11975. if(context->argumentCount()==1)
  11976. {
  11977. QMenu*self= getself<QMenu*> (context);
  11978. QAction*action= argument<QAction*> (0,context);
  11979. if(action)
  11980. {
  11981. self->addAction(action);
  11982. }
  11983. else
  11984. {
  11985. context->throwError("Incorrect argument type passed to "
  11986. "QMenu::addAction(). This method requires a "
  11987. "QAction.");
  11988. }
  11989. }
  11990. else
  11991. {
  11992. context->throwError("Incorrect number of arguments passed to "
  11993. "QMenu::addAction(). This method takes one "
  11994. "QAction as an argument.");
  11995. }
  11996. return QScriptValue();
  11997. }
  11998. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  11999. {
  12000. if(context->argumentCount()==0)
  12001. {
  12002. QMenu*self= getself<QMenu*> (context);
  12003. self->addSeparator();
  12004. }
  12005. else
  12006. {
  12007. context->throwError("Incorrect number of arguments passed to "
  12008. "QMenu::addSeparator(). This method takes no "
  12009. "arguments.");
  12010. }
  12011. return QScriptValue();
  12012. }
  12013. /*:50*//*53:*/
  12014. #line 1536 "./typica.w"
  12015. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  12016. {
  12017. QScriptValue object= engine->newQObject(new QFrame);
  12018. setQFrameProperties(object,engine);
  12019. return object;
  12020. }
  12021. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  12022. {
  12023. setQWidgetProperties(value,engine);
  12024. }
  12025. /*:53*//*56:*/
  12026. #line 1570 "./typica.w"
  12027. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  12028. {
  12029. QString text;
  12030. if(context->argumentCount()==1)
  12031. {
  12032. text= argument<QString> (0,context);
  12033. }
  12034. QScriptValue object= engine->newQObject(new QLabel(text));
  12035. setQLabelProperties(object,engine);
  12036. return object;
  12037. }
  12038. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  12039. {
  12040. setQFrameProperties(value,engine);
  12041. }
  12042. /*:56*//*59:*/
  12043. #line 1607 "./typica.w"
  12044. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  12045. {
  12046. QScriptValue object= engine->newQObject(new QLineEdit());
  12047. setQLineEditProperties(object,engine);
  12048. return object;
  12049. }
  12050. /*:59*//*60:*/
  12051. #line 1618 "./typica.w"
  12052. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  12053. {
  12054. setQWidgetProperties(value,engine);
  12055. }
  12056. /*:60*//*63:*/
  12057. #line 1652 "./typica.w"
  12058. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  12059. {
  12060. QScriptValue object= engine->newQObject(new QSplitter);
  12061. setQSplitterProperties(object,engine);
  12062. return object;
  12063. }
  12064. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  12065. {
  12066. setQFrameProperties(value,engine);
  12067. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  12068. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  12069. value.setProperty("restoreState",
  12070. engine->newFunction(QSplitter_restoreState));
  12071. }
  12072. /*:63*//*64:*/
  12073. #line 1672 "./typica.w"
  12074. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  12075. {
  12076. if(context->argumentCount()==1)
  12077. {
  12078. QSplitter*self= getself<QSplitter*> (context);
  12079. QWidget*widget= argument<QWidget*> (0,context);
  12080. if(widget)
  12081. {
  12082. self->addWidget(widget);
  12083. }
  12084. else
  12085. {
  12086. context->throwError("Incorrect argument type passed to "
  12087. "QSplitter::addWidget(). This method "
  12088. "requires a QWidget.");
  12089. }
  12090. }
  12091. else
  12092. {
  12093. context->throwError("Incorrect number of arguments passed to "
  12094. "QSplitter::addWidget(). This method takes one "
  12095. "QWidget as an argument.");
  12096. }
  12097. return QScriptValue();
  12098. }
  12099. /*:64*//*65:*/
  12100. #line 1705 "./typica.w"
  12101. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  12102. {
  12103. if(context->argumentCount()==1)
  12104. {
  12105. QSplitter*self= getself<QSplitter*> (context);
  12106. QString key= argument<QString> (0,context);
  12107. QSettings settings;
  12108. settings.setValue(key,self->saveState());
  12109. }
  12110. else
  12111. {
  12112. context->throwError("Incorrect number of arguments passed to "
  12113. "QSplitter::saveState(). This method takes one "
  12114. "string as an argument.");
  12115. }
  12116. return QScriptValue();
  12117. }
  12118. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  12119. {
  12120. if(context->argumentCount()==1)
  12121. {
  12122. QSplitter*self= getself<QSplitter*> (context);
  12123. QString key= argument<QString> (0,context);
  12124. QSettings settings;
  12125. self->restoreState(settings.value(key).toByteArray());
  12126. }
  12127. else
  12128. {
  12129. context->throwError("Incorrect number of arguments passed to "
  12130. "QSplitter::restoreState(). This method takes "
  12131. "one string as an argument.");
  12132. }
  12133. return QScriptValue();
  12134. }
  12135. /*:65*//*67:*/
  12136. #line 1758 "./typica.w"
  12137. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  12138. {
  12139. setQLayoutItemProperties(value,engine);
  12140. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  12141. }
  12142. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  12143. {
  12144. if(context->argumentCount()==1)
  12145. {
  12146. QLayout*self= getself<QLayout*> (context);
  12147. QWidget*widget= argument<QWidget*> (0,context);
  12148. if(widget)
  12149. {
  12150. self->addWidget(widget);
  12151. }
  12152. else
  12153. {
  12154. context->throwError("Incorrect argument type passed to "
  12155. "QLayout::addWidget(). This method requires "
  12156. "a QWidget.");
  12157. }
  12158. }
  12159. else
  12160. {
  12161. context->throwError("Incorrect number of arguments passed to "
  12162. "QLayout::addWidget(). This method takes one "
  12163. "QWidget as an argument.");
  12164. }
  12165. return QScriptValue();
  12166. }
  12167. /*:67*//*70:*/
  12168. #line 1825 "./typica.w"
  12169. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  12170. {
  12171. QScriptValue object=
  12172. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  12173. setQBoxLayoutProperties(object,engine);
  12174. return object;
  12175. }
  12176. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  12177. {
  12178. setQLayoutProperties(value,engine);
  12179. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  12180. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  12181. }
  12182. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  12183. {
  12184. if(context->argumentCount()> 0&&context->argumentCount()<3)
  12185. {
  12186. QBoxLayout*self= getself<QBoxLayout*> (context);
  12187. QLayout*layout= argument<QLayout*> (0,context);
  12188. int stretch= 0;
  12189. if(context->argumentCount()==2)
  12190. {
  12191. stretch= argument<int> (1,context);
  12192. }
  12193. if(layout)
  12194. {
  12195. self->addLayout(layout,stretch);
  12196. }
  12197. else
  12198. {
  12199. context->throwError("Incorrect argument type passed to "
  12200. "QLayout::addLayout(). This method requires "
  12201. "a QLayout.");
  12202. }
  12203. }
  12204. else
  12205. {
  12206. context->throwError("Incorrect number of arguments passed to "
  12207. "QLayout::addLayout(). This method takes one "
  12208. "QLayout as an argument and optionally one integer.");
  12209. }
  12210. return QScriptValue();
  12211. }
  12212. /*:70*//*71:*/
  12213. #line 1876 "./typica.w"
  12214. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  12215. {
  12216. if(context->argumentCount()> 0&&context->argumentCount()<4)
  12217. {
  12218. QBoxLayout*self= getself<QBoxLayout*> (context);
  12219. QWidget*widget= argument<QWidget*> (0,context);
  12220. int stretch= 0;
  12221. Qt::Alignment alignment= 0;
  12222. if(context->argumentCount()> 1)
  12223. {
  12224. stretch= argument<int> (1,context);
  12225. }
  12226. if(context->argumentCount()> 2)
  12227. {
  12228. alignment= (Qt::Alignment)(argument<int> (2,context));
  12229. }
  12230. if(widget)
  12231. {
  12232. self->addWidget(widget,stretch,alignment);
  12233. }
  12234. else
  12235. {
  12236. context->throwError("Incorrect argument type passed to "
  12237. "QBoxLayout::addWidget(). This method requires "
  12238. "a QWidget.");
  12239. }
  12240. }
  12241. else
  12242. {
  12243. context->throwError("Incorrect number of arguments passed to "
  12244. "QBoxLayout::addWidget(). This method takes one "
  12245. "QWidget and optionally up to two integers as "
  12246. "arguments.");
  12247. }
  12248. return QScriptValue();
  12249. }
  12250. /*:71*//*74:*/
  12251. #line 1940 "./typica.w"
  12252. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  12253. {
  12254. QScriptValue object= engine->newQObject(new QAction(NULL));
  12255. setQActionProperties(object,engine);
  12256. return object;
  12257. }
  12258. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  12259. {
  12260. setQObjectProperties(value,engine);
  12261. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  12262. }
  12263. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  12264. {
  12265. if(context->argumentCount()==1)
  12266. {
  12267. QAction*self= getself<QAction*> (context);
  12268. self->setShortcut(argument<QString> (0,context));
  12269. }
  12270. else
  12271. {
  12272. context->throwError("Incorrect number of arguments passed to "
  12273. "QAction::setShortcut(). This method takes one "
  12274. "string as an argument.");
  12275. }
  12276. return QScriptValue();
  12277. }
  12278. /*:74*//*77:*/
  12279. #line 1998 "./typica.w"
  12280. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  12281. QScriptEngine*engine)
  12282. {
  12283. QScriptValue retval;
  12284. if(context->argumentCount()==3)
  12285. {
  12286. QWidget*widget= argument<QWidget*> (0,context);
  12287. if(widget)
  12288. {
  12289. QString caption= argument<QString> (1,context);
  12290. QString dir= argument<QString> (2,context);
  12291. retval= QScriptValue(engine,
  12292. QFileDialog::getOpenFileName(widget,caption,
  12293. dir,"",0,0));
  12294. setQFileDialogProperties(retval,engine);
  12295. }
  12296. else
  12297. {
  12298. context->throwError("Incorrect argument type passed to "
  12299. "QFileDialog::getOpenFileName(). The first "
  12300. "argument to this method must be a QWidget.");
  12301. }
  12302. }
  12303. else
  12304. {
  12305. context->throwError("Incorrect number of arguments passed to "
  12306. "QFileDialog::getOpenFileName(). This method "
  12307. "takes one QWidget followed by two strings for a "
  12308. "total of three arguments.");
  12309. }
  12310. return retval;
  12311. }
  12312. /*:77*//*78:*/
  12313. #line 2034 "./typica.w"
  12314. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  12315. QScriptEngine*engine)
  12316. {
  12317. QScriptValue retval;
  12318. if(context->argumentCount()==3)
  12319. {
  12320. QWidget*widget= argument<QWidget*> (0,context);
  12321. if(widget)
  12322. {
  12323. QString caption= argument<QString> (1,context);
  12324. QString dir= argument<QString> (2,context);
  12325. retval= QScriptValue(engine,
  12326. QFileDialog::getSaveFileName(widget,caption,
  12327. dir,"",0,0));
  12328. setQFileDialogProperties(retval,engine);
  12329. }
  12330. else
  12331. {
  12332. context->throwError("Incorrect argument type passed to "
  12333. "QFileDialog::getSaveFileName(). The first "
  12334. "argument to this method must be a QWidget.");
  12335. }
  12336. }
  12337. else
  12338. {
  12339. context->throwError("Incorrect number of arguments passed to "
  12340. "QFileDialog::getSaveFileName(). This method "
  12341. "takes one QWidget followed by two strings for a "
  12342. "total of three arguments.");
  12343. }
  12344. return retval;
  12345. }
  12346. /*:78*//*79:*/
  12347. #line 2071 "./typica.w"
  12348. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  12349. {
  12350. setQDialogProperties(value,engine);
  12351. }
  12352. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  12353. {
  12354. setQWidgetProperties(value,engine);
  12355. }
  12356. /*:79*//*82:*/
  12357. #line 2106 "./typica.w"
  12358. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  12359. {
  12360. QScriptValue object=
  12361. engine->newQObject(new QFile(argument<QString> (0,context)));
  12362. setQFileProperties(object,engine);
  12363. return object;
  12364. }
  12365. /*:82*//*83:*/
  12366. #line 2117 "./typica.w"
  12367. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  12368. {
  12369. setQIODeviceProperties(value,engine);
  12370. value.setProperty("remove",engine->newFunction(QFile_remove));
  12371. }
  12372. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  12373. {
  12374. QFile*self= getself<QFile*> (context);
  12375. bool retval= self->remove();
  12376. return QScriptValue(engine,retval);
  12377. }
  12378. /*:83*//*84:*/
  12379. #line 2139 "./typica.w"
  12380. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  12381. {
  12382. setQObjectProperties(value,engine);
  12383. value.setProperty("open",engine->newFunction(QIODevice_open));
  12384. value.setProperty("close",engine->newFunction(QIODevice_close));
  12385. value.setProperty("readToString",
  12386. engine->newFunction(QIODevice_readToString));
  12387. }
  12388. /*:84*//*85:*/
  12389. #line 2154 "./typica.w"
  12390. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  12391. {
  12392. QIODevice*self= getself<QIODevice*> (context);
  12393. if(context->argumentCount()==1)
  12394. {
  12395. switch(argument<int> (0,context))
  12396. {
  12397. case 1:
  12398. self->open(QIODevice::ReadOnly);
  12399. break;
  12400. case 2:
  12401. self->open(QIODevice::WriteOnly);
  12402. break;
  12403. case 3:
  12404. self->open(QIODevice::ReadWrite);
  12405. break;
  12406. default:
  12407. break;
  12408. }
  12409. }
  12410. else
  12411. {
  12412. self->open(QIODevice::ReadWrite);
  12413. }
  12414. return QScriptValue();
  12415. }
  12416. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  12417. {
  12418. QIODevice*self= getself<QIODevice*> (context);
  12419. self->close();
  12420. return QScriptValue();
  12421. }
  12422. /*:85*//*86:*/
  12423. #line 2193 "./typica.w"
  12424. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  12425. {
  12426. QIODevice*self= getself<QIODevice*> (context);
  12427. self->reset();
  12428. return QScriptValue(QString(self->readAll()));
  12429. }
  12430. /*:86*//*89:*/
  12431. #line 2223 "./typica.w"
  12432. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  12433. {
  12434. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  12435. QScriptValue object= engine->newQObject(new QBuffer(array));
  12436. setQBufferProperties(object,engine);
  12437. return object;
  12438. }
  12439. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  12440. {
  12441. setQIODeviceProperties(value,engine);
  12442. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  12443. }
  12444. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  12445. {
  12446. QBuffer*self= getself<QBuffer*> (context);
  12447. self->setData(argument<QString> (0,context).toAscii());
  12448. return QScriptValue();
  12449. }
  12450. /*:89*//*92:*/
  12451. #line 2271 "./typica.w"
  12452. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  12453. {
  12454. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  12455. setXQueryProperties(object,engine);
  12456. return object;
  12457. }
  12458. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  12459. {
  12460. value.setProperty("bind",engine->newFunction(XQuery_bind));
  12461. value.setProperty("exec",engine->newFunction(XQuery_exec));
  12462. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  12463. }
  12464. /*:92*//*93:*/
  12465. #line 2289 "./typica.w"
  12466. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  12467. {
  12468. QXmlQuery*self= getself<QXmlQuery*> (context);
  12469. QIODevice*buffer= argument<QIODevice*> (1,context);
  12470. self->bindVariable(argument<QString> (0,context),buffer);
  12471. return QScriptValue();
  12472. }
  12473. /*:93*//*94:*/
  12474. #line 2300 "./typica.w"
  12475. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  12476. {
  12477. QXmlQuery*self= getself<QXmlQuery*> (context);
  12478. self->setQuery(argument<QString> (0,context));
  12479. return QScriptValue();
  12480. }
  12481. /*:94*//*95:*/
  12482. #line 2310 "./typica.w"
  12483. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  12484. {
  12485. QXmlQuery*self= getself<QXmlQuery*> (context);
  12486. QString result;
  12487. self->evaluateTo(&result);
  12488. return QScriptValue(result);
  12489. }
  12490. /*:95*//*98:*/
  12491. #line 2365 "./typica.w"
  12492. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  12493. {
  12494. QXmlStreamWriter*retval;
  12495. if(context->argumentCount()==1)
  12496. {
  12497. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  12498. }
  12499. else
  12500. {
  12501. retval= new QXmlStreamWriter;
  12502. }
  12503. QScriptValue object= engine->toScriptValue<void*> (retval);
  12504. setXmlWriterProperties(object,engine);
  12505. return object;
  12506. }
  12507. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  12508. {
  12509. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  12510. value.setProperty("writeAttribute",
  12511. engine->newFunction(XmlWriter_writeAttribute));
  12512. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  12513. value.setProperty("writeCharacters",
  12514. engine->newFunction(XmlWriter_writeCharacters));
  12515. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  12516. value.setProperty("writeEmptyElement",
  12517. engine->newFunction(XmlWriter_writeEmptyElement));
  12518. value.setProperty("writeEndDocument",
  12519. engine->newFunction(XmlWriter_writeEndDocument));
  12520. value.setProperty("writeEndElement",
  12521. engine->newFunction(XmlWriter_writeEndElement));
  12522. value.setProperty("writeEntityReference",
  12523. engine->newFunction(XmlWriter_writeEntityReference));
  12524. value.setProperty("writeProcessingInstruction",
  12525. engine->newFunction(XmlWriter_writeProcessingInstruction));
  12526. value.setProperty("writeStartDocument",
  12527. engine->newFunction(XmlWriter_writeStartDocument));
  12528. value.setProperty("writeStartElement",
  12529. engine->newFunction(XmlWriter_writeStartElement));
  12530. value.setProperty("writeTextElement",
  12531. engine->newFunction(XmlWriter_writeTextElement));
  12532. }
  12533. /*:98*//*99:*/
  12534. #line 2412 "./typica.w"
  12535. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  12536. {
  12537. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12538. QIODevice*device= argument<QIODevice*> (0,context);
  12539. self->setDevice(device);
  12540. return QScriptValue();
  12541. }
  12542. /*:99*//*100:*/
  12543. #line 2426 "./typica.w"
  12544. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  12545. QScriptEngine*)
  12546. {
  12547. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12548. self->writeStartDocument(argument<QString> (0,context));
  12549. return QScriptValue();
  12550. }
  12551. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  12552. QScriptEngine*)
  12553. {
  12554. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12555. self->writeEndDocument();
  12556. return QScriptValue();
  12557. }
  12558. /*:100*//*101:*/
  12559. #line 2445 "./typica.w"
  12560. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  12561. {
  12562. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12563. self->writeDTD(argument<QString> (0,context));
  12564. return QScriptValue();
  12565. }
  12566. /*:101*//*102:*/
  12567. #line 2456 "./typica.w"
  12568. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  12569. QScriptEngine*)
  12570. {
  12571. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12572. self->writeStartElement(argument<QString> (0,context));
  12573. return QScriptValue();
  12574. }
  12575. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  12576. {
  12577. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12578. self->writeAttribute(argument<QString> (0,context),
  12579. argument<QString> (1,context));
  12580. return QScriptValue();
  12581. }
  12582. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  12583. {
  12584. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12585. self->writeCharacters(argument<QString> (0,context));
  12586. return QScriptValue();
  12587. }
  12588. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  12589. {
  12590. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12591. self->writeEndElement();
  12592. return QScriptValue();
  12593. }
  12594. /*:102*//*103:*/
  12595. #line 2492 "./typica.w"
  12596. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  12597. QScriptEngine*)
  12598. {
  12599. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12600. self->writeEmptyElement(argument<QString> (0,context));
  12601. return QScriptValue();
  12602. }
  12603. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  12604. QScriptEngine*)
  12605. {
  12606. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12607. self->writeTextElement(argument<QString> (0,context),
  12608. argument<QString> (1,context));
  12609. return QScriptValue();
  12610. }
  12611. /*:103*//*104:*/
  12612. #line 2513 "./typica.w"
  12613. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  12614. {
  12615. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12616. self->writeCDATA(argument<QString> (0,context));
  12617. return QScriptValue();
  12618. }
  12619. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  12620. QScriptEngine*)
  12621. {
  12622. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12623. self->writeEntityReference(argument<QString> (0,context));
  12624. return QScriptValue();
  12625. }
  12626. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  12627. QScriptEngine*)
  12628. {
  12629. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  12630. self->writeProcessingInstruction(argument<QString> (0,context),
  12631. argument<QString> (1,context));
  12632. return QScriptValue();
  12633. }
  12634. /*:104*//*107:*/
  12635. #line 2572 "./typica.w"
  12636. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  12637. {
  12638. QXmlStreamReader*retval=
  12639. new QXmlStreamReader(argument<QIODevice*> (0,context));
  12640. QScriptValue object= engine->toScriptValue<void*> (retval);
  12641. setXmlReaderProperties(object,engine);
  12642. return object;
  12643. }
  12644. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  12645. {
  12646. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  12647. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  12648. value.setProperty("hasAttribute",
  12649. engine->newFunction(XmlReader_hasAttribute));
  12650. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  12651. value.setProperty("isStartElement",
  12652. engine->newFunction(XmlReader_isStartElement));
  12653. value.setProperty("name",engine->newFunction(XmlReader_name));
  12654. value.setProperty("readElementText",
  12655. engine->newFunction(XmlReader_readElementText));
  12656. value.setProperty("readNext",
  12657. engine->newFunction(XmlReader_readNext));
  12658. value.setProperty("text",engine->newFunction(XmlReader_text));
  12659. }
  12660. /*:107*//*108:*/
  12661. #line 2602 "./typica.w"
  12662. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  12663. {
  12664. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12665. QString retval=
  12666. self->attributes().value(argument<QString> (0,context)).toString();
  12667. return QScriptValue(retval);
  12668. }
  12669. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  12670. {
  12671. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12672. bool retval=
  12673. self->attributes().hasAttribute(argument<QString> (0,context));
  12674. return QScriptValue(retval);
  12675. }
  12676. /*:108*//*109:*/
  12677. #line 2622 "./typica.w"
  12678. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  12679. {
  12680. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12681. return QScriptValue(self->atEnd());
  12682. }
  12683. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  12684. {
  12685. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12686. return QScriptValue(self->isDTD());
  12687. }
  12688. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  12689. {
  12690. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12691. return QScriptValue(self->isStartElement());
  12692. }
  12693. /*:109*//*110:*/
  12694. #line 2643 "./typica.w"
  12695. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  12696. {
  12697. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12698. self->readNext();
  12699. return QScriptValue();
  12700. }
  12701. /*:110*//*111:*/
  12702. #line 2653 "./typica.w"
  12703. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  12704. {
  12705. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12706. return QScriptValue(self->name().toString());
  12707. }
  12708. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  12709. {
  12710. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12711. return QScriptValue(self->readElementText());
  12712. }
  12713. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  12714. {
  12715. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  12716. return QScriptValue(self->text().toString());
  12717. }
  12718. /*:111*//*114:*/
  12719. #line 2695 "./typica.w"
  12720. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  12721. {
  12722. setQObjectProperties(value,engine);
  12723. value.setProperty("value",engine->newFunction(QSettings_value));
  12724. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  12725. }
  12726. /*:114*//*115:*/
  12727. #line 2707 "./typica.w"
  12728. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  12729. {
  12730. QScriptValue object;
  12731. if(context->argumentCount()==1||context->argumentCount()==2)
  12732. {
  12733. QSettings settings;
  12734. QString key= argument<QString> (0,context);
  12735. QVariant value;
  12736. QVariant retval;
  12737. if(context->argumentCount()> 1)
  12738. {
  12739. value= argument<QVariant> (1,context);
  12740. retval= settings.value(key,value);
  12741. }
  12742. else
  12743. {
  12744. retval= settings.value(key);
  12745. }
  12746. object= engine->newVariant(retval);
  12747. }
  12748. else
  12749. {
  12750. context->throwError("Incorrect number of arguments passed to "
  12751. "QSettings::value(). This method takes one "
  12752. "string and one optional variant type.");
  12753. }
  12754. return object;
  12755. }
  12756. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  12757. {
  12758. if(context->argumentCount()==2)
  12759. {
  12760. QSettings settings;
  12761. QString key= argument<QString> (0,context);
  12762. QVariant value= argument<QVariant> (1,context);
  12763. settings.setValue(key,value);
  12764. }
  12765. else
  12766. {
  12767. context->throwError("Incorrect number of arguments passed to "
  12768. "QSettings::setValue(). This method takes one "
  12769. "string and one variant type for a total of two "
  12770. "arguments.");
  12771. }
  12772. return QScriptValue();
  12773. }
  12774. /*:115*//*118:*/
  12775. #line 2776 "./typica.w"
  12776. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  12777. {
  12778. QScriptValue object= engine->newQObject(new QLCDNumber());
  12779. setQLCDNumberProperties(object,engine);
  12780. return object;
  12781. }
  12782. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  12783. {
  12784. setQFrameProperties(value,engine);
  12785. }
  12786. /*:118*//*121:*/
  12787. #line 2834 "./typica.w"
  12788. QScriptValue constructQTime(QScriptContext*context,
  12789. QScriptEngine*engine)
  12790. {
  12791. QScriptValue object;
  12792. if(context->argumentCount()==0||
  12793. (context->argumentCount()>=2&&context->argumentCount()<=4))
  12794. {
  12795. int arg1= 0;
  12796. int arg2= 0;
  12797. int arg3= 0;
  12798. int arg4= 0;
  12799. switch(context->argumentCount())
  12800. {
  12801. case 4:
  12802. arg4= argument<int> (3,context);
  12803. case 3:
  12804. arg3= argument<int> (2,context);
  12805. case 2:
  12806. arg2= argument<int> (1,context);
  12807. arg1= argument<int> (0,context);
  12808. default:
  12809. break;
  12810. }
  12811. if(context->argumentCount())
  12812. {
  12813. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  12814. arg4));
  12815. }
  12816. else
  12817. {
  12818. object= engine->toScriptValue<QTime> (QTime());
  12819. }
  12820. setQTimeProperties(object,engine);
  12821. }
  12822. else
  12823. {
  12824. context->throwError("Incorrect number of arguments passed to "
  12825. "QTime::QTime(). This method takes zero, two, "
  12826. "three, or four integer arguments.");
  12827. }
  12828. return object;
  12829. }
  12830. /*:121*//*122:*/
  12831. #line 2882 "./typica.w"
  12832. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  12833. {
  12834. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  12835. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  12836. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  12837. value.setProperty("hour",engine->newFunction(QTime_hour));
  12838. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  12839. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  12840. value.setProperty("minute",engine->newFunction(QTime_minute));
  12841. value.setProperty("msec",engine->newFunction(QTime_msec));
  12842. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  12843. value.setProperty("restart",engine->newFunction(QTime_restart));
  12844. value.setProperty("second",engine->newFunction(QTime_second));
  12845. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  12846. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  12847. value.setProperty("start",engine->newFunction(QTime_start));
  12848. value.setProperty("toString",engine->newFunction(QTime_toString));
  12849. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  12850. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  12851. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  12852. }
  12853. /*:122*//*123:*/
  12854. #line 2911 "./typica.w"
  12855. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  12856. {
  12857. QTime self= getself<QTime> (context);
  12858. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  12859. (self.second()*1000)+self.msec();
  12860. return QScriptValue(retval);
  12861. }
  12862. /*:123*//*124:*/
  12863. #line 2925 "./typica.w"
  12864. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  12865. {
  12866. QTime time;
  12867. QScriptValue retval;
  12868. if(context->argumentCount()==1)
  12869. {
  12870. QTime self= getself<QTime> (context);
  12871. time= self.addMSecs(argument<int> (0,context));
  12872. retval= engine->toScriptValue<QTime> (time);
  12873. setQTimeProperties(retval,engine);
  12874. }
  12875. else
  12876. {
  12877. context->throwError("Incorrect number of arguments passed to "
  12878. "QTime::addMSecs(). This method takes one "
  12879. "integer as an argument.");
  12880. }
  12881. return retval;
  12882. }
  12883. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  12884. {
  12885. QTime time;
  12886. QScriptValue retval;
  12887. if(context->argumentCount()==1)
  12888. {
  12889. QTime self= getself<QTime> (context);
  12890. time= self.addSecs(argument<int> (0,context));
  12891. retval= engine->toScriptValue<QTime> (time);
  12892. setQTimeProperties(retval,engine);
  12893. }
  12894. else
  12895. {
  12896. context->throwError("Incorrect number of arguments passed to "
  12897. "QTime::addSecs(). This method takes one "
  12898. "integer as an argument.");
  12899. }
  12900. return retval;
  12901. }
  12902. /*:124*//*125:*/
  12903. #line 2968 "./typica.w"
  12904. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  12905. {
  12906. QScriptValue retval;
  12907. if(context->argumentCount()==0)
  12908. {
  12909. QTime self= getself<QTime> (context);
  12910. retval= QScriptValue(engine,self.elapsed());
  12911. }
  12912. else
  12913. {
  12914. context->throwError("Incorrect number of arguments passed to "
  12915. "QTime::elapsed(). This method takes no "
  12916. "arguments.");
  12917. }
  12918. return retval;
  12919. }
  12920. /*:125*//*126:*/
  12921. #line 2989 "./typica.w"
  12922. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  12923. {
  12924. QScriptValue retval;
  12925. if(context->argumentCount()==0)
  12926. {
  12927. QTime self= getself<QTime> (context);
  12928. retval= QScriptValue(engine,self.hour());
  12929. }
  12930. else
  12931. {
  12932. context->throwError("Incorrect number of arguments passed to "
  12933. "QTime::hour(). This method takes no "
  12934. "arguments.");
  12935. }
  12936. return retval;
  12937. }
  12938. /*:126*//*127:*/
  12939. #line 3009 "./typica.w"
  12940. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  12941. {
  12942. QScriptValue retval;
  12943. if(context->argumentCount()==0)
  12944. {
  12945. QTime self= getself<QTime> (context);
  12946. retval= QScriptValue(engine,self.minute());
  12947. }
  12948. else
  12949. {
  12950. context->throwError("Incorrect number of arguments passed to "
  12951. "QTime::minute(). This method takes no "
  12952. "arguments.");
  12953. }
  12954. return retval;
  12955. }
  12956. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  12957. {
  12958. QScriptValue retval;
  12959. if(context->argumentCount()==0)
  12960. {
  12961. QTime self= getself<QTime> (context);
  12962. retval= QScriptValue(engine,self.second());
  12963. }
  12964. else
  12965. {
  12966. context->throwError("Incorrect number of arguments passed to "
  12967. "QTime::second(). This method takes no "
  12968. "arguments.");
  12969. }
  12970. return retval;
  12971. }
  12972. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  12973. {
  12974. QScriptValue retval;
  12975. if(context->argumentCount()==0)
  12976. {
  12977. QTime self= getself<QTime> (context);
  12978. retval= QScriptValue(engine,self.msec());
  12979. }
  12980. else
  12981. {
  12982. context->throwError("Incorrect number of arguments passed to "
  12983. "QTime::msec(). This method takes no "
  12984. "arguments.");
  12985. }
  12986. return retval;
  12987. }
  12988. /*:127*//*128:*/
  12989. #line 3065 "./typica.w"
  12990. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  12991. {
  12992. QScriptValue retval;
  12993. if(context->argumentCount()==0)
  12994. {
  12995. QTime self= getself<QTime> (context);
  12996. retval= QScriptValue(engine,self.isNull());
  12997. }
  12998. else
  12999. {
  13000. context->throwError("Incorrect number of arguments passed to "
  13001. "QTime::isNull(). This method takes no "
  13002. "arguments.");
  13003. }
  13004. return retval;
  13005. }
  13006. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  13007. {
  13008. QScriptValue retval;
  13009. if(context->argumentCount()==0)
  13010. {
  13011. QTime self= getself<QTime> (context);
  13012. retval= QScriptValue(engine,self.isValid());
  13013. }
  13014. else
  13015. {
  13016. context->throwError("Incorrect number of arguments passed to "
  13017. "QTime::isValid(). This method takes no "
  13018. "arguments.");
  13019. }
  13020. return retval;
  13021. }
  13022. /*:128*//*129:*/
  13023. #line 3103 "./typica.w"
  13024. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  13025. {
  13026. QScriptValue retval;
  13027. if(context->argumentCount()==1)
  13028. {
  13029. QTime self= getself<QTime> (context);
  13030. QTime arg= argument<QVariant> (0,context).toTime();
  13031. retval= QScriptValue(engine,self.msecsTo(arg));
  13032. }
  13033. else
  13034. {
  13035. context->throwError("Incorrect number of arguments passed to "
  13036. "QTime::msecsTo(). This method takes one QTime.");
  13037. }
  13038. return retval;
  13039. }
  13040. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  13041. {
  13042. QScriptValue retval;
  13043. if(context->argumentCount()==1)
  13044. {
  13045. QTime self= getself<QTime> (context);
  13046. QTime arg= argument<QVariant> (0,context).toTime();
  13047. retval= QScriptValue(engine,self.secsTo(arg));
  13048. }
  13049. else
  13050. {
  13051. context->throwError("Incorrect number of arguments passed to "
  13052. "QTime::secsTo(). This method takes one QTime.");
  13053. }
  13054. return retval;
  13055. }
  13056. /*:129*//*130:*/
  13057. #line 3142 "./typica.w"
  13058. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  13059. {
  13060. QScriptValue retval;
  13061. if(context->argumentCount()==0)
  13062. {
  13063. QTime self= getself<QTime> (context);
  13064. retval= QScriptValue(engine,self.restart());
  13065. }
  13066. else
  13067. {
  13068. context->throwError("Incorrect number of arguments passed to "
  13069. "QTime::restart(). This method takes no "
  13070. "arguments.");
  13071. }
  13072. return retval;
  13073. }
  13074. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  13075. {
  13076. if(context->argumentCount()==0)
  13077. {
  13078. QTime self= getself<QTime> (context);
  13079. self.start();
  13080. }
  13081. else
  13082. {
  13083. context->throwError("Incorrect number of arguments passed to "
  13084. "QTime::start(). This method takes no arguments.");
  13085. }
  13086. return QScriptValue();
  13087. }
  13088. /*:130*//*131:*/
  13089. #line 3178 "./typica.w"
  13090. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  13091. {
  13092. QScriptValue retval;
  13093. if(context->argumentCount()==3||context->argumentCount()==4)
  13094. {
  13095. QTime self= getself<QTime> (context);
  13096. int arg1= 0;
  13097. int arg2= 0;
  13098. int arg3= 0;
  13099. int arg4= 0;
  13100. switch(context->argumentCount())
  13101. {
  13102. case 4:
  13103. arg4= argument<int> (3,context);
  13104. case 3:
  13105. arg3= argument<int> (2,context);
  13106. arg2= argument<int> (1,context);
  13107. arg1= argument<int> (0,context);
  13108. default:
  13109. break;
  13110. }
  13111. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  13112. }
  13113. else
  13114. {
  13115. context->throwError("Incorrect number of arguments passed to "
  13116. "QTime::setHMS(). This method takes three or "
  13117. "four integer arguments.");
  13118. }
  13119. return retval;
  13120. }
  13121. /*:131*//*132:*/
  13122. #line 3214 "./typica.w"
  13123. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  13124. {
  13125. QScriptValue retval;
  13126. if(context->argumentCount()==1)
  13127. {
  13128. QTime self= getself<QTime> (context);
  13129. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  13130. }
  13131. else
  13132. {
  13133. context->throwError("Incorrect number of arguments passed to "
  13134. "QTime::toString(). This method takes one QString "
  13135. "as an argument.");
  13136. }
  13137. return retval;
  13138. }
  13139. /*:132*//*133:*/
  13140. #line 3235 "./typica.w"
  13141. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  13142. {
  13143. QScriptValue object;
  13144. object= engine->toScriptValue<QTime> (QTime::currentTime());
  13145. setQTimeProperties(object,engine);
  13146. return object;
  13147. }
  13148. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  13149. {
  13150. QScriptValue object;
  13151. if(context->argumentCount()==2)
  13152. {
  13153. QString time= argument<QString> (0,context);
  13154. QString format= argument<QString> (1,context);
  13155. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  13156. setQTimeProperties(object,engine);
  13157. }
  13158. else
  13159. {
  13160. context->throwError("Incorrect number of arguments passed to "
  13161. "QTime::fromString(). This method takes two "
  13162. "string arguments.");
  13163. }
  13164. return object;
  13165. }
  13166. /*:133*//*135:*/
  13167. #line 3275 "./typica.w"
  13168. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  13169. {
  13170. setQFrameProperties(value,engine);
  13171. }
  13172. /*:135*//*137:*/
  13173. #line 3289 "./typica.w"
  13174. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  13175. {
  13176. setQAbstractScrollAreaProperties(value,engine);
  13177. }
  13178. /*:137*//*139:*/
  13179. #line 3303 "./typica.w"
  13180. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  13181. {
  13182. setQAbstractScrollAreaProperties(value,engine);
  13183. }
  13184. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  13185. {
  13186. setQAbstractItemViewProperties(value,engine);
  13187. }
  13188. /*:139*//*142:*/
  13189. #line 3336 "./typica.w"
  13190. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  13191. {
  13192. QScriptValue object= engine->newQObject(new QPushButton());
  13193. setQPushButtonProperties(object,engine);
  13194. return object;
  13195. }
  13196. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  13197. {
  13198. setQAbstractButtonProperties(value,engine);
  13199. }
  13200. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  13201. {
  13202. setQWidgetProperties(value,engine);
  13203. }
  13204. /*:142*//*149:*/
  13205. #line 3448 "./typica.w"
  13206. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  13207. {
  13208. QScriptValue object=
  13209. engine->toScriptValue<void*> (new SqlQueryConnection());
  13210. setQSqlQueryProperties(object,engine);
  13211. return object;
  13212. }
  13213. /*:149*//*150:*/
  13214. #line 3460 "./typica.w"
  13215. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  13216. {
  13217. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  13218. value.setProperty("bindFileData",
  13219. engine->newFunction(QSqlQuery_bindFileData));
  13220. value.setProperty("bindDeviceData",
  13221. engine->newFunction(QSqlQuery_bindDeviceData));
  13222. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  13223. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  13224. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  13225. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  13226. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  13227. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  13228. }
  13229. /*:150*//*151:*/
  13230. #line 3478 "./typica.w"
  13231. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  13232. {
  13233. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13234. QScriptValue retval;
  13235. if(context->argumentCount()==1)
  13236. {
  13237. retval= QScriptValue(engine,
  13238. query->exec(argument<QString> (0,context)));
  13239. }
  13240. else
  13241. {
  13242. retval= QScriptValue(engine,query->exec());
  13243. }
  13244. if(query->lastError().isValid())
  13245. {
  13246. qDebug()<<query->lastQuery();
  13247. qDebug()<<query->lastError().text();
  13248. }
  13249. return retval;
  13250. }
  13251. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  13252. {
  13253. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13254. return QScriptValue(query->lastQuery());
  13255. }
  13256. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  13257. {
  13258. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13259. return QScriptValue(engine,query->next());
  13260. }
  13261. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  13262. {
  13263. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13264. return QScriptValue(engine,
  13265. query->value(argument<int> (0,context)).toString());
  13266. }
  13267. /*:151*//*152:*/
  13268. #line 3522 "./typica.w"
  13269. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  13270. {
  13271. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13272. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  13273. }
  13274. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  13275. {
  13276. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13277. query->bindValue(argument<QString> (0,context),
  13278. argument<QVariant> (1,context));
  13279. return QScriptValue();
  13280. }
  13281. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  13282. QScriptEngine*)
  13283. {
  13284. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13285. QString placeholder= argument<QString> (0,context);
  13286. QString filename= argument<QString> (1,context);
  13287. QFile file(filename);
  13288. QByteArray data;
  13289. if(file.open(QIODevice::ReadOnly))
  13290. {
  13291. data= file.readAll();
  13292. file.close();
  13293. }
  13294. query->bindValue(placeholder,data);
  13295. return QScriptValue();
  13296. }
  13297. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  13298. QScriptEngine*)
  13299. {
  13300. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13301. QString placeholder= argument<QString> (0,context);
  13302. QIODevice*device= argument<QIODevice*> (1,context);
  13303. device->reset();
  13304. QByteArray data;
  13305. data= device->readAll();
  13306. query->bindValue(placeholder,data);
  13307. return QScriptValue();
  13308. }
  13309. /*:152*//*153:*/
  13310. #line 3574 "./typica.w"
  13311. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  13312. {
  13313. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  13314. delete query;
  13315. return QScriptValue::UndefinedValue;
  13316. }
  13317. /*:153*//*156:*/
  13318. #line 3615 "./typica.w"
  13319. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  13320. {
  13321. QFileInfo info(argument<QString> (0,context));
  13322. QScriptValue retval(engine,info.baseName());
  13323. return retval;
  13324. }
  13325. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  13326. {
  13327. QFileInfo info(argument<QString> (0,context));
  13328. QDir dir= info.dir();
  13329. QScriptValue retval(engine,dir.path());
  13330. return retval;
  13331. }
  13332. /*:156*//*157:*/
  13333. #line 3634 "./typica.w"
  13334. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  13335. {
  13336. QString source= argument<QString> (0,context);
  13337. source.remove(0,1);
  13338. source.chop(1);
  13339. QStringList elements= source.split(",");
  13340. QString element;
  13341. QScriptValue dest= engine->newArray(elements.size());
  13342. int i= 0;
  13343. foreach(element,elements)
  13344. {
  13345. if(element.startsWith("\"")&&element.endsWith("\""))
  13346. {
  13347. element.chop(1);
  13348. element= element.remove(0,1);
  13349. }
  13350. dest.setProperty(i,QScriptValue(engine,element));
  13351. i++;
  13352. }
  13353. return dest;
  13354. }
  13355. /*:157*//*158:*/
  13356. #line 3660 "./typica.w"
  13357. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  13358. {
  13359. QString font= argument<QString> (0,context);
  13360. QString classname;
  13361. if(context->argumentCount()> 1)
  13362. {
  13363. classname= argument<QString> (1,context);
  13364. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  13365. }
  13366. else
  13367. {
  13368. QApplication::setFont(QFont(font));
  13369. }
  13370. return QScriptValue();
  13371. }
  13372. /*:158*//*159:*/
  13373. #line 3680 "./typica.w"
  13374. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  13375. {
  13376. SqlQueryConnection query;
  13377. QString q= "SELECT file FROM files WHERE id = :file";
  13378. query.prepare(q);
  13379. query.bindValue(":file",argument<int> (0,context));
  13380. query.exec();
  13381. query.next();
  13382. QByteArray array= query.value(0).toByteArray();
  13383. QBuffer buffer(&array);
  13384. buffer.open(QIODevice::ReadOnly);
  13385. QXmlQuery xquery;
  13386. xquery.bindVariable("profile",&buffer);
  13387. QString xq;
  13388. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  13389. xquery.setQuery(xq);
  13390. QString result;
  13391. xquery.evaluateTo(&result);
  13392. return QScriptValue(result);
  13393. }
  13394. /*:159*//*160:*/
  13395. #line 3706 "./typica.w"
  13396. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  13397. {
  13398. QWidget::setTabOrder(argument<QWidget*> (0,context),
  13399. argument<QWidget*> (1,context));
  13400. return QScriptValue();
  13401. }
  13402. /*:160*//*167:*/
  13403. #line 3945 "./typica.w"
  13404. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  13405. {
  13406. QString targetID= argument<QString> (0,context);
  13407. QDomNode element;
  13408. QScriptValue object;
  13409. /*168:*/
  13410. #line 3966 "./typica.w"
  13411. QDomNodeList windows=
  13412. AppInstance->configuration()->documentElement().elementsByTagName("window");
  13413. QDomNode nullNode;
  13414. int i= 0;
  13415. element= nullNode;
  13416. while(i<windows.count())
  13417. {
  13418. element= windows.at(i);
  13419. QDomNamedNodeMap attributes= element.attributes();
  13420. if(attributes.contains("id"))
  13421. {
  13422. if(attributes.namedItem("id").toAttr().value()==targetID)
  13423. {
  13424. break;
  13425. }
  13426. }
  13427. element= nullNode;
  13428. i++;
  13429. }
  13430. /*:168*/
  13431. #line 3951 "./typica.w"
  13432. if(!element.isNull())
  13433. {
  13434. /*169:*/
  13435. #line 3998 "./typica.w"
  13436. ScriptQMainWindow*window= new ScriptQMainWindow;
  13437. window->setObjectName(targetID);
  13438. object= engine->newQObject(window);
  13439. setQMainWindowProperties(object,engine);
  13440. QWidget*central= new(QWidget);
  13441. central->setParent(window);
  13442. central->setObjectName("centralWidget");
  13443. window->setCentralWidget(central);
  13444. if(element.hasChildNodes())
  13445. {
  13446. /*170:*/
  13447. #line 4033 "./typica.w"
  13448. QStack<QWidget*> widgetStack;
  13449. QStack<QLayout*> layoutStack;
  13450. QString windowScript;
  13451. widgetStack.push(central);
  13452. QDomNodeList windowChildren= element.childNodes();
  13453. int i= 0;
  13454. while(i<windowChildren.count())
  13455. {
  13456. QDomNode current;
  13457. QDomElement element;
  13458. current= windowChildren.at(i);
  13459. if(current.isElement())
  13460. {
  13461. element= current.toElement();
  13462. if(element.tagName()=="program")
  13463. {
  13464. windowScript.append(element.text());
  13465. }
  13466. else if(element.tagName()=="layout")
  13467. {
  13468. addLayoutToWidget(element,&widgetStack,&layoutStack);
  13469. }
  13470. else if(element.tagName()=="menu")
  13471. {
  13472. /*171:*/
  13473. #line 4080 "./typica.w"
  13474. QMenuBar*bar= window->menuBar();
  13475. bar->setParent(window);
  13476. bar->setObjectName("menuBar");
  13477. if(element.hasAttribute("name"))
  13478. {
  13479. QMenu*menu= bar->addMenu(element.attribute("name"));
  13480. menu->setParent(bar);
  13481. if(element.hasAttribute("type"))
  13482. {
  13483. if(element.attribute("type")=="reports")
  13484. {
  13485. if(element.hasAttribute("src"))
  13486. {
  13487. /*583:*/
  13488. #line 12844 "./typica.w"
  13489. QSettings settings;
  13490. QDir directory(QString("%1/%2").arg(settings.value("config").toString()).
  13491. arg(element.attribute("src")));
  13492. directory.setFilter(QDir::Files);
  13493. directory.setSorting(QDir::Name);
  13494. QStringList nameFilter;
  13495. nameFilter<<"*.xml";
  13496. directory.setNameFilters(nameFilter);
  13497. QFileInfoList reportFiles= directory.entryInfoList();
  13498. for(int i= 0;i<reportFiles.size();i++)
  13499. {
  13500. QFileInfo reportFile= reportFiles.at(i);
  13501. /*587:*/
  13502. #line 12921 "./typica.w"
  13503. QString path= reportFile.absoluteFilePath();
  13504. QFile file(path);
  13505. if(file.open(QIODevice::ReadOnly))
  13506. {
  13507. QDomDocument document;
  13508. document.setContent(&file,true);
  13509. QDomElement root= document.documentElement();
  13510. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  13511. if(!titleNode.isNull())
  13512. {
  13513. QDomElement titleElement= titleNode.toElement();
  13514. QString title= titleElement.text();
  13515. if(!title.isEmpty())
  13516. {
  13517. QStringList hierarchy= title.split(":->");
  13518. QMenu*insertionPoint= menu;
  13519. /*588:*/
  13520. #line 12948 "./typica.w"
  13521. for(int j= 0;j<hierarchy.size()-1;j++)
  13522. {
  13523. QObjectList menuList= insertionPoint->children();
  13524. bool menuFound= false;
  13525. for(int k= 0;k<menuList.size();k++)
  13526. {
  13527. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  13528. if(currentItem)
  13529. {
  13530. if(currentItem->title()==hierarchy.at(j))
  13531. {
  13532. menuFound= true;
  13533. insertionPoint= currentItem;
  13534. break;
  13535. }
  13536. }
  13537. }
  13538. if(!menuFound)
  13539. {
  13540. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  13541. }
  13542. }
  13543. /*:588*/
  13544. #line 12938 "./typica.w"
  13545. ReportAction*action= new ReportAction(path,hierarchy.last());
  13546. insertionPoint->addAction(action);
  13547. }
  13548. }
  13549. }
  13550. /*:587*/
  13551. #line 12857 "./typica.w"
  13552. }
  13553. /*:583*/
  13554. #line 4094 "./typica.w"
  13555. }
  13556. }
  13557. }
  13558. if(element.hasChildNodes())
  13559. {
  13560. /*172:*/
  13561. #line 4107 "./typica.w"
  13562. QDomNodeList menuItems= element.childNodes();
  13563. int j= 0;
  13564. while(j<menuItems.count())
  13565. {
  13566. QDomNode item= menuItems.at(j);
  13567. if(item.isElement())
  13568. {
  13569. QDomElement itemElement= item.toElement();
  13570. if(itemElement.tagName()=="item")
  13571. {
  13572. QAction*itemAction= new QAction(itemElement.text(),menu);
  13573. if(itemElement.hasAttribute("id"))
  13574. {
  13575. itemAction->setObjectName(itemElement.attribute("id"));
  13576. }
  13577. if(itemElement.hasAttribute("shortcut"))
  13578. {
  13579. itemAction->setShortcut(itemElement.attribute("shortcut"));
  13580. }
  13581. menu->addAction(itemAction);
  13582. }
  13583. else if(itemElement.tagName()=="separator")
  13584. {
  13585. menu->addSeparator();
  13586. }
  13587. }
  13588. j++;
  13589. }
  13590. #line 1 "./helpmenu.w"
  13591. /*:172*/
  13592. #line 4100 "./typica.w"
  13593. }
  13594. }
  13595. /*:171*/
  13596. #line 4058 "./typica.w"
  13597. }
  13598. }
  13599. i++;
  13600. }
  13601. QScriptValue oldThis= context->thisObject();
  13602. context->setThisObject(object);
  13603. QScriptValue result= engine->evaluate(windowScript);
  13604. /*164:*/
  13605. #line 3847 "./typica.w"
  13606. if(engine->hasUncaughtException())
  13607. {
  13608. int line= engine->uncaughtExceptionLineNumber();
  13609. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13610. result.toString();
  13611. QString trace;
  13612. foreach(trace,engine->uncaughtExceptionBacktrace())
  13613. {
  13614. qDebug()<<trace;
  13615. }
  13616. }
  13617. /*:164*/
  13618. #line 4066 "./typica.w"
  13619. context->setThisObject(oldThis);
  13620. /*:170*/
  13621. #line 4009 "./typica.w"
  13622. }
  13623. /*173:*/
  13624. #line 9 "./helpmenu.w"
  13625. HelpMenu*helpMenu= new HelpMenu();
  13626. window->menuBar()->addMenu(helpMenu);
  13627. /*:173*/
  13628. #line 4011 "./typica.w"
  13629. window->show();
  13630. /*:169*/
  13631. #line 3954 "./typica.w"
  13632. }
  13633. return object;
  13634. }
  13635. /*:167*//*178:*/
  13636. #line 4149 "./typica.w"
  13637. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  13638. QStack<QLayout*> *layoutStack)
  13639. {
  13640. if(element.hasAttribute("type"))
  13641. {
  13642. /*179:*/
  13643. #line 4170 "./typica.w"
  13644. QLayout*layout;
  13645. QString layoutType= element.attribute("type");
  13646. if(layoutType=="horizontal")
  13647. {
  13648. layout= new QHBoxLayout;
  13649. layoutStack->push(layout);
  13650. populateBoxLayout(element,widgetStack,layoutStack);
  13651. }
  13652. else if(layoutType=="vertical")
  13653. {
  13654. layout= new QVBoxLayout;
  13655. layoutStack->push(layout);
  13656. populateBoxLayout(element,widgetStack,layoutStack);
  13657. }
  13658. else if(layoutType=="grid")
  13659. {
  13660. layout= new QGridLayout;
  13661. layoutStack->push(layout);
  13662. populateGridLayout(element,widgetStack,layoutStack);
  13663. }
  13664. else if(layoutType=="stack")
  13665. {
  13666. layout= new QStackedLayout;
  13667. layoutStack->push(layout);
  13668. populateStackedLayout(element,widgetStack,layoutStack);
  13669. }
  13670. if(element.hasAttribute("id"))
  13671. {
  13672. layout->setObjectName(element.attribute("id"));
  13673. }
  13674. if(element.hasAttribute("spacing"))
  13675. {
  13676. layout->setSpacing(element.attribute("spacing").toInt());
  13677. }
  13678. if(element.hasAttribute("margin"))
  13679. {
  13680. int m= element.attribute("margin").toInt();
  13681. layout->setContentsMargins(m,m,m,m);
  13682. }
  13683. /*:179*/
  13684. #line 4155 "./typica.w"
  13685. QWidget*widget= widgetStack->top();
  13686. if(layout)
  13687. {
  13688. widget->setLayout(layout);
  13689. }
  13690. layoutStack->pop();
  13691. }
  13692. }
  13693. /*:178*//*180:*/
  13694. #line 4217 "./typica.w"
  13695. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  13696. QStack<QLayout*> *layoutStack)
  13697. {
  13698. QDomNodeList children= element.childNodes();
  13699. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  13700. for(int i= 0;i<children.count();i++)
  13701. {
  13702. QDomNode current;
  13703. QDomElement currentElement;
  13704. current= children.at(i);
  13705. if(current.isElement())
  13706. {
  13707. currentElement= current.toElement();
  13708. if(currentElement.tagName()=="page")
  13709. {
  13710. QWidget*widget= new QWidget;
  13711. layout->addWidget(widget);
  13712. widgetStack->push(widget);
  13713. populateWidget(currentElement,widgetStack,layoutStack);
  13714. widgetStack->pop();
  13715. }
  13716. }
  13717. }
  13718. }
  13719. /*:180*//*181:*/
  13720. #line 4249 "./typica.w"
  13721. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  13722. QStack<QLayout*> *layoutStack)
  13723. {
  13724. QDomNodeList children= element.childNodes();
  13725. int row= -1;
  13726. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  13727. for(int i= 0;i<children.count();i++)
  13728. {
  13729. QDomNode current;
  13730. QDomElement currentElement;
  13731. current= children.at(i);
  13732. if(current.isElement())
  13733. {
  13734. currentElement= current.toElement();
  13735. if(currentElement.tagName()=="row")
  13736. {
  13737. row++;
  13738. if(currentElement.hasAttribute("height"))
  13739. {
  13740. layout->setRowMinimumHeight(row,
  13741. currentElement.attribute("height").toInt());
  13742. }
  13743. if(currentElement.hasAttribute("stretch"))
  13744. {
  13745. layout->setRowStretch(row,
  13746. currentElement.attribute("stretch").toInt());
  13747. }
  13748. /*182:*/
  13749. #line 4305 "./typica.w"
  13750. int column= -1;
  13751. QDomNodeList rowChildren= currentElement.childNodes();
  13752. for(int j= 0;j<rowChildren.count();j++)
  13753. {
  13754. QDomNode columnNode;
  13755. QDomElement columnElement;
  13756. columnNode= rowChildren.at(j);
  13757. if(columnNode.isElement())
  13758. {
  13759. columnElement= columnNode.toElement();
  13760. if(columnElement.tagName()=="column")
  13761. {
  13762. column++;
  13763. if(columnElement.hasAttribute("column"))
  13764. {
  13765. column= columnElement.attribute("column").toInt();
  13766. }
  13767. if(columnElement.hasAttribute("width"))
  13768. {
  13769. layout->setColumnMinimumWidth(column,
  13770. columnElement.attribute("width").toInt());
  13771. }
  13772. if(columnElement.hasAttribute("stretch"))
  13773. {
  13774. layout->setColumnStretch(column,
  13775. columnElement.attribute("stretch").toInt());
  13776. }
  13777. int hspan= 1;
  13778. int vspan= 1;
  13779. if(columnElement.hasAttribute("rowspan"))
  13780. {
  13781. vspan= columnElement.attribute("rowspan").toInt();
  13782. }
  13783. if(columnElement.hasAttribute("colspan"))
  13784. {
  13785. hspan= columnElement.attribute("colspan").toInt();
  13786. }
  13787. QHBoxLayout*cell= new QHBoxLayout;
  13788. layout->addLayout(cell,row,column,vspan,hspan);
  13789. layoutStack->push(cell);
  13790. populateBoxLayout(columnElement,widgetStack,layoutStack);
  13791. layoutStack->pop();
  13792. }
  13793. }
  13794. }
  13795. /*:182*/
  13796. #line 4277 "./typica.w"
  13797. }
  13798. }
  13799. }
  13800. }
  13801. /*:181*//*183:*/
  13802. #line 4355 "./typica.w"
  13803. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  13804. QStack<QLayout*> *layoutStack)
  13805. {
  13806. QDomNodeList children= element.childNodes();
  13807. for(int i= 0;i<children.count();i++)
  13808. {
  13809. QDomNode current;
  13810. QDomElement currentElement;
  13811. current= children.at(i);
  13812. if(current.isElement())
  13813. {
  13814. currentElement= current.toElement();
  13815. if(currentElement.tagName()=="button")
  13816. {
  13817. addButtonToLayout(currentElement,widgetStack,layoutStack);
  13818. }
  13819. else if(currentElement.tagName()=="calendar")
  13820. {
  13821. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  13822. }
  13823. else if(currentElement.tagName()=="decoration")
  13824. {
  13825. addDecorationToLayout(currentElement,widgetStack,
  13826. layoutStack);
  13827. }
  13828. else if(currentElement.tagName()=="layout")
  13829. {
  13830. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  13831. }
  13832. else if(currentElement.tagName()=="splitter")
  13833. {
  13834. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  13835. }
  13836. else if(currentElement.tagName()=="label")
  13837. {
  13838. QBoxLayout*layout=
  13839. qobject_cast<QBoxLayout*> (layoutStack->top());
  13840. QLabel*label= new QLabel(currentElement.text());
  13841. layout->addWidget(label);
  13842. }
  13843. else if(currentElement.tagName()=="lcdtemperature")
  13844. {
  13845. addTemperatureDisplayToLayout(currentElement,widgetStack,
  13846. layoutStack);
  13847. }
  13848. else if(currentElement.tagName()=="lcdtimer")
  13849. {
  13850. addTimerDisplayToLayout(currentElement,widgetStack,
  13851. layoutStack);
  13852. }
  13853. else if(currentElement.tagName()=="line")
  13854. {
  13855. addLineToLayout(currentElement,widgetStack,layoutStack);
  13856. }
  13857. else if(currentElement.tagName()=="report")
  13858. {
  13859. addReportToLayout(currentElement,widgetStack,layoutStack);
  13860. }
  13861. else if(currentElement.tagName()=="sqldrop")
  13862. {
  13863. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  13864. }
  13865. else if(currentElement.tagName()=="sqltablearray")
  13866. {
  13867. addSaltToLayout(currentElement,widgetStack,layoutStack);
  13868. }
  13869. else if(currentElement.tagName()=="sqlview")
  13870. {
  13871. addSqlQueryViewToLayout(currentElement,widgetStack,
  13872. layoutStack);
  13873. }
  13874. else if(currentElement.tagName()=="textarea")
  13875. {
  13876. addTextToLayout(currentElement,widgetStack,layoutStack);
  13877. }
  13878. else if(currentElement.tagName()=="spinbox")
  13879. {
  13880. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  13881. }
  13882. else if(currentElement.tagName()=="formarray")
  13883. {
  13884. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  13885. }
  13886. else if(currentElement.tagName()=="hscale")
  13887. {
  13888. addScaleControlToLayout(currentElement,widgetStack,
  13889. layoutStack);
  13890. }
  13891. else if(currentElement.tagName()=="vscale")
  13892. {
  13893. addIntensityControlToLayout(currentElement,widgetStack,
  13894. layoutStack);
  13895. }
  13896. else if(currentElement.tagName()=="webview")
  13897. {
  13898. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  13899. }
  13900. else if(currentElement.tagName()=="stretch")
  13901. {
  13902. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13903. layout->addStretch();
  13904. }
  13905. }
  13906. }
  13907. }
  13908. /*:183*//*184:*/
  13909. #line 4465 "./typica.w"
  13910. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  13911. QStack<QLayout*> *layoutStack)
  13912. {
  13913. QLayout*targetLayout= layoutStack->pop();
  13914. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  13915. if(element.hasAttribute("type"))
  13916. {
  13917. /*179:*/
  13918. #line 4170 "./typica.w"
  13919. QLayout*layout;
  13920. QString layoutType= element.attribute("type");
  13921. if(layoutType=="horizontal")
  13922. {
  13923. layout= new QHBoxLayout;
  13924. layoutStack->push(layout);
  13925. populateBoxLayout(element,widgetStack,layoutStack);
  13926. }
  13927. else if(layoutType=="vertical")
  13928. {
  13929. layout= new QVBoxLayout;
  13930. layoutStack->push(layout);
  13931. populateBoxLayout(element,widgetStack,layoutStack);
  13932. }
  13933. else if(layoutType=="grid")
  13934. {
  13935. layout= new QGridLayout;
  13936. layoutStack->push(layout);
  13937. populateGridLayout(element,widgetStack,layoutStack);
  13938. }
  13939. else if(layoutType=="stack")
  13940. {
  13941. layout= new QStackedLayout;
  13942. layoutStack->push(layout);
  13943. populateStackedLayout(element,widgetStack,layoutStack);
  13944. }
  13945. if(element.hasAttribute("id"))
  13946. {
  13947. layout->setObjectName(element.attribute("id"));
  13948. }
  13949. if(element.hasAttribute("spacing"))
  13950. {
  13951. layout->setSpacing(element.attribute("spacing").toInt());
  13952. }
  13953. if(element.hasAttribute("margin"))
  13954. {
  13955. int m= element.attribute("margin").toInt();
  13956. layout->setContentsMargins(m,m,m,m);
  13957. }
  13958. /*:179*/
  13959. #line 4473 "./typica.w"
  13960. boxLayout->addLayout(layout);
  13961. layoutStack->pop();
  13962. }
  13963. layoutStack->push(targetLayout);
  13964. }
  13965. /*:184*//*185:*/
  13966. #line 4484 "./typica.w"
  13967. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  13968. QStack<QLayout*> *layoutStack)
  13969. {
  13970. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13971. QSplitter*splitter= new(QSplitter);
  13972. layout->addWidget(splitter);
  13973. /*186:*/
  13974. #line 4497 "./typica.w"
  13975. QString orientation= element.attribute("type");
  13976. if(orientation=="horizontal")
  13977. {
  13978. splitter->setOrientation(Qt::Horizontal);
  13979. }
  13980. else if(orientation=="vertical")
  13981. {
  13982. splitter->setOrientation(Qt::Vertical);
  13983. }
  13984. QString id= element.attribute("id");
  13985. if(!id.isEmpty())
  13986. {
  13987. splitter->setObjectName(id);
  13988. }
  13989. if(element.hasChildNodes())
  13990. {
  13991. widgetStack->push(splitter);
  13992. populateSplitter(element,widgetStack,layoutStack);
  13993. widgetStack->pop();
  13994. }
  13995. /*:186*/
  13996. #line 4491 "./typica.w"
  13997. }
  13998. /*:185*//*187:*/
  13999. #line 4523 "./typica.w"
  14000. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  14001. QStack<QLayout*> *layoutStack)
  14002. {
  14003. QDomNodeList children= element.childNodes();
  14004. for(int i= 0;i<children.count();i++)
  14005. {
  14006. QDomNode current;
  14007. QDomElement currentElement;
  14008. current= children.at(i);
  14009. if(current.isElement())
  14010. {
  14011. currentElement= current.toElement();
  14012. if(currentElement.tagName()=="decoration")
  14013. {
  14014. addDecorationToSplitter(currentElement,widgetStack,
  14015. layoutStack);
  14016. }
  14017. else if(currentElement.tagName()=="graph")
  14018. {
  14019. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  14020. }
  14021. else if(currentElement.tagName()=="splitter")
  14022. {
  14023. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  14024. }
  14025. else if(currentElement.tagName()=="lcdtemperature")
  14026. {
  14027. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  14028. layoutStack);
  14029. }
  14030. else if(currentElement.tagName()=="lcdtimer")
  14031. {
  14032. addTimerDisplayToSplitter(currentElement,widgetStack,
  14033. layoutStack);
  14034. }
  14035. else if(currentElement.tagName()=="measurementtable")
  14036. {
  14037. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  14038. }
  14039. else if(currentElement.tagName()=="widget")
  14040. {
  14041. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  14042. }
  14043. }
  14044. }
  14045. }
  14046. /*:187*//*188:*/
  14047. #line 4573 "./typica.w"
  14048. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  14049. QStack<QLayout*> *layoutStack)
  14050. {
  14051. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  14052. QSplitter*splitter= new(QSplitter);
  14053. splitter->setParent(parent);
  14054. parent->addWidget(splitter);
  14055. /*186:*/
  14056. #line 4497 "./typica.w"
  14057. QString orientation= element.attribute("type");
  14058. if(orientation=="horizontal")
  14059. {
  14060. splitter->setOrientation(Qt::Horizontal);
  14061. }
  14062. else if(orientation=="vertical")
  14063. {
  14064. splitter->setOrientation(Qt::Vertical);
  14065. }
  14066. QString id= element.attribute("id");
  14067. if(!id.isEmpty())
  14068. {
  14069. splitter->setObjectName(id);
  14070. }
  14071. if(element.hasChildNodes())
  14072. {
  14073. widgetStack->push(splitter);
  14074. populateSplitter(element,widgetStack,layoutStack);
  14075. widgetStack->pop();
  14076. }
  14077. /*:186*/
  14078. #line 4581 "./typica.w"
  14079. }
  14080. /*:188*//*189:*/
  14081. #line 4590 "./typica.w"
  14082. void addTemperatureDisplayToSplitter(QDomElement element,
  14083. QStack<QWidget*> *widgetStack,
  14084. QStack<QLayout*> *)
  14085. {
  14086. TemperatureDisplay*display= new(TemperatureDisplay);
  14087. if(element.hasAttribute("id"))
  14088. {
  14089. display->setObjectName(element.attribute("id"));
  14090. }
  14091. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14092. splitter->addWidget(display);
  14093. }
  14094. void addTemperatureDisplayToLayout(QDomElement element,
  14095. QStack<QWidget*> *,
  14096. QStack<QLayout*> *layoutStack)
  14097. {
  14098. TemperatureDisplay*display= new(TemperatureDisplay);
  14099. if(element.hasAttribute("id"))
  14100. {
  14101. display->setObjectName(element.attribute("id"));
  14102. }
  14103. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14104. layout->addWidget(display);
  14105. }
  14106. /*:189*//*190:*/
  14107. #line 4621 "./typica.w"
  14108. void addTimerDisplayToSplitter(QDomElement element,
  14109. QStack<QWidget*> *widgetStack,
  14110. QStack<QLayout*> *)
  14111. {
  14112. TimerDisplay*display= new(TimerDisplay);
  14113. if(element.hasAttribute("id"))
  14114. {
  14115. display->setObjectName(element.attribute("id"));
  14116. }
  14117. if(element.hasAttribute("format"))
  14118. {
  14119. display->setDisplayFormat(element.attribute("format"));
  14120. }
  14121. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14122. splitter->addWidget(display);
  14123. }
  14124. void addTimerDisplayToLayout(QDomElement element,
  14125. QStack<QWidget*> *,
  14126. QStack<QLayout*> *layoutStack)
  14127. {
  14128. TimerDisplay*display= new(TimerDisplay);
  14129. if(element.hasAttribute("id"))
  14130. {
  14131. display->setObjectName(element.attribute("id"));
  14132. }
  14133. if(element.hasAttribute("format"))
  14134. {
  14135. display->setDisplayFormat(element.attribute("format"));
  14136. }
  14137. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14138. layout->addWidget(display);
  14139. }
  14140. /*:190*//*191:*/
  14141. #line 4659 "./typica.w"
  14142. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  14143. QStack<QLayout*> *layoutStack)
  14144. {
  14145. /*192:*/
  14146. #line 4680 "./typica.w"
  14147. QString labelText= element.attribute("name");
  14148. Qt::Orientations orientation= Qt::Horizontal;
  14149. if(element.hasAttribute("type"))
  14150. {
  14151. if(element.attribute("type")=="horizontal")
  14152. {
  14153. orientation= Qt::Horizontal;
  14154. }
  14155. else if(element.attribute("type")=="vertical")
  14156. {
  14157. orientation= Qt::Vertical;
  14158. }
  14159. }
  14160. /*193:*/
  14161. #line 4705 "./typica.w"
  14162. QWidget*theWidget= NULL;
  14163. QDomNodeList children= element.childNodes();
  14164. for(int i= 0;i<children.count();i++)
  14165. {
  14166. QDomNode item= children.at(i);
  14167. if(item.isElement())
  14168. {
  14169. QDomElement itemElement= item.toElement();
  14170. if(itemElement.tagName()=="lcdtemperature")
  14171. {
  14172. TemperatureDisplay*display= new TemperatureDisplay;
  14173. if(itemElement.hasAttribute("id"))
  14174. {
  14175. display->setObjectName(itemElement.attribute("id"));
  14176. }
  14177. theWidget= display;
  14178. }
  14179. else if(itemElement.tagName()=="lcdtimer")
  14180. {
  14181. TimerDisplay*display= new TimerDisplay;
  14182. if(itemElement.hasAttribute("id"))
  14183. {
  14184. display->setObjectName(itemElement.attribute("id"));
  14185. }
  14186. if(itemElement.hasAttribute("format"))
  14187. {
  14188. display->setDisplayFormat(itemElement.attribute("format"));
  14189. }
  14190. theWidget= display;
  14191. }
  14192. }
  14193. }
  14194. /*:193*/
  14195. #line 4694 "./typica.w"
  14196. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  14197. orientation);
  14198. if(element.hasAttribute("id"))
  14199. {
  14200. decoration->setObjectName(element.attribute("id"));
  14201. }
  14202. /*:192*/
  14203. #line 4663 "./typica.w"
  14204. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14205. layout->addWidget(decoration);
  14206. }
  14207. void addDecorationToSplitter(QDomElement element,
  14208. QStack<QWidget*> *widgetStack,
  14209. QStack<QLayout*> *)
  14210. {
  14211. /*192:*/
  14212. #line 4680 "./typica.w"
  14213. QString labelText= element.attribute("name");
  14214. Qt::Orientations orientation= Qt::Horizontal;
  14215. if(element.hasAttribute("type"))
  14216. {
  14217. if(element.attribute("type")=="horizontal")
  14218. {
  14219. orientation= Qt::Horizontal;
  14220. }
  14221. else if(element.attribute("type")=="vertical")
  14222. {
  14223. orientation= Qt::Vertical;
  14224. }
  14225. }
  14226. /*193:*/
  14227. #line 4705 "./typica.w"
  14228. QWidget*theWidget= NULL;
  14229. QDomNodeList children= element.childNodes();
  14230. for(int i= 0;i<children.count();i++)
  14231. {
  14232. QDomNode item= children.at(i);
  14233. if(item.isElement())
  14234. {
  14235. QDomElement itemElement= item.toElement();
  14236. if(itemElement.tagName()=="lcdtemperature")
  14237. {
  14238. TemperatureDisplay*display= new TemperatureDisplay;
  14239. if(itemElement.hasAttribute("id"))
  14240. {
  14241. display->setObjectName(itemElement.attribute("id"));
  14242. }
  14243. theWidget= display;
  14244. }
  14245. else if(itemElement.tagName()=="lcdtimer")
  14246. {
  14247. TimerDisplay*display= new TimerDisplay;
  14248. if(itemElement.hasAttribute("id"))
  14249. {
  14250. display->setObjectName(itemElement.attribute("id"));
  14251. }
  14252. if(itemElement.hasAttribute("format"))
  14253. {
  14254. display->setDisplayFormat(itemElement.attribute("format"));
  14255. }
  14256. theWidget= display;
  14257. }
  14258. }
  14259. }
  14260. /*:193*/
  14261. #line 4694 "./typica.w"
  14262. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  14263. orientation);
  14264. if(element.hasAttribute("id"))
  14265. {
  14266. decoration->setObjectName(element.attribute("id"));
  14267. }
  14268. /*:192*/
  14269. #line 4672 "./typica.w"
  14270. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14271. splitter->addWidget(decoration);
  14272. }
  14273. /*:191*//*194:*/
  14274. #line 4744 "./typica.w"
  14275. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  14276. QStack<QLayout*> *layoutStack)
  14277. {
  14278. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14279. QWidget*widget= new QWidget;
  14280. if(element.hasAttribute("id"))
  14281. {
  14282. widget->setObjectName(element.attribute("id"));
  14283. }
  14284. splitter->addWidget(widget);
  14285. if(element.hasChildNodes())
  14286. {
  14287. widgetStack->push(widget);
  14288. populateWidget(element,widgetStack,layoutStack);
  14289. widgetStack->pop();
  14290. }
  14291. }
  14292. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  14293. QStack<QLayout*> *layoutStack)
  14294. {
  14295. QDomNodeList children= element.childNodes();
  14296. for(int i= 0;i<children.count();i++)
  14297. {
  14298. QDomNode current;
  14299. QDomElement currentElement;
  14300. current= children.at(i);
  14301. if(current.isElement())
  14302. {
  14303. currentElement= current.toElement();
  14304. if(currentElement.tagName()=="layout")
  14305. {
  14306. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  14307. }
  14308. }
  14309. }
  14310. }
  14311. /*:194*//*195:*/
  14312. #line 4787 "./typica.w"
  14313. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  14314. QStack<QLayout*> *layoutStack)
  14315. {
  14316. QAbstractButton*button= NULL;
  14317. QString text= element.attribute("name");
  14318. if(element.hasAttribute("type"))
  14319. {
  14320. QString type= element.attribute("type");
  14321. if(type=="annotation")
  14322. {
  14323. AnnotationButton*abutton= new AnnotationButton(text);
  14324. if(element.hasAttribute("annotation"))
  14325. {
  14326. abutton->setAnnotation(element.attribute("annotation"));
  14327. }
  14328. if(element.hasAttribute("series"))
  14329. {
  14330. abutton->setTemperatureColumn(element.attribute("series").
  14331. toInt());
  14332. }
  14333. if(element.hasAttribute("column"))
  14334. {
  14335. abutton->setAnnotationColumn(element.attribute("column").
  14336. toInt());
  14337. }
  14338. button= abutton;
  14339. }
  14340. else if(type=="check")
  14341. {
  14342. button= new QCheckBox(text);
  14343. }
  14344. else if(type=="push")
  14345. {
  14346. button= new QPushButton(text);
  14347. }
  14348. }
  14349. if(element.hasAttribute("id"))
  14350. {
  14351. button->setObjectName(element.attribute("id"));
  14352. }
  14353. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14354. layout->addWidget(button);
  14355. }
  14356. /*:195*//*196:*/
  14357. #line 4839 "./typica.w"
  14358. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  14359. QStack<QLayout*> *layoutStack)
  14360. {
  14361. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  14362. if(element.hasAttribute("pretext"))
  14363. {
  14364. box->setPretext(element.attribute("pretext"));
  14365. }
  14366. if(element.hasAttribute("posttext"))
  14367. {
  14368. box->setPosttext(element.attribute("posttext"));
  14369. }
  14370. if(element.hasAttribute("series"))
  14371. {
  14372. box->setTemperatureColumn(element.attribute("series").toInt());
  14373. }
  14374. if(element.hasAttribute("column"))
  14375. {
  14376. box->setAnnotationColumn(element.attribute("column").toInt());
  14377. }
  14378. if(element.hasAttribute("min"))
  14379. {
  14380. box->setMinimum(element.attribute("min").toDouble());
  14381. }
  14382. if(element.hasAttribute("max"))
  14383. {
  14384. box->setMaximum(element.attribute("max").toDouble());
  14385. }
  14386. if(element.hasAttribute("decimals"))
  14387. {
  14388. box->setDecimals(element.attribute("decimals").toInt());
  14389. }
  14390. if(element.hasAttribute("step"))
  14391. {
  14392. box->setSingleStep(element.attribute("step").toDouble());
  14393. }
  14394. if(element.hasAttribute("id"))
  14395. {
  14396. box->setObjectName(element.attribute("id"));
  14397. }
  14398. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14399. layout->addWidget(box);
  14400. }
  14401. /*:196*//*197:*/
  14402. #line 4895 "./typica.w"
  14403. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  14404. QStack<QLayout*> *)
  14405. {
  14406. ZoomLog*widget= new ZoomLog;
  14407. if(!widget)
  14408. {
  14409. qDebug()<<"Error constructing widget!";
  14410. }
  14411. if(element.hasAttribute("id"))
  14412. {
  14413. widget->setObjectName(element.attribute("id"));
  14414. }
  14415. if(element.hasChildNodes())
  14416. {
  14417. QDomNodeList children= element.childNodes();
  14418. int column= 0;
  14419. for(int i= 0;i<children.count();i++)
  14420. {
  14421. QDomNode current;
  14422. QDomElement currentElement;
  14423. current= children.at(i);
  14424. if(current.isElement())
  14425. {
  14426. currentElement= current.toElement();
  14427. if(currentElement.tagName()=="column")
  14428. {
  14429. QString text= currentElement.text();
  14430. widget->setHeaderData(column,text);
  14431. column++;
  14432. }
  14433. }
  14434. }
  14435. }
  14436. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14437. if(splitter)
  14438. {
  14439. splitter->addWidget(widget);
  14440. }
  14441. else
  14442. {
  14443. qDebug()<<"Splitter not found at top of widget stack!";
  14444. }
  14445. }
  14446. /*:197*//*198:*/
  14447. #line 4943 "./typica.w"
  14448. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  14449. QStack<QLayout*> *)
  14450. {
  14451. GraphView*view= new GraphView;
  14452. if(element.hasAttribute("id"))
  14453. {
  14454. view->setObjectName(element.attribute("id"));
  14455. }
  14456. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  14457. splitter->addWidget(view);
  14458. }
  14459. /*:198*//*199:*/
  14460. #line 4960 "./typica.w"
  14461. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  14462. QStack<QLayout*> *layoutStack)
  14463. {
  14464. SqlComboBox*box= new SqlComboBox();
  14465. if(element.hasAttribute("data"))
  14466. {
  14467. box->setDataColumn(element.attribute("data").toInt());
  14468. }
  14469. if(element.hasAttribute("display"))
  14470. {
  14471. box->setDisplayColumn(element.attribute("display").toInt());
  14472. }
  14473. if(element.hasAttribute("showdata"))
  14474. {
  14475. if(element.attribute("showdata")=="true")
  14476. {
  14477. box->showData(true);
  14478. }
  14479. }
  14480. if(element.hasAttribute("editable"))
  14481. {
  14482. if(element.attribute("editable")=="true")
  14483. {
  14484. box->setEditable(true);
  14485. }
  14486. }
  14487. if(element.hasChildNodes())
  14488. {
  14489. QDomNodeList children= element.childNodes();
  14490. for(int i= 0;i<children.count();i++)
  14491. {
  14492. QDomNode current;
  14493. QDomElement currentElement;
  14494. current= children.at(i);
  14495. if(current.isElement())
  14496. {
  14497. currentElement= current.toElement();
  14498. if(currentElement.tagName()=="null")
  14499. {
  14500. box->addNullOption();
  14501. }
  14502. else if(currentElement.tagName()=="query")
  14503. {
  14504. box->addSqlOptions(currentElement.text());
  14505. }
  14506. }
  14507. }
  14508. }
  14509. if(element.hasAttribute("id"))
  14510. {
  14511. box->setObjectName(element.attribute("id"));
  14512. }
  14513. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14514. layout->addWidget(box);
  14515. }
  14516. /*:199*//*200:*/
  14517. #line 5039 "./typica.w"
  14518. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  14519. QStack<QLayout*> *layoutStack)
  14520. {
  14521. QTableView*view= new QTableView;
  14522. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  14523. SaltModel*model= new SaltModel(element.childNodes().count());
  14524. if(element.hasAttribute("id"))
  14525. {
  14526. view->setObjectName(element.attribute("id"));
  14527. }
  14528. if(element.hasChildNodes())
  14529. {
  14530. QDomNodeList children= element.childNodes();
  14531. int currentColumn= 0;
  14532. for(int i= 0;i<children.count();i++)
  14533. {
  14534. QDomNode current;
  14535. QDomElement currentElement;
  14536. current= children.at(i);
  14537. if(current.isElement())
  14538. {
  14539. currentElement= current.toElement();
  14540. if(currentElement.tagName()=="column")
  14541. {
  14542. if(currentElement.hasAttribute("name"))
  14543. {
  14544. model->setHeaderData(currentColumn,Qt::Horizontal,
  14545. currentElement.attribute("name"));
  14546. }
  14547. if(currentElement.hasAttribute("delegate"))
  14548. {
  14549. /*201:*/
  14550. #line 5087 "./typica.w"
  14551. if(currentElement.attribute("delegate")=="sql")
  14552. {
  14553. /*202:*/
  14554. #line 5103 "./typica.w"
  14555. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  14556. SqlComboBox*widget= new SqlComboBox();
  14557. if(currentElement.hasAttribute("null"))
  14558. {
  14559. if(currentElement.attribute("null")=="true")
  14560. {
  14561. widget->addNullOption();
  14562. }
  14563. }
  14564. if(currentElement.hasAttribute("showdata"))
  14565. {
  14566. if(currentElement.attribute("showdata")=="true")
  14567. {
  14568. widget->showData(true);
  14569. }
  14570. }
  14571. if(currentElement.hasAttribute("data"))
  14572. {
  14573. widget->setDataColumn(currentElement.attribute("data").toInt());
  14574. }
  14575. if(currentElement.hasAttribute("display"))
  14576. {
  14577. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  14578. }
  14579. widget->addSqlOptions(currentElement.text());
  14580. delegate->setWidget(widget);
  14581. view->setItemDelegateForColumn(currentColumn,delegate);
  14582. /*:202*/
  14583. #line 5090 "./typica.w"
  14584. }
  14585. else if(currentElement.attribute("delegate")=="numeric")
  14586. {
  14587. /*203:*/
  14588. #line 5136 "./typica.w"
  14589. NumericDelegate*delegate= new NumericDelegate;
  14590. view->setItemDelegateForColumn(currentColumn,delegate);
  14591. /*:203*/
  14592. #line 5094 "./typica.w"
  14593. }
  14594. /*:201*/
  14595. #line 5071 "./typica.w"
  14596. }
  14597. currentColumn++;
  14598. }
  14599. }
  14600. }
  14601. }
  14602. view->setModel(model);
  14603. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14604. layout->addWidget(view);
  14605. }
  14606. /*:200*//*210:*/
  14607. #line 5246 "./typica.w"
  14608. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  14609. QStack<QLayout*> *layoutStack)
  14610. {
  14611. QLineEdit*widget= new QLineEdit(element.text());
  14612. if(element.hasAttribute("id"))
  14613. {
  14614. widget->setObjectName(element.attribute("id"));
  14615. }
  14616. if(element.hasAttribute("writable"))
  14617. {
  14618. if(element.attribute("writable")=="false")
  14619. {
  14620. widget->setReadOnly(true);
  14621. }
  14622. }
  14623. if(element.hasAttribute("validator"))
  14624. {
  14625. if(element.attribute("validator")=="numeric")
  14626. {
  14627. widget->setValidator(new QDoubleValidator(NULL));
  14628. }
  14629. else if(element.attribute("validator")=="integer")
  14630. {
  14631. widget->setValidator(new QIntValidator(NULL));
  14632. }
  14633. else if(element.attribute("validator")=="expression"&&
  14634. element.hasAttribute("expression"))
  14635. {
  14636. widget->setValidator(new QRegExpValidator(
  14637. QRegExp(element.attribute("expression")),
  14638. NULL));
  14639. }
  14640. }
  14641. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14642. layout->addWidget(widget);
  14643. }
  14644. /*:210*//*211:*/
  14645. #line 5287 "./typica.w"
  14646. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  14647. QStack<QLayout*> *layoutStack)
  14648. {
  14649. QTextEdit*widget= new QTextEdit;
  14650. if(element.hasAttribute("id"))
  14651. {
  14652. widget->setObjectName(element.attribute("id"));
  14653. }
  14654. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14655. layout->addWidget(widget);
  14656. }
  14657. /*:211*//*212:*/
  14658. #line 5304 "./typica.w"
  14659. void addSqlQueryViewToLayout(QDomElement element,
  14660. QStack<QWidget*> *,
  14661. QStack<QLayout*> *layoutStack)
  14662. {
  14663. SqlQueryView*view= new SqlQueryView;
  14664. if(element.hasAttribute("id"))
  14665. {
  14666. view->setObjectName(element.attribute("id"));
  14667. }
  14668. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14669. layout->addWidget(view);
  14670. }
  14671. /*:212*//*213:*/
  14672. #line 5321 "./typica.w"
  14673. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  14674. QStack<QLayout*> *layoutStack)
  14675. {
  14676. QDateEdit*widget= new QDateEdit;
  14677. widget->setCalendarPopup(true);
  14678. if(element.hasAttribute("id"))
  14679. {
  14680. widget->setObjectName(element.attribute("id"));
  14681. }
  14682. widget->setDate(QDate::currentDate());
  14683. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14684. layout->addWidget(widget);
  14685. }
  14686. /*:213*//*214:*/
  14687. #line 5339 "./typica.w"
  14688. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  14689. {
  14690. setQDateTimeEditProperties(value,engine);
  14691. }
  14692. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  14693. {
  14694. setQAbstractSpinBoxProperties(value,engine);
  14695. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  14696. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  14697. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  14698. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  14699. }
  14700. /*:214*//*215:*/
  14701. #line 5359 "./typica.w"
  14702. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  14703. {
  14704. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  14705. if(context->argumentCount()==3)
  14706. {
  14707. self->setDate(QDate(argument<int> (0,context),
  14708. argument<int> (1,context),
  14709. argument<int> (2,context)));
  14710. }
  14711. else
  14712. {
  14713. context->throwError("Incorrect number of arguments passed to "
  14714. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  14715. "specifying the year, month, and day.");
  14716. }
  14717. return QScriptValue();
  14718. }
  14719. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  14720. {
  14721. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  14722. return QScriptValue(self->date().day());
  14723. }
  14724. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  14725. {
  14726. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  14727. return QScriptValue(self->date().month());
  14728. }
  14729. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  14730. {
  14731. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  14732. return QScriptValue(self->date().year());
  14733. }
  14734. /*:215*//*219:*/
  14735. #line 5426 "./typica.w"
  14736. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  14737. {
  14738. QObject*parent= argument<QObject*> (0,context);
  14739. QString name= argument<QString> (1,context);
  14740. QObject*object= parent->findChild<QObject*> (name);
  14741. QScriptValue value;
  14742. if(object)
  14743. {
  14744. value= engine->newQObject(object);
  14745. QString className= object->metaObject()->className();
  14746. /*220:*/
  14747. #line 5444 "./typica.w"
  14748. if(className=="TemperatureDisplay")
  14749. {
  14750. setTemperatureDisplayProperties(value,engine);
  14751. }
  14752. else if(className=="TimerDisplay")
  14753. {
  14754. setTimerDisplayProperties(value,engine);
  14755. }
  14756. else if(className=="QAction")
  14757. {
  14758. setQActionProperties(value,engine);
  14759. }
  14760. else if(className=="QBoxLayout")
  14761. {
  14762. setQBoxLayoutProperties(value,engine);
  14763. }
  14764. else if(className=="QDateEdit")
  14765. {
  14766. setQDateEditProperties(value,engine);
  14767. }
  14768. else if(className=="QFrame")
  14769. {
  14770. setQFrameProperties(value,engine);
  14771. }
  14772. else if(className=="QHBoxLayout")
  14773. {
  14774. setQBoxLayoutProperties(value,engine);
  14775. }
  14776. else if(className=="QLCDNumber")
  14777. {
  14778. setQLCDNumberProperties(value,engine);
  14779. }
  14780. else if(className=="QMenu")
  14781. {
  14782. setQMenuProperties(value,engine);
  14783. }
  14784. else if(className=="QMenuBar")
  14785. {
  14786. setQMenuBarProperties(value,engine);
  14787. }
  14788. else if(className=="QPushButton")
  14789. {
  14790. setQPushButtonProperties(value,engine);
  14791. }
  14792. else if(className=="QSplitter")
  14793. {
  14794. setQSplitterProperties(value,engine);
  14795. }
  14796. else if(className=="QTableView")
  14797. {
  14798. if(object->property("tabletype").isValid())
  14799. {
  14800. if(object->property("tabletype").toString()=="SaltTable")
  14801. {
  14802. setSaltTableProperties(value,engine);
  14803. }
  14804. }
  14805. }
  14806. else if(className=="QVBoxLayout")
  14807. {
  14808. setQBoxLayoutProperties(value,engine);
  14809. }
  14810. else if(className=="QWidget")
  14811. {
  14812. setQWidgetProperties(value,engine);
  14813. }
  14814. else if(className=="ScriptQMainWindow")
  14815. {
  14816. setQMainWindowProperties(value,engine);
  14817. }
  14818. else if(className=="SqlComboBox")
  14819. {
  14820. setSqlComboBoxProperties(value,engine);
  14821. }
  14822. else if(className=="SqlQueryView")
  14823. {
  14824. setSqlQueryViewProperties(value,engine);
  14825. }
  14826. else if(className=="ZoomLog")
  14827. {
  14828. setZoomLogProperties(value,engine);
  14829. }
  14830. else if(className=="QTextEdit")
  14831. {
  14832. setQTextEditProperties(value,engine);
  14833. }
  14834. else if(className=="QWebView")
  14835. {
  14836. setQWebViewProperties(value,engine);
  14837. }
  14838. else if(className=="QLineEdit")
  14839. {
  14840. setQLineEditProperties(value,engine);
  14841. }
  14842. /*:220*/
  14843. #line 5437 "./typica.w"
  14844. }
  14845. return value;
  14846. }
  14847. /*:219*//*222:*/
  14848. #line 5566 "./typica.w"
  14849. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  14850. {
  14851. QTableView*self= getself<QTableView*> (context);
  14852. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14853. QString datum;
  14854. double total= 0.0;
  14855. int column= argument<int> (0,context);
  14856. int role= argument<int> (1,context);
  14857. for(int i= 0;i<model->rowCount();i++)
  14858. {
  14859. datum= model->data(model->index(i,column),role).toString();
  14860. if(!datum.isEmpty())
  14861. {
  14862. total+= datum.toDouble();
  14863. }
  14864. }
  14865. return QScriptValue(engine,total);
  14866. }
  14867. /*:222*//*223:*/
  14868. #line 5590 "./typica.w"
  14869. QScriptValue SaltTable_columnArray(QScriptContext*context,
  14870. QScriptEngine*engine)
  14871. {
  14872. QTableView*self= getself<QTableView*> (context);
  14873. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14874. int column= argument<int> (0,context);
  14875. int role= argument<int> (1,context);
  14876. QString literal= model->arrayLiteral(column,role);
  14877. return QScriptValue(engine,literal);
  14878. }
  14879. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  14880. QScriptEngine*engine)
  14881. {
  14882. QTableView*self= getself<QTableView*> (context);
  14883. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14884. int column= argument<int> (0,context);
  14885. int role= argument<int> (1,context);
  14886. QString literal= model->quotedArrayLiteral(column,role);
  14887. return QScriptValue(engine,literal);
  14888. }
  14889. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  14890. QScriptEngine*engine)
  14891. {
  14892. QTableView*self= getself<QTableView*> (context);
  14893. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14894. int column= argument<int> (0,context);
  14895. int role= argument<int> (1,context);
  14896. QString literal= model->arrayLiteral(column,role);
  14897. literal.chop(1);
  14898. literal= literal.remove(0,1);
  14899. return QScriptValue(engine,literal);
  14900. }
  14901. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  14902. QScriptEngine*engine)
  14903. {
  14904. QTableView*self= getself<QTableView*> (context);
  14905. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14906. int column= argument<int> (0,context);
  14907. int role= argument<int> (1,context);
  14908. QString literal= model->quotedArrayLiteral(column,role);
  14909. literal.chop(1);
  14910. literal= literal.remove(0,1);
  14911. return QScriptValue(engine,literal);
  14912. }
  14913. /*:223*//*224:*/
  14914. #line 5642 "./typica.w"
  14915. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  14916. {
  14917. QTableView*self= getself<QTableView*> (context);
  14918. QScriptValue value= engine->newQObject(self->model());
  14919. return value;
  14920. }
  14921. /*:224*//*225:*/
  14922. #line 5656 "./typica.w"
  14923. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  14924. {
  14925. QTableView*self= getself<QTableView*> (context);
  14926. int row= argument<int> (0,context);
  14927. int column= argument<int> (1,context);
  14928. QVariant value= argument<QVariant> (2,context);
  14929. int role= argument<int> (3,context);
  14930. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14931. QModelIndex cell= model->index(row,column);
  14932. model->setData(cell,value,role);
  14933. self->update(cell);
  14934. return QScriptValue();
  14935. }
  14936. /*:225*//*226:*/
  14937. #line 5674 "./typica.w"
  14938. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  14939. {
  14940. QTableView*self= getself<QTableView*> (context);
  14941. int row= argument<int> (0,context);
  14942. int column= argument<int> (1,context);
  14943. int role= argument<int> (2,context);
  14944. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  14945. QModelIndex cell= model->index(row,column);
  14946. QVariant value= model->data(cell,role);
  14947. QScriptValue retval= engine->newVariant(value);
  14948. retval.setProperty("value",QScriptValue(value.toString()));
  14949. return retval;
  14950. }
  14951. /*:226*//*227:*/
  14952. #line 5692 "./typica.w"
  14953. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  14954. {
  14955. setQWidgetProperties(value,engine);
  14956. value.setProperty("columnArray",
  14957. engine->newFunction(SaltTable_columnArray));
  14958. value.setProperty("quotedColumnArray",
  14959. engine->newFunction(SaltTable_quotedColumnArray));
  14960. value.setProperty("bindableColumnArray",
  14961. engine->newFunction(SaltTable_bindableColumnArray));
  14962. value.setProperty("bindableQuotedColumnArray",
  14963. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  14964. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  14965. value.setProperty("data",engine->newFunction(SaltTable_data));
  14966. value.setProperty("model",engine->newFunction(SaltTable_model));
  14967. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  14968. }
  14969. /*:227*//*229:*/
  14970. #line 5725 "./typica.w"
  14971. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  14972. {
  14973. setQComboBoxProperties(value,engine);
  14974. }
  14975. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  14976. {
  14977. setQWidgetProperties(value,engine);
  14978. value.setProperty("currentData",
  14979. engine->newFunction(QComboBox_currentData));
  14980. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  14981. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  14982. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  14983. }
  14984. QScriptValue QComboBox_currentData(QScriptContext*context,
  14985. QScriptEngine*engine)
  14986. {
  14987. QComboBox*self= getself<QComboBox*> (context);
  14988. return QScriptValue(engine,
  14989. self->itemData(self->currentIndex()).toString());
  14990. }
  14991. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  14992. {
  14993. QComboBox*self= getself<QComboBox*> (context);
  14994. self->addItem(argument<QString> (0,context));
  14995. return QScriptValue();
  14996. }
  14997. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  14998. {
  14999. QComboBox*self= getself<QComboBox*> (context);
  15000. self->setModel(argument<QAbstractItemModel*> (0,context));
  15001. return QScriptValue();
  15002. }
  15003. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  15004. {
  15005. QComboBox*self= getself<QComboBox*> (context);
  15006. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  15007. }
  15008. #line 1 "./abouttypica.w"
  15009. /*:229*//*242:*/
  15010. #line 396 "./units.w"
  15011. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine)
  15012. {
  15013. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  15014. argument<Units::Unit> (1,context),
  15015. argument<Units::Unit> (2,context)));
  15016. }
  15017. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  15018. QScriptEngine*engine)
  15019. {
  15020. return QScriptValue(Units::convertRelativeTemperature(
  15021. argument<double> (0,context),
  15022. argument<Units::Unit> (1,context),
  15023. argument<Units::Unit> (2,context)));
  15024. }
  15025. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine)
  15026. {
  15027. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  15028. }
  15029. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine)
  15030. {
  15031. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  15032. argument<Units::Unit> (1,context),
  15033. argument<Units::Unit> (2,context)));
  15034. }
  15035. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine)
  15036. {
  15037. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  15038. }
  15039. /*:242*//*245:*/
  15040. #line 444 "./units.w"
  15041. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  15042. {
  15043. return engine->newVariant(QVariant(value));
  15044. }
  15045. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  15046. {
  15047. value= sv.toVariant().value<Units::Unit> ();
  15048. }
  15049. /*:245*//*269:*/
  15050. #line 6364 "./typica.w"
  15051. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  15052. {
  15053. QScriptValue object;
  15054. if(context->argumentCount()==1)
  15055. {
  15056. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  15057. QScriptEngine::ScriptOwnership);
  15058. setDAQProperties(object,engine);
  15059. }
  15060. else if(context->argumentCount()==2)
  15061. {
  15062. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  15063. argument<QString> (1,context)),
  15064. QScriptEngine::ScriptOwnership);
  15065. setDAQProperties(object,engine);
  15066. }
  15067. else
  15068. {
  15069. context->throwError("Incorrect number of arguments passed to DAQ"
  15070. "constructor. The DAQ constructor takes one"
  15071. "string as an argument specifying a device name."
  15072. "Example: Dev1");
  15073. }
  15074. return object;
  15075. }
  15076. /*:269*//*270:*/
  15077. #line 6394 "./typica.w"
  15078. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  15079. {
  15080. setQObjectProperties(value,engine);
  15081. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  15082. }
  15083. /*:270*//*271:*/
  15084. #line 6404 "./typica.w"
  15085. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  15086. {
  15087. DAQ*self= getself<DAQ*> (context);
  15088. QScriptValue object;
  15089. if(self)
  15090. {
  15091. object=
  15092. engine->newQObject(self->newChannel(argument<int> (0,context),
  15093. argument<int> (1,context)));
  15094. setChannelProperties(object,engine);
  15095. }
  15096. return object;
  15097. }
  15098. /*:271*//*278:*/
  15099. #line 6560 "./typica.w"
  15100. QScriptValue constructFakeDAQ(QScriptContext*context,
  15101. QScriptEngine*engine)
  15102. {
  15103. QScriptValue object;
  15104. if(context->argumentCount()==1)
  15105. {
  15106. object=
  15107. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  15108. QScriptEngine::ScriptOwnership);
  15109. setFakeDAQProperties(object,engine);
  15110. }
  15111. else
  15112. {
  15113. context->throwError("Incorrect number of arguments passed to DAQ"
  15114. "constructor. The DAQ constructor takes one"
  15115. "string as an argument specifying a device name."
  15116. "Example: Dev1");
  15117. }
  15118. return object;
  15119. }
  15120. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  15121. {
  15122. setQObjectProperties(value,engine);
  15123. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  15124. }
  15125. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  15126. {
  15127. FakeDAQ*self= getself<FakeDAQ*> (context);
  15128. QScriptValue object;
  15129. if(self)
  15130. {
  15131. object=
  15132. engine->newQObject(self->newChannel(argument<int> (0,context),
  15133. argument<int> (1,context)));
  15134. setChannelProperties(object,engine);
  15135. }
  15136. return object;
  15137. }
  15138. /*:278*//*282:*/
  15139. #line 6651 "./typica.w"
  15140. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  15141. {
  15142. setQObjectProperties(value,engine);
  15143. }
  15144. /*:282*//*289:*/
  15145. #line 6843 "./typica.w"
  15146. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  15147. {
  15148. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  15149. setLinearCalibratorProperties(object,engine);
  15150. return object;
  15151. }
  15152. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  15153. {
  15154. setQObjectProperties(value,engine);
  15155. }
  15156. /*:289*//*294:*/
  15157. #line 6981 "./typica.w"
  15158. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  15159. {
  15160. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  15161. setLinearSplineInterpolatorProperties(object,engine);
  15162. return object;
  15163. }
  15164. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  15165. {
  15166. setQObjectProperties(value,engine);
  15167. }
  15168. /*:294*//*304:*/
  15169. #line 7187 "./typica.w"
  15170. QScriptValue constructTemperatureDisplay(QScriptContext*,
  15171. QScriptEngine*engine)
  15172. {
  15173. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  15174. setTemperatureDisplayProperties(object,engine);
  15175. return object;
  15176. }
  15177. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  15178. {
  15179. setQLCDNumberProperties(value,engine);
  15180. value.setProperty("setDisplayUnits",
  15181. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  15182. }
  15183. /*:304*//*305:*/
  15184. #line 7211 "./typica.w"
  15185. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  15186. {
  15187. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  15188. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  15189. return QScriptValue();
  15190. }
  15191. /*:305*//*312:*/
  15192. #line 7348 "./typica.w"
  15193. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  15194. QScriptEngine*engine)
  15195. {
  15196. QScriptValue object=
  15197. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  15198. setMeasurementTimeOffsetProperties(object,engine);
  15199. return object;
  15200. }
  15201. void setMeasurementTimeOffsetProperties(QScriptValue value,
  15202. QScriptEngine*engine)
  15203. {
  15204. setQObjectProperties(value,engine);
  15205. }
  15206. /*:312*//*317:*/
  15207. #line 7457 "./typica.w"
  15208. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  15209. {
  15210. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  15211. return object;
  15212. }
  15213. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  15214. {
  15215. setQObjectProperties(value,engine);
  15216. }
  15217. /*:317*//*322:*/
  15218. #line 7554 "./typica.w"
  15219. QScriptValue constructZeroEmitter(QScriptContext*context,
  15220. QScriptEngine*engine)
  15221. {
  15222. QScriptValue object=
  15223. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  15224. setZeroEmitterProperties(object,engine);
  15225. return object;
  15226. }
  15227. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  15228. {
  15229. setQObjectProperties(value,engine);
  15230. }
  15231. /*:322*//*327:*/
  15232. #line 7634 "./typica.w"
  15233. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  15234. QScriptEngine*engine)
  15235. {
  15236. QScriptValue object=
  15237. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  15238. setMeasurementAdapterProperties(object,engine);
  15239. return object;
  15240. }
  15241. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  15242. {
  15243. setQObjectProperties(value,engine);
  15244. }
  15245. /*:327*//*344:*/
  15246. #line 8096 "./typica.w"
  15247. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  15248. {
  15249. QScriptValue object= engine->newQObject(new GraphView);
  15250. setGraphViewProperties(object,engine);
  15251. return object;
  15252. }
  15253. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  15254. {
  15255. setQGraphicsViewProperties(value,engine);
  15256. }
  15257. /*:344*//*367:*/
  15258. #line 8734 "./typica.w"
  15259. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  15260. {
  15261. QScriptValue object= engine->newQObject(new ZoomLog);
  15262. setZoomLogProperties(object,engine);
  15263. return object;
  15264. }
  15265. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  15266. {
  15267. setQTableViewProperties(value,engine);
  15268. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  15269. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  15270. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  15271. value.setProperty("restoreState",
  15272. engine->newFunction(ZoomLog_restoreState));
  15273. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  15274. value.setProperty("saveTemporary",
  15275. engine->newFunction(ZoomLog_saveTemporary));
  15276. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  15277. }
  15278. /*:367*//*368:*/
  15279. #line 8761 "./typica.w"
  15280. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  15281. {
  15282. ZoomLog*self= getself<ZoomLog*> (context);
  15283. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  15284. return QScriptValue(engine,retval);
  15285. }
  15286. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  15287. {
  15288. ZoomLog*self= getself<ZoomLog*> (context);
  15289. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  15290. return QScriptValue(engine,retval);
  15291. }
  15292. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  15293. QScriptEngine*engine)
  15294. {
  15295. ZoomLog*self= getself<ZoomLog*> (context);
  15296. QString filename= QDir::tempPath();
  15297. filename.append("/");
  15298. filename.append(QUuid::createUuid().toString());
  15299. filename.append(".xml");
  15300. QFile*file= new QFile(filename);
  15301. self->saveXML(file);
  15302. file->close();
  15303. delete file;
  15304. return QScriptValue(engine,filename);
  15305. }
  15306. /*:368*//*369:*/
  15307. #line 8809 "./typica.w"
  15308. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  15309. {
  15310. ZoomLog*self= getself<ZoomLog*> (context);
  15311. QString key= argument<QString> (0,context);
  15312. int columns= argument<int> (1,context);
  15313. QSettings settings;
  15314. for(int i= 0;i<columns;i++)
  15315. {
  15316. if(self->columnWidth(i))
  15317. {
  15318. settings.beginGroup(key);
  15319. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  15320. settings.endGroup();
  15321. }
  15322. }
  15323. return QScriptValue();
  15324. }
  15325. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  15326. {
  15327. ZoomLog*self= getself<ZoomLog*> (context);
  15328. QString key= argument<QString> (0,context);
  15329. int columns= argument<int> (1,context);
  15330. QSettings settings;
  15331. for(int i= 0;i<columns;i++)
  15332. {
  15333. settings.beginGroup(key);
  15334. self->setColumnWidth(i,
  15335. settings.value(QString("%1").arg(i),80).toInt());
  15336. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  15337. {
  15338. self->setColumnWidth(i,80);
  15339. }
  15340. settings.endGroup();
  15341. }
  15342. return QScriptValue();
  15343. }
  15344. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  15345. {
  15346. ZoomLog*self= getself<ZoomLog*> (context);
  15347. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  15348. }
  15349. /*:369*//*370:*/
  15350. #line 8862 "./typica.w"
  15351. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  15352. {
  15353. ZoomLog*self= getself<ZoomLog*> (context);
  15354. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  15355. return QScriptValue();
  15356. }
  15357. /*:370*//*405:*/
  15358. #line 9679 "./typica.w"
  15359. QScriptValue constructAnnotationButton(QScriptContext*context,
  15360. QScriptEngine*engine)
  15361. {
  15362. QScriptValue object=
  15363. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  15364. setAnnotationButtonProperties(object,engine);
  15365. return object;
  15366. }
  15367. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  15368. {
  15369. setQPushButtonProperties(value,engine);
  15370. }
  15371. /*:405*//*413:*/
  15372. #line 9822 "./typica.w"
  15373. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  15374. QScriptEngine*engine)
  15375. {
  15376. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  15377. argument<QString> (0,context),argument<QString> (1,context)));
  15378. setAnnotationSpinBoxProperties(object,engine);
  15379. return object;
  15380. }
  15381. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  15382. {
  15383. setQDoubleSpinBoxProperties(value,engine);
  15384. }
  15385. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  15386. {
  15387. setQAbstractSpinBoxProperties(value,engine);
  15388. }
  15389. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  15390. {
  15391. setQWidgetProperties(value,engine);
  15392. }
  15393. /*:413*//*434:*/
  15394. #line 10241 "./typica.w"
  15395. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  15396. {
  15397. QScriptValue object= engine->newQObject(new TimerDisplay);
  15398. setTimerDisplayProperties(object,engine);
  15399. return object;
  15400. }
  15401. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  15402. {
  15403. setQLCDNumberProperties(value,engine);
  15404. }
  15405. /*:434*//*461:*/
  15406. #line 10736 "./typica.w"
  15407. QScriptValue constructWidgetDecorator(QScriptContext*context,
  15408. QScriptEngine*engine)
  15409. {
  15410. QWidget*widget= argument<QWidget*> (0,context);
  15411. QString text= argument<QString> (1,context);
  15412. Qt::Orientations orientation;
  15413. switch(argument<int> (2,context))
  15414. {
  15415. case 2:
  15416. orientation= Qt::Vertical;
  15417. break;
  15418. default:
  15419. orientation= Qt::Horizontal;
  15420. break;
  15421. }
  15422. QScriptValue object=
  15423. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  15424. setWidgetDecoratorProperties(object,engine);
  15425. return object;
  15426. }
  15427. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  15428. {
  15429. setQWidgetProperties(value,engine);
  15430. }
  15431. /*:461*//*474:*/
  15432. #line 11017 "./typica.w"
  15433. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  15434. {
  15435. QScriptValue object= engine->newQObject(new LogEditWindow);
  15436. return object;
  15437. }
  15438. /*:474*//*493:*/
  15439. #line 11549 "./typica.w"
  15440. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  15441. {
  15442. QIODevice*device= argument<QIODevice*> (0,context);
  15443. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  15444. argument<int> (1,context)));
  15445. object.setProperty("input",engine->newFunction(XMLInput_input));
  15446. return object;
  15447. }
  15448. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  15449. {
  15450. XMLInput*self= getself<XMLInput*> (context);
  15451. self->input();
  15452. return QScriptValue();
  15453. }
  15454. /*:493*//*507:*/
  15455. #line 152 "./webview.w"
  15456. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  15457. {
  15458. QScriptValue object= engine->newQObject(new TypicaWebView);
  15459. setQWebViewProperties(object,engine);
  15460. return object;
  15461. }
  15462. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  15463. {
  15464. setQWidgetProperties(value,engine);
  15465. }
  15466. /*:507*//*508:*/
  15467. #line 169 "./webview.w"
  15468. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  15469. QStack<QLayout*> *layoutStack)
  15470. {
  15471. TypicaWebView*view= new TypicaWebView;
  15472. if(element.hasAttribute("id"))
  15473. {
  15474. view->setObjectName(element.attribute("id"));
  15475. }
  15476. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15477. layout->addWidget(view);
  15478. }
  15479. /*:508*//*513:*/
  15480. #line 220 "./webview.w"
  15481. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  15482. {
  15483. QVariant var;
  15484. var.setValue(element);
  15485. QScriptValue object= engine->newVariant(var);
  15486. return object;
  15487. }
  15488. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  15489. {
  15490. element= value.toVariant().value<QWebElement> ();
  15491. }
  15492. /*:513*//*518:*/
  15493. #line 285 "./webview.w"
  15494. template<> QWebElement argument(int arg,QScriptContext*context)
  15495. {
  15496. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  15497. }
  15498. /*:518*//*519:*/
  15499. #line 294 "./webview.w"
  15500. QScriptValue constructWebElement(QScriptContext*context,
  15501. QScriptEngine*engine)
  15502. {
  15503. QWebElement element= argument<QWebElement> (0,context);
  15504. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  15505. return object;
  15506. }
  15507. /*:519*//*581:*/
  15508. #line 12770 "./typica.w"
  15509. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  15510. {
  15511. QScriptValue object= engine->newQObject(new SqlQueryView);
  15512. setSqlQueryViewProperties(object,engine);
  15513. return object;
  15514. }
  15515. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  15516. {
  15517. setQTableViewProperties(value,engine);
  15518. value.setProperty("setHeaderData",
  15519. engine->newFunction(SqlQueryView_setHeaderData));
  15520. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  15521. }
  15522. /*:581*//*582:*/
  15523. #line 12788 "./typica.w"
  15524. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  15525. {
  15526. SqlQueryView*self= getself<SqlQueryView*> (context);
  15527. QString query= argument<QString> (0,context);
  15528. self->setQuery(query);
  15529. self->reset();
  15530. return QScriptValue();
  15531. }
  15532. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  15533. QScriptEngine*)
  15534. {
  15535. SqlQueryView*self= getself<SqlQueryView*> (context);
  15536. int section= argument<int> (0,context);
  15537. QString data= argument<QString> (1,context);
  15538. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  15539. return QScriptValue();
  15540. }
  15541. /*:582*//*590:*/
  15542. #line 12987 "./typica.w"
  15543. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  15544. QStack<QLayout*> *layoutStack)
  15545. {
  15546. QTextEdit*widget= new QTextEdit;
  15547. if(element.hasAttribute("id"))
  15548. {
  15549. widget->setObjectName(element.attribute("id"));
  15550. }
  15551. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15552. layout->addWidget(widget);
  15553. QTextDocument*document= new QTextDocument;
  15554. QFont defaultFont;
  15555. defaultFont.setPointSize(11);
  15556. document->setDefaultFont(defaultFont);
  15557. QTextCursor cursor(document);
  15558. /*591:*/
  15559. #line 13010 "./typica.w"
  15560. QDomNodeList children= element.childNodes();
  15561. for(int i= 0;i<children.count();i++)
  15562. {
  15563. QDomNode current;
  15564. QDomElement currentElement;
  15565. current= children.at(i);
  15566. if(current.isElement())
  15567. {
  15568. currentElement= current.toElement();
  15569. /*592:*/
  15570. #line 13027 "./typica.w"
  15571. if(currentElement.tagName()=="style")
  15572. {
  15573. document->setDefaultStyleSheet(currentElement.text());
  15574. }
  15575. /*:592*//*593:*/
  15576. #line 13038 "./typica.w"
  15577. if(currentElement.tagName()=="html")
  15578. {
  15579. cursor.insertHtml(currentElement.text());
  15580. }
  15581. /*:593*//*594:*/
  15582. #line 13048 "./typica.w"
  15583. if(currentElement.tagName()=="text")
  15584. {
  15585. cursor.insertText(currentElement.text());
  15586. }
  15587. /*:594*//*595:*/
  15588. #line 13058 "./typica.w"
  15589. if(currentElement.tagName()=="table")
  15590. {
  15591. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  15592. ReportTable*table= new ReportTable(frame,currentElement);
  15593. table->setParent(widget);
  15594. if(currentElement.hasAttribute("id"))
  15595. {
  15596. table->setObjectName(currentElement.attribute("id"));
  15597. }
  15598. }
  15599. /*:595*/
  15600. #line 13020 "./typica.w"
  15601. }
  15602. }
  15603. /*:591*/
  15604. #line 13003 "./typica.w"
  15605. widget->setDocument(document);
  15606. }
  15607. /*:590*//*606:*/
  15608. #line 13270 "./typica.w"
  15609. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  15610. {
  15611. QTextEdit*self= getself<QTextEdit*> (context);
  15612. QTextDocument*document= self->document();
  15613. QPrinter printer;
  15614. QPrintDialog printwindow(&printer,self);
  15615. if(printwindow.exec()!=QDialog::Accepted)
  15616. {
  15617. return QScriptValue();
  15618. }
  15619. document->print(&printer);
  15620. return QScriptValue();
  15621. }
  15622. /*:606*//*607:*/
  15623. #line 13288 "./typica.w"
  15624. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  15625. {
  15626. setQAbstractScrollAreaProperties(value,engine);
  15627. value.setProperty("print",engine->newFunction(QTextEdit_print));
  15628. }
  15629. /*:607*//*616:*/
  15630. #line 13466 "./typica.w"
  15631. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  15632. QStack<QLayout*> *layoutStack)
  15633. {
  15634. FormArray*widget= new FormArray(element);
  15635. if(element.hasAttribute("id"))
  15636. {
  15637. widget->setObjectName(element.attribute("id"));
  15638. }
  15639. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15640. layout->addWidget(widget);
  15641. }
  15642. /*:616*//*637:*/
  15643. #line 14053 "./typica.w"
  15644. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  15645. QStack<QLayout*> *layoutStack)
  15646. {
  15647. ScaleControl*scale= new ScaleControl;
  15648. if(element.hasAttribute("id"))
  15649. {
  15650. scale->setObjectName(element.attribute("id"));
  15651. }
  15652. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15653. layout->addWidget(scale);
  15654. }
  15655. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  15656. QStack<QLayout*> *layoutStack)
  15657. {
  15658. IntensityControl*scale= new IntensityControl;
  15659. if(element.hasAttribute("id"))
  15660. {
  15661. scale->setObjectName(element.attribute("id"));
  15662. }
  15663. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15664. layout->addWidget(scale);
  15665. }
  15666. /*:637*//*663:*/
  15667. #line 14643 "./typica.w"
  15668. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  15669. {
  15670. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  15671. setDeviceTreeModelProperties(object,engine);
  15672. return object;
  15673. }
  15674. /*:663*//*665:*/
  15675. #line 14666 "./typica.w"
  15676. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  15677. {
  15678. setQAbstractItemModelProperties(value,engine);
  15679. value.setProperty("referenceElement",
  15680. engine->newFunction(DeviceTreeModel_referenceElement));
  15681. }
  15682. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  15683. {
  15684. setQObjectProperties(value,engine);
  15685. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  15686. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  15687. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  15688. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  15689. }
  15690. /*:665*//*666:*/
  15691. #line 14693 "./typica.w"
  15692. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  15693. QScriptEngine*engine)
  15694. {
  15695. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  15696. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  15697. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15698. QDomElement node;
  15699. QVariantMap retval;
  15700. retval.insert("driver",referenceElement.attribute("driver"));
  15701. for(int i= 0;i<configData.size();i++)
  15702. {
  15703. node= configData.at(i).toElement();
  15704. retval.insert(node.attribute("name"),node.attribute("value"));
  15705. }
  15706. return engine->toScriptValue(retval);
  15707. }
  15708. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  15709. {
  15710. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  15711. QModelIndex index= argument<QModelIndex> (0,context);
  15712. int role= argument<int> (1,context);
  15713. return engine->toScriptValue(model->data(index,role));
  15714. }
  15715. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  15716. {
  15717. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  15718. int row= 0;
  15719. int column= 0;
  15720. QModelIndex index;
  15721. if(context->argumentCount()> 1)
  15722. {
  15723. row= argument<int> (0,context);
  15724. column= argument<int> (1,context);
  15725. }
  15726. if(context->argumentCount()> 2)
  15727. {
  15728. index= argument<QModelIndex> (2,context);
  15729. }
  15730. QModelIndex retval= model->index(row,column,index);
  15731. return engine->toScriptValue(retval);
  15732. }
  15733. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  15734. QScriptEngine*)
  15735. {
  15736. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  15737. QModelIndex index;
  15738. if(context->argumentCount()==1)
  15739. {
  15740. index= argument<QModelIndex> (0,context);
  15741. }
  15742. return QScriptValue(model->rowCount(index));
  15743. }
  15744. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  15745. QScriptEngine*engine)
  15746. {
  15747. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  15748. QModelIndex index;
  15749. if(context->argumentCount()==1)
  15750. {
  15751. index= argument<QModelIndex> (0,context);
  15752. }
  15753. return QScriptValue(engine,model->hasChildren(index));
  15754. }
  15755. /*:666*//*669:*/
  15756. #line 14777 "./typica.w"
  15757. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  15758. {
  15759. QVariant var;
  15760. var.setValue(index);
  15761. QScriptValue object= engine->newVariant(var);
  15762. return object;
  15763. }
  15764. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  15765. {
  15766. index= value.toVariant().value<QModelIndex> ();
  15767. }
  15768. /*:669*//*685:*/
  15769. #line 15074 "./typica.w"
  15770. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  15771. QScriptEngine*engine)
  15772. {
  15773. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  15774. return object;
  15775. }
  15776. /*:685*//*756:*/
  15777. #line 42 "./settings.w"
  15778. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  15779. {
  15780. QScriptValue object= engine->newQObject(new SettingsWindow);
  15781. return object;
  15782. }
  15783. /*:756*//*776:*/
  15784. #line 17623 "./typica.w"
  15785. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  15786. {
  15787. QScriptValue object;
  15788. if(context->argumentCount()==2)
  15789. {
  15790. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  15791. argument<QModelIndex> (1,context)),
  15792. QScriptEngine::ScriptOwnership);
  15793. setModbusRTUDeviceProperties(object,engine);
  15794. }
  15795. else
  15796. {
  15797. context->throwError("Incorrect number of arguments passed to "
  15798. "ModbusRTUDevice constructor. This takes the configuration model "
  15799. "and an index.");
  15800. }
  15801. return object;
  15802. }
  15803. /*:776*//*777:*/
  15804. #line 17645 "./typica.w"
  15805. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  15806. {
  15807. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  15808. QScriptValue object;
  15809. if(self)
  15810. {
  15811. if(self->channels.size()> 0)
  15812. {
  15813. object= engine->newQObject(self->channels.at(0));
  15814. setChannelProperties(object,engine);
  15815. }
  15816. }
  15817. return object;
  15818. }
  15819. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  15820. {
  15821. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  15822. QScriptValue object;
  15823. if(self)
  15824. {
  15825. if(self->channels.size()> 1)
  15826. {
  15827. object= engine->newQObject(self->channels.at(1));
  15828. setChannelProperties(object,engine);
  15829. }
  15830. }
  15831. return object;
  15832. }
  15833. /*:777*//*778:*/
  15834. #line 17678 "./typica.w"
  15835. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  15836. {
  15837. setQObjectProperties(value,engine);
  15838. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  15839. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  15840. }
  15841. /*:778*//*800:*/
  15842. #line 170 "./rate.w"
  15843. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  15844. {
  15845. int cachetime= 1;
  15846. int scaletime= 1;
  15847. if(context->argumentCount()> 0)
  15848. {
  15849. cachetime= argument<int> (0,context);
  15850. if(context->argumentCount()> 1)
  15851. {
  15852. scaletime= argument<int> (1,context);
  15853. }
  15854. }
  15855. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  15856. setRateOfChangeProperties(object,engine);
  15857. return object;
  15858. }
  15859. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  15860. {
  15861. setQObjectProperties(value,engine);
  15862. }
  15863. /*:800*//*825:*/
  15864. #line 614 "./dataqsdk.w"
  15865. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  15866. {
  15867. QScriptValue object;
  15868. if(context->argumentCount()==1)
  15869. {
  15870. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  15871. QScriptEngine::ScriptOwnership);
  15872. setDataqSdkDeviceProperties(object,engine);
  15873. }
  15874. else
  15875. {
  15876. context->throwError("Incorrect number of arguments passed to "
  15877. "DataqSdkDevice. The constructor takes one string "
  15878. "as an argument specifying a device name. "
  15879. "Example: Dev1");
  15880. }
  15881. return object;
  15882. }
  15883. /*:825*//*826:*/
  15884. #line 637 "./dataqsdk.w"
  15885. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  15886. {
  15887. setQObjectProperties(value,engine);
  15888. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  15889. }
  15890. /*:826*//*827:*/
  15891. #line 647 "./dataqsdk.w"
  15892. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  15893. {
  15894. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  15895. QScriptValue object;
  15896. if(self)
  15897. {
  15898. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  15899. setChannelProperties(object,engine);
  15900. }
  15901. return object;
  15902. }
  15903. /*:827*//*852:*/
  15904. #line 80 "./scales.w"
  15905. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  15906. {
  15907. QScriptValue object;
  15908. QString labelText= "";
  15909. if(context->argumentCount()==1)
  15910. {
  15911. labelText= argument<QString> (0,context);
  15912. }
  15913. object= engine->newQObject(new DragLabel(labelText));
  15914. setDragLabelProperties(object,engine);
  15915. return object;
  15916. }
  15917. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  15918. {
  15919. setQLabelProperties(value,engine);
  15920. }
  15921. /*:852*//*862:*/
  15922. #line 272 "./scales.w"
  15923. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  15924. {
  15925. return engine->newVariant(QVariant((int)(value)));
  15926. }
  15927. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  15928. {
  15929. value= (BaudRateType)(sv.toVariant().toInt());
  15930. }
  15931. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  15932. {
  15933. return engine->newVariant(QVariant((int)(value)));
  15934. }
  15935. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  15936. {
  15937. value= (DataBitsType)(sv.toVariant().toInt());
  15938. }
  15939. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  15940. {
  15941. return engine->newVariant(QVariant((int)(value)));
  15942. }
  15943. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  15944. {
  15945. value= (ParityType)(sv.toVariant().toInt());
  15946. }
  15947. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  15948. {
  15949. return engine->newVariant(QVariant((int)(value)));
  15950. }
  15951. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  15952. {
  15953. value= (StopBitsType)(sv.toVariant().toInt());
  15954. }
  15955. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  15956. {
  15957. return engine->newVariant(QVariant((int)(value)));
  15958. }
  15959. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  15960. {
  15961. value= (FlowType)(sv.toVariant().toInt());
  15962. }
  15963. /*:862*//*865:*/
  15964. #line 341 "./scales.w"
  15965. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  15966. {
  15967. setQIODeviceProperties(value,engine);
  15968. }
  15969. /*:865*//*866:*/
  15970. #line 349 "./scales.w"
  15971. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  15972. {
  15973. QScriptValue object;
  15974. if(context->argumentCount()==1)
  15975. {
  15976. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  15977. setSerialScaleProperties(object,engine);
  15978. }
  15979. else
  15980. {
  15981. context->throwError("Incorrect number of arguments passed to "
  15982. "SerialScale. The constructor takes one string "
  15983. "as an argument specifying a port name.");
  15984. }
  15985. return object;
  15986. }
  15987. /*:866*//*888:*/
  15988. #line 278 "./valueannotation.w"
  15989. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine)
  15990. {
  15991. QScriptValue object= engine->newQObject(new ValueAnnotation);
  15992. setValueAnnotationProperties(object,engine);
  15993. return object;
  15994. }
  15995. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  15996. {
  15997. setQObjectProperties(value,engine);
  15998. }
  15999. #line 18448 "./typica.w"
  16000. /*:888*/
  16001. #line 764 "./typica.w"
  16002. /*560:*/
  16003. #line 12407 "./typica.w"
  16004. int main(int argc,char**argv)
  16005. {
  16006. int*c= &argc;
  16007. Application app(*c,argv);
  16008. /*561:*/
  16009. #line 12433 "./typica.w"
  16010. QStringList themeSearchPath= QIcon::themeSearchPaths();
  16011. themeSearchPath.append(":/resources/icons/tango");
  16012. QIcon::setThemeSearchPaths(themeSearchPath);
  16013. QIcon::setThemeName(":/resources/icons/tango");
  16014. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  16015. /*:561*/
  16016. #line 12412 "./typica.w"
  16017. /*562:*/
  16018. #line 12450 "./typica.w"
  16019. QFile entypo(":/resources/fonts/entypo.ttf");
  16020. entypo.open(QIODevice::ReadOnly);
  16021. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  16022. entypo.close();
  16023. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  16024. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  16025. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  16026. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  16027. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  16028. /*:562*/
  16029. #line 12413 "./typica.w"
  16030. QSettings settings;
  16031. /*695:*/
  16032. #line 15294 "./typica.w"
  16033. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  16034. /*:695*//*705:*/
  16035. #line 15536 "./typica.w"
  16036. app.registerDeviceConfigurationWidget("nidaqmxbase",
  16037. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  16038. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  16039. NiDaqMxBase9211ConfWidget::staticMetaObject);
  16040. app.registerDeviceConfigurationWidget("ni9211seriestc",
  16041. Ni9211TcConfWidget::staticMetaObject);
  16042. /*:705*//*713:*/
  16043. #line 15767 "./typica.w"
  16044. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  16045. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  16046. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  16047. /*:713*//*737:*/
  16048. #line 16732 "./typica.w"
  16049. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  16050. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  16051. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  16052. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  16053. /*:737*//*742:*/
  16054. #line 16817 "./typica.w"
  16055. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  16056. /*:742*//*745:*/
  16057. #line 16887 "./typica.w"
  16058. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  16059. /*:745*//*748:*/
  16060. #line 17014 "./typica.w"
  16061. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  16062. #line 1 "./freeannotation.w"
  16063. /*:748*//*752:*/
  16064. #line 57 "./freeannotation.w"
  16065. app.registerDeviceConfigurationWidget("freeannotation",
  16066. FreeAnnotationConfWidget::staticMetaObject);
  16067. #line 17018 "./typica.w"
  16068. #line 1 "./settings.w"
  16069. /*:752*//*781:*/
  16070. #line 18219 "./typica.w"
  16071. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  16072. /*:781*//*788:*/
  16073. #line 18349 "./typica.w"
  16074. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  16075. /*:788*//*792:*/
  16076. #line 18438 "./typica.w"
  16077. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  16078. #line 1 "./rate.w"
  16079. /*:792*//*804:*/
  16080. #line 272 "./rate.w"
  16081. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  16082. /*:804*//*845:*/
  16083. #line 1233 "./dataqsdk.w"
  16084. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  16085. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  16086. DataqSdkChannelConfWidget::staticMetaObject);
  16087. /*:845*//*870:*/
  16088. #line 490 "./scales.w"
  16089. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  16090. /*:870*//*878:*/
  16091. #line 138 "./valueannotation.w"
  16092. app.registerDeviceConfigurationWidget("valueannotation",
  16093. ValueAnnotationConfWidget::staticMetaObject);
  16094. /*:878*/
  16095. #line 12417 "./typica.w"
  16096. /*563:*/
  16097. #line 12467 "./typica.w"
  16098. if(settings.value("database/exists","false").toString()=="true")
  16099. {
  16100. /*568:*/
  16101. #line 12588 "./typica.w"
  16102. QSqlDatabase database=
  16103. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  16104. database.setConnectOptions("application_name=Typica");
  16105. database.setHostName(settings.value("database/hostname").toString());
  16106. database.setDatabaseName(settings.value("database/dbname").toString());
  16107. database.setUserName(settings.value("database/user").toString());
  16108. database.setPassword(settings.value("database/password").toString());
  16109. if(!database.open())
  16110. {
  16111. settings.setValue("database/exists","false");
  16112. }
  16113. /*:568*/
  16114. #line 12470 "./typica.w"
  16115. }
  16116. if(settings.value("database/exists","false").toString()=="false")
  16117. {
  16118. /*567:*/
  16119. #line 12579 "./typica.w"
  16120. SqlConnectionSetup dialog;
  16121. dialog.exec();
  16122. /*:567*/
  16123. #line 12474 "./typica.w"
  16124. }
  16125. /*:563*/
  16126. #line 12418 "./typica.w"
  16127. /*161:*/
  16128. #line 3740 "./typica.w"
  16129. QStringList arguments= QCoreApplication::arguments();
  16130. int position= arguments.indexOf("-c");
  16131. QString filename= QString();
  16132. if(position!=-1)
  16133. {
  16134. if(arguments.size()>=position+1)
  16135. {
  16136. filename= arguments.at(position+1);
  16137. }
  16138. }
  16139. if(filename.isEmpty())
  16140. {
  16141. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  16142. settings.value("config","").toString());
  16143. }
  16144. QDir directory;
  16145. if(!filename.isEmpty())
  16146. {
  16147. QFile file(filename);
  16148. QFileInfo info(filename);
  16149. directory= info.dir();
  16150. settings.setValue("config",directory.path());
  16151. if(file.open(QIODevice::ReadOnly))
  16152. {
  16153. app.configuration()->setContent(&file,true);
  16154. }
  16155. }
  16156. /*162:*/
  16157. #line 3774 "./typica.w"
  16158. QDomElement root= app.configuration()->documentElement();
  16159. QDomNodeList children= root.childNodes();
  16160. QString replacementDoc;
  16161. QDomDocument includedDoc;
  16162. QDomDocumentFragment fragment;
  16163. for(int i= 0;i<children.size();i++)
  16164. {
  16165. QDomNode currentNode= children.at(i);
  16166. QDomElement currentElement;
  16167. if(currentNode.nodeName()=="include")
  16168. {
  16169. currentElement= currentNode.toElement();
  16170. if(currentElement.hasAttribute("src"))
  16171. {
  16172. replacementDoc= directory.path();
  16173. replacementDoc.append('/');
  16174. replacementDoc.append(currentElement.attribute("src"));
  16175. QFile doc(replacementDoc);
  16176. if(doc.open(QIODevice::ReadOnly))
  16177. {
  16178. includedDoc.setContent(&doc,true);
  16179. fragment= includedDoc.createDocumentFragment();
  16180. fragment.appendChild(includedDoc.documentElement());
  16181. root.replaceChild(fragment,currentNode);
  16182. doc.close();
  16183. }
  16184. }
  16185. }
  16186. }
  16187. /*:162*/
  16188. #line 3768 "./typica.w"
  16189. /*:161*/
  16190. #line 12419 "./typica.w"
  16191. /*20:*/
  16192. #line 892 "./typica.w"
  16193. QScriptEngine*engine= new QScriptEngine;
  16194. QScriptValue constructor;
  16195. QScriptValue value;
  16196. /*:20*//*30:*/
  16197. #line 1078 "./typica.w"
  16198. constructor= engine->newFunction(constructQWidget);
  16199. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  16200. engine->globalObject().setProperty("QWidget",value);
  16201. /*:30*//*41:*/
  16202. #line 1324 "./typica.w"
  16203. constructor= engine->newFunction(constructQMainWindow);
  16204. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  16205. constructor);
  16206. engine->globalObject().setProperty("QMainWindow",value);
  16207. /*:41*//*52:*/
  16208. #line 1529 "./typica.w"
  16209. constructor= engine->newFunction(constructQFrame);
  16210. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  16211. engine->globalObject().setProperty("QFrame",value);
  16212. /*:52*//*55:*/
  16213. #line 1562 "./typica.w"
  16214. constructor= engine->newFunction(constructQLabel);
  16215. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  16216. engine->globalObject().setProperty("QLabel",value);
  16217. /*:55*//*58:*/
  16218. #line 1600 "./typica.w"
  16219. constructor= engine->newFunction(constructQLineEdit);
  16220. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  16221. engine->globalObject().setProperty("QLineEdit",value);
  16222. /*:58*//*62:*/
  16223. #line 1645 "./typica.w"
  16224. constructor= engine->newFunction(constructQSplitter);
  16225. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  16226. engine->globalObject().setProperty("QSplitter",value);
  16227. /*:62*//*69:*/
  16228. #line 1816 "./typica.w"
  16229. constructor= engine->newFunction(constructQBoxLayout);
  16230. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  16231. engine->globalObject().setProperty("QBoxLayout",value);
  16232. /*:69*//*73:*/
  16233. #line 1928 "./typica.w"
  16234. constructor= engine->newFunction(constructQAction);
  16235. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  16236. engine->globalObject().setProperty("QAction",value);
  16237. /*:73*//*76:*/
  16238. #line 1987 "./typica.w"
  16239. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  16240. value.setProperty("getOpenFileName",
  16241. engine->newFunction(QFileDialog_getOpenFileName));
  16242. value.setProperty("getSaveFileName",
  16243. engine->newFunction(QFileDialog_getSaveFileName));
  16244. engine->globalObject().setProperty("QFileDialog",value);
  16245. /*:76*//*81:*/
  16246. #line 2099 "./typica.w"
  16247. constructor= engine->newFunction(constructQFile);
  16248. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  16249. engine->globalObject().setProperty("QFile",value);
  16250. /*:81*//*88:*/
  16251. #line 2216 "./typica.w"
  16252. constructor= engine->newFunction(constructQBuffer);
  16253. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  16254. engine->globalObject().setProperty("QBuffer",value);
  16255. /*:88*//*91:*/
  16256. #line 2264 "./typica.w"
  16257. constructor= engine->newFunction(constructXQuery);
  16258. engine->globalObject().setProperty("XQuery",constructor);
  16259. /*:91*//*97:*/
  16260. #line 2358 "./typica.w"
  16261. constructor= engine->newFunction(constructXmlWriter);
  16262. engine->globalObject().setProperty("XmlWriter",constructor);
  16263. /*:97*//*106:*/
  16264. #line 2564 "./typica.w"
  16265. constructor= engine->newFunction(constructXmlReader);
  16266. engine->globalObject().setProperty("XmlReader",constructor);
  16267. /*:106*//*113:*/
  16268. #line 2688 "./typica.w"
  16269. value= engine->newQObject(&settings);
  16270. setQSettingsProperties(value,engine);
  16271. engine->globalObject().setProperty("QSettings",value);
  16272. /*:113*//*117:*/
  16273. #line 2769 "./typica.w"
  16274. constructor= engine->newFunction(constructQLCDNumber);
  16275. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  16276. engine->globalObject().setProperty("QLCDNumber",value);
  16277. /*:117*//*120:*/
  16278. #line 2825 "./typica.w"
  16279. constructor= engine->newFunction(constructQTime);
  16280. engine->globalObject().setProperty("QTime",constructor);
  16281. /*:120*//*141:*/
  16282. #line 3329 "./typica.w"
  16283. constructor= engine->newFunction(constructQPushButton);
  16284. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  16285. engine->globalObject().setProperty("QPushButton",value);
  16286. /*:141*//*148:*/
  16287. #line 3440 "./typica.w"
  16288. constructor= engine->newFunction(constructQSqlQuery);
  16289. engine->globalObject().setProperty("QSqlQuery",constructor);
  16290. /*:148*//*155:*/
  16291. #line 3601 "./typica.w"
  16292. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  16293. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  16294. engine->globalObject().setProperty("sqlToArray",
  16295. engine->newFunction(sqlToArray));
  16296. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  16297. engine->globalObject().setProperty("annotationFromRecord",
  16298. engine->newFunction(annotationFromRecord));
  16299. engine->globalObject().setProperty("setTabOrder",engine->newFunction(setTabOrder));
  16300. /*:155*//*166:*/
  16301. #line 3937 "./typica.w"
  16302. engine->globalObject().setProperty("createWindow",
  16303. engine->newFunction(createWindow));
  16304. /*:166*//*218:*/
  16305. #line 5418 "./typica.w"
  16306. engine->globalObject().setProperty("findChildObject",
  16307. engine->newFunction(findChildObject));
  16308. /*:218*//*241:*/
  16309. #line 384 "./units.w"
  16310. value= engine->newQMetaObject(&Units::staticMetaObject);
  16311. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  16312. value.setProperty("convertRelativeTemperature",
  16313. engine->newFunction(Units_convertRelativeTemperature));
  16314. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  16315. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  16316. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  16317. engine->globalObject().setProperty("Units",value);
  16318. /*:241*//*246:*/
  16319. #line 457 "./units.w"
  16320. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  16321. #line 5780 "./typica.w"
  16322. /*:246*//*268:*/
  16323. #line 6350 "./typica.w"
  16324. constructor= engine->newFunction(constructDAQ);
  16325. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  16326. value.setProperty("Fahrenheit",Units::Fahrenheit);
  16327. value.setProperty("Celsius",Units::Celsius);
  16328. value.setProperty("Kelvin",Units::Kelvin);
  16329. value.setProperty("Rankine",Units::Rankine);
  16330. engine->globalObject().setProperty("DAQ",value);
  16331. /*:268*//*277:*/
  16332. #line 6552 "./typica.w"
  16333. constructor= engine->newFunction(constructFakeDAQ);
  16334. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  16335. engine->globalObject().setProperty("FakeDAQ",value);
  16336. /*:277*//*288:*/
  16337. #line 6835 "./typica.w"
  16338. constructor= engine->newFunction(constructLinearCalibrator);
  16339. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  16340. constructor);
  16341. engine->globalObject().setProperty("LinearCalibrator",value);
  16342. /*:288*//*293:*/
  16343. #line 6974 "./typica.w"
  16344. constructor= engine->newFunction(constructLinearSplineInterpolator);
  16345. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  16346. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  16347. /*:293*//*303:*/
  16348. #line 7179 "./typica.w"
  16349. constructor= engine->newFunction(constructTemperatureDisplay);
  16350. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  16351. constructor);
  16352. engine->globalObject().setProperty("TemperatureDisplay",value);
  16353. /*:303*//*311:*/
  16354. #line 7337 "./typica.w"
  16355. constructor= engine->newFunction(constructMeasurementTimeOffset);
  16356. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  16357. constructor);
  16358. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  16359. /*:311*//*316:*/
  16360. #line 7448 "./typica.w"
  16361. constructor= engine->newFunction(constructThresholdDetector);
  16362. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  16363. engine->globalObject().setProperty("ThresholdDetector",value);
  16364. /*:316*//*321:*/
  16365. #line 7547 "./typica.w"
  16366. constructor= engine->newFunction(constructZeroEmitter);
  16367. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  16368. engine->globalObject().setProperty("ZeroEmitter",value);
  16369. /*:321*//*326:*/
  16370. #line 7626 "./typica.w"
  16371. constructor= engine->newFunction(constructMeasurementAdapter);
  16372. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  16373. constructor);
  16374. engine->globalObject().setProperty("MeasurementAdapter",value);
  16375. /*:326*//*343:*/
  16376. #line 8089 "./typica.w"
  16377. constructor= engine->newFunction(constructGraphView);
  16378. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  16379. engine->globalObject().setProperty("GraphView",value);
  16380. /*:343*//*366:*/
  16381. #line 8726 "./typica.w"
  16382. constructor= engine->newFunction(constructZoomLog);
  16383. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  16384. engine->globalObject().setProperty("ZoomLog",value);
  16385. /*:366*//*404:*/
  16386. #line 9671 "./typica.w"
  16387. constructor= engine->newFunction(constructAnnotationButton);
  16388. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  16389. constructor);
  16390. engine->globalObject().setProperty("AnnotationButton",value);
  16391. /*:404*//*412:*/
  16392. #line 9813 "./typica.w"
  16393. constructor= engine->newFunction(constructAnnotationSpinBox);
  16394. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  16395. constructor);
  16396. engine->globalObject().setProperty("AnnotationSpinBox",value);
  16397. /*:412*//*433:*/
  16398. #line 10234 "./typica.w"
  16399. constructor= engine->newFunction(constructTimerDisplay);
  16400. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  16401. engine->globalObject().setProperty("TimerDisplay",value);
  16402. /*:433*//*460:*/
  16403. #line 10728 "./typica.w"
  16404. constructor= engine->newFunction(constructWidgetDecorator);
  16405. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  16406. engine->globalObject().setProperty("WidgetDecorator",value);
  16407. /*:460*//*473:*/
  16408. #line 11010 "./typica.w"
  16409. constructor= engine->newFunction(constructLogEditWindow);
  16410. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  16411. engine->globalObject().setProperty("LogEditWindow",value);
  16412. /*:473*//*492:*/
  16413. #line 11542 "./typica.w"
  16414. constructor= engine->newFunction(constructXMLInput);
  16415. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  16416. engine->globalObject().setProperty("XMLInput",value);
  16417. /*:492*//*506:*/
  16418. #line 144 "./webview.w"
  16419. constructor= engine->newFunction(constructWebView);
  16420. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  16421. engine->globalObject().setProperty("WebView",value);
  16422. /*:506*//*514:*/
  16423. #line 236 "./webview.w"
  16424. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  16425. /*:514*//*517:*/
  16426. #line 278 "./webview.w"
  16427. constructor= engine->newFunction(constructWebElement);
  16428. engine->globalObject().setProperty("WebElement",constructor);
  16429. /*:517*//*528:*/
  16430. #line 11785 "./typica.w"
  16431. value= engine->newQObject(AppInstance);
  16432. engine->globalObject().setProperty("Application",value);
  16433. /*:528*//*580:*/
  16434. #line 12762 "./typica.w"
  16435. constructor= engine->newFunction(constructSqlQueryView);
  16436. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  16437. engine->globalObject().setProperty("SqlQueryView",value);
  16438. /*:580*//*664:*/
  16439. #line 14653 "./typica.w"
  16440. constructor= engine->newFunction(constructDeviceTreeModel);
  16441. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  16442. constructor);
  16443. engine->globalObject().setProperty("DeviceTreeModel",value);
  16444. /*:664*//*670:*/
  16445. #line 14793 "./typica.w"
  16446. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  16447. /*:670*//*686:*/
  16448. #line 15084 "./typica.w"
  16449. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  16450. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  16451. constructor);
  16452. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  16453. /*:686*//*757:*/
  16454. #line 51 "./settings.w"
  16455. constructor= engine->newFunction(constructSettingsWindow);
  16456. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  16457. engine->globalObject().setProperty("SettingsWindow",value);
  16458. #line 1 "./graphsettings.w"
  16459. /*:757*//*775:*/
  16460. #line 17614 "./typica.w"
  16461. constructor= engine->newFunction(constructModbusRTUDevice);
  16462. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  16463. engine->globalObject().setProperty("ModbusRTUDevice",value);
  16464. /*:775*//*799:*/
  16465. #line 163 "./rate.w"
  16466. constructor= engine->newFunction(constructRateOfChange);
  16467. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  16468. engine->globalObject().setProperty("RateOfChange",value);
  16469. /*:799*//*824:*/
  16470. #line 604 "./dataqsdk.w"
  16471. constructor= engine->newFunction(constructDataqSdkDevice);
  16472. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  16473. engine->globalObject().setProperty("DataqSdkDevice",value);
  16474. /*:824*//*851:*/
  16475. #line 73 "./scales.w"
  16476. constructor= engine->newFunction(constructDragLabel);
  16477. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  16478. engine->globalObject().setProperty("DragLabel",value);
  16479. /*:851*//*859:*/
  16480. #line 239 "./scales.w"
  16481. constructor= engine->newFunction(constructSerialScale);
  16482. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  16483. engine->globalObject().setProperty("SerialScale",value);
  16484. /*:859*//*863:*/
  16485. #line 325 "./scales.w"
  16486. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  16487. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  16488. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  16489. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  16490. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  16491. /*:863*//*887:*/
  16492. #line 271 "./valueannotation.w"
  16493. constructor= engine->newFunction(constructValueAnnotation);
  16494. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  16495. engine->globalObject().setProperty("ValueAnnotation",value);
  16496. /*:887*/
  16497. #line 12420 "./typica.w"
  16498. app.engine= engine;
  16499. /*163:*/
  16500. #line 3822 "./typica.w"
  16501. QString styleText;
  16502. QString programText;
  16503. QDomElement currentElement;
  16504. for(int i= 0;i<children.size();i++)
  16505. {
  16506. QDomNode currentNode= children.at(i);
  16507. if(currentNode.nodeName()=="style")
  16508. {
  16509. currentElement= currentNode.toElement();
  16510. styleText.append(currentElement.text());
  16511. }
  16512. else if(currentNode.nodeName()=="program")
  16513. {
  16514. currentElement= currentNode.toElement();
  16515. programText.append(currentElement.text());
  16516. }
  16517. }
  16518. app.setStyleSheet(styleText);
  16519. QScriptValue result= engine->evaluate(programText);
  16520. /*164:*/
  16521. #line 3847 "./typica.w"
  16522. if(engine->hasUncaughtException())
  16523. {
  16524. int line= engine->uncaughtExceptionLineNumber();
  16525. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16526. result.toString();
  16527. QString trace;
  16528. foreach(trace,engine->uncaughtExceptionBacktrace())
  16529. {
  16530. qDebug()<<trace;
  16531. }
  16532. }
  16533. /*:164*/
  16534. #line 3842 "./typica.w"
  16535. /*:163*/
  16536. #line 12422 "./typica.w"
  16537. int retval= app.exec();
  16538. delete engine;
  16539. return retval;
  16540. }
  16541. /*:560*/
  16542. #line 765 "./typica.w"
  16543. #include "moc_typica.cpp"
  16544. /*:16*/