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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 619 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. /*:5*//*6:*/
  17. #line 635 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*303:*/
  20. #line 6782 "./typica.w"
  21. #include "units.h"
  22. #line 1 "./measurement.w"
  23. /*:303*//*574:*/
  24. #line 212 "./webview.w"
  25. #include "webview.h"
  26. /*:574*//*587:*/
  27. #line 390 "./webview.w"
  28. #include "webelement.h"
  29. #line 12758 "./typica.w"
  30. #line 1 "./printerselector.w"
  31. /*:587*//*589:*/
  32. #line 40 "./printerselector.w"
  33. #include "printerselector.h"
  34. /*:589*//*713:*/
  35. #line 489 "./daterangeselector.w"
  36. #include "daterangeselector.h"
  37. #line 14493 "./typica.w"
  38. /*:713*//*821:*/
  39. #line 17064 "./typica.w"
  40. #include "qextserialport.h"
  41. #include "qextserialenumerator.h"
  42. /*:821*//*1001:*/
  43. #line 124 "./dataqsdk.w"
  44. #ifdef Q_OS_WIN32
  45. #include <windef.h>
  46. #else
  47. #define PASCAL
  48. #endif
  49. /*:1001*//*1025:*/
  50. #line 862 "./dataqsdk.w"
  51. #include <limits>
  52. /*:1025*//*1040:*/
  53. #line 62 "./scales.w"
  54. #include "draglabel.h"
  55. /*:1040*//*1055:*/
  56. #line 361 "./scales.w"
  57. #include "scale.h"
  58. /*:1055*/
  59. #line 525 "./typica.w"
  60. /*26:*/
  61. #line 1042 "./typica.w"
  62. class ScriptQMainWindow:public QMainWindow
  63. {
  64. Q_OBJECT
  65. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  66. public:
  67. ScriptQMainWindow();
  68. QString closePrompt();
  69. public slots:
  70. void show();
  71. void saveSizeAndPosition(const QString&key);
  72. void restoreSizeAndPosition(const QString&key);
  73. void displayStatus(const QString&message= QString());
  74. void setClosePrompt(QString prompt);
  75. protected:
  76. void closeEvent(QCloseEvent*event);
  77. void showEvent(QShowEvent*event);
  78. signals:
  79. void aboutToClose(void);
  80. private:
  81. QString cprompt;
  82. };
  83. /*:26*//*172:*/
  84. #line 3966 "./typica.w"
  85. class SqlQueryConnection:public QSqlQuery
  86. {
  87. public:
  88. SqlQueryConnection(const QString&query= QString());
  89. ~SqlQueryConnection();
  90. QSqlQuery*operator->()const;
  91. private:
  92. QString connection;
  93. QSqlQuery*q;
  94. };
  95. /*:172*//*249:*/
  96. #line 5939 "./typica.w"
  97. class NumericDelegate:public QItemDelegate
  98. {
  99. Q_OBJECT
  100. public:
  101. NumericDelegate(QObject*parent= NULL);
  102. QWidget*createEditor(QWidget*parent,
  103. const QStyleOptionViewItem&option,
  104. const QModelIndex&index)const;
  105. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  106. void setModelData(QWidget*editor,QAbstractItemModel*model,
  107. const QModelIndex&index)const;
  108. void updateEditorGeometry(QWidget*editor,
  109. const QStyleOptionViewItem&option,
  110. const QModelIndex&index)const;
  111. };
  112. /*:249*//*255:*/
  113. #line 6032 "./typica.w"
  114. class ScriptValidator:public QValidator
  115. {
  116. Q_OBJECT
  117. public:
  118. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  119. void fixup(QString&input)const;
  120. QValidator::State validate(QString&input,int&pos)const;
  121. private:
  122. QValidator*v;
  123. };
  124. /*:255*//*299:*/
  125. #line 438 "./units.w"
  126. Q_DECLARE_METATYPE(Units::Unit)
  127. /*:299*//*304:*/
  128. #line 19 "./measurement.w"
  129. class Measurement:public QVariantMap
  130. {
  131. public:
  132. Measurement(double temperature= 0,QTime time= QTime(),
  133. Units::Unit sc= Units::Fahrenheit);
  134. Measurement(double temperature);
  135. double temperature()const;
  136. QTime time()const;
  137. void setTemperature(double temperature);
  138. void setTime(QTime time);
  139. void setUnit(Units::Unit scale);
  140. Units::Unit scale()const;
  141. Measurement toFahrenheit();
  142. Measurement toCelsius();
  143. Measurement toKelvin();
  144. Measurement toRankine();
  145. };
  146. /*:304*//*308:*/
  147. #line 128 "./measurement.w"
  148. Q_DECLARE_METATYPE(Measurement)
  149. /*:308*//*315:*/
  150. #line 6846 "./typica.w"
  151. class Channel;
  152. class DAQImplementation;
  153. class DAQ:public QObject
  154. {
  155. Q_OBJECT
  156. Q_ENUMS(ThermocoupleType)
  157. DAQImplementation*imp;
  158. private slots:
  159. void threadFinished();
  160. public:
  161. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  162. ~DAQ();
  163. Channel*newChannel(int units,int thermocouple);
  164. Q_INVOKABLE void setClockRate(double Hz);
  165. Q_INVOKABLE void start();
  166. Q_INVOKABLE void stop();
  167. enum ThermocoupleType
  168. {
  169. TypeJ= 10072,
  170. TypeK= 10073,
  171. TypeN= 10077,
  172. TypeR= 10082,
  173. TypeS= 10085,
  174. TypeT= 10086,
  175. TypeB= 10047,
  176. TypeE= 10055
  177. };
  178. };
  179. /*:315*//*316:*/
  180. #line 6884 "./typica.w"
  181. class DAQImplementation:public QThread
  182. {
  183. Q_OBJECT
  184. public:
  185. DAQImplementation(const QString&driverinfo);
  186. ~DAQImplementation();
  187. void run();
  188. void measure();
  189. /*317:*/
  190. #line 6904 "./typica.w"
  191. typedef int(*daqfp)(...);
  192. daqfp read;
  193. daqfp errorInfo;
  194. daqfp startTask;
  195. daqfp createTask;
  196. daqfp createChannel;
  197. daqfp setClock;
  198. daqfp stopTask;
  199. daqfp clearTask;
  200. daqfp resetDevice;
  201. daqfp waitForMeasurement;
  202. /*:317*/
  203. #line 6893 "./typica.w"
  204. /*318:*/
  205. #line 6920 "./typica.w"
  206. bool useBase;
  207. QString device;
  208. QVector<Channel*> channelMap;
  209. unsigned int handle;
  210. int error;
  211. int channels;
  212. bool ready;
  213. QLibrary driver;
  214. QVector<Units::Unit> unitMap;
  215. /*:318*/
  216. #line 6894 "./typica.w"
  217. };
  218. /*:316*//*334:*/
  219. #line 7425 "./typica.w"
  220. class FakeDAQImplementation:public QThread
  221. {
  222. Q_OBJECT
  223. public:
  224. FakeDAQImplementation();
  225. ~FakeDAQImplementation();
  226. void run();
  227. void measure();
  228. QVector<Channel*> channelMap;
  229. int channels;
  230. bool ready;
  231. double clockRate;
  232. };
  233. class FakeDAQ:public QObject
  234. {
  235. Q_OBJECT
  236. FakeDAQImplementation*imp;
  237. public:
  238. FakeDAQ(QString device);
  239. ~FakeDAQ();
  240. Channel*newChannel(int units,int thermocouple);
  241. Q_INVOKABLE void setClockRate(double Hz);
  242. Q_INVOKABLE void start();
  243. };
  244. /*:334*//*341:*/
  245. #line 7612 "./typica.w"
  246. class Channel:public QObject
  247. {
  248. Q_OBJECT
  249. public:
  250. Channel();
  251. ~Channel();
  252. public slots:
  253. void input(Measurement measurement);
  254. signals:
  255. void newData(Measurement);
  256. };
  257. /*:341*//*345:*/
  258. #line 7679 "./typica.w"
  259. class LinearCalibrator:public QObject
  260. {
  261. Q_OBJECT
  262. Q_PROPERTY(double measuredLower READ measuredLower
  263. WRITE setMeasuredLower)
  264. Q_PROPERTY(double measuredUpper READ measuredUpper
  265. WRITE setMeasuredUpper)
  266. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  267. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  268. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  269. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  270. public:
  271. LinearCalibrator(QObject*parent= NULL);
  272. double measuredLower();
  273. double measuredUpper();
  274. double mappedLower();
  275. double mappedUpper();
  276. bool isClosedRange();
  277. double sensitivity();
  278. public slots:
  279. void setMeasuredLower(double lower);
  280. void setMeasuredUpper(double upper);
  281. void setMappedLower(double lower);
  282. void setMappedUpper(double upper);
  283. void setClosedRange(bool closed);
  284. void setSensitivity(double sensitivity);
  285. Measurement newMeasurement(Measurement measure);
  286. signals:
  287. void measurement(Measurement measure);
  288. void newData(Measurement measure);
  289. private:
  290. double Lo1;
  291. double Lo2;
  292. double Up1;
  293. double Up2;
  294. double sensitivitySetting;
  295. bool clamp;
  296. };
  297. /*:345*//*352:*/
  298. #line 7875 "./typica.w"
  299. class LinearSplineInterpolator:public QObject
  300. {
  301. Q_OBJECT
  302. public:
  303. LinearSplineInterpolator(QObject*parent= NULL);
  304. Q_INVOKABLE void add_pair(double source,double destination);
  305. public slots:
  306. Measurement newMeasurement(Measurement measure);
  307. signals:
  308. void newData(Measurement measure);
  309. private:
  310. void make_interpolators();
  311. QMap<double,double> *pairs;
  312. QList<LinearCalibrator*> *interpolators;
  313. };
  314. /*:352*//*357:*/
  315. #line 8011 "./typica.w"
  316. class TemperatureDisplay:public QLCDNumber
  317. {
  318. Q_OBJECT
  319. int unit;
  320. bool r;
  321. public:
  322. TemperatureDisplay(QWidget*parent= NULL);
  323. ~TemperatureDisplay();
  324. public slots:
  325. void setValue(Measurement temperature);
  326. void invalidate();
  327. void setDisplayUnits(Units::Unit scale);
  328. void setRelativeMode(bool relative);
  329. };
  330. /*:357*//*368:*/
  331. #line 8230 "./typica.w"
  332. class MeasurementTimeOffset:public QObject
  333. {
  334. Q_OBJECT
  335. QTime epoch;
  336. QTime previous;
  337. bool hasPrevious;
  338. public:
  339. MeasurementTimeOffset(QTime zero);
  340. QTime zeroTime();
  341. public slots:
  342. void newMeasurement(Measurement measure);
  343. void setZeroTime(QTime zero);
  344. signals:
  345. void measurement(Measurement measure);
  346. };
  347. /*:368*//*375:*/
  348. #line 8382 "./typica.w"
  349. class ThresholdDetector:public QObject
  350. {
  351. Q_OBJECT
  352. Q_ENUMS(EdgeDirection)
  353. public:
  354. enum EdgeDirection{
  355. Ascending,Descending
  356. };
  357. ThresholdDetector(double value);
  358. public slots:
  359. void newMeasurement(Measurement measure);
  360. void setThreshold(double value);
  361. void setEdgeDirection(EdgeDirection direction);
  362. signals:
  363. void timeForValue(double);
  364. private:
  365. bool previousValueValid;
  366. double previousValue;
  367. double threshold;
  368. EdgeDirection currentDirection;
  369. };
  370. /*:375*//*380:*/
  371. #line 8498 "./typica.w"
  372. class ZeroEmitter:public QObject
  373. {
  374. Q_OBJECT
  375. Q_PROPERTY(int column READ column WRITE setColumn)
  376. Measurement cache;
  377. int col;
  378. public:
  379. ZeroEmitter(int tempcolumn= 1);
  380. int column();
  381. double lastTemperature();
  382. public slots:
  383. void newMeasurement(Measurement measure);
  384. void setColumn(int column);
  385. void emitZero();
  386. signals:
  387. void measurement(Measurement measure,int tempcolumn);
  388. };
  389. /*:380*//*385:*/
  390. #line 8592 "./typica.w"
  391. class MeasurementAdapter:public QObject
  392. {
  393. Q_OBJECT
  394. int col;
  395. public:
  396. MeasurementAdapter(int tempcolumn);
  397. int column();
  398. public slots:
  399. void newMeasurement(Measurement measure);
  400. void setColumn(int column);
  401. signals:
  402. void measurement(Measurement measure,int tempcolumn);
  403. };
  404. /*:385*//*390:*/
  405. #line 8681 "./typica.w"
  406. class GraphView:public QGraphicsView
  407. {
  408. Q_OBJECT
  409. QGraphicsScene*theScene;
  410. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  411. QMap<int,QPointF> *prevPoints;
  412. QMap<int,double> *translations;
  413. QList<QGraphicsItem*> *gridLinesF;
  414. QList<QGraphicsItem*> *gridLinesC;
  415. QList<QGraphicsItem*> *relativeGridLines;
  416. bool relativeEnabled;
  417. bool timeIndicatorEnabled;
  418. QGraphicsLineItem*timeLine;
  419. LinearSplineInterpolator*relativeAdjuster;
  420. public:
  421. GraphView(QWidget*parent= NULL);
  422. void removeSeries(int column);
  423. protected:
  424. void resizeEvent(QResizeEvent*event);
  425. public slots:
  426. void newMeasurement(Measurement measure,int tempcolumn);
  427. void setSeriesTranslation(int column,double offset);
  428. void setTimeIndicatorEnabled(bool enabled);
  429. void clear();
  430. void showF();
  431. void showC();
  432. };
  433. /*:390*//*407:*/
  434. #line 9146 "./typica.w"
  435. class MeasurementModel;
  436. class ZoomLog:public QTableView
  437. {
  438. Q_OBJECT
  439. /*408:*/
  440. #line 9195 "./typica.w"
  441. MeasurementModel*model_ms;
  442. MeasurementModel*model_1s;
  443. MeasurementModel*model_5s;
  444. MeasurementModel*model_10s;
  445. MeasurementModel*model_15s;
  446. MeasurementModel*model_30s;
  447. MeasurementModel*model_1m;
  448. QList<MeasurementModel*> modelSet;
  449. QHash<int,Measurement> lastMeasurement;
  450. MeasurementModel*currentModel;
  451. QList<int> saveTempCols;
  452. QList<int> saveControlCols;
  453. QList<int> saveNoteCols;
  454. QList<int> currentColumnSet;
  455. /*:408*/
  456. #line 9151 "./typica.w"
  457. void switchLOD(MeasurementModel*m);
  458. private slots:
  459. void centerOn(int row);
  460. void persistColumnResize(int column,int oldsize,int newsize);
  461. void restoreColumnWidths();
  462. public:
  463. ZoomLog();
  464. QVariant data(int row,int column)const;
  465. int rowCount();
  466. bool saveXML(QIODevice*device);
  467. bool saveCSV(QIODevice*device);
  468. QString lastTime(int series);
  469. Q_INVOKABLE Units::Unit displayUnits();
  470. public slots:
  471. void setVisible(bool visibility);
  472. void setHeaderData(int section,QString text);
  473. void LOD_ms();
  474. void LOD_1s();
  475. void LOD_5s();
  476. void LOD_10s();
  477. void LOD_15s();
  478. void LOD_30s();
  479. void LOD_1m();
  480. void newMeasurement(Measurement measure,int tempcolumn);
  481. void newAnnotation(QString annotation,int tempcolumn,
  482. int annotationcolumn);
  483. void clear();
  484. void addOutputTemperatureColumn(int column);
  485. void addOutputControlColumn(int column);
  486. void addOutputAnnotationColumn(int column);
  487. void clearOutputColumns();
  488. void setDisplayUnits(Units::Unit scale);
  489. void addToCurrentColumnSet(int column);
  490. void clearCurrentColumnSet();
  491. protected:
  492. virtual void showEvent(QShowEvent*event);
  493. };
  494. /*:407*//*433:*/
  495. #line 9891 "./typica.w"
  496. class MeasurementList;
  497. class MeasurementModel:public QAbstractItemModel
  498. {
  499. Q_OBJECT
  500. Units::Unit unit;
  501. QList<MeasurementList*> *entries;
  502. QStringList*hData;
  503. int colcount;
  504. QHash<int,int> *lastTemperature;
  505. QList<MeasurementList*> ::iterator lastInsertion;
  506. QHash<int,bool> *controlColumns;
  507. public:
  508. MeasurementModel(QObject*parent= NULL);
  509. ~MeasurementModel();
  510. int rowCount(const QModelIndex&parent= QModelIndex())const;
  511. int columnCount(const QModelIndex&parent= QModelIndex())const;
  512. bool setHeaderData(int section,Qt::Orientation orientation,
  513. const QVariant&value,int role= Qt::DisplayRole);
  514. QVariant data(const QModelIndex&index,int role)const;
  515. bool setData(const QModelIndex&index,const QVariant&value,
  516. int role= Qt::EditRole);
  517. Qt::ItemFlags flags(const QModelIndex&index)const;
  518. QVariant headerData(int section,Qt::Orientation orientation,
  519. int role= Qt::DisplayRole)const;
  520. QModelIndex index(int row,int column,
  521. const QModelIndex&parent= QModelIndex())const;
  522. QModelIndex parent(const QModelIndex&index)const;
  523. Units::Unit displayUnits();
  524. public slots:
  525. void newMeasurement(Measurement measure,int tempcolumn);
  526. void newAnnotation(QString annotation,int tempcolumn,
  527. int annotationColumn);
  528. void clear();
  529. void setDisplayUnits(Units::Unit scale);
  530. signals:
  531. void rowChanged(int);
  532. };
  533. /*:433*//*434:*/
  534. #line 9935 "./typica.w"
  535. class MeasurementList:public QVariantList
  536. {
  537. public:
  538. bool operator<(const MeasurementList&other)const;
  539. bool operator==(const MeasurementList&other)const;
  540. };
  541. /*:434*//*460:*/
  542. #line 10593 "./typica.w"
  543. class AnnotationButton:public QPushButton
  544. {
  545. Q_OBJECT
  546. QString note;
  547. int tc;
  548. int ac;
  549. int count;
  550. public:
  551. AnnotationButton(const QString&text,QWidget*parent= NULL);
  552. public slots:
  553. void setAnnotation(const QString&annotation);
  554. void setTemperatureColumn(int tempcolumn);
  555. void setAnnotationColumn(int annotationcolumn);
  556. void annotate();
  557. void resetCount();
  558. signals:
  559. void annotation(QString annotation,int tempcolumn,
  560. int notecolumn);
  561. };
  562. /*:460*//*468:*/
  563. #line 10718 "./typica.w"
  564. class AnnotationSpinBox:public QDoubleSpinBox
  565. {
  566. Q_OBJECT
  567. QString pretext;
  568. QString posttext;
  569. int tc;
  570. int ac;
  571. bool change;
  572. public:
  573. AnnotationSpinBox(const QString&pret,const QString&postt,
  574. QWidget*parent= NULL);
  575. public slots:
  576. void setPretext(const QString&pret);
  577. void setPosttext(const QString&postt);
  578. void setTemperatureColumn(int tempcolumn);
  579. void setAnnotationColumn(int annotationcolumn);
  580. void annotate();
  581. void resetChange();
  582. signals:
  583. void annotation(QString annotation,int tempcolumn,
  584. int notecolumn);
  585. };
  586. /*:468*//*476:*/
  587. #line 10877 "./typica.w"
  588. class TimerDisplay:public QLCDNumber
  589. {
  590. Q_OBJECT
  591. /*477:*/
  592. #line 10927 "./typica.w"
  593. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  594. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  595. Q_PROPERTY(bool running READ isRunning)
  596. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  597. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  598. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  599. Q_PROPERTY(QString value READ value)
  600. /*:477*/
  601. #line 10881 "./typica.w"
  602. private slots:
  603. void updateTime();
  604. void setCountUpMode();
  605. void setCountDownMode();
  606. void setClockMode();
  607. public:
  608. TimerDisplay(QWidget*parent= NULL);
  609. ~TimerDisplay();
  610. enum TimerMode
  611. {
  612. CountUp,
  613. CountDown,
  614. Clock
  615. };
  616. QString value();
  617. QTime seconds();
  618. TimerMode mode();
  619. bool isRunning();
  620. QTime resetValue();
  621. QString displayFormat();
  622. bool autoReset();
  623. public slots:
  624. void setTimer(QTime value= QTime(0,0,0));
  625. void setMode(TimerMode mode);
  626. void startTimer();
  627. void stopTimer();
  628. void copyTimer();
  629. void setResetValue(QTime value= QTime(0,0,0));
  630. void reset();
  631. void setDisplayFormat(QString format);
  632. void setAutoReset(bool reset);
  633. void updateDisplay();
  634. signals:
  635. void valueChanged(QTime);
  636. void runStateChanged(bool);
  637. private:
  638. /*478:*/
  639. #line 10938 "./typica.w"
  640. QTime s;
  641. QTime r;
  642. QTimer clock;
  643. TimerDisplay::TimerMode m;
  644. bool running;
  645. bool ar;
  646. QAction*startAction;
  647. QAction*stopAction;
  648. QAction*resetAction;
  649. QString f;
  650. QTime relative;
  651. QTime base;
  652. /*:478*/
  653. #line 10918 "./typica.w"
  654. };
  655. /*:476*//*499:*/
  656. #line 11330 "./typica.w"
  657. class PackLayout:public QLayout
  658. {
  659. int doLayout(const QRect&rect,bool testOnly)const;
  660. QList<QLayoutItem*> itemList;
  661. Qt::Orientations orientation;
  662. public:
  663. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  664. PackLayout(int spacing= -1);
  665. ~PackLayout();
  666. void addItem(QLayoutItem*item);
  667. Qt::Orientations expandingDirections()const;
  668. bool hasHeightForWidth()const;
  669. int heightForWidth(int width)const;
  670. int count()const;
  671. QLayoutItem*itemAt(int index)const;
  672. QSize minimumSize()const;
  673. void setGeometry(const QRect&rect);
  674. void setOrientation(Qt::Orientations direction);
  675. QSize sizeHint()const;
  676. QLayoutItem*takeAt(int index);
  677. };
  678. /*:499*//*512:*/
  679. #line 11608 "./typica.w"
  680. class SceneButton:public QGraphicsScene
  681. {
  682. Q_OBJECT
  683. public:
  684. SceneButton();
  685. ~SceneButton();
  686. protected:
  687. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  688. signals:
  689. void clicked(QPoint pos);
  690. };
  691. /*:512*//*514:*/
  692. #line 11650 "./typica.w"
  693. class WidgetDecorator:public QWidget
  694. {
  695. Q_OBJECT
  696. PackLayout*layout;
  697. QGraphicsView*label;
  698. QGraphicsTextItem*text;
  699. SceneButton*scene;
  700. public:
  701. WidgetDecorator(QWidget*widget,const QString&labeltext,
  702. Qt::Orientations orientation= Qt::Horizontal,
  703. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  704. ~WidgetDecorator();
  705. void setBackgroundBrush(QBrush background);
  706. void setTextColor(QColor color);
  707. };
  708. /*:514*//*525:*/
  709. #line 11825 "./typica.w"
  710. class LogEditWindow:public QMainWindow
  711. {
  712. Q_OBJECT
  713. QWidget*centralWidget;
  714. PackLayout*mainLayout;
  715. QHBoxLayout*addRowsLayout;
  716. QLabel*startTimeLabel;
  717. QTimeEdit*startTime;
  718. QLabel*endTimeLabel;
  719. QTimeEdit*endTime;
  720. QLabel*intervalLabel;
  721. QSpinBox*interval;
  722. QPushButton*addRows;
  723. QAction*saveXml;
  724. QAction*saveCsv;
  725. QAction*openXml;
  726. MeasurementModel*model;
  727. QTableView*log;
  728. private slots:
  729. void addTheRows();
  730. void saveXML();
  731. void saveCSV();
  732. void openXML();
  733. protected:
  734. void closeEvent(QCloseEvent*event);
  735. public:
  736. LogEditWindow();
  737. };
  738. /*:525*//*539:*/
  739. #line 12133 "./typica.w"
  740. class XMLOutput:public QObject
  741. {
  742. Q_OBJECT
  743. MeasurementModel*data;
  744. QIODevice*out;
  745. int time;
  746. QMap<int,QString> temperatureColumns;
  747. QMap<int,QString> controlColumns;
  748. QMap<int,QString> annotationColumns;
  749. public:
  750. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  751. void addTemperatureColumn(const QString&series,int column);
  752. void addControlColumn(const QString&series,int column);
  753. void addAnnotationColumn(const QString&series,int column);
  754. void setModel(MeasurementModel*model);
  755. void setTimeColumn(int column);
  756. void setDevice(QIODevice*device);
  757. bool output();
  758. };
  759. /*:539*//*546:*/
  760. #line 12369 "./typica.w"
  761. class XMLInput:public QObject
  762. {
  763. Q_OBJECT
  764. int firstc;
  765. QIODevice*in;
  766. public:
  767. XMLInput(QIODevice*input,int c);
  768. void setFirstColumn(int column);
  769. void setDevice(QIODevice*device);
  770. bool input();
  771. signals:
  772. void measure(Measurement,int);
  773. void annotation(QString,int,int);
  774. void newTemperatureColumn(int,QString);
  775. void newAnnotationColumn(int,QString);
  776. void lastColumn(int);
  777. };
  778. /*:546*//*557:*/
  779. #line 12623 "./typica.w"
  780. class CSVOutput
  781. {
  782. MeasurementModel*data;
  783. QIODevice*out;
  784. int time;
  785. QMap<int,QString> temperatureColumns;
  786. QMap<int,QString> controlColumns;
  787. QMap<int,QString> annotationColumns;
  788. public:
  789. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  790. void addTemperatureColumn(const QString&series,int column);
  791. void addControlColumn(const QString&series,int column);
  792. void addAnnotationColumn(const QString&series,int column);
  793. void setModel(MeasurementModel*model);
  794. void setTimeColumn(int column);
  795. void setDevice(QIODevice*device);
  796. bool output();
  797. };
  798. /*:557*//*597:*/
  799. #line 12768 "./typica.w"
  800. #define AppInstance (qobject_cast<Application *> (qApp))
  801. class NodeInserter;
  802. class DeviceTreeModel;
  803. class Application:public QApplication
  804. {
  805. Q_OBJECT
  806. public:
  807. Application(int&argc,char**argv);
  808. QDomDocument*configuration();
  809. /*745:*/
  810. #line 15339 "./typica.w"
  811. QDomDocument deviceConfiguration();
  812. /*:745*//*778:*/
  813. #line 16012 "./typica.w"
  814. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  815. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  816. const QModelIndex&index);
  817. /*:778*//*783:*/
  818. #line 16116 "./typica.w"
  819. QList<NodeInserter*> topLevelNodeInserters;
  820. /*:783*/
  821. #line 12779 "./typica.w"
  822. QSqlDatabase database();
  823. QScriptEngine*engine;
  824. public slots:
  825. /*746:*/
  826. #line 15346 "./typica.w"
  827. void saveDeviceConfiguration();
  828. /*:746*/
  829. #line 12783 "./typica.w"
  830. private:
  831. /*744:*/
  832. #line 15330 "./typica.w"
  833. QDomDocument deviceConfigurationDocument;
  834. /*:744*//*777:*/
  835. #line 16006 "./typica.w"
  836. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  837. /*:777*/
  838. #line 12785 "./typica.w"
  839. QDomDocument conf;
  840. };
  841. /*:597*//*605:*/
  842. #line 12910 "./typica.w"
  843. class SaltModel:public QAbstractItemModel
  844. {
  845. Q_OBJECT
  846. QList<QList<QMap<int,QVariant> > > modelData;
  847. QStringList hData;
  848. int colcount;
  849. public:
  850. SaltModel(int columns);
  851. ~SaltModel();
  852. int rowCount(const QModelIndex&parent= QModelIndex())const;
  853. int columnCount(const QModelIndex&parent= QModelIndex())const;
  854. bool setHeaderData(int section,Qt::Orientation orientation,
  855. const QVariant&value,int role= Qt::DisplayRole);
  856. QVariant data(const QModelIndex&index,int role)const;
  857. bool setData(const QModelIndex&index,const QVariant&value,
  858. int role= Qt::EditRole);
  859. Qt::ItemFlags flags(const QModelIndex&index)const;
  860. QVariant headerData(int section,Qt::Orientation orientation,
  861. int role= Qt::DisplayRole)const;
  862. QModelIndex index(int row,int column,
  863. const QModelIndex&parent= QModelIndex())const;
  864. QModelIndex parent(const QModelIndex&index)const;
  865. QString arrayLiteral(int column,int role)const;
  866. QString quotedArrayLiteral(int column,int role)const;
  867. void clear();
  868. bool removeRows(int row,int count,
  869. const QModelIndex&parent= QModelIndex());
  870. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  871. };
  872. /*:605*//*621:*/
  873. #line 13295 "./typica.w"
  874. class SqlComboBox:public QComboBox
  875. {
  876. Q_OBJECT
  877. int dataColumn;
  878. int displayColumn;
  879. bool dataColumnShown;
  880. QString specialNullText;
  881. QVariant specialNullData;
  882. public:
  883. SqlComboBox();
  884. ~SqlComboBox();
  885. SqlComboBox*clone(QWidget*parent);
  886. public slots:
  887. void addNullOption();
  888. void addSqlOptions(QString query);
  889. void setDataColumn(int column);
  890. void setDisplayColumn(int column);
  891. void showData(bool show);
  892. void setNullText(QString nullText);
  893. void setNullData(QVariant nullData);
  894. };
  895. /*:621*//*628:*/
  896. #line 13442 "./typica.w"
  897. class SqlComboBoxDelegate:public QItemDelegate
  898. {
  899. Q_OBJECT
  900. SqlComboBox*delegate;
  901. public:
  902. SqlComboBoxDelegate(QObject*parent= NULL);
  903. QWidget*createEditor(QWidget*parent,
  904. const QStyleOptionViewItem&option,
  905. const QModelIndex&index)const;
  906. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  907. void setModelData(QWidget*editor,QAbstractItemModel*model,
  908. const QModelIndex&index)const;
  909. void setWidget(SqlComboBox*widget);
  910. virtual QSize sizeHint()const;
  911. void updateEditorGeometry(QWidget*editor,
  912. const QStyleOptionViewItem&option,
  913. const QModelIndex&index)const;
  914. };
  915. /*:628*//*643:*/
  916. #line 13653 "./typica.w"
  917. class SqlConnectionSetup:public QDialog
  918. {
  919. Q_OBJECT
  920. public:
  921. SqlConnectionSetup();
  922. ~SqlConnectionSetup();
  923. public slots:
  924. void testConnection();
  925. private:
  926. QFormLayout*formLayout;
  927. QComboBox*driver;
  928. QLineEdit*hostname;
  929. QLineEdit*portnumber;
  930. QLineEdit*dbname;
  931. QLineEdit*user;
  932. QLineEdit*password;
  933. QVBoxLayout*layout;
  934. QHBoxLayout*buttons;
  935. QPushButton*cancelButton;
  936. QPushButton*connectButton;
  937. };
  938. /*:643*//*648:*/
  939. #line 13801 "./typica.w"
  940. class SqlQueryView:public QTableView
  941. {
  942. Q_OBJECT
  943. public:
  944. SqlQueryView(QWidget*parent= NULL);
  945. void setQuery(const QString&query);
  946. bool setHeaderData(int section,Qt::Orientation orientation,
  947. const QVariant&value,int role);
  948. Q_INVOKABLE QVariant data(int row,int column,
  949. int role= Qt::DisplayRole);
  950. signals:
  951. void openEntry(QString key);
  952. void openEntryRow(int row);
  953. protected:
  954. virtual void showEvent(QShowEvent*event);
  955. private slots:
  956. void openRow(const QModelIndex&index);
  957. void persistColumnResize(int column,int oldsize,int newsize);
  958. };
  959. /*:648*//*663:*/
  960. #line 14056 "./typica.w"
  961. class ReportAction:public QAction
  962. {
  963. Q_OBJECT
  964. public:
  965. ReportAction(const QString&fileName,const QString&reportName,
  966. QObject*parent= NULL);
  967. private slots:
  968. void createReport();
  969. private:
  970. QString reportFile;
  971. };
  972. /*:663*//*675:*/
  973. #line 14267 "./typica.w"
  974. class ReportTable:public QObject
  975. {
  976. Q_OBJECT
  977. QTextFrame*area;
  978. QDomElement configuration;
  979. QMap<QString,QVariant> bindings;
  980. public:
  981. ReportTable(QTextFrame*frame,QDomElement description);
  982. ~ReportTable();
  983. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  984. public slots:
  985. void refresh();
  986. };
  987. /*:675*//*688:*/
  988. #line 63 "./plugins.w"
  989. class PluginAction:public QAction
  990. {
  991. Q_OBJECT
  992. Q_PROPERTY(QString preRun READ preRun WRITE setPreRun);
  993. Q_PROPERTY(QString postRun READ postRun WRITE setPostRun);
  994. public:
  995. PluginAction(const QFileInfo&info,QObject*parent);
  996. QString preRun();
  997. QString postRun();
  998. public slots:
  999. void setPreRun(const QString&script);
  1000. void setPostRun(const QString&script);
  1001. private slots:
  1002. void runScript();
  1003. private:
  1004. QString pluginFile;
  1005. QString preRunScript;
  1006. QString postRunScript;
  1007. };
  1008. /*:688*//*691:*/
  1009. #line 155 "./plugins.w"
  1010. Q_DECLARE_METATYPE(QScriptValue)
  1011. /*:691*//*714:*/
  1012. #line 14508 "./typica.w"
  1013. class FormArray:public QScrollArea
  1014. {
  1015. Q_OBJECT
  1016. QDomElement configuration;
  1017. QWidget itemContainer;
  1018. QVBoxLayout itemLayout;
  1019. int maxwidth;
  1020. int maxheight;
  1021. public:
  1022. FormArray(QDomElement description);
  1023. Q_INVOKABLE QWidget*elementAt(int index);
  1024. Q_INVOKABLE int elements();
  1025. public slots:
  1026. void addElements(int copies= 1);
  1027. void removeAllElements();
  1028. void setMaximumElementWidth(int width);
  1029. void setMaximumElementHeight(int height);
  1030. };
  1031. /*:714*//*724:*/
  1032. #line 14724 "./typica.w"
  1033. class ScaleControl:public QGraphicsView
  1034. {
  1035. Q_OBJECT
  1036. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1037. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1038. /*725:*/
  1039. #line 14750 "./typica.w"
  1040. QGraphicsScene scene;
  1041. QGraphicsPolygonItem initialDecrement;
  1042. QGraphicsPolygonItem initialIncrement;
  1043. QGraphicsPolygonItem finalDecrement;
  1044. QGraphicsPolygonItem finalIncrement;
  1045. QGraphicsPolygonItem initialIndicator;
  1046. QGraphicsPolygonItem finalIndicator;
  1047. QGraphicsPathItem scaleLine;
  1048. QPolygonF left;
  1049. QPolygonF right;
  1050. QPolygonF down;
  1051. QPolygonF up;
  1052. QPainterPath scalePath;
  1053. QBrush initialBrush;
  1054. QBrush finalBrush;
  1055. double nonScoredValue;
  1056. double scoredValue;
  1057. bool initialSet;
  1058. bool finalSet;
  1059. bool scaleDown;
  1060. /*:725*/
  1061. #line 14730 "./typica.w"
  1062. public:
  1063. ScaleControl();
  1064. double initialValue(void);
  1065. double finalValue(void);
  1066. virtual QSize sizeHint()const;
  1067. public slots:
  1068. void setInitialValue(double value);
  1069. void setFinalValue(double value);
  1070. signals:
  1071. void initialChanged(double);
  1072. void finalChanged(double);
  1073. protected:
  1074. virtual void mousePressEvent(QMouseEvent*event);
  1075. virtual void mouseReleaseEvent(QMouseEvent*event);
  1076. };
  1077. /*:724*//*736:*/
  1078. #line 15047 "./typica.w"
  1079. class IntensityControl:public QGraphicsView
  1080. {
  1081. Q_OBJECT
  1082. Q_PROPERTY(double value READ value WRITE setValue)
  1083. QGraphicsScene scene;
  1084. QGraphicsPolygonItem decrement;
  1085. QGraphicsPolygonItem increment;
  1086. QGraphicsPolygonItem indicator;
  1087. QGraphicsPathItem scaleLine;
  1088. QPolygonF left;
  1089. QPolygonF up;
  1090. QPolygonF down;
  1091. QPainterPath scalePath;
  1092. QBrush theBrush;
  1093. double theValue;
  1094. bool valueSet;
  1095. bool scaleDown;
  1096. public:
  1097. IntensityControl();
  1098. double value();
  1099. virtual QSize sizeHint()const;
  1100. public slots:
  1101. void setValue(double val);
  1102. signals:
  1103. void valueChanged(double);
  1104. protected:
  1105. virtual void mousePressEvent(QMouseEvent*event);
  1106. virtual void mouseReleaseEvent(QMouseEvent*event);
  1107. };
  1108. /*:736*//*752:*/
  1109. #line 15435 "./typica.w"
  1110. class DeviceTreeModelNode
  1111. {
  1112. public:
  1113. DeviceTreeModelNode(QDomNode&node,int row,
  1114. DeviceTreeModelNode*parent= NULL);
  1115. ~DeviceTreeModelNode();
  1116. DeviceTreeModelNode*child(int index);
  1117. DeviceTreeModelNode*parent();
  1118. QDomNode node()const;
  1119. int row();
  1120. private:
  1121. QDomNode domNode;
  1122. QHash<int,DeviceTreeModelNode*> children;
  1123. int rowNumber;
  1124. DeviceTreeModelNode*parentItem;
  1125. };
  1126. /*:752*//*754:*/
  1127. #line 15510 "./typica.w"
  1128. class DeviceTreeModel:public QAbstractItemModel
  1129. {
  1130. Q_OBJECT
  1131. public:
  1132. DeviceTreeModel(QObject*parent= NULL);
  1133. ~DeviceTreeModel();
  1134. QVariant data(const QModelIndex&index,int role)const;
  1135. Qt::ItemFlags flags(const QModelIndex&index)const;
  1136. QVariant headerData(int section,Qt::Orientation orientation,
  1137. int role= Qt::DisplayRole)const;
  1138. QModelIndex index(int row,int column,
  1139. const QModelIndex&parent= QModelIndex())const;
  1140. QModelIndex parent(const QModelIndex&child)const;
  1141. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1142. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1143. bool setData(const QModelIndex&index,const QVariant&value,
  1144. int role);
  1145. bool removeRows(int row,int count,const QModelIndex&parent);
  1146. QDomElement referenceElement(const QString&id);
  1147. public slots:
  1148. void newNode(const QString&name,const QString&driver,
  1149. const QModelIndex&parent);
  1150. private:
  1151. QDomDocument document;
  1152. DeviceTreeModelNode*root;
  1153. QDomNode referenceSection;
  1154. QDomNode treeRoot;
  1155. };
  1156. /*:754*//*773:*/
  1157. #line 15964 "./typica.w"
  1158. Q_DECLARE_METATYPE(QModelIndex)
  1159. /*:773*//*781:*/
  1160. #line 16071 "./typica.w"
  1161. class NodeInserter:public QAction
  1162. {
  1163. Q_OBJECT
  1164. public:
  1165. NodeInserter(const QString&title,const QString&name,
  1166. const QString&driver,QObject*parent= NULL);
  1167. signals:
  1168. void triggered(QString name,QString driver);
  1169. private slots:
  1170. void onTriggered();
  1171. private:
  1172. QString defaultNodeName;
  1173. QString driverString;
  1174. };
  1175. /*:781*//*784:*/
  1176. #line 16126 "./typica.w"
  1177. class DeviceConfigurationWindow:public QWidget
  1178. {
  1179. Q_OBJECT
  1180. public:
  1181. DeviceConfigurationWindow();
  1182. public slots:
  1183. void addDevice();
  1184. void removeNode();
  1185. void newSelection(const QModelIndex&index);
  1186. private slots:
  1187. void resizeColumn();
  1188. private:
  1189. QDomDocument document;
  1190. DeviceTreeModel*model;
  1191. QTreeView*view;
  1192. QScrollArea*configArea;
  1193. };
  1194. /*:784*//*793:*/
  1195. #line 16296 "./typica.w"
  1196. class BasicDeviceConfigurationWidget:public QWidget
  1197. {
  1198. Q_OBJECT
  1199. public:
  1200. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1201. const QModelIndex&index);
  1202. public slots:
  1203. void insertChildNode(const QString&name,const QString&driver);
  1204. void updateAttribute(const QString&name,const QString&value);
  1205. protected:
  1206. DeviceTreeModel*deviceModel;
  1207. QModelIndex currentNode;
  1208. };
  1209. /*:793*//*797:*/
  1210. #line 16381 "./typica.w"
  1211. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1212. {
  1213. Q_OBJECT
  1214. public:
  1215. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1216. const QModelIndex&index);
  1217. private slots:
  1218. void updateRoasterId(int id);
  1219. void updateCapacityCheck(int value);
  1220. void updateCapacity(const QString&value);
  1221. void updateCapacityUnit(const QString&value);
  1222. };
  1223. /*:797*//*802:*/
  1224. #line 16586 "./typica.w"
  1225. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1226. {
  1227. Q_OBJECT
  1228. public:
  1229. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1230. const QModelIndex&index);
  1231. };
  1232. /*:802*//*804:*/
  1233. #line 16632 "./typica.w"
  1234. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1235. {
  1236. Q_OBJECT
  1237. public:
  1238. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1239. const QModelIndex&index);
  1240. private slots:
  1241. void addChannel();
  1242. void updateDeviceId(const QString&newId);
  1243. };
  1244. /*:804*//*808:*/
  1245. #line 16718 "./typica.w"
  1246. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1247. {
  1248. Q_OBJECT
  1249. public:
  1250. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1251. const QModelIndex&index);
  1252. private slots:
  1253. void updateThermocoupleType(const QString&type);
  1254. void updateColumnName(const QString&name);
  1255. void updateHidden(bool hidden);
  1256. };
  1257. /*:808*//*813:*/
  1258. #line 16834 "./typica.w"
  1259. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1260. {
  1261. Q_OBJECT
  1262. public:
  1263. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1264. const QModelIndex&index);
  1265. };
  1266. /*:813*//*815:*/
  1267. #line 16875 "./typica.w"
  1268. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1269. {
  1270. Q_OBJECT
  1271. public:
  1272. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1273. const QModelIndex&index);
  1274. private slots:
  1275. void addChannel();
  1276. void updateDeviceId(const QString&newId);
  1277. };
  1278. /*:815*//*817:*/
  1279. #line 16944 "./typica.w"
  1280. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1281. {
  1282. Q_OBJECT
  1283. public:
  1284. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1285. const QModelIndex&index);
  1286. private slots:
  1287. void updateDeviceId(const QString&newId);
  1288. void updateThermocoupleType(const QString&type);
  1289. void updateColumnName(const QString&name);
  1290. void updateHidden(bool hidden);
  1291. };
  1292. /*:817*//*822:*/
  1293. #line 17075 "./typica.w"
  1294. class PortSelector:public QComboBox
  1295. {
  1296. Q_OBJECT
  1297. public:
  1298. PortSelector(QWidget*parent= NULL);
  1299. private slots:
  1300. void addDevice(QextPortInfo port);
  1301. private:
  1302. QextSerialEnumerator*lister;
  1303. };
  1304. /*:822*//*824:*/
  1305. #line 17123 "./typica.w"
  1306. class BaudSelector:public QComboBox
  1307. {
  1308. Q_OBJECT
  1309. Q_ENUMS(BaudRateType)
  1310. public:
  1311. BaudSelector(QWidget*parent= NULL);
  1312. enum BaudRateType
  1313. {
  1314. #if defined(Q_OS_UNIX) || defined(qdoc)
  1315. BAUD50= 50,
  1316. BAUD75= 75,
  1317. BAUD134= 134,
  1318. BAUD150= 150,
  1319. BAUD200= 200,
  1320. BAUD1800= 1800,
  1321. #if defined(B76800) || defined(qdoc)
  1322. BAUD76800= 76800,
  1323. #endif
  1324. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1325. BAUD230400= 230400,
  1326. BAUD460800= 460800,
  1327. BAUD500000= 500000,
  1328. BAUD576000= 576000,
  1329. BAUD921600= 921600,
  1330. BAUD1000000= 1000000,
  1331. BAUD1152000= 1152000,
  1332. BAUD1500000= 1500000,
  1333. BAUD2000000= 2000000,
  1334. BAUD2500000= 2500000,
  1335. BAUD3000000= 3000000,
  1336. BAUD3500000= 3500000,
  1337. BAUD4000000= 4000000,
  1338. #endif
  1339. #endif
  1340. #if defined(Q_OS_WIN) || defined(qdoc)
  1341. BAUD14400= 14400,
  1342. BAUD56000= 56000,
  1343. BAUD128000= 128000,
  1344. BAUD256000= 256000,
  1345. #endif
  1346. BAUD110= 110,
  1347. BAUD300= 300,
  1348. BAUD600= 600,
  1349. BAUD1200= 1200,
  1350. BAUD2400= 2400,
  1351. BAUD4800= 4800,
  1352. BAUD9600= 9600,
  1353. BAUD19200= 19200,
  1354. BAUD38400= 38400,
  1355. BAUD57600= 57600,
  1356. BAUD115200= 115200
  1357. };
  1358. };
  1359. /*:824*//*826:*/
  1360. #line 17194 "./typica.w"
  1361. class ParitySelector:public QComboBox
  1362. {
  1363. Q_OBJECT
  1364. Q_ENUMS(ParityType)
  1365. public:
  1366. ParitySelector(QWidget*parent= NULL);
  1367. enum ParityType
  1368. {
  1369. PAR_NONE,
  1370. PAR_ODD,
  1371. PAR_EVEN,
  1372. #if defined(Q_OS_WIN) || defined(qdoc)
  1373. PAR_MARK,
  1374. #endif
  1375. PAR_SPACE
  1376. };
  1377. };
  1378. /*:826*//*828:*/
  1379. #line 17232 "./typica.w"
  1380. class FlowSelector:public QComboBox
  1381. {
  1382. Q_OBJECT
  1383. Q_ENUMS(FlowType)
  1384. public:
  1385. FlowSelector(QWidget*parent= NULL);
  1386. enum FlowType
  1387. {
  1388. FLOW_OFF,
  1389. FLOW_HARDWARE,
  1390. FLOW_XONXOFF
  1391. };
  1392. };
  1393. /*:828*//*830:*/
  1394. #line 17265 "./typica.w"
  1395. class StopSelector:public QComboBox
  1396. {
  1397. Q_OBJECT
  1398. Q_ENUMS(StopBitsType)
  1399. public:
  1400. StopSelector(QWidget*parent= NULL);
  1401. enum StopBitsType
  1402. {
  1403. STOP_1,
  1404. #if defined(Q_OS_WIN) || defined(qdoc)
  1405. STOP_1_5,
  1406. #endif
  1407. STOP_2
  1408. };
  1409. };
  1410. /*:830*//*833:*/
  1411. #line 17322 "./typica.w"
  1412. class ShortHexSpinBox:public QSpinBox
  1413. {
  1414. Q_OBJECT
  1415. public:
  1416. ShortHexSpinBox(QWidget*parent= NULL);
  1417. virtual QValidator::State validate(QString&input,int&pos)const;
  1418. protected:
  1419. virtual int valueFromText(const QString&text)const;
  1420. virtual QString textFromValue(int value)const;
  1421. };
  1422. /*:833*//*835:*/
  1423. #line 17384 "./typica.w"
  1424. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1425. {
  1426. Q_OBJECT
  1427. public:
  1428. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1429. const QModelIndex&index);
  1430. private slots:
  1431. void updatePort(const QString&newPort);
  1432. void updateBaudRate(const QString&newRate);
  1433. void updateParity(const QString&newParity);
  1434. void updateFlowControl(const QString&newFlow);
  1435. void updateStopBits(const QString&newStopBits);
  1436. };
  1437. /*:835*//*837:*/
  1438. #line 17535 "./typica.w"
  1439. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1440. {
  1441. Q_OBJECT
  1442. public:
  1443. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1444. const QModelIndex&index);
  1445. private slots:
  1446. void updateStationNumber(int newStation);
  1447. void updateFixedUnit(bool newFixed);
  1448. void updateFixedDecimal(bool newFixed);
  1449. void updateUnit(const QString&newUnit);
  1450. void updateUnitAddress(int newAddress);
  1451. void updateValueF(int newValue);
  1452. void updateValueC(int newValue);
  1453. void updatePrecisionAddress(int newAddress);
  1454. void updatePrecisionValue(int newValue);
  1455. private:
  1456. QStackedLayout*unitSpecificationLayout;
  1457. QStackedLayout*decimalSpecificationLayout;
  1458. };
  1459. /*:837*//*839:*/
  1460. #line 17794 "./typica.w"
  1461. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1462. {
  1463. Q_OBJECT
  1464. public:
  1465. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1466. const QModelIndex&index);
  1467. private slots:
  1468. void updateAddress(int newAddress);
  1469. };
  1470. /*:839*//*841:*/
  1471. #line 17840 "./typica.w"
  1472. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1473. {
  1474. Q_OBJECT
  1475. public:
  1476. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1477. const QModelIndex&index);
  1478. private slots:
  1479. void updateReadAddress(int newAddress);
  1480. void updateWriteAddress(int newAddress);
  1481. void updateFixedRange(bool fixed);
  1482. void updateLower(const QString&lower);
  1483. void updateUpper(const QString&upper);
  1484. void updateLowerAddress(int newAddress);
  1485. void updateUpperAddress(int newAddress);
  1486. private:
  1487. QStackedLayout*boundsLayout;
  1488. };
  1489. /*:841*//*845:*/
  1490. #line 18034 "./typica.w"
  1491. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1492. {
  1493. Q_OBJECT
  1494. public:
  1495. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1496. private slots:
  1497. void updateButtonText(const QString&text);
  1498. void updateAnnotationText(const QString&text);
  1499. };
  1500. /*:845*//*849:*/
  1501. #line 18102 "./typica.w"
  1502. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1503. {
  1504. Q_OBJECT
  1505. public:
  1506. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1507. private slots:
  1508. void updateButtonText(const QString&text);
  1509. void updateAnnotationText(const QString&text);
  1510. };
  1511. /*:849*//*852:*/
  1512. #line 18176 "./typica.w"
  1513. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1514. {
  1515. Q_OBJECT
  1516. public:
  1517. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1518. private slots:
  1519. void updateLabel(const QString&text);
  1520. void updateMinimum(const QString&minimum);
  1521. void updateMaximum(const QString&maximum);
  1522. void updatePrecision(int precision);
  1523. void updatePretext(const QString&text);
  1524. void updatePosttext(const QString&text);
  1525. };
  1526. /*:852*//*855:*/
  1527. #line 12 "./freeannotation.w"
  1528. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1529. {
  1530. Q_OBJECT
  1531. public:
  1532. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1533. private slots:
  1534. void updateLabel(const QString&text);
  1535. };
  1536. /*:855*//*859:*/
  1537. #line 11 "./settings.w"
  1538. class SettingsWindow:public QMainWindow
  1539. {
  1540. Q_OBJECT
  1541. public:
  1542. SettingsWindow();
  1543. };
  1544. /*:859*//*864:*/
  1545. #line 8 "./graphsettings.w"
  1546. class GraphSettingsWidget:public QWidget
  1547. {
  1548. Q_OBJECT
  1549. public:
  1550. GraphSettingsWidget();
  1551. };
  1552. /*:864*//*866:*/
  1553. #line 46 "./graphsettings.w"
  1554. class GraphSettingsRelativeTab:public QWidget
  1555. {
  1556. Q_OBJECT
  1557. public:
  1558. GraphSettingsRelativeTab();
  1559. public slots:
  1560. void updateEnableSetting(bool enable);
  1561. void updateColorSetting(const QString&color);
  1562. void updateAxisSetting(const QString&gridList);
  1563. void updateUnit(int unit);
  1564. void showColorPicker();
  1565. private:
  1566. QLineEdit*colorEdit;
  1567. };
  1568. /*:866*//*870:*/
  1569. #line 7 "./advancedsettings.w"
  1570. class AdvancedSettingsWidget:public QWidget
  1571. {
  1572. Q_OBJECT
  1573. public:
  1574. AdvancedSettingsWidget();
  1575. public slots:
  1576. void enableDiagnosticLogging(bool enabled);
  1577. };
  1578. /*:870*//*874:*/
  1579. #line 18301 "./typica.w"
  1580. class ModbusRTUDevice:public QObject
  1581. {
  1582. Q_OBJECT
  1583. public:
  1584. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1585. ~ModbusRTUDevice();
  1586. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1587. Q_INVOKABLE double SVLower();
  1588. Q_INVOKABLE double SVUpper();
  1589. Q_INVOKABLE int decimals();
  1590. QList<Channel*> channels;
  1591. public slots:
  1592. void outputSV(double sv);
  1593. signals:
  1594. void SVLowerChanged(double);
  1595. void SVUpperChanged(double);
  1596. void SVDecimalChanged(int);
  1597. void queueEmpty();
  1598. private slots:
  1599. void dataAvailable();
  1600. void sendNextMessage();
  1601. void decimalResponse(QByteArray response);
  1602. void unitResponse(QByteArray response);
  1603. void svlResponse(QByteArray response);
  1604. void svuResponse(QByteArray response);
  1605. void requestMeasurement();
  1606. void mResponse(QByteArray response);
  1607. void ignore(QByteArray response);
  1608. void timeout();
  1609. private:
  1610. QextSerialPort*port;
  1611. QByteArray responseBuffer;
  1612. QList<QByteArray> messageQueue;
  1613. QList<QObject*> retObjQueue;
  1614. QList<char*> callbackQueue;
  1615. quint16 calculateCRC(QByteArray data);
  1616. QTimer*messageDelayTimer;
  1617. QTimer*commTimeout;
  1618. int delayTime;
  1619. char station;
  1620. int decimalPosition;
  1621. int valueF;
  1622. int valueC;
  1623. bool unitIsF;
  1624. double outputSVLower;
  1625. double outputSVUpper;
  1626. QByteArray outputSVStub;
  1627. QByteArray pvStub;
  1628. QByteArray svStub;
  1629. QByteArray mStub;
  1630. quint16 pvaddress;
  1631. quint16 svaddress;
  1632. bool svenabled;
  1633. bool readingsv;
  1634. double savedpv;
  1635. bool waiting;
  1636. };
  1637. /*:874*//*890:*/
  1638. #line 19004 "./typica.w"
  1639. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1640. {
  1641. Q_OBJECT
  1642. public:
  1643. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1644. private slots:
  1645. void updatePort(const QString&newPort);
  1646. void updateBaudRate(const QString&newRate);
  1647. void updateParity(const QString&newParity);
  1648. void updateFlowControl(const QString&newFlow);
  1649. void updateStopBits(const QString&newStopBits);
  1650. void updateStation(int station);
  1651. void updateFixedDecimal(bool fixed);
  1652. void updateDecimalAddress(int address);
  1653. void updateDecimalPosition(int position);
  1654. void updateFixedUnit(bool fixed);
  1655. void updateUnitAddress(int address);
  1656. void updateValueForF(int value);
  1657. void updateValueForC(int value);
  1658. void updateUnit(const QString&newUnit);
  1659. void updatePVAddress(int address);
  1660. void updateSVEnabled(bool enabled);
  1661. void updateSVReadAddress(int address);
  1662. void updateDeviceLimit(bool query);
  1663. void updateSVLowerAddress(int address);
  1664. void updateSVUpperAddress(int address);
  1665. void updateSVLower(double value);
  1666. void updateSVUpper(double value);
  1667. void updateSVWritable(bool canWriteSV);
  1668. void updateSVWriteAddress(int address);
  1669. void updatePVColumnName(const QString&name);
  1670. void updateSVColumnName(const QString&name);
  1671. void updatePVHidden(bool hidden);
  1672. void updateSVHidden(bool hidden);
  1673. private:
  1674. PortSelector*port;
  1675. BaudSelector*baud;
  1676. ParitySelector*parity;
  1677. FlowSelector*flow;
  1678. StopSelector*stop;
  1679. QSpinBox*station;
  1680. QCheckBox*decimalQuery;
  1681. ShortHexSpinBox*decimalAddress;
  1682. QSpinBox*decimalPosition;
  1683. QCheckBox*unitQuery;
  1684. ShortHexSpinBox*unitAddress;
  1685. QSpinBox*valueF;
  1686. QSpinBox*valueC;
  1687. QComboBox*fixedUnit;
  1688. ShortHexSpinBox*pVAddress;
  1689. QCheckBox*sVEnabled;
  1690. ShortHexSpinBox*sVReadAddress;
  1691. QCheckBox*deviceLimit;
  1692. ShortHexSpinBox*sVLowerAddr;
  1693. ShortHexSpinBox*sVUpperAddr;
  1694. QDoubleSpinBox*sVLower;
  1695. QDoubleSpinBox*sVUpper;
  1696. QCheckBox*sVWritable;
  1697. ShortHexSpinBox*sVOutputAddr;
  1698. QLineEdit*pVColumnName;
  1699. QLineEdit*sVColumnName;
  1700. };
  1701. /*:890*//*894:*/
  1702. #line 22 "./modbus.w"
  1703. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1704. {
  1705. Q_OBJECT
  1706. public:
  1707. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1708. private slots:
  1709. void updatePort(const QString&value);
  1710. void updateBaudRate(const QString&value);
  1711. void updateParity(int value);
  1712. void updateFlowControl(int value);
  1713. void updateStopBits(int value);
  1714. void addInput();
  1715. private:
  1716. ParitySelector*m_parity;
  1717. FlowSelector*m_flow;
  1718. StopSelector*m_stop;
  1719. };
  1720. /*:894*//*896:*/
  1721. #line 144 "./modbus.w"
  1722. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1723. {
  1724. Q_OBJECT
  1725. public:
  1726. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1727. private slots:
  1728. void updateStation(int value);
  1729. void updateAddress(int value);
  1730. void updateFunction(int value);
  1731. void updateFormat(int value);
  1732. void updateDecimals(int value);
  1733. void updateUnit(int value);
  1734. void updateColumnName(const QString&value);
  1735. void updateHidden(bool value);
  1736. };
  1737. /*:896*//*900:*/
  1738. #line 342 "./modbus.w"
  1739. enum ModbusDataFormat
  1740. {
  1741. Int16,
  1742. FloatHL,
  1743. FloatLH
  1744. };
  1745. struct ModbusScanItem
  1746. {
  1747. QByteArray request;
  1748. ModbusDataFormat format;
  1749. int decimalPosition;
  1750. Units::Unit unit;
  1751. mutable double lastValue;
  1752. };
  1753. /*:900*//*901:*/
  1754. #line 362 "./modbus.w"
  1755. class ModbusNG:public QObject
  1756. {
  1757. Q_OBJECT
  1758. public:
  1759. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1760. ~ModbusNG();
  1761. Q_INVOKABLE int channelCount();
  1762. Channel*getChannel(int);
  1763. Q_INVOKABLE QString channelColumnName(int);
  1764. Q_INVOKABLE QString channelIndicatorText(int);
  1765. Q_INVOKABLE bool isChannelHidden(int);
  1766. Q_INVOKABLE QString channelType(int);
  1767. private slots:
  1768. void sendNextMessage();
  1769. void timeout();
  1770. void dataAvailable();
  1771. void rateLimitTimeout();
  1772. private:
  1773. quint16 calculateCRC(QByteArray data);
  1774. QextSerialPort*port;
  1775. int delayTime;
  1776. QTimer*messageDelayTimer;
  1777. QTimer*commTimeout;
  1778. QTimer*rateLimiter;
  1779. int scanPosition;
  1780. bool waiting;
  1781. QByteArray responseBuffer;
  1782. QList<Channel*> channels;
  1783. QList<ModbusScanItem> scanList;
  1784. QList<QString> channelNames;
  1785. QList<QString> channelLabels;
  1786. QList<bool> hiddenStates;
  1787. QList<QString> channelTypeList;
  1788. QVector<double> lastMeasurement;
  1789. };
  1790. /*:901*//*906:*/
  1791. #line 36 "./unsupportedserial.w"
  1792. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1793. {
  1794. Q_OBJECT
  1795. public:
  1796. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1797. const QModelIndex&index);
  1798. private slots:
  1799. void updateConfiguration();
  1800. void saveScript();
  1801. void addChannel();
  1802. private:
  1803. SaltModel*deviceSettingsModel;
  1804. QTextEdit*scriptEditor;
  1805. };
  1806. /*:906*//*911:*/
  1807. #line 166 "./unsupportedserial.w"
  1808. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1809. {
  1810. Q_OBJECT
  1811. public:
  1812. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1813. const QModelIndex&index);
  1814. private slots:
  1815. void updateColumnName(const QString&value);
  1816. void updateHidden(bool hidden);
  1817. void updateConfiguration();
  1818. private:
  1819. SaltModel*channelSettingsModel;
  1820. };
  1821. /*:911*//*916:*/
  1822. #line 298 "./unsupportedserial.w"
  1823. class JavaScriptDevice:public QObject
  1824. {
  1825. Q_OBJECT
  1826. public:
  1827. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1828. QScriptEngine*engine);
  1829. Q_INVOKABLE int channelCount();
  1830. Channel*getChannel(int channel);
  1831. Q_INVOKABLE bool isChannelHidden(int channel);
  1832. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1833. Q_INVOKABLE QString channelColumnName(int channel);
  1834. Q_INVOKABLE QString channelIndicatorText(int channel);
  1835. public slots:
  1836. void setTemperatureColumn(int tcol);
  1837. void setAnnotationColumn(int ncol);
  1838. void start();
  1839. void stop();
  1840. signals:
  1841. void annotation(QString note,int tcol,int ncol);
  1842. void triggerStartBatch();
  1843. void triggerStopBatch();
  1844. void deviceStopRequested();
  1845. private:
  1846. QVariantMap deviceSettings;
  1847. QString deviceScript;
  1848. QList<Channel*> channelList;
  1849. QList<bool> hiddenState;
  1850. QList<Units::Unit> channelUnits;
  1851. QList<QString> columnNames;
  1852. QList<QString> indicatorTexts;
  1853. QList<QVariantMap> channelSettings;
  1854. int annotationTemperatureColumn;
  1855. int annotationNoteColumn;
  1856. QScriptEngine*scriptengine;
  1857. };
  1858. /*:916*//*938:*/
  1859. #line 11 "./phidgets.w"
  1860. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1861. {
  1862. Q_OBJECT
  1863. public:
  1864. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1865. const QModelIndex&index);
  1866. private slots:
  1867. void addChannel();
  1868. void updateRate(int ms);
  1869. };
  1870. /*:938*//*942:*/
  1871. #line 82 "./phidgets.w"
  1872. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1873. {
  1874. Q_OBJECT
  1875. public:
  1876. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1877. const QModelIndex&index);
  1878. private slots:
  1879. void updateColumnName(const QString&value);
  1880. void updateHidden(bool hidden);
  1881. void updateTC(int index);
  1882. void updateChannel(int channel);
  1883. private:
  1884. QComboBox*tcType;
  1885. };
  1886. /*:942*//*947:*/
  1887. #line 213 "./phidgets.w"
  1888. class PhidgetsTemperatureSensor:public QObject
  1889. {
  1890. Q_OBJECT
  1891. public:
  1892. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1893. Q_INVOKABLE int channelCount();
  1894. Channel*getChannel(int channel);
  1895. Q_INVOKABLE bool isChannelHidden(int channel);
  1896. Q_INVOKABLE QString channelColumnName(int channel);
  1897. Q_INVOKABLE QString channelIndicatorText(int channel);
  1898. public slots:
  1899. void start();
  1900. void stop();
  1901. private slots:
  1902. void getMeasurements();
  1903. private:
  1904. QList<int> channelIndices;
  1905. QList<int> tctypes;
  1906. QList<Channel*> channelList;
  1907. QMap<int,Channel*> channelMap;
  1908. QList<bool> hiddenState;
  1909. QList<QString> columnNames;
  1910. QList<QString> indicatorTexts;
  1911. QLibrary driver;
  1912. QTimer sampleTimer;
  1913. void*device;
  1914. /*951:*/
  1915. #line 349 "./phidgets.w"
  1916. #ifdef _WIN32
  1917. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1918. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1919. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1920. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1921. #else
  1922. typedef int(*PhidgetHandleOnly)(void*);
  1923. typedef int(*PhidgetHandleInt)(void*,int);
  1924. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1925. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1926. #endif
  1927. PhidgetHandleOnly createDevice;
  1928. PhidgetHandleInt openDevice;
  1929. PhidgetHandleInt waitForOpen;
  1930. PhidgetHandleIntInt setTCType;
  1931. PhidgetHandleIntDoubleOut getTemperature;
  1932. PhidgetHandleOnly closeDevice;
  1933. PhidgetHandleOnly deleteDevice;
  1934. /*:951*/
  1935. #line 240 "./phidgets.w"
  1936. };
  1937. /*:947*//*960:*/
  1938. #line 19544 "./typica.w"
  1939. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1940. {
  1941. Q_OBJECT
  1942. public:
  1943. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1944. const QModelIndex&index);
  1945. private slots:
  1946. void updateSourceColumn(const QString&source);
  1947. void updateDestinationColumn(const QString&dest);
  1948. void updateKnots();
  1949. private:
  1950. SaltModel*tablemodel;
  1951. };
  1952. /*:960*//*966:*/
  1953. #line 19674 "./typica.w"
  1954. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1955. {
  1956. Q_OBJECT
  1957. public:
  1958. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1959. const QModelIndex&index);
  1960. private slots:
  1961. void updateResetTime(QTime time);
  1962. };
  1963. /*:966*//*970:*/
  1964. #line 19740 "./typica.w"
  1965. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1966. {
  1967. Q_OBJECT
  1968. public:
  1969. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1970. private slots:
  1971. void updateStartButtonText(const QString&text);
  1972. void updateStopButtonText(const QString&text);
  1973. void updateStartColumnName(const QString&text);
  1974. void updateStopColumnName(const QString&text);
  1975. void updateStartValue(const QString&text);
  1976. void updateStopValue(const QString&text);
  1977. void updateStartTrigger(int option);
  1978. void updateStopTrigger(int option);
  1979. };
  1980. /*:970*//*975:*/
  1981. #line 19992 "./typica.w"
  1982. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1983. {
  1984. Q_OBJECT
  1985. public:
  1986. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1987. const QModelIndex&index);
  1988. private slots:
  1989. void updateColumnName(const QString&text);
  1990. void updateRangeData();
  1991. private:
  1992. SaltModel*tablemodel;
  1993. };
  1994. /*:975*//*980:*/
  1995. #line 20094 "./typica.w"
  1996. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1997. {
  1998. Q_OBJECT
  1999. public:
  2000. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2001. private slots:
  2002. void updateMatchingColumn(const QString&column);
  2003. void updateTemperature();
  2004. void updateDelay();
  2005. private:
  2006. QDoubleSpinBox*temperatureValue;
  2007. QComboBox*unitSelector;
  2008. QSpinBox*delaySelector;
  2009. };
  2010. /*:980*//*984:*/
  2011. #line 16 "./rate.w"
  2012. class RateOfChange:public QObject
  2013. {
  2014. Q_OBJECT
  2015. public:
  2016. RateOfChange(int cachetime= 1,int scaletime= 1);
  2017. public slots:
  2018. void newMeasurement(Measurement measure);
  2019. void setCacheTime(int seconds);
  2020. void setScaleTime(int seconds);
  2021. signals:
  2022. void newData(Measurement measure);
  2023. private:
  2024. int ct;
  2025. int st;
  2026. QList<Measurement> cache;
  2027. };
  2028. /*:984*//*992:*/
  2029. #line 177 "./rate.w"
  2030. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  2031. {
  2032. Q_OBJECT
  2033. public:
  2034. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2035. private slots:
  2036. void updateColumn(const QString&column);
  2037. void updateCacheTime(const QString&seconds);
  2038. void updateScaleTime(const QString&seconds);
  2039. };
  2040. /*:992*//*998:*/
  2041. #line 19 "./dataqsdk.w"
  2042. class DataqSdkDeviceImplementation;
  2043. class DataqSdkDevice:public QObject
  2044. {
  2045. Q_OBJECT
  2046. DataqSdkDeviceImplementation*imp;
  2047. private slots:
  2048. void threadFinished();
  2049. public:
  2050. DataqSdkDevice(QString device);
  2051. ~DataqSdkDevice();
  2052. Channel*newChannel(Units::Unit scale);
  2053. Q_INVOKABLE void setClockRate(double Hz);
  2054. Q_INVOKABLE void start();
  2055. static QStringList detectPorts();
  2056. static QStringList detectHardware();
  2057. };
  2058. /*:998*//*999:*/
  2059. #line 49 "./dataqsdk.w"
  2060. class DataqSdkDeviceImplementation:public QThread
  2061. {
  2062. Q_OBJECT
  2063. public:
  2064. DataqSdkDeviceImplementation();
  2065. ~DataqSdkDeviceImplementation();
  2066. void run();
  2067. /*1000:*/
  2068. #line 70 "./dataqsdk.w"
  2069. typedef struct di_inlist_struct{
  2070. unsigned short chan;
  2071. unsigned short diff;
  2072. unsigned short gain;
  2073. unsigned short unipolar;
  2074. unsigned short dig_out_enable;
  2075. unsigned short dig_out;
  2076. unsigned short ave;
  2077. unsigned short counter;
  2078. }DI_INLIST_STRUCT;
  2079. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2080. typedef int(PASCAL*FPDICLOSE)(void);
  2081. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2082. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2083. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2084. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2085. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2086. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2087. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2088. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2089. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2090. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2091. FPDIOPEN di_open;
  2092. FPDICLOSE di_close;
  2093. FPDISAMPLERATE di_sample_rate;
  2094. FPDIMAXIMUMRATE di_maximum_rate;
  2095. FPDILISTLENGTH di_list_length;
  2096. FPDIINLIST di_inlist;
  2097. FPDIBUFFERALLOC di_buffer_alloc;
  2098. FPDISTARTSCAN di_start_scan;
  2099. FPDISTATUSREAD di_status_read;
  2100. FPDIBUFFERSTATUS di_buffer_status;
  2101. FPDIBURSTRATE di_burst_rate;
  2102. FPDISTOPSCAN di_stop_scan;
  2103. /*:1000*/
  2104. #line 57 "./dataqsdk.w"
  2105. /*1002:*/
  2106. #line 134 "./dataqsdk.w"
  2107. bool isOpen;
  2108. double sampleRate;
  2109. long oversample;
  2110. long burstDivisor;
  2111. QString device;
  2112. unsigned deviceNumber;
  2113. QVector<Channel*> channelMap;
  2114. int error;
  2115. int channels;
  2116. bool ready;
  2117. QLibrary*driver;
  2118. QVector<Units::Unit> unitMap;
  2119. int*input_buffer;
  2120. QTimer*eventClock;
  2121. QMultiMap<int,double> smoother;
  2122. /*:1002*/
  2123. #line 58 "./dataqsdk.w"
  2124. public slots:
  2125. void measure();
  2126. private:
  2127. qint16*buffer;
  2128. };
  2129. /*:999*//*1019:*/
  2130. #line 663 "./dataqsdk.w"
  2131. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2132. {
  2133. Q_OBJECT
  2134. public:
  2135. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2136. const QModelIndex&index);
  2137. private slots:
  2138. void updateAutoSelect(bool automatic);
  2139. void updateDeviceNumber(int deviceNumber);
  2140. void updatePort(QString portId);
  2141. void addChannel();
  2142. private:
  2143. QStackedWidget*deviceIdStack;
  2144. };
  2145. /*:1019*//*1024:*/
  2146. #line 808 "./dataqsdk.w"
  2147. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2148. {
  2149. Q_OBJECT
  2150. public:
  2151. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2152. const QModelIndex&index);
  2153. private slots:
  2154. void updateUnits(const QString&unit);
  2155. void updateColumnName(const QString&value);
  2156. void updateMeasuredLower(const QString&value);
  2157. void updateMeasuredUpper(const QString&value);
  2158. void updateMappedLower(const QString&value);
  2159. void updateMappedUpper(const QString&value);
  2160. void updateClosedInterval(bool closed);
  2161. void updateSmoothingEnabled(bool enabled);
  2162. void updateSensitivity(const QString&value);
  2163. void startCalibration();
  2164. void stopCalibration();
  2165. void resetCalibration();
  2166. void updateInput(Measurement measure);
  2167. void updateOutput(Measurement measure);
  2168. void updateHidden(bool hidden);
  2169. private:
  2170. QPushButton*startButton;
  2171. QPushButton*resetButton;
  2172. QPushButton*stopButton;
  2173. /*1029:*/
  2174. #line 1098 "./dataqsdk.w"
  2175. bool autoSelect;
  2176. QString deviceID;
  2177. unsigned int channelOfInterest;
  2178. /*:1029*/
  2179. #line 835 "./dataqsdk.w"
  2180. DataqSdkDevice*calibrationDevice;
  2181. LinearCalibrator*calibrator;
  2182. QLineEdit*currentMeasurement;
  2183. QLineEdit*minimumMeasurement;
  2184. QLineEdit*maximumMeasurement;
  2185. QLineEdit*averageMeasurement;
  2186. QLineEdit*currentMapped;
  2187. QLineEdit*minimumMapped;
  2188. QLineEdit*maximumMapped;
  2189. QLineEdit*averageMapped;
  2190. int rmCount;
  2191. int cmCount;
  2192. double rmin;
  2193. double rmax;
  2194. double rmean;
  2195. double cmin;
  2196. double cmax;
  2197. double cmean;
  2198. };
  2199. /*:1024*//*1051:*/
  2200. #line 273 "./scales.w"
  2201. Q_DECLARE_METATYPE(BaudRateType)
  2202. Q_DECLARE_METATYPE(DataBitsType)
  2203. Q_DECLARE_METATYPE(ParityType)
  2204. Q_DECLARE_METATYPE(StopBitsType)
  2205. Q_DECLARE_METATYPE(FlowType)
  2206. /*:1051*//*1058:*/
  2207. #line 396 "./scales.w"
  2208. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2209. {
  2210. Q_OBJECT
  2211. public:
  2212. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2213. const QModelIndex&index);
  2214. private slots:
  2215. void updatePort(const QString&newPort);
  2216. void updateBaudRate(const QString&rate);
  2217. void updateParity(int index);
  2218. void updateFlowControl(int index);
  2219. void updateStopBits(int index);
  2220. void updateWeighCommand(const QString&command);
  2221. void updateCommandTerminator(const QString&terminator);
  2222. private:
  2223. PortSelector*port;
  2224. BaudSelector*baud;
  2225. ParitySelector*parity;
  2226. FlowSelector*flow;
  2227. StopSelector*stop;
  2228. QLineEdit*weighcommand;
  2229. QComboBox*commandterminator;
  2230. };
  2231. /*:1058*//*1063:*/
  2232. #line 14 "./valueannotation.w"
  2233. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2234. {
  2235. Q_OBJECT
  2236. public:
  2237. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2238. const QModelIndex&index);
  2239. private slots:
  2240. void updateSourceColumn(const QString&source);
  2241. void updateAnnotations();
  2242. void updateStart(bool noteOnStart);
  2243. private:
  2244. SaltModel*tablemodel;
  2245. };
  2246. /*:1063*//*1071:*/
  2247. #line 165 "./valueannotation.w"
  2248. class ValueAnnotation:public QObject
  2249. {
  2250. Q_OBJECT
  2251. public:
  2252. ValueAnnotation();
  2253. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2254. public slots:
  2255. void newMeasurement(Measurement measure);
  2256. void annotate();
  2257. void setAnnotationColumn(int column);
  2258. void setTemperatureColumn(int column);
  2259. void setTolerance(double epsilon);
  2260. signals:
  2261. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2262. private:
  2263. int lastIndex;
  2264. int annotationColumn;
  2265. int measurementColumn;
  2266. QList<double> values;
  2267. QStringList annotations;
  2268. double tolerance;
  2269. };
  2270. /*:1071*//*1080:*/
  2271. #line 14 "./thresholdannotation.w"
  2272. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2273. {
  2274. Q_OBJECT
  2275. public:
  2276. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2277. const QModelIndex&index);
  2278. private slots:
  2279. void updateSourceColumn(const QString&source);
  2280. void updateThreshold(double value);
  2281. void updateDirection(int index);
  2282. void updateAnnotation(const QString&note);
  2283. };
  2284. /*:1080*//*1085:*/
  2285. #line 127 "./thresholdannotation.w"
  2286. class Annotator:public QObject
  2287. {
  2288. Q_OBJECT
  2289. QString note;
  2290. int tc;
  2291. int ac;
  2292. QTimer t;
  2293. public:
  2294. Annotator(const QString&text);
  2295. public slots:
  2296. void setAnnotation(const QString&annotation);
  2297. void setTemperatureColumn(int tempcolumn);
  2298. void setAnnotationColumn(int annotationcolumn);
  2299. void annotate();
  2300. private slots:
  2301. void catchTimer();
  2302. signals:
  2303. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2304. };
  2305. /*:1085*/
  2306. #line 526 "./typica.w"
  2307. /*12:*/
  2308. #line 811 "./typica.w"
  2309. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2310. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*engine);
  2311. /*:12*//*14:*/
  2312. #line 836 "./typica.w"
  2313. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2314. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2315. /*:14*//*19:*/
  2316. #line 896 "./typica.w"
  2317. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2318. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2319. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2320. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2321. QScriptEngine*engine);
  2322. /*:19*//*23:*/
  2323. #line 986 "./typica.w"
  2324. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2325. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2326. /*:23*//*33:*/
  2327. #line 1187 "./typica.w"
  2328. QScriptValue constructQMainWindow(QScriptContext*context,
  2329. QScriptEngine*engine);
  2330. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2331. QScriptEngine*engine);
  2332. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2333. QScriptEngine*engine);
  2334. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2335. /*:33*//*38:*/
  2336. #line 1286 "./typica.w"
  2337. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2338. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2339. /*:38*//*41:*/
  2340. #line 1331 "./typica.w"
  2341. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2342. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2343. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2344. /*:41*//*44:*/
  2345. #line 1397 "./typica.w"
  2346. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2347. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2348. /*:44*//*47:*/
  2349. #line 1430 "./typica.w"
  2350. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2351. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2352. /*:47*//*50:*/
  2353. #line 1468 "./typica.w"
  2354. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2355. QScriptValue constructQSvgWidget(QScriptContext*context,
  2356. QScriptEngine*engine);
  2357. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2358. QScriptEngine*engine);
  2359. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2360. QStack<QLayout*> *layoutStack);
  2361. /*:50*//*56:*/
  2362. #line 1555 "./typica.w"
  2363. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2364. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2365. /*:56*//*60:*/
  2366. #line 1594 "./typica.w"
  2367. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2368. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2369. QScriptEngine*engine);
  2370. QScriptValue QSplitter_saveState(QScriptContext*context,
  2371. QScriptEngine*engine);
  2372. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2373. QScriptEngine*engine);
  2374. QScriptValue QSplitter_count(QScriptContext*context,
  2375. QScriptEngine*engine);
  2376. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2377. /*:60*//*66:*/
  2378. #line 1733 "./typica.w"
  2379. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2380. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2381. /*:66*//*68:*/
  2382. #line 1788 "./typica.w"
  2383. QScriptValue constructQBoxLayout(QScriptContext*context,
  2384. QScriptEngine*engine);
  2385. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2386. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2387. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2388. /*:68*//*72:*/
  2389. #line 1901 "./typica.w"
  2390. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2391. QScriptValue QAction_setShortcut(QScriptContext*context,
  2392. QScriptEngine*engine);
  2393. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2394. /*:72*//*75:*/
  2395. #line 1957 "./typica.w"
  2396. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2397. QScriptEngine*engine);
  2398. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2399. QScriptEngine*engine);
  2400. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2401. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2402. /*:75*//*80:*/
  2403. #line 2068 "./typica.w"
  2404. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2405. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2406. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2407. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2408. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2409. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2410. QScriptValue QIODevice_readToString(QScriptContext*context,
  2411. QScriptEngine*engine);
  2412. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2413. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2414. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2415. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2416. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2417. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2418. /*:80*//*91:*/
  2419. #line 2294 "./typica.w"
  2420. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2421. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2422. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2423. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2424. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2425. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2426. /*:91*//*99:*/
  2427. #line 2412 "./typica.w"
  2428. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2429. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2430. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2431. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2432. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2433. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2434. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2435. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2436. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2437. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2438. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2439. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2440. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2441. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2442. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2443. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2444. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2445. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2446. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2447. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2448. /*:99*//*112:*/
  2449. #line 2686 "./typica.w"
  2450. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2451. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2452. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2453. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2454. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2455. /*:112*//*115:*/
  2456. #line 2791 "./typica.w"
  2457. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2458. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2459. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2460. /*:115*//*118:*/
  2461. #line 2836 "./typica.w"
  2462. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2463. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2464. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2465. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2466. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2467. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2468. /*:118*//*124:*/
  2469. #line 2918 "./typica.w"
  2470. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2471. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2472. QScriptEngine*engine);
  2473. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2474. QScriptEngine*engine);
  2475. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2476. QScriptEngine*engine);
  2477. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2478. QScriptEngine*engine);
  2479. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2480. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2481. QScriptEngine*engine);
  2482. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2483. QScriptEngine*engine);
  2484. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2485. QScriptEngine*engine);
  2486. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2487. QScriptEngine*engine);
  2488. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2489. QScriptEngine*engine);
  2490. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2491. QScriptEngine*engine);
  2492. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2493. QScriptEngine*engine);
  2494. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2495. QScriptEngine*engine);
  2496. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2497. /*:124*//*133:*/
  2498. #line 3136 "./typica.w"
  2499. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2500. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2501. QScriptValue XmlReader_attribute(QScriptContext*context,
  2502. QScriptEngine*engine);
  2503. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2504. QScriptEngine*engine);
  2505. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2506. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2507. QScriptEngine*engine);
  2508. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2509. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2510. QScriptEngine*engine);
  2511. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2512. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2513. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2514. /*:133*//*140:*/
  2515. #line 3271 "./typica.w"
  2516. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2517. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2518. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2519. /*:140*//*144:*/
  2520. #line 3353 "./typica.w"
  2521. QScriptValue constructQLCDNumber(QScriptContext*context,
  2522. QScriptEngine*engine);
  2523. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2524. /*:144*//*147:*/
  2525. #line 3391 "./typica.w"
  2526. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2527. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2528. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2529. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2530. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2531. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2532. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2533. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2534. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2535. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2536. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2537. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2538. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2539. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2540. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2541. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2542. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2544. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2545. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2546. /*:147*//*163:*/
  2547. #line 3869 "./typica.w"
  2548. void setQAbstractScrollAreaProperties(QScriptValue value,
  2549. QScriptEngine*engine);
  2550. /*:163*//*165:*/
  2551. #line 3884 "./typica.w"
  2552. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2553. /*:165*//*167:*/
  2554. #line 3897 "./typica.w"
  2555. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2556. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2557. /*:167*//*169:*/
  2558. #line 3921 "./typica.w"
  2559. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2560. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2561. QScriptValue constructQPushButton(QScriptContext*context,
  2562. QScriptEngine*engine);
  2563. /*:169*//*176:*/
  2564. #line 4020 "./typica.w"
  2565. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2566. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2567. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2568. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2569. QScriptEngine*engine);
  2570. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2571. QScriptEngine*engine);
  2572. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2573. QScriptEngine*engine);
  2574. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2575. QScriptEngine*engine);
  2576. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2577. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2578. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2579. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2580. /*:176*//*183:*/
  2581. #line 4191 "./typica.w"
  2582. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2583. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2584. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2585. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2586. QScriptValue annotationFromRecord(QScriptContext*context,
  2587. QScriptEngine*engine);
  2588. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2589. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2590. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2591. /*:183*//*196:*/
  2592. #line 4523 "./typica.w"
  2593. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2594. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2595. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2596. QStack<QLayout*> *layoutStack);
  2597. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2598. QStack<QLayout*> *layoutStack);
  2599. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2600. QStack<QLayout*> *layoutStack);
  2601. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2602. QStack<QLayout*> *layoutStack);
  2603. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2604. QStack<QLayout*> *layoutStack);
  2605. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2606. QStack<QLayout*> *layoutStack);
  2607. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2608. QStack<QLayout*> *layoutStack);
  2609. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2610. QStack<QLayout*> *layoutStack);
  2611. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2612. QStack<QLayout*> *layoutStack);
  2613. void addTemperatureDisplayToSplitter(QDomElement element,
  2614. QStack<QWidget*> *widgetStack,
  2615. QStack<QLayout*> *layoutStack);
  2616. void addTemperatureDisplayToLayout(QDomElement element,
  2617. QStack<QWidget*> *widgetStack,
  2618. QStack<QLayout*> *layoutStack);
  2619. void addTimerDisplayToSplitter(QDomElement element,
  2620. QStack<QWidget*> *widgetStack,
  2621. QStack<QLayout*> *layoutStack);
  2622. void addTimerDisplayToLayout(QDomElement element,
  2623. QStack<QWidget*> *widgetStack,
  2624. QStack<QLayout*> *layoutStack);
  2625. void addDecorationToSplitter(QDomElement element,
  2626. QStack<QWidget*> *widgetStack,
  2627. QStack<QLayout*> *layoutStack);
  2628. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2629. QStack<QLayout*> *layoutStack);
  2630. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2631. QStack<QLayout*> *layoutStack);
  2632. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2633. QStack<QLayout*> *layoutStack);
  2634. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2635. QStack<QLayout*> *layoutStack);
  2636. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2637. QStack<QLayout*> *layoutStack);
  2638. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2639. QStack<QLayout*> *layoutStack);
  2640. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2641. QStack<QLayout*> *layoutStack);
  2642. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2643. QStack<QLayout*> *layoutStack);
  2644. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2645. QStack<QLayout*> *layoutStack);
  2646. void addSqlQueryViewToLayout(QDomElement element,
  2647. QStack<QWidget*> *widgetStack,
  2648. QStack<QLayout*> *layoutStack);
  2649. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2650. QStack<QLayout*> *layoutStack);
  2651. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2652. QStack<QLayout*> *layoutStack);
  2653. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2654. QStack<QLayout*> *layoutStack);
  2655. /*:196*//*225:*/
  2656. #line 5003 "./typica.w"
  2657. QScriptValue constructQTabBar(QScriptContext*context,QScriptEngine*engine);
  2658. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine);
  2659. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*engine);
  2660. /*:225*//*266:*/
  2661. #line 6289 "./typica.w"
  2662. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2663. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2664. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2665. QScriptEngine*engine);
  2666. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2667. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2668. QScriptEngine*engine);
  2669. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2670. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2671. /*:266*//*269:*/
  2672. #line 6334 "./typica.w"
  2673. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2674. /*:269*//*270:*/
  2675. #line 6342 "./typica.w"
  2676. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2677. /*:270*//*274:*/
  2678. #line 6489 "./typica.w"
  2679. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2680. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2681. QScriptEngine*engine);
  2682. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2683. QScriptEngine*engine);
  2684. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2685. QScriptEngine*engine);
  2686. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2687. QScriptEngine*engine);
  2688. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2689. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2690. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2691. QScriptEngine*engine);
  2692. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2693. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2694. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2695. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2696. /*:274*//*284:*/
  2697. #line 6705 "./typica.w"
  2698. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2699. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2700. QScriptValue QComboBox_currentData(QScriptContext*context,
  2701. QScriptEngine*engine);
  2702. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2703. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2704. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2705. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2706. /*:284*//*296:*/
  2707. #line 379 "./units.w"
  2708. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2709. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2710. QScriptEngine*engine);
  2711. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2712. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2713. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2714. /*:296*//*300:*/
  2715. #line 443 "./units.w"
  2716. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2717. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2718. /*:300*//*309:*/
  2719. #line 133 "./measurement.w"
  2720. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2721. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2722. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2723. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2724. /*:309*//*329:*/
  2725. #line 7340 "./typica.w"
  2726. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2727. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2728. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2729. /*:329*//*338:*/
  2730. #line 7545 "./typica.w"
  2731. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2732. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2733. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2734. /*:338*//*343:*/
  2735. #line 7646 "./typica.w"
  2736. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2737. /*:343*//*349:*/
  2738. #line 7828 "./typica.w"
  2739. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2740. QScriptEngine*engine);
  2741. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2742. /*:349*//*354:*/
  2743. #line 7968 "./typica.w"
  2744. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2745. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2746. /*:354*//*364:*/
  2747. #line 8173 "./typica.w"
  2748. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2749. QScriptEngine*engine);
  2750. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2751. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2752. QScriptEngine*engine);
  2753. /*:364*//*372:*/
  2754. #line 8332 "./typica.w"
  2755. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2756. QScriptEngine*engine);
  2757. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2758. QScriptEngine*engine);
  2759. /*:372*//*377:*/
  2760. #line 8455 "./typica.w"
  2761. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2762. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2763. /*:377*//*382:*/
  2764. #line 8553 "./typica.w"
  2765. QScriptValue constructZeroEmitter(QScriptContext*context,
  2766. QScriptEngine*engine);
  2767. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2768. /*:382*//*387:*/
  2769. #line 8632 "./typica.w"
  2770. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2771. QScriptEngine*engine);
  2772. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2773. /*:387*//*404:*/
  2774. #line 9096 "./typica.w"
  2775. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2776. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2777. /*:404*//*427:*/
  2778. #line 9723 "./typica.w"
  2779. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2780. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2781. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2782. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2783. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2784. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2785. QScriptEngine*engine);
  2786. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2787. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2788. QScriptEngine*engnie);
  2789. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2790. QScriptEngine*engine);
  2791. /*:427*//*465:*/
  2792. #line 10680 "./typica.w"
  2793. QScriptValue constructAnnotationButton(QScriptContext*context,
  2794. QScriptEngine*engine);
  2795. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2796. /*:465*//*473:*/
  2797. #line 10820 "./typica.w"
  2798. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2799. QScriptEngine*engine);
  2800. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2801. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2802. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2803. /*:473*//*494:*/
  2804. #line 11246 "./typica.w"
  2805. QScriptValue constructTimerDisplay(QScriptContext*context,
  2806. QScriptEngine*engine);
  2807. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2808. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2809. /*:494*//*522:*/
  2810. #line 11771 "./typica.w"
  2811. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2812. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2813. QScriptEngine*engine);
  2814. /*:522*//*535:*/
  2815. #line 12054 "./typica.w"
  2816. QScriptValue constructLogEditWindow(QScriptContext*context,
  2817. QScriptEngine*engine);
  2818. /*:535*//*554:*/
  2819. #line 12581 "./typica.w"
  2820. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2821. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2822. /*:554*//*573:*/
  2823. #line 204 "./webview.w"
  2824. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2825. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2826. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2827. QStack<QLayout*> *layoutStack);
  2828. /*:573*//*576:*/
  2829. #line 234 "./webview.w"
  2830. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2831. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2832. /*:576*//*580:*/
  2833. #line 292 "./webview.w"
  2834. QScriptValue constructWebElement(QScriptContext*context,
  2835. QScriptEngine*engine);
  2836. /*:580*//*592:*/
  2837. #line 67 "./printerselector.w"
  2838. QScriptValue constructPrinterSelector(QScriptContext*context,
  2839. QScriptEngine*engine);
  2840. void addPrinterSelectorToLayout(QDomElement element,
  2841. QStack<QWidget*> *widgetStack,
  2842. QStack<QLayout*> *layoutStack);
  2843. /*:592*//*658:*/
  2844. #line 13935 "./typica.w"
  2845. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2846. QScriptValue constructSqlQueryView(QScriptContext*context,
  2847. QScriptEngine*engine);
  2848. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2849. QScriptEngine*engine);
  2850. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2851. QScriptEngine*engine);
  2852. /*:658*//*668:*/
  2853. #line 14174 "./typica.w"
  2854. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2855. QStack<QLayout*> *layoutStack);
  2856. /*:668*//*684:*/
  2857. #line 14459 "./typica.w"
  2858. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2859. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2860. /*:684*//*712:*/
  2861. #line 482 "./daterangeselector.w"
  2862. void addDateRangeToLayout(QDomElement element,
  2863. QStack<QWidget*> *widgetStack,
  2864. QStack<QLayout*> *layoutStack);
  2865. /*:712*//*721:*/
  2866. #line 14658 "./typica.w"
  2867. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2868. QStack<QLayout*> *layoutStack);
  2869. /*:721*//*742:*/
  2870. #line 15242 "./typica.w"
  2871. void addScaleControlToLayout(QDomElement element,
  2872. QStack<QWidget*> *widgetStack,
  2873. QStack<QLayout*> *layoutStack);
  2874. void addIntensityControlToLayout(QDomElement element,
  2875. QStack<QWidget*> *widgetStack,
  2876. QStack<QLayout*> *layoutStack);
  2877. /*:742*//*768:*/
  2878. #line 15828 "./typica.w"
  2879. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2880. QScriptEngine*engine);
  2881. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2882. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2883. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2884. QScriptEngine*engine);
  2885. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2886. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2887. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2888. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2889. /*:768*//*774:*/
  2890. #line 15970 "./typica.w"
  2891. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2892. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2893. /*:774*//*790:*/
  2894. #line 16268 "./typica.w"
  2895. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2896. QScriptEngine*engine);
  2897. /*:790*//*861:*/
  2898. #line 42 "./settings.w"
  2899. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2900. /*:861*//*885:*/
  2901. #line 18911 "./typica.w"
  2902. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2903. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2904. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2905. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2906. /*:885*//*903:*/
  2907. #line 698 "./modbus.w"
  2908. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  2909. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  2910. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  2911. /*:903*//*917:*/
  2912. #line 345 "./unsupportedserial.w"
  2913. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2914. /*:917*//*923:*/
  2915. #line 425 "./unsupportedserial.w"
  2916. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2917. /*:923*//*929:*/
  2918. #line 617 "./unsupportedserial.w"
  2919. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2920. /*:929*//*933:*/
  2921. #line 651 "./unsupportedserial.w"
  2922. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2923. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2924. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2925. /*:933*//*957:*/
  2926. #line 457 "./phidgets.w"
  2927. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2928. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2929. /*:957*//*989:*/
  2930. #line 138 "./rate.w"
  2931. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2932. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2933. /*:989*//*1014:*/
  2934. #line 597 "./dataqsdk.w"
  2935. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2936. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2937. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2938. /*:1014*//*1041:*/
  2939. #line 67 "./scales.w"
  2940. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2941. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2942. /*:1041*//*1049:*/
  2943. #line 259 "./scales.w"
  2944. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2945. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2946. /*:1049*//*1052:*/
  2947. #line 284 "./scales.w"
  2948. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2949. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2950. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2951. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2952. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2953. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2954. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2955. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2956. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2957. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2958. /*:1052*//*1077:*/
  2959. #line 265 "./valueannotation.w"
  2960. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2961. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2962. /*:1077*//*1088:*/
  2963. #line 194 "./thresholdannotation.w"
  2964. QScriptValue constructAnnotator(QScriptContext*context,
  2965. QScriptEngine*engine);
  2966. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  2967. /*:1088*/
  2968. #line 527 "./typica.w"
  2969. /*638:*/
  2970. #line 13579 "./typica.w"
  2971. void messageFileOutput(QtMsgType type,const char*msg);
  2972. /*:638*/
  2973. #line 528 "./typica.w"
  2974. /*4:*/
  2975. #line 537 "./typica.w"
  2976. /*782:*/
  2977. #line 16091 "./typica.w"
  2978. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2979. const QString&driver,QObject*parent):
  2980. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2981. {
  2982. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2983. }
  2984. void NodeInserter::onTriggered()
  2985. {
  2986. emit triggered(defaultNodeName,driverString);
  2987. }
  2988. /*:782*/
  2989. #line 538 "./typica.w"
  2990. /*305:*/
  2991. #line 40 "./measurement.w"
  2992. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2993. {
  2994. insert("measurement",temperature);
  2995. insert("time",time);
  2996. insert("unit",sc);
  2997. }
  2998. Measurement::Measurement(double temperature)
  2999. {
  3000. insert("measurement",temperature);
  3001. insert("time",QTime::currentTime());
  3002. insert("unit",Units::Fahrenheit);
  3003. }
  3004. void Measurement::setTemperature(double temperature)
  3005. {
  3006. insert("measurement",temperature);
  3007. }
  3008. void Measurement::setTime(QTime time)
  3009. {
  3010. insert("time",time);
  3011. }
  3012. void Measurement::setUnit(Units::Unit scale)
  3013. {
  3014. insert("unit",scale);
  3015. }
  3016. double Measurement::temperature()const
  3017. {
  3018. return value("measurement").toDouble();
  3019. }
  3020. QTime Measurement::time()const
  3021. {
  3022. return value("time").toTime();
  3023. }
  3024. Units::Unit Measurement::scale()const
  3025. {
  3026. return(Units::Unit)(value("unit").toInt());
  3027. }
  3028. /*:305*//*306:*/
  3029. #line 88 "./measurement.w"
  3030. Measurement Measurement::toFahrenheit()
  3031. {
  3032. return Measurement(Units::convertTemperature(this->temperature(),
  3033. this->scale(),Units::Fahrenheit),
  3034. this->time(),Units::Fahrenheit);
  3035. }
  3036. Measurement Measurement::toCelsius()
  3037. {
  3038. return Measurement(Units::convertTemperature(this->temperature(),
  3039. this->scale(),Units::Celsius),
  3040. this->time(),Units::Celsius);
  3041. }
  3042. Measurement Measurement::toKelvin()
  3043. {
  3044. return Measurement(Units::convertTemperature(this->temperature(),
  3045. this->scale(),Units::Kelvin),
  3046. this->time(),Units::Kelvin);
  3047. }
  3048. Measurement Measurement::toRankine()
  3049. {
  3050. return Measurement(Units::convertTemperature(this->temperature(),
  3051. this->scale(),Units::Rankine),
  3052. this->time(),Units::Rankine);
  3053. }
  3054. /*:306*/
  3055. #line 539 "./typica.w"
  3056. /*319:*/
  3057. #line 6945 "./typica.w"
  3058. void DAQImplementation::measure()
  3059. {
  3060. int samplesRead= 0;
  3061. double buffer[channels];
  3062. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3063. (unsigned long)(0),buffer,(unsigned long)(channels),
  3064. &samplesRead,(signed long)(0));
  3065. if(error)
  3066. {
  3067. ready= false;
  3068. }
  3069. else
  3070. {
  3071. if(samplesRead)
  3072. {
  3073. QTime time= QTime::currentTime();
  3074. for(int i= 0;i<samplesRead;i++)
  3075. {
  3076. for(int j= 0;j<channels;j++)
  3077. {
  3078. double measuredValue= buffer[j+(i*channels)];
  3079. Measurement measure(measuredValue,time,
  3080. unitMap[j]);
  3081. channelMap[j]->input(measure);
  3082. }
  3083. }
  3084. }
  3085. }
  3086. }
  3087. /*:319*//*320:*/
  3088. #line 6988 "./typica.w"
  3089. void DAQImplementation::run()
  3090. {
  3091. setPriority(QThread::TimeCriticalPriority);
  3092. while(ready)
  3093. {
  3094. measure();
  3095. }
  3096. }
  3097. /*:320*//*321:*/
  3098. #line 7004 "./typica.w"
  3099. void DAQ::threadFinished()
  3100. {
  3101. if(imp->error)
  3102. {
  3103. /*322:*/
  3104. #line 7055 "./typica.w"
  3105. imp->ready= false;
  3106. QMessageBox warning;
  3107. warning.setStandardButtons(QMessageBox::Cancel);
  3108. warning.setIcon(QMessageBox::Warning);
  3109. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3110. unsigned long bytes= imp->errorInfo(NULL,0);
  3111. char string[bytes];
  3112. imp->errorInfo(string,bytes);
  3113. warning.setInformativeText(QString(string));
  3114. warning.setWindowTitle(QString(PROGRAM_NAME));
  3115. warning.exec();
  3116. /*:322*/
  3117. #line 7009 "./typica.w"
  3118. }
  3119. }
  3120. /*:321*//*323:*/
  3121. #line 7080 "./typica.w"
  3122. void DAQ::start()
  3123. {
  3124. if(imp->ready)
  3125. {
  3126. imp->error= imp->startTask(imp->handle);
  3127. if(imp->error)
  3128. {
  3129. /*322:*/
  3130. #line 7055 "./typica.w"
  3131. imp->ready= false;
  3132. QMessageBox warning;
  3133. warning.setStandardButtons(QMessageBox::Cancel);
  3134. warning.setIcon(QMessageBox::Warning);
  3135. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3136. unsigned long bytes= imp->errorInfo(NULL,0);
  3137. char string[bytes];
  3138. imp->errorInfo(string,bytes);
  3139. warning.setInformativeText(QString(string));
  3140. warning.setWindowTitle(QString(PROGRAM_NAME));
  3141. warning.exec();
  3142. /*:322*/
  3143. #line 7088 "./typica.w"
  3144. }
  3145. else
  3146. {
  3147. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3148. imp->start();
  3149. }
  3150. }
  3151. }
  3152. void DAQ::stop()
  3153. {
  3154. if(imp->useBase)
  3155. {
  3156. imp->ready= false;
  3157. imp->wait(ULONG_MAX);
  3158. imp->stopTask(imp->handle);
  3159. }
  3160. else
  3161. {
  3162. imp->ready= false;
  3163. imp->error= imp->stopTask(imp->handle);
  3164. if(imp->error)
  3165. {
  3166. /*322:*/
  3167. #line 7055 "./typica.w"
  3168. imp->ready= false;
  3169. QMessageBox warning;
  3170. warning.setStandardButtons(QMessageBox::Cancel);
  3171. warning.setIcon(QMessageBox::Warning);
  3172. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3173. unsigned long bytes= imp->errorInfo(NULL,0);
  3174. char string[bytes];
  3175. imp->errorInfo(string,bytes);
  3176. warning.setInformativeText(QString(string));
  3177. warning.setWindowTitle(QString(PROGRAM_NAME));
  3178. warning.exec();
  3179. /*:322*/
  3180. #line 7112 "./typica.w"
  3181. }
  3182. imp->error= imp->clearTask(imp->handle);
  3183. if(imp->error)
  3184. {
  3185. /*322:*/
  3186. #line 7055 "./typica.w"
  3187. imp->ready= false;
  3188. QMessageBox warning;
  3189. warning.setStandardButtons(QMessageBox::Cancel);
  3190. warning.setIcon(QMessageBox::Warning);
  3191. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3192. unsigned long bytes= imp->errorInfo(NULL,0);
  3193. char string[bytes];
  3194. imp->errorInfo(string,bytes);
  3195. warning.setInformativeText(QString(string));
  3196. warning.setWindowTitle(QString(PROGRAM_NAME));
  3197. warning.exec();
  3198. /*:322*/
  3199. #line 7117 "./typica.w"
  3200. }
  3201. }
  3202. }
  3203. /*:323*//*324:*/
  3204. #line 7127 "./typica.w"
  3205. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3206. {
  3207. imp->device= device;
  3208. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3209. if(imp->error)
  3210. {
  3211. /*322:*/
  3212. #line 7055 "./typica.w"
  3213. imp->ready= false;
  3214. QMessageBox warning;
  3215. warning.setStandardButtons(QMessageBox::Cancel);
  3216. warning.setIcon(QMessageBox::Warning);
  3217. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3218. unsigned long bytes= imp->errorInfo(NULL,0);
  3219. char string[bytes];
  3220. imp->errorInfo(string,bytes);
  3221. warning.setInformativeText(QString(string));
  3222. warning.setWindowTitle(QString(PROGRAM_NAME));
  3223. warning.exec();
  3224. /*:322*/
  3225. #line 7134 "./typica.w"
  3226. }
  3227. else
  3228. {
  3229. imp->ready= true;
  3230. }
  3231. }
  3232. /*:324*//*325:*/
  3233. #line 7148 "./typica.w"
  3234. Channel*DAQ::newChannel(int units,int thermocouple)
  3235. {
  3236. Channel*retval= new Channel();
  3237. imp->channelMap[imp->channels]= retval;
  3238. imp->unitMap[imp->channels]= (Units::Unit)units;
  3239. imp->channels++;
  3240. if(imp->ready)
  3241. {
  3242. if(imp->useBase)
  3243. {
  3244. imp->error= imp->createChannel(imp->handle,
  3245. QString("%1/ai%2").arg(imp->device).
  3246. arg(imp->channels-1).
  3247. toAscii().data(),
  3248. "",(double)(-1.0),(double)(100.0),
  3249. (signed long)(units),
  3250. (signed long)(thermocouple),
  3251. (signed long)(10200),(double)(0),
  3252. "");
  3253. }
  3254. else
  3255. {
  3256. imp->error= imp->createChannel(imp->handle,
  3257. QString("%1/ai%2").arg(imp->device).
  3258. arg(imp->channels-1).
  3259. toAscii().data(),
  3260. "",(double)(50.0),(double)(500.0),
  3261. (signed long)(units),
  3262. (signed long)(thermocouple),
  3263. (signed long)(10200),(double)(0),
  3264. "");
  3265. }
  3266. if(imp->error)
  3267. {
  3268. /*322:*/
  3269. #line 7055 "./typica.w"
  3270. imp->ready= false;
  3271. QMessageBox warning;
  3272. warning.setStandardButtons(QMessageBox::Cancel);
  3273. warning.setIcon(QMessageBox::Warning);
  3274. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3275. unsigned long bytes= imp->errorInfo(NULL,0);
  3276. char string[bytes];
  3277. imp->errorInfo(string,bytes);
  3278. warning.setInformativeText(QString(string));
  3279. warning.setWindowTitle(QString(PROGRAM_NAME));
  3280. warning.exec();
  3281. /*:322*/
  3282. #line 7183 "./typica.w"
  3283. }
  3284. }
  3285. return retval;
  3286. }
  3287. /*:325*//*326:*/
  3288. #line 7197 "./typica.w"
  3289. void DAQ::setClockRate(double Hz)
  3290. {
  3291. if(imp->ready)
  3292. {
  3293. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3294. (signed long)(10280),(signed long)(10123),
  3295. (unsigned long long)(1));
  3296. if(imp->error)
  3297. {
  3298. /*322:*/
  3299. #line 7055 "./typica.w"
  3300. imp->ready= false;
  3301. QMessageBox warning;
  3302. warning.setStandardButtons(QMessageBox::Cancel);
  3303. warning.setIcon(QMessageBox::Warning);
  3304. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3305. unsigned long bytes= imp->errorInfo(NULL,0);
  3306. char string[bytes];
  3307. imp->errorInfo(string,bytes);
  3308. warning.setInformativeText(QString(string));
  3309. warning.setWindowTitle(QString(PROGRAM_NAME));
  3310. warning.exec();
  3311. /*:322*/
  3312. #line 7207 "./typica.w"
  3313. }
  3314. }
  3315. }
  3316. /*:326*//*327:*/
  3317. #line 7217 "./typica.w"
  3318. DAQ::~DAQ()
  3319. {
  3320. if(imp->useBase)
  3321. {
  3322. imp->resetDevice(imp->device.toAscii().data());
  3323. imp->clearTask(imp->handle);
  3324. }
  3325. else
  3326. {
  3327. if(imp->ready)
  3328. {
  3329. imp->ready= false;
  3330. imp->wait(ULONG_MAX);
  3331. imp->stopTask(imp->handle);
  3332. imp->resetDevice(imp->device.toAscii().data());
  3333. imp->clearTask(imp->handle);
  3334. }
  3335. }
  3336. delete imp;
  3337. }
  3338. /*:327*//*328:*/
  3339. #line 7248 "./typica.w"
  3340. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3341. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3342. unitMap(4)
  3343. {
  3344. if(driverinfo=="nidaqmxbase")
  3345. {
  3346. useBase= true;
  3347. }
  3348. else
  3349. {
  3350. useBase= false;
  3351. }
  3352. if(useBase)
  3353. {
  3354. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3355. if(!driver.load())
  3356. {
  3357. driver.setFileName("nidaqmxbase");
  3358. if(!driver.load())
  3359. {
  3360. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3361. tr("Failed to find nidaqmxbase. Please install it."));
  3362. QApplication::quit();
  3363. }
  3364. }
  3365. }
  3366. else
  3367. {
  3368. driver.setFileName("nicaiu");
  3369. if(!driver.load())
  3370. {
  3371. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3372. tr("Failed to find nidaqmx. Please install it."));
  3373. QApplication::quit();
  3374. }
  3375. }
  3376. if(useBase)
  3377. {
  3378. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3379. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3380. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3381. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3382. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3383. ==0||
  3384. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3385. 0||
  3386. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3387. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3388. 0||
  3389. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3390. {
  3391. waitForMeasurement= NULL;
  3392. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3393. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3394. QApplication::quit();
  3395. }
  3396. }
  3397. else
  3398. {
  3399. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3400. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3401. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3402. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3403. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3404. ==0||
  3405. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3406. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3407. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3408. 0||
  3409. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3410. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3411. {
  3412. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3413. tr("Failed to link a required symbol in NI-DAQmx."));
  3414. QApplication::quit();
  3415. }
  3416. }
  3417. }
  3418. DAQImplementation::~DAQImplementation()
  3419. {
  3420. driver.unload();
  3421. }
  3422. /*:328*/
  3423. #line 540 "./typica.w"
  3424. /*1003:*/
  3425. #line 197 "./dataqsdk.w"
  3426. void DataqSdkDeviceImplementation::measure()
  3427. {
  3428. unsigned count= channels*40;
  3429. di_status_read(buffer,count);
  3430. QTime time= QTime::currentTime();
  3431. for(unsigned int i= 0;i<count;i++)
  3432. {
  3433. buffer[i]= buffer[i]&0xFFFC;
  3434. }
  3435. QList<int> countList;
  3436. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3437. {
  3438. QList<double> channelBuffer;
  3439. for(unsigned int j= 0;j<40;j++)
  3440. {
  3441. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3442. if(i==0)
  3443. {
  3444. countList<<buffer[i+(channels*j)];
  3445. }
  3446. }
  3447. double value= 0.0;
  3448. for(unsigned int j= 0;j<40;j++)
  3449. {
  3450. value+= channelBuffer[j];
  3451. }
  3452. value/= 40.0;
  3453. if(i==0)
  3454. {
  3455. QList<double> smoothingList;
  3456. smoothingList<<value;
  3457. QList<int> smoothingKeys= smoother.uniqueKeys();
  3458. for(int j= 0;j<smoothingKeys.size();j++)
  3459. {
  3460. if(countList.contains(smoothingKeys[j]))
  3461. {
  3462. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3463. for(int k= 0;k<keyValues.size();k++)
  3464. {
  3465. smoothingList<<keyValues[k];
  3466. }
  3467. }
  3468. else
  3469. {
  3470. smoother.remove(smoothingKeys[j]);
  3471. }
  3472. }
  3473. qSort(countList);
  3474. int lastCount= 0;
  3475. for(int j= 0;j<countList.size();j++)
  3476. {
  3477. if(j==0||countList[j]!=lastCount)
  3478. {
  3479. smoother.insert(countList[j],value);
  3480. lastCount= countList[j];
  3481. }
  3482. }
  3483. value= 0.0;
  3484. for(int j= 0;j<smoothingList.size();j++)
  3485. {
  3486. value+= smoothingList[j];
  3487. }
  3488. value/= smoothingList.size();
  3489. }
  3490. Measurement measure(value,time,unitMap[i]);
  3491. channelMap[i]->input(measure);
  3492. }
  3493. }
  3494. /*:1003*//*1004:*/
  3495. #line 290 "./dataqsdk.w"
  3496. void DataqSdkDeviceImplementation::run()
  3497. {
  3498. if(!ready)
  3499. {
  3500. error= 9;
  3501. return;
  3502. }
  3503. driver= new QLibrary(device);
  3504. if(!driver->load())
  3505. {
  3506. error= 1;
  3507. qDebug()<<"Failed to load driver: "<<device;
  3508. return;
  3509. }
  3510. di_open= (FPDIOPEN)driver->resolve("di_open");
  3511. di_close= (FPDICLOSE)driver->resolve("di_close");
  3512. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3513. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3514. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3515. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3516. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3517. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3518. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3519. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3520. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3521. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3522. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3523. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3524. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3525. (!di_burst_rate)||(!di_stop_scan))
  3526. {
  3527. error= 2;
  3528. return;
  3529. }
  3530. error= di_open(deviceNumber);
  3531. if(error)
  3532. {
  3533. di_close();
  3534. error= di_open(deviceNumber);
  3535. if(error)
  3536. {
  3537. error= 3;
  3538. di_close();
  3539. return;
  3540. }
  3541. }
  3542. isOpen= true;
  3543. di_maximum_rate(240.0);
  3544. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3545. &burstDivisor);
  3546. buffer= new qint16[(int)sampleRate];
  3547. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3548. for(unsigned short i= 0;i<channels;i++)
  3549. {
  3550. inlist[i].chan= i;
  3551. inlist[i].gain= 0;
  3552. inlist[i].ave= 1;
  3553. inlist[i].counter= (oversample-1);
  3554. }
  3555. error= di_list_length(channels,0);
  3556. if(error)
  3557. {
  3558. error= 4;
  3559. return;
  3560. }
  3561. error= di_inlist(inlist);
  3562. if(error)
  3563. {
  3564. error= 5;
  3565. return;
  3566. }
  3567. input_buffer= di_buffer_alloc(0,4096);
  3568. if(input_buffer==NULL)
  3569. {
  3570. error= 6;
  3571. return;
  3572. }
  3573. error= di_start_scan();
  3574. if(error)
  3575. {
  3576. error= 7;
  3577. return;
  3578. }
  3579. while(ready)
  3580. {
  3581. measure();
  3582. }
  3583. }
  3584. /*:1004*//*1005:*/
  3585. #line 386 "./dataqsdk.w"
  3586. void DataqSdkDevice::threadFinished()
  3587. {
  3588. if(imp->error)
  3589. {
  3590. /*1006:*/
  3591. #line 400 "./dataqsdk.w"
  3592. imp->ready= false;
  3593. QMessageBox warning;
  3594. warning.setStandardButtons(QMessageBox::Cancel);
  3595. warning.setIcon(QMessageBox::Warning);
  3596. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3597. warning.setInformativeText(tr("An error occurred"));
  3598. warning.setWindowTitle(QString(PROGRAM_NAME));
  3599. warning.exec();
  3600. /*:1006*/
  3601. #line 391 "./dataqsdk.w"
  3602. }
  3603. }
  3604. /*:1005*//*1007:*/
  3605. #line 417 "./dataqsdk.w"
  3606. void DataqSdkDevice::start()
  3607. {
  3608. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3609. imp->start();
  3610. }
  3611. /*:1007*//*1008:*/
  3612. #line 428 "./dataqsdk.w"
  3613. QStringList DataqSdkDevice::detectHardware()
  3614. {
  3615. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3616. QSettings::NativeFormat);
  3617. QStringList keys= deviceLookup.childKeys();
  3618. QStringList devices;
  3619. for(int i= 0;i<keys.size();i++)
  3620. {
  3621. QString value= deviceLookup.value(keys.at(i)).toString();
  3622. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3623. {
  3624. devices.append(value.split("\\").at(2));
  3625. }
  3626. }
  3627. QStringList portList;
  3628. foreach(QString device,devices)
  3629. {
  3630. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3631. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3632. portList.append(deviceEntry.value("FriendlyName").toString());
  3633. }
  3634. return portList;
  3635. }
  3636. QStringList DataqSdkDevice::detectPorts()
  3637. {
  3638. QStringList friendlyNames= detectHardware();
  3639. QStringList portList;
  3640. foreach(QString name,friendlyNames)
  3641. {
  3642. name.remove(0,name.indexOf("COM"));
  3643. name.chop(1);
  3644. portList.append(name);
  3645. }
  3646. return portList;
  3647. }
  3648. /*:1008*//*1009:*/
  3649. #line 473 "./dataqsdk.w"
  3650. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3651. {
  3652. bool usesAuto= false;
  3653. int autoIndex= device.toInt(&usesAuto);
  3654. QString finalizedPort;
  3655. if(usesAuto)
  3656. {
  3657. QStringList portList= detectPorts();
  3658. if(autoIndex> 0&&autoIndex<=portList.size())
  3659. {
  3660. finalizedPort= portList.at(autoIndex-1);
  3661. }
  3662. else
  3663. {
  3664. imp->error= 8;
  3665. qDebug()<<"Failed to detect port.";
  3666. }
  3667. }
  3668. else
  3669. {
  3670. finalizedPort= device;
  3671. }
  3672. int rstart= finalizedPort.indexOf("COM");
  3673. finalizedPort.remove(0,rstart+3);
  3674. bool chopFinished= false;
  3675. int finalizedPortNumber= 0;
  3676. while(finalizedPort.size()> 0&&!chopFinished)
  3677. {
  3678. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3679. if(!chopFinished)
  3680. {
  3681. finalizedPort.chop(1);
  3682. }
  3683. }
  3684. if(finalizedPortNumber<10)
  3685. {
  3686. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3687. }
  3688. else
  3689. {
  3690. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3691. }
  3692. imp->deviceNumber= 0x12C02D00;
  3693. imp->deviceNumber+= finalizedPortNumber;
  3694. imp->ready= true;
  3695. }
  3696. /*:1009*//*1010:*/
  3697. #line 523 "./dataqsdk.w"
  3698. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3699. {
  3700. Channel*retval= NULL;
  3701. if(imp->ready)
  3702. {
  3703. retval= new Channel();
  3704. imp->channelMap[imp->channels]= retval;
  3705. imp->unitMap[imp->channels]= scale;
  3706. imp->channels++;
  3707. }
  3708. return retval;
  3709. }
  3710. /*:1010*//*1011:*/
  3711. #line 547 "./dataqsdk.w"
  3712. void DataqSdkDevice::setClockRate(double Hz)
  3713. {
  3714. imp->sampleRate= Hz;
  3715. }
  3716. /*:1011*//*1012:*/
  3717. #line 557 "./dataqsdk.w"
  3718. DataqSdkDevice::~DataqSdkDevice()
  3719. {
  3720. if(imp->ready)
  3721. {
  3722. imp->ready= false;
  3723. }
  3724. imp->wait(ULONG_MAX);
  3725. delete imp;
  3726. }
  3727. /*:1012*//*1013:*/
  3728. #line 575 "./dataqsdk.w"
  3729. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3730. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3731. {
  3732. }
  3733. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3734. {
  3735. if(isOpen)
  3736. {
  3737. di_stop_scan();
  3738. di_close();
  3739. }
  3740. if(driver->isLoaded())
  3741. {
  3742. driver->unload();
  3743. }
  3744. }
  3745. /*:1013*/
  3746. #line 541 "./typica.w"
  3747. /*335:*/
  3748. #line 7457 "./typica.w"
  3749. void FakeDAQImplementation::measure()
  3750. {
  3751. msleep((int)(1000/clockRate));
  3752. QTime time= QTime::currentTime();
  3753. for(int i= 0;i<channels;i++)
  3754. {
  3755. Measurement measure(qrand()%500,time);
  3756. channelMap[i]->input(measure);
  3757. }
  3758. }
  3759. /*:335*//*336:*/
  3760. #line 7471 "./typica.w"
  3761. void FakeDAQImplementation::run()
  3762. {
  3763. setPriority(QThread::TimeCriticalPriority);
  3764. while(ready)
  3765. {
  3766. measure();
  3767. }
  3768. }
  3769. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3770. channels(0),ready(false),clockRate(1)
  3771. {
  3772. }
  3773. FakeDAQImplementation::~FakeDAQImplementation()
  3774. {
  3775. }
  3776. /*:336*//*337:*/
  3777. #line 7496 "./typica.w"
  3778. void FakeDAQ::start()
  3779. {
  3780. if(imp->ready)
  3781. {
  3782. imp->start();
  3783. }
  3784. }
  3785. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3786. {
  3787. imp->ready= true;
  3788. }
  3789. Channel*FakeDAQ::newChannel(int,int)
  3790. {
  3791. Channel*retval;
  3792. if(imp->ready)
  3793. {
  3794. retval= new Channel();
  3795. imp->channelMap[imp->channels]= retval;
  3796. imp->channels++;
  3797. }
  3798. else
  3799. {
  3800. return NULL;
  3801. }
  3802. return retval;
  3803. }
  3804. void FakeDAQ::setClockRate(double Hz)
  3805. {
  3806. if(imp->ready)
  3807. {
  3808. imp->clockRate= Hz;
  3809. }
  3810. }
  3811. FakeDAQ::~FakeDAQ()
  3812. {
  3813. imp->ready= false;
  3814. imp->wait(ULONG_MAX);
  3815. delete imp;
  3816. }
  3817. /*:337*/
  3818. #line 542 "./typica.w"
  3819. /*342:*/
  3820. #line 7627 "./typica.w"
  3821. Channel::Channel():QObject(NULL)
  3822. {
  3823. }
  3824. Channel::~Channel()
  3825. {
  3826. }
  3827. void Channel::input(Measurement measurement)
  3828. {
  3829. emit newData(measurement);
  3830. }
  3831. /*:342*/
  3832. #line 543 "./typica.w"
  3833. /*358:*/
  3834. #line 8032 "./typica.w"
  3835. void TemperatureDisplay::setRelativeMode(bool relative)
  3836. {
  3837. r= relative;
  3838. }
  3839. /*:358*//*359:*/
  3840. #line 8049 "./typica.w"
  3841. void TemperatureDisplay::setValue(Measurement temperature)
  3842. {
  3843. QString number;
  3844. switch(unit)
  3845. {
  3846. case Units::Fahrenheit:
  3847. display(QString("%1'F").
  3848. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3849. 2)));
  3850. break;
  3851. case Units::Celsius:
  3852. if(!r){
  3853. display(QString("%1'C").
  3854. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3855. 2)));
  3856. }else{
  3857. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3858. display(QString("%1'C").arg(number));
  3859. }
  3860. break;
  3861. case Units::Kelvin:
  3862. if(!r){
  3863. display(QString("%1").
  3864. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3865. 2)));
  3866. }else{
  3867. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3868. display(QString("%1").arg(number));
  3869. }
  3870. break;
  3871. case Units::Rankine:
  3872. display(QString("%1'r").
  3873. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3874. 2)));
  3875. break;
  3876. case Units::Unitless:
  3877. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3878. break;
  3879. default:
  3880. switch(temperature.scale())
  3881. {
  3882. case Units::Fahrenheit:
  3883. display(QString("%1'F").
  3884. arg(number.setNum(temperature.temperature(),'f',2)));
  3885. break;
  3886. case Units::Celsius:
  3887. display(QString("%1'C").
  3888. arg(number.setNum(temperature.temperature(),'f',2)));
  3889. break;
  3890. case Units::Kelvin:
  3891. display(QString("%1").
  3892. arg(number.setNum(temperature.temperature(),'f',2)));
  3893. break;
  3894. case Units::Rankine:
  3895. display(QString("%1'r").
  3896. arg(number.setNum(temperature.temperature(),'f',2)));
  3897. break;
  3898. case Units::Unitless:
  3899. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3900. break;
  3901. default:
  3902. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  3903. break;
  3904. }
  3905. break;
  3906. }
  3907. }
  3908. /*:359*//*360:*/
  3909. #line 8128 "./typica.w"
  3910. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3911. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3912. {
  3913. setSegmentStyle(Filled);
  3914. display("---.--'F");
  3915. }
  3916. /*:360*//*361:*/
  3917. #line 8144 "./typica.w"
  3918. void TemperatureDisplay::invalidate()
  3919. {
  3920. display("---.--'F");
  3921. }
  3922. /*:361*//*362:*/
  3923. #line 8156 "./typica.w"
  3924. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3925. {
  3926. unit= scale;
  3927. }
  3928. /*:362*//*363:*/
  3929. #line 8164 "./typica.w"
  3930. TemperatureDisplay::~TemperatureDisplay()
  3931. {
  3932. }
  3933. /*:363*/
  3934. #line 544 "./typica.w"
  3935. /*369:*/
  3936. #line 8264 "./typica.w"
  3937. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3938. {
  3939. if(measure.time()<epoch)
  3940. {
  3941. if(hasPrevious)
  3942. {
  3943. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3944. epoch.msec());
  3945. QTime jitComp(epoch.hour(),measure.time().minute(),
  3946. measure.time().second(),measure.time().msec());
  3947. int relTime= jitBase.msecsTo(jitComp);
  3948. /*370:*/
  3949. #line 8298 "./typica.w"
  3950. QTime newTime(0,0,0,0);
  3951. newTime= newTime.addMSecs(relTime);
  3952. if(newTime.hour()> 0)
  3953. {
  3954. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3955. }
  3956. Measurement rel= measure;
  3957. rel.setTime(newTime);
  3958. emit measurement(rel);
  3959. /*:370*/
  3960. #line 8276 "./typica.w"
  3961. }
  3962. else
  3963. {
  3964. Measurement rel= measure;
  3965. rel.setTime(QTime(0,0,0,0));
  3966. emit measurement(rel);
  3967. }
  3968. }
  3969. else
  3970. {
  3971. int relTime= epoch.msecsTo(measure.time());
  3972. /*370:*/
  3973. #line 8298 "./typica.w"
  3974. QTime newTime(0,0,0,0);
  3975. newTime= newTime.addMSecs(relTime);
  3976. if(newTime.hour()> 0)
  3977. {
  3978. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3979. }
  3980. Measurement rel= measure;
  3981. rel.setTime(newTime);
  3982. emit measurement(rel);
  3983. /*:370*/
  3984. #line 8288 "./typica.w"
  3985. }
  3986. hasPrevious= true;
  3987. previous= measure.time();
  3988. }
  3989. /*:369*//*371:*/
  3990. #line 8311 "./typica.w"
  3991. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3992. previous(0,0,0,0),hasPrevious(false)
  3993. {
  3994. }
  3995. QTime MeasurementTimeOffset::zeroTime()
  3996. {
  3997. return epoch;
  3998. }
  3999. void MeasurementTimeOffset::setZeroTime(QTime zero)
  4000. {
  4001. epoch= zero;
  4002. hasPrevious= false;
  4003. }
  4004. /*:371*/
  4005. #line 545 "./typica.w"
  4006. /*381:*/
  4007. #line 8519 "./typica.w"
  4008. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  4009. {
  4010. }
  4011. int ZeroEmitter::column()
  4012. {
  4013. return col;
  4014. }
  4015. double ZeroEmitter::lastTemperature()
  4016. {
  4017. return cache.temperature();
  4018. }
  4019. void ZeroEmitter::newMeasurement(Measurement measure)
  4020. {
  4021. cache= measure;
  4022. }
  4023. void ZeroEmitter::setColumn(int column)
  4024. {
  4025. col= column;
  4026. }
  4027. void ZeroEmitter::emitZero()
  4028. {
  4029. cache.setTime(QTime(0,0,0,0));
  4030. emit measurement(cache,col);
  4031. }
  4032. /*:381*/
  4033. #line 546 "./typica.w"
  4034. /*386:*/
  4035. #line 8609 "./typica.w"
  4036. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  4037. {
  4038. }
  4039. int MeasurementAdapter::column()
  4040. {
  4041. return col;
  4042. }
  4043. void MeasurementAdapter::newMeasurement(Measurement measure)
  4044. {
  4045. emit measurement(measure,col);
  4046. }
  4047. void MeasurementAdapter::setColumn(int column)
  4048. {
  4049. col= column;
  4050. }
  4051. /*:386*/
  4052. #line 547 "./typica.w"
  4053. /*391:*/
  4054. #line 8731 "./typica.w"
  4055. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4056. theScene(new QGraphicsScene),
  4057. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4058. prevPoints(new QMap<int,QPointF> ),
  4059. translations(new QMap<int,double> ),
  4060. gridLinesF(new QList<QGraphicsItem*> ),
  4061. gridLinesC(new QList<QGraphicsItem*> ),
  4062. relativeGridLines(new QList<QGraphicsItem*> ),
  4063. relativeEnabled(false),
  4064. timeIndicatorEnabled(false),
  4065. timeLine(new QGraphicsLineItem),
  4066. relativeAdjuster(new LinearSplineInterpolator)
  4067. {
  4068. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4069. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4070. setScene(theScene);
  4071. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4072. QPen timePen;
  4073. timePen.setColor(QColor(160,160,164,127));
  4074. timeLine->setPen(timePen);
  4075. timeLine->setLine(0,0,0,-500);
  4076. timeLine->hide();
  4077. theScene->addItem(timeLine);
  4078. /*392:*/
  4079. #line 8771 "./typica.w"
  4080. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4081. tempaxis->setLine(-10,-500,-10,0);
  4082. theScene->addItem(tempaxis);
  4083. QGraphicsLineItem*gridLine;
  4084. QGraphicsTextItem*label;
  4085. for(int y= -100;y> -600;y-= 100)
  4086. {
  4087. gridLine= new QGraphicsLineItem;
  4088. gridLine->setLine(0,y,1200,y);
  4089. theScene->addItem(gridLine);
  4090. label= new QGraphicsTextItem;
  4091. label->setHtml(QString("%1&deg;F").arg(-y));
  4092. label->setPos(-55,y-(label->boundingRect().height()/2));
  4093. theScene->addItem(label);
  4094. gridLinesF->append(gridLine);
  4095. gridLinesF->append(label);
  4096. }
  4097. for(int degC= 50;degC<=250;degC+= 50)
  4098. {
  4099. gridLine= new QGraphicsLineItem;
  4100. int y= -(degC*(9.0/5.0)+32);
  4101. gridLine->setLine(0,y,1200,y);
  4102. gridLine->hide();
  4103. theScene->addItem(gridLine);
  4104. gridLinesC->append(gridLine);
  4105. label= new QGraphicsTextItem;
  4106. label->setHtml(QString("%1&deg;C").arg(degC));
  4107. label->setPos(-55,y-(label->boundingRect().height()/2));
  4108. label->hide();
  4109. theScene->addItem(label);
  4110. gridLinesC->append(label);
  4111. }
  4112. /*:392*/
  4113. #line 8755 "./typica.w"
  4114. ;
  4115. /*393:*/
  4116. #line 8812 "./typica.w"
  4117. QSettings settings;
  4118. if(settings.contains("settings/graph/relative/enable"))
  4119. {
  4120. if(settings.value("settings/graph/relative/enable").toBool())
  4121. {
  4122. relativeEnabled= true;
  4123. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4124. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4125. QMap<double,QString> relativeAxisPairs;
  4126. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4127. foreach(QString item,relativeAxisLabels)
  4128. {
  4129. relativeAxisPairs.insert(item.toDouble(),item);
  4130. }
  4131. if(relativeAxisPairs.size()> 1)
  4132. {
  4133. double skip= 500.0/(relativeAxisPairs.size()-1);
  4134. double y= 0;
  4135. foreach(double key,relativeAxisPairs.keys())
  4136. {
  4137. gridLine= new QGraphicsLineItem;
  4138. gridLine->setLine(0,y,1205,y);
  4139. gridLine->setPen(QPen(relativeColor));
  4140. theScene->addItem(gridLine);
  4141. relativeGridLines->append(gridLine);
  4142. label= new QGraphicsTextItem;
  4143. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4144. label->setPos(1210,y-(label->boundingRect().height()/2));
  4145. theScene->addItem(label);
  4146. relativeGridLines->append(label);
  4147. if(unit=="F")
  4148. {
  4149. relativeAdjuster->add_pair(key,-y);
  4150. }
  4151. else
  4152. {
  4153. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4154. }
  4155. y-= skip;
  4156. }
  4157. }
  4158. }
  4159. }
  4160. /*:393*/
  4161. #line 8756 "./typica.w"
  4162. /*395:*/
  4163. #line 8889 "./typica.w"
  4164. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4165. timeaxis->setLine(0,10,1200,10);
  4166. theScene->addItem(timeaxis);
  4167. for(int x= 0;x<1201;x+= 120)
  4168. {
  4169. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4170. tick->setLine(x,0,x,20);
  4171. theScene->addItem(tick);
  4172. QGraphicsTextItem*label= new QGraphicsTextItem;
  4173. label->setPlainText(QString("%1").arg(x/60));
  4174. label->setPos(x-(label->boundingRect().width()/2),20);
  4175. theScene->addItem(label);
  4176. }
  4177. /*:395*/
  4178. #line 8757 "./typica.w"
  4179. ;
  4180. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4181. }
  4182. /*:391*//*394:*/
  4183. #line 8859 "./typica.w"
  4184. void GraphView::showF()
  4185. {
  4186. for(int i= 0;i<gridLinesF->size();i++)
  4187. {
  4188. gridLinesF->at(i)->show();
  4189. }
  4190. for(int i= 0;i<gridLinesC->size();i++)
  4191. {
  4192. gridLinesC->at(i)->hide();
  4193. }
  4194. }
  4195. void GraphView::showC()
  4196. {
  4197. for(int i= 0;i<gridLinesF->size();i++)
  4198. {
  4199. gridLinesF->at(i)->hide();
  4200. }
  4201. for(int i= 0;i<gridLinesC->size();i++)
  4202. {
  4203. gridLinesC->at(i)->show();
  4204. }
  4205. }
  4206. /*:394*//*396:*/
  4207. #line 8908 "./typica.w"
  4208. void GraphView::resizeEvent(QResizeEvent*)
  4209. {
  4210. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4211. }
  4212. /*:396*//*397:*/
  4213. #line 8922 "./typica.w"
  4214. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4215. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4216. {
  4217. double offset= 0;
  4218. if(measure.contains("relative"))
  4219. {
  4220. if(measure.value("relative").toBool())
  4221. {
  4222. if(relativeEnabled)
  4223. {
  4224. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4225. }
  4226. else
  4227. {
  4228. return;
  4229. }
  4230. }
  4231. }
  4232. if(translations->contains(tempcolumn))
  4233. {
  4234. offset= translations->value(tempcolumn);
  4235. }
  4236. if(prevPoints->contains(tempcolumn))
  4237. {
  4238. /*399:*/
  4239. #line 8999 "./typica.w"
  4240. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4241. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4242. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4243. -(prevPoints->value(tempcolumn).y()),
  4244. nextPoint.x()+offset,-(nextPoint.y()));
  4245. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4246. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4247. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4248. Qt::darkYellow};
  4249. segment->setPen(p[tempcolumn%12]);
  4250. theScene->addItem(segment);
  4251. prevPoints->insert(tempcolumn,nextPoint);
  4252. if(timeIndicatorEnabled)
  4253. {
  4254. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4255. }
  4256. /*:399*/
  4257. #line 8948 "./typica.w"
  4258. if(graphLines->contains(tempcolumn))
  4259. {
  4260. graphLines->value(tempcolumn)->append(segment);
  4261. }
  4262. else
  4263. {
  4264. QList<QGraphicsLineItem*> *newLine=
  4265. new QList<QGraphicsLineItem*> ;
  4266. newLine->append(segment);
  4267. graphLines->insert(tempcolumn,newLine);
  4268. }
  4269. }
  4270. else
  4271. {
  4272. /*398:*/
  4273. #line 8984 "./typica.w"
  4274. int x= FULLTIMETOINT(measure.time())/1000;
  4275. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4276. if(timeIndicatorEnabled)
  4277. {
  4278. timeLine->setLine(x,0,x,-500);
  4279. }
  4280. /*:398*/
  4281. #line 8965 "./typica.w"
  4282. }
  4283. }
  4284. /*:397*//*400:*/
  4285. #line 9020 "./typica.w"
  4286. void GraphView::clear()
  4287. {
  4288. int i;
  4289. foreach(i,prevPoints->keys())
  4290. {
  4291. removeSeries(i);
  4292. }
  4293. translations->clear();
  4294. }
  4295. /*:400*//*401:*/
  4296. #line 9034 "./typica.w"
  4297. void GraphView::removeSeries(int column)
  4298. {
  4299. if(graphLines->contains(column))
  4300. {
  4301. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4302. QGraphicsLineItem*segment;
  4303. foreach(segment,*series)
  4304. {
  4305. theScene->removeItem(segment);
  4306. }
  4307. qDeleteAll(*series);
  4308. }
  4309. graphLines->remove(column);
  4310. prevPoints->remove(column);
  4311. }
  4312. /*:401*//*402:*/
  4313. #line 9053 "./typica.w"
  4314. void GraphView::setSeriesTranslation(int column,double offset)
  4315. {
  4316. if(graphLines->contains(column))
  4317. {
  4318. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4319. QGraphicsLineItem*segment;
  4320. foreach(segment,*series)
  4321. {
  4322. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4323. }
  4324. }
  4325. if(translations->contains(column))
  4326. {
  4327. translations->insert(column,offset+translations->value(column));
  4328. }
  4329. else
  4330. {
  4331. translations->insert(column,offset);
  4332. }
  4333. }
  4334. /*:402*//*403:*/
  4335. #line 9080 "./typica.w"
  4336. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4337. {
  4338. timeIndicatorEnabled= enabled;
  4339. if(enabled)
  4340. {
  4341. timeLine->show();
  4342. }
  4343. else
  4344. {
  4345. timeLine->hide();
  4346. }
  4347. }
  4348. /*:403*/
  4349. #line 548 "./typica.w"
  4350. /*409:*/
  4351. #line 9224 "./typica.w"
  4352. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4353. {
  4354. if(measure.time()!=QTime(0,0,0,0))
  4355. {
  4356. /*411:*/
  4357. #line 9298 "./typica.w"
  4358. if(lastMeasurement.contains(tempcolumn))
  4359. {
  4360. if(lastMeasurement[tempcolumn].time()<measure.time())
  4361. {
  4362. QList<QTime> timelist;
  4363. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4364. {
  4365. timelist.append(i);
  4366. }
  4367. for(int i= 0;i<timelist.size();i++)
  4368. {
  4369. Measurement synthesized= measure;
  4370. synthesized.setTime(timelist[i]);
  4371. newMeasurement(synthesized,tempcolumn);
  4372. }
  4373. }
  4374. }
  4375. /*:411*/
  4376. #line 9229 "./typica.w"
  4377. }
  4378. model_ms->newMeasurement(measure,tempcolumn);
  4379. if(lastMeasurement.contains(tempcolumn))
  4380. {
  4381. if(measure.time().second()!=
  4382. lastMeasurement.value(tempcolumn).time().second())
  4383. {
  4384. Measurement adjusted= measure;
  4385. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4386. adjusted.setTime(adjtime);
  4387. model_1s->newMeasurement(adjusted,tempcolumn);
  4388. if(adjusted.time().second()%5==0)
  4389. {
  4390. model_5s->newMeasurement(adjusted,tempcolumn);
  4391. if(adjusted.time().second()%10==0)
  4392. {
  4393. model_10s->newMeasurement(adjusted,tempcolumn);
  4394. }
  4395. if(adjusted.time().second()%15==0)
  4396. {
  4397. model_15s->newMeasurement(adjusted,tempcolumn);
  4398. if(adjusted.time().second()%30==0)
  4399. {
  4400. model_30s->newMeasurement(adjusted,tempcolumn);
  4401. if(adjusted.time().second()==0)
  4402. {
  4403. model_1m->newMeasurement(adjusted,tempcolumn);
  4404. }
  4405. }
  4406. }
  4407. }
  4408. }
  4409. /*413:*/
  4410. #line 9342 "./typica.w"
  4411. if(currentColumnSet.contains(tempcolumn))
  4412. {
  4413. int replicationcolumn;
  4414. foreach(replicationcolumn,currentColumnSet)
  4415. {
  4416. if(replicationcolumn!=tempcolumn)
  4417. {
  4418. if(lastMeasurement.contains(replicationcolumn))
  4419. {
  4420. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4421. {
  4422. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4423. synthetic.setTime(measure.time());
  4424. model_ms->newMeasurement(synthetic,replicationcolumn);
  4425. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4426. {
  4427. Measurement adjusted= synthetic;
  4428. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4429. model_1s->newMeasurement(adjusted,replicationcolumn);
  4430. if(adjusted.time().second()%5==0)
  4431. {
  4432. model_5s->newMeasurement(adjusted,replicationcolumn);
  4433. if(adjusted.time().second()%10==0)
  4434. {
  4435. model_10s->newMeasurement(adjusted,replicationcolumn);
  4436. }
  4437. if(adjusted.time().second()%15==0)
  4438. {
  4439. model_15s->newMeasurement(adjusted,replicationcolumn);
  4440. if(adjusted.time().second()%30==0)
  4441. {
  4442. model_30s->newMeasurement(adjusted,replicationcolumn);
  4443. if(adjusted.time().second()==0)
  4444. {
  4445. model_1m->newMeasurement(adjusted,replicationcolumn);
  4446. }
  4447. }
  4448. }
  4449. }
  4450. }
  4451. lastMeasurement[replicationcolumn]= synthetic;
  4452. }
  4453. }
  4454. }
  4455. }
  4456. }
  4457. /*:413*/
  4458. #line 9262 "./typica.w"
  4459. }
  4460. else
  4461. {
  4462. /*410:*/
  4463. #line 9274 "./typica.w"
  4464. MeasurementModel*m;
  4465. foreach(m,modelSet)
  4466. {
  4467. m->newMeasurement(measure,tempcolumn);
  4468. }
  4469. /*:410*/
  4470. #line 9266 "./typica.w"
  4471. }
  4472. lastMeasurement.insert(tempcolumn,measure);
  4473. }
  4474. /*:409*//*412:*/
  4475. #line 9328 "./typica.w"
  4476. void ZoomLog::addToCurrentColumnSet(int column)
  4477. {
  4478. currentColumnSet.append(column);
  4479. }
  4480. void ZoomLog::clearCurrentColumnSet()
  4481. {
  4482. currentColumnSet.clear();
  4483. }
  4484. /*:412*//*414:*/
  4485. #line 9412 "./typica.w"
  4486. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4487. int annotationcolumn)
  4488. {
  4489. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4490. MeasurementModel*m;
  4491. if(lastMeasurement.contains(tempcolumn))
  4492. {
  4493. foreach(m,modelSet)
  4494. {
  4495. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4496. }
  4497. }
  4498. foreach(m,modelSet)
  4499. {
  4500. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4501. }
  4502. }
  4503. /*:414*//*415:*/
  4504. #line 9436 "./typica.w"
  4505. void ZoomLog::centerOn(int row)
  4506. {
  4507. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4508. }
  4509. /*:415*//*416:*/
  4510. #line 9446 "./typica.w"
  4511. void ZoomLog::clear()
  4512. {
  4513. MeasurementModel*m;
  4514. foreach(m,modelSet)
  4515. {
  4516. m->clear();
  4517. }
  4518. lastMeasurement.clear();
  4519. saveTempCols.clear();
  4520. saveControlCols.clear();
  4521. saveNoteCols.clear();
  4522. }
  4523. /*:416*//*417:*/
  4524. #line 9464 "./typica.w"
  4525. QVariant ZoomLog::data(int row,int column)const
  4526. {
  4527. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4528. Qt::DisplayRole);
  4529. }
  4530. int ZoomLog::rowCount()
  4531. {
  4532. return model_ms->rowCount();
  4533. }
  4534. /*:417*//*418:*/
  4535. #line 9487 "./typica.w"
  4536. bool ZoomLog::saveXML(QIODevice*device)
  4537. {
  4538. Units::Unit prevUnits= model_ms->displayUnits();
  4539. if(prevUnits!=Units::Fahrenheit)
  4540. {
  4541. model_ms->setDisplayUnits(Units::Fahrenheit);
  4542. }
  4543. XMLOutput writer(model_ms,device,0);
  4544. int c;
  4545. foreach(c,saveTempCols)
  4546. {
  4547. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4548. toString(),c);
  4549. }
  4550. foreach(c,saveControlCols)
  4551. {
  4552. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4553. toString(),c);
  4554. }
  4555. foreach(c,saveNoteCols)
  4556. {
  4557. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4558. toString(),c);
  4559. }
  4560. bool retval= writer.output();
  4561. if(prevUnits!=Units::Fahrenheit)
  4562. {
  4563. model_ms->setDisplayUnits(prevUnits);
  4564. }
  4565. return retval;
  4566. }
  4567. /*:418*//*419:*/
  4568. #line 9523 "./typica.w"
  4569. bool ZoomLog::saveCSV(QIODevice*device)
  4570. {
  4571. CSVOutput writer(currentModel,device,0);
  4572. int c;
  4573. foreach(c,saveTempCols)
  4574. {
  4575. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4576. toString(),c);
  4577. }
  4578. foreach(c,saveControlCols)
  4579. {
  4580. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4581. toString(),c);
  4582. }
  4583. foreach(c,saveNoteCols)
  4584. {
  4585. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4586. toString(),c);
  4587. }
  4588. return writer.output();
  4589. }
  4590. /*:419*//*420:*/
  4591. #line 9552 "./typica.w"
  4592. void ZoomLog::switchLOD(MeasurementModel*m)
  4593. {
  4594. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4595. setModel(m);
  4596. currentModel= m;
  4597. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4598. }
  4599. void ZoomLog::LOD_ms()
  4600. {
  4601. switchLOD(model_ms);
  4602. }
  4603. void ZoomLog::LOD_1s()
  4604. {
  4605. switchLOD(model_1s);
  4606. }
  4607. void ZoomLog::LOD_5s()
  4608. {
  4609. switchLOD(model_5s);
  4610. }
  4611. void ZoomLog::LOD_10s()
  4612. {
  4613. switchLOD(model_10s);
  4614. }
  4615. void ZoomLog::LOD_15s()
  4616. {
  4617. switchLOD(model_15s);
  4618. }
  4619. void ZoomLog::LOD_30s()
  4620. {
  4621. switchLOD(model_30s);
  4622. }
  4623. void ZoomLog::LOD_1m()
  4624. {
  4625. switchLOD(model_1m);
  4626. }
  4627. /*:420*//*421:*/
  4628. #line 9600 "./typica.w"
  4629. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4630. {
  4631. model_ms->setDisplayUnits(scale);
  4632. model_1s->setDisplayUnits(scale);
  4633. model_5s->setDisplayUnits(scale);
  4634. model_10s->setDisplayUnits(scale);
  4635. model_15s->setDisplayUnits(scale);
  4636. model_30s->setDisplayUnits(scale);
  4637. model_1m->setDisplayUnits(scale);
  4638. }
  4639. Units::Unit ZoomLog::displayUnits()
  4640. {
  4641. return model_ms->displayUnits();
  4642. }
  4643. /*:421*//*422:*/
  4644. #line 9620 "./typica.w"
  4645. QString ZoomLog::lastTime(int series)
  4646. {
  4647. Measurement measure= lastMeasurement.value(series);
  4648. QTime time= measure.time();
  4649. return time.toString("h:mm:ss.zzz");
  4650. }
  4651. /*:422*//*423:*/
  4652. #line 9630 "./typica.w"
  4653. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4654. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4655. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4656. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4657. {
  4658. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4659. setSelectionMode(QAbstractItemView::NoSelection);
  4660. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4661. model_30s<<model_1m;
  4662. currentModel= model_30s;
  4663. setModel(currentModel);
  4664. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4665. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4666. this,SLOT(persistColumnResize(int,int,int)));
  4667. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4668. this,SLOT(restoreColumnWidths()));
  4669. }
  4670. /*:423*//*424:*/
  4671. #line 9653 "./typica.w"
  4672. void ZoomLog::setHeaderData(int section,QString text)
  4673. {
  4674. MeasurementModel*m;
  4675. foreach(m,modelSet)
  4676. {
  4677. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4678. }
  4679. }
  4680. /*:424*//*425:*/
  4681. #line 9671 "./typica.w"
  4682. void ZoomLog::addOutputTemperatureColumn(int column)
  4683. {
  4684. saveTempCols.append(column);
  4685. }
  4686. void ZoomLog::addOutputControlColumn(int column)
  4687. {
  4688. saveControlCols.append(column);
  4689. }
  4690. void ZoomLog::addOutputAnnotationColumn(int column)
  4691. {
  4692. saveNoteCols.append(column);
  4693. }
  4694. void ZoomLog::clearOutputColumns()
  4695. {
  4696. saveTempCols.clear();
  4697. saveControlCols.clear();
  4698. saveNoteCols.clear();
  4699. }
  4700. /*:425*//*426:*/
  4701. #line 9697 "./typica.w"
  4702. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4703. {
  4704. /*651:*/
  4705. #line 13850 "./typica.w"
  4706. QSettings settings;
  4707. /*652:*/
  4708. #line 13863 "./typica.w"
  4709. QWidget*topLevelWidget= this;
  4710. while(topLevelWidget->parentWidget())
  4711. {
  4712. topLevelWidget= topLevelWidget->parentWidget();
  4713. }
  4714. /*:652*/
  4715. #line 13852 "./typica.w"
  4716. settings.setValue(QString("columnWidths/%1/%2/%3").
  4717. arg(topLevelWidget->objectName()).
  4718. arg(objectName()).arg(column),
  4719. QVariant(newsize));
  4720. /*:651*/
  4721. #line 9700 "./typica.w"
  4722. }
  4723. void ZoomLog::restoreColumnWidths()
  4724. {
  4725. /*654:*/
  4726. #line 13883 "./typica.w"
  4727. QSettings settings;
  4728. /*652:*/
  4729. #line 13863 "./typica.w"
  4730. QWidget*topLevelWidget= this;
  4731. while(topLevelWidget->parentWidget())
  4732. {
  4733. topLevelWidget= topLevelWidget->parentWidget();
  4734. }
  4735. /*:652*/
  4736. #line 13885 "./typica.w"
  4737. QString baseKey=
  4738. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4739. arg(objectName());
  4740. for(int i= 0;i<model()->columnCount();i++)
  4741. {
  4742. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4743. if(settings.contains(key))
  4744. {
  4745. setColumnWidth(i,settings.value(key).toInt());
  4746. }
  4747. }
  4748. /*:654*/
  4749. #line 9705 "./typica.w"
  4750. }
  4751. void ZoomLog::setVisible(bool visibility)
  4752. {
  4753. QTableView::setVisible(visibility);
  4754. }
  4755. void ZoomLog::showEvent(QShowEvent*)
  4756. {
  4757. /*654:*/
  4758. #line 13883 "./typica.w"
  4759. QSettings settings;
  4760. /*652:*/
  4761. #line 13863 "./typica.w"
  4762. QWidget*topLevelWidget= this;
  4763. while(topLevelWidget->parentWidget())
  4764. {
  4765. topLevelWidget= topLevelWidget->parentWidget();
  4766. }
  4767. /*:652*/
  4768. #line 13885 "./typica.w"
  4769. QString baseKey=
  4770. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4771. arg(objectName());
  4772. for(int i= 0;i<model()->columnCount();i++)
  4773. {
  4774. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4775. if(settings.contains(key))
  4776. {
  4777. setColumnWidth(i,settings.value(key).toInt());
  4778. }
  4779. }
  4780. /*:654*/
  4781. #line 9715 "./typica.w"
  4782. }
  4783. /*:426*/
  4784. #line 549 "./typica.w"
  4785. /*435:*/
  4786. #line 9948 "./typica.w"
  4787. bool MeasurementList::operator<(const MeasurementList&other)const
  4788. {
  4789. return this->first().toTime()<other.first().toTime();
  4790. }
  4791. bool MeasurementList::operator==(const MeasurementList&other)const
  4792. {
  4793. return this->first().toTime()==other.first().toTime();
  4794. }
  4795. /*:435*//*436:*/
  4796. #line 9964 "./typica.w"
  4797. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4798. {
  4799. return QModelIndex();
  4800. }
  4801. /*:436*//*437:*/
  4802. #line 9974 "./typica.w"
  4803. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4804. {
  4805. if(measure.scale()==Units::Unitless)
  4806. {
  4807. controlColumns->insert(tempcolumn,true);
  4808. }
  4809. else
  4810. {
  4811. controlColumns->insert(tempcolumn,false);
  4812. }
  4813. MeasurementList*temp;
  4814. temp= new MeasurementList;
  4815. temp->append(QVariant(measure.time()));
  4816. /*438:*/
  4817. #line 10033 "./typica.w"
  4818. /*439:*/
  4819. #line 10078 "./typica.w"
  4820. QList<MeasurementList*> ::iterator i= lastInsertion;
  4821. bool quickscan= false;
  4822. if(entries->size()> 5)
  4823. {
  4824. if(**i<*temp)
  4825. {
  4826. i+= 1;
  4827. for(int j= 10;j> 0;j--)
  4828. {
  4829. if(i!=entries->end())
  4830. {
  4831. if(**i<*temp)
  4832. {
  4833. i+= 1;
  4834. }
  4835. else
  4836. {
  4837. quickscan= true;
  4838. break;
  4839. }
  4840. }
  4841. else
  4842. {
  4843. quickscan= true;
  4844. break;
  4845. }
  4846. }
  4847. }
  4848. else
  4849. {
  4850. if(**i==*temp)
  4851. {
  4852. quickscan= true;
  4853. }
  4854. }
  4855. }
  4856. /*:439*/
  4857. #line 10034 "./typica.w"
  4858. if(quickscan==false)
  4859. {
  4860. i= entries->begin();
  4861. QList<MeasurementList*> ::iterator u= entries->end();
  4862. QList<MeasurementList*> ::iterator midpoint;
  4863. int n= u-i;
  4864. int rA;
  4865. while(n> 0)
  4866. {
  4867. rA= n>>1;
  4868. midpoint= i+rA;
  4869. if(**midpoint<*temp)
  4870. {
  4871. i= midpoint+1;
  4872. n-= rA+1;
  4873. }
  4874. else
  4875. {
  4876. n= rA;
  4877. }
  4878. }
  4879. }
  4880. /*:438*/
  4881. #line 9988 "./typica.w"
  4882. MeasurementList*newEntry;
  4883. int insertion;
  4884. if(i!=entries->end())
  4885. {
  4886. insertion= entries->indexOf(*i);
  4887. if((*i)->first().toTime()==measure.time())
  4888. {
  4889. /*440:*/
  4890. #line 10120 "./typica.w"
  4891. if((*i)->size()<tempcolumn+1)
  4892. {
  4893. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4894. {
  4895. (*i)->append(QVariant());
  4896. }
  4897. }
  4898. (*i)->replace(tempcolumn,measure);
  4899. lastInsertion= i;
  4900. emit dataChanged(createIndex(insertion,tempcolumn),
  4901. createIndex(insertion,tempcolumn));
  4902. lastTemperature->insert(tempcolumn,insertion);
  4903. /*:440*/
  4904. #line 9996 "./typica.w"
  4905. }
  4906. else
  4907. {
  4908. /*441:*/
  4909. #line 10138 "./typica.w"
  4910. beginInsertRows(QModelIndex(),insertion,insertion);
  4911. newEntry= new MeasurementList;
  4912. newEntry->append(QVariant(measure.time()));
  4913. for(int j= 0;j<tempcolumn+1;j++)
  4914. {
  4915. newEntry->append(QVariant());
  4916. }
  4917. newEntry->replace(tempcolumn,measure);
  4918. lastInsertion= entries->insert(i,newEntry);
  4919. endInsertRows();
  4920. lastTemperature->insert(tempcolumn,insertion);
  4921. /*:441*/
  4922. #line 10000 "./typica.w"
  4923. }
  4924. }
  4925. else
  4926. {
  4927. /*442:*/
  4928. #line 10156 "./typica.w"
  4929. insertion= entries->size();
  4930. /*441:*/
  4931. #line 10138 "./typica.w"
  4932. beginInsertRows(QModelIndex(),insertion,insertion);
  4933. newEntry= new MeasurementList;
  4934. newEntry->append(QVariant(measure.time()));
  4935. for(int j= 0;j<tempcolumn+1;j++)
  4936. {
  4937. newEntry->append(QVariant());
  4938. }
  4939. newEntry->replace(tempcolumn,measure);
  4940. lastInsertion= entries->insert(i,newEntry);
  4941. endInsertRows();
  4942. lastTemperature->insert(tempcolumn,insertion);
  4943. /*:441*/
  4944. #line 10158 "./typica.w"
  4945. /*:442*/
  4946. #line 10005 "./typica.w"
  4947. }
  4948. if(tempcolumn>=colcount)
  4949. {
  4950. colcount= tempcolumn+1;
  4951. }
  4952. emit rowChanged(insertion);
  4953. delete temp;
  4954. }
  4955. /*:437*//*443:*/
  4956. #line 10168 "./typica.w"
  4957. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4958. int annotationColumn)
  4959. {
  4960. int r;
  4961. if(lastTemperature->contains(tempcolumn))
  4962. {
  4963. r= lastTemperature->value(tempcolumn);
  4964. }
  4965. else
  4966. {
  4967. r= 0;
  4968. }
  4969. if(r==0&&entries->size()==0)
  4970. {
  4971. /*444:*/
  4972. #line 10206 "./typica.w"
  4973. beginInsertRows(QModelIndex(),0,0);
  4974. MeasurementList*newEntry= new MeasurementList;
  4975. newEntry->append(QVariant(QTime(0,0,0,0)));
  4976. entries->append(newEntry);
  4977. endInsertRows();
  4978. /*:444*/
  4979. #line 10183 "./typica.w"
  4980. }
  4981. MeasurementList*row= entries->at(r);
  4982. if(row->size()<=annotationColumn)
  4983. {
  4984. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4985. {
  4986. row->append(QVariant());
  4987. }
  4988. }
  4989. row->replace(annotationColumn,annotation);
  4990. emit dataChanged(createIndex(r,annotationColumn),
  4991. createIndex(r,annotationColumn));
  4992. emit rowChanged(r);
  4993. if(annotationColumn> colcount-1)
  4994. {
  4995. colcount= annotationColumn+1;
  4996. }
  4997. }
  4998. /*:443*//*445:*/
  4999. #line 10217 "./typica.w"
  5000. void MeasurementModel::clear()
  5001. {
  5002. beginRemoveRows(QModelIndex(),0,entries->size());
  5003. while(entries->size()!=0)
  5004. {
  5005. MeasurementList*row= entries->takeFirst();
  5006. delete row;
  5007. }
  5008. endRemoveRows();
  5009. colcount= hData->size();
  5010. lastTemperature->clear();
  5011. reset();
  5012. }
  5013. /*:445*//*446:*/
  5014. #line 10250 "./typica.w"
  5015. bool MeasurementModel::setData(const QModelIndex&index,
  5016. const QVariant&value,int role)
  5017. {
  5018. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  5019. {
  5020. return false;
  5021. }
  5022. /*447:*/
  5023. #line 10282 "./typica.w"
  5024. bool valid= false;
  5025. if(index.isValid())
  5026. {
  5027. if(index.row()<entries->size())
  5028. {
  5029. if(index.column()<colcount)
  5030. {
  5031. valid= true;
  5032. }
  5033. }
  5034. }
  5035. /*:447*/
  5036. #line 10258 "./typica.w"
  5037. if(!valid)
  5038. {
  5039. return false;
  5040. }
  5041. MeasurementList*row= entries->at(index.row());
  5042. if(index.column()>=row->size())
  5043. {
  5044. /*448:*/
  5045. #line 10299 "./typica.w"
  5046. for(int i= row->size()-1;i<index.column();i++)
  5047. {
  5048. row->append(QVariant());
  5049. }
  5050. /*:448*/
  5051. #line 10266 "./typica.w"
  5052. }
  5053. if(index.column()==0)
  5054. {
  5055. /*449:*/
  5056. #line 10314 "./typica.w"
  5057. QTime time;
  5058. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5059. {
  5060. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5061. {
  5062. return false;
  5063. }
  5064. }
  5065. row= entries->takeAt(index.row());
  5066. row->replace(index.column(),QVariant(time));
  5067. MeasurementList*temp= row;
  5068. /*438:*/
  5069. #line 10033 "./typica.w"
  5070. /*439:*/
  5071. #line 10078 "./typica.w"
  5072. QList<MeasurementList*> ::iterator i= lastInsertion;
  5073. bool quickscan= false;
  5074. if(entries->size()> 5)
  5075. {
  5076. if(**i<*temp)
  5077. {
  5078. i+= 1;
  5079. for(int j= 10;j> 0;j--)
  5080. {
  5081. if(i!=entries->end())
  5082. {
  5083. if(**i<*temp)
  5084. {
  5085. i+= 1;
  5086. }
  5087. else
  5088. {
  5089. quickscan= true;
  5090. break;
  5091. }
  5092. }
  5093. else
  5094. {
  5095. quickscan= true;
  5096. break;
  5097. }
  5098. }
  5099. }
  5100. else
  5101. {
  5102. if(**i==*temp)
  5103. {
  5104. quickscan= true;
  5105. }
  5106. }
  5107. }
  5108. /*:439*/
  5109. #line 10034 "./typica.w"
  5110. if(quickscan==false)
  5111. {
  5112. i= entries->begin();
  5113. QList<MeasurementList*> ::iterator u= entries->end();
  5114. QList<MeasurementList*> ::iterator midpoint;
  5115. int n= u-i;
  5116. int rA;
  5117. while(n> 0)
  5118. {
  5119. rA= n>>1;
  5120. midpoint= i+rA;
  5121. if(**midpoint<*temp)
  5122. {
  5123. i= midpoint+1;
  5124. n-= rA+1;
  5125. }
  5126. else
  5127. {
  5128. n= rA;
  5129. }
  5130. }
  5131. }
  5132. /*:438*/
  5133. #line 10326 "./typica.w"
  5134. entries->insert(i,row);
  5135. int newRow= entries->indexOf(*i);
  5136. if(newRow<index.row())
  5137. {
  5138. emit dataChanged(createIndex(newRow,index.column()),index);
  5139. }
  5140. else
  5141. {
  5142. emit dataChanged(index,createIndex(newRow,index.column()));
  5143. }
  5144. /*:449*/
  5145. #line 10270 "./typica.w"
  5146. }
  5147. else
  5148. {
  5149. /*450:*/
  5150. #line 10340 "./typica.w"
  5151. row->replace(index.column(),value);
  5152. emit dataChanged(index,index);
  5153. /*:450*/
  5154. #line 10274 "./typica.w"
  5155. }
  5156. return true;
  5157. }
  5158. /*:446*//*451:*/
  5159. #line 10348 "./typica.w"
  5160. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5161. unit(Units::Fahrenheit),hData(new QStringList),
  5162. lastTemperature(new QHash<int,int> ),
  5163. controlColumns(new QHash<int,bool> )
  5164. {
  5165. colcount= 1;
  5166. entries= new QList<MeasurementList*> ;
  5167. lastInsertion= entries->begin();
  5168. hData->append(tr("Time"));
  5169. }
  5170. /*:451*//*452:*/
  5171. #line 10362 "./typica.w"
  5172. MeasurementModel::~MeasurementModel()
  5173. {
  5174. clear();
  5175. delete entries;
  5176. delete hData;
  5177. }
  5178. /*:452*//*453:*/
  5179. #line 10374 "./typica.w"
  5180. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5181. {
  5182. if(parent==QModelIndex())
  5183. {
  5184. return entries->size();
  5185. }
  5186. return 0;
  5187. }
  5188. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5189. {
  5190. if(parent==QModelIndex())
  5191. {
  5192. return colcount;
  5193. }
  5194. return 0;
  5195. }
  5196. /*:453*//*454:*/
  5197. #line 10401 "./typica.w"
  5198. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5199. const QVariant&value,int)
  5200. {
  5201. if(orientation==Qt::Horizontal)
  5202. {
  5203. if(hData->size()<section+1)
  5204. {
  5205. for(int i= hData->size();i<section+1;i++)
  5206. {
  5207. if(colcount<i)
  5208. {
  5209. beginInsertColumns(QModelIndex(),i,i);
  5210. }
  5211. hData->append(QString());
  5212. if(colcount<i)
  5213. {
  5214. endInsertColumns();
  5215. }
  5216. }
  5217. }
  5218. hData->replace(section,value.toString());
  5219. emit headerDataChanged(orientation,section,section);
  5220. if(colcount<section+1)
  5221. {
  5222. colcount= section+1;
  5223. }
  5224. return true;
  5225. }
  5226. return false;
  5227. }
  5228. /*:454*//*455:*/
  5229. #line 10441 "./typica.w"
  5230. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5231. {
  5232. beginResetModel();
  5233. unit= scale;
  5234. endResetModel();
  5235. }
  5236. Units::Unit MeasurementModel::displayUnits()
  5237. {
  5238. return unit;
  5239. }
  5240. /*:455*//*456:*/
  5241. #line 10467 "./typica.w"
  5242. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5243. {
  5244. /*447:*/
  5245. #line 10282 "./typica.w"
  5246. bool valid= false;
  5247. if(index.isValid())
  5248. {
  5249. if(index.row()<entries->size())
  5250. {
  5251. if(index.column()<colcount)
  5252. {
  5253. valid= true;
  5254. }
  5255. }
  5256. }
  5257. /*:447*/
  5258. #line 10470 "./typica.w"
  5259. if(!valid)
  5260. {
  5261. return QVariant();
  5262. }
  5263. MeasurementList*row= entries->at(index.row());
  5264. if(role==Qt::UserRole)
  5265. {
  5266. return QVariant(row->at(index.column()));
  5267. }
  5268. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5269. {
  5270. if(index.column()> row->size())
  5271. {
  5272. return QVariant();
  5273. }
  5274. else
  5275. {
  5276. if(index.column()==0)
  5277. {
  5278. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5279. }
  5280. else if(lastTemperature->contains(index.column()))
  5281. {
  5282. QVariantMap v= row->at(index.column()).toMap();
  5283. if(!v.contains("measurement"))
  5284. {
  5285. return QVariant();
  5286. }
  5287. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5288. {
  5289. return v.value("measurement");
  5290. }
  5291. else
  5292. {
  5293. if(v.contains("relative"))
  5294. {
  5295. if(v.value("relative").toBool())
  5296. {
  5297. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5298. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5299. }
  5300. }
  5301. return QVariant(QString("%1").
  5302. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5303. (Units::Unit)(v.value("unit").toInt()),unit)));
  5304. }
  5305. }
  5306. return QVariant(row->at(index.column()).toString());
  5307. }
  5308. }
  5309. return QVariant();
  5310. }
  5311. /*:456*//*457:*/
  5312. #line 10526 "./typica.w"
  5313. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5314. int role)const
  5315. {
  5316. if(orientation==Qt::Horizontal)
  5317. {
  5318. if(role==Qt::DisplayRole)
  5319. {
  5320. if(section<hData->size())
  5321. {
  5322. return QVariant(hData->at(section));
  5323. }
  5324. }
  5325. }
  5326. return QVariant();
  5327. }
  5328. /*:457*//*458:*/
  5329. #line 10553 "./typica.w"
  5330. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5331. {
  5332. /*447:*/
  5333. #line 10282 "./typica.w"
  5334. bool valid= false;
  5335. if(index.isValid())
  5336. {
  5337. if(index.row()<entries->size())
  5338. {
  5339. if(index.column()<colcount)
  5340. {
  5341. valid= true;
  5342. }
  5343. }
  5344. }
  5345. /*:447*/
  5346. #line 10556 "./typica.w"
  5347. if(valid)
  5348. {
  5349. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5350. }
  5351. return 0;
  5352. }
  5353. /*:458*//*459:*/
  5354. #line 10568 "./typica.w"
  5355. QModelIndex MeasurementModel::index(int row,int column,
  5356. const QModelIndex&parent)const
  5357. {
  5358. if(parent==QModelIndex())
  5359. {
  5360. if(row<entries->size()&&entries->isEmpty()==false)
  5361. {
  5362. if(column<entries->at(row)->size())
  5363. {
  5364. return createIndex(row,column);
  5365. }
  5366. }
  5367. }
  5368. return QModelIndex();
  5369. }
  5370. /*:459*/
  5371. #line 550 "./typica.w"
  5372. /*461:*/
  5373. #line 10619 "./typica.w"
  5374. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5375. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5376. {
  5377. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5378. }
  5379. /*:461*//*462:*/
  5380. #line 10634 "./typica.w"
  5381. void AnnotationButton::annotate()
  5382. {
  5383. if(note.contains("%1"))
  5384. {
  5385. count++;
  5386. emit annotation(note.arg(count),tc,ac);
  5387. }
  5388. else
  5389. {
  5390. emit annotation(note,tc,ac);
  5391. }
  5392. }
  5393. /*:462*//*463:*/
  5394. #line 10652 "./typica.w"
  5395. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5396. {
  5397. tc= tempcolumn;
  5398. }
  5399. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5400. {
  5401. ac= annotationcolumn;
  5402. }
  5403. void AnnotationButton::setAnnotation(const QString&annotation)
  5404. {
  5405. note= annotation;
  5406. }
  5407. /*:463*//*464:*/
  5408. #line 10671 "./typica.w"
  5409. void AnnotationButton::resetCount()
  5410. {
  5411. count= 0;
  5412. }
  5413. /*:464*/
  5414. #line 551 "./typica.w"
  5415. /*469:*/
  5416. #line 10754 "./typica.w"
  5417. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5418. const QString&postt,
  5419. QWidget*parent)
  5420. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5421. {
  5422. resetChange();
  5423. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5424. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5425. }
  5426. /*:469*//*470:*/
  5427. #line 10771 "./typica.w"
  5428. void AnnotationSpinBox::resetChange()
  5429. {
  5430. change= true;
  5431. }
  5432. /*:470*//*471:*/
  5433. #line 10782 "./typica.w"
  5434. void AnnotationSpinBox::annotate()
  5435. {
  5436. if(change)
  5437. {
  5438. change= false;
  5439. emit annotation(QString("%1%2%3").arg(pretext).
  5440. arg(value()).arg(posttext),tc,ac);
  5441. }
  5442. }
  5443. /*:471*//*472:*/
  5444. #line 10795 "./typica.w"
  5445. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5446. {
  5447. tc= tempcolumn;
  5448. }
  5449. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5450. {
  5451. ac= annotationcolumn;
  5452. }
  5453. void AnnotationSpinBox::setPretext(const QString&pret)
  5454. {
  5455. pretext= pret;
  5456. }
  5457. void AnnotationSpinBox::setPosttext(const QString&postt)
  5458. {
  5459. posttext= postt;
  5460. }
  5461. /*:472*/
  5462. #line 552 "./typica.w"
  5463. /*479:*/
  5464. #line 10964 "./typica.w"
  5465. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5466. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5467. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5468. stopAction(new QAction(tr("Stop"),NULL)),
  5469. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5470. relative(QTime::currentTime()),base(QTime(0,0,0))
  5471. {
  5472. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5473. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5474. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5475. clock.setInterval(500);
  5476. clock.setSingleShot(false);
  5477. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5478. setSegmentStyle(Filled);
  5479. updateDisplay();
  5480. }
  5481. /*:479*//*480:*/
  5482. #line 10985 "./typica.w"
  5483. void TimerDisplay::updateTime()
  5484. {
  5485. QTime time;
  5486. int cseconds= 0;
  5487. int oseconds= 0;
  5488. int r= 0;
  5489. QTime nt= QTime(0,0,0);
  5490. int n= 0;
  5491. int bseconds= 0;
  5492. switch(m)
  5493. {
  5494. case TimerDisplay::CountUp:
  5495. /*481:*/
  5496. #line 11017 "./typica.w"
  5497. /*482:*/
  5498. #line 11030 "./typica.w"
  5499. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5500. time= QTime::currentTime();
  5501. cseconds= TIMETOINT(time);
  5502. oseconds= TIMETOINT(relative);
  5503. r= cseconds-oseconds;
  5504. /*:482*/
  5505. #line 11018 "./typica.w"
  5506. nt= nt.addSecs(r);
  5507. if(nt!=s)
  5508. {
  5509. s= nt;
  5510. emit valueChanged(s);
  5511. }
  5512. /*:481*/
  5513. #line 10998 "./typica.w"
  5514. ;
  5515. break;
  5516. case TimerDisplay::CountDown:
  5517. /*483:*/
  5518. #line 11042 "./typica.w"
  5519. if(s> QTime(0,0,0))
  5520. {
  5521. /*482:*/
  5522. #line 11030 "./typica.w"
  5523. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5524. time= QTime::currentTime();
  5525. cseconds= TIMETOINT(time);
  5526. oseconds= TIMETOINT(relative);
  5527. r= cseconds-oseconds;
  5528. /*:482*/
  5529. #line 11045 "./typica.w"
  5530. bseconds= TIMETOINT(base);
  5531. n= bseconds-r;
  5532. nt= nt.addSecs(n);
  5533. if(nt!=s)
  5534. {
  5535. s= nt;
  5536. emit valueChanged(s);
  5537. }
  5538. }else{
  5539. stopTimer();
  5540. }
  5541. /*:483*/
  5542. #line 11001 "./typica.w"
  5543. ;
  5544. break;
  5545. case TimerDisplay::Clock:
  5546. /*484:*/
  5547. #line 11061 "./typica.w"
  5548. time= QTime::currentTime();
  5549. if(time!=s)
  5550. {
  5551. s= time;
  5552. emit valueChanged(s);
  5553. }
  5554. /*:484*/
  5555. #line 11004 "./typica.w"
  5556. ;
  5557. break;
  5558. default:
  5559. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5560. break;
  5561. }
  5562. updateDisplay();
  5563. }
  5564. /*:480*//*485:*/
  5565. #line 11073 "./typica.w"
  5566. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5567. void TimerDisplay::startTimer()
  5568. {
  5569. if(!running)
  5570. {
  5571. relative= QTime::currentTime();
  5572. if(ar)
  5573. {
  5574. reset();
  5575. }
  5576. else
  5577. {
  5578. relative= TIMESUBTRACT(relative,s);
  5579. }
  5580. if(m==Clock)
  5581. {
  5582. updateTime();
  5583. }
  5584. base= s;
  5585. clock.start();
  5586. running= true;
  5587. emit runStateChanged(true);
  5588. }
  5589. }
  5590. /*:485*//*486:*/
  5591. #line 11103 "./typica.w"
  5592. void TimerDisplay::stopTimer()
  5593. {
  5594. if(running)
  5595. {
  5596. clock.stop();
  5597. running= false;
  5598. emit runStateChanged(false);
  5599. }
  5600. }
  5601. /*:486*//*487:*/
  5602. #line 11116 "./typica.w"
  5603. TimerDisplay::~TimerDisplay()
  5604. {
  5605. clock.stop();
  5606. }
  5607. /*:487*//*488:*/
  5608. #line 11125 "./typica.w"
  5609. void TimerDisplay::setCountUpMode()
  5610. {
  5611. m= TimerDisplay::CountUp;
  5612. }
  5613. void TimerDisplay::setCountDownMode()
  5614. {
  5615. m= TimerDisplay::CountDown;
  5616. }
  5617. void TimerDisplay::setClockMode()
  5618. {
  5619. m= TimerDisplay::Clock;
  5620. }
  5621. /*:488*//*489:*/
  5622. #line 11143 "./typica.w"
  5623. QString TimerDisplay::value()
  5624. {
  5625. return s.toString(f);
  5626. }
  5627. QTime TimerDisplay::seconds()
  5628. {
  5629. return s;
  5630. }
  5631. TimerDisplay::TimerMode TimerDisplay::mode()
  5632. {
  5633. return m;
  5634. }
  5635. bool TimerDisplay::isRunning()
  5636. {
  5637. return running;
  5638. }
  5639. QTime TimerDisplay::resetValue()
  5640. {
  5641. return r;
  5642. }
  5643. QString TimerDisplay::displayFormat()
  5644. {
  5645. return f;
  5646. }
  5647. bool TimerDisplay::autoReset()
  5648. {
  5649. return ar;
  5650. }
  5651. /*:489*//*490:*/
  5652. #line 11181 "./typica.w"
  5653. void TimerDisplay::setTimer(QTime value)
  5654. {
  5655. if(value.isValid())
  5656. {
  5657. s= value;
  5658. updateDisplay();
  5659. emit valueChanged(value);
  5660. }
  5661. }
  5662. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5663. {
  5664. m= mode;
  5665. }
  5666. void TimerDisplay::setResetValue(QTime value)
  5667. {
  5668. r= value;
  5669. }
  5670. void TimerDisplay::setDisplayFormat(QString format)
  5671. {
  5672. f= format;
  5673. setNumDigits(format.length());
  5674. }
  5675. void TimerDisplay::setAutoReset(bool reset)
  5676. {
  5677. ar= reset;
  5678. }
  5679. /*:490*//*491:*/
  5680. #line 11216 "./typica.w"
  5681. void TimerDisplay::copyTimer()
  5682. {
  5683. QApplication::clipboard()->setText(value());
  5684. }
  5685. /*:491*//*492:*/
  5686. #line 11225 "./typica.w"
  5687. void TimerDisplay::reset()
  5688. {
  5689. if(!running)
  5690. {
  5691. s= r;
  5692. updateDisplay();
  5693. }
  5694. }
  5695. /*:492*//*493:*/
  5696. #line 11238 "./typica.w"
  5697. void TimerDisplay::updateDisplay()
  5698. {
  5699. display(value());
  5700. }
  5701. /*:493*/
  5702. #line 553 "./typica.w"
  5703. /*500:*/
  5704. #line 11363 "./typica.w"
  5705. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5706. {
  5707. int x= rect.x();
  5708. int y= rect.y();
  5709. QLayoutItem*item;
  5710. if(orientation==Qt::Horizontal)
  5711. {
  5712. /*501:*/
  5713. #line 11387 "./typica.w"
  5714. foreach(item,itemList)
  5715. {
  5716. int nextX= x+item->sizeHint().width()+spacing();
  5717. int right= x+item->sizeHint().width();
  5718. if(item==itemList.last())
  5719. {
  5720. right= rect.right();
  5721. }
  5722. int bottom= rect.bottom();
  5723. if(!testOnly)
  5724. {
  5725. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5726. }
  5727. x= nextX;
  5728. }
  5729. /*:501*/
  5730. #line 11371 "./typica.w"
  5731. }
  5732. else
  5733. {
  5734. /*502:*/
  5735. #line 11406 "./typica.w"
  5736. foreach(item,itemList)
  5737. {
  5738. int nextY= y+item->sizeHint().height()+spacing();
  5739. int bottom= y+item->sizeHint().height();
  5740. if(item==itemList.last())
  5741. {
  5742. bottom= rect.bottom();
  5743. }
  5744. int right= rect.right();
  5745. if(!testOnly)
  5746. {
  5747. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5748. }
  5749. y= nextY;
  5750. }
  5751. /*:502*/
  5752. #line 11375 "./typica.w"
  5753. }
  5754. return y;
  5755. }
  5756. /*:500*//*503:*/
  5757. #line 11430 "./typica.w"
  5758. QSize PackLayout::minimumSize()const
  5759. {
  5760. QSize size;
  5761. QLayoutItem*item;
  5762. foreach(item,itemList)
  5763. {
  5764. if(orientation==Qt::Horizontal)
  5765. {
  5766. size+= QSize(item->minimumSize().width(),0);
  5767. if(size.height()<item->minimumSize().height())
  5768. {
  5769. size.setHeight(item->minimumSize().height());
  5770. }
  5771. }
  5772. else
  5773. {
  5774. size+= QSize(0,item->minimumSize().height());
  5775. if(size.width()<item->minimumSize().width())
  5776. {
  5777. size.setWidth(item->minimumSize().width());
  5778. }
  5779. }
  5780. }
  5781. size+= QSize(2*margin(),2*margin());
  5782. return size;
  5783. }
  5784. /*:503*//*504:*/
  5785. #line 11462 "./typica.w"
  5786. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5787. QLayout(parent)
  5788. {
  5789. setMargin(margin);
  5790. setSpacing(spacing);
  5791. setOrientation(Qt::Horizontal);
  5792. }
  5793. PackLayout::PackLayout(int spacing)
  5794. {
  5795. setSpacing(spacing);
  5796. setOrientation(Qt::Horizontal);
  5797. }
  5798. /*:504*//*505:*/
  5799. #line 11480 "./typica.w"
  5800. PackLayout::~PackLayout()
  5801. {
  5802. QLayoutItem*item;
  5803. while((item= takeAt(0)))
  5804. {
  5805. delete item;
  5806. }
  5807. }
  5808. /*:505*//*506:*/
  5809. #line 11494 "./typica.w"
  5810. QLayoutItem*PackLayout::takeAt(int index)
  5811. {
  5812. if(index>=0&&index<itemList.size())
  5813. {
  5814. return itemList.takeAt(index);
  5815. }
  5816. else
  5817. {
  5818. return NULL;
  5819. }
  5820. }
  5821. /*:506*//*507:*/
  5822. #line 11510 "./typica.w"
  5823. QLayoutItem*PackLayout::itemAt(int index)const
  5824. {
  5825. if(index>=0&&index<itemList.size())
  5826. {
  5827. return itemList.at(index);
  5828. }
  5829. else
  5830. {
  5831. return NULL;
  5832. }
  5833. }
  5834. /*:507*//*508:*/
  5835. #line 11533 "./typica.w"
  5836. void PackLayout::addItem(QLayoutItem*item)
  5837. {
  5838. itemList.append(item);
  5839. }
  5840. /*:508*//*509:*/
  5841. #line 11541 "./typica.w"
  5842. int PackLayout::count()const
  5843. {
  5844. return itemList.size();
  5845. }
  5846. /*:509*//*510:*/
  5847. #line 11553 "./typica.w"
  5848. Qt::Orientations PackLayout::expandingDirections()const
  5849. {
  5850. return Qt::Vertical|Qt::Horizontal;
  5851. }
  5852. bool PackLayout::hasHeightForWidth()const
  5853. {
  5854. return false;
  5855. }
  5856. int PackLayout::heightForWidth(int width)const
  5857. {
  5858. return doLayout(QRect(0,0,width,0),true);
  5859. }
  5860. void PackLayout::setGeometry(const QRect&rect)
  5861. {
  5862. QLayout::setGeometry(rect);
  5863. doLayout(rect,false);
  5864. }
  5865. QSize PackLayout::sizeHint()const
  5866. {
  5867. return minimumSize();
  5868. }
  5869. /*:510*//*511:*/
  5870. #line 11584 "./typica.w"
  5871. void PackLayout::setOrientation(Qt::Orientations direction)
  5872. {
  5873. orientation= direction;
  5874. doLayout(geometry(),false);
  5875. }
  5876. /*:511*/
  5877. #line 554 "./typica.w"
  5878. /*513:*/
  5879. #line 11623 "./typica.w"
  5880. SceneButton::SceneButton():QGraphicsScene()
  5881. {
  5882. }
  5883. SceneButton::~SceneButton()
  5884. {
  5885. }
  5886. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5887. {
  5888. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5889. }
  5890. /*:513*/
  5891. #line 555 "./typica.w"
  5892. /*515:*/
  5893. #line 11669 "./typica.w"
  5894. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5895. Qt::Orientations orientation,
  5896. QWidget*parent,Qt::WindowFlags f):
  5897. QWidget(parent,f),label(new QGraphicsView()),
  5898. scene(new SceneButton())
  5899. {
  5900. layout= new PackLayout(this);
  5901. layout->setOrientation(orientation);
  5902. /*516:*/
  5903. #line 11689 "./typica.w"
  5904. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5905. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5906. label->setFrameShape(QFrame::NoFrame);
  5907. label->setInteractive(true);
  5908. /*:516*/
  5909. #line 11678 "./typica.w"
  5910. /*517:*/
  5911. #line 11700 "./typica.w"
  5912. scene->setBackgroundBrush(Qt::cyan);
  5913. text= scene->addText(labeltext);
  5914. if(orientation==Qt::Horizontal)
  5915. {
  5916. text->rotate(270.0);
  5917. }
  5918. label->setScene(scene);
  5919. /*:517*/
  5920. #line 11679 "./typica.w"
  5921. /*518:*/
  5922. #line 11718 "./typica.w"
  5923. if(orientation==Qt::Horizontal)
  5924. {
  5925. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5926. }
  5927. else
  5928. {
  5929. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5930. }
  5931. label->centerOn(text);
  5932. /*:518*/
  5933. #line 11680 "./typica.w"
  5934. /*519:*/
  5935. #line 11733 "./typica.w"
  5936. layout->addWidget(label);
  5937. layout->addWidget(widget);
  5938. if(orientation==Qt::Horizontal)
  5939. {
  5940. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5941. widget->sizeHint().height());
  5942. }
  5943. else
  5944. {
  5945. setMinimumSize(widget->sizeHint().width(),
  5946. widget->sizeHint().height()+label->sizeHint().height());
  5947. }
  5948. /*:519*/
  5949. #line 11681 "./typica.w"
  5950. }
  5951. /*:515*//*520:*/
  5952. #line 11750 "./typica.w"
  5953. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5954. {
  5955. scene->setBackgroundBrush(background);
  5956. }
  5957. void WidgetDecorator::setTextColor(QColor color)
  5958. {
  5959. text->setDefaultTextColor(color);
  5960. }
  5961. /*:520*//*521:*/
  5962. #line 11763 "./typica.w"
  5963. WidgetDecorator::~WidgetDecorator()
  5964. {
  5965. }
  5966. /*:521*/
  5967. #line 556 "./typica.w"
  5968. /*526:*/
  5969. #line 11862 "./typica.w"
  5970. void LogEditWindow::addTheRows()
  5971. {
  5972. QTime s= startTime->time();
  5973. while(s<endTime->time())
  5974. {
  5975. model->newMeasurement(Measurement(0,s),1);
  5976. s= s.addSecs(interval->value());
  5977. }
  5978. model->newMeasurement(Measurement(0,endTime->time()),1);
  5979. }
  5980. /*:526*//*527:*/
  5981. #line 11876 "./typica.w"
  5982. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5983. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5984. addRowsLayout(new QHBoxLayout(NULL)),
  5985. startTimeLabel(new QLabel("Start Time")),
  5986. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5987. endTimeLabel(new QLabel("End Time")),
  5988. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5989. intervalLabel(new QLabel("Interval (seconds)")),
  5990. interval(new QSpinBox()),
  5991. addRows(new QPushButton("Add Rows")),
  5992. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5993. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5994. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5995. model(new MeasurementModel()),
  5996. log(new QTableView())
  5997. {
  5998. /*528:*/
  5999. #line 11913 "./typica.w"
  6000. QSettings settings;
  6001. resize(settings.value("logSize",QSize(620,400)).toSize());
  6002. move(settings.value("logPos",QPoint(200,60)).toPoint());
  6003. /*:528*/
  6004. #line 11893 "./typica.w"
  6005. /*529:*/
  6006. #line 11926 "./typica.w"
  6007. mainLayout->setOrientation(Qt::Vertical);
  6008. addRowsLayout->addSpacing(10);
  6009. addRowsLayout->addWidget(startTimeLabel);
  6010. addRowsLayout->addWidget(startTime);
  6011. addRowsLayout->addSpacing(10);
  6012. startTime->setDisplayFormat("mm:ss");
  6013. addRowsLayout->addWidget(endTimeLabel);
  6014. addRowsLayout->addWidget(endTime);
  6015. addRowsLayout->addSpacing(10);
  6016. endTime->setDisplayFormat("mm:ss");
  6017. addRowsLayout->addWidget(intervalLabel);
  6018. addRowsLayout->addWidget(interval);
  6019. addRowsLayout->addSpacing(10);
  6020. interval->setRange(0,60);
  6021. interval->setValue(30);
  6022. addRowsLayout->addWidget(addRows);
  6023. addRowsLayout->addSpacing(10);
  6024. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  6025. /*:529*/
  6026. #line 11894 "./typica.w"
  6027. /*530:*/
  6028. #line 11949 "./typica.w"
  6029. model->setHeaderData(0,Qt::Horizontal,"Time");
  6030. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  6031. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  6032. model->clear();
  6033. /*:530*/
  6034. #line 11895 "./typica.w"
  6035. /*531:*/
  6036. #line 11958 "./typica.w"
  6037. log->setModel(model);
  6038. log->setColumnWidth(0,100);
  6039. log->setColumnWidth(1,100);
  6040. log->setColumnWidth(2,100);
  6041. /*:531*/
  6042. #line 11896 "./typica.w"
  6043. mainLayout->addItem(addRowsLayout);
  6044. mainLayout->addWidget(log);
  6045. centralWidget->setLayout(mainLayout);
  6046. setCentralWidget(centralWidget);
  6047. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  6048. fileMenu->addAction(openXml);
  6049. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  6050. fileMenu->addAction(saveXml);
  6051. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6052. fileMenu->addAction(saveCsv);
  6053. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6054. }
  6055. /*:527*//*532:*/
  6056. #line 11969 "./typica.w"
  6057. void LogEditWindow::saveXML()
  6058. {
  6059. QSettings settings;
  6060. QString lastDir= settings.value("lastDirectory").toString();
  6061. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6062. lastDir,"",0);
  6063. QFile file(filename);
  6064. XMLOutput writer(model,&file,0);
  6065. writer.addTemperatureColumn("Temperature",1);
  6066. writer.addAnnotationColumn("Annotation",2);
  6067. if(writer.output())
  6068. {
  6069. QFileInfo info(filename);
  6070. QDir directory= info.dir();
  6071. lastDir= directory.path();
  6072. settings.setValue("lastDirectory",lastDir);
  6073. }
  6074. }
  6075. void LogEditWindow::saveCSV()
  6076. {
  6077. QSettings settings;
  6078. QString lastDir= settings.value("lastDirectory").toString();
  6079. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6080. lastDir,"",0);
  6081. QFile file(filename);
  6082. CSVOutput writer(model,&file,0);
  6083. writer.addTemperatureColumn("Temperature",1);
  6084. writer.addAnnotationColumn("Annotation",2);
  6085. if(writer.output())
  6086. {
  6087. QFileInfo info(filename);
  6088. QDir directory= info.dir();
  6089. lastDir= directory.path();
  6090. settings.setValue("lastDirectory",lastDir);
  6091. }
  6092. }
  6093. /*:532*//*533:*/
  6094. #line 12012 "./typica.w"
  6095. void LogEditWindow::openXML()
  6096. {
  6097. QSettings settings;
  6098. QString lastDir= settings.value("lastDirectory").toString();
  6099. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6100. lastDir,"",0);
  6101. if(filename.isNull())
  6102. {
  6103. return;
  6104. }
  6105. QFile file(filename);
  6106. XMLInput reader(&file,1);
  6107. connect(&reader,SIGNAL(measure(Measurement,int)),
  6108. model,SLOT(newMeasurement(Measurement,int)));
  6109. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6110. model,SLOT(newAnnotation(QString,int,int)));
  6111. if(reader.input())
  6112. {
  6113. QFileInfo info(filename);
  6114. setWindowTitle(QString(tr("%1 - %2")).
  6115. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6116. QDir directory= info.dir();
  6117. lastDir= directory.path();
  6118. settings.setValue("lastDirectory",lastDir);
  6119. }
  6120. }
  6121. /*:533*//*534:*/
  6122. #line 12043 "./typica.w"
  6123. void LogEditWindow::closeEvent(QCloseEvent*event)
  6124. {
  6125. QSettings settings;
  6126. settings.setValue("logSize",size());
  6127. settings.setValue("logPos",pos());
  6128. event->accept();
  6129. }
  6130. /*:534*/
  6131. #line 557 "./typica.w"
  6132. /*540:*/
  6133. #line 12158 "./typica.w"
  6134. bool XMLOutput::output()
  6135. {
  6136. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6137. {
  6138. return false;
  6139. }
  6140. QXmlStreamWriter xmlout(out);
  6141. xmlout.writeStartDocument("1.0");
  6142. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6143. xmlout.writeStartElement("roastlog");
  6144. /*541:*/
  6145. #line 12191 "./typica.w"
  6146. foreach(int c,temperatureColumns.keys())
  6147. {
  6148. xmlout.writeStartElement("tempseries");
  6149. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6150. xmlout.writeEndElement();
  6151. }
  6152. foreach(int c,controlColumns.keys())
  6153. {
  6154. xmlout.writeStartElement("controlseries");
  6155. xmlout.writeAttribute("name",controlColumns.value(c));
  6156. xmlout.writeEndElement();
  6157. }
  6158. foreach(int c,annotationColumns.keys())
  6159. {
  6160. xmlout.writeStartElement("noteseries");
  6161. xmlout.writeAttribute("name",annotationColumns.value(c));
  6162. xmlout.writeEndElement();
  6163. }
  6164. /*:541*/
  6165. #line 12169 "./typica.w"
  6166. xmlout.writeStartElement("roast");
  6167. bool oresult;
  6168. for(int i= 0;i<data->rowCount();i++)
  6169. {
  6170. /*542:*/
  6171. #line 12216 "./typica.w"
  6172. oresult= false;
  6173. foreach(int c,temperatureColumns.keys())
  6174. {
  6175. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6176. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6177. {
  6178. oresult= true;
  6179. break;
  6180. }
  6181. }
  6182. foreach(int c,controlColumns.keys())
  6183. {
  6184. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6185. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6186. {
  6187. oresult= true;
  6188. break;
  6189. }
  6190. }
  6191. if(oresult==false)
  6192. {
  6193. foreach(int c,annotationColumns.keys())
  6194. {
  6195. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6196. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6197. isEmpty()))
  6198. {
  6199. oresult= true;
  6200. break;
  6201. }
  6202. }
  6203. }
  6204. /*:542*/
  6205. #line 12174 "./typica.w"
  6206. if(oresult)
  6207. {
  6208. /*543:*/
  6209. #line 12255 "./typica.w"
  6210. xmlout.writeStartElement("tuple");
  6211. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6212. Qt::DisplayRole).toString());
  6213. foreach(int c,temperatureColumns.keys())
  6214. {
  6215. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6216. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6217. {
  6218. xmlout.writeStartElement("temperature");
  6219. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6220. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6221. {
  6222. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6223. {
  6224. xmlout.writeAttribute("relative","true");
  6225. }
  6226. }
  6227. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6228. toString());
  6229. xmlout.writeEndElement();
  6230. }
  6231. }
  6232. foreach(int c,controlColumns.keys())
  6233. {
  6234. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6235. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6236. {
  6237. xmlout.writeStartElement("control");
  6238. xmlout.writeAttribute("series",controlColumns.value(c));
  6239. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6240. xmlout.writeEndElement();
  6241. }
  6242. }
  6243. foreach(int c,annotationColumns.keys())
  6244. {
  6245. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6246. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6247. {
  6248. xmlout.writeStartElement("annotation");
  6249. xmlout.writeAttribute("series",annotationColumns.value(c));
  6250. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6251. toString());
  6252. xmlout.writeEndElement();
  6253. }
  6254. }
  6255. xmlout.writeEndElement();
  6256. /*:543*/
  6257. #line 12177 "./typica.w"
  6258. }
  6259. }
  6260. xmlout.writeEndElement();
  6261. xmlout.writeEndElement();
  6262. xmlout.writeEndDocument();
  6263. out->close();
  6264. return true;
  6265. }
  6266. /*:540*//*544:*/
  6267. #line 12305 "./typica.w"
  6268. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6269. :QObject(NULL),data(model),out(device),time(timec)
  6270. {
  6271. }
  6272. void XMLOutput::setModel(MeasurementModel*model)
  6273. {
  6274. data= model;
  6275. }
  6276. void XMLOutput::setTimeColumn(int column)
  6277. {
  6278. time= column;
  6279. }
  6280. void XMLOutput::setDevice(QIODevice*device)
  6281. {
  6282. out= device;
  6283. }
  6284. /*:544*//*545:*/
  6285. #line 12334 "./typica.w"
  6286. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6287. {
  6288. temperatureColumns.insert(column,series);
  6289. }
  6290. void XMLOutput::addControlColumn(const QString&series,int column)
  6291. {
  6292. controlColumns.insert(column,series);
  6293. }
  6294. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6295. {
  6296. annotationColumns.insert(column,series);
  6297. }
  6298. /*:545*/
  6299. #line 558 "./typica.w"
  6300. /*547:*/
  6301. #line 12391 "./typica.w"
  6302. bool XMLInput::input()
  6303. {
  6304. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6305. {
  6306. return false;
  6307. }
  6308. QXmlStreamReader xmlin(in);
  6309. QMap<QString,int> temperatureColumns;
  6310. QMap<QString,int> annotationColumns;
  6311. int nextColumn= firstc;
  6312. /*548:*/
  6313. #line 12422 "./typica.w"
  6314. while(!xmlin.isDTD())
  6315. {
  6316. xmlin.readNext();
  6317. }
  6318. if(xmlin.isDTD())
  6319. {
  6320. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6321. {
  6322. /*549:*/
  6323. #line 12444 "./typica.w"
  6324. emit newTemperatureColumn(firstc,"Bean");
  6325. emit newAnnotationColumn(firstc+1,"Note");
  6326. emit lastColumn(firstc+1);
  6327. /*:549*/
  6328. #line 12431 "./typica.w"
  6329. }
  6330. else
  6331. {
  6332. xmlin.readNext();
  6333. /*550:*/
  6334. #line 12453 "./typica.w"
  6335. while(xmlin.name()!="roast")
  6336. {
  6337. if(xmlin.isStartElement())
  6338. {
  6339. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6340. {
  6341. temperatureColumns.insert(xmlin.attributes().value("name").
  6342. toString(),
  6343. nextColumn);
  6344. emit newTemperatureColumn(nextColumn,
  6345. xmlin.attributes().value("name").
  6346. toString());
  6347. nextColumn++;
  6348. }
  6349. else if(xmlin.name()=="noteseries")
  6350. {
  6351. annotationColumns.insert(xmlin.attributes().value("name").
  6352. toString(),nextColumn);
  6353. emit newAnnotationColumn(nextColumn,
  6354. xmlin.attributes().value("name").
  6355. toString());
  6356. nextColumn++;
  6357. }
  6358. }
  6359. xmlin.readNext();
  6360. }
  6361. emit lastColumn(nextColumn-1);
  6362. /*:550*/
  6363. #line 12436 "./typica.w"
  6364. }
  6365. }
  6366. /*:548*/
  6367. #line 12402 "./typica.w"
  6368. QTime timeval= QTime();
  6369. double tempval= 0;
  6370. QString noteval= QString();
  6371. int column;
  6372. int counter= 0;
  6373. while(!xmlin.atEnd())
  6374. {
  6375. /*551:*/
  6376. #line 12494 "./typica.w"
  6377. xmlin.readNext();
  6378. if(xmlin.isStartElement())
  6379. {
  6380. /*552:*/
  6381. #line 12520 "./typica.w"
  6382. if(xmlin.name()=="time")
  6383. {
  6384. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6385. }
  6386. else if(xmlin.name()=="temperature")
  6387. {
  6388. column= xmlin.attributes().hasAttribute("series")?
  6389. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6390. bool relative= (xmlin.attributes().value("relative")=="true");
  6391. tempval= xmlin.readElementText().toDouble();
  6392. Measurement measurement(tempval,timeval);
  6393. if(relative)
  6394. {
  6395. measurement.insert("relative",true);
  6396. }
  6397. emit measure(measurement,column);
  6398. }
  6399. else if(xmlin.name()=="control")
  6400. {
  6401. column= xmlin.attributes().value("series").toString().isEmpty()?
  6402. firstc:temperatureColumns.value(xmlin.attributes().
  6403. value("series").toString());
  6404. tempval= xmlin.readElementText().toDouble();
  6405. Measurement measurement(tempval,timeval,Units::Unitless);
  6406. emit measure(measurement,column);
  6407. }
  6408. else if(xmlin.name()=="annotation")
  6409. {
  6410. column= xmlin.attributes().value("series").toString().isEmpty()?
  6411. firstc+1:annotationColumns.value(xmlin.attributes().
  6412. value("series").toString());
  6413. noteval= xmlin.readElementText();
  6414. if(!noteval.isEmpty())
  6415. {
  6416. emit annotation(noteval,firstc,column);
  6417. }
  6418. }
  6419. /*:552*/
  6420. #line 12498 "./typica.w"
  6421. }
  6422. counter++;
  6423. if(counter%100==0)
  6424. {
  6425. QCoreApplication::processEvents();
  6426. }
  6427. /*:551*/
  6428. #line 12410 "./typica.w"
  6429. }
  6430. return true;
  6431. }
  6432. /*:547*//*553:*/
  6433. #line 12561 "./typica.w"
  6434. XMLInput::XMLInput(QIODevice*input,int c):
  6435. firstc(c),in(input)
  6436. {
  6437. }
  6438. void XMLInput::setFirstColumn(int column)
  6439. {
  6440. firstc= column;
  6441. }
  6442. void XMLInput::setDevice(QIODevice*device)
  6443. {
  6444. in= device;
  6445. }
  6446. /*:553*/
  6447. #line 559 "./typica.w"
  6448. /*558:*/
  6449. #line 12652 "./typica.w"
  6450. bool CSVOutput::output()
  6451. {
  6452. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6453. {
  6454. return false;
  6455. }
  6456. QTextStream output(out);
  6457. /*559:*/
  6458. #line 12676 "./typica.w"
  6459. output<<"Time";
  6460. foreach(int c,temperatureColumns.keys())
  6461. {
  6462. output<<','<<temperatureColumns.value(c);
  6463. }
  6464. foreach(int c,controlColumns.keys())
  6465. {
  6466. output<<','<<controlColumns.value(c);
  6467. }
  6468. foreach(int c,annotationColumns.keys())
  6469. {
  6470. output<<','<<annotationColumns.value(c);
  6471. }
  6472. output<<'\n';
  6473. /*:559*/
  6474. #line 12660 "./typica.w"
  6475. bool oresult;
  6476. for(int i= 0;i<data->rowCount();i++)
  6477. {
  6478. /*542:*/
  6479. #line 12216 "./typica.w"
  6480. oresult= false;
  6481. foreach(int c,temperatureColumns.keys())
  6482. {
  6483. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6484. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6485. {
  6486. oresult= true;
  6487. break;
  6488. }
  6489. }
  6490. foreach(int c,controlColumns.keys())
  6491. {
  6492. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6493. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6494. {
  6495. oresult= true;
  6496. break;
  6497. }
  6498. }
  6499. if(oresult==false)
  6500. {
  6501. foreach(int c,annotationColumns.keys())
  6502. {
  6503. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6504. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6505. isEmpty()))
  6506. {
  6507. oresult= true;
  6508. break;
  6509. }
  6510. }
  6511. }
  6512. /*:542*/
  6513. #line 12664 "./typica.w"
  6514. if(oresult)
  6515. {
  6516. /*560:*/
  6517. #line 12701 "./typica.w"
  6518. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6519. foreach(int c,temperatureColumns.keys())
  6520. {
  6521. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6522. }
  6523. foreach(int c,controlColumns.keys())
  6524. {
  6525. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6526. }
  6527. foreach(int c,annotationColumns.keys())
  6528. {
  6529. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6530. }
  6531. output<<'\n';
  6532. /*:560*/
  6533. #line 12667 "./typica.w"
  6534. }
  6535. }
  6536. out->close();
  6537. return true;
  6538. }
  6539. /*:558*//*561:*/
  6540. #line 12720 "./typica.w"
  6541. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6542. data(model),out(device),time(timec)
  6543. {
  6544. }
  6545. void CSVOutput::setModel(MeasurementModel*model)
  6546. {
  6547. data= model;
  6548. }
  6549. void CSVOutput::setTimeColumn(int column)
  6550. {
  6551. time= column;
  6552. }
  6553. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6554. {
  6555. temperatureColumns.insert(column,series);
  6556. }
  6557. void CSVOutput::addControlColumn(const QString&series,int column)
  6558. {
  6559. controlColumns.insert(column,series);
  6560. }
  6561. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6562. {
  6563. annotationColumns.insert(column,series);
  6564. }
  6565. void CSVOutput::setDevice(QIODevice*device)
  6566. {
  6567. out= device;
  6568. }
  6569. #line 1 "./webview.w"
  6570. /*:561*/
  6571. #line 560 "./typica.w"
  6572. /*606:*/
  6573. #line 12983 "./typica.w"
  6574. QString SaltModel::arrayLiteral(int column,int role)const
  6575. {
  6576. QString literal= "'{";
  6577. for(int i= 0;i<rowCount();i++)
  6578. {
  6579. QString datum= data(index(i,column),role).toString();
  6580. if(!datum.isEmpty())
  6581. {
  6582. literal.append(datum);
  6583. literal.append(", ");
  6584. }
  6585. }
  6586. if(literal.size()> 2)
  6587. {
  6588. literal.chop(2);
  6589. }
  6590. literal.append("}'");
  6591. return literal;
  6592. }
  6593. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6594. {
  6595. QString literal= "'{";
  6596. for(int i= 0;i<rowCount();i++)
  6597. {
  6598. QString datum= data(index(i,column),role).toString();
  6599. if(!datum.isEmpty())
  6600. {
  6601. literal.append("\"");
  6602. literal.append(datum);
  6603. literal.append("\", ");
  6604. }
  6605. }
  6606. if(literal.size()> 2)
  6607. {
  6608. literal.chop(2);
  6609. }
  6610. literal.append("}'");
  6611. return literal;
  6612. }
  6613. /*:606*//*607:*/
  6614. #line 13027 "./typica.w"
  6615. QModelIndex SaltModel::parent(const QModelIndex&)const
  6616. {
  6617. return QModelIndex();
  6618. }
  6619. /*:607*//*608:*/
  6620. #line 13046 "./typica.w"
  6621. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6622. int role)
  6623. {
  6624. /*609:*/
  6625. #line 13077 "./typica.w"
  6626. bool valid= false;
  6627. if(index.isValid())
  6628. {
  6629. if(index.row()<modelData.size())
  6630. {
  6631. if(index.column()<colcount)
  6632. {
  6633. valid= true;
  6634. }
  6635. }
  6636. }
  6637. /*:609*/
  6638. #line 13050 "./typica.w"
  6639. if(!valid)
  6640. {
  6641. return false;
  6642. }
  6643. if(index.row()==modelData.size()-1)
  6644. {
  6645. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6646. /*610:*/
  6647. #line 13093 "./typica.w"
  6648. QList<QMap<int,QVariant> > newRow;
  6649. QMap<int,QVariant> defaults;
  6650. for(int i= 0;i<colcount;i++)
  6651. {
  6652. newRow.append(defaults);
  6653. }
  6654. modelData.append(newRow);
  6655. /*:610*/
  6656. #line 13058 "./typica.w"
  6657. endInsertRows();
  6658. }
  6659. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6660. QMap<int,QVariant> cell= row.at(index.column());
  6661. cell.insert(role,value);
  6662. if(role==Qt::EditRole)
  6663. {
  6664. cell.insert(Qt::DisplayRole,value);
  6665. }
  6666. row.replace(index.column(),cell);
  6667. modelData.replace(index.row(),row);
  6668. emit dataChanged(index,index);
  6669. return true;
  6670. }
  6671. /*:608*//*611:*/
  6672. #line 13104 "./typica.w"
  6673. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6674. {
  6675. for(int i= 0;i<columns;i++)
  6676. {
  6677. hData<<"";
  6678. }
  6679. /*610:*/
  6680. #line 13093 "./typica.w"
  6681. QList<QMap<int,QVariant> > newRow;
  6682. QMap<int,QVariant> defaults;
  6683. for(int i= 0;i<colcount;i++)
  6684. {
  6685. newRow.append(defaults);
  6686. }
  6687. modelData.append(newRow);
  6688. /*:610*/
  6689. #line 13111 "./typica.w"
  6690. }
  6691. /*:611*//*612:*/
  6692. #line 13116 "./typica.w"
  6693. SaltModel::~SaltModel()
  6694. {
  6695. }
  6696. /*:612*//*613:*/
  6697. #line 13126 "./typica.w"
  6698. int SaltModel::rowCount(const QModelIndex&parent)const
  6699. {
  6700. return(parent==QModelIndex()?modelData.size():0);
  6701. }
  6702. int SaltModel::columnCount(const QModelIndex&parent)const
  6703. {
  6704. return(parent==QModelIndex()?colcount:0);
  6705. }
  6706. /*:613*//*614:*/
  6707. #line 13139 "./typica.w"
  6708. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6709. const QVariant&value,int)
  6710. {
  6711. if(orientation==Qt::Horizontal&&section<colcount)
  6712. {
  6713. hData.replace(section,value.toString());
  6714. emit headerDataChanged(orientation,section,section);
  6715. return true;
  6716. }
  6717. return false;
  6718. }
  6719. /*:614*//*615:*/
  6720. #line 13154 "./typica.w"
  6721. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6722. {
  6723. /*609:*/
  6724. #line 13077 "./typica.w"
  6725. bool valid= false;
  6726. if(index.isValid())
  6727. {
  6728. if(index.row()<modelData.size())
  6729. {
  6730. if(index.column()<colcount)
  6731. {
  6732. valid= true;
  6733. }
  6734. }
  6735. }
  6736. /*:609*/
  6737. #line 13157 "./typica.w"
  6738. if(!valid)
  6739. {
  6740. return QVariant();
  6741. }
  6742. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6743. QMap<int,QVariant> cell= row.at(index.column());
  6744. return cell.value(role,QVariant());
  6745. }
  6746. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6747. int role)const
  6748. {
  6749. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6750. section<colcount)
  6751. {
  6752. return QVariant(hData.at(section));
  6753. }
  6754. return QVariant();
  6755. }
  6756. /*:615*//*616:*/
  6757. #line 13181 "./typica.w"
  6758. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6759. {
  6760. /*609:*/
  6761. #line 13077 "./typica.w"
  6762. bool valid= false;
  6763. if(index.isValid())
  6764. {
  6765. if(index.row()<modelData.size())
  6766. {
  6767. if(index.column()<colcount)
  6768. {
  6769. valid= true;
  6770. }
  6771. }
  6772. }
  6773. /*:609*/
  6774. #line 13184 "./typica.w"
  6775. if(valid)
  6776. {
  6777. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6778. }
  6779. return 0;
  6780. }
  6781. /*:616*//*617:*/
  6782. #line 13195 "./typica.w"
  6783. QModelIndex SaltModel::index(int row,int column,
  6784. const QModelIndex&parent)const
  6785. {
  6786. if(parent==QModelIndex())
  6787. {
  6788. if(row<modelData.size()&&column<colcount)
  6789. {
  6790. return createIndex(row,column);
  6791. }
  6792. }
  6793. return QModelIndex();
  6794. }
  6795. /*:617*//*618:*/
  6796. #line 13213 "./typica.w"
  6797. void SaltModel::clear()
  6798. {
  6799. beginResetModel();
  6800. modelData.clear();
  6801. /*610:*/
  6802. #line 13093 "./typica.w"
  6803. QList<QMap<int,QVariant> > newRow;
  6804. QMap<int,QVariant> defaults;
  6805. for(int i= 0;i<colcount;i++)
  6806. {
  6807. newRow.append(defaults);
  6808. }
  6809. modelData.append(newRow);
  6810. /*:610*/
  6811. #line 13218 "./typica.w"
  6812. endResetModel();
  6813. }
  6814. /*:618*//*619:*/
  6815. #line 13227 "./typica.w"
  6816. bool SaltModel::removeRows(int row,int count,
  6817. const QModelIndex&parent)
  6818. {
  6819. if(parent==QModelIndex())
  6820. {
  6821. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6822. {
  6823. beginRemoveRows(parent,row,row+count-1);
  6824. for(int i= 0;i<count;i++)
  6825. {
  6826. modelData.removeAt(row);
  6827. }
  6828. endRemoveRows();
  6829. if(modelData.size()==0)
  6830. {
  6831. beginInsertRows(parent,0,0);
  6832. /*610:*/
  6833. #line 13093 "./typica.w"
  6834. QList<QMap<int,QVariant> > newRow;
  6835. QMap<int,QVariant> defaults;
  6836. for(int i= 0;i<colcount;i++)
  6837. {
  6838. newRow.append(defaults);
  6839. }
  6840. modelData.append(newRow);
  6841. /*:610*/
  6842. #line 13244 "./typica.w"
  6843. endInsertRows();
  6844. }
  6845. return true;
  6846. }
  6847. }
  6848. return false;
  6849. }
  6850. /*:619*//*620:*/
  6851. #line 13258 "./typica.w"
  6852. int SaltModel::findData(const QVariant&value,int column,int role)
  6853. {
  6854. for(int i= 0;i<modelData.size();i++)
  6855. {
  6856. if(modelData.at(i).size()> column)
  6857. {
  6858. if(modelData.at(i).at(column).contains(role))
  6859. {
  6860. if(modelData.at(i).at(column).value(role)==value)
  6861. {
  6862. return i;
  6863. }
  6864. }
  6865. }
  6866. }
  6867. return-1;
  6868. }
  6869. /*:620*/
  6870. #line 561 "./typica.w"
  6871. /*622:*/
  6872. #line 13322 "./typica.w"
  6873. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6874. {
  6875. SqlComboBox*widget= new SqlComboBox();
  6876. widget->setParent(parent);
  6877. for(int i= 0;i<count();i++)
  6878. {
  6879. widget->addItem(itemText(i),itemData(i));
  6880. }
  6881. return widget;
  6882. }
  6883. /*:622*//*623:*/
  6884. #line 13339 "./typica.w"
  6885. void SqlComboBox::showData(bool show)
  6886. {
  6887. dataColumnShown= show;
  6888. }
  6889. /*:623*//*624:*/
  6890. #line 13353 "./typica.w"
  6891. void SqlComboBox::addNullOption()
  6892. {
  6893. addItem(specialNullText,specialNullData);
  6894. }
  6895. void SqlComboBox::setNullText(QString nullText)
  6896. {
  6897. specialNullText= nullText;
  6898. }
  6899. void SqlComboBox::setNullData(QVariant nullData)
  6900. {
  6901. specialNullData= nullData;
  6902. }
  6903. /*:624*//*625:*/
  6904. #line 13376 "./typica.w"
  6905. void SqlComboBox::setDataColumn(int column)
  6906. {
  6907. dataColumn= column;
  6908. }
  6909. void SqlComboBox::setDisplayColumn(int column)
  6910. {
  6911. displayColumn= column;
  6912. }
  6913. /*:625*//*626:*/
  6914. #line 13390 "./typica.w"
  6915. void SqlComboBox::addSqlOptions(QString query)
  6916. {
  6917. SqlQueryConnection h;
  6918. QSqlQuery*dbquery= h.operator->();
  6919. if(!dbquery->exec(query))
  6920. {
  6921. QSqlError error= dbquery->lastError();
  6922. qDebug()<<error.databaseText();
  6923. qDebug()<<error.driverText();
  6924. qDebug()<<error.text();
  6925. qDebug()<<dbquery->lastQuery();
  6926. }
  6927. while(dbquery->next())
  6928. {
  6929. QString displayValue(dbquery->value(displayColumn).toString());
  6930. QString dataValue(dbquery->value(dataColumn).toString());
  6931. if(dataColumnShown)
  6932. {
  6933. displayValue.append(QString(" (%1)").arg(dataValue));
  6934. }
  6935. addItem(displayValue,dataValue);
  6936. }
  6937. }
  6938. /*:626*//*627:*/
  6939. #line 13426 "./typica.w"
  6940. SqlComboBox::SqlComboBox():
  6941. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6942. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6943. {
  6944. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6945. }
  6946. SqlComboBox::~SqlComboBox()
  6947. {
  6948. }
  6949. /*:627*/
  6950. #line 562 "./typica.w"
  6951. /*629:*/
  6952. #line 13465 "./typica.w"
  6953. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6954. {
  6955. delegate= widget;
  6956. }
  6957. /*:629*//*630:*/
  6958. #line 13474 "./typica.w"
  6959. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6960. const QStyleOptionViewItem&,
  6961. const QModelIndex&)const
  6962. {
  6963. return delegate->clone(parent);
  6964. }
  6965. /*:630*//*631:*/
  6966. #line 13485 "./typica.w"
  6967. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6968. const QModelIndex&index)const
  6969. {
  6970. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6971. self->setCurrentIndex(self->findData(
  6972. index.model()->data(index,
  6973. Qt::UserRole).toString()));
  6974. }
  6975. /*:631*//*632:*/
  6976. #line 13498 "./typica.w"
  6977. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6978. QAbstractItemModel*model,
  6979. const QModelIndex&index)const
  6980. {
  6981. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6982. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6983. Qt::UserRole);
  6984. model->setData(index,self->currentText(),Qt::DisplayRole);
  6985. }
  6986. /*:632*//*633:*/
  6987. #line 13511 "./typica.w"
  6988. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6989. const QStyleOptionViewItem&option,
  6990. const QModelIndex&)const
  6991. {
  6992. editor->setGeometry(option.rect);
  6993. }
  6994. /*:633*//*634:*/
  6995. #line 13522 "./typica.w"
  6996. QSize SqlComboBoxDelegate::sizeHint()const
  6997. {
  6998. return delegate->sizeHint();
  6999. }
  7000. /*:634*//*635:*/
  7001. #line 13530 "./typica.w"
  7002. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  7003. :QItemDelegate(parent)
  7004. {
  7005. }
  7006. /*:635*/
  7007. #line 563 "./typica.w"
  7008. /*598:*/
  7009. #line 12792 "./typica.w"
  7010. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  7011. {
  7012. /*599:*/
  7013. #line 12807 "./typica.w"
  7014. setOrganizationName("Wilson's Coffee & Tea");
  7015. setOrganizationDomain("wilsonscoffee.com");
  7016. setApplicationName(PROGRAM_NAME);
  7017. /*:599*/
  7018. #line 12795 "./typica.w"
  7019. /*600:*/
  7020. #line 12816 "./typica.w"
  7021. QTranslator*base= new QTranslator;
  7022. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7023. {
  7024. installTranslator(base);
  7025. }
  7026. QTranslator*app= new QTranslator;
  7027. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7028. {
  7029. installTranslator(app);
  7030. }
  7031. /*:600*/
  7032. #line 12796 "./typica.w"
  7033. /*307:*/
  7034. #line 123 "./measurement.w"
  7035. qRegisterMetaType<Measurement> ("Measurement");
  7036. /*:307*/
  7037. #line 12797 "./typica.w"
  7038. /*812:*/
  7039. #line 16818 "./typica.w"
  7040. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  7041. tr("NI DAQmx Base"),
  7042. "nidaqmxbase",NULL);
  7043. topLevelNodeInserters.append(inserter);
  7044. /*:812*//*820:*/
  7045. #line 17049 "./typica.w"
  7046. #ifdef Q_OS_WIN32
  7047. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  7048. topLevelNodeInserters.append(inserter);
  7049. #endif
  7050. /*:820*//*844:*/
  7051. #line 18016 "./typica.w"
  7052. #if 0
  7053. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7054. topLevelNodeInserters.append(inserter);
  7055. #endif
  7056. /*:844*//*893:*/
  7057. #line 19529 "./typica.w"
  7058. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7059. topLevelNodeInserters.append(inserter);
  7060. #line 1 "./modbus.w"
  7061. /*:893*//*899:*/
  7062. #line 328 "./modbus.w"
  7063. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7064. topLevelNodeInserters.append(inserter);
  7065. /*:899*//*915:*/
  7066. #line 272 "./unsupportedserial.w"
  7067. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7068. "unsupporteddevice",NULL);
  7069. topLevelNodeInserters.append(inserter);
  7070. /*:915*//*946:*/
  7071. #line 190 "./phidgets.w"
  7072. QLibrary phidgetsCheck("phidget21");
  7073. if(phidgetsCheck.load())
  7074. {
  7075. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7076. "phidgets1048",NULL);
  7077. topLevelNodeInserters.append(inserter);
  7078. phidgetsCheck.unload();
  7079. }
  7080. else
  7081. {
  7082. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7083. if(phidgetsCheck.load())
  7084. {
  7085. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7086. "phidgets1048",NULL);
  7087. topLevelNodeInserters.append(inserter);
  7088. phidgetsCheck.unload();
  7089. }
  7090. }
  7091. /*:946*//*1037:*/
  7092. #line 1241 "./dataqsdk.w"
  7093. #ifdef Q_OS_WIN32
  7094. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7095. "dataqsdk",NULL);
  7096. topLevelNodeInserters.append(inserter);
  7097. #endif
  7098. #line 20196 "./typica.w"
  7099. #line 1 "./scales.w"
  7100. /*:1037*//*1062:*/
  7101. #line 557 "./scales.w"
  7102. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7103. topLevelNodeInserters.append(inserter);
  7104. #line 20198 "./typica.w"
  7105. #line 1 "./valueannotation.w"
  7106. /*:1062*/
  7107. #line 12798 "./typica.w"
  7108. }
  7109. /*:598*//*602:*/
  7110. #line 12839 "./typica.w"
  7111. QDomDocument*Application::configuration()
  7112. {
  7113. return&conf;
  7114. }
  7115. /*:602*//*603:*/
  7116. #line 12848 "./typica.w"
  7117. QSqlDatabase Application::database()
  7118. {
  7119. QString connectionName;
  7120. QSqlDatabase connection=
  7121. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7122. do
  7123. {
  7124. connectionName= QUuid::createUuid().toString();
  7125. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7126. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7127. }
  7128. /*:603*//*747:*/
  7129. #line 15351 "./typica.w"
  7130. void Application::saveDeviceConfiguration()
  7131. {
  7132. QSettings settings;
  7133. settings.setValue("DeviceConfiguration",
  7134. QVariant(deviceConfigurationDocument.toByteArray()));
  7135. }
  7136. /*:747*//*748:*/
  7137. #line 15363 "./typica.w"
  7138. QDomDocument Application::deviceConfiguration()
  7139. {
  7140. if(deviceConfigurationDocument.isNull())
  7141. {
  7142. /*749:*/
  7143. #line 15377 "./typica.w"
  7144. QSettings settings;
  7145. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7146. QString etext;
  7147. int eline;
  7148. int ecol;
  7149. if(document.length()==0)
  7150. {
  7151. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7152. /*750:*/
  7153. #line 15401 "./typica.w"
  7154. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7155. emptyDocument.open(QIODevice::ReadOnly);
  7156. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7157. &etext,&eline,&ecol))
  7158. {
  7159. /*751:*/
  7160. #line 15418 "./typica.w"
  7161. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7162. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7163. qDebug()<<etext;
  7164. /*:751*/
  7165. #line 15407 "./typica.w"
  7166. }
  7167. else
  7168. {
  7169. saveDeviceConfiguration();
  7170. }
  7171. /*:750*/
  7172. #line 15386 "./typica.w"
  7173. }
  7174. else
  7175. {
  7176. if(!deviceConfigurationDocument.setContent(document,false,
  7177. &etext,&eline,&ecol))
  7178. {
  7179. /*751:*/
  7180. #line 15418 "./typica.w"
  7181. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7182. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7183. qDebug()<<etext;
  7184. /*:751*/
  7185. #line 15393 "./typica.w"
  7186. /*750:*/
  7187. #line 15401 "./typica.w"
  7188. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7189. emptyDocument.open(QIODevice::ReadOnly);
  7190. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7191. &etext,&eline,&ecol))
  7192. {
  7193. /*751:*/
  7194. #line 15418 "./typica.w"
  7195. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7196. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7197. qDebug()<<etext;
  7198. /*:751*/
  7199. #line 15407 "./typica.w"
  7200. }
  7201. else
  7202. {
  7203. saveDeviceConfiguration();
  7204. }
  7205. /*:750*/
  7206. #line 15394 "./typica.w"
  7207. }
  7208. }
  7209. /*:749*/
  7210. #line 15368 "./typica.w"
  7211. }
  7212. return deviceConfigurationDocument;
  7213. }
  7214. /*:748*//*779:*/
  7215. #line 16019 "./typica.w"
  7216. void Application::registerDeviceConfigurationWidget(QString driver,
  7217. QMetaObject widget)
  7218. {
  7219. deviceConfigurationWidgets.insert(driver,widget);
  7220. }
  7221. /*:779*//*780:*/
  7222. #line 16035 "./typica.w"
  7223. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7224. const QModelIndex&index)
  7225. {
  7226. QVariant nodeReference= index.data(Qt::UserRole);
  7227. QDomElement referenceElement= model->referenceElement(
  7228. model->data(index,Qt::UserRole).toString());
  7229. QMetaObject metaObject=
  7230. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7231. QWidget::staticMetaObject);
  7232. QWidget*editor;
  7233. if(metaObject.className()==QWidget::staticMetaObject.className())
  7234. {
  7235. editor= NULL;
  7236. }
  7237. else
  7238. {
  7239. editor= qobject_cast<QWidget*> (
  7240. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7241. Q_ARG(QModelIndex,index)));
  7242. }
  7243. return editor;
  7244. }
  7245. /*:780*/
  7246. #line 564 "./typica.w"
  7247. /*644:*/
  7248. #line 13678 "./typica.w"
  7249. SqlConnectionSetup::SqlConnectionSetup():
  7250. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7251. portnumber(new QLineEdit),
  7252. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7253. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7254. cancelButton(new QPushButton(tr("Cancel"))),
  7255. connectButton(new QPushButton(tr("Connect")))
  7256. {
  7257. QSettings settings;
  7258. driver->addItem("PostgreSQL","QPSQL");
  7259. formLayout->addRow(tr("Database driver:"),driver);
  7260. formLayout->addRow(tr("Host name:"),hostname);
  7261. hostname->setText(settings.value("database/hostname").toString());
  7262. formLayout->addRow(tr("Port number:"),portnumber);
  7263. portnumber->setText(settings.value("database/portnumber","5432").toString());
  7264. formLayout->addRow(tr("Database name:"),dbname);
  7265. dbname->setText(settings.value("database/dbname").toString());
  7266. formLayout->addRow(tr("User name:"),user);
  7267. user->setText(settings.value("database/user").toString());
  7268. password->setEchoMode(QLineEdit::Password);
  7269. formLayout->addRow(tr("Password:"),password);
  7270. password->setText(settings.value("database/password").toString());
  7271. layout->addLayout(formLayout);
  7272. buttons->addStretch(1);
  7273. buttons->addWidget(cancelButton);
  7274. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7275. buttons->addWidget(connectButton);
  7276. layout->addLayout(buttons);
  7277. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7278. connectButton->setDefault(true);
  7279. setLayout(layout);
  7280. setModal(true);
  7281. }
  7282. SqlConnectionSetup::~SqlConnectionSetup()
  7283. {
  7284. }
  7285. /*:644*//*645:*/
  7286. #line 13721 "./typica.w"
  7287. void SqlConnectionSetup::testConnection()
  7288. {
  7289. QSqlDatabase database=
  7290. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7291. toString());
  7292. database.setConnectOptions("application_name=Typica");
  7293. database.setHostName(hostname->text());
  7294. database.setPort(portnumber->text().toInt());
  7295. database.setDatabaseName(dbname->text());
  7296. database.setUserName(user->text());
  7297. database.setPassword(password->text());
  7298. if(database.open())
  7299. {
  7300. QSettings settings;
  7301. settings.setValue("database/exists","true");
  7302. settings.setValue("database/driver",
  7303. driver->itemData(driver->currentIndex()).toString());
  7304. settings.setValue("database/hostname",hostname->text());
  7305. settings.setValue("database/portnumber",portnumber->text());
  7306. settings.setValue("database/dbname",dbname->text());
  7307. settings.setValue("database/user",user->text());
  7308. settings.setValue("database/password",password->text());
  7309. database.close();
  7310. accept();
  7311. }
  7312. else
  7313. {
  7314. QMessageBox::information(this,tr("Database connection failed"),
  7315. tr("Failed to connect to database."));
  7316. }
  7317. }
  7318. /*:645*/
  7319. #line 565 "./typica.w"
  7320. /*649:*/
  7321. #line 13826 "./typica.w"
  7322. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7323. {
  7324. setModel(new QSqlQueryModel);
  7325. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7326. this,SLOT(openRow(QModelIndex)));
  7327. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7328. this,SLOT(persistColumnResize(int,int,int)));
  7329. }
  7330. /*:649*//*650:*/
  7331. #line 13841 "./typica.w"
  7332. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7333. {
  7334. /*651:*/
  7335. #line 13850 "./typica.w"
  7336. QSettings settings;
  7337. /*652:*/
  7338. #line 13863 "./typica.w"
  7339. QWidget*topLevelWidget= this;
  7340. while(topLevelWidget->parentWidget())
  7341. {
  7342. topLevelWidget= topLevelWidget->parentWidget();
  7343. }
  7344. /*:652*/
  7345. #line 13852 "./typica.w"
  7346. settings.setValue(QString("columnWidths/%1/%2/%3").
  7347. arg(topLevelWidget->objectName()).
  7348. arg(objectName()).arg(column),
  7349. QVariant(newsize));
  7350. /*:651*/
  7351. #line 13844 "./typica.w"
  7352. }
  7353. /*:650*//*653:*/
  7354. #line 13873 "./typica.w"
  7355. void SqlQueryView::showEvent(QShowEvent*event)
  7356. {
  7357. /*654:*/
  7358. #line 13883 "./typica.w"
  7359. QSettings settings;
  7360. /*652:*/
  7361. #line 13863 "./typica.w"
  7362. QWidget*topLevelWidget= this;
  7363. while(topLevelWidget->parentWidget())
  7364. {
  7365. topLevelWidget= topLevelWidget->parentWidget();
  7366. }
  7367. /*:652*/
  7368. #line 13885 "./typica.w"
  7369. QString baseKey=
  7370. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7371. arg(objectName());
  7372. for(int i= 0;i<model()->columnCount();i++)
  7373. {
  7374. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7375. if(settings.contains(key))
  7376. {
  7377. setColumnWidth(i,settings.value(key).toInt());
  7378. }
  7379. }
  7380. /*:654*/
  7381. #line 13876 "./typica.w"
  7382. event->accept();
  7383. }
  7384. /*:653*//*655:*/
  7385. #line 13900 "./typica.w"
  7386. void SqlQueryView::openRow(const QModelIndex&index)
  7387. {
  7388. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7389. emit openEntryRow(index.row());
  7390. }
  7391. /*:655*//*656:*/
  7392. #line 13909 "./typica.w"
  7393. void SqlQueryView::setQuery(const QString&query)
  7394. {
  7395. QSqlDatabase database= AppInstance->database();
  7396. database.open();
  7397. QSqlQuery q(query,database);
  7398. ((QSqlQueryModel*)model())->setQuery(q);
  7399. database.close();
  7400. }
  7401. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7402. const QVariant&value,int role)
  7403. {
  7404. return model()->setHeaderData(section,orientation,value,role);
  7405. }
  7406. /*:656*//*657:*/
  7407. #line 13927 "./typica.w"
  7408. QVariant SqlQueryView::data(int row,int column,int role)
  7409. {
  7410. return model()->data(model()->index(row,column),role);
  7411. }
  7412. /*:657*/
  7413. #line 566 "./typica.w"
  7414. /*173:*/
  7415. #line 3984 "./typica.w"
  7416. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7417. {
  7418. QSqlDatabase database= AppInstance->database();
  7419. database.open();
  7420. q= new QSqlQuery(query,database);
  7421. connection= database.connectionName();
  7422. }
  7423. /*:173*//*174:*/
  7424. #line 3997 "./typica.w"
  7425. SqlQueryConnection::~SqlQueryConnection()
  7426. {
  7427. delete q;
  7428. {
  7429. QSqlDatabase database= QSqlDatabase::database(connection);
  7430. database.close();
  7431. }
  7432. QSqlDatabase::removeDatabase(connection);
  7433. }
  7434. /*:174*//*175:*/
  7435. #line 4011 "./typica.w"
  7436. QSqlQuery*SqlQueryConnection::operator->()const
  7437. {
  7438. return q;
  7439. }
  7440. /*:175*/
  7441. #line 567 "./typica.w"
  7442. /*676:*/
  7443. #line 14286 "./typica.w"
  7444. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7445. area(frame),configuration(description)
  7446. {
  7447. refresh();
  7448. }
  7449. ReportTable::~ReportTable()
  7450. {
  7451. }
  7452. /*:676*//*677:*/
  7453. #line 14302 "./typica.w"
  7454. void ReportTable::bind(QString placeholder,QVariant value)
  7455. {
  7456. bindings.insert(placeholder,value);
  7457. }
  7458. /*:677*//*678:*/
  7459. #line 14312 "./typica.w"
  7460. void ReportTable::refresh()
  7461. {
  7462. /*679:*/
  7463. #line 14333 "./typica.w"
  7464. QTextCursor cursor= area->firstCursorPosition();
  7465. while(cursor<area->lastCursorPosition())
  7466. {
  7467. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7468. }
  7469. cursor.removeSelectedText();
  7470. /*:679*/
  7471. #line 14315 "./typica.w"
  7472. int rows= 1;
  7473. int columns= 1;
  7474. int currentRow= 0;
  7475. QTextTable*table= cursor.insertTable(rows,columns);
  7476. /*680:*/
  7477. #line 14346 "./typica.w"
  7478. QTextTableFormat format= table->format();
  7479. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7480. if(configuration.hasAttribute("align"))
  7481. {
  7482. if(configuration.attribute("align")=="center")
  7483. {
  7484. format.setAlignment(Qt::AlignHCenter);
  7485. }
  7486. }
  7487. table->setFormat(format);
  7488. /*:680*/
  7489. #line 14320 "./typica.w"
  7490. /*681:*/
  7491. #line 14360 "./typica.w"
  7492. QDomNodeList children= configuration.childNodes();
  7493. for(int i= 0;i<children.count();i++)
  7494. {
  7495. QDomNode current;
  7496. QDomElement currentElement;
  7497. current= children.at(i);
  7498. if(current.isElement())
  7499. {
  7500. currentElement= current.toElement();
  7501. if(currentElement.tagName()=="query")
  7502. {
  7503. /*682:*/
  7504. #line 14387 "./typica.w"
  7505. SqlQueryConnection h;
  7506. QSqlQuery*query= h.operator->();
  7507. query->prepare(currentElement.text());
  7508. foreach(QString key,bindings.uniqueKeys())
  7509. {
  7510. if(currentElement.text().contains(key))
  7511. {
  7512. query->bindValue(key,bindings.value(key));
  7513. }
  7514. }
  7515. query->exec();
  7516. if(!query->next())
  7517. {
  7518. continue;
  7519. }
  7520. if(query->record().count()> columns)
  7521. {
  7522. table->appendColumns(query->record().count()-columns);
  7523. }
  7524. do
  7525. {
  7526. table->appendRows(1);
  7527. rows++;
  7528. currentRow++;
  7529. for(int j= 0;j<query->record().count();j++)
  7530. {
  7531. QTextTableCell cell= table->cellAt(currentRow,j);
  7532. cursor= cell.firstCursorPosition();
  7533. cursor.insertText(query->value(j).toString());
  7534. }
  7535. }while(query->next());
  7536. /*:682*/
  7537. #line 14372 "./typica.w"
  7538. }
  7539. else if(currentElement.tagName()=="row")
  7540. {
  7541. /*683:*/
  7542. #line 14427 "./typica.w"
  7543. table->appendRows(1);
  7544. currentRow++;
  7545. rows++;
  7546. QDomNodeList rowChildren= currentElement.childNodes();
  7547. int currentColumn= 0;
  7548. for(int j= 0;j<rowChildren.count();j++)
  7549. {
  7550. QDomNode node;
  7551. QDomElement nodeElement;
  7552. node= rowChildren.at(j);
  7553. if(node.isElement())
  7554. {
  7555. nodeElement= node.toElement();
  7556. if(nodeElement.tagName()=="cell")
  7557. {
  7558. if(currentColumn==columns)
  7559. {
  7560. table->appendColumns(1);
  7561. columns++;
  7562. }
  7563. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7564. cursor= cell.firstCursorPosition();
  7565. cursor.insertText(nodeElement.text());
  7566. currentColumn++;
  7567. }
  7568. }
  7569. }
  7570. /*:683*/
  7571. #line 14376 "./typica.w"
  7572. }
  7573. }
  7574. }
  7575. /*:681*/
  7576. #line 14321 "./typica.w"
  7577. if(rows> 1)
  7578. {
  7579. table->removeRows(0,1);
  7580. }
  7581. }
  7582. /*:678*/
  7583. #line 568 "./typica.w"
  7584. /*715:*/
  7585. #line 14533 "./typica.w"
  7586. FormArray::FormArray(QDomElement description):configuration(description),
  7587. maxwidth(-1),maxheight(-1)
  7588. {
  7589. setWidget(&itemContainer);
  7590. itemContainer.setLayout(&itemLayout);
  7591. }
  7592. /*:715*//*716:*/
  7593. #line 14550 "./typica.w"
  7594. void FormArray::addElements(int copies)
  7595. {
  7596. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7597. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7598. QWidget*widget;
  7599. for(int i= 0;i<copies;i++)
  7600. {
  7601. widget= new QWidget;
  7602. if(maxwidth> -1)
  7603. {
  7604. widget->setMaximumWidth(maxwidth);
  7605. }
  7606. if(maxheight> -1)
  7607. {
  7608. widget->setMaximumHeight(maxheight);
  7609. }
  7610. if(configuration.hasChildNodes())
  7611. {
  7612. widgetStack->push(widget);
  7613. populateWidget(configuration,widgetStack,layoutStack);
  7614. widgetStack->pop();
  7615. widget->setMinimumHeight(widget->sizeHint().height());
  7616. itemLayout.addWidget(widget);
  7617. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7618. {
  7619. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7620. }
  7621. else
  7622. {
  7623. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7624. +widget->sizeHint().height());
  7625. }
  7626. if(maxwidth> -1)
  7627. {
  7628. itemContainer.setMinimumWidth(maxwidth+50);
  7629. }
  7630. else
  7631. {
  7632. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7633. }
  7634. }
  7635. }
  7636. }
  7637. /*:716*//*717:*/
  7638. #line 14600 "./typica.w"
  7639. QWidget*FormArray::elementAt(int index)
  7640. {
  7641. if(index<itemLayout.count())
  7642. {
  7643. QLayoutItem*item= itemLayout.itemAt(index);
  7644. return item->widget();
  7645. }
  7646. else
  7647. {
  7648. return NULL;
  7649. }
  7650. }
  7651. /*:717*//*718:*/
  7652. #line 14617 "./typica.w"
  7653. void FormArray::removeAllElements()
  7654. {
  7655. while(itemLayout.count()> 0)
  7656. {
  7657. QLayoutItem*item;
  7658. item= itemLayout.itemAt(0);
  7659. item->widget()->hide();
  7660. itemLayout.removeWidget(item->widget());
  7661. }
  7662. itemContainer.setMinimumHeight(0);
  7663. }
  7664. /*:718*//*719:*/
  7665. #line 14633 "./typica.w"
  7666. int FormArray::elements()
  7667. {
  7668. return itemLayout.count();
  7669. }
  7670. /*:719*//*720:*/
  7671. #line 14644 "./typica.w"
  7672. void FormArray::setMaximumElementWidth(int width)
  7673. {
  7674. maxwidth= width;
  7675. }
  7676. void FormArray::setMaximumElementHeight(int height)
  7677. {
  7678. maxheight= height;
  7679. }
  7680. /*:720*/
  7681. #line 569 "./typica.w"
  7682. /*726:*/
  7683. #line 14775 "./typica.w"
  7684. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7685. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7686. {
  7687. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7688. QPointF(0,5);
  7689. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7690. QPointF(10,5);
  7691. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7692. QPointF(0,0);
  7693. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7694. initialBrush.setColor(QColor(170,170,255));
  7695. initialBrush.setStyle(Qt::SolidPattern);
  7696. finalBrush.setColor(Qt::blue);
  7697. finalBrush.setStyle(Qt::SolidPattern);
  7698. initialDecrement.setPolygon(left);
  7699. initialDecrement.setBrush(initialBrush);
  7700. initialDecrement.setPos(0,0);
  7701. scene.addItem(&initialDecrement);
  7702. initialIncrement.setPolygon(right);
  7703. initialIncrement.setBrush(initialBrush);
  7704. initialIncrement.setPos(122,0);
  7705. scene.addItem(&initialIncrement);
  7706. finalDecrement.setPolygon(left);
  7707. finalDecrement.setBrush(finalBrush);
  7708. finalDecrement.setPos(0,12);
  7709. scene.addItem(&finalDecrement);
  7710. finalIncrement.setPolygon(right);
  7711. finalIncrement.setBrush(finalBrush);
  7712. finalIncrement.setPos(122,12);
  7713. scene.addItem(&finalIncrement);
  7714. scalePath.moveTo(0,10);
  7715. scalePath.lineTo(100,10);
  7716. scalePath.moveTo(0,0);
  7717. scalePath.lineTo(0,20);
  7718. scalePath.moveTo(10,5);
  7719. scalePath.lineTo(10,15);
  7720. scalePath.moveTo(20,5);
  7721. scalePath.lineTo(20,15);
  7722. scalePath.moveTo(30,5);
  7723. scalePath.lineTo(30,15);
  7724. scalePath.moveTo(40,5);
  7725. scalePath.lineTo(40,15);
  7726. scalePath.moveTo(50,0);
  7727. scalePath.lineTo(50,20);
  7728. scalePath.moveTo(60,5);
  7729. scalePath.lineTo(60,15);
  7730. scalePath.moveTo(70,5);
  7731. scalePath.lineTo(70,15);
  7732. scalePath.moveTo(80,5);
  7733. scalePath.lineTo(80,15);
  7734. scalePath.moveTo(90,5);
  7735. scalePath.lineTo(90,15);
  7736. scalePath.moveTo(100,0);
  7737. scalePath.lineTo(100,20);
  7738. scaleLine.setPath(scalePath);
  7739. scaleLine.setPos(16,1);
  7740. scene.addItem(&scaleLine);
  7741. setScene(&scene);
  7742. initialIndicator.setPolygon(down);
  7743. initialIndicator.setBrush(initialBrush);
  7744. finalIndicator.setPolygon(up);
  7745. finalIndicator.setBrush(finalBrush);
  7746. setMinimumSize(sizeHint());
  7747. setMaximumSize(sizeHint());
  7748. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7749. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7750. setMinimumSize(sizeHint());
  7751. }
  7752. /*:726*//*727:*/
  7753. #line 14848 "./typica.w"
  7754. QSize ScaleControl::sizeHint()const
  7755. {
  7756. return QSize(140,30);
  7757. }
  7758. /*:727*//*728:*/
  7759. #line 14857 "./typica.w"
  7760. void ScaleControl::setInitialValue(double value)
  7761. {
  7762. if(value>=0&&value<=10)
  7763. {
  7764. nonScoredValue= value;
  7765. if(!initialSet)
  7766. {
  7767. scene.addItem(&initialIndicator);
  7768. }
  7769. initialSet= true;
  7770. initialIndicator.setPos(value*10+16,10);
  7771. emit initialChanged(value);
  7772. if(!finalSet)
  7773. {
  7774. setFinalValue(value);
  7775. }
  7776. }
  7777. }
  7778. void ScaleControl::setFinalValue(double value)
  7779. {
  7780. if(value>=0&&value<=10)
  7781. {
  7782. scoredValue= value;
  7783. if(!finalSet)
  7784. {
  7785. scene.addItem(&finalIndicator);
  7786. }
  7787. finalSet= true;
  7788. finalIndicator.setPos(value*10+16,11);
  7789. emit finalChanged(value);
  7790. }
  7791. }
  7792. /*:728*//*729:*/
  7793. #line 14894 "./typica.w"
  7794. double ScaleControl::initialValue(void)
  7795. {
  7796. return nonScoredValue;
  7797. }
  7798. double ScaleControl::finalValue(void)
  7799. {
  7800. return scoredValue;
  7801. }
  7802. /*:729*//*730:*/
  7803. #line 14915 "./typica.w"
  7804. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7805. {
  7806. /*731:*/
  7807. #line 14927 "./typica.w"
  7808. if(event->button()!=Qt::LeftButton)
  7809. {
  7810. event->ignore();
  7811. return;
  7812. }
  7813. /*:731*/
  7814. #line 14918 "./typica.w"
  7815. scaleDown= true;
  7816. event->accept();
  7817. }
  7818. /*:730*//*732:*/
  7819. #line 14938 "./typica.w"
  7820. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7821. {
  7822. /*731:*/
  7823. #line 14927 "./typica.w"
  7824. if(event->button()!=Qt::LeftButton)
  7825. {
  7826. event->ignore();
  7827. return;
  7828. }
  7829. /*:731*/
  7830. #line 14941 "./typica.w"
  7831. if(!scaleDown)
  7832. {
  7833. event->ignore();
  7834. return;
  7835. }
  7836. scaleDown= false;
  7837. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7838. /*733:*/
  7839. #line 14963 "./typica.w"
  7840. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7841. {
  7842. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7843. {
  7844. if(initialSet)
  7845. {
  7846. setInitialValue(nonScoredValue-0.05);
  7847. }
  7848. event->accept();
  7849. return;
  7850. }
  7851. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7852. {
  7853. if(finalSet)
  7854. {
  7855. setFinalValue(scoredValue-0.05);
  7856. event->accept();
  7857. return;
  7858. }
  7859. }
  7860. }
  7861. /*:733*/
  7862. #line 14949 "./typica.w"
  7863. /*734:*/
  7864. #line 14989 "./typica.w"
  7865. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7866. {
  7867. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7868. {
  7869. if(initialSet)
  7870. {
  7871. setInitialValue(nonScoredValue+0.05);
  7872. event->accept();
  7873. return;
  7874. }
  7875. }
  7876. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7877. {
  7878. if(finalSet)
  7879. {
  7880. setFinalValue(scoredValue+0.05);
  7881. event->accept();
  7882. return;
  7883. }
  7884. }
  7885. }
  7886. /*:734*/
  7887. #line 14950 "./typica.w"
  7888. /*735:*/
  7889. #line 15015 "./typica.w"
  7890. double relativeX= sceneCoordinate.x()-16;
  7891. if(initialSet)
  7892. {
  7893. if(relativeX>=0&&relativeX<=100)
  7894. {
  7895. setFinalValue(relativeX/10.0);
  7896. event->accept();
  7897. return;
  7898. }
  7899. }
  7900. else
  7901. {
  7902. if(relativeX>=0&&relativeX<=100)
  7903. {
  7904. setInitialValue(relativeX/10.0);
  7905. event->accept();
  7906. return;
  7907. }
  7908. }
  7909. /*:735*/
  7910. #line 14951 "./typica.w"
  7911. event->ignore();
  7912. return;
  7913. }
  7914. /*:732*/
  7915. #line 570 "./typica.w"
  7916. /*737:*/
  7917. #line 15081 "./typica.w"
  7918. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7919. valueSet(false),scaleDown(false)
  7920. {
  7921. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7922. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7923. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7924. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7925. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7926. theBrush.setColor(Qt::blue);
  7927. theBrush.setStyle(Qt::SolidPattern);
  7928. increment.setPolygon(up);
  7929. increment.setBrush(theBrush);
  7930. increment.setPos(0,0);
  7931. scene.addItem(&increment);
  7932. decrement.setPolygon(down);
  7933. decrement.setBrush(theBrush);
  7934. decrement.setPos(0,122);
  7935. scene.addItem(&decrement);
  7936. scalePath.moveTo(5,0);
  7937. scalePath.lineTo(5,100);
  7938. scalePath.moveTo(0,0);
  7939. scalePath.lineTo(10,0);
  7940. scalePath.moveTo(0,10);
  7941. scalePath.lineTo(10,10);
  7942. scalePath.moveTo(0,20);
  7943. scalePath.lineTo(10,20);
  7944. scalePath.moveTo(0,30);
  7945. scalePath.lineTo(10,30);
  7946. scalePath.moveTo(0,40);
  7947. scalePath.lineTo(10,40);
  7948. scalePath.moveTo(0,50);
  7949. scalePath.lineTo(10,50);
  7950. scalePath.moveTo(0,60);
  7951. scalePath.lineTo(10,60);
  7952. scalePath.moveTo(0,70);
  7953. scalePath.lineTo(10,70);
  7954. scalePath.moveTo(0,80);
  7955. scalePath.lineTo(10,80);
  7956. scalePath.moveTo(0,90);
  7957. scalePath.lineTo(10,90);
  7958. scalePath.moveTo(0,100);
  7959. scalePath.lineTo(10,100);
  7960. scaleLine.setPath(scalePath);
  7961. scaleLine.setPos(0,16);
  7962. scene.addItem(&scaleLine);
  7963. setScene(&scene);
  7964. indicator.setPolygon(left);
  7965. indicator.setBrush(theBrush);
  7966. setMinimumSize(sizeHint());
  7967. setMaximumSize(sizeHint());
  7968. }
  7969. /*:737*//*738:*/
  7970. #line 15136 "./typica.w"
  7971. QSize IntensityControl::sizeHint()const
  7972. {
  7973. return QSize(25,160);
  7974. }
  7975. /*:738*//*739:*/
  7976. #line 15151 "./typica.w"
  7977. void IntensityControl::setValue(double val)
  7978. {
  7979. if(val>=0&&val<=10)
  7980. {
  7981. theValue= val;
  7982. if(!valueSet)
  7983. {
  7984. scene.addItem(&indicator);
  7985. }
  7986. valueSet= true;
  7987. indicator.setPos(6,(100-(val*10))+16);
  7988. emit(valueChanged(val));
  7989. }
  7990. else if(val<1)
  7991. {
  7992. setValue(0);
  7993. }
  7994. else
  7995. {
  7996. setValue(10);
  7997. }
  7998. }
  7999. double IntensityControl::value()
  8000. {
  8001. return theValue;
  8002. }
  8003. /*:739*//*740:*/
  8004. #line 15183 "./typica.w"
  8005. void IntensityControl::mousePressEvent(QMouseEvent*event)
  8006. {
  8007. /*731:*/
  8008. #line 14927 "./typica.w"
  8009. if(event->button()!=Qt::LeftButton)
  8010. {
  8011. event->ignore();
  8012. return;
  8013. }
  8014. /*:731*/
  8015. #line 15186 "./typica.w"
  8016. scaleDown= true;
  8017. event->accept();
  8018. }
  8019. /*:740*//*741:*/
  8020. #line 15197 "./typica.w"
  8021. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  8022. {
  8023. /*731:*/
  8024. #line 14927 "./typica.w"
  8025. if(event->button()!=Qt::LeftButton)
  8026. {
  8027. event->ignore();
  8028. return;
  8029. }
  8030. /*:731*/
  8031. #line 15200 "./typica.w"
  8032. if(!scaleDown)
  8033. {
  8034. event->ignore();
  8035. return;
  8036. }
  8037. scaleDown= false;
  8038. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8039. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  8040. {
  8041. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8042. {
  8043. if(valueSet)
  8044. {
  8045. setValue(theValue+0.05);
  8046. }
  8047. event->accept();
  8048. return;
  8049. }
  8050. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  8051. {
  8052. if(valueSet)
  8053. {
  8054. setValue(theValue-0.05);
  8055. }
  8056. event->accept();
  8057. return;
  8058. }
  8059. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8060. {
  8061. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8062. event->accept();
  8063. return;
  8064. }
  8065. }
  8066. }
  8067. /*:741*/
  8068. #line 571 "./typica.w"
  8069. /*376:*/
  8070. #line 8415 "./typica.w"
  8071. void ThresholdDetector::newMeasurement(Measurement measure)
  8072. {
  8073. if((currentDirection==Ascending&&previousValue<threshold&&
  8074. previousValueValid)||(currentDirection==Descending&&
  8075. previousValue> threshold&&previousValueValid))
  8076. {
  8077. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8078. (currentDirection==Descending&&measure.temperature()<=threshold))
  8079. {
  8080. double offset= measure.time().hour()*60*60;
  8081. offset+= measure.time().minute()*60;
  8082. offset+= measure.time().second();
  8083. offset+= measure.time().msec()/1000;
  8084. emit timeForValue(offset);
  8085. }
  8086. }
  8087. previousValue= measure.temperature();
  8088. previousValueValid= true;
  8089. }
  8090. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8091. previousValueValid(false),
  8092. previousValue(-1),threshold(value),currentDirection(Ascending)
  8093. {
  8094. }
  8095. void ThresholdDetector::setThreshold(double value)
  8096. {
  8097. threshold= value;
  8098. }
  8099. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8100. {
  8101. currentDirection= direction;
  8102. }
  8103. /*:376*/
  8104. #line 572 "./typica.w"
  8105. /*823:*/
  8106. #line 17089 "./typica.w"
  8107. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8108. lister(new QextSerialEnumerator)
  8109. {
  8110. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8111. QextPortInfo port;
  8112. foreach(port,ports)
  8113. {
  8114. #ifdef Q_OS_WIN32
  8115. addItem(port.portName);
  8116. #else
  8117. addItem(port.physName);
  8118. #endif
  8119. }
  8120. lister->setUpNotifications();
  8121. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8122. this,SLOT(addDevice(QextPortInfo)));
  8123. setEditable(true);
  8124. }
  8125. void PortSelector::addDevice(QextPortInfo port)
  8126. {
  8127. addItem(port.portName);
  8128. }
  8129. /*:823*/
  8130. #line 573 "./typica.w"
  8131. /*825:*/
  8132. #line 17181 "./typica.w"
  8133. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8134. {
  8135. QMetaObject meta= BaudSelector::staticMetaObject;
  8136. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8137. for(int i= 0;i<type.keyCount();i++)
  8138. {
  8139. addItem(QString("%1").arg(type.value(i)));
  8140. }
  8141. }
  8142. /*:825*/
  8143. #line 574 "./typica.w"
  8144. /*827:*/
  8145. #line 17219 "./typica.w"
  8146. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8147. {
  8148. QMetaObject meta= ParitySelector::staticMetaObject;
  8149. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8150. for(int i= 0;i<type.keyCount();i++)
  8151. {
  8152. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8153. }
  8154. }
  8155. /*:827*/
  8156. #line 575 "./typica.w"
  8157. /*829:*/
  8158. #line 17249 "./typica.w"
  8159. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8160. {
  8161. QMetaObject meta= FlowSelector::staticMetaObject;
  8162. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8163. for(int i= 0;i<type.keyCount();i++)
  8164. {
  8165. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8166. }
  8167. }
  8168. /*:829*/
  8169. #line 576 "./typica.w"
  8170. /*831:*/
  8171. #line 17284 "./typica.w"
  8172. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8173. {
  8174. QMetaObject meta= StopSelector::staticMetaObject;
  8175. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8176. for(int i= 0;i<type.keyCount();i++)
  8177. {
  8178. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8179. }
  8180. }
  8181. /*:831*/
  8182. #line 577 "./typica.w"
  8183. /*891:*/
  8184. #line 19070 "./typica.w"
  8185. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8186. :BasicDeviceConfigurationWidget(model,index),
  8187. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8188. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8189. decimalQuery(new QCheckBox(tr("Enable"))),
  8190. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8191. unitQuery(new QCheckBox(tr("Enable"))),
  8192. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8193. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8194. pVAddress(new ShortHexSpinBox),
  8195. sVEnabled(new QCheckBox(tr("Enable"))),
  8196. sVReadAddress(new ShortHexSpinBox),
  8197. deviceLimit(new QCheckBox(tr("Enable"))),
  8198. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8199. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8200. sVWritable(new QCheckBox(tr("Enable"))),
  8201. sVOutputAddr(new ShortHexSpinBox),
  8202. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8203. {
  8204. QHBoxLayout*layout= new QHBoxLayout;
  8205. QWidget*form= new QWidget;
  8206. QHBoxLayout*masterLayout= new QHBoxLayout;
  8207. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8208. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8209. QFormLayout*serialSection= new QFormLayout;
  8210. serialSection->addRow(QString(tr("Port:")),port);
  8211. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8212. serialSection->addRow(QString(tr("Parity:")),parity);
  8213. serialSection->addRow(QString(tr("Flow control:")),flow);
  8214. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8215. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8216. serialSectionBox->setLayout(serialSection);
  8217. portAndDeviceLayout->addWidget(serialSectionBox);
  8218. QFormLayout*deviceSection= new QFormLayout;
  8219. station->setMinimum(1);
  8220. station->setMaximum(255);
  8221. decimalPosition->setMinimum(0);
  8222. decimalPosition->setMaximum(9);
  8223. valueF->setMinimum(0);
  8224. valueF->setMaximum(0xFFFF);
  8225. valueC->setMinimum(0);
  8226. valueC->setMaximum(0xFFFF);
  8227. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8228. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8229. deviceSection->addRow(tr("Station:"),station);
  8230. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8231. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8232. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8233. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8234. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8235. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8236. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8237. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8238. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8239. deviceSectionBox->setLayout(deviceSection);
  8240. portAndDeviceLayout->addWidget(deviceSectionBox);
  8241. QFormLayout*pVSection= new QFormLayout;
  8242. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8243. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8244. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8245. pVSection->addRow(pVHideBox);
  8246. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8247. processValueBox->setLayout(pVSection);
  8248. seriesLayout->addWidget(processValueBox);
  8249. QFormLayout*sVSection= new QFormLayout;
  8250. sVLower->setDecimals(1);
  8251. sVLower->setMinimum(0.0);
  8252. sVLower->setMaximum(999.9);
  8253. sVUpper->setDecimals(1);
  8254. sVUpper->setMinimum(0.0);
  8255. sVUpper->setMaximum(999.9);
  8256. sVSection->addRow(tr("Set value:"),sVEnabled);
  8257. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8258. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8259. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8260. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8261. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8262. sVSection->addRow(tr("Lower limit:"),sVLower);
  8263. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8264. sVSection->addRow(tr("Output set value:"),sVWritable);
  8265. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8266. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8267. sVSection->addRow(sVHideBox);
  8268. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8269. setValueBox->setLayout(sVSection);
  8270. seriesLayout->addWidget(setValueBox);
  8271. masterLayout->addLayout(portAndDeviceLayout);
  8272. masterLayout->addLayout(seriesLayout);
  8273. form->setLayout(masterLayout);
  8274. /*799:*/
  8275. #line 16530 "./typica.w"
  8276. QDomElement referenceElement=
  8277. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8278. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8279. QDomElement node;
  8280. /*:799*/
  8281. #line 19160 "./typica.w"
  8282. for(int i= 0;i<configData.size();i++)
  8283. {
  8284. node= configData.at(i).toElement();
  8285. if(node.attribute("name")=="port")
  8286. {
  8287. QString portname= node.attribute("value");
  8288. int idx= port->findText(portname);
  8289. if(idx>=0)
  8290. {
  8291. port->setCurrentIndex(idx);
  8292. }
  8293. else
  8294. {
  8295. port->addItem(portname);
  8296. }
  8297. }
  8298. else if(node.attribute("name")=="baud")
  8299. {
  8300. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8301. }
  8302. else if(node.attribute("name")=="parity")
  8303. {
  8304. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8305. }
  8306. else if(node.attribute("name")=="flow")
  8307. {
  8308. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8309. }
  8310. else if(node.attribute("name")=="stop")
  8311. {
  8312. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8313. }
  8314. else if(node.attribute("name")=="station")
  8315. {
  8316. station->setValue(node.attribute("value").toInt());
  8317. }
  8318. else if(node.attribute("name")=="decimalQuery")
  8319. {
  8320. if(node.attribute("value")=="true")
  8321. {
  8322. decimalQuery->setChecked(true);
  8323. }
  8324. else
  8325. {
  8326. decimalQuery->setChecked(false);
  8327. }
  8328. }
  8329. else if(node.attribute("name")=="decimalAddress")
  8330. {
  8331. decimalAddress->setValue(node.attribute("value").toInt());
  8332. }
  8333. else if(node.attribute("name")=="decimalPosition")
  8334. {
  8335. decimalPosition->setValue(node.attribute("value").toInt());
  8336. }
  8337. else if(node.attribute("name")=="unitQuery")
  8338. {
  8339. if(node.attribute("value")=="true")
  8340. {
  8341. unitQuery->setChecked(true);
  8342. }
  8343. else
  8344. {
  8345. unitQuery->setChecked(false);
  8346. }
  8347. }
  8348. else if(node.attribute("name")=="unitAddress")
  8349. {
  8350. unitAddress->setValue(node.attribute("value").toInt());
  8351. }
  8352. else if(node.attribute("name")=="valueF")
  8353. {
  8354. valueF->setValue(node.attribute("value").toInt());
  8355. }
  8356. else if(node.attribute("name")=="valueC")
  8357. {
  8358. valueC->setValue(node.attribute("value").toInt());
  8359. }
  8360. else if(node.attribute("name")=="fixedUnit")
  8361. {
  8362. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8363. }
  8364. else if(node.attribute("name")=="pVAddress")
  8365. {
  8366. pVAddress->setValue(node.attribute("value").toInt());
  8367. }
  8368. else if(node.attribute("name")=="sVEnabled")
  8369. {
  8370. if(node.attribute("value")=="true")
  8371. {
  8372. sVEnabled->setChecked(true);
  8373. }
  8374. else
  8375. {
  8376. sVEnabled->setChecked(false);
  8377. }
  8378. }
  8379. else if(node.attribute("name")=="sVReadAddress")
  8380. {
  8381. sVReadAddress->setValue(node.attribute("value").toInt());
  8382. }
  8383. else if(node.attribute("name")=="deviceLimit")
  8384. {
  8385. if(node.attribute("value")=="true")
  8386. {
  8387. deviceLimit->setChecked(true);
  8388. }
  8389. else
  8390. {
  8391. deviceLimit->setChecked(false);
  8392. }
  8393. }
  8394. else if(node.attribute("name")=="sVLowerAddr")
  8395. {
  8396. sVLowerAddr->setValue(node.attribute("value").toInt());
  8397. }
  8398. else if(node.attribute("name")=="sVUpperAddr")
  8399. {
  8400. sVUpperAddr->setValue(node.attribute("value").toInt());
  8401. }
  8402. else if(node.attribute("name")=="sVLower")
  8403. {
  8404. sVLower->setValue(node.attribute("value").toDouble());
  8405. }
  8406. else if(node.attribute("name")=="sVUpper")
  8407. {
  8408. sVUpper->setValue(node.attribute("value").toDouble());
  8409. }
  8410. else if(node.attribute("name")=="sVWritable")
  8411. {
  8412. if(node.attribute("value")=="true")
  8413. {
  8414. sVWritable->setChecked(true);
  8415. }
  8416. else
  8417. {
  8418. sVWritable->setChecked(false);
  8419. }
  8420. }
  8421. else if(node.attribute("name")=="sVOutputAddr")
  8422. {
  8423. sVOutputAddr->setValue(node.attribute("value").toInt());
  8424. }
  8425. else if(node.attribute("name")=="pvcolname")
  8426. {
  8427. pVColumnName->setText(node.attribute("value"));
  8428. }
  8429. else if(node.attribute("name")=="svcolname")
  8430. {
  8431. sVColumnName->setText(node.attribute("value"));
  8432. }
  8433. else if(node.attribute("name")=="pvhidden")
  8434. {
  8435. pVHideBox->setChecked(node.attribute("value")=="true");
  8436. }
  8437. else if(node.attribute("name")=="svhidden")
  8438. {
  8439. sVHideBox->setChecked(node.attribute("value")=="true");
  8440. }
  8441. }
  8442. updatePort(port->currentText());
  8443. updateBaudRate(baud->currentText());
  8444. updateParity(parity->itemData(parity->currentIndex()).toString());
  8445. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8446. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8447. updateStation(station->value());
  8448. updateFixedDecimal(decimalQuery->isChecked());
  8449. updateDecimalAddress(decimalAddress->value());
  8450. updateDecimalPosition(decimalPosition->value());
  8451. updateFixedUnit(unitQuery->isChecked());
  8452. updateUnitAddress(unitAddress->value());
  8453. updateValueForF(valueF->value());
  8454. updateValueForC(valueC->value());
  8455. updateUnit(fixedUnit->currentText());
  8456. updatePVAddress(pVAddress->value());
  8457. updateSVEnabled(sVEnabled->isChecked());
  8458. updateSVReadAddress(sVReadAddress->value());
  8459. updateDeviceLimit(deviceLimit->isChecked());
  8460. updateSVLowerAddress(sVLowerAddr->value());
  8461. updateSVUpperAddress(sVUpperAddr->value());
  8462. updateSVLower(sVLower->value());
  8463. updateSVUpper(sVUpper->value());
  8464. updateSVWritable(sVWritable->isChecked());
  8465. updateSVWriteAddress(sVOutputAddr->value());
  8466. updatePVColumnName(pVColumnName->text());
  8467. updateSVColumnName(sVColumnName->text());
  8468. updatePVHidden(pVHideBox->isChecked());
  8469. updateSVHidden(sVHideBox->isChecked());
  8470. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8471. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8472. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8473. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8474. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8475. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8476. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8477. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8478. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8479. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8480. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8481. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8482. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8483. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8484. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8485. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8486. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8487. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8488. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8489. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8490. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8491. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8492. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8493. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8494. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8495. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8496. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8497. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8498. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8499. layout->addWidget(form);
  8500. setLayout(layout);
  8501. }
  8502. void ModbusConfigurator::updatePort(const QString&newPort)
  8503. {
  8504. updateAttribute("port",newPort);
  8505. }
  8506. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8507. {
  8508. updateAttribute("baud",newRate);
  8509. }
  8510. void ModbusConfigurator::updateParity(const QString&)
  8511. {
  8512. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8513. }
  8514. void ModbusConfigurator::updateFlowControl(const QString&)
  8515. {
  8516. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8517. }
  8518. void ModbusConfigurator::updateStopBits(const QString&)
  8519. {
  8520. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8521. }
  8522. void ModbusConfigurator::updateStation(int station)
  8523. {
  8524. updateAttribute("station",QString("%1").arg(station));
  8525. }
  8526. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8527. {
  8528. updateAttribute("decimalQuery",fixed?"true":"false");
  8529. }
  8530. void ModbusConfigurator::updateDecimalAddress(int address)
  8531. {
  8532. updateAttribute("decimalAddress",QString("%1").arg(address));
  8533. }
  8534. void ModbusConfigurator::updateDecimalPosition(int position)
  8535. {
  8536. updateAttribute("decimalPosition",QString("%1").arg(position));
  8537. }
  8538. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8539. {
  8540. updateAttribute("unitQuery",fixed?"true":"false");
  8541. }
  8542. void ModbusConfigurator::updateUnitAddress(int address)
  8543. {
  8544. updateAttribute("unitAddress",QString("%1").arg(address));
  8545. }
  8546. void ModbusConfigurator::updateValueForF(int value)
  8547. {
  8548. updateAttribute("valueF",QString("%1").arg(value));
  8549. }
  8550. void ModbusConfigurator::updateValueForC(int value)
  8551. {
  8552. updateAttribute("valueC",QString("%1").arg(value));
  8553. }
  8554. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8555. {
  8556. updateAttribute("fixedUnit",newUnit);
  8557. }
  8558. void ModbusConfigurator::updatePVAddress(int address)
  8559. {
  8560. updateAttribute("pVAddress",QString("%1").arg(address));
  8561. }
  8562. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8563. {
  8564. updateAttribute("sVEnabled",enabled?"true":"false");
  8565. }
  8566. void ModbusConfigurator::updateSVReadAddress(int address)
  8567. {
  8568. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8569. }
  8570. void ModbusConfigurator::updateDeviceLimit(bool query)
  8571. {
  8572. updateAttribute("deviceLimit",query?"true":"false");
  8573. }
  8574. void ModbusConfigurator::updateSVLowerAddress(int address)
  8575. {
  8576. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8577. }
  8578. void ModbusConfigurator::updateSVUpperAddress(int address)
  8579. {
  8580. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8581. }
  8582. void ModbusConfigurator::updateSVLower(double value)
  8583. {
  8584. updateAttribute("sVLower",QString("%1").arg(value));
  8585. }
  8586. void ModbusConfigurator::updateSVUpper(double value)
  8587. {
  8588. updateAttribute("sVUpper",QString("%1").arg(value));
  8589. }
  8590. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8591. {
  8592. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8593. }
  8594. void ModbusConfigurator::updateSVWriteAddress(int address)
  8595. {
  8596. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8597. }
  8598. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8599. {
  8600. updateAttribute("pvcolname",name);
  8601. }
  8602. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8603. {
  8604. updateAttribute("svcolname",name);
  8605. }
  8606. void ModbusConfigurator::updatePVHidden(bool hidden)
  8607. {
  8608. updateAttribute("pvhidden",hidden?"true":"false");
  8609. }
  8610. void ModbusConfigurator::updateSVHidden(bool hidden)
  8611. {
  8612. updateAttribute("svhidden",hidden?"true":"false");
  8613. }
  8614. /*:891*/
  8615. #line 578 "./typica.w"
  8616. /*834:*/
  8617. #line 17337 "./typica.w"
  8618. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8619. {
  8620. setMinimum(0);
  8621. setMaximum(0xFFFF);
  8622. setPrefix("0x");
  8623. setMinimumWidth(65);
  8624. }
  8625. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8626. {
  8627. if(input.size()==2)
  8628. {
  8629. return QValidator::Intermediate;
  8630. }
  8631. bool okay;
  8632. input.toInt(&okay,16);
  8633. if(okay)
  8634. {
  8635. return QValidator::Acceptable;
  8636. }
  8637. return QValidator::Invalid;
  8638. }
  8639. int ShortHexSpinBox::valueFromText(const QString&text)const
  8640. {
  8641. return text.toInt(NULL,16);
  8642. }
  8643. QString ShortHexSpinBox::textFromValue(int value)const
  8644. {
  8645. QString retval;
  8646. retval.setNum(value,16);
  8647. while(retval.size()<4)
  8648. {
  8649. retval.prepend("0");
  8650. }
  8651. return retval.toUpper();
  8652. }
  8653. /*:834*/
  8654. #line 579 "./typica.w"
  8655. /*875:*/
  8656. #line 18369 "./typica.w"
  8657. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8658. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8659. waiting(false)
  8660. {
  8661. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8662. Qt::UserRole).toString());
  8663. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8664. QDomElement node;
  8665. QVariantMap attributes;
  8666. for(int i= 0;i<portConfigData.size();i++)
  8667. {
  8668. node= portConfigData.at(i).toElement();
  8669. attributes.insert(node.attribute("name"),node.attribute("value"));
  8670. }
  8671. port= new QextSerialPort(attributes.value("port").toString(),
  8672. QextSerialPort::EventDriven);
  8673. int baudRate= attributes.value("baud").toInt();
  8674. port->setBaudRate((BaudRateType)baudRate);
  8675. double temp= ((double)(1)/(double)(baudRate))*48;
  8676. delayTime= (int)(temp*3000);
  8677. messageDelayTimer->setSingleShot(true);
  8678. commTimeout->setSingleShot(true);
  8679. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8680. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8681. port->setDataBits(DATA_8);
  8682. port->setParity((ParityType)attributes.value("parity").toInt());
  8683. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8684. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8685. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8686. port->open(QIODevice::ReadWrite);
  8687. station= (char)attributes.value("station").toInt();
  8688. if(attributes.value("decimalQuery")=="true")
  8689. {
  8690. decimalPosition= 0;
  8691. QByteArray message;
  8692. message.append(station);
  8693. message.append((char)0x03);
  8694. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8695. char*addressBytes= (char*)&address;
  8696. message.append(addressBytes[1]);
  8697. message.append(addressBytes[0]);
  8698. message.append((char)0x00);
  8699. message.append((char)0x01);
  8700. queueMessage(message,this,"decimalResponse(QByteArray)");
  8701. }
  8702. else
  8703. {
  8704. decimalPosition= attributes.value("decimalPosition").toInt();
  8705. }
  8706. valueF= attributes.value("valueF").toInt();
  8707. valueC= attributes.value("valueC").toInt();
  8708. if(attributes.value("unitQuery")=="true")
  8709. {
  8710. QByteArray message;
  8711. message.append(station);
  8712. message.append((char)0x03);
  8713. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8714. char*addressBytes= (char*)&address;
  8715. message.append(addressBytes[1]);
  8716. message.append(addressBytes[0]);
  8717. message.append((char)0x00);
  8718. message.append((char)0x01);
  8719. queueMessage(message,this,"unitResponse(QByteArray)");
  8720. }
  8721. else
  8722. {
  8723. if(attributes.value("fixedUnit")=="Celsius")
  8724. {
  8725. unitIsF= false;
  8726. }
  8727. }
  8728. if(attributes.value("sVWritable")=="true")
  8729. {
  8730. if(attributes.value("deviceLimit")=="true")
  8731. {
  8732. QByteArray lmessage;
  8733. lmessage.append(station);
  8734. lmessage.append((char)0x03);
  8735. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8736. char*addressBytes= (char*)&laddress;
  8737. lmessage.append(addressBytes[1]);
  8738. lmessage.append(addressBytes[0]);
  8739. lmessage.append((char)0x00);
  8740. lmessage.append((char)0x01);
  8741. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8742. QByteArray umessage;
  8743. umessage.append(station);
  8744. umessage.append((char)0x03);
  8745. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8746. addressBytes= (char*)&uaddress;
  8747. umessage.append(addressBytes[1]);
  8748. umessage.append(addressBytes[0]);
  8749. umessage.append((char)0x00);
  8750. umessage.append((char)0x01);
  8751. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8752. }
  8753. else
  8754. {
  8755. outputSVLower= attributes.value("sVLower").toDouble();
  8756. outputSVUpper= attributes.value("sVUpper").toDouble();
  8757. }
  8758. outputSVStub.append(station);
  8759. outputSVStub.append((char)0x06);
  8760. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8761. char*addressBytes= (char*)&address;
  8762. outputSVStub.append(addressBytes[1]);
  8763. outputSVStub.append(addressBytes[0]);
  8764. }
  8765. Channel*pv= new Channel;
  8766. channels.append(pv);
  8767. pvStub.append(station);
  8768. pvStub.append((char)0x04);
  8769. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8770. char*pvac= (char*)&pvaddress;
  8771. pvStub.append(pvac[1]);
  8772. pvStub.append(pvac[0]);
  8773. pvStub.append((char)0x00);
  8774. pvStub.append((char)0x01);
  8775. svenabled= attributes.value("sVEnabled").toBool();
  8776. if(svenabled)
  8777. {
  8778. Channel*sv= new Channel;
  8779. channels.append(sv);
  8780. svStub.append(station);
  8781. svStub.append((char)0x04);
  8782. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8783. char*svac= (char*)&svaddress;
  8784. svStub.append(svac[1]);
  8785. svStub.append(svac[0]);
  8786. svStub.append((char)0x00);
  8787. svStub.append((char)0x01);
  8788. if(svaddress-pvaddress==1)
  8789. {
  8790. mStub.append(station);
  8791. mStub.append((char)0x04);
  8792. mStub.append(pvac[1]);
  8793. mStub.append(pvac[0]);
  8794. mStub.append((char)0x00);
  8795. mStub.append((char)0x02);
  8796. }
  8797. }
  8798. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8799. requestMeasurement();
  8800. }
  8801. double ModbusRTUDevice::SVLower()
  8802. {
  8803. return outputSVLower;
  8804. }
  8805. double ModbusRTUDevice::SVUpper()
  8806. {
  8807. return outputSVUpper;
  8808. }
  8809. int ModbusRTUDevice::decimals()
  8810. {
  8811. return decimalPosition;
  8812. }
  8813. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8814. {
  8815. quint16 temp;
  8816. char*tchar= (char*)&temp;
  8817. tchar[1]= response.at(3);
  8818. tchar[0]= response.at(4);
  8819. decimalPosition= temp;
  8820. emit SVDecimalChanged(decimalPosition);
  8821. qDebug()<<"Received decimal response";
  8822. }
  8823. void ModbusRTUDevice::unitResponse(QByteArray response)
  8824. {
  8825. quint16 temp;
  8826. char*tchar= (char*)&temp;
  8827. tchar[1]= response.at(3);
  8828. tchar[0]= response.at(4);
  8829. int value= temp;
  8830. if(value==valueF)
  8831. {
  8832. unitIsF= true;
  8833. }
  8834. else
  8835. {
  8836. unitIsF= false;
  8837. }
  8838. qDebug()<<"Received unit response";
  8839. }
  8840. void ModbusRTUDevice::svlResponse(QByteArray response)
  8841. {
  8842. quint16 temp;
  8843. char*tchar= (char*)&temp;
  8844. tchar[1]= response.at(3);
  8845. tchar[0]= response.at(4);
  8846. outputSVLower= (double)temp;
  8847. for(int i= 0;i<decimalPosition;i++)
  8848. {
  8849. outputSVLower/= 10;
  8850. }
  8851. emit SVLowerChanged(outputSVLower);
  8852. qDebug()<<"Received set value lower bound response";
  8853. }
  8854. void ModbusRTUDevice::svuResponse(QByteArray response)
  8855. {
  8856. quint16 temp;
  8857. char*tchar= (char*)&temp;
  8858. tchar[1]= response.at(3);
  8859. tchar[0]= response.at(4);
  8860. outputSVUpper= (double)temp;
  8861. for(int i= 0;i<decimalPosition;i++)
  8862. {
  8863. outputSVUpper/= 10;
  8864. }
  8865. emit SVUpperChanged(outputSVUpper);
  8866. qDebug()<<"Received set value upper bound response";
  8867. }
  8868. void ModbusRTUDevice::requestMeasurement()
  8869. {
  8870. if(mStub.length()> 0)
  8871. {
  8872. queueMessage(mStub,this,"mResponse(QByteArray)");
  8873. }
  8874. else
  8875. {
  8876. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8877. if(svenabled)
  8878. {
  8879. queueMessage(svStub,this,"mResponse(QByteArray)");
  8880. }
  8881. }
  8882. }
  8883. void ModbusRTUDevice::mResponse(QByteArray response)
  8884. {
  8885. QTime time= QTime::currentTime();
  8886. if(response.at(2)==0x04)
  8887. {
  8888. /*876:*/
  8889. #line 18623 "./typica.w"
  8890. quint16 pv;
  8891. quint16 sv;
  8892. char*pvBytes= (char*)&pv;
  8893. char*svBytes= (char*)&sv;
  8894. pvBytes[1]= response.at(3);
  8895. pvBytes[0]= response.at(4);
  8896. svBytes[1]= response.at(5);
  8897. svBytes[0]= response.at(6);
  8898. double pvOut= (double)pv;
  8899. double svOut= (double)sv;
  8900. for(int i= 0;i<decimalPosition;i++)
  8901. {
  8902. pvOut/= 10;
  8903. svOut/= 10;
  8904. }
  8905. if(!unitIsF)
  8906. {
  8907. pvOut= pvOut*9/5+32;
  8908. svOut= svOut*9/5+32;
  8909. }
  8910. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8911. Measurement svm(svOut,time,Units::Fahrenheit);
  8912. channels.at(0)->input(pvm);
  8913. channels.at(1)->input(svm);
  8914. /*:876*/
  8915. #line 18610 "./typica.w"
  8916. }
  8917. else
  8918. {
  8919. /*877:*/
  8920. #line 18653 "./typica.w"
  8921. quint16 value;
  8922. char*valueBytes= (char*)&value;
  8923. valueBytes[1]= response.at(3);
  8924. valueBytes[0]= response.at(4);
  8925. double valueOut= (double)value;
  8926. for(int i= 0;i<decimalPosition;i++)
  8927. {
  8928. valueOut/= 10;
  8929. }
  8930. if(!unitIsF)
  8931. {
  8932. valueOut= valueOut*9/5+32;
  8933. }
  8934. if(!svenabled)
  8935. {
  8936. Measurement vm(valueOut,time,Units::Fahrenheit);
  8937. channels.at(0)->input(vm);
  8938. }
  8939. else
  8940. {
  8941. if(readingsv)
  8942. {
  8943. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8944. Measurement svm(valueOut,time,Units::Fahrenheit);
  8945. channels.at(0)->input(pvm);
  8946. channels.at(1)->input(svm);
  8947. readingsv= false;
  8948. }
  8949. else
  8950. {
  8951. savedpv= valueOut;
  8952. readingsv= true;
  8953. }
  8954. }
  8955. /*:877*/
  8956. #line 18614 "./typica.w"
  8957. }
  8958. }
  8959. /*:875*//*878:*/
  8960. #line 18691 "./typica.w"
  8961. ModbusRTUDevice::~ModbusRTUDevice()
  8962. {
  8963. commTimeout->stop();
  8964. messageDelayTimer->stop();
  8965. port->close();
  8966. }
  8967. /*:878*//*879:*/
  8968. #line 18718 "./typica.w"
  8969. void ModbusRTUDevice::dataAvailable()
  8970. {
  8971. if(messageDelayTimer->isActive())
  8972. {
  8973. messageDelayTimer->stop();
  8974. }
  8975. responseBuffer.append(port->readAll());
  8976. /*880:*/
  8977. #line 18764 "./typica.w"
  8978. if(responseBuffer.size()<5)
  8979. {
  8980. return;
  8981. }
  8982. switch(responseBuffer.at(1))
  8983. {
  8984. case 0x01:
  8985. case 0x02:
  8986. if(responseBuffer.size()<6)
  8987. {
  8988. return;
  8989. }
  8990. responseBuffer= responseBuffer.left(6);
  8991. break;
  8992. case 0x03:
  8993. case 0x04:
  8994. if(responseBuffer.size()<5+responseBuffer.at(2))
  8995. {
  8996. return;
  8997. }
  8998. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8999. break;
  9000. case 0x05:
  9001. case 0x06:
  9002. case 0x10:
  9003. if(responseBuffer.size()<8)
  9004. {
  9005. return;
  9006. }
  9007. responseBuffer= responseBuffer.left(8);
  9008. break;
  9009. }
  9010. /*:880*/
  9011. #line 18726 "./typica.w"
  9012. commTimeout->stop();
  9013. if(calculateCRC(responseBuffer)==0)
  9014. {
  9015. QObject*object= retObjQueue.at(0);
  9016. char*method= callbackQueue.at(0);
  9017. QMetaMethod metamethod= object->metaObject()->
  9018. method(object->metaObject()->
  9019. indexOfMethod(QMetaObject::normalizedSignature(method)));
  9020. metamethod.invoke(object,Qt::QueuedConnection,
  9021. Q_ARG(QByteArray,responseBuffer));
  9022. messageQueue.removeAt(0);
  9023. retObjQueue.removeAt(0);
  9024. callbackQueue.removeAt(0);
  9025. }
  9026. else
  9027. {
  9028. qDebug()<<"CRC failed";
  9029. }
  9030. messageDelayTimer->start(delayTime);
  9031. waiting= false;
  9032. responseBuffer.clear();
  9033. }
  9034. /*:879*//*881:*/
  9035. #line 18806 "./typica.w"
  9036. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  9037. {
  9038. quint16 retval= 0xFFFF;
  9039. int i= 0;
  9040. while(i<data.size())
  9041. {
  9042. retval^= 0x00FF&(quint16)data.at(i);
  9043. for(int j= 0;j<8;j++)
  9044. {
  9045. if(retval&1)
  9046. {
  9047. retval= (retval>>1)^0xA001;
  9048. }
  9049. else
  9050. {
  9051. retval>>= 1;
  9052. }
  9053. }
  9054. i++;
  9055. }
  9056. return retval;
  9057. }
  9058. /*:881*//*882:*/
  9059. #line 18837 "./typica.w"
  9060. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9061. const char*callback)
  9062. {
  9063. messageQueue.append(request);
  9064. retObjQueue.append(object);
  9065. callbackQueue.append(const_cast<char*> (callback));
  9066. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9067. {
  9068. sendNextMessage();
  9069. }
  9070. }
  9071. void ModbusRTUDevice::sendNextMessage()
  9072. {
  9073. if(messageQueue.size()> 0&&!waiting)
  9074. {
  9075. QByteArray message= messageQueue.at(0);
  9076. quint16 crc= calculateCRC(message);
  9077. char*check= (char*)&crc;
  9078. message.append(check[0]);
  9079. message.append(check[1]);
  9080. qDebug()<<"Writing"<<message.toHex();
  9081. port->write(message);
  9082. commTimeout->start(2000);
  9083. messageDelayTimer->start(delayTime);
  9084. waiting= true;
  9085. }
  9086. else
  9087. {
  9088. emit queueEmpty();
  9089. }
  9090. }
  9091. void ModbusRTUDevice::outputSV(double value)
  9092. {
  9093. for(int i= 0;i<decimalPosition;i++)
  9094. {
  9095. value*= 10;
  9096. }
  9097. quint16 outval= (quint16)value;
  9098. QByteArray message(outputSVStub);
  9099. char*valBytes= (char*)&outval;
  9100. message.append(valBytes[1]);
  9101. message.append(valBytes[0]);
  9102. queueMessage(message,this,"ignore(QByteArray)");
  9103. }
  9104. /*:882*//*883:*/
  9105. #line 18887 "./typica.w"
  9106. void ModbusRTUDevice::ignore(QByteArray)
  9107. {
  9108. return;
  9109. }
  9110. /*:883*//*884:*/
  9111. #line 18900 "./typica.w"
  9112. void ModbusRTUDevice::timeout()
  9113. {
  9114. qDebug()<<"Communications timeout.";
  9115. responseBuffer.clear();
  9116. waiting= false;
  9117. messageDelayTimer->start();
  9118. }
  9119. /*:884*/
  9120. #line 580 "./typica.w"
  9121. /*753:*/
  9122. #line 15455 "./typica.w"
  9123. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9124. DeviceTreeModelNode*parent)
  9125. :domNode(node),rowNumber(row),parentItem(parent)
  9126. {
  9127. }
  9128. DeviceTreeModelNode::~DeviceTreeModelNode()
  9129. {
  9130. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9131. for(i= children.begin();i!=children.end();i++)
  9132. {
  9133. delete i.value();
  9134. }
  9135. }
  9136. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9137. {
  9138. return parentItem;
  9139. }
  9140. int DeviceTreeModelNode::row()
  9141. {
  9142. return rowNumber;
  9143. }
  9144. QDomNode DeviceTreeModelNode::node()const
  9145. {
  9146. return domNode;
  9147. }
  9148. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9149. {
  9150. if(children.contains(index))
  9151. {
  9152. return children[index];
  9153. }
  9154. if(index>=0&&index<domNode.childNodes().count())
  9155. {
  9156. QDomNode childNode= domNode.childNodes().item(index);
  9157. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9158. index,this);
  9159. children[index]= childItem;
  9160. return childItem;
  9161. }
  9162. return NULL;
  9163. }
  9164. /*:753*/
  9165. #line 581 "./typica.w"
  9166. /*755:*/
  9167. #line 15544 "./typica.w"
  9168. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9169. :QAbstractItemModel(parent)
  9170. {
  9171. document= AppInstance->deviceConfiguration();
  9172. QDomNodeList elements= document.elementsByTagName("devices");
  9173. if(elements.size()!=1)
  9174. {
  9175. qDebug()<<"Unexpected result when loading device map.";
  9176. }
  9177. treeRoot= elements.at(0);
  9178. root= new DeviceTreeModelNode(treeRoot,0);
  9179. elements= document.elementsByTagName("references");
  9180. if(elements.size()!=1)
  9181. {
  9182. qDebug()<<"No references section. Creating.";
  9183. referenceSection= document.createElement("references");
  9184. document.appendChild(referenceSection);
  9185. }
  9186. else
  9187. {
  9188. referenceSection= elements.at(0);
  9189. }
  9190. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9191. AppInstance,SLOT(saveDeviceConfiguration()));
  9192. connect(this,SIGNAL(modelReset()),
  9193. AppInstance,SLOT(saveDeviceConfiguration()));
  9194. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9195. AppInstance,SLOT(saveDeviceConfiguration()));
  9196. }
  9197. /*:755*//*756:*/
  9198. #line 15579 "./typica.w"
  9199. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9200. {
  9201. return 1;
  9202. }
  9203. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9204. {
  9205. if(parent.column()> 0)
  9206. {
  9207. return 0;
  9208. }
  9209. /*757:*/
  9210. #line 15598 "./typica.w"
  9211. DeviceTreeModelNode*parentItem;
  9212. if(!parent.isValid())
  9213. {
  9214. parentItem= root;
  9215. }
  9216. else
  9217. {
  9218. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9219. }
  9220. /*:757*/
  9221. #line 15591 "./typica.w"
  9222. return parentItem->node().childNodes().count();
  9223. }
  9224. /*:756*//*758:*/
  9225. #line 15612 "./typica.w"
  9226. QModelIndex DeviceTreeModel::index(int row,int column,
  9227. const QModelIndex&parent)const
  9228. {
  9229. if(!hasIndex(row,column,parent))
  9230. {
  9231. return QModelIndex();
  9232. }
  9233. /*757:*/
  9234. #line 15598 "./typica.w"
  9235. DeviceTreeModelNode*parentItem;
  9236. if(!parent.isValid())
  9237. {
  9238. parentItem= root;
  9239. }
  9240. else
  9241. {
  9242. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9243. }
  9244. /*:757*/
  9245. #line 15620 "./typica.w"
  9246. DeviceTreeModelNode*childItem= parentItem->child(row);
  9247. if(childItem)
  9248. {
  9249. return createIndex(row,column,childItem);
  9250. }
  9251. return QModelIndex();
  9252. }
  9253. /*:758*//*759:*/
  9254. #line 15631 "./typica.w"
  9255. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9256. {
  9257. if(!child.isValid())
  9258. {
  9259. return QModelIndex();
  9260. }
  9261. DeviceTreeModelNode*childItem=
  9262. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9263. DeviceTreeModelNode*parentItem= childItem->parent();
  9264. if(!parentItem||parentItem==root)
  9265. {
  9266. return QModelIndex();
  9267. }
  9268. return createIndex(parentItem->row(),0,parentItem);
  9269. }
  9270. /*:759*//*760:*/
  9271. #line 15650 "./typica.w"
  9272. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9273. {
  9274. if(!index.isValid())
  9275. {
  9276. return 0;
  9277. }
  9278. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9279. }
  9280. /*:760*//*761:*/
  9281. #line 15665 "./typica.w"
  9282. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9283. {
  9284. if(!index.isValid())
  9285. {
  9286. return QVariant();
  9287. }
  9288. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9289. {
  9290. return QVariant();
  9291. }
  9292. DeviceTreeModelNode*item=
  9293. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9294. QDomNode node= item->node();
  9295. QDomElement element= node.toElement();
  9296. switch(role)
  9297. {
  9298. case Qt::DisplayRole:
  9299. case Qt::EditRole:
  9300. return QVariant(element.attribute("name"));
  9301. case Qt::UserRole:
  9302. return QVariant(element.attribute("reference"));
  9303. default:
  9304. return QVariant();
  9305. }
  9306. return QVariant();
  9307. }
  9308. /*:761*//*762:*/
  9309. #line 15697 "./typica.w"
  9310. bool DeviceTreeModel::setData(const QModelIndex&index,
  9311. const QVariant&value,int)
  9312. {
  9313. if(!index.isValid())
  9314. {
  9315. return false;
  9316. }
  9317. DeviceTreeModelNode*item=
  9318. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9319. QDomNode node= item->node();
  9320. QDomElement element= node.toElement();
  9321. element.setAttribute("name",value.toString());
  9322. emit dataChanged(index,index);
  9323. return true;
  9324. }
  9325. /*:762*//*763:*/
  9326. #line 15720 "./typica.w"
  9327. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9328. const QModelIndex&parent)
  9329. {
  9330. QString referenceID= QUuid::createUuid().toString();
  9331. /*757:*/
  9332. #line 15598 "./typica.w"
  9333. DeviceTreeModelNode*parentItem;
  9334. if(!parent.isValid())
  9335. {
  9336. parentItem= root;
  9337. }
  9338. else
  9339. {
  9340. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9341. }
  9342. /*:757*/
  9343. #line 15725 "./typica.w"
  9344. QDomNode parentNode= parentItem->node();
  9345. int newRowNumber= rowCount(parent);
  9346. beginInsertRows(parent,newRowNumber,newRowNumber);
  9347. QDomElement deviceElement= document.createElement("node");
  9348. deviceElement.setAttribute("name",name);
  9349. deviceElement.setAttribute("reference",referenceID);
  9350. parentNode.appendChild(deviceElement);
  9351. QDomElement referenceElement= document.createElement("reference");
  9352. referenceElement.setAttribute("id",referenceID);
  9353. referenceElement.setAttribute("driver",driver);
  9354. referenceSection.appendChild(referenceElement);
  9355. endInsertRows();
  9356. }
  9357. /*:763*//*764:*/
  9358. #line 15743 "./typica.w"
  9359. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9360. {
  9361. /*757:*/
  9362. #line 15598 "./typica.w"
  9363. DeviceTreeModelNode*parentItem;
  9364. if(!parent.isValid())
  9365. {
  9366. parentItem= root;
  9367. }
  9368. else
  9369. {
  9370. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9371. }
  9372. /*:757*/
  9373. #line 15746 "./typica.w"
  9374. QDomNode parentNode= parentItem->node();
  9375. QDomNodeList childNodes= parentNode.childNodes();
  9376. if(childNodes.size()<row+count)
  9377. {
  9378. return false;
  9379. }
  9380. beginRemoveRows(parent,row,row+count-1);
  9381. QList<QDomElement> removalList;
  9382. for(int i= row;i<row+count;i++)
  9383. {
  9384. removalList.append(childNodes.at(i).toElement());
  9385. }
  9386. QDomElement element;
  9387. QDomElement reference;
  9388. for(int i= 0;i<count;i++)
  9389. {
  9390. element= removalList.at(i);
  9391. if(element.hasAttribute("reference"))
  9392. {
  9393. reference= referenceElement(element.attribute("reference"));
  9394. if(!reference.isNull())
  9395. {
  9396. referenceSection.removeChild(reference);
  9397. }
  9398. }
  9399. parentNode.removeChild(element);
  9400. }
  9401. endRemoveRows();
  9402. beginResetModel();
  9403. delete root;
  9404. root= new DeviceTreeModelNode(treeRoot,0);
  9405. endResetModel();
  9406. return true;
  9407. }
  9408. /*:764*//*765:*/
  9409. #line 15785 "./typica.w"
  9410. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9411. {
  9412. QDomNodeList childNodes= referenceSection.childNodes();
  9413. QDomElement element;
  9414. for(int i= 0;i<childNodes.size();i++)
  9415. {
  9416. element= childNodes.at(i).toElement();
  9417. if(element.hasAttribute("id"))
  9418. {
  9419. if(element.attribute("id")==id)
  9420. {
  9421. return element;
  9422. }
  9423. }
  9424. }
  9425. return QDomElement();
  9426. }
  9427. /*:765*//*766:*/
  9428. #line 15806 "./typica.w"
  9429. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9430. {
  9431. return QVariant();
  9432. }
  9433. /*:766*//*767:*/
  9434. #line 15815 "./typica.w"
  9435. DeviceTreeModel::~DeviceTreeModel()
  9436. {
  9437. delete root;
  9438. }
  9439. /*:767*/
  9440. #line 582 "./typica.w"
  9441. /*794:*/
  9442. #line 16315 "./typica.w"
  9443. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9444. DeviceTreeModel*model,const QModelIndex&index)
  9445. :QWidget(NULL),deviceModel(model),currentNode(index)
  9446. {
  9447. }
  9448. /*:794*//*795:*/
  9449. #line 16327 "./typica.w"
  9450. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9451. const QString&value)
  9452. {
  9453. QDomElement referenceElement= deviceModel->referenceElement(
  9454. deviceModel->data(currentNode,Qt::UserRole).toString());
  9455. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9456. QDomElement node;
  9457. bool found= false;
  9458. for(int i= 0;i<configData.size();i++)
  9459. {
  9460. node= configData.at(i).toElement();
  9461. if(node.attribute("name")==name)
  9462. {
  9463. node.setAttribute("value",value);
  9464. found= true;
  9465. break;
  9466. }
  9467. }
  9468. if(!found)
  9469. {
  9470. node= AppInstance->deviceConfiguration().createElement("attribute");
  9471. node.setAttribute("name",name);
  9472. node.setAttribute("value",value);
  9473. referenceElement.appendChild(node);
  9474. }
  9475. AppInstance->saveDeviceConfiguration();
  9476. }
  9477. /*:795*//*796:*/
  9478. #line 16361 "./typica.w"
  9479. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9480. const QString&driver)
  9481. {
  9482. deviceModel->newNode(name,driver,currentNode);
  9483. }
  9484. /*:796*/
  9485. #line 583 "./typica.w"
  9486. /*785:*/
  9487. #line 16159 "./typica.w"
  9488. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9489. view(new QTreeView),configArea(new QScrollArea)
  9490. {
  9491. QSplitter*splitter= new QSplitter;
  9492. QWidget*leftWidget= new QWidget;
  9493. leftWidget->setMinimumWidth(200);
  9494. QVBoxLayout*left= new QVBoxLayout;
  9495. view->setAnimated(true);
  9496. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9497. document= AppInstance->deviceConfiguration();
  9498. model= new DeviceTreeModel;
  9499. view->setModel(model);
  9500. view->setTextElideMode(Qt::ElideNone);
  9501. view->expandAll();
  9502. view->resizeColumnToContents(0);
  9503. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9504. QHBoxLayout*treeButtons= new QHBoxLayout;
  9505. QToolButton*addDeviceButton= new QToolButton;
  9506. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9507. addDeviceButton->setToolTip(tr("New Roaster"));
  9508. connect(addDeviceButton,SIGNAL(clicked()),
  9509. this,SLOT(addDevice()));
  9510. QToolButton*removeNodeButton= new QToolButton;
  9511. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9512. removeNodeButton->setToolTip(tr("Delete Selection"));
  9513. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9514. treeButtons->addWidget(addDeviceButton);
  9515. treeButtons->addWidget(removeNodeButton);
  9516. left->addWidget(view);
  9517. left->addLayout(treeButtons);
  9518. leftWidget->setLayout(left);
  9519. splitter->addWidget(leftWidget);
  9520. configArea->setMinimumWidth(580);
  9521. configArea->setMinimumHeight(460);
  9522. configArea->setWidgetResizable(true);
  9523. splitter->addWidget(configArea);
  9524. QVBoxLayout*centralLayout= new QVBoxLayout;
  9525. centralLayout->addWidget(splitter);
  9526. setLayout(centralLayout);
  9527. connect(view,SIGNAL(activated(QModelIndex)),
  9528. this,SLOT(newSelection(QModelIndex)));
  9529. connect(view,SIGNAL(clicked(QModelIndex)),
  9530. this,SLOT(newSelection(QModelIndex)));
  9531. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9532. view,SLOT(expand(QModelIndex)));
  9533. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9534. this,SLOT(resizeColumn()));
  9535. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9536. this,SLOT(resizeColumn()));
  9537. }
  9538. /*:785*//*786:*/
  9539. #line 16214 "./typica.w"
  9540. void DeviceConfigurationWindow::addDevice()
  9541. {
  9542. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9543. }
  9544. /*:786*//*787:*/
  9545. #line 16222 "./typica.w"
  9546. void DeviceConfigurationWindow::removeNode()
  9547. {
  9548. QModelIndex index= view->currentIndex();
  9549. if(index.isValid())
  9550. {
  9551. int row= index.row();
  9552. QModelIndex parent= index.parent();
  9553. model->removeRow(row,parent);
  9554. }
  9555. }
  9556. /*:787*//*788:*/
  9557. #line 16238 "./typica.w"
  9558. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9559. {
  9560. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9561. if(editor)
  9562. {
  9563. configArea->setWidget(editor);
  9564. editor->show();
  9565. }
  9566. }
  9567. /*:788*//*789:*/
  9568. #line 16255 "./typica.w"
  9569. void DeviceConfigurationWindow::resizeColumn()
  9570. {
  9571. view->resizeColumnToContents(0);
  9572. }
  9573. /*:789*/
  9574. #line 584 "./typica.w"
  9575. /*809:*/
  9576. #line 16736 "./typica.w"
  9577. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9578. const QModelIndex&index):
  9579. BasicDeviceConfigurationWidget(model,index)
  9580. {
  9581. QFormLayout*layout= new QFormLayout;
  9582. QLineEdit*columnName= new QLineEdit;
  9583. layout->addRow(tr("Column Name:"),columnName);
  9584. QComboBox*typeSelector= new QComboBox;
  9585. typeSelector->addItem("J");
  9586. typeSelector->addItem("K");
  9587. typeSelector->addItem("T");
  9588. typeSelector->addItem("B");
  9589. typeSelector->addItem("E");
  9590. typeSelector->addItem("N");
  9591. typeSelector->addItem("R");
  9592. typeSelector->addItem("S");
  9593. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9594. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9595. layout->addRow(hideSeries);
  9596. setLayout(layout);
  9597. /*799:*/
  9598. #line 16530 "./typica.w"
  9599. QDomElement referenceElement=
  9600. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9601. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9602. QDomElement node;
  9603. /*:799*/
  9604. #line 16757 "./typica.w"
  9605. for(int i= 0;i<configData.size();i++)
  9606. {
  9607. node= configData.at(i).toElement();
  9608. if(node.attribute("name")=="type")
  9609. {
  9610. typeSelector->setCurrentIndex(
  9611. typeSelector->findText(node.attribute("value")));
  9612. }
  9613. else if(node.attribute("name")=="columnname")
  9614. {
  9615. columnName->setText(node.attribute("value"));
  9616. }
  9617. else if(node.attribute("name")=="hidden")
  9618. {
  9619. hideSeries->setChecked(node.attribute("value")=="true");
  9620. }
  9621. }
  9622. updateThermocoupleType(typeSelector->currentText());
  9623. updateColumnName(columnName->text());
  9624. updateHidden(hideSeries->isChecked());
  9625. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9626. this,SLOT(updateThermocoupleType(QString)));
  9627. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9628. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9629. }
  9630. /*:809*//*810:*/
  9631. #line 16787 "./typica.w"
  9632. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9633. {
  9634. updateAttribute("type",type);
  9635. }
  9636. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9637. {
  9638. updateAttribute("columnname",name);
  9639. }
  9640. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9641. {
  9642. updateAttribute("hidden",hidden?"true":"false");
  9643. }
  9644. /*:810*/
  9645. #line 585 "./typica.w"
  9646. /*805:*/
  9647. #line 16650 "./typica.w"
  9648. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9649. const QModelIndex&index)
  9650. :BasicDeviceConfigurationWidget(model,index)
  9651. {
  9652. QVBoxLayout*layout= new QVBoxLayout;
  9653. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9654. QLabel*label= new QLabel(tr("Device ID:"));
  9655. QLineEdit*deviceId= new QLineEdit;
  9656. deviceIdLayout->addWidget(label);
  9657. deviceIdLayout->addWidget(deviceId);
  9658. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9659. layout->addLayout(deviceIdLayout);
  9660. layout->addWidget(addChannelButton);
  9661. /*799:*/
  9662. #line 16530 "./typica.w"
  9663. QDomElement referenceElement=
  9664. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9665. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9666. QDomElement node;
  9667. /*:799*/
  9668. #line 16664 "./typica.w"
  9669. for(int i= 0;i<configData.size();i++)
  9670. {
  9671. node= configData.at(i).toElement();
  9672. if(node.attribute("name")=="deviceID")
  9673. {
  9674. deviceId->setText(node.attribute("value","Dev1"));
  9675. break;
  9676. }
  9677. }
  9678. updateDeviceId(deviceId->text());
  9679. connect(addChannelButton,SIGNAL(clicked()),
  9680. this,SLOT(addChannel()));
  9681. connect(deviceId,SIGNAL(textEdited(QString)),
  9682. this,SLOT(updateDeviceId(QString)));
  9683. setLayout(layout);
  9684. }
  9685. /*:805*//*806:*/
  9686. #line 16686 "./typica.w"
  9687. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9688. {
  9689. updateAttribute("deviceID",newId);
  9690. }
  9691. /*:806*//*807:*/
  9692. #line 16694 "./typica.w"
  9693. void NiDaqMxBase9211ConfWidget::addChannel()
  9694. {
  9695. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9696. }
  9697. /*:807*/
  9698. #line 586 "./typica.w"
  9699. /*803:*/
  9700. #line 16601 "./typica.w"
  9701. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9702. DeviceTreeModel*model,const QModelIndex&index):
  9703. BasicDeviceConfigurationWidget(model,index)
  9704. {
  9705. QHBoxLayout*layout= new QHBoxLayout;
  9706. QToolButton*addDeviceButton= new QToolButton;
  9707. addDeviceButton->setText(tr("Add Device"));
  9708. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9709. "nidaqmxbase9211series");
  9710. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9711. "nidaqmxbase9211series");
  9712. connect(add9211,SIGNAL(triggered(QString,QString)),
  9713. this,SLOT(insertChildNode(QString,QString)));
  9714. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9715. this,SLOT(insertChildNode(QString,QString)));
  9716. QMenu*deviceMenu= new QMenu;
  9717. deviceMenu->addAction(add9211);
  9718. deviceMenu->addAction(add9211a);
  9719. addDeviceButton->setMenu(deviceMenu);
  9720. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9721. layout->addWidget(addDeviceButton);
  9722. setLayout(layout);
  9723. }
  9724. /*:803*/
  9725. #line 587 "./typica.w"
  9726. /*664:*/
  9727. #line 14073 "./typica.w"
  9728. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9729. QObject*parent):
  9730. QAction(reportName,parent),reportFile(fileName)
  9731. {
  9732. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9733. }
  9734. /*:664*//*665:*/
  9735. #line 14089 "./typica.w"
  9736. void ReportAction::createReport()
  9737. {
  9738. QFile file(reportFile);
  9739. QDomDocument document;
  9740. if(file.open(QIODevice::ReadOnly))
  9741. {
  9742. document.setContent(&file,true);
  9743. QDomElement element= document.documentElement();
  9744. QScriptEngine*engine= AppInstance->engine;
  9745. QScriptContext*context= engine->pushContext();
  9746. QScriptValue object;
  9747. QString targetID= reportFile;
  9748. /*201:*/
  9749. #line 4679 "./typica.w"
  9750. ScriptQMainWindow*window= new ScriptQMainWindow;
  9751. window->setObjectName(targetID);
  9752. object= engine->newQObject(window);
  9753. setQMainWindowProperties(object,engine);
  9754. QWidget*central= new(QWidget);
  9755. central->setParent(window);
  9756. central->setObjectName("centralWidget");
  9757. window->setCentralWidget(central);
  9758. if(element.hasChildNodes())
  9759. {
  9760. /*202:*/
  9761. #line 4714 "./typica.w"
  9762. QStack<QWidget*> widgetStack;
  9763. QStack<QLayout*> layoutStack;
  9764. QString windowScript;
  9765. widgetStack.push(central);
  9766. QDomNodeList windowChildren= element.childNodes();
  9767. int i= 0;
  9768. while(i<windowChildren.count())
  9769. {
  9770. QDomNode current;
  9771. QDomElement element;
  9772. current= windowChildren.at(i);
  9773. if(current.isElement())
  9774. {
  9775. element= current.toElement();
  9776. if(element.tagName()=="program")
  9777. {
  9778. windowScript.append(element.text());
  9779. }
  9780. else if(element.tagName()=="layout")
  9781. {
  9782. element.setAttribute("trcontext","configuration");
  9783. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9784. }
  9785. else if(element.tagName()=="menu")
  9786. {
  9787. /*203:*/
  9788. #line 4762 "./typica.w"
  9789. QMenuBar*bar= window->menuBar();
  9790. bar->setParent(window);
  9791. bar->setObjectName("menuBar");
  9792. if(element.hasAttribute("name"))
  9793. {
  9794. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  9795. element.attribute("name").toUtf8().data()));
  9796. menu->setParent(bar);
  9797. if(element.hasAttribute("type"))
  9798. {
  9799. if(element.attribute("type")=="reports")
  9800. {
  9801. if(element.hasAttribute("src"))
  9802. {
  9803. /*662:*/
  9804. #line 14033 "./typica.w"
  9805. QSettings settings;
  9806. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9807. toString()).
  9808. arg(element.attribute("src"));
  9809. QDir::addSearchPath("reports",reportDirectory);
  9810. QDir directory(reportDirectory);
  9811. directory.setFilter(QDir::Files);
  9812. directory.setSorting(QDir::Name);
  9813. QStringList nameFilter;
  9814. nameFilter<<"*.xml";
  9815. directory.setNameFilters(nameFilter);
  9816. QFileInfoList reportFiles= directory.entryInfoList();
  9817. for(int i= 0;i<reportFiles.size();i++)
  9818. {
  9819. QFileInfo reportFile= reportFiles.at(i);
  9820. /*666:*/
  9821. #line 14113 "./typica.w"
  9822. QString path= reportFile.absoluteFilePath();
  9823. QFile file(path);
  9824. if(file.open(QIODevice::ReadOnly))
  9825. {
  9826. QDomDocument document;
  9827. document.setContent(&file,true);
  9828. QDomElement root= document.documentElement();
  9829. QString translationContext= root.attribute("id");
  9830. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9831. if(!titleNode.isNull())
  9832. {
  9833. QDomElement titleElement= titleNode.toElement();
  9834. QString title= QCoreApplication::translate("configuration",
  9835. titleElement.text().toUtf8().data());
  9836. if(!title.isEmpty())
  9837. {
  9838. QStringList hierarchy= title.split(":->");
  9839. QMenu*insertionPoint= menu;
  9840. /*667:*/
  9841. #line 14142 "./typica.w"
  9842. for(int j= 0;j<hierarchy.size()-1;j++)
  9843. {
  9844. QObjectList menuList= insertionPoint->children();
  9845. bool menuFound= false;
  9846. for(int k= 0;k<menuList.size();k++)
  9847. {
  9848. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9849. if(currentItem)
  9850. {
  9851. if(currentItem->title()==hierarchy.at(j))
  9852. {
  9853. menuFound= true;
  9854. insertionPoint= currentItem;
  9855. break;
  9856. }
  9857. }
  9858. }
  9859. if(!menuFound)
  9860. {
  9861. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9862. }
  9863. }
  9864. /*:667*/
  9865. #line 14132 "./typica.w"
  9866. ReportAction*action= new ReportAction(path,hierarchy.last());
  9867. insertionPoint->addAction(action);
  9868. }
  9869. }
  9870. }
  9871. /*:666*/
  9872. #line 14049 "./typica.w"
  9873. }
  9874. /*:662*/
  9875. #line 4777 "./typica.w"
  9876. }
  9877. }
  9878. }
  9879. if(element.hasChildNodes())
  9880. {
  9881. /*204:*/
  9882. #line 4790 "./typica.w"
  9883. QDomNodeList menuItems= element.childNodes();
  9884. int j= 0;
  9885. while(j<menuItems.count())
  9886. {
  9887. QDomNode item= menuItems.at(j);
  9888. if(item.isElement())
  9889. {
  9890. QDomElement itemElement= item.toElement();
  9891. if(itemElement.tagName()=="item")
  9892. {
  9893. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  9894. itemElement.text().toUtf8().data()),menu);
  9895. if(itemElement.hasAttribute("id"))
  9896. {
  9897. itemAction->setObjectName(itemElement.attribute("id"));
  9898. }
  9899. if(itemElement.hasAttribute("shortcut"))
  9900. {
  9901. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9902. }
  9903. menu->addAction(itemAction);
  9904. }
  9905. else if(itemElement.tagName()=="separator")
  9906. {
  9907. menu->addSeparator();
  9908. }
  9909. else if(itemElement.tagName()=="plugins")
  9910. {
  9911. /*687:*/
  9912. #line 21 "./plugins.w"
  9913. QMenu*pluginMenu= new QMenu(menu);
  9914. if(itemElement.hasAttribute("id"))
  9915. {
  9916. pluginMenu->setObjectName(itemElement.attribute("id"));
  9917. }
  9918. if(itemElement.hasAttribute("title"))
  9919. {
  9920. pluginMenu->setTitle(itemElement.attribute("title"));
  9921. }
  9922. if(itemElement.hasAttribute("src"))
  9923. {
  9924. QSettings settings;
  9925. QString pluginDirectory= QString("%1/%2").
  9926. arg(settings.value("config").toString()).
  9927. arg(itemElement.attribute("src"));
  9928. QDir directory(pluginDirectory);
  9929. directory.setFilter(QDir::Files);
  9930. directory.setSorting(QDir::Name);
  9931. QStringList nameFilter;
  9932. nameFilter<<"*.js";
  9933. directory.setNameFilters(nameFilter);
  9934. QFileInfoList pluginFiles= directory.entryInfoList();
  9935. for(int k= 0;k<pluginFiles.size();k++)
  9936. {
  9937. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  9938. if(itemElement.hasAttribute("preRun"))
  9939. {
  9940. pa->setPreRun(itemElement.attribute("preRun"));
  9941. }
  9942. if(itemElement.hasAttribute("postRun"))
  9943. {
  9944. pa->setPostRun(itemElement.attribute("postRun"));
  9945. }
  9946. pluginMenu->addAction(pa);
  9947. }
  9948. }
  9949. menu->addMenu(pluginMenu);
  9950. /*:687*/
  9951. #line 4819 "./typica.w"
  9952. }
  9953. }
  9954. j++;
  9955. }
  9956. #line 1 "./helpmenu.w"
  9957. /*:204*/
  9958. #line 4783 "./typica.w"
  9959. }
  9960. }
  9961. /*:203*/
  9962. #line 4740 "./typica.w"
  9963. }
  9964. }
  9965. i++;
  9966. }
  9967. QScriptValue oldThis= context->thisObject();
  9968. context->setThisObject(object);
  9969. QScriptValue result= engine->evaluate(windowScript);
  9970. /*195:*/
  9971. #line 4494 "./typica.w"
  9972. if(engine->hasUncaughtException())
  9973. {
  9974. int line= engine->uncaughtExceptionLineNumber();
  9975. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9976. result.toString();
  9977. QString trace;
  9978. foreach(trace,engine->uncaughtExceptionBacktrace())
  9979. {
  9980. qDebug()<<trace;
  9981. }
  9982. }
  9983. /*:195*/
  9984. #line 4748 "./typica.w"
  9985. context->setThisObject(oldThis);
  9986. /*:202*/
  9987. #line 4690 "./typica.w"
  9988. }
  9989. /*205:*/
  9990. #line 9 "./helpmenu.w"
  9991. HelpMenu*helpMenu= new HelpMenu();
  9992. window->menuBar()->addMenu(helpMenu);
  9993. /*:205*/
  9994. #line 4692 "./typica.w"
  9995. window->show();
  9996. /*:201*/
  9997. #line 14102 "./typica.w"
  9998. file.close();
  9999. engine->popContext();
  10000. }
  10001. }
  10002. /*:665*/
  10003. #line 588 "./typica.w"
  10004. /*250:*/
  10005. #line 5958 "./typica.w"
  10006. NumericDelegate::NumericDelegate(QObject*parent):
  10007. QItemDelegate(parent)
  10008. {
  10009. }
  10010. /*:250*//*251:*/
  10011. #line 5970 "./typica.w"
  10012. void NumericDelegate::setEditorData(QWidget*editor,
  10013. const QModelIndex&index)const
  10014. {
  10015. QString value= index.model()->data(index,Qt::EditRole).toString();
  10016. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10017. line->setText(value);
  10018. }
  10019. /*:251*//*252:*/
  10020. #line 5985 "./typica.w"
  10021. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  10022. const QModelIndex&index)const
  10023. {
  10024. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10025. model->setData(index,line->text(),Qt::EditRole);
  10026. QScriptEngine*engine= AppInstance->engine;
  10027. engine->pushContext();
  10028. QString script= QString("Number(%1)").arg(line->text());
  10029. QScriptValue result= engine->evaluate(line->text());
  10030. if(result.isNumber())
  10031. {
  10032. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10033. }
  10034. else
  10035. {
  10036. model->setData(index,QVariant(),Qt::DisplayRole);
  10037. }
  10038. engine->popContext();
  10039. }
  10040. /*:252*//*253:*/
  10041. #line 6008 "./typica.w"
  10042. QWidget*NumericDelegate::createEditor(QWidget*parent,
  10043. const QStyleOptionViewItem&,
  10044. const QModelIndex&)const
  10045. {
  10046. return(new QLineEdit(parent));
  10047. }
  10048. /*:253*//*254:*/
  10049. #line 6019 "./typica.w"
  10050. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  10051. const QStyleOptionViewItem&option,
  10052. const QModelIndex&)const
  10053. {
  10054. editor->setGeometry(option.rect);
  10055. }
  10056. /*:254*/
  10057. #line 589 "./typica.w"
  10058. /*814:*/
  10059. #line 16846 "./typica.w"
  10060. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  10061. const QModelIndex&index)
  10062. :BasicDeviceConfigurationWidget(model,index)
  10063. {
  10064. QHBoxLayout*layout= new QHBoxLayout;
  10065. QToolButton*addDeviceButton= new QToolButton;
  10066. addDeviceButton->setText(tr("Add Device"));
  10067. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10068. "nidaqmx9211series");
  10069. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  10070. "nidaqmxtc01");
  10071. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10072. this,SLOT(insertChildNode(QString,QString)));
  10073. connect(addtc01,SIGNAL(triggered(QString,QString)),
  10074. this,SLOT(insertChildNode(QString,QString)));
  10075. QMenu*deviceMenu= new QMenu;
  10076. deviceMenu->addAction(add9211a);
  10077. deviceMenu->addAction(addtc01);
  10078. addDeviceButton->setMenu(deviceMenu);
  10079. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10080. layout->addWidget(addDeviceButton);
  10081. setLayout(layout);
  10082. }
  10083. /*:814*/
  10084. #line 590 "./typica.w"
  10085. /*816:*/
  10086. #line 16895 "./typica.w"
  10087. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  10088. const QModelIndex&index)
  10089. :BasicDeviceConfigurationWidget(model,index)
  10090. {
  10091. QVBoxLayout*layout= new QVBoxLayout;
  10092. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10093. QLabel*label= new QLabel(tr("Device ID:"));
  10094. QLineEdit*deviceId= new QLineEdit;
  10095. deviceIdLayout->addWidget(label);
  10096. deviceIdLayout->addWidget(deviceId);
  10097. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10098. layout->addLayout(deviceIdLayout);
  10099. layout->addWidget(addChannelButton);
  10100. /*799:*/
  10101. #line 16530 "./typica.w"
  10102. QDomElement referenceElement=
  10103. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10104. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10105. QDomElement node;
  10106. /*:799*/
  10107. #line 16909 "./typica.w"
  10108. for(int i= 0;i<configData.size();i++)
  10109. {
  10110. node= configData.at(i).toElement();
  10111. if(node.attribute("name")=="deviceID")
  10112. {
  10113. deviceId->setText(node.attribute("value","Dev1"));
  10114. break;
  10115. }
  10116. }
  10117. updateDeviceId(deviceId->text());
  10118. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10119. connect(deviceId,SIGNAL(textEdited(QString)),
  10120. this,SLOT(updateDeviceId(QString)));
  10121. setLayout(layout);
  10122. }
  10123. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10124. {
  10125. updateAttribute("deviceID",newId);
  10126. }
  10127. void NiDaqMx9211ConfWidget::addChannel()
  10128. {
  10129. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10130. }
  10131. /*:816*/
  10132. #line 591 "./typica.w"
  10133. /*818:*/
  10134. #line 16960 "./typica.w"
  10135. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10136. const QModelIndex&index)
  10137. :BasicDeviceConfigurationWidget(model,index)
  10138. {
  10139. QFormLayout*layout= new QFormLayout;
  10140. QLineEdit*deviceId= new QLineEdit;
  10141. layout->addRow(tr("Device ID:"),deviceId);
  10142. QLineEdit*columnName= new QLineEdit;
  10143. layout->addRow(tr("Column Name:"),columnName);
  10144. QComboBox*typeSelector= new QComboBox;
  10145. typeSelector->addItem("J");
  10146. typeSelector->addItem("K");
  10147. typeSelector->addItem("T");
  10148. typeSelector->addItem("B");
  10149. typeSelector->addItem("E");
  10150. typeSelector->addItem("N");
  10151. typeSelector->addItem("R");
  10152. typeSelector->addItem("S");
  10153. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10154. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10155. layout->addRow(hideSeries);
  10156. /*799:*/
  10157. #line 16530 "./typica.w"
  10158. QDomElement referenceElement=
  10159. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10160. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10161. QDomElement node;
  10162. /*:799*/
  10163. #line 16982 "./typica.w"
  10164. for(int i= 0;i<configData.size();i++)
  10165. {
  10166. node= configData.at(i).toElement();
  10167. if(node.attribute("name")=="deviceID")
  10168. {
  10169. deviceId->setText(node.attribute("value"));
  10170. }
  10171. else if(node.attribute("name")=="type")
  10172. {
  10173. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10174. }
  10175. else if(node.attribute("name")=="columnname")
  10176. {
  10177. columnName->setText(node.attribute("value"));
  10178. }
  10179. else if(node.attribute("name")=="hidden")
  10180. {
  10181. hideSeries->setChecked(node.attribute("value")=="true");
  10182. }
  10183. }
  10184. updateDeviceId(deviceId->text());
  10185. updateThermocoupleType(typeSelector->currentText());
  10186. updateColumnName(columnName->text());
  10187. updateHidden(hideSeries->isChecked());
  10188. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10189. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10190. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10191. setLayout(layout);
  10192. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10193. }
  10194. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10195. {
  10196. updateAttribute("deviceID",newId);
  10197. }
  10198. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10199. {
  10200. updateAttribute("type",type);
  10201. }
  10202. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10203. {
  10204. updateAttribute("columnname",name);
  10205. }
  10206. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10207. {
  10208. updateAttribute("hidden",hidden?"true":"false");
  10209. }
  10210. /*:818*/
  10211. #line 592 "./typica.w"
  10212. /*836:*/
  10213. #line 17402 "./typica.w"
  10214. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10215. const QModelIndex&index)
  10216. :BasicDeviceConfigurationWidget(model,index)
  10217. {
  10218. QFormLayout*layout= new QFormLayout;
  10219. QToolButton*addDeviceButton= new QToolButton;
  10220. addDeviceButton->setText(tr("Add Device"));
  10221. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10222. "Modbus RTU Device",
  10223. "modbusrtudevice");
  10224. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10225. this,SLOT(insertChildNode(QString,QString)));
  10226. QMenu*deviceMenu= new QMenu;
  10227. deviceMenu->addAction(addModbusRtuDevice);
  10228. addDeviceButton->setMenu(deviceMenu);
  10229. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10230. layout->addRow(QString(),addDeviceButton);
  10231. PortSelector*port= new PortSelector;
  10232. layout->addRow(tr("Port:"),port);
  10233. connect(port,SIGNAL(currentIndexChanged(QString)),
  10234. this,SLOT(updatePort(QString)));
  10235. connect(port,SIGNAL(editTextChanged(QString)),
  10236. this,SLOT(updatePort(QString)));
  10237. BaudSelector*rate= new BaudSelector;
  10238. layout->addRow(tr("Baud:"),rate);
  10239. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10240. this,SLOT(updateBaudRate(QString)));
  10241. ParitySelector*parity= new ParitySelector;
  10242. layout->addRow(tr("Parity:"),parity);
  10243. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10244. this,SLOT(updateParity(QString)));
  10245. FlowSelector*flow= new FlowSelector;
  10246. layout->addRow(tr("Flow Control:"),flow);
  10247. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10248. this,SLOT(updateFlowControl(QString)));
  10249. StopSelector*stop= new StopSelector;
  10250. layout->addRow(tr("Stop Bits:"),stop);
  10251. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10252. this,SLOT(updateStopBits(QString)));
  10253. /*799:*/
  10254. #line 16530 "./typica.w"
  10255. QDomElement referenceElement=
  10256. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10257. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10258. QDomElement node;
  10259. /*:799*/
  10260. #line 17442 "./typica.w"
  10261. for(int i= 0;i<configData.size();i++)
  10262. {
  10263. node= configData.at(i).toElement();
  10264. if(node.attribute("name")=="port")
  10265. {
  10266. int j= port->findText(node.attribute("value"));
  10267. if(j>=0)
  10268. {
  10269. port->setCurrentIndex(j);
  10270. }
  10271. else
  10272. {
  10273. port->insertItem(0,node.attribute("value"));
  10274. port->setCurrentIndex(0);
  10275. }
  10276. }
  10277. else if(node.attribute("name")=="baudrate")
  10278. {
  10279. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10280. }
  10281. else if(node.attribute("name")=="parity")
  10282. {
  10283. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10284. }
  10285. else if(node.attribute("name")=="flowcontrol")
  10286. {
  10287. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10288. }
  10289. else if(node.attribute("name")=="stopbits")
  10290. {
  10291. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10292. }
  10293. }
  10294. updatePort(port->currentText());
  10295. updateBaudRate(rate->currentText());
  10296. updateParity(parity->currentText());
  10297. updateFlowControl(flow->currentText());
  10298. updateStopBits(stop->currentText());
  10299. setLayout(layout);
  10300. }
  10301. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10302. {
  10303. updateAttribute("port",newPort);
  10304. }
  10305. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10306. {
  10307. updateAttribute("baudrate",newRate);
  10308. }
  10309. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10310. {
  10311. updateAttribute("parity",newParity);
  10312. }
  10313. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10314. {
  10315. updateAttribute("flowcontrol",newFlow);
  10316. }
  10317. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10318. {
  10319. updateAttribute("stopbits",newStopBits);
  10320. }
  10321. /*:836*/
  10322. #line 593 "./typica.w"
  10323. /*838:*/
  10324. #line 17565 "./typica.w"
  10325. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10326. const QModelIndex&index)
  10327. :BasicDeviceConfigurationWidget(model,index),
  10328. unitSpecificationLayout(new QStackedLayout),
  10329. decimalSpecificationLayout(new QStackedLayout)
  10330. {
  10331. QVBoxLayout*layout= new QVBoxLayout;
  10332. QToolButton*addChannelButton= new QToolButton;
  10333. addChannelButton->setText(tr("Add Channel"));
  10334. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10335. "Temperature Process Value",
  10336. "modbustemperaturepv");
  10337. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10338. "Temperature Set Value",
  10339. "modbustemperaturesv");
  10340. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10341. this,SLOT(insertChildNode(QString,QString)));
  10342. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10343. this,SLOT(insertChildNode(QString,QString)));
  10344. QMenu*channelMenu= new QMenu;
  10345. channelMenu->addAction(addTemperaturePV);
  10346. channelMenu->addAction(addTemperatureSV);
  10347. addChannelButton->setMenu(channelMenu);
  10348. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10349. layout->addWidget(addChannelButton);
  10350. QHBoxLayout*stationLayout= new QHBoxLayout;
  10351. QLabel*stationLabel= new QLabel(tr("Station:"));
  10352. QSpinBox*stationNumber= new QSpinBox;
  10353. stationNumber->setMinimum(0);
  10354. stationNumber->setMaximum(255);
  10355. stationLayout->addWidget(stationLabel);
  10356. stationLayout->addWidget(stationNumber);
  10357. layout->addLayout(stationLayout);
  10358. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10359. layout->addWidget(fixedUnit);
  10360. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10361. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10362. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10363. QComboBox*fixedUnitSelector= new QComboBox;
  10364. fixedUnitSelector->addItem("Fahrenheit");
  10365. fixedUnitSelector->addItem("Celsius");
  10366. fixedUnitLayout->addWidget(fixedUnitLabel);
  10367. fixedUnitLayout->addWidget(fixedUnitSelector);
  10368. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10369. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10370. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10371. QFormLayout*queriedUnitLayout= new QFormLayout;
  10372. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10373. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10374. QSpinBox*valueF= new QSpinBox;
  10375. valueF->setMinimum(0);
  10376. valueF->setMaximum(65535);
  10377. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10378. QSpinBox*valueC= new QSpinBox;
  10379. valueC->setMinimum(0);
  10380. valueC->setMaximum(65535);
  10381. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10382. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10383. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10384. layout->addLayout(unitSpecificationLayout);
  10385. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10386. layout->addWidget(fixedPrecision);
  10387. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10388. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10389. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10390. fixedPrecisionValue->setMinimum(0);
  10391. fixedPrecisionValue->setMaximum(9);
  10392. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10393. fixedPrecisionValue);
  10394. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10395. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10396. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10397. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10398. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10399. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10400. precisionAddress);
  10401. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10402. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10403. layout->addLayout(decimalSpecificationLayout);
  10404. /*799:*/
  10405. #line 16530 "./typica.w"
  10406. QDomElement referenceElement=
  10407. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10408. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10409. QDomElement node;
  10410. /*:799*/
  10411. #line 17645 "./typica.w"
  10412. for(int i= 0;i<configData.size();i++)
  10413. {
  10414. node= configData.at(i).toElement();
  10415. if(node.attribute("name")=="station")
  10416. {
  10417. stationNumber->setValue(node.attribute("value").toInt());
  10418. }
  10419. else if(node.attribute("name")=="fixedunit")
  10420. {
  10421. if(node.attribute("value")=="true")
  10422. {
  10423. fixedUnit->setCheckState(Qt::Checked);
  10424. }
  10425. else if(node.attribute("value")=="false")
  10426. {
  10427. fixedUnit->setCheckState(Qt::Unchecked);
  10428. }
  10429. }
  10430. else if(node.attribute("name")=="fixedprecision")
  10431. {
  10432. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10433. }
  10434. else if(node.attribute("name")=="unit")
  10435. {
  10436. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10437. }
  10438. else if(node.attribute("name")=="unitaddress")
  10439. {
  10440. unitAddress->setValue(node.attribute("value").toInt());
  10441. }
  10442. else if(node.attribute("name")=="fvalue")
  10443. {
  10444. valueF->setValue(node.attribute("value").toInt());
  10445. }
  10446. else if(node.attribute("name")=="cvalue")
  10447. {
  10448. valueC->setValue(node.attribute("value").toInt());
  10449. }
  10450. else if(node.attribute("name")=="precisionaddress")
  10451. {
  10452. precisionAddress->setValue(node.attribute("value").toInt());
  10453. }
  10454. else if(node.attribute("name")=="precision")
  10455. {
  10456. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10457. }
  10458. }
  10459. updateStationNumber(stationNumber->value());
  10460. updateFixedUnit(fixedUnit->isChecked());
  10461. updateFixedDecimal(fixedPrecision->isChecked());
  10462. updateUnit(fixedUnitSelector->currentText());
  10463. updateUnitAddress(unitAddress->value());
  10464. updateValueF(valueF->value());
  10465. updateValueC(valueC->value());
  10466. updatePrecisionAddress(precisionAddress->value());
  10467. updatePrecisionValue(fixedPrecisionValue->value());
  10468. connect(stationNumber,SIGNAL(valueChanged(int)),
  10469. this,SLOT(updateStationNumber(int)));
  10470. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10471. this,SLOT(updateUnit(QString)));
  10472. connect(unitAddress,SIGNAL(valueChanged(int)),
  10473. this,SLOT(updateUnitAddress(int)));
  10474. connect(valueF,SIGNAL(valueChanged(int)),
  10475. this,SLOT(updateValueF(int)));
  10476. connect(valueC,SIGNAL(valueChanged(int)),
  10477. this,SLOT(updateValueC(int)));
  10478. connect(fixedUnit,SIGNAL(toggled(bool)),
  10479. this,SLOT(updateFixedUnit(bool)));
  10480. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10481. this,SLOT(updateFixedDecimal(bool)));
  10482. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10483. this,SLOT(updatePrecisionValue(int)));
  10484. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10485. this,SLOT(updatePrecisionAddress(int)));
  10486. setLayout(layout);
  10487. }
  10488. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10489. {
  10490. updateAttribute("station",QString("%1").arg(newStation));
  10491. }
  10492. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10493. {
  10494. if(newFixed)
  10495. {
  10496. unitSpecificationLayout->setCurrentIndex(0);
  10497. updateAttribute("fixedunit","true");
  10498. }
  10499. else
  10500. {
  10501. unitSpecificationLayout->setCurrentIndex(1);
  10502. updateAttribute("fixedunit","false");
  10503. }
  10504. }
  10505. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10506. {
  10507. if(newFixed)
  10508. {
  10509. decimalSpecificationLayout->setCurrentIndex(0);
  10510. updateAttribute("fixedprecision","true");
  10511. }
  10512. else
  10513. {
  10514. decimalSpecificationLayout->setCurrentIndex(1);
  10515. updateAttribute("fixedprecision","false");
  10516. }
  10517. }
  10518. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10519. {
  10520. updateAttribute("unit",newUnit);
  10521. }
  10522. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10523. {
  10524. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10525. }
  10526. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10527. {
  10528. updateAttribute("fvalue",QString("%1").arg(newValue));
  10529. }
  10530. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10531. {
  10532. updateAttribute("cvalue",QString("%1").arg(newValue));
  10533. }
  10534. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10535. {
  10536. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10537. }
  10538. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10539. {
  10540. updateAttribute("precision",QString("%1").arg(newValue));
  10541. }
  10542. /*:838*/
  10543. #line 594 "./typica.w"
  10544. /*840:*/
  10545. #line 17808 "./typica.w"
  10546. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10547. const QModelIndex&index)
  10548. :BasicDeviceConfigurationWidget(model,index)
  10549. {
  10550. QFormLayout*layout= new QFormLayout;
  10551. ShortHexSpinBox*address= new ShortHexSpinBox;
  10552. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10553. /*799:*/
  10554. #line 16530 "./typica.w"
  10555. QDomElement referenceElement=
  10556. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10557. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10558. QDomElement node;
  10559. /*:799*/
  10560. #line 17816 "./typica.w"
  10561. for(int i= 0;i<configData.size();i++)
  10562. {
  10563. node= configData.at(i).toElement();
  10564. if(node.attribute("name")=="address")
  10565. {
  10566. address->setValue(node.attribute("value").toInt());
  10567. break;
  10568. }
  10569. }
  10570. updateAddress(address->value());
  10571. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10572. setLayout(layout);
  10573. }
  10574. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10575. {
  10576. updateAttribute("address",QString("%1").arg(newAddress));
  10577. }
  10578. /*:840*/
  10579. #line 595 "./typica.w"
  10580. /*842:*/
  10581. #line 17864 "./typica.w"
  10582. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10583. const QModelIndex&index)
  10584. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10585. {
  10586. QVBoxLayout*layout= new QVBoxLayout;
  10587. QFormLayout*addressLayout= new QFormLayout;
  10588. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10589. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10590. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10591. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10592. layout->addLayout(addressLayout);
  10593. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10594. layout->addWidget(fixedRange);
  10595. QWidget*queriedRangePlaceholder= new QWidget(this);
  10596. QFormLayout*queriedRangeLayout= new QFormLayout;
  10597. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10598. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10599. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10600. lowerAddress);
  10601. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10602. upperAddress);
  10603. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10604. boundsLayout->addWidget(queriedRangePlaceholder);
  10605. QWidget*fixedRangePlaceholder= new QWidget(this);
  10606. QFormLayout*fixedRangeLayout= new QFormLayout;
  10607. QLineEdit*fixedLower= new QLineEdit;
  10608. QLineEdit*fixedUpper= new QLineEdit;
  10609. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10610. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10611. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10612. boundsLayout->addWidget(fixedRangePlaceholder);
  10613. layout->addLayout(boundsLayout);
  10614. /*799:*/
  10615. #line 16530 "./typica.w"
  10616. QDomElement referenceElement=
  10617. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10618. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10619. QDomElement node;
  10620. /*:799*/
  10621. #line 17897 "./typica.w"
  10622. for(int i= 0;i<configData.size();i++)
  10623. {
  10624. node= configData.at(i).toElement();
  10625. if(node.attribute("name")=="readaddress")
  10626. {
  10627. readAddress->setValue(node.attribute("value").toInt());
  10628. }
  10629. else if(node.attribute("name")=="writeaddress")
  10630. {
  10631. writeAddress->setValue(node.attribute("value").toInt());
  10632. }
  10633. else if(node.attribute("name")=="fixedrange")
  10634. {
  10635. if(node.attribute("value")=="true")
  10636. {
  10637. fixedRange->setCheckState(Qt::Checked);
  10638. }
  10639. else if(node.attribute("value")=="false")
  10640. {
  10641. fixedRange->setCheckState(Qt::Unchecked);
  10642. }
  10643. }
  10644. else if(node.attribute("name")=="fixedlower")
  10645. {
  10646. fixedLower->setText(node.attribute("value"));
  10647. }
  10648. else if(node.attribute("name")=="fixedupper")
  10649. {
  10650. fixedUpper->setText(node.attribute("value"));
  10651. }
  10652. else if(node.attribute("name")=="loweraddress")
  10653. {
  10654. lowerAddress->setValue(node.attribute("value").toInt());
  10655. }
  10656. else if(node.attribute("name")=="upperaddress")
  10657. {
  10658. upperAddress->setValue(node.attribute("value").toInt());
  10659. }
  10660. }
  10661. updateReadAddress(readAddress->value());
  10662. updateWriteAddress(writeAddress->value());
  10663. updateFixedRange(fixedRange->isChecked());
  10664. updateLower(fixedLower->text());
  10665. updateUpper(fixedUpper->text());
  10666. updateLowerAddress(lowerAddress->value());
  10667. updateUpperAddress(upperAddress->value());
  10668. connect(readAddress,SIGNAL(valueChanged(int)),
  10669. this,SLOT(updateReadAddress(int)));
  10670. connect(writeAddress,SIGNAL(valueChanged(int)),
  10671. this,SLOT(updateWriteAddress(int)));
  10672. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10673. connect(fixedLower,SIGNAL(textChanged(QString)),
  10674. this,SLOT(updateLower(QString)));
  10675. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10676. this,SLOT(updateUpper(QString)));
  10677. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10678. this,SLOT(updateLowerAddress(int)));
  10679. connect(upperAddress,SIGNAL(valueChanged(int)),
  10680. this,SLOT(updateUpperAddress(int)));
  10681. setLayout(layout);
  10682. }
  10683. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10684. {
  10685. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10686. }
  10687. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10688. {
  10689. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10690. }
  10691. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10692. {
  10693. if(fixed)
  10694. {
  10695. updateAttribute("fixedrange","true");
  10696. boundsLayout->setCurrentIndex(1);
  10697. }
  10698. else
  10699. {
  10700. updateAttribute("fixedrange","false");
  10701. boundsLayout->setCurrentIndex(0);
  10702. }
  10703. }
  10704. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10705. {
  10706. updateAttribute("fixedlower",lower);
  10707. }
  10708. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10709. {
  10710. updateAttribute("fixedupper",upper);
  10711. }
  10712. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10713. {
  10714. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10715. }
  10716. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10717. {
  10718. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10719. }
  10720. /*:842*/
  10721. #line 596 "./typica.w"
  10722. /*798:*/
  10723. #line 16400 "./typica.w"
  10724. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10725. :BasicDeviceConfigurationWidget(model,index)
  10726. {
  10727. QVBoxLayout*layout= new QVBoxLayout;
  10728. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10729. QMenu*deviceMenu= new QMenu;
  10730. NodeInserter*insertAction;
  10731. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10732. {
  10733. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10734. this,SLOT(insertChildNode(QString,QString)));
  10735. deviceMenu->addAction(insertAction);
  10736. }
  10737. addDeviceButton->setMenu(deviceMenu);
  10738. layout->addWidget(addDeviceButton);
  10739. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10740. QMenu*annotationMenu= new QMenu;
  10741. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10742. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10743. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10744. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10745. tr("Free Text"),
  10746. "freeannotation");
  10747. annotationMenu->addAction(basicButtonInserter);
  10748. annotationMenu->addAction(countingButtonInserter);
  10749. annotationMenu->addAction(spinBoxInserter);
  10750. annotationMenu->addAction(freeAnnotationInserter);
  10751. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10752. this,SLOT(insertChildNode(QString,QString)));
  10753. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10754. this,SLOT(insertChildNode(QString,QString)));
  10755. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10756. this,SLOT(insertChildNode(QString,QString)));
  10757. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10758. this,SLOT(insertChildNode(QString,QString)));
  10759. /*1070:*/
  10760. #line 144 "./valueannotation.w"
  10761. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10762. tr("Value Annotation"),
  10763. "valueannotation");
  10764. annotationMenu->addAction(valueAnnotationInserter);
  10765. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10766. this,SLOT(insertChildNode(QString,QString)));
  10767. /*:1070*//*1084:*/
  10768. #line 115 "./thresholdannotation.w"
  10769. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  10770. tr("Threshold Annotation"),
  10771. "thresholdannotation");
  10772. annotationMenu->addAction(thresholdAnnotationInserter);
  10773. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10774. this,SLOT(insertChildNode(QString,QString)));
  10775. /*:1084*/
  10776. #line 16436 "./typica.w"
  10777. addAnnotationControlButton->setMenu(annotationMenu);
  10778. layout->addWidget(addAnnotationControlButton);
  10779. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10780. QMenu*timersMenu= new QMenu;
  10781. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10782. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10783. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10784. timersMenu->addAction(coolingTimerInserter);
  10785. timersMenu->addAction(rangeTimerInserter);
  10786. timersMenu->addAction(multirangeTimerInserter);
  10787. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10788. this,SLOT(insertChildNode(QString,QString)));
  10789. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10790. this,SLOT(insertChildNode(QString,QString)));
  10791. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10792. this,SLOT(insertChildNode(QString,QString)));
  10793. timersButton->setMenu(timersMenu);
  10794. layout->addWidget(timersButton);
  10795. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10796. QMenu*advancedMenu= new QMenu;
  10797. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10798. advancedMenu->addAction(linearsplineinserter);
  10799. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10800. advancedMenu->addAction(translationinserter);
  10801. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10802. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10803. /*996:*/
  10804. #line 258 "./rate.w"
  10805. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10806. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10807. advancedMenu->addAction(rateOfChangeInserter);
  10808. /*:996*/
  10809. #line 16465 "./typica.w"
  10810. advancedButton->setMenu(advancedMenu);
  10811. layout->addWidget(advancedButton);
  10812. QHBoxLayout*idLayout= new QHBoxLayout;
  10813. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10814. idLayout->addWidget(idLabel);
  10815. QSpinBox*id= new QSpinBox;
  10816. idLayout->addWidget(id);
  10817. idLayout->addStretch();
  10818. layout->addLayout(idLayout);
  10819. QHBoxLayout*capacityLayout= new QHBoxLayout;
  10820. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  10821. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  10822. capacity->setMinimum(0.0);
  10823. capacity->setDecimals(3);
  10824. capacity->setMaximum(999999.999);
  10825. QComboBox*capacityUnit= new QComboBox;
  10826. capacityUnit->addItem("g");
  10827. capacityUnit->addItem("Kg");
  10828. capacityUnit->addItem("oz");
  10829. capacityUnit->addItem("Lb");
  10830. capacityUnit->setCurrentIndex(3);
  10831. capacityLayout->addWidget(capacityCheckEnabled);
  10832. capacityLayout->addWidget(capacity);
  10833. capacityLayout->addWidget(capacityUnit);
  10834. capacityLayout->addStretch();
  10835. layout->addLayout(capacityLayout);
  10836. layout->addStretch();
  10837. /*799:*/
  10838. #line 16530 "./typica.w"
  10839. QDomElement referenceElement=
  10840. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10841. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10842. QDomElement node;
  10843. /*:799*/
  10844. #line 16494 "./typica.w"
  10845. for(int i= 0;i<configData.size();i++)
  10846. {
  10847. node= configData.at(i).toElement();
  10848. if(node.attribute("name")=="databaseid")
  10849. {
  10850. id->setValue(node.attribute("value").toInt());
  10851. }
  10852. else if(node.attribute("name")=="checkcapacity")
  10853. {
  10854. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  10855. }
  10856. else if(node.attribute("name")=="capacity")
  10857. {
  10858. capacity->setValue(node.attribute("value").toDouble());
  10859. }
  10860. else if(node.attribute("name")=="capacityunit")
  10861. {
  10862. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  10863. }
  10864. }
  10865. updateRoasterId(id->value());
  10866. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10867. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  10868. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  10869. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  10870. setLayout(layout);
  10871. }
  10872. /*:798*//*800:*/
  10873. #line 16540 "./typica.w"
  10874. void RoasterConfWidget::updateRoasterId(int id)
  10875. {
  10876. updateAttribute("databaseid",QString("%1").arg(id));
  10877. }
  10878. void RoasterConfWidget::updateCapacityCheck(int value)
  10879. {
  10880. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  10881. }
  10882. void RoasterConfWidget::updateCapacity(const QString&value)
  10883. {
  10884. updateAttribute("capacity",value);
  10885. }
  10886. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  10887. {
  10888. updateAttribute("capacityunit",value);
  10889. }
  10890. /*:800*/
  10891. #line 597 "./typica.w"
  10892. /*846:*/
  10893. #line 18047 "./typica.w"
  10894. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10895. :BasicDeviceConfigurationWidget(model,index)
  10896. {
  10897. QFormLayout*layout= new QFormLayout;
  10898. QLineEdit*buttonTextEdit= new QLineEdit;
  10899. QLineEdit*annotationTextEdit= new QLineEdit;
  10900. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10901. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10902. /*799:*/
  10903. #line 16530 "./typica.w"
  10904. QDomElement referenceElement=
  10905. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10906. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10907. QDomElement node;
  10908. /*:799*/
  10909. #line 18056 "./typica.w"
  10910. for(int i= 0;i<configData.size();i++)
  10911. {
  10912. node= configData.at(i).toElement();
  10913. if(node.attribute("name")=="buttontext")
  10914. {
  10915. buttonTextEdit->setText(node.attribute("value"));
  10916. }
  10917. else if(node.attribute("name")=="annotationtext")
  10918. {
  10919. annotationTextEdit->setText(node.attribute("value"));
  10920. }
  10921. }
  10922. updateButtonText(buttonTextEdit->text());
  10923. updateAnnotationText(annotationTextEdit->text());
  10924. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10925. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10926. setLayout(layout);
  10927. }
  10928. /*:846*//*847:*/
  10929. #line 18078 "./typica.w"
  10930. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10931. {
  10932. updateAttribute("buttontext",text);
  10933. }
  10934. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10935. {
  10936. updateAttribute("annotationtext",text);
  10937. }
  10938. /*:847*//*850:*/
  10939. #line 18116 "./typica.w"
  10940. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10941. :BasicDeviceConfigurationWidget(model,index)
  10942. {
  10943. QFormLayout*layout= new QFormLayout;
  10944. QLineEdit*buttonTextEdit= new QLineEdit;
  10945. QLineEdit*annotationTextEdit= new QLineEdit;
  10946. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10947. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10948. /*799:*/
  10949. #line 16530 "./typica.w"
  10950. QDomElement referenceElement=
  10951. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10952. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10953. QDomElement node;
  10954. /*:799*/
  10955. #line 18125 "./typica.w"
  10956. for(int i= 0;i<configData.size();i++)
  10957. {
  10958. node= configData.at(i).toElement();
  10959. if(node.attribute("name")=="buttontext")
  10960. {
  10961. buttonTextEdit->setText(node.attribute("value"));
  10962. }
  10963. else if(node.attribute("name")=="annotationtext")
  10964. {
  10965. annotationTextEdit->setText(node.attribute("value"));
  10966. }
  10967. }
  10968. updateButtonText(buttonTextEdit->text());
  10969. updateAnnotationText(annotationTextEdit->text());
  10970. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10971. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10972. QTextEdit*documentation= new QTextEdit;
  10973. 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."));
  10974. documentation->setReadOnly(true);
  10975. layout->addRow("",documentation);
  10976. setLayout(layout);
  10977. }
  10978. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10979. {
  10980. updateAttribute("buttontext",text);
  10981. }
  10982. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10983. {
  10984. updateAttribute("annotationtext",text);
  10985. }
  10986. /*:850*/
  10987. #line 598 "./typica.w"
  10988. /*853:*/
  10989. #line 18193 "./typica.w"
  10990. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10991. :BasicDeviceConfigurationWidget(model,index)
  10992. {
  10993. QFormLayout*layout= new QFormLayout;
  10994. QLineEdit*labelEdit= new QLineEdit;
  10995. layout->addRow(tr("Control Label: "),labelEdit);
  10996. QLineEdit*minimumEdit= new QLineEdit;
  10997. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10998. QLineEdit*maximumEdit= new QLineEdit;
  10999. layout->addRow(tr("Maximum Value: "),maximumEdit);
  11000. QSpinBox*precisionEdit= new QSpinBox;
  11001. precisionEdit->setMinimum(0);
  11002. precisionEdit->setMaximum(9);
  11003. layout->addRow(tr("Precision"),precisionEdit);
  11004. QLineEdit*pretext= new QLineEdit;
  11005. layout->addRow(tr("Prefix text"),pretext);
  11006. QLineEdit*posttext= new QLineEdit;
  11007. layout->addRow(tr("Suffix text"),posttext);
  11008. /*799:*/
  11009. #line 16530 "./typica.w"
  11010. QDomElement referenceElement=
  11011. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11012. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11013. QDomElement node;
  11014. /*:799*/
  11015. #line 18212 "./typica.w"
  11016. for(int i= 0;i<configData.size();i++)
  11017. {
  11018. node= configData.at(i).toElement();
  11019. if(node.attribute("name")=="label")
  11020. {
  11021. labelEdit->setText(node.attribute("value"));
  11022. }
  11023. else if(node.attribute("name")=="minimum")
  11024. {
  11025. minimumEdit->setText(node.attribute("value"));
  11026. }
  11027. else if(node.attribute("name")=="maximum")
  11028. {
  11029. maximumEdit->setText(node.attribute("value"));
  11030. }
  11031. else if(node.attribute("name")=="precision")
  11032. {
  11033. precisionEdit->setValue(node.attribute("value").toInt());
  11034. }
  11035. else if(node.attribute("name")=="pretext")
  11036. {
  11037. pretext->setText(node.attribute("value"));
  11038. }
  11039. else if(node.attribute("name")=="posttext")
  11040. {
  11041. posttext->setText(node.attribute("value"));
  11042. }
  11043. }
  11044. updateLabel(labelEdit->text());
  11045. updateMinimum(minimumEdit->text());
  11046. updateMaximum(maximumEdit->text());
  11047. updatePrecision(precisionEdit->value());
  11048. updatePretext(pretext->text());
  11049. updatePosttext(posttext->text());
  11050. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  11051. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  11052. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  11053. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  11054. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  11055. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  11056. setLayout(layout);
  11057. }
  11058. void NoteSpinConfWidget::updateLabel(const QString&text)
  11059. {
  11060. updateAttribute("label",text);
  11061. }
  11062. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  11063. {
  11064. updateAttribute("minimum",minimum);
  11065. }
  11066. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  11067. {
  11068. updateAttribute("maximum",maximum);
  11069. }
  11070. void NoteSpinConfWidget::updatePrecision(int precision)
  11071. {
  11072. updateAttribute("precision",QString("%1").arg(precision));
  11073. }
  11074. void NoteSpinConfWidget::updatePretext(const QString&text)
  11075. {
  11076. updateAttribute("pretext",text);
  11077. }
  11078. void NoteSpinConfWidget::updatePosttext(const QString&text)
  11079. {
  11080. updateAttribute("posttext",text);
  11081. }
  11082. /*:853*/
  11083. #line 599 "./typica.w"
  11084. /*346:*/
  11085. #line 7723 "./typica.w"
  11086. LinearCalibrator::LinearCalibrator(QObject*parent):
  11087. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  11088. {
  11089. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11090. }
  11091. /*:346*//*347:*/
  11092. #line 7737 "./typica.w"
  11093. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  11094. {
  11095. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  11096. if(clamp)
  11097. {
  11098. if(outval<Lo1)
  11099. {
  11100. outval= Lo1;
  11101. }
  11102. else if(outval> Up1)
  11103. {
  11104. outval= Up1;
  11105. }
  11106. }
  11107. if(sensitivitySetting>=0.05)
  11108. {
  11109. int temp= qRound(outval/sensitivitySetting);
  11110. outval= temp*sensitivitySetting;
  11111. }
  11112. Measurement adjusted(outval,measure.time(),measure.scale());
  11113. emit measurement(adjusted);
  11114. return adjusted;
  11115. }
  11116. /*:347*//*348:*/
  11117. #line 7764 "./typica.w"
  11118. double LinearCalibrator::measuredLower()
  11119. {
  11120. return Lo2;
  11121. }
  11122. double LinearCalibrator::measuredUpper()
  11123. {
  11124. return Up2;
  11125. }
  11126. double LinearCalibrator::mappedLower()
  11127. {
  11128. return Lo1;
  11129. }
  11130. double LinearCalibrator::mappedUpper()
  11131. {
  11132. return Up1;
  11133. }
  11134. bool LinearCalibrator::isClosedRange()
  11135. {
  11136. return clamp;
  11137. }
  11138. void LinearCalibrator::setMeasuredLower(double lower)
  11139. {
  11140. Lo2= lower;
  11141. }
  11142. void LinearCalibrator::setMeasuredUpper(double upper)
  11143. {
  11144. Up2= upper;
  11145. }
  11146. void LinearCalibrator::setMappedLower(double lower)
  11147. {
  11148. Lo1= lower;
  11149. }
  11150. void LinearCalibrator::setMappedUpper(double upper)
  11151. {
  11152. Up1= upper;
  11153. }
  11154. void LinearCalibrator::setClosedRange(bool closed)
  11155. {
  11156. clamp= closed;
  11157. }
  11158. void LinearCalibrator::setSensitivity(double sensitivity)
  11159. {
  11160. sensitivitySetting= sensitivity;
  11161. }
  11162. double LinearCalibrator::sensitivity()
  11163. {
  11164. return sensitivitySetting;
  11165. }
  11166. /*:348*/
  11167. #line 600 "./typica.w"
  11168. /*353:*/
  11169. #line 7897 "./typica.w"
  11170. void LinearSplineInterpolator::add_pair(double source,double destination)
  11171. {
  11172. pairs->insert(source,destination);
  11173. make_interpolators();
  11174. }
  11175. void LinearSplineInterpolator::make_interpolators()
  11176. {
  11177. if(pairs->size()> 1)
  11178. {
  11179. while(interpolators->size()> 0)
  11180. {
  11181. LinearCalibrator*removed= interpolators->takeFirst();
  11182. removed->deleteLater();
  11183. }
  11184. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11185. QMap<double,double> ::const_iterator j= i+1;
  11186. while(j!=pairs->constEnd())
  11187. {
  11188. LinearCalibrator*segment= new LinearCalibrator();
  11189. segment->setMeasuredLower(i.key());
  11190. segment->setMappedLower(i.value());
  11191. segment->setMeasuredUpper(j.key());
  11192. segment->setMappedUpper(j.value());
  11193. segment->setClosedRange(false);
  11194. interpolators->append(segment);
  11195. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11196. i++;
  11197. j++;
  11198. }
  11199. }
  11200. }
  11201. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11202. QObject(parent),pairs(new QMap<double,double> ),
  11203. interpolators(new QList<LinearCalibrator*> )
  11204. {
  11205. }
  11206. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11207. {
  11208. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11209. int index= -1;
  11210. while(i!=pairs->constEnd())
  11211. {
  11212. if(measure.temperature()<=i.key())
  11213. {
  11214. break;
  11215. }
  11216. i++;
  11217. index++;
  11218. }
  11219. if(index<0)
  11220. {
  11221. index= 0;
  11222. }
  11223. if(index>=interpolators->size())
  11224. {
  11225. index= interpolators->size()-1;
  11226. }
  11227. if(interpolators->at(index)!=NULL)
  11228. {
  11229. return interpolators->at(index)->newMeasurement(measure);
  11230. }
  11231. return Measurement();
  11232. }
  11233. /*:353*/
  11234. #line 601 "./typica.w"
  11235. /*961:*/
  11236. #line 19563 "./typica.w"
  11237. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11238. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11239. {
  11240. QFormLayout*layout= new QFormLayout;
  11241. QLineEdit*source= new QLineEdit;
  11242. layout->addRow(tr("Source column name:"),source);
  11243. QLineEdit*destination= new QLineEdit;
  11244. layout->addRow(tr("Destination column name:"),destination);
  11245. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11246. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11247. QTableView*mappingTable= new QTableView;
  11248. mappingTable->setModel(tablemodel);
  11249. NumericDelegate*delegate= new NumericDelegate;
  11250. mappingTable->setItemDelegate(delegate);
  11251. layout->addRow(tr("Mapping data:"),mappingTable);
  11252. /*799:*/
  11253. #line 16530 "./typica.w"
  11254. QDomElement referenceElement=
  11255. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11256. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11257. QDomElement node;
  11258. /*:799*/
  11259. #line 19579 "./typica.w"
  11260. for(int i= 0;i<configData.size();i++)
  11261. {
  11262. node= configData.at(i).toElement();
  11263. if(node.attribute("name")=="source")
  11264. {
  11265. source->setText(node.attribute("value"));
  11266. }
  11267. else if(node.attribute("name")=="destination")
  11268. {
  11269. destination->setText(node.attribute("value"));
  11270. }
  11271. else if(node.attribute("name")=="sourcevalues")
  11272. {
  11273. /*962:*/
  11274. #line 19618 "./typica.w"
  11275. QString data= node.attribute("value");
  11276. if(data.length()> 3)
  11277. {
  11278. data.chop(2);
  11279. data= data.remove(0,2);
  11280. }
  11281. QStringList itemList= data.split(",");
  11282. /*:962*/
  11283. #line 19593 "./typica.w"
  11284. int column= 0;
  11285. /*963:*/
  11286. #line 19630 "./typica.w"
  11287. for(int j= 0;j<itemList.size();j++)
  11288. {
  11289. tablemodel->setData(tablemodel->index(j,column),
  11290. QVariant(itemList.at(j).toDouble()),
  11291. Qt::DisplayRole);
  11292. }
  11293. /*:963*/
  11294. #line 19595 "./typica.w"
  11295. }
  11296. else if(node.attribute("name")=="destinationvalues")
  11297. {
  11298. /*962:*/
  11299. #line 19618 "./typica.w"
  11300. QString data= node.attribute("value");
  11301. if(data.length()> 3)
  11302. {
  11303. data.chop(2);
  11304. data= data.remove(0,2);
  11305. }
  11306. QStringList itemList= data.split(",");
  11307. /*:962*/
  11308. #line 19600 "./typica.w"
  11309. int column= 1;
  11310. /*963:*/
  11311. #line 19630 "./typica.w"
  11312. for(int j= 0;j<itemList.size();j++)
  11313. {
  11314. tablemodel->setData(tablemodel->index(j,column),
  11315. QVariant(itemList.at(j).toDouble()),
  11316. Qt::DisplayRole);
  11317. }
  11318. /*:963*/
  11319. #line 19602 "./typica.w"
  11320. }
  11321. }
  11322. updateSourceColumn(source->text());
  11323. updateDestinationColumn(destination->text());
  11324. updateKnots();
  11325. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11326. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11327. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11328. setLayout(layout);
  11329. }
  11330. /*:961*//*964:*/
  11331. #line 19641 "./typica.w"
  11332. void LinearSplineInterpolationConfWidget::updateKnots()
  11333. {
  11334. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11335. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11336. }
  11337. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11338. {
  11339. updateAttribute("source",source);
  11340. }
  11341. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11342. {
  11343. updateAttribute("destination",dest);
  11344. }
  11345. /*:964*/
  11346. #line 602 "./typica.w"
  11347. /*981:*/
  11348. #line 20112 "./typica.w"
  11349. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11350. :BasicDeviceConfigurationWidget(model,index),
  11351. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox),
  11352. delaySelector(new QSpinBox)
  11353. {
  11354. unitSelector->addItem("Fahrenheit");
  11355. unitSelector->addItem("Celsius");
  11356. temperatureValue->setMinimum(0);
  11357. temperatureValue->setMaximum(1000);
  11358. QFormLayout*layout= new QFormLayout;
  11359. QLineEdit*column= new QLineEdit;
  11360. layout->addRow(tr("Column to match:"),column);
  11361. layout->addRow(tr("Unit:"),unitSelector);
  11362. layout->addRow(tr("Value:"),temperatureValue);
  11363. layout->addRow(tr("Start of batch safety delay:"),delaySelector);
  11364. /*799:*/
  11365. #line 16530 "./typica.w"
  11366. QDomElement referenceElement=
  11367. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11368. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11369. QDomElement node;
  11370. /*:799*/
  11371. #line 20128 "./typica.w"
  11372. for(int i= 0;i<configData.size();i++)
  11373. {
  11374. node= configData.at(i).toElement();
  11375. if(node.attribute("name")=="column")
  11376. {
  11377. column->setText(node.attribute("value"));
  11378. }
  11379. else if(node.attribute("name")=="unit")
  11380. {
  11381. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11382. }
  11383. else if(node.attribute("name")=="value")
  11384. {
  11385. temperatureValue->setValue(node.attribute("value").toDouble());
  11386. }
  11387. else if(node.attribute("name")=="delay")
  11388. {
  11389. delaySelector->setValue(node.attribute("value").toInt());
  11390. }
  11391. }
  11392. updateMatchingColumn(column->text());
  11393. updateTemperature();
  11394. updateDelay();
  11395. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11396. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11397. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11398. connect(delaySelector,SIGNAL(valueChanged(int)),this,SLOT(updateDelay()));
  11399. setLayout(layout);
  11400. }
  11401. /*:981*//*982:*/
  11402. #line 20163 "./typica.w"
  11403. void TranslationConfWidget::updateTemperature()
  11404. {
  11405. updateAttribute("unit",unitSelector->currentText());
  11406. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11407. if(unitSelector->currentText()=="Fahrenheit")
  11408. {
  11409. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11410. }
  11411. else
  11412. {
  11413. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11414. }
  11415. }
  11416. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11417. {
  11418. updateAttribute("column",column);
  11419. }
  11420. void TranslationConfWidget::updateDelay()
  11421. {
  11422. updateAttribute("delay",QString("%1").arg(delaySelector->value()));
  11423. }
  11424. /*:982*/
  11425. #line 603 "./typica.w"
  11426. /*856:*/
  11427. #line 24 "./freeannotation.w"
  11428. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11429. const QModelIndex&index)
  11430. :BasicDeviceConfigurationWidget(model,index)
  11431. {
  11432. QFormLayout*layout= new QFormLayout;
  11433. QLineEdit*labelEdit= new QLineEdit;
  11434. layout->addRow(tr("Label Text:"),labelEdit);
  11435. /*799:*/
  11436. #line 16530 "./typica.w"
  11437. QDomElement referenceElement=
  11438. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11439. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11440. QDomElement node;
  11441. /*:799*/
  11442. #line 32 "./freeannotation.w"
  11443. for(int i= 0;i<configData.size();i++)
  11444. {
  11445. node= configData.at(i).toElement();
  11446. if(node.attribute("name")=="labeltext")
  11447. {
  11448. labelEdit->setText(node.attribute("value"));
  11449. }
  11450. }
  11451. updateLabel(labelEdit->text());
  11452. connect(labelEdit,SIGNAL(textEdited(QString)),
  11453. this,SLOT(updateLabel(QString)));
  11454. setLayout(layout);
  11455. }
  11456. /*:856*//*857:*/
  11457. #line 49 "./freeannotation.w"
  11458. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11459. {
  11460. updateAttribute("labeltext",text);
  11461. }
  11462. /*:857*/
  11463. #line 604 "./typica.w"
  11464. /*985:*/
  11465. #line 39 "./rate.w"
  11466. void RateOfChange::newMeasurement(Measurement measure)
  11467. {
  11468. cache.append(measure);
  11469. /*986:*/
  11470. #line 64 "./rate.w"
  11471. if(cache.size()> 2)
  11472. {
  11473. bool done= false;
  11474. while(!done)
  11475. {
  11476. if(cache.front().time().secsTo(cache.back().time())> ct)
  11477. {
  11478. cache.removeFirst();
  11479. }
  11480. else if(cache.back().time()<cache.front().time())
  11481. {
  11482. cache.removeFirst();
  11483. done= true;
  11484. }
  11485. else
  11486. {
  11487. done= true;
  11488. }
  11489. if(cache.size()<3)
  11490. {
  11491. done= true;
  11492. }
  11493. }
  11494. }
  11495. /*:986*/
  11496. #line 43 "./rate.w"
  11497. if(cache.size()>=2)
  11498. {
  11499. /*987:*/
  11500. #line 96 "./rate.w"
  11501. int N= cache.size();
  11502. double SXY= 0;
  11503. double SX= 0;
  11504. double SXX= 0;
  11505. double SY= 0;
  11506. double y;
  11507. double x;
  11508. for(int i= 0;i<N;i++)
  11509. {
  11510. y= cache.at(i).temperature();
  11511. SY+= y;
  11512. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11513. SX+= x;
  11514. SXX+= (x*x);
  11515. SXY+= (x*y);
  11516. }
  11517. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11518. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11519. value.insert("relative",true);
  11520. emit newData(value);
  11521. /*:987*/
  11522. #line 46 "./rate.w"
  11523. }
  11524. }
  11525. /*:985*//*988:*/
  11526. #line 120 "./rate.w"
  11527. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11528. {
  11529. setScaleTime(scaletime);
  11530. }
  11531. void RateOfChange::setCacheTime(int seconds)
  11532. {
  11533. ct= seconds;
  11534. }
  11535. void RateOfChange::setScaleTime(int seconds)
  11536. {
  11537. st= (seconds> 0?seconds:1);
  11538. }
  11539. /*:988*/
  11540. #line 605 "./typica.w"
  11541. /*860:*/
  11542. #line 26 "./settings.w"
  11543. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11544. {
  11545. QTabWidget*settingsTab= new QTabWidget;
  11546. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11547. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11548. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11549. settingsTab->addTab(graphSettings,tr("Graph"));
  11550. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11551. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11552. setCentralWidget(settingsTab);
  11553. }
  11554. /*:860*/
  11555. #line 606 "./typica.w"
  11556. /*865:*/
  11557. #line 27 "./graphsettings.w"
  11558. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11559. {
  11560. QTabWidget*graphCategories= new QTabWidget;
  11561. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11562. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11563. QVBoxLayout*layout= new QVBoxLayout;
  11564. layout->addWidget(graphCategories);
  11565. setLayout(layout);
  11566. }
  11567. /*:865*//*867:*/
  11568. #line 65 "./graphsettings.w"
  11569. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11570. colorEdit(new QLineEdit)
  11571. {
  11572. QSettings settings;
  11573. QVBoxLayout*layout= new QVBoxLayout;
  11574. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11575. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11576. updateEnableSetting(enable->isChecked());
  11577. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11578. layout->addWidget(enable);
  11579. QHBoxLayout*colorLayout= new QHBoxLayout;
  11580. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11581. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11582. updateColorSetting(colorEdit->text());
  11583. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11584. QToolButton*colorPickerButton= new QToolButton();
  11585. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11586. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11587. colorLayout->addWidget(colorLabel);
  11588. colorLayout->addWidget(colorEdit);
  11589. colorLayout->addWidget(colorPickerButton);
  11590. colorLayout->addStretch();
  11591. layout->addLayout(colorLayout);
  11592. QHBoxLayout*unitLayout= new QHBoxLayout;
  11593. QLabel*unitLabel= new QLabel(tr("Unit"));
  11594. QComboBox*unitSelector= new QComboBox;
  11595. unitSelector->addItem(tr("Fahrenheit"));
  11596. unitSelector->addItem(tr("Celsius"));
  11597. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11598. updateUnit(unitSelector->currentIndex());
  11599. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11600. unitLayout->addWidget(unitLabel);
  11601. unitLayout->addWidget(unitSelector);
  11602. unitLayout->addStretch();
  11603. layout->addLayout(unitLayout);
  11604. QHBoxLayout*axisLayout= new QHBoxLayout;
  11605. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11606. QLineEdit*axisEdit= new QLineEdit;
  11607. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11608. updateAxisSetting(axisEdit->text());
  11609. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11610. axisLayout->addWidget(axisLabel);
  11611. axisLayout->addWidget(axisEdit);
  11612. layout->addLayout(axisLayout);
  11613. layout->addStretch();
  11614. setLayout(layout);
  11615. }
  11616. /*:867*//*868:*/
  11617. #line 116 "./graphsettings.w"
  11618. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11619. {
  11620. QSettings settings;
  11621. settings.setValue("settings/graph/relative/enable",enabled);
  11622. }
  11623. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11624. {
  11625. QSettings settings;
  11626. settings.setValue("settings/graph/relative/color",color);
  11627. }
  11628. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11629. {
  11630. QSettings settings;
  11631. QString settingValue;
  11632. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11633. QStringList numbers;
  11634. foreach(QString text,points)
  11635. {
  11636. bool okay= false;
  11637. text.toDouble(&okay);
  11638. if(okay)
  11639. {
  11640. numbers.append(text);
  11641. }
  11642. }
  11643. numbers.removeDuplicates();
  11644. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11645. }
  11646. void GraphSettingsRelativeTab::updateUnit(int unit)
  11647. {
  11648. QSettings settings;
  11649. settings.setValue("settings/graph/relative/unit",unit);
  11650. }
  11651. /*:868*//*869:*/
  11652. #line 159 "./graphsettings.w"
  11653. void GraphSettingsRelativeTab::showColorPicker()
  11654. {
  11655. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11656. colorEdit->setText(color.name());
  11657. }
  11658. #line 62 "./settings.w"
  11659. #line 1 "./advancedsettings.w"
  11660. /*:869*/
  11661. #line 607 "./typica.w"
  11662. /*1020:*/
  11663. #line 682 "./dataqsdk.w"
  11664. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11665. const QModelIndex&index)
  11666. :BasicDeviceConfigurationWidget(model,index),
  11667. deviceIdStack(new QStackedWidget)
  11668. {
  11669. QVBoxLayout*layout= new QVBoxLayout;
  11670. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11671. layout->addWidget(autoDetect);
  11672. QWidget*autoLayerWidget= new QWidget;
  11673. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11674. QLabel*autoLabel= new QLabel(tr("Device number"));
  11675. QSpinBox*autoNumber= new QSpinBox;
  11676. autoNumber->setMinimum(1);
  11677. autoNumber->setMaximum(99);
  11678. autoLayerLayout->addWidget(autoLabel);
  11679. autoLayerLayout->addWidget(autoNumber);
  11680. autoLayerWidget->setLayout(autoLayerLayout);
  11681. QWidget*fixedLayerWidget= new QWidget;
  11682. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11683. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11684. QComboBox*portSelection= new QComboBox;
  11685. portSelection->setEditable(true);
  11686. portSelection->addItems(DataqSdkDevice::detectHardware());
  11687. fixedLayerLayout->addWidget(fixedLabel);
  11688. fixedLayerLayout->addWidget(portSelection);
  11689. fixedLayerWidget->setLayout(fixedLayerLayout);
  11690. deviceIdStack->addWidget(autoLayerWidget);
  11691. deviceIdStack->addWidget(fixedLayerWidget);
  11692. layout->addWidget(deviceIdStack);
  11693. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11694. layout->addWidget(addChannelButton);
  11695. /*799:*/
  11696. #line 16530 "./typica.w"
  11697. QDomElement referenceElement=
  11698. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11699. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11700. QDomElement node;
  11701. /*:799*/
  11702. #line 714 "./dataqsdk.w"
  11703. for(int i= 0;i<configData.size();i++)
  11704. {
  11705. node= configData.at(i).toElement();
  11706. if(node.attribute("name")=="autoSelect")
  11707. {
  11708. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11709. }
  11710. else if(node.attribute("name")=="deviceNumber")
  11711. {
  11712. autoNumber->setValue(node.attribute("value").toInt());
  11713. }
  11714. else if(node.attribute("name")=="port")
  11715. {
  11716. int index= portSelection->findText(node.attribute("value"));
  11717. if(index> -1)
  11718. {
  11719. portSelection->setCurrentIndex(index);
  11720. }
  11721. else
  11722. {
  11723. portSelection->setEditText(node.attribute("value"));
  11724. }
  11725. }
  11726. }
  11727. updateAutoSelect(autoDetect->isChecked());
  11728. updateDeviceNumber(autoNumber->value());
  11729. updatePort(portSelection->currentText());
  11730. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11731. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11732. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11733. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11734. setLayout(layout);
  11735. }
  11736. /*:1020*//*1021:*/
  11737. #line 758 "./dataqsdk.w"
  11738. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11739. {
  11740. if(automatic)
  11741. {
  11742. updateAttribute("autoSelect","true");
  11743. deviceIdStack->setCurrentIndex(0);
  11744. }
  11745. else
  11746. {
  11747. updateAttribute("autoSelect","false");
  11748. deviceIdStack->setCurrentIndex(1);
  11749. }
  11750. }
  11751. /*:1021*//*1022:*/
  11752. #line 775 "./dataqsdk.w"
  11753. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11754. {
  11755. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11756. }
  11757. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11758. {
  11759. updateAttribute("port",portId);
  11760. }
  11761. /*:1022*//*1023:*/
  11762. #line 788 "./dataqsdk.w"
  11763. void DataqSdkDeviceConfWidget::addChannel()
  11764. {
  11765. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11766. }
  11767. /*:1023*//*1026:*/
  11768. #line 868 "./dataqsdk.w"
  11769. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11770. const QModelIndex&index)
  11771. :BasicDeviceConfigurationWidget(model,index),
  11772. startButton(new QPushButton(tr("Start"))),
  11773. resetButton(new QPushButton(tr("Reset"))),
  11774. stopButton(new QPushButton(tr("Stop"))),
  11775. calibrator(new LinearCalibrator),
  11776. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11777. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11778. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11779. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11780. rmCount(0),cmCount(0),
  11781. rmin(std::numeric_limits<double> ::max()),
  11782. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11783. cmin(std::numeric_limits<double> ::max()),
  11784. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11785. {
  11786. /*1030:*/
  11787. #line 1107 "./dataqsdk.w"
  11788. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11789. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11790. QDomElement deviceNode;
  11791. QString configPort;
  11792. QString configAuto;
  11793. for(int i= 0;i<deviceConfigData.size();i++)
  11794. {
  11795. deviceNode= deviceConfigData.at(i).toElement();
  11796. if(deviceNode.attribute("name")=="autoSelect")
  11797. {
  11798. autoSelect= (deviceNode.attribute("value")=="true");
  11799. }
  11800. else if(deviceNode.attribute("name")=="deviceNumber")
  11801. {
  11802. configAuto= deviceNode.attribute("value");
  11803. }
  11804. else if(deviceNode.attribute("name")=="port")
  11805. {
  11806. configPort= deviceNode.attribute("value");
  11807. }
  11808. }
  11809. deviceID= autoSelect?configAuto:configPort;
  11810. channelOfInterest= index.row();
  11811. /*:1030*/
  11812. #line 886 "./dataqsdk.w"
  11813. resetButton->setEnabled(false);
  11814. stopButton->setEnabled(false);
  11815. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11816. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11817. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11818. QVBoxLayout*layout= new QVBoxLayout;
  11819. QFormLayout*topLayout= new QFormLayout;
  11820. QLineEdit*columnEdit= new QLineEdit;
  11821. topLayout->addRow(tr("Column name"),columnEdit);
  11822. QComboBox*unitSelector= new QComboBox;
  11823. unitSelector->addItem(tr("Temperature"));
  11824. unitSelector->addItem(tr("Control"));
  11825. topLayout->addRow(tr("Measurement type"),unitSelector);
  11826. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11827. topLayout->addRow(smoothingBox);
  11828. layout->addLayout(topLayout);
  11829. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11830. topLayout->addRow(hideSeries);
  11831. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11832. layout->addWidget(calibrationLabel);
  11833. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11834. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11835. QLineEdit*measuredLowerEdit= new QLineEdit;
  11836. measuredLowerEdit->setText("0");
  11837. QLineEdit*measuredUpperEdit= new QLineEdit;
  11838. measuredUpperEdit->setText("10");
  11839. QLineEdit*mappedLowerEdit= new QLineEdit;
  11840. mappedLowerEdit->setText("0");
  11841. QLineEdit*mappedUpperEdit= new QLineEdit;
  11842. mappedUpperEdit->setText("10");
  11843. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11844. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11845. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11846. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11847. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11848. calibrationControlsLayout->addRow(closedBox);
  11849. QLineEdit*sensitivityEdit= new QLineEdit;
  11850. sensitivityEdit->setText("0");
  11851. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11852. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11853. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11854. deviceControlLayout->addWidget(startButton);
  11855. deviceControlLayout->addWidget(resetButton);
  11856. deviceControlLayout->addWidget(stopButton);
  11857. QFormLayout*indicatorLayout= new QFormLayout;
  11858. currentMeasurement->setReadOnly(true);
  11859. minimumMeasurement->setReadOnly(true);
  11860. maximumMeasurement->setReadOnly(true);
  11861. averageMeasurement->setReadOnly(true);
  11862. currentMapped->setReadOnly(true);
  11863. minimumMapped->setReadOnly(true);
  11864. maximumMapped->setReadOnly(true);
  11865. averageMapped->setReadOnly(true);
  11866. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11867. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11868. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11869. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11870. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11871. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11872. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11873. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11874. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11875. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11876. calibrationTestLayout->addLayout(deviceControlLayout);
  11877. calibrationTestLayout->addLayout(indicatorLayout);
  11878. calibrationLayout->addLayout(calibrationControlsLayout);
  11879. calibrationLayout->addLayout(calibrationTestLayout);
  11880. layout->addLayout(calibrationLayout);
  11881. /*799:*/
  11882. #line 16530 "./typica.w"
  11883. QDomElement referenceElement=
  11884. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11885. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11886. QDomElement node;
  11887. /*:799*/
  11888. #line 955 "./dataqsdk.w"
  11889. for(int i= 0;i<configData.size();i++)
  11890. {
  11891. node= configData.at(i).toElement();
  11892. if(node.attribute("name")=="column")
  11893. {
  11894. columnEdit->setText(node.attribute("value"));
  11895. }
  11896. else if(node.attribute("name")=="type")
  11897. {
  11898. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11899. }
  11900. else if(node.attribute("name")=="smoothing")
  11901. {
  11902. smoothingBox->setChecked(node.attribute("value")=="true");
  11903. }
  11904. else if(node.attribute("name")=="calibrationMeasuredLower")
  11905. {
  11906. measuredLowerEdit->setText(node.attribute("value"));
  11907. }
  11908. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11909. {
  11910. measuredUpperEdit->setText(node.attribute("value"));
  11911. }
  11912. else if(node.attribute("name")=="calibrationMappedLower")
  11913. {
  11914. mappedLowerEdit->setText(node.attribute("value"));
  11915. }
  11916. else if(node.attribute("name")=="calibrationMappedUpper")
  11917. {
  11918. mappedUpperEdit->setText(node.attribute("value"));
  11919. }
  11920. else if(node.attribute("name")=="calibrationClosedInterval")
  11921. {
  11922. closedBox->setChecked(node.attribute("value")=="true");
  11923. }
  11924. else if(node.attribute("name")=="calibrationSensitivity")
  11925. {
  11926. sensitivityEdit->setText(node.attribute("value"));
  11927. }
  11928. else if(node.attribute("name")=="hidden")
  11929. {
  11930. hideSeries->setChecked(node.attribute("value")=="true");
  11931. }
  11932. }
  11933. updateColumnName(columnEdit->text());
  11934. updateUnits(unitSelector->currentText());
  11935. updateSmoothingEnabled(smoothingBox->isChecked());
  11936. updateMeasuredLower(measuredLowerEdit->text());
  11937. updateMeasuredUpper(measuredUpperEdit->text());
  11938. updateMappedLower(mappedLowerEdit->text());
  11939. updateMappedUpper(mappedUpperEdit->text());
  11940. updateClosedInterval(closedBox->isChecked());
  11941. updateSensitivity(sensitivityEdit->text());
  11942. updateHidden(hideSeries->isChecked());
  11943. connect(columnEdit,SIGNAL(textChanged(QString)),
  11944. this,SLOT(updateColumnName(QString)));
  11945. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11946. this,SLOT(updateUnits(QString)));
  11947. connect(smoothingBox,SIGNAL(toggled(bool)),
  11948. this,SLOT(updateSmoothingEnabled(bool)));
  11949. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11950. this,SLOT(updateMeasuredLower(QString)));
  11951. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11952. this,SLOT(updateMappedLower(QString)));
  11953. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11954. this,SLOT(updateMeasuredUpper(QString)));
  11955. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11956. this,SLOT(updateMappedUpper(QString)));
  11957. connect(closedBox,SIGNAL(toggled(bool)),
  11958. this,SLOT(updateClosedInterval(bool)));
  11959. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11960. this,SLOT(updateSensitivity(QString)));
  11961. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11962. setLayout(layout);
  11963. }
  11964. /*:1026*//*1027:*/
  11965. #line 1038 "./dataqsdk.w"
  11966. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11967. {
  11968. updateAttribute("type",unit);
  11969. }
  11970. /*:1027*//*1028:*/
  11971. #line 1047 "./dataqsdk.w"
  11972. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11973. {
  11974. updateAttribute("calibrationMeasuredLower",value);
  11975. calibrator->setMeasuredLower(value.toDouble());
  11976. }
  11977. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11978. {
  11979. updateAttribute("calibrationMeasuredUpper",value);
  11980. calibrator->setMeasuredUpper(value.toDouble());
  11981. }
  11982. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11983. {
  11984. updateAttribute("calibrationMappedLower",value);
  11985. calibrator->setMappedLower(value.toDouble());
  11986. }
  11987. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11988. {
  11989. updateAttribute("calibrationMappedUpper",value);
  11990. calibrator->setMappedUpper(value.toDouble());
  11991. }
  11992. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11993. {
  11994. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11995. calibrator->setClosedRange(closed);
  11996. }
  11997. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11998. {
  11999. updateAttribute("smoothing",enabled?"true":"false");
  12000. }
  12001. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  12002. {
  12003. updateAttribute("calibrationSensitivity",value);
  12004. calibrator->setSensitivity(value.toDouble());
  12005. }
  12006. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  12007. {
  12008. updateAttribute("hidden",hidden?"true":"false");
  12009. }
  12010. /*:1028*//*1031:*/
  12011. #line 1136 "./dataqsdk.w"
  12012. void DataqSdkChannelConfWidget::startCalibration()
  12013. {
  12014. startButton->setEnabled(false);
  12015. stopButton->setEnabled(true);
  12016. resetButton->setEnabled(true);
  12017. calibrationDevice= new DataqSdkDevice(deviceID);
  12018. Channel*channel;
  12019. for(unsigned int i= 0;i<=channelOfInterest;i++)
  12020. {
  12021. channel= calibrationDevice->newChannel(Units::Unitless);
  12022. }
  12023. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  12024. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  12025. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  12026. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  12027. calibrationDevice->start();
  12028. }
  12029. void DataqSdkChannelConfWidget::stopCalibration()
  12030. {
  12031. startButton->setEnabled(true);
  12032. stopButton->setEnabled(false);
  12033. resetButton->setEnabled(false);
  12034. calibrationDevice->deleteLater();
  12035. /*1033:*/
  12036. #line 1181 "./dataqsdk.w"
  12037. rmCount= 0;
  12038. cmCount= 0;
  12039. rmin= std::numeric_limits<double> ::max();
  12040. rmax= std::numeric_limits<double> ::min();
  12041. rmean= 0;
  12042. cmin= std::numeric_limits<double> ::max();
  12043. cmax= std::numeric_limits<double> ::min();
  12044. cmean= 0;
  12045. /*:1033*/
  12046. #line 1161 "./dataqsdk.w"
  12047. }
  12048. /*:1031*//*1032:*/
  12049. #line 1172 "./dataqsdk.w"
  12050. void DataqSdkChannelConfWidget::resetCalibration()
  12051. {
  12052. /*1033:*/
  12053. #line 1181 "./dataqsdk.w"
  12054. rmCount= 0;
  12055. cmCount= 0;
  12056. rmin= std::numeric_limits<double> ::max();
  12057. rmax= std::numeric_limits<double> ::min();
  12058. rmean= 0;
  12059. cmin= std::numeric_limits<double> ::max();
  12060. cmax= std::numeric_limits<double> ::min();
  12061. cmean= 0;
  12062. /*:1033*/
  12063. #line 1175 "./dataqsdk.w"
  12064. }
  12065. /*:1032*//*1034:*/
  12066. #line 1195 "./dataqsdk.w"
  12067. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  12068. {
  12069. double nv= measure.temperature();
  12070. currentMeasurement->setText(QString("%1").arg(nv));
  12071. rmin= qMin(nv,rmin);
  12072. minimumMeasurement->setText(QString("%1").arg(rmin));
  12073. rmax= qMax(nv,rmax);
  12074. maximumMeasurement->setText(QString("%1").arg(rmax));
  12075. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  12076. rmCount++;
  12077. averageMeasurement->setText(QString("%1").arg(rmean));
  12078. }
  12079. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  12080. {
  12081. double nv= measure.temperature();
  12082. currentMapped->setText(QString("%1").arg(nv));
  12083. cmin= qMin(nv,cmin);
  12084. minimumMapped->setText(QString("%1").arg(cmin));
  12085. cmax= qMax(nv,cmax);
  12086. maximumMapped->setText(QString("%1").arg(cmax));
  12087. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  12088. cmCount++;
  12089. averageMapped->setText(QString("%1").arg(cmean));
  12090. }
  12091. /*:1034*//*1035:*/
  12092. #line 1224 "./dataqsdk.w"
  12093. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  12094. {
  12095. updateAttribute("column",value);
  12096. }
  12097. /*:1035*/
  12098. #line 608 "./typica.w"
  12099. /*1059:*/
  12100. #line 423 "./scales.w"
  12101. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  12102. const QModelIndex&index)
  12103. :BasicDeviceConfigurationWidget(model,index),
  12104. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  12105. flow(new FlowSelector),stop(new StopSelector),
  12106. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  12107. {
  12108. QFormLayout*layout= new QFormLayout;
  12109. layout->addRow(tr("Port:"),port);
  12110. connect(port,SIGNAL(currentIndexChanged(QString)),
  12111. this,SLOT(updatePort(QString)));
  12112. connect(port,SIGNAL(editTextChanged(QString)),
  12113. this,SLOT(updatePort(QString)));
  12114. layout->addRow(tr("Baud:"),baud);
  12115. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12116. this,SLOT(updateBaudRate(QString)));
  12117. layout->addRow(tr("Parity:"),parity);
  12118. connect(parity,SIGNAL(currentIndexChanged(int)),
  12119. this,SLOT(updateParity(int)));
  12120. layout->addRow(tr("Flow Control:"),flow);
  12121. connect(flow,SIGNAL(currentIndexChanged(int)),
  12122. this,SLOT(updateFlowControl(int)));
  12123. layout->addRow(tr("Stop Bits:"),stop);
  12124. connect(stop,SIGNAL(currentIndexChanged(int)),
  12125. this,SLOT(updateStopBits(int)));
  12126. layout->addRow(tr("Weigh Command:"),weighcommand);
  12127. connect(weighcommand,SIGNAL(textChanged(QString)),
  12128. this,SLOT(updateWeighCommand(QString)));
  12129. commandterminator->addItem("CRLF");
  12130. commandterminator->addItem("CR");
  12131. commandterminator->addItem("LF");
  12132. layout->addRow(tr("Command Terminator:"),commandterminator);
  12133. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12134. this,SLOT(updateCommandTerminator(QString)));
  12135. /*799:*/
  12136. #line 16530 "./typica.w"
  12137. QDomElement referenceElement=
  12138. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12139. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12140. QDomElement node;
  12141. /*:799*/
  12142. #line 459 "./scales.w"
  12143. for(int i= 0;i<configData.size();i++)
  12144. {
  12145. node= configData.at(i).toElement();
  12146. if(node.attribute("name")=="port")
  12147. {
  12148. int j= port->findText(node.attribute("value"));
  12149. if(j>=0)
  12150. {
  12151. port->setCurrentIndex(j);
  12152. }
  12153. else
  12154. {
  12155. port->insertItem(0,node.attribute("value"));
  12156. port->setCurrentIndex(0);
  12157. }
  12158. }
  12159. else if(node.attribute("name")=="baudrate")
  12160. {
  12161. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12162. }
  12163. else if(node.attribute("name")=="parity")
  12164. {
  12165. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12166. }
  12167. else if(node.attribute("name")=="flowcontrol")
  12168. {
  12169. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12170. }
  12171. else if(node.attribute("name")=="stopbits")
  12172. {
  12173. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12174. }
  12175. else if(node.attribute("name")=="weighcommand")
  12176. {
  12177. weighcommand->setText(node.attribute("value"));
  12178. }
  12179. else if(node.attribute("name")=="commandterminator")
  12180. {
  12181. commandterminator->setCurrentIndex(
  12182. commandterminator->findText(node.attribute("value")));
  12183. }
  12184. }
  12185. updatePort(port->currentText());
  12186. updateBaudRate(baud->currentText());
  12187. updateParity(parity->currentIndex());
  12188. updateFlowControl(flow->currentIndex());
  12189. updateStopBits(stop->currentIndex());
  12190. updateWeighCommand(weighcommand->text());
  12191. updateCommandTerminator(commandterminator->currentText());
  12192. setLayout(layout);
  12193. }
  12194. /*:1059*//*1060:*/
  12195. #line 514 "./scales.w"
  12196. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12197. {
  12198. updateAttribute("port",newPort);
  12199. }
  12200. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12201. {
  12202. updateAttribute("baudrate",rate);
  12203. }
  12204. void SerialScaleConfWidget::updateParity(int index)
  12205. {
  12206. updateAttribute("parity",parity->itemData(index).toString());
  12207. }
  12208. void SerialScaleConfWidget::updateFlowControl(int index)
  12209. {
  12210. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12211. }
  12212. void SerialScaleConfWidget::updateStopBits(int index)
  12213. {
  12214. updateAttribute("stopbits",stop->itemData(index).toString());
  12215. }
  12216. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12217. {
  12218. updateAttribute("weighcommand",command);
  12219. }
  12220. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12221. {
  12222. updateAttribute("commandterminator",terminator);
  12223. }
  12224. /*:1060*/
  12225. #line 609 "./typica.w"
  12226. /*1072:*/
  12227. #line 195 "./valueannotation.w"
  12228. void ValueAnnotation::newMeasurement(Measurement measure)
  12229. {
  12230. for(int i= 0;i<values.size();i++)
  12231. {
  12232. if(measure.temperature()> values.at(i)-tolerance&&
  12233. measure.temperature()<values.at(i)+tolerance)
  12234. {
  12235. if(i!=lastIndex)
  12236. {
  12237. lastIndex= i;
  12238. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12239. }
  12240. }
  12241. }
  12242. }
  12243. /*:1072*//*1073:*/
  12244. #line 216 "./valueannotation.w"
  12245. void ValueAnnotation::annotate()
  12246. {
  12247. if(lastIndex> -1)
  12248. {
  12249. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12250. }
  12251. }
  12252. /*:1073*//*1074:*/
  12253. #line 228 "./valueannotation.w"
  12254. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12255. {
  12256. values.append(value);
  12257. annotations.append(annotation);
  12258. }
  12259. /*:1074*//*1075:*/
  12260. #line 237 "./valueannotation.w"
  12261. void ValueAnnotation::setAnnotationColumn(int column)
  12262. {
  12263. annotationColumn= column;
  12264. }
  12265. void ValueAnnotation::setTemperatureColumn(int column)
  12266. {
  12267. measurementColumn= column;
  12268. }
  12269. void ValueAnnotation::setTolerance(double epsilon)
  12270. {
  12271. tolerance= epsilon;
  12272. }
  12273. /*:1075*//*1076:*/
  12274. #line 255 "./valueannotation.w"
  12275. ValueAnnotation::ValueAnnotation():QObject(),
  12276. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12277. {
  12278. }
  12279. /*:1076*/
  12280. #line 610 "./typica.w"
  12281. /*1064:*/
  12282. #line 33 "./valueannotation.w"
  12283. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12284. const QModelIndex&index)
  12285. :BasicDeviceConfigurationWidget(model,index),
  12286. tablemodel(new SaltModel(2))
  12287. {
  12288. QFormLayout*layout= new QFormLayout;
  12289. QLineEdit*source= new QLineEdit;
  12290. layout->addRow(tr("Source column name:"),source);
  12291. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12292. noteOnStart->setChecked(true);
  12293. layout->addRow(noteOnStart);
  12294. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12295. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12296. QTableView*annotationTable= new QTableView;
  12297. annotationTable->setModel(tablemodel);
  12298. NumericDelegate*delegate= new NumericDelegate;
  12299. annotationTable->setItemDelegateForColumn(0,delegate);
  12300. layout->addRow(tr("Annotations for values:"),annotationTable);
  12301. /*799:*/
  12302. #line 16530 "./typica.w"
  12303. QDomElement referenceElement=
  12304. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12305. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12306. QDomElement node;
  12307. /*:799*/
  12308. #line 52 "./valueannotation.w"
  12309. for(int i= 0;i<configData.size();i++)
  12310. {
  12311. node= configData.at(i).toElement();
  12312. if(node.attribute("name")=="source")
  12313. {
  12314. source->setText(node.attribute("value"));
  12315. }
  12316. else if(node.attribute("name")=="emitOnStart")
  12317. {
  12318. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12319. }
  12320. else if(node.attribute("name")=="measuredValues")
  12321. {
  12322. /*962:*/
  12323. #line 19618 "./typica.w"
  12324. QString data= node.attribute("value");
  12325. if(data.length()> 3)
  12326. {
  12327. data.chop(2);
  12328. data= data.remove(0,2);
  12329. }
  12330. QStringList itemList= data.split(",");
  12331. /*:962*/
  12332. #line 66 "./valueannotation.w"
  12333. int column= 0;
  12334. /*963:*/
  12335. #line 19630 "./typica.w"
  12336. for(int j= 0;j<itemList.size();j++)
  12337. {
  12338. tablemodel->setData(tablemodel->index(j,column),
  12339. QVariant(itemList.at(j).toDouble()),
  12340. Qt::DisplayRole);
  12341. }
  12342. /*:963*/
  12343. #line 68 "./valueannotation.w"
  12344. }
  12345. else if(node.attribute("name")=="annotations")
  12346. {
  12347. /*1065:*/
  12348. #line 89 "./valueannotation.w"
  12349. QString data= node.attribute("value");
  12350. if(data.length()> 3)
  12351. {
  12352. data.chop(2);
  12353. data= data.remove(0,2);
  12354. }
  12355. QStringList itemList= data.split(",");
  12356. for(int i= 0;i<itemList.size();i++)
  12357. {
  12358. itemList[i]= itemList[i].simplified();
  12359. }
  12360. /*:1065*/
  12361. #line 72 "./valueannotation.w"
  12362. int column= 1;
  12363. /*1066:*/
  12364. #line 104 "./valueannotation.w"
  12365. for(int i= 0;i<itemList.size();i++)
  12366. {
  12367. tablemodel->setData(tablemodel->index(i,column),
  12368. QVariant(itemList.at(i)),
  12369. Qt::DisplayRole);
  12370. }
  12371. /*:1066*/
  12372. #line 74 "./valueannotation.w"
  12373. }
  12374. }
  12375. updateSourceColumn(source->text());
  12376. updateStart(noteOnStart->isChecked());
  12377. updateAnnotations();
  12378. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12379. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12380. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12381. setLayout(layout);
  12382. }
  12383. /*:1064*//*1067:*/
  12384. #line 115 "./valueannotation.w"
  12385. void ValueAnnotationConfWidget::updateAnnotations()
  12386. {
  12387. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12388. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12389. }
  12390. /*:1067*//*1068:*/
  12391. #line 125 "./valueannotation.w"
  12392. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12393. {
  12394. updateAttribute("source",source);
  12395. }
  12396. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12397. {
  12398. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12399. }
  12400. /*:1068*/
  12401. #line 611 "./typica.w"
  12402. /*895:*/
  12403. #line 44 "./modbus.w"
  12404. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12405. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12406. m_flow(new FlowSelector),m_stop(new StopSelector)
  12407. {
  12408. QFormLayout*layout= new QFormLayout;
  12409. PortSelector*port= new PortSelector;
  12410. BaudSelector*baud= new BaudSelector;
  12411. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12412. layout->addRow(QString(tr("Port:")),port);
  12413. layout->addRow(QString(tr("Baud rate:")),baud);
  12414. layout->addRow(QString(tr("Parity:")),m_parity);
  12415. layout->addRow(QString(tr("Flow control:")),m_flow);
  12416. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12417. layout->addRow(newInput);
  12418. /*799:*/
  12419. #line 16530 "./typica.w"
  12420. QDomElement referenceElement=
  12421. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12422. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12423. QDomElement node;
  12424. /*:799*/
  12425. #line 60 "./modbus.w"
  12426. for(int i= 0;i<configData.size();i++)
  12427. {
  12428. node= configData.at(i).toElement();
  12429. if(node.attribute("name")=="port")
  12430. {
  12431. int idx= port->findText(node.attribute("value"));
  12432. if(idx>=0)
  12433. {
  12434. port->setCurrentIndex(idx);
  12435. }
  12436. else
  12437. {
  12438. port->addItem(node.attribute("value"));
  12439. }
  12440. }
  12441. else if(node.attribute("name")=="baud")
  12442. {
  12443. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12444. }
  12445. else if(node.attribute("name")=="parity")
  12446. {
  12447. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12448. }
  12449. else if(node.attribute("name")=="flow")
  12450. {
  12451. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12452. }
  12453. else if(node.attribute("name")=="stop")
  12454. {
  12455. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12456. }
  12457. }
  12458. updatePort(port->currentText());
  12459. updateBaudRate(baud->currentText());
  12460. updateParity(m_parity->currentIndex());
  12461. updateFlowControl(m_flow->currentIndex());
  12462. updateStopBits(m_stop->currentIndex());
  12463. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12464. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12465. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12466. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12467. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12468. this,SLOT(updateFlowControl(int)));
  12469. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12470. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12471. setLayout(layout);
  12472. }
  12473. void ModbusNGConfWidget::updatePort(const QString&value)
  12474. {
  12475. updateAttribute("port",value);
  12476. }
  12477. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12478. {
  12479. updateAttribute("baud",value);
  12480. }
  12481. void ModbusNGConfWidget::updateParity(int value)
  12482. {
  12483. updateAttribute("parity",m_parity->itemData(value).toString());
  12484. }
  12485. void ModbusNGConfWidget::updateFlowControl(int value)
  12486. {
  12487. updateAttribute("flow",m_flow->itemData(value).toString());
  12488. }
  12489. void ModbusNGConfWidget::updateStopBits(int value)
  12490. {
  12491. updateAttribute("stop",m_stop->itemData(value).toString());
  12492. }
  12493. void ModbusNGConfWidget::addInput()
  12494. {
  12495. insertChildNode(tr("Input"),"modbusnginput");
  12496. }
  12497. /*:895*//*897:*/
  12498. #line 164 "./modbus.w"
  12499. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12500. {
  12501. QFormLayout*layout= new QFormLayout;
  12502. QSpinBox*station= new QSpinBox;
  12503. station->setMinimum(1);
  12504. station->setMaximum(247);
  12505. layout->addRow(tr("Station ID"),station);
  12506. QComboBox*function= new QComboBox;
  12507. function->addItem("3","3");
  12508. function->addItem("4","4");
  12509. function->setCurrentIndex(1);
  12510. layout->addRow(tr("Function"),function);
  12511. ShortHexSpinBox*address= new ShortHexSpinBox;
  12512. layout->addRow(tr("Address"),address);
  12513. QComboBox*format= new QComboBox;
  12514. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12515. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12516. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12517. layout->addRow(tr("Data format"),format);
  12518. QSpinBox*decimals= new QSpinBox;
  12519. decimals->setMinimum(0);
  12520. decimals->setMaximum(9);
  12521. layout->addRow(tr("Decimal places"),decimals);
  12522. QComboBox*unit= new QComboBox;
  12523. unit->addItem("Celsius","C");
  12524. unit->addItem("Fahrenheit","F");
  12525. unit->addItem("Control","Control");
  12526. unit->setCurrentIndex(1);
  12527. layout->addRow(tr("Unit"),unit);
  12528. QLineEdit*column= new QLineEdit;
  12529. layout->addRow(tr("Column name"),column);
  12530. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12531. layout->addRow(hidden);
  12532. /*799:*/
  12533. #line 16530 "./typica.w"
  12534. QDomElement referenceElement=
  12535. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12536. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12537. QDomElement node;
  12538. /*:799*/
  12539. #line 199 "./modbus.w"
  12540. for(int i= 0;i<configData.size();i++)
  12541. {
  12542. node= configData.at(i).toElement();
  12543. if(node.attribute("name")=="station")
  12544. {
  12545. station->setValue(node.attribute("value").toInt());
  12546. }
  12547. else if(node.attribute("name")=="function")
  12548. {
  12549. function->setCurrentIndex(function->findText(node.attribute("value")));
  12550. }
  12551. else if(node.attribute("name")=="address")
  12552. {
  12553. address->setValue(node.attribute("value").toInt());
  12554. }
  12555. else if(node.attribute("name")=="format")
  12556. {
  12557. format->setCurrentIndex(format->findData(node.attribute("value")));
  12558. }
  12559. else if(node.attribute("name")=="decimals")
  12560. {
  12561. decimals->setValue(node.attribute("value").toInt());
  12562. }
  12563. else if(node.attribute("name")=="unit")
  12564. {
  12565. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12566. }
  12567. else if(node.attribute("name")=="column")
  12568. {
  12569. column->setText(node.attribute("value"));
  12570. }
  12571. else if(node.attribute("name")=="hidden")
  12572. {
  12573. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12574. }
  12575. }
  12576. updateStation(station->value());
  12577. updateFunction(function->currentIndex());
  12578. updateAddress(address->value());
  12579. updateFormat(format->currentIndex());
  12580. updateDecimals(decimals->value());
  12581. updateUnit(unit->currentIndex());
  12582. updateColumnName(column->text());
  12583. updateHidden(hidden->isChecked());
  12584. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12585. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12586. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12587. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12588. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12589. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12590. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12591. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12592. setLayout(layout);
  12593. }
  12594. void ModbusNGInputConfWidget::updateStation(int value)
  12595. {
  12596. updateAttribute("station",QString("%1").arg(value));
  12597. }
  12598. void ModbusNGInputConfWidget::updateFunction(int value)
  12599. {
  12600. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12601. }
  12602. void ModbusNGInputConfWidget::updateAddress(int value)
  12603. {
  12604. updateAttribute("address",QString("%1").arg(value));
  12605. }
  12606. void ModbusNGInputConfWidget::updateFormat(int value)
  12607. {
  12608. switch(value)
  12609. {
  12610. case 0:
  12611. updateAttribute("format","16fixedint");
  12612. break;
  12613. case 1:
  12614. updateAttribute("format","32floathl");
  12615. break;
  12616. case 2:
  12617. updateAttribute("format","32floatlh");
  12618. break;
  12619. }
  12620. }
  12621. void ModbusNGInputConfWidget::updateDecimals(int value)
  12622. {
  12623. updateAttribute("decimals",QString("%1").arg(value));
  12624. }
  12625. void ModbusNGInputConfWidget::updateUnit(int value)
  12626. {
  12627. switch(value)
  12628. {
  12629. case 0:
  12630. updateAttribute("unit","C");
  12631. break;
  12632. case 1:
  12633. updateAttribute("unit","F");
  12634. break;
  12635. case 2:
  12636. updateAttribute("unit","Control");
  12637. break;
  12638. }
  12639. }
  12640. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  12641. {
  12642. updateAttribute("column",value);
  12643. }
  12644. void ModbusNGInputConfWidget::updateHidden(bool value)
  12645. {
  12646. updateAttribute("hidden",value?"true":"false");
  12647. }
  12648. /*:897*//*902:*/
  12649. #line 403 "./modbus.w"
  12650. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  12651. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  12652. rateLimiter(new QTimer),scanPosition(0),waiting(false)
  12653. {
  12654. QDomElement portReferenceElement=
  12655. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12656. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  12657. QDomElement node;
  12658. QVariantMap attributes;
  12659. for(int i= 0;i<portConfigData.size();i++)
  12660. {
  12661. node= portConfigData.at(i).toElement();
  12662. attributes.insert(node.attribute("name"),node.attribute("value"));
  12663. }
  12664. port= new QextSerialPort(attributes.value("port").toString(),
  12665. QextSerialPort::EventDriven);
  12666. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  12667. port->setDataBits(DATA_8);
  12668. port->setParity((ParityType)attributes.value("parity").toInt());
  12669. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  12670. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  12671. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  12672. messageDelayTimer->setSingleShot(true);
  12673. commTimeout->setSingleShot(true);
  12674. rateLimiter->setSingleShot(true);
  12675. rateLimiter->setInterval(0);
  12676. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  12677. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  12678. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  12679. connect(rateLimiter,SIGNAL(timeout()),this,SLOT(rateLimitTimeout()));
  12680. if(!port->open(QIODevice::ReadWrite))
  12681. {
  12682. qDebug()<<"Failed to open serial port";
  12683. }
  12684. for(int i= 0;i<model->rowCount(index);i++)
  12685. {
  12686. QModelIndex channelIndex= model->index(i,0,index);
  12687. QDomElement channelReferenceElement=
  12688. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12689. QDomNodeList channelConfigData=
  12690. channelReferenceElement.elementsByTagName("attribute");
  12691. QDomElement channelNode;
  12692. QVariantMap channelAttributes;
  12693. for(int j= 0;j<channelConfigData.size();j++)
  12694. {
  12695. channelNode= channelConfigData.at(j).toElement();
  12696. channelAttributes.insert(channelNode.attribute("name"),
  12697. channelNode.attribute("value"));
  12698. }
  12699. ModbusScanItem scanItem;
  12700. QString format= channelAttributes.value("format").toString();
  12701. if(format=="16fixedint")
  12702. {
  12703. scanItem.format= Int16;
  12704. }
  12705. else if(format=="32floathl")
  12706. {
  12707. scanItem.format= FloatHL;
  12708. }
  12709. else if(format=="32floatlh")
  12710. {
  12711. scanItem.format= FloatLH;
  12712. }
  12713. scanItem.request.append((char)channelAttributes.value("station").toInt());
  12714. scanItem.request.append((char)channelAttributes.value("function").toInt());
  12715. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  12716. char*startAddressBytes= (char*)&startAddress;
  12717. scanItem.request.append(startAddressBytes[1]);
  12718. scanItem.request.append(startAddressBytes[0]);
  12719. scanItem.request.append((char)0x00);
  12720. if(scanItem.format==Int16)
  12721. {
  12722. scanItem.request.append((char)0x01);
  12723. }
  12724. else
  12725. {
  12726. scanItem.request.append((char)0x02);
  12727. }
  12728. quint16 crc= calculateCRC(scanItem.request);
  12729. char*crcBytes= (char*)&crc;
  12730. scanItem.request.append(crcBytes[0]);
  12731. scanItem.request.append(crcBytes[1]);
  12732. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  12733. if(channelAttributes.value("unit").toString()=="C")
  12734. {
  12735. scanItem.unit= Units::Celsius;
  12736. channelTypeList.append("T");
  12737. }
  12738. else if(channelAttributes.value("unit").toString()=="F")
  12739. {
  12740. scanItem.unit= Units::Fahrenheit;
  12741. channelTypeList.append("T");
  12742. }
  12743. else
  12744. {
  12745. scanItem.unit= Units::Unitless;
  12746. channelTypeList.append("C");
  12747. }
  12748. scanList.append(scanItem);
  12749. lastMeasurement.append(0.0);
  12750. channels.append(new Channel);
  12751. channelNames.append(channelAttributes.value("column").toString());
  12752. hiddenStates.append(
  12753. channelAttributes.value("hidden").toString()=="true"?true:false);
  12754. channelLabels.append(model->data(channelIndex,0).toString());
  12755. }
  12756. messageDelayTimer->start();
  12757. }
  12758. ModbusNG::~ModbusNG()
  12759. {
  12760. commTimeout->stop();
  12761. messageDelayTimer->stop();
  12762. port->close();
  12763. }
  12764. void ModbusNG::sendNextMessage()
  12765. {
  12766. if(scanList.length()> 0&&!waiting)
  12767. {
  12768. port->write(scanList.at(scanPosition).request);
  12769. commTimeout->start(2000);
  12770. messageDelayTimer->start(delayTime);
  12771. waiting= true;
  12772. }
  12773. }
  12774. void ModbusNG::timeout()
  12775. {
  12776. qDebug()<<"Communications timeout.";
  12777. messageDelayTimer->start();
  12778. }
  12779. void ModbusNG::rateLimitTimeout()
  12780. {
  12781. messageDelayTimer->start();
  12782. }
  12783. void ModbusNG::dataAvailable()
  12784. {
  12785. if(messageDelayTimer->isActive())
  12786. {
  12787. messageDelayTimer->stop();
  12788. }
  12789. responseBuffer.append(port->readAll());
  12790. if(responseBuffer.size()<5)
  12791. {
  12792. return;
  12793. }
  12794. if(responseBuffer.size()<5+responseBuffer.at(2))
  12795. {
  12796. return;
  12797. }
  12798. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  12799. commTimeout->stop();
  12800. if(calculateCRC(responseBuffer)==0)
  12801. {
  12802. quint16 intresponse;
  12803. float floatresponse;
  12804. char*ibytes= (char*)&intresponse;
  12805. char*fbytes= (char*)&floatresponse;
  12806. double output;
  12807. switch(scanList.at(scanPosition).format)
  12808. {
  12809. case Int16:
  12810. ibytes[0]= responseBuffer.at(4);
  12811. ibytes[1]= responseBuffer.at(3);
  12812. output= intresponse;
  12813. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  12814. {
  12815. output/= 10;
  12816. }
  12817. break;
  12818. case FloatHL:
  12819. fbytes[0]= responseBuffer.at(4);
  12820. fbytes[1]= responseBuffer.at(3);
  12821. fbytes[2]= responseBuffer.at(6);
  12822. fbytes[3]= responseBuffer.at(5);
  12823. output= floatresponse;
  12824. break;
  12825. case FloatLH:
  12826. fbytes[0]= responseBuffer.at(6);
  12827. fbytes[1]= responseBuffer.at(5);
  12828. fbytes[2]= responseBuffer.at(4);
  12829. fbytes[3]= responseBuffer.at(3);
  12830. output= floatresponse;
  12831. break;
  12832. }
  12833. if(scanList.at(scanPosition).unit==Units::Celsius)
  12834. {
  12835. output= output*9.0/5.0+32.0;
  12836. }
  12837. scanList.at(scanPosition).lastValue= output;
  12838. }
  12839. else
  12840. {
  12841. qDebug()<<"CRC failed";
  12842. }
  12843. scanPosition= (scanPosition+1)%scanList.size();
  12844. if(scanPosition==0)
  12845. {
  12846. QTime time= QTime::currentTime();
  12847. bool doOutput= false;
  12848. for(int i= 0;i<scanList.size();i++)
  12849. {
  12850. if(scanList.at(i).lastValue!=lastMeasurement.at(i))
  12851. {
  12852. doOutput= true;
  12853. break;
  12854. }
  12855. }
  12856. if(doOutput)
  12857. {
  12858. for(int i= 0;i<scanList.size();i++)
  12859. {
  12860. lastMeasurement[i]= scanList.at(i).lastValue;
  12861. if(scanList.at(scanPosition).unit==Units::Unitless)
  12862. {
  12863. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Unitless));
  12864. }
  12865. else
  12866. {
  12867. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  12868. }
  12869. }
  12870. }
  12871. }
  12872. responseBuffer.clear();
  12873. waiting= false;
  12874. if(scanPosition==0)
  12875. {
  12876. rateLimiter->start();
  12877. }
  12878. else
  12879. {
  12880. messageDelayTimer->start(delayTime);
  12881. }
  12882. }
  12883. quint16 ModbusNG::calculateCRC(QByteArray data)
  12884. {
  12885. quint16 retval= 0xFFFF;
  12886. int i= 0;
  12887. while(i<data.size())
  12888. {
  12889. retval^= 0x00FF&(quint16)data.at(i);
  12890. for(int j= 0;j<8;j++)
  12891. {
  12892. if(retval&1)
  12893. {
  12894. retval= (retval>>1)^0xA001;
  12895. }
  12896. else
  12897. {
  12898. retval>>= 1;
  12899. }
  12900. }
  12901. i++;
  12902. }
  12903. return retval;
  12904. }
  12905. int ModbusNG::channelCount()
  12906. {
  12907. return channels.size();
  12908. }
  12909. Channel*ModbusNG::getChannel(int channel)
  12910. {
  12911. return channels.at(channel);
  12912. }
  12913. QString ModbusNG::channelColumnName(int channel)
  12914. {
  12915. return channelNames.at(channel);
  12916. }
  12917. QString ModbusNG::channelIndicatorText(int channel)
  12918. {
  12919. return channelLabels.at(channel);
  12920. }
  12921. bool ModbusNG::isChannelHidden(int channel)
  12922. {
  12923. return hiddenStates.at(channel);
  12924. }
  12925. QString ModbusNG::channelType(int channel)
  12926. {
  12927. return channelTypeList.at(channel);
  12928. }
  12929. /*:902*/
  12930. #line 612 "./typica.w"
  12931. /*1081:*/
  12932. #line 33 "./thresholdannotation.w"
  12933. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  12934. const QModelIndex&index)
  12935. :BasicDeviceConfigurationWidget(model,index)
  12936. {
  12937. QFormLayout*layout= new QFormLayout;
  12938. QLineEdit*source= new QLineEdit;
  12939. layout->addRow(tr("Source column name:"),source);
  12940. QDoubleSpinBox*value= new QDoubleSpinBox;
  12941. value->setMinimum(-9999.99);
  12942. value->setMaximum(9999.99);
  12943. value->setDecimals(2);
  12944. layout->addRow(tr("Threshold value:"),value);
  12945. QComboBox*direction= new QComboBox;
  12946. direction->addItem(tr("Ascending"));
  12947. direction->addItem(tr("Descending"));
  12948. layout->addRow(tr("Direction:"),direction);
  12949. QLineEdit*annotation= new QLineEdit;
  12950. layout->addRow(tr("Annotation:"),annotation);
  12951. /*799:*/
  12952. #line 16530 "./typica.w"
  12953. QDomElement referenceElement=
  12954. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12955. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12956. QDomElement node;
  12957. /*:799*/
  12958. #line 52 "./thresholdannotation.w"
  12959. for(int i= 0;i<configData.size();i++)
  12960. {
  12961. node= configData.at(i).toElement();
  12962. if(node.attribute("name")=="source")
  12963. {
  12964. source->setText(node.attribute("value"));
  12965. }
  12966. else if(node.attribute("name")=="value")
  12967. {
  12968. value->setValue(node.attribute("value").toDouble());
  12969. }
  12970. else if(node.attribute("name")=="direction")
  12971. {
  12972. direction->setCurrentIndex(node.attribute("value").toInt());
  12973. }
  12974. else if(node.attribute("name")=="annotation")
  12975. {
  12976. annotation->setText(node.attribute("value"));
  12977. }
  12978. }
  12979. updateSourceColumn(source->text());
  12980. updateThreshold(value->value());
  12981. updateDirection(direction->currentIndex());
  12982. updateAnnotation(annotation->text());
  12983. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12984. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  12985. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  12986. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  12987. setLayout(layout);
  12988. }
  12989. /*:1081*//*1082:*/
  12990. #line 86 "./thresholdannotation.w"
  12991. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  12992. {
  12993. updateAttribute("source",source);
  12994. }
  12995. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  12996. {
  12997. updateAttribute("value",QString("%1").arg(value));
  12998. }
  12999. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  13000. {
  13001. updateAttribute("direction",QString("%1").arg(direction));
  13002. }
  13003. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  13004. {
  13005. updateAttribute("annotation",annotation);
  13006. }
  13007. /*:1082*/
  13008. #line 613 "./typica.w"
  13009. /*1086:*/
  13010. #line 152 "./thresholdannotation.w"
  13011. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  13012. {
  13013. t.setInterval(0);
  13014. t.setSingleShot(true);
  13015. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  13016. }
  13017. void Annotator::setAnnotation(const QString&annotation)
  13018. {
  13019. note= annotation;
  13020. }
  13021. void Annotator::setTemperatureColumn(int tempcolumn)
  13022. {
  13023. tc= tempcolumn;
  13024. }
  13025. void Annotator::setAnnotationColumn(int annotationcolumn)
  13026. {
  13027. ac= annotationcolumn;
  13028. }
  13029. /*:1086*//*1087:*/
  13030. #line 181 "./thresholdannotation.w"
  13031. void Annotator::catchTimer()
  13032. {
  13033. emit annotation(note,tc,ac);
  13034. }
  13035. void Annotator::annotate()
  13036. {
  13037. t.start();
  13038. }
  13039. /*:1087*/
  13040. #line 614 "./typica.w"
  13041. /*:4*//*259:*/
  13042. #line 6084 "./typica.w"
  13043. /*256:*/
  13044. #line 6047 "./typica.w"
  13045. void ScriptValidator::fixup(QString&input)const
  13046. {
  13047. QScriptEngine*engine= AppInstance->engine;
  13048. engine->pushContext();
  13049. input= engine->evaluate(input).toString();
  13050. engine->popContext();
  13051. }
  13052. /*:256*//*257:*/
  13053. #line 6060 "./typica.w"
  13054. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  13055. {
  13056. if(v)
  13057. {
  13058. if(v->validate(input,pos)==QValidator::Acceptable)
  13059. {
  13060. return QValidator::Acceptable;
  13061. }
  13062. }
  13063. return QValidator::Intermediate;
  13064. }
  13065. /*:257*//*258:*/
  13066. #line 6075 "./typica.w"
  13067. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  13068. :QValidator(parent),v(validator)
  13069. {
  13070. }
  13071. /*:258*/
  13072. #line 6085 "./typica.w"
  13073. /*:259*//*692:*/
  13074. #line 160 "./plugins.w"
  13075. /*689:*/
  13076. #line 92 "./plugins.w"
  13077. PluginAction::PluginAction(const QFileInfo&info,QObject*parent):
  13078. QAction(parent),preRunScript(""),postRunScript("")
  13079. {
  13080. pluginFile= info.absoluteFilePath();
  13081. setText(info.baseName());
  13082. connect(this,SIGNAL(triggered()),this,SLOT(runScript()));
  13083. }
  13084. void PluginAction::runScript()
  13085. {
  13086. QFile file(pluginFile);
  13087. if(file.open(QIODevice::ReadOnly))
  13088. {
  13089. QScriptEngine*engine= AppInstance->engine;
  13090. QScriptContext*context= engine->pushContext();
  13091. if(parent()->dynamicPropertyNames().contains("activationObject"))
  13092. {
  13093. QScriptValue activationObject=
  13094. parent()->property("activationObject").value<QScriptValue> ();
  13095. context->setActivationObject(activationObject);
  13096. }
  13097. QString script(file.readAll());
  13098. QScriptValue retval= engine->evaluate(preRunScript+script+postRunScript,pluginFile);
  13099. if(engine->hasUncaughtException())
  13100. {
  13101. qDebug()<<"Uncaught exception: "<<
  13102. engine->uncaughtException().toString()<<
  13103. " in "<<pluginFile<<" line: "<<
  13104. engine->uncaughtExceptionLineNumber();
  13105. }
  13106. engine->popContext();
  13107. file.close();
  13108. }
  13109. }
  13110. /*:689*//*690:*/
  13111. #line 131 "./plugins.w"
  13112. QString PluginAction::preRun()
  13113. {
  13114. return preRunScript;
  13115. }
  13116. QString PluginAction::postRun()
  13117. {
  13118. return postRunScript;
  13119. }
  13120. void PluginAction::setPreRun(const QString&script)
  13121. {
  13122. preRunScript= script;
  13123. }
  13124. void PluginAction::setPostRun(const QString&script)
  13125. {
  13126. postRunScript= script;
  13127. }
  13128. /*:690*/
  13129. #line 161 "./plugins.w"
  13130. #line 14491 "./typica.w"
  13131. #line 1 "./daterangeselector.w"
  13132. /*:692*//*873:*/
  13133. #line 60 "./advancedsettings.w"
  13134. /*871:*/
  13135. #line 26 "./advancedsettings.w"
  13136. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  13137. {
  13138. QSettings settings;
  13139. QFormLayout*layout= new QFormLayout;
  13140. QCheckBox*logDiagnostics= new QCheckBox;
  13141. logDiagnostics->setCheckState(
  13142. settings.value("settings/advanced/logging",false).toBool()?
  13143. Qt::Checked:Qt::Unchecked);
  13144. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  13145. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  13146. setLayout(layout);
  13147. }
  13148. /*:871*//*872:*/
  13149. #line 43 "./advancedsettings.w"
  13150. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  13151. {
  13152. QSettings settings;
  13153. settings.setValue("settings/advanced/logging",enabled);
  13154. if(enabled)
  13155. {
  13156. qInstallMsgHandler(messageFileOutput);
  13157. }
  13158. else
  13159. {
  13160. qInstallMsgHandler(0);
  13161. }
  13162. }
  13163. /*:872*/
  13164. #line 61 "./advancedsettings.w"
  13165. #line 18294 "./typica.w"
  13166. /*:873*//*932:*/
  13167. #line 639 "./unsupportedserial.w"
  13168. /*907:*/
  13169. #line 58 "./unsupportedserial.w"
  13170. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  13171. const QModelIndex&index)
  13172. :BasicDeviceConfigurationWidget(model,index),
  13173. deviceSettingsModel(new SaltModel(2)),
  13174. scriptEditor(new QTextEdit)
  13175. {
  13176. scriptEditor->setTabStopWidth(20);
  13177. QVBoxLayout*dummyLayout= new QVBoxLayout;
  13178. QTabWidget*central= new QTabWidget;
  13179. QWidget*deviceConfigurationWidget= new QWidget;
  13180. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  13181. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13182. deviceConfigurationLayout->addWidget(addChannelButton);
  13183. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13184. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  13185. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  13186. QTableView*deviceSettingsView= new QTableView;
  13187. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  13188. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  13189. deviceSettingsView->setModel(deviceSettingsModel);
  13190. deviceConfigurationLayout->addWidget(deviceSettingsView);
  13191. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  13192. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  13193. central->addTab(scriptEditor,tr("Script"));
  13194. dummyLayout->addWidget(central);
  13195. /*799:*/
  13196. #line 16530 "./typica.w"
  13197. QDomElement referenceElement=
  13198. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13199. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13200. QDomElement node;
  13201. /*:799*/
  13202. #line 86 "./unsupportedserial.w"
  13203. for(int i= 0;i<configData.size();i++)
  13204. {
  13205. node= configData.at(i).toElement();
  13206. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13207. {
  13208. int column= 0;
  13209. if(node.attribute("name")=="values")
  13210. {
  13211. column= 1;
  13212. }
  13213. QString data= node.attribute("value");
  13214. if(data.length()> 3)
  13215. {
  13216. data.chop(2);
  13217. data= data.remove(0,2);
  13218. }
  13219. QStringList keyList= data.split(", ");
  13220. for(int j= 0;j<keyList.size();j++)
  13221. {
  13222. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  13223. QVariant(keyList.at(j)),
  13224. Qt::EditRole);
  13225. }
  13226. }
  13227. else if(node.attribute("name")=="script")
  13228. {
  13229. scriptEditor->setPlainText(node.attribute("value"));
  13230. }
  13231. }
  13232. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13233. this,SLOT(updateConfiguration()));
  13234. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13235. setLayout(dummyLayout);
  13236. }
  13237. /*:907*//*908:*/
  13238. #line 131 "./unsupportedserial.w"
  13239. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13240. {
  13241. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13242. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13243. }
  13244. /*:908*//*909:*/
  13245. #line 144 "./unsupportedserial.w"
  13246. void UnsupportedSerialDeviceConfWidget::saveScript()
  13247. {
  13248. updateAttribute("script",scriptEditor->toPlainText());
  13249. }
  13250. /*:909*//*910:*/
  13251. #line 155 "./unsupportedserial.w"
  13252. void UnsupportedSerialDeviceConfWidget::addChannel()
  13253. {
  13254. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13255. }
  13256. /*:910*//*912:*/
  13257. #line 183 "./unsupportedserial.w"
  13258. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13259. const QModelIndex&index)
  13260. :BasicDeviceConfigurationWidget(model,index),
  13261. channelSettingsModel(new SaltModel(2))
  13262. {
  13263. QFormLayout*layout= new QFormLayout;
  13264. QLineEdit*columnName= new QLineEdit;
  13265. layout->addRow(tr("Column Name:"),columnName);
  13266. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13267. layout->addRow(hideSeries);
  13268. QTableView*channelSettings= new QTableView;
  13269. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13270. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13271. channelSettings->setModel(channelSettingsModel);
  13272. layout->addRow(channelSettings);
  13273. setLayout(layout);
  13274. /*799:*/
  13275. #line 16530 "./typica.w"
  13276. QDomElement referenceElement=
  13277. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13278. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13279. QDomElement node;
  13280. /*:799*/
  13281. #line 200 "./unsupportedserial.w"
  13282. for(int i= 0;i<configData.size();i++)
  13283. {
  13284. node= configData.at(i).toElement();
  13285. if(node.attribute("name")=="columnname")
  13286. {
  13287. columnName->setText(node.attribute("value"));
  13288. }
  13289. else if(node.attribute("name")=="hidden")
  13290. {
  13291. hideSeries->setChecked(node.attribute("value")=="true");
  13292. }
  13293. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13294. {
  13295. int column= 0;
  13296. if(node.attribute("name")=="values")
  13297. {
  13298. column= 1;
  13299. }
  13300. QString data= node.attribute("value");
  13301. if(data.length()> 3)
  13302. {
  13303. data.chop(2);
  13304. data= data.remove(0,2);
  13305. }
  13306. QStringList keyList= data.split(", ");
  13307. for(int j= 0;j<keyList.size();j++)
  13308. {
  13309. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13310. QVariant(keyList.at(j)),
  13311. Qt::EditRole);
  13312. }
  13313. }
  13314. }
  13315. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13316. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13317. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13318. this,SLOT(updateConfiguration()));
  13319. }
  13320. /*:912*//*913:*/
  13321. #line 244 "./unsupportedserial.w"
  13322. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13323. {
  13324. updateAttribute("columnname",value);
  13325. }
  13326. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13327. {
  13328. updateAttribute("hidden",hidden?"true":"false");
  13329. }
  13330. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13331. {
  13332. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13333. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13334. }
  13335. /*:913*/
  13336. #line 640 "./unsupportedserial.w"
  13337. /*920:*/
  13338. #line 371 "./unsupportedserial.w"
  13339. void JavaScriptDevice::start()
  13340. {
  13341. QScriptValue object= scriptengine->newQObject(this);
  13342. /*921:*/
  13343. #line 390 "./unsupportedserial.w"
  13344. QScriptValue settingsObject= scriptengine->newObject();
  13345. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13346. while(i!=deviceSettings.constEnd())
  13347. {
  13348. settingsObject.setProperty(i.key(),i.value().toString());
  13349. i++;
  13350. }
  13351. object.setProperty("settings",settingsObject);
  13352. /*:921*/
  13353. #line 375 "./unsupportedserial.w"
  13354. /*922:*/
  13355. #line 405 "./unsupportedserial.w"
  13356. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13357. for(int i= 0;i<channelCount();i++)
  13358. {
  13359. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13360. QScriptValue channelSettingsObject= scriptengine->newObject();
  13361. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13362. while(j!=channelSettings.at(i).constEnd())
  13363. {
  13364. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13365. j++;
  13366. }
  13367. channelObject.setProperty("settings",channelSettingsObject);
  13368. channelsArray.setProperty(i,channelObject);
  13369. }
  13370. object.setProperty("channels",channelsArray);
  13371. /*:922*/
  13372. #line 376 "./unsupportedserial.w"
  13373. QScriptContext*context= scriptengine->currentContext();
  13374. QScriptValue oldThis= context->thisObject();
  13375. context->setThisObject(object);
  13376. QScriptValue result= scriptengine->evaluate(deviceScript);
  13377. QScriptEngine*engine= scriptengine;
  13378. /*195:*/
  13379. #line 4494 "./typica.w"
  13380. if(engine->hasUncaughtException())
  13381. {
  13382. int line= engine->uncaughtExceptionLineNumber();
  13383. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13384. result.toString();
  13385. QString trace;
  13386. foreach(trace,engine->uncaughtExceptionBacktrace())
  13387. {
  13388. qDebug()<<trace;
  13389. }
  13390. }
  13391. /*:195*/
  13392. #line 382 "./unsupportedserial.w"
  13393. context->setThisObject(oldThis);
  13394. }
  13395. /*:920*//*925:*/
  13396. #line 446 "./unsupportedserial.w"
  13397. void JavaScriptDevice::stop()
  13398. {
  13399. emit deviceStopRequested();
  13400. }
  13401. /*:925*//*926:*/
  13402. #line 459 "./unsupportedserial.w"
  13403. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13404. QScriptEngine*engine):
  13405. QObject(NULL),scriptengine(engine)
  13406. {
  13407. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13408. QDomElement deviceReferenceElement=
  13409. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13410. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13411. QDomElement node;
  13412. QStringList deviceKeys;
  13413. QStringList deviceValues;
  13414. for(int i= 0;i<deviceConfigData.size();i++)
  13415. {
  13416. node= deviceConfigData.at(i).toElement();
  13417. if(node.attribute("name")=="keys")
  13418. {
  13419. QString data= node.attribute("value");
  13420. if(data.length()> 3)
  13421. {
  13422. data.chop(2);
  13423. data= data.remove(0,2);
  13424. }
  13425. deviceKeys= data.split(", ");
  13426. }
  13427. else if(node.attribute("name")=="values")
  13428. {
  13429. QString data= node.attribute("value");
  13430. if(data.length()> 3)
  13431. {
  13432. data.chop(2);
  13433. data= data.remove(0,2);
  13434. }
  13435. deviceValues= data.split(", ");
  13436. }
  13437. else if(node.attribute("name")=="script")
  13438. {
  13439. deviceScript= node.attribute("value");
  13440. }
  13441. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13442. }
  13443. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13444. {
  13445. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13446. }
  13447. if(model->hasChildren(index))
  13448. {
  13449. for(int i= 0;i<model->rowCount(index);i++)
  13450. {
  13451. QModelIndex channelIndex= model->index(i,0,index);
  13452. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13453. channelList.append(new Channel);
  13454. QDomElement channelReferenceElement=
  13455. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13456. QDomNodeList channelConfigData=
  13457. channelReferenceElement.elementsByTagName("attribute");
  13458. QStringList channelKeys;
  13459. QStringList channelValues;
  13460. for(int j= 0;j<channelConfigData.size();j++)
  13461. {
  13462. node= channelConfigData.at(j).toElement();
  13463. if(node.attribute("name")=="keys")
  13464. {
  13465. QString data= node.attribute("value");
  13466. if(data.length()> 3)
  13467. {
  13468. data.chop(2);
  13469. data= data.remove(0,2);
  13470. }
  13471. channelKeys= data.split(", ");
  13472. }
  13473. else if(node.attribute("name")=="values")
  13474. {
  13475. QString data= node.attribute("value");
  13476. if(data.length()> 3)
  13477. {
  13478. data.chop(2);
  13479. data= data.remove(0,2);
  13480. }
  13481. channelValues= data.split(", ");
  13482. }
  13483. else if(node.attribute("name")=="hidden")
  13484. {
  13485. hiddenState.append(node.attribute("value")=="true");
  13486. }
  13487. else if(node.attribute("name")=="columnname")
  13488. {
  13489. columnNames.append(node.attribute("value"));
  13490. }
  13491. }
  13492. QVariantMap cs;
  13493. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13494. {
  13495. cs.insert(channelKeys[j],channelValues[j]);
  13496. }
  13497. channelSettings.append(cs);
  13498. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13499. channelUnits.append(Units::Fahrenheit);
  13500. }
  13501. }
  13502. }
  13503. /*:926*//*927:*/
  13504. #line 564 "./unsupportedserial.w"
  13505. int JavaScriptDevice::channelCount()
  13506. {
  13507. return channelList.length();
  13508. }
  13509. Channel*JavaScriptDevice::getChannel(int channel)
  13510. {
  13511. return channelList.at(channel);
  13512. }
  13513. bool JavaScriptDevice::isChannelHidden(int channel)
  13514. {
  13515. return hiddenState.at(channel);
  13516. }
  13517. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13518. {
  13519. return channelUnits.at(channel);
  13520. }
  13521. QString JavaScriptDevice::channelColumnName(int channel)
  13522. {
  13523. if(channel>=0&&channel<columnNames.length())
  13524. {
  13525. return columnNames.at(channel);
  13526. }
  13527. return QString();
  13528. }
  13529. QString JavaScriptDevice::channelIndicatorText(int channel)
  13530. {
  13531. return indicatorTexts.at(channel);
  13532. }
  13533. /*:927*//*928:*/
  13534. #line 601 "./unsupportedserial.w"
  13535. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13536. {
  13537. annotationTemperatureColumn= tcol;
  13538. }
  13539. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13540. {
  13541. annotationNoteColumn= ncol;
  13542. }
  13543. /*:928*/
  13544. #line 641 "./unsupportedserial.w"
  13545. /*:932*//*955:*/
  13546. #line 444 "./phidgets.w"
  13547. /*939:*/
  13548. #line 31 "./phidgets.w"
  13549. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13550. const QModelIndex&index)
  13551. :BasicDeviceConfigurationWidget(model,index)
  13552. {
  13553. QFormLayout*layout= new QFormLayout;
  13554. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13555. QSpinBox*sampleRate= new QSpinBox;
  13556. sampleRate->setMinimum(40);
  13557. sampleRate->setMaximum(600);
  13558. sampleRate->setSingleStep(40);
  13559. sampleRate->setValue(360);
  13560. /*799:*/
  13561. #line 16530 "./typica.w"
  13562. QDomElement referenceElement=
  13563. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13564. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13565. QDomElement node;
  13566. /*:799*/
  13567. #line 44 "./phidgets.w"
  13568. for(int i= 0;i<configData.size();i++)
  13569. {
  13570. node= configData.at(i).toElement();
  13571. if(node.attribute("name")=="sampleRate")
  13572. {
  13573. sampleRate->setValue(node.attribute("value").toInt());
  13574. }
  13575. }
  13576. updateRate(sampleRate->value());
  13577. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13578. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13579. layout->addRow(addChannelButton);
  13580. layout->addRow(tr("Sample rate:"),sampleRate);
  13581. setLayout(layout);
  13582. }
  13583. /*:939*//*940:*/
  13584. #line 66 "./phidgets.w"
  13585. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13586. {
  13587. insertChildNode(tr("Channel"),"phidgets1048channel");
  13588. }
  13589. /*:940*//*941:*/
  13590. #line 74 "./phidgets.w"
  13591. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13592. {
  13593. updateAttribute("sampleRate",QString("%1").arg(ms));
  13594. }
  13595. /*:941*//*943:*/
  13596. #line 103 "./phidgets.w"
  13597. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13598. DeviceTreeModel*model,const QModelIndex&index)
  13599. :BasicDeviceConfigurationWidget(model,index),
  13600. tcType(new QComboBox)
  13601. {
  13602. QFormLayout*layout= new QFormLayout;
  13603. QLineEdit*columnName= new QLineEdit;
  13604. layout->addRow(tr("Column Name:"),columnName);
  13605. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13606. layout->addRow(hideSeries);
  13607. layout->addRow(tr("Thermocouple Type:"),tcType);
  13608. tcType->addItem("Type K","1");
  13609. tcType->addItem("Type J","2");
  13610. tcType->addItem("Type E","3");
  13611. tcType->addItem("Type T","4");
  13612. QSpinBox*channel= new QSpinBox;
  13613. layout->addRow(tr("Channel:"),channel);
  13614. channel->setMinimum(0);
  13615. channel->setMaximum(3);
  13616. setLayout(layout);
  13617. /*799:*/
  13618. #line 16530 "./typica.w"
  13619. QDomElement referenceElement=
  13620. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13621. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13622. QDomElement node;
  13623. /*:799*/
  13624. #line 124 "./phidgets.w"
  13625. for(int i= 0;i<configData.size();i++)
  13626. {
  13627. node= configData.at(i).toElement();
  13628. if(node.attribute("name")=="columnname")
  13629. {
  13630. columnName->setText(node.attribute("value"));
  13631. }
  13632. else if(node.attribute("name")=="hidden")
  13633. {
  13634. hideSeries->setChecked(node.attribute("value")=="true");
  13635. }
  13636. else if(node.attribute("name")=="tctype")
  13637. {
  13638. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  13639. }
  13640. else if(node.attribute("name")=="channel")
  13641. {
  13642. channel->setValue(node.attribute("value").toInt());
  13643. }
  13644. }
  13645. updateColumnName(columnName->text());
  13646. updateHidden(hideSeries->isChecked());
  13647. updateTC(tcType->currentIndex());
  13648. updateChannel(channel->value());
  13649. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13650. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13651. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  13652. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  13653. }
  13654. /*:943*//*944:*/
  13655. #line 157 "./phidgets.w"
  13656. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  13657. {
  13658. updateAttribute("columnname",value);
  13659. }
  13660. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  13661. {
  13662. updateAttribute("hidden",hidden?"true":"false");
  13663. }
  13664. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  13665. {
  13666. updateAttribute("tctype",tcType->itemData(index).toString());
  13667. }
  13668. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  13669. {
  13670. updateAttribute("channel",QString("%1").arg(channel));
  13671. }
  13672. /*:944*//*948:*/
  13673. #line 246 "./phidgets.w"
  13674. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  13675. :QObject(NULL),driver("phidget21"),device(NULL)
  13676. {
  13677. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13678. QDomElement deviceReferenceElement=
  13679. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13680. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13681. QDomElement node;
  13682. for(int i= 0;i<deviceConfigData.size();i++)
  13683. {
  13684. node= deviceConfigData.at(i).toElement();
  13685. if(node.attribute("name")=="sampleRate")
  13686. {
  13687. sampleTimer.setInterval(node.attribute("value").toInt());
  13688. }
  13689. }
  13690. if(model->hasChildren(index))
  13691. {
  13692. for(int i= 0;i<model->rowCount(index);i++)
  13693. {
  13694. QModelIndex channelIndex= model->index(i,0,index);
  13695. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13696. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13697. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  13698. for(int j= 0;j<channelConfigData.size();j++)
  13699. {
  13700. node= channelConfigData.at(j).toElement();
  13701. if(node.attribute("name")=="channel")
  13702. {
  13703. int channelID= node.attribute("value").toInt();
  13704. channelIndices.append(channelID);
  13705. Channel*channel= new Channel;
  13706. channelList.append(channel);
  13707. channelMap.insert(channelID,channel);
  13708. }
  13709. else if(node.attribute("name")=="hidden")
  13710. {
  13711. hiddenState.append(node.attribute("value")=="true");
  13712. }
  13713. else if(node.attribute("name")=="columnname")
  13714. {
  13715. columnNames.append(node.attribute("value"));
  13716. }
  13717. else if(node.attribute("name")=="tctype")
  13718. {
  13719. tctypes.append(node.attribute("value").toInt());
  13720. }
  13721. }
  13722. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13723. }
  13724. }
  13725. }
  13726. /*:948*//*949:*/
  13727. #line 306 "./phidgets.w"
  13728. int PhidgetsTemperatureSensor::channelCount()
  13729. {
  13730. return channelList.length();
  13731. }
  13732. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  13733. {
  13734. return channelList.at(channel);
  13735. }
  13736. /*:949*//*950:*/
  13737. #line 319 "./phidgets.w"
  13738. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  13739. {
  13740. return hiddenState.at(channel);
  13741. }
  13742. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  13743. {
  13744. if(channel>=0&&channel<columnNames.length())
  13745. {
  13746. return columnNames.at(channel);
  13747. }
  13748. return QString();
  13749. }
  13750. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  13751. {
  13752. if(channel>=0&&channel<indicatorTexts.length())
  13753. {
  13754. return indicatorTexts.at(channel);
  13755. }
  13756. return QString();
  13757. }
  13758. /*:950*//*952:*/
  13759. #line 371 "./phidgets.w"
  13760. void PhidgetsTemperatureSensor::start()
  13761. {
  13762. if(!driver.load())
  13763. {
  13764. driver.setFileName("Phidget21.framework/Phidget21");
  13765. if(!driver.load())
  13766. {
  13767. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  13768. tr("Failed to find phidget21. Please install it."));
  13769. return;
  13770. }
  13771. }
  13772. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  13773. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  13774. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  13775. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  13776. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  13777. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  13778. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  13779. {
  13780. QMessageBox::critical(NULL,tr("Typica: Link error"),
  13781. tr("Failed to link a required symbol in phidget21."));
  13782. return;
  13783. }
  13784. createDevice(&device);
  13785. openDevice(device,-1);
  13786. int error;
  13787. if((error= waitForOpen(device,10000)))
  13788. {
  13789. closeDevice(device);
  13790. deleteDevice(device);
  13791. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  13792. tr("CPhidget_waitForAttachment returns error %n",0,error));
  13793. return;
  13794. }
  13795. for(int i= 0;i<channelIndices.length();i++)
  13796. {
  13797. setTCType(device,channelIndices.at(i),tctypes.at(i));
  13798. }
  13799. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  13800. sampleTimer.start();
  13801. }
  13802. /*:952*//*953:*/
  13803. #line 418 "./phidgets.w"
  13804. void PhidgetsTemperatureSensor::getMeasurements()
  13805. {
  13806. double value= 0.0;
  13807. QTime time= QTime::currentTime();
  13808. foreach(int i,channelIndices)
  13809. {
  13810. getTemperature(device,i,&value);
  13811. Measurement measure(value*9.0/5.0+32.0,time);
  13812. channelMap[i]->input(measure);
  13813. }
  13814. }
  13815. /*:953*//*954:*/
  13816. #line 433 "./phidgets.w"
  13817. void PhidgetsTemperatureSensor::stop()
  13818. {
  13819. sampleTimer.stop();
  13820. closeDevice(device);
  13821. deleteDevice(device);
  13822. driver.unload();
  13823. }
  13824. /*:954*/
  13825. #line 445 "./phidgets.w"
  13826. /*:955*//*969:*/
  13827. #line 19726 "./typica.w"
  13828. /*967:*/
  13829. #line 19688 "./typica.w"
  13830. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  13831. const QModelIndex&index)
  13832. :BasicDeviceConfigurationWidget(model,index)
  13833. {
  13834. QHBoxLayout*layout= new QHBoxLayout;
  13835. QLabel*label= new QLabel(tr("Cooling Time: "));
  13836. QTimeEdit*editor= new QTimeEdit;
  13837. editor->setDisplayFormat("mm:ss");
  13838. /*799:*/
  13839. #line 16530 "./typica.w"
  13840. QDomElement referenceElement=
  13841. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13842. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13843. QDomElement node;
  13844. /*:799*/
  13845. #line 19697 "./typica.w"
  13846. for(int i= 0;i<configData.size();i++)
  13847. {
  13848. node= configData.at(i).toElement();
  13849. if(node.attribute("name")=="reset")
  13850. {
  13851. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  13852. }
  13853. }
  13854. updateResetTime(editor->time());
  13855. connect(editor,SIGNAL(timeChanged(QTime)),
  13856. this,SLOT(updateResetTime(QTime)));
  13857. layout->addWidget(label);
  13858. layout->addWidget(editor);
  13859. setLayout(layout);
  13860. }
  13861. void CoolingTimerConfWidget::updateResetTime(QTime time)
  13862. {
  13863. updateAttribute("reset",time.toString("mm:ss"));
  13864. }
  13865. /*:967*/
  13866. #line 19727 "./typica.w"
  13867. /*:969*//*974:*/
  13868. #line 19985 "./typica.w"
  13869. /*971:*/
  13870. #line 19759 "./typica.w"
  13871. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13872. :BasicDeviceConfigurationWidget(model,index)
  13873. {
  13874. QVBoxLayout*layout= new QVBoxLayout;
  13875. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  13876. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  13877. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  13878. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  13879. QButtonGroup*startOptionGroup= new QButtonGroup;
  13880. startOptionGroup->addButton(startBatchOption,1);
  13881. startOptionGroup->addButton(buttonOption,2);
  13882. startOptionGroup->addButton(thresholdOption,3);
  13883. startBatchOption->setChecked(true);
  13884. QGridLayout*startOptions= new QGridLayout;
  13885. startOptions->addWidget(startBatchOption,0,0);
  13886. startOptions->addWidget(buttonOption,1,0);
  13887. startOptions->addWidget(thresholdOption,2,0);
  13888. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  13889. QLineEdit*buttonTextEdit= new QLineEdit;
  13890. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  13891. buttonTextOptions->addWidget(buttonTextLabel);
  13892. buttonTextOptions->addWidget(buttonTextEdit);
  13893. startOptions->addLayout(buttonTextOptions,1,1);
  13894. QFormLayout*thresholdOptions= new QFormLayout;
  13895. QLineEdit*startColumnName= new QLineEdit;
  13896. QLineEdit*startValue= new QLineEdit;
  13897. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  13898. thresholdOptions->addRow(tr("Value: "),startValue);
  13899. startOptions->addLayout(thresholdOptions,2,1);
  13900. startConfigurationGroup->setLayout(startOptions);
  13901. layout->addWidget(startConfigurationGroup);
  13902. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  13903. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  13904. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  13905. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  13906. QButtonGroup*stopOptionGroup= new QButtonGroup;
  13907. stopOptionGroup->addButton(stopBatchOption,1);
  13908. stopOptionGroup->addButton(stopButtonOption,2);
  13909. stopOptionGroup->addButton(stopThresholdOption,3);
  13910. stopBatchOption->setChecked(true);
  13911. QGridLayout*stopOptions= new QGridLayout;
  13912. stopOptions->addWidget(stopBatchOption,0,0);
  13913. stopOptions->addWidget(stopButtonOption,1,0);
  13914. stopOptions->addWidget(stopThresholdOption,2,0);
  13915. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  13916. QLineEdit*stopButtonEdit= new QLineEdit;
  13917. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  13918. stopButtonTextOptions->addWidget(stopButtonLabel);
  13919. stopButtonTextOptions->addWidget(stopButtonEdit);
  13920. stopOptions->addLayout(stopButtonTextOptions,1,1);
  13921. QLineEdit*stopColumnName= new QLineEdit;
  13922. QLineEdit*stopValue= new QLineEdit;
  13923. QFormLayout*stopThresholdOptions= new QFormLayout;
  13924. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  13925. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  13926. stopOptions->addLayout(stopThresholdOptions,2,1);
  13927. stopConfigurationGroup->setLayout(stopOptions);
  13928. layout->addWidget(stopConfigurationGroup);
  13929. /*799:*/
  13930. #line 16530 "./typica.w"
  13931. QDomElement referenceElement=
  13932. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13933. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13934. QDomElement node;
  13935. /*:799*/
  13936. #line 19821 "./typica.w"
  13937. for(int i= 0;i<configData.size();i++)
  13938. {
  13939. node= configData.at(i).toElement();
  13940. if(node.attribute("name")=="startbuttontext")
  13941. {
  13942. buttonTextEdit->setText(node.attribute("value"));
  13943. }
  13944. else if(node.attribute("name")=="stopbuttontext")
  13945. {
  13946. stopButtonEdit->setText(node.attribute("value"));
  13947. }
  13948. else if(node.attribute("name")=="startcolumnname")
  13949. {
  13950. startColumnName->setText(node.attribute("value"));
  13951. }
  13952. else if(node.attribute("name")=="stopcolumnname")
  13953. {
  13954. stopColumnName->setText(node.attribute("value"));
  13955. }
  13956. else if(node.attribute("name")=="startvalue")
  13957. {
  13958. startValue->setText(node.attribute("value"));
  13959. }
  13960. else if(node.attribute("name")=="stopvalue")
  13961. {
  13962. stopValue->setText(node.attribute("value"));
  13963. }
  13964. else if(node.attribute("name")=="starttrigger")
  13965. {
  13966. if(node.attribute("value")=="batch")
  13967. {
  13968. startBatchOption->setChecked(true);
  13969. }
  13970. else if(node.attribute("value")=="manual")
  13971. {
  13972. buttonOption->setChecked(true);
  13973. }
  13974. else if(node.attribute("value")=="value")
  13975. {
  13976. thresholdOption->setChecked(true);
  13977. }
  13978. }
  13979. else if(node.attribute("name")=="stoptrigger")
  13980. {
  13981. if(node.attribute("value")=="batch")
  13982. {
  13983. stopBatchOption->setChecked(true);
  13984. }
  13985. else if(node.attribute("value")=="manual")
  13986. {
  13987. stopButtonOption->setChecked(true);
  13988. }
  13989. else if(node.attribute("value")=="value")
  13990. {
  13991. stopThresholdOption->setChecked(true);
  13992. }
  13993. }
  13994. }
  13995. updateStartButtonText(buttonTextEdit->text());
  13996. updateStopButtonText(stopButtonEdit->text());
  13997. updateStartColumnName(startColumnName->text());
  13998. updateStopColumnName(stopColumnName->text());
  13999. updateStartValue(startValue->text());
  14000. updateStopValue(stopValue->text());
  14001. updateStartTrigger(startOptionGroup->checkedId());
  14002. updateStopTrigger(stopOptionGroup->checkedId());
  14003. setLayout(layout);
  14004. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  14005. this,SLOT(updateStartButtonText(QString)));
  14006. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  14007. this,SLOT(updateStopButtonText(QString)));
  14008. connect(startColumnName,SIGNAL(textChanged(QString)),
  14009. this,SLOT(updateStartColumnName(QString)));
  14010. connect(stopColumnName,SIGNAL(textChanged(QString)),
  14011. this,SLOT(updateStopColumnName(QString)));
  14012. connect(startValue,SIGNAL(textChanged(QString)),
  14013. this,SLOT(updateStartValue(QString)));
  14014. connect(stopValue,SIGNAL(textChanged(QString)),
  14015. this,SLOT(updateStopValue(QString)));
  14016. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  14017. this,SLOT(updateStartTrigger(int)));
  14018. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  14019. this,SLOT(updateStopTrigger(int)));
  14020. }
  14021. /*:971*//*972:*/
  14022. #line 19911 "./typica.w"
  14023. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  14024. {
  14025. updateAttribute("startbuttontext",text);
  14026. }
  14027. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  14028. {
  14029. updateAttribute("stopbuttontext",text);
  14030. }
  14031. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  14032. {
  14033. updateAttribute("startcolumnname",text);
  14034. }
  14035. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  14036. {
  14037. updateAttribute("stopcolumnname",text);
  14038. }
  14039. void RangeTimerConfWidget::updateStartValue(const QString&text)
  14040. {
  14041. updateAttribute("startvalue",text);
  14042. }
  14043. void RangeTimerConfWidget::updateStopValue(const QString&text)
  14044. {
  14045. updateAttribute("stopvalue",text);
  14046. }
  14047. void RangeTimerConfWidget::updateStartTrigger(int option)
  14048. {
  14049. switch(option)
  14050. {
  14051. case 1:
  14052. updateAttribute("starttrigger","batch");
  14053. break;
  14054. case 2:
  14055. updateAttribute("starttrigger","manual");
  14056. break;
  14057. case 3:
  14058. updateAttribute("starttrigger","value");
  14059. break;
  14060. default:
  14061. break;
  14062. }
  14063. }
  14064. void RangeTimerConfWidget::updateStopTrigger(int option)
  14065. {
  14066. switch(option)
  14067. {
  14068. case 1:
  14069. updateAttribute("stoptrigger","batch");
  14070. break;
  14071. case 2:
  14072. updateAttribute("stoptrigger","manual");
  14073. break;
  14074. case 3:
  14075. updateAttribute("stoptrigger","value");
  14076. break;
  14077. default:
  14078. break;
  14079. }
  14080. }
  14081. /*:972*/
  14082. #line 19986 "./typica.w"
  14083. /*:974*//*979:*/
  14084. #line 20086 "./typica.w"
  14085. /*976:*/
  14086. #line 20010 "./typica.w"
  14087. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  14088. const QModelIndex&index)
  14089. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  14090. {
  14091. QFormLayout*layout= new QFormLayout;
  14092. QLineEdit*trigger= new QLineEdit;
  14093. layout->addRow(tr("Trigger column name:"),trigger);
  14094. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  14095. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  14096. QTableView*rangeTable= new QTableView;
  14097. rangeTable->setModel(tablemodel);
  14098. layout->addRow(tr("Range data:"),rangeTable);
  14099. /*799:*/
  14100. #line 16530 "./typica.w"
  14101. QDomElement referenceElement=
  14102. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14103. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14104. QDomElement node;
  14105. /*:799*/
  14106. #line 20023 "./typica.w"
  14107. for(int i= 0;i<configData.size();i++)
  14108. {
  14109. node= configData.at(i).toElement();
  14110. if(node.attribute("name")=="trigger")
  14111. {
  14112. trigger->setText(node.attribute("value"));
  14113. }
  14114. else if(node.attribute("name")=="rangenames")
  14115. {
  14116. QString data= node.attribute("value");
  14117. if(data.length()> 3)
  14118. {
  14119. data.chop(2);
  14120. data= data.remove(0,2);
  14121. }
  14122. QStringList itemList= data.split(", ");
  14123. for(int j= 0;j<itemList.size();j++)
  14124. {
  14125. QString item= itemList.at(j);
  14126. item.chop(1);
  14127. item= item.remove(0,1);
  14128. tablemodel->setData(tablemodel->index(j,0),
  14129. QVariant(item),Qt::DisplayRole);
  14130. }
  14131. }
  14132. else if(node.attribute("name")=="endtemps")
  14133. {
  14134. /*962:*/
  14135. #line 19618 "./typica.w"
  14136. QString data= node.attribute("value");
  14137. if(data.length()> 3)
  14138. {
  14139. data.chop(2);
  14140. data= data.remove(0,2);
  14141. }
  14142. QStringList itemList= data.split(",");
  14143. /*:962*/
  14144. #line 20051 "./typica.w"
  14145. int column= 1;
  14146. /*963:*/
  14147. #line 19630 "./typica.w"
  14148. for(int j= 0;j<itemList.size();j++)
  14149. {
  14150. tablemodel->setData(tablemodel->index(j,column),
  14151. QVariant(itemList.at(j).toDouble()),
  14152. Qt::DisplayRole);
  14153. }
  14154. /*:963*/
  14155. #line 20053 "./typica.w"
  14156. }
  14157. }
  14158. updateColumnName(trigger->text());
  14159. updateRangeData();
  14160. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  14161. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  14162. setLayout(layout);
  14163. }
  14164. /*:976*//*977:*/
  14165. #line 20067 "./typica.w"
  14166. void MultiRangeTimerConfWidget::updateRangeData()
  14167. {
  14168. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  14169. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  14170. }
  14171. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  14172. {
  14173. updateAttribute("trigger",text);
  14174. }
  14175. /*:977*/
  14176. #line 20087 "./typica.w"
  14177. /*:979*//*997:*/
  14178. #line 265 "./rate.w"
  14179. /*993:*/
  14180. #line 191 "./rate.w"
  14181. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14182. :BasicDeviceConfigurationWidget(model,index)
  14183. {
  14184. QFormLayout*layout= new QFormLayout;
  14185. QLineEdit*column= new QLineEdit;
  14186. layout->addRow(tr("Primary series column name:"),column);
  14187. QSpinBox*cacheTime= new QSpinBox;
  14188. cacheTime->setMinimum(0);
  14189. cacheTime->setMaximum(300);
  14190. layout->addRow(tr("Cache time:"),cacheTime);
  14191. QSpinBox*scaleTime= new QSpinBox;
  14192. scaleTime->setMinimum(1);
  14193. scaleTime->setMaximum(300);
  14194. layout->addRow(tr("Scale time:"),scaleTime);
  14195. /*799:*/
  14196. #line 16530 "./typica.w"
  14197. QDomElement referenceElement=
  14198. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14199. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14200. QDomElement node;
  14201. /*:799*/
  14202. #line 206 "./rate.w"
  14203. for(int i= 0;i<configData.size();i++)
  14204. {
  14205. node= configData.at(i).toElement();
  14206. if(node.attribute("name")=="column")
  14207. {
  14208. column->setText(node.attribute("value"));
  14209. }
  14210. else if(node.attribute("name")=="cache")
  14211. {
  14212. cacheTime->setValue(node.attribute("value").toInt());
  14213. }
  14214. else if(node.attribute("name")=="scale")
  14215. {
  14216. scaleTime->setValue(node.attribute("value").toInt());
  14217. }
  14218. }
  14219. updateColumn(column->text());
  14220. updateCacheTime(cacheTime->text());
  14221. updateScaleTime(scaleTime->text());
  14222. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  14223. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  14224. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  14225. setLayout(layout);
  14226. }
  14227. /*:993*//*994:*/
  14228. #line 235 "./rate.w"
  14229. void RateOfChangeConfWidget::updateColumn(const QString&column)
  14230. {
  14231. updateAttribute("column",column);
  14232. }
  14233. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  14234. {
  14235. updateAttribute("cache",seconds);
  14236. }
  14237. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  14238. {
  14239. updateAttribute("scale",seconds);
  14240. }
  14241. /*:994*/
  14242. #line 266 "./rate.w"
  14243. #line 20194 "./typica.w"
  14244. #line 1 "./dataqsdk.w"
  14245. /*:997*/
  14246. #line 529 "./typica.w"
  14247. /*8:*/
  14248. #line 675 "./typica.w"
  14249. template<class TYPE> TYPE getself(QScriptContext*context)
  14250. {
  14251. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  14252. return self;
  14253. }
  14254. template<> QTime getself(QScriptContext*context)
  14255. {
  14256. QTime self= context->thisObject().toVariant().toTime();
  14257. return self;
  14258. }
  14259. template<> QByteArray getself(QScriptContext*context)
  14260. {
  14261. QByteArray self= context->thisObject().toVariant().toByteArray();
  14262. return self;
  14263. }
  14264. template<> SqlQueryConnection*getself(QScriptContext*context)
  14265. {
  14266. SqlQueryConnection*self=
  14267. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  14268. return self;
  14269. }
  14270. template<> QXmlQuery*getself(QScriptContext*context)
  14271. {
  14272. QXmlQuery*self=
  14273. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  14274. return self;
  14275. }
  14276. template<> QXmlStreamWriter*getself(QScriptContext*context)
  14277. {
  14278. QXmlStreamWriter*self=
  14279. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  14280. return self;
  14281. }
  14282. template<> QXmlStreamReader*getself(QScriptContext*context)
  14283. {
  14284. QXmlStreamReader*self=
  14285. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  14286. return self;
  14287. }
  14288. /*:8*//*9:*/
  14289. #line 726 "./typica.w"
  14290. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  14291. {
  14292. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  14293. return argument;
  14294. }
  14295. template<> QString argument(int arg,QScriptContext*context)
  14296. {
  14297. return context->argument(arg).toString();
  14298. }
  14299. template<> QVariant argument(int arg,QScriptContext*context)
  14300. {
  14301. return context->argument(arg).toVariant();
  14302. }
  14303. template<> int argument(int arg,QScriptContext*context)
  14304. {
  14305. return context->argument(arg).toInt32();
  14306. }
  14307. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  14308. {
  14309. return(SqlQueryConnection*)
  14310. qscriptvalue_cast<void*> (context->argument(arg));
  14311. }
  14312. template<> QModelIndex argument(int arg,QScriptContext*context)
  14313. {
  14314. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  14315. }
  14316. template<> double argument(int arg,QScriptContext*context)
  14317. {
  14318. return(double)(context->argument(arg).toNumber());
  14319. }
  14320. template<> Units::Unit argument(int arg,QScriptContext*context)
  14321. {
  14322. return(Units::Unit)(context->argument(arg).toInt32());
  14323. }
  14324. template<> QByteArray argument(int arg,QScriptContext*context)
  14325. {
  14326. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  14327. }
  14328. /*:9*//*13:*/
  14329. #line 820 "./typica.w"
  14330. void setQObjectProperties(QScriptValue value,QScriptEngine*engine)
  14331. {
  14332. value.setProperty("setProperty",engine->newFunction(QObject_setProperty));
  14333. }
  14334. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*)
  14335. {
  14336. QObject*self= getself<QObject*> (context);
  14337. self->setProperty(argument<QString> (0,context).toUtf8().constData(),
  14338. argument<QVariant> (1,context));
  14339. return QScriptValue();
  14340. }
  14341. /*:13*//*15:*/
  14342. #line 842 "./typica.w"
  14343. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  14344. {
  14345. }
  14346. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  14347. {
  14348. }
  14349. /*:15*//*18:*/
  14350. #line 874 "./typica.w"
  14351. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  14352. {
  14353. setQObjectProperties(value,engine);
  14354. }
  14355. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  14356. {
  14357. QScriptValue object= engine->newQObject(new QTimer);
  14358. setQTimerProperties(object,engine);
  14359. return object;
  14360. }
  14361. /*:18*//*21:*/
  14362. #line 916 "./typica.w"
  14363. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  14364. {
  14365. QScriptValue object= engine->newQObject(new QWidget);
  14366. setQWidgetProperties(object,engine);
  14367. return object;
  14368. }
  14369. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14370. {
  14371. setQObjectProperties(value,engine);
  14372. setQPaintDeviceProperties(value,engine);
  14373. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  14374. value.setProperty("activateWindow",
  14375. engine->newFunction(QWidget_activateWindow));
  14376. }
  14377. /*:21*//*22:*/
  14378. #line 938 "./typica.w"
  14379. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  14380. {
  14381. if(context->argumentCount()==1)
  14382. {
  14383. QWidget*self= getself<QWidget*> (context);
  14384. QLayout*layout= argument<QLayout*> (0,context);
  14385. if(layout)
  14386. {
  14387. self->setLayout(layout);
  14388. }
  14389. else
  14390. {
  14391. context->throwError("Incorrect argument type passed to "
  14392. "QWidget::setLayout(). This method requires "
  14393. "a QLayout.");
  14394. }
  14395. }
  14396. else
  14397. {
  14398. context->throwError("Incorrect number of arguments passed to "
  14399. "QWidget::setLayout(). This method takes one "
  14400. "QLayout as an argument.");
  14401. }
  14402. return QScriptValue();
  14403. }
  14404. QScriptValue QWidget_activateWindow(QScriptContext*context,
  14405. QScriptEngine*)
  14406. {
  14407. QWidget*self= getself<QWidget*> (context);
  14408. self->activateWindow();
  14409. return QScriptValue();
  14410. }
  14411. /*:22*//*25:*/
  14412. #line 1000 "./typica.w"
  14413. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  14414. {
  14415. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  14416. argument<QString> (0,context),
  14417. argument<QString> (1,context),
  14418. QMessageBox::Ok|QMessageBox::Cancel);
  14419. if(selection==QMessageBox::Ok){
  14420. return QScriptValue(true);
  14421. }
  14422. return QScriptValue(false);
  14423. }
  14424. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  14425. {
  14426. QMessageBox::critical(NULL,argument<QString> (0,context),
  14427. argument<QString> (1,context));
  14428. return QScriptValue();
  14429. }
  14430. /*:25*//*27:*/
  14431. #line 1067 "./typica.w"
  14432. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  14433. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  14434. {
  14435. }
  14436. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  14437. {
  14438. QSettings settings;
  14439. settings.beginGroup(key);
  14440. settings.setValue("pos",pos());
  14441. settings.setValue("size",size());
  14442. settings.endGroup();
  14443. }
  14444. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  14445. {
  14446. QSettings settings;
  14447. settings.beginGroup(key);
  14448. if(settings.contains("size"))
  14449. {
  14450. resize(settings.value("size").toSize());
  14451. }
  14452. if(settings.contains("pos"))
  14453. {
  14454. move(settings.value("pos").toPoint());
  14455. }
  14456. settings.endGroup();
  14457. }
  14458. void ScriptQMainWindow::displayStatus(const QString&message)
  14459. {
  14460. statusBar()->showMessage(message);
  14461. }
  14462. void ScriptQMainWindow::showEvent(QShowEvent*event)
  14463. {
  14464. if(!event->spontaneous())
  14465. {
  14466. /*32:*/
  14467. #line 1179 "./typica.w"
  14468. QSettings settings;
  14469. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  14470. toByteArray());
  14471. /*:32*/
  14472. #line 1107 "./typica.w"
  14473. event->accept();
  14474. }
  14475. else
  14476. {
  14477. event->ignore();
  14478. }
  14479. }
  14480. void ScriptQMainWindow::show()
  14481. {
  14482. QMainWindow::show();
  14483. }
  14484. /*:27*//*28:*/
  14485. #line 1128 "./typica.w"
  14486. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  14487. {
  14488. if(isWindowModified()){
  14489. /*29:*/
  14490. #line 1142 "./typica.w"
  14491. QMessageBox::StandardButton result;
  14492. result= QMessageBox::warning(this,"Typica",closePrompt(),
  14493. QMessageBox::Ok|QMessageBox::Cancel);
  14494. if(result==QMessageBox::Cancel)
  14495. {
  14496. event->ignore();
  14497. return;
  14498. }
  14499. /*:29*/
  14500. #line 1132 "./typica.w"
  14501. }
  14502. emit aboutToClose();
  14503. /*31:*/
  14504. #line 1173 "./typica.w"
  14505. QSettings settings;
  14506. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  14507. /*:31*/
  14508. #line 1135 "./typica.w"
  14509. event->accept();
  14510. }
  14511. /*:28*//*30:*/
  14512. #line 1154 "./typica.w"
  14513. QString ScriptQMainWindow::closePrompt()
  14514. {
  14515. return cprompt;
  14516. }
  14517. void ScriptQMainWindow::setClosePrompt(QString prompt)
  14518. {
  14519. cprompt= prompt;
  14520. }
  14521. /*:30*//*35:*/
  14522. #line 1207 "./typica.w"
  14523. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  14524. {
  14525. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  14526. setQMainWindowProperties(object,engine);
  14527. return object;
  14528. }
  14529. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  14530. {
  14531. setQWidgetProperties(value,engine);
  14532. value.setProperty("setCentralWidget",
  14533. engine->newFunction(QMainWindow_setCentralWidget));
  14534. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  14535. }
  14536. /*:35*//*36:*/
  14537. #line 1229 "./typica.w"
  14538. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  14539. QScriptEngine*)
  14540. {
  14541. if(context->argumentCount()==1)
  14542. {
  14543. QMainWindow*self= getself<QMainWindow*> (context);
  14544. QWidget*widget= argument<QWidget*> (0,context);
  14545. if(widget)
  14546. {
  14547. self->setCentralWidget(widget);
  14548. }
  14549. else
  14550. {
  14551. context->throwError("Incorrect argument type passed to "
  14552. "QMainWindow::setCentralWidget(). This "
  14553. "method requires a QWidget.");
  14554. }
  14555. }
  14556. else
  14557. {
  14558. context->throwError("Incorrect number of arguments passed to "
  14559. "QMainWindow::setCentralWidget(). This method "
  14560. "takes one QWidget as an argument.");
  14561. }
  14562. return QScriptValue();
  14563. }
  14564. /*:36*//*37:*/
  14565. #line 1263 "./typica.w"
  14566. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  14567. {
  14568. QScriptValue object;
  14569. if(context->argumentCount()==0)
  14570. {
  14571. QMainWindow*self= getself<QMainWindow*> (context);
  14572. QMenuBar*bar= self->menuBar();
  14573. object= engine->newQObject(bar);
  14574. setQMenuBarProperties(object,engine);
  14575. }
  14576. else
  14577. {
  14578. context->throwError("Incorrect number of arguments passed to "
  14579. "QMainWindow::menuBar(). This method takes no "
  14580. "arguments.");
  14581. }
  14582. return object;
  14583. }
  14584. /*:37*//*39:*/
  14585. #line 1293 "./typica.w"
  14586. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  14587. {
  14588. setQWidgetProperties(value,engine);
  14589. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  14590. }
  14591. /*:39*//*40:*/
  14592. #line 1308 "./typica.w"
  14593. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  14594. {
  14595. QScriptValue object;
  14596. if(context->argumentCount()==1)
  14597. {
  14598. QMenuBar*self= getself<QMenuBar*> (context);
  14599. QString title= argument<QString> (0,context);
  14600. object= engine->newQObject(self->addMenu(title));
  14601. setQMenuProperties(object,engine);
  14602. }
  14603. else
  14604. {
  14605. context->throwError("Incorrect number of arguments passed to "
  14606. "QMenuBar::addMenu(). This method takes one "
  14607. "string as an argument.");
  14608. }
  14609. return object;
  14610. }
  14611. /*:40*//*42:*/
  14612. #line 1338 "./typica.w"
  14613. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  14614. {
  14615. setQWidgetProperties(value,engine);
  14616. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  14617. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  14618. }
  14619. /*:42*//*43:*/
  14620. #line 1348 "./typica.w"
  14621. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  14622. {
  14623. if(context->argumentCount()==1)
  14624. {
  14625. QMenu*self= getself<QMenu*> (context);
  14626. QAction*action= argument<QAction*> (0,context);
  14627. if(action)
  14628. {
  14629. self->addAction(action);
  14630. }
  14631. else
  14632. {
  14633. context->throwError("Incorrect argument type passed to "
  14634. "QMenu::addAction(). This method requires a "
  14635. "QAction.");
  14636. }
  14637. }
  14638. else
  14639. {
  14640. context->throwError("Incorrect number of arguments passed to "
  14641. "QMenu::addAction(). This method takes one "
  14642. "QAction as an argument.");
  14643. }
  14644. return QScriptValue();
  14645. }
  14646. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  14647. {
  14648. if(context->argumentCount()==0)
  14649. {
  14650. QMenu*self= getself<QMenu*> (context);
  14651. self->addSeparator();
  14652. }
  14653. else
  14654. {
  14655. context->throwError("Incorrect number of arguments passed to "
  14656. "QMenu::addSeparator(). This method takes no "
  14657. "arguments.");
  14658. }
  14659. return QScriptValue();
  14660. }
  14661. /*:43*//*46:*/
  14662. #line 1410 "./typica.w"
  14663. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  14664. {
  14665. QScriptValue object= engine->newQObject(new QFrame);
  14666. setQFrameProperties(object,engine);
  14667. return object;
  14668. }
  14669. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  14670. {
  14671. setQWidgetProperties(value,engine);
  14672. }
  14673. /*:46*//*49:*/
  14674. #line 1444 "./typica.w"
  14675. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  14676. {
  14677. QString text;
  14678. if(context->argumentCount()==1)
  14679. {
  14680. text= argument<QString> (0,context);
  14681. }
  14682. QScriptValue object= engine->newQObject(new QLabel(text));
  14683. setQLabelProperties(object,engine);
  14684. return object;
  14685. }
  14686. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  14687. {
  14688. setQFrameProperties(value,engine);
  14689. }
  14690. /*:49*//*52:*/
  14691. #line 1486 "./typica.w"
  14692. QScriptValue constructQSvgWidget(QScriptContext*,
  14693. QScriptEngine*engine)
  14694. {
  14695. QScriptValue object= engine->newQObject(new QSvgWidget);
  14696. setQSvgWidgetProperties(object,engine);
  14697. return object;
  14698. }
  14699. /*:52*//*53:*/
  14700. #line 1497 "./typica.w"
  14701. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14702. {
  14703. setQWidgetProperties(value,engine);
  14704. value.setProperty("loadDevice",
  14705. engine->newFunction(QSvgWidget_loadDevice));
  14706. }
  14707. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  14708. {
  14709. if(context->argumentCount()==1)
  14710. {
  14711. QSvgWidget*self= getself<QSvgWidget*> (context);
  14712. QIODevice*device= argument<QIODevice*> (0,context);
  14713. device->reset();
  14714. QByteArray data= device->readAll();
  14715. self->load(data);
  14716. }
  14717. else
  14718. {
  14719. context->throwError("Incorrect number of arguments passed to "
  14720. "QSvgWidget::loadData(). This method takes one "
  14721. "QIODevice as an argument.");
  14722. }
  14723. return QScriptValue();
  14724. }
  14725. /*:53*//*55:*/
  14726. #line 1535 "./typica.w"
  14727. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  14728. QStack<QLayout*> *layoutStack)
  14729. {
  14730. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14731. QSvgWidget*widget= new QSvgWidget;
  14732. layout->addWidget(widget);
  14733. QString id= element.attribute("id");
  14734. if(!id.isEmpty())
  14735. {
  14736. widget->setObjectName(id);
  14737. }
  14738. }
  14739. /*:55*//*58:*/
  14740. #line 1568 "./typica.w"
  14741. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  14742. {
  14743. QScriptValue object= engine->newQObject(new QLineEdit());
  14744. setQLineEditProperties(object,engine);
  14745. return object;
  14746. }
  14747. /*:58*//*59:*/
  14748. #line 1579 "./typica.w"
  14749. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  14750. {
  14751. setQWidgetProperties(value,engine);
  14752. }
  14753. /*:59*//*62:*/
  14754. #line 1615 "./typica.w"
  14755. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  14756. {
  14757. QScriptValue object= engine->newQObject(new QSplitter);
  14758. setQSplitterProperties(object,engine);
  14759. return object;
  14760. }
  14761. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  14762. {
  14763. setQFrameProperties(value,engine);
  14764. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  14765. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  14766. value.setProperty("restoreState",
  14767. engine->newFunction(QSplitter_restoreState));
  14768. value.setProperty("count",engine->newFunction(QSplitter_count));
  14769. }
  14770. /*:62*//*63:*/
  14771. #line 1636 "./typica.w"
  14772. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  14773. {
  14774. if(context->argumentCount()==1)
  14775. {
  14776. QSplitter*self= getself<QSplitter*> (context);
  14777. QWidget*widget= argument<QWidget*> (0,context);
  14778. if(widget)
  14779. {
  14780. self->addWidget(widget);
  14781. }
  14782. else
  14783. {
  14784. context->throwError("Incorrect argument type passed to "
  14785. "QSplitter::addWidget(). This method "
  14786. "requires a QWidget.");
  14787. }
  14788. }
  14789. else
  14790. {
  14791. context->throwError("Incorrect number of arguments passed to "
  14792. "QSplitter::addWidget(). This method takes one "
  14793. "QWidget as an argument.");
  14794. }
  14795. return QScriptValue();
  14796. }
  14797. /*:63*//*64:*/
  14798. #line 1673 "./typica.w"
  14799. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  14800. {
  14801. QSplitter*self= getself<QSplitter*> (context);
  14802. return QScriptValue(self->count());
  14803. }
  14804. /*:64*//*65:*/
  14805. #line 1686 "./typica.w"
  14806. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  14807. {
  14808. if(context->argumentCount()==1)
  14809. {
  14810. QSplitter*self= getself<QSplitter*> (context);
  14811. QString key= argument<QString> (0,context);
  14812. QSettings settings;
  14813. settings.setValue(key,self->saveState());
  14814. }
  14815. else
  14816. {
  14817. context->throwError("Incorrect number of arguments passed to "
  14818. "QSplitter::saveState(). This method takes one "
  14819. "string as an argument.");
  14820. }
  14821. return QScriptValue();
  14822. }
  14823. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  14824. {
  14825. if(context->argumentCount()==1)
  14826. {
  14827. QSplitter*self= getself<QSplitter*> (context);
  14828. QString key= argument<QString> (0,context);
  14829. QSettings settings;
  14830. self->restoreState(settings.value(key).toByteArray());
  14831. }
  14832. else
  14833. {
  14834. context->throwError("Incorrect number of arguments passed to "
  14835. "QSplitter::restoreState(). This method takes "
  14836. "one string as an argument.");
  14837. }
  14838. return QScriptValue();
  14839. }
  14840. /*:65*//*67:*/
  14841. #line 1739 "./typica.w"
  14842. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14843. {
  14844. setQLayoutItemProperties(value,engine);
  14845. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  14846. }
  14847. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14848. {
  14849. if(context->argumentCount()==1)
  14850. {
  14851. QLayout*self= getself<QLayout*> (context);
  14852. QWidget*widget= argument<QWidget*> (0,context);
  14853. if(widget)
  14854. {
  14855. self->addWidget(widget);
  14856. }
  14857. else
  14858. {
  14859. context->throwError("Incorrect argument type passed to "
  14860. "QLayout::addWidget(). This method requires "
  14861. "a QWidget.");
  14862. }
  14863. }
  14864. else
  14865. {
  14866. context->throwError("Incorrect number of arguments passed to "
  14867. "QLayout::addWidget(). This method takes one "
  14868. "QWidget as an argument.");
  14869. }
  14870. return QScriptValue();
  14871. }
  14872. /*:67*//*70:*/
  14873. #line 1806 "./typica.w"
  14874. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  14875. {
  14876. QScriptValue object=
  14877. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  14878. setQBoxLayoutProperties(object,engine);
  14879. return object;
  14880. }
  14881. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14882. {
  14883. setQLayoutProperties(value,engine);
  14884. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  14885. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  14886. }
  14887. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  14888. {
  14889. if(context->argumentCount()> 0&&context->argumentCount()<3)
  14890. {
  14891. QBoxLayout*self= getself<QBoxLayout*> (context);
  14892. QLayout*layout= argument<QLayout*> (0,context);
  14893. int stretch= 0;
  14894. if(context->argumentCount()==2)
  14895. {
  14896. stretch= argument<int> (1,context);
  14897. }
  14898. if(layout)
  14899. {
  14900. self->addLayout(layout,stretch);
  14901. }
  14902. else
  14903. {
  14904. context->throwError("Incorrect argument type passed to "
  14905. "QLayout::addLayout(). This method requires "
  14906. "a QLayout.");
  14907. }
  14908. }
  14909. else
  14910. {
  14911. context->throwError("Incorrect number of arguments passed to "
  14912. "QLayout::addLayout(). This method takes one "
  14913. "QLayout as an argument and optionally one integer.");
  14914. }
  14915. return QScriptValue();
  14916. }
  14917. /*:70*//*71:*/
  14918. #line 1857 "./typica.w"
  14919. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14920. {
  14921. if(context->argumentCount()> 0&&context->argumentCount()<4)
  14922. {
  14923. QBoxLayout*self= getself<QBoxLayout*> (context);
  14924. QWidget*widget= argument<QWidget*> (0,context);
  14925. int stretch= 0;
  14926. Qt::Alignment alignment= 0;
  14927. if(context->argumentCount()> 1)
  14928. {
  14929. stretch= argument<int> (1,context);
  14930. }
  14931. if(context->argumentCount()> 2)
  14932. {
  14933. alignment= (Qt::Alignment)(argument<int> (2,context));
  14934. }
  14935. if(widget)
  14936. {
  14937. self->addWidget(widget,stretch,alignment);
  14938. }
  14939. else
  14940. {
  14941. context->throwError("Incorrect argument type passed to "
  14942. "QBoxLayout::addWidget(). This method requires "
  14943. "a QWidget.");
  14944. }
  14945. }
  14946. else
  14947. {
  14948. context->throwError("Incorrect number of arguments passed to "
  14949. "QBoxLayout::addWidget(). This method takes one "
  14950. "QWidget and optionally up to two integers as "
  14951. "arguments.");
  14952. }
  14953. return QScriptValue();
  14954. }
  14955. /*:71*//*74:*/
  14956. #line 1921 "./typica.w"
  14957. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  14958. {
  14959. QScriptValue object= engine->newQObject(new QAction(NULL));
  14960. setQActionProperties(object,engine);
  14961. return object;
  14962. }
  14963. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  14964. {
  14965. setQObjectProperties(value,engine);
  14966. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  14967. }
  14968. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  14969. {
  14970. if(context->argumentCount()==1)
  14971. {
  14972. QAction*self= getself<QAction*> (context);
  14973. self->setShortcut(argument<QString> (0,context));
  14974. }
  14975. else
  14976. {
  14977. context->throwError("Incorrect number of arguments passed to "
  14978. "QAction::setShortcut(). This method takes one "
  14979. "string as an argument.");
  14980. }
  14981. return QScriptValue();
  14982. }
  14983. /*:74*//*77:*/
  14984. #line 1979 "./typica.w"
  14985. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  14986. QScriptEngine*engine)
  14987. {
  14988. QScriptValue retval;
  14989. if(context->argumentCount()==3)
  14990. {
  14991. QWidget*widget= argument<QWidget*> (0,context);
  14992. if(widget)
  14993. {
  14994. QString caption= argument<QString> (1,context);
  14995. QString dir= argument<QString> (2,context);
  14996. retval= QScriptValue(engine,
  14997. QFileDialog::getOpenFileName(widget,caption,
  14998. dir,"",0,0));
  14999. setQFileDialogProperties(retval,engine);
  15000. }
  15001. else
  15002. {
  15003. context->throwError("Incorrect argument type passed to "
  15004. "QFileDialog::getOpenFileName(). The first "
  15005. "argument to this method must be a QWidget.");
  15006. }
  15007. }
  15008. else
  15009. {
  15010. context->throwError("Incorrect number of arguments passed to "
  15011. "QFileDialog::getOpenFileName(). This method "
  15012. "takes one QWidget followed by two strings for a "
  15013. "total of three arguments.");
  15014. }
  15015. return retval;
  15016. }
  15017. /*:77*//*78:*/
  15018. #line 2015 "./typica.w"
  15019. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  15020. QScriptEngine*engine)
  15021. {
  15022. QScriptValue retval;
  15023. if(context->argumentCount()==3)
  15024. {
  15025. QWidget*widget= argument<QWidget*> (0,context);
  15026. if(widget)
  15027. {
  15028. QString caption= argument<QString> (1,context);
  15029. QString dir= argument<QString> (2,context);
  15030. retval= QScriptValue(engine,
  15031. QFileDialog::getSaveFileName(widget,caption,
  15032. dir,"",0,0));
  15033. setQFileDialogProperties(retval,engine);
  15034. }
  15035. else
  15036. {
  15037. context->throwError("Incorrect argument type passed to "
  15038. "QFileDialog::getSaveFileName(). The first "
  15039. "argument to this method must be a QWidget.");
  15040. }
  15041. }
  15042. else
  15043. {
  15044. context->throwError("Incorrect number of arguments passed to "
  15045. "QFileDialog::getSaveFileName(). This method "
  15046. "takes one QWidget followed by two strings for a "
  15047. "total of three arguments.");
  15048. }
  15049. return retval;
  15050. }
  15051. /*:78*//*79:*/
  15052. #line 2052 "./typica.w"
  15053. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  15054. {
  15055. setQDialogProperties(value,engine);
  15056. }
  15057. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  15058. {
  15059. setQWidgetProperties(value,engine);
  15060. }
  15061. /*:79*//*82:*/
  15062. #line 2093 "./typica.w"
  15063. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  15064. {
  15065. QScriptValue object=
  15066. engine->newQObject(new QFile(argument<QString> (0,context)));
  15067. setQFileProperties(object,engine);
  15068. return object;
  15069. }
  15070. /*:82*//*83:*/
  15071. #line 2104 "./typica.w"
  15072. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  15073. {
  15074. setQIODeviceProperties(value,engine);
  15075. value.setProperty("remove",engine->newFunction(QFile_remove));
  15076. }
  15077. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  15078. {
  15079. QFile*self= getself<QFile*> (context);
  15080. bool retval= self->remove();
  15081. return QScriptValue(engine,retval);
  15082. }
  15083. /*:83*//*84:*/
  15084. #line 2126 "./typica.w"
  15085. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  15086. {
  15087. setQObjectProperties(value,engine);
  15088. value.setProperty("open",engine->newFunction(QIODevice_open));
  15089. value.setProperty("close",engine->newFunction(QIODevice_close));
  15090. value.setProperty("readToString",
  15091. engine->newFunction(QIODevice_readToString));
  15092. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  15093. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  15094. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  15095. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  15096. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  15097. value.setProperty("read",engine->newFunction(QIODevice_read));
  15098. }
  15099. /*:84*//*85:*/
  15100. #line 2147 "./typica.w"
  15101. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  15102. {
  15103. QIODevice*self= getself<QIODevice*> (context);
  15104. bool retval= false;
  15105. if(context->argumentCount()==1)
  15106. {
  15107. switch(argument<int> (0,context))
  15108. {
  15109. case 1:
  15110. retval= self->open(QIODevice::ReadOnly);
  15111. break;
  15112. case 2:
  15113. retval= self->open(QIODevice::WriteOnly);
  15114. break;
  15115. case 3:
  15116. retval= self->open(QIODevice::ReadWrite);
  15117. break;
  15118. default:
  15119. break;
  15120. }
  15121. }
  15122. else
  15123. {
  15124. retval= self->open(QIODevice::ReadWrite);
  15125. }
  15126. return QScriptValue(retval);
  15127. }
  15128. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  15129. {
  15130. QIODevice*self= getself<QIODevice*> (context);
  15131. self->close();
  15132. return QScriptValue();
  15133. }
  15134. /*:85*//*86:*/
  15135. #line 2187 "./typica.w"
  15136. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  15137. {
  15138. QIODevice*self= getself<QIODevice*> (context);
  15139. self->reset();
  15140. return QScriptValue(QString(self->readAll()));
  15141. }
  15142. /*:86*//*87:*/
  15143. #line 2203 "./typica.w"
  15144. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  15145. {
  15146. QIODevice*self= getself<QIODevice*> (context);
  15147. if(context->argumentCount()==1)
  15148. {
  15149. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  15150. }
  15151. context->throwError("Incorrect number of arguments passed to "
  15152. "QIODevice::putChar()");
  15153. return QScriptValue();
  15154. }
  15155. /*:87*//*88:*/
  15156. #line 2221 "./typica.w"
  15157. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  15158. {
  15159. QIODevice*self= getself<QIODevice*> (context);
  15160. if(context->argumentCount()==1)
  15161. {
  15162. self->write(argument<QString> (0,context).toUtf8());
  15163. }
  15164. else
  15165. {
  15166. context->throwError("Incorrect number of arguments passed to "
  15167. "QIODevice::writeString()");
  15168. }
  15169. return QScriptValue();
  15170. }
  15171. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  15172. {
  15173. QIODevice*self= getself<QIODevice*> (context);
  15174. if(context->argumentCount()==1)
  15175. {
  15176. self->write(argument<QByteArray> (0,context));
  15177. }
  15178. else
  15179. {
  15180. context->throwError("Incorrect number of arguments passed to "
  15181. "QIODevice::writeBytes()");
  15182. }
  15183. return QScriptValue();
  15184. }
  15185. /*:88*//*89:*/
  15186. #line 2255 "./typica.w"
  15187. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  15188. {
  15189. QIODevice*self= getself<QIODevice*> (context);
  15190. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  15191. setQByteArrayProperties(value,engine);
  15192. return value;
  15193. }
  15194. /*:89*//*90:*/
  15195. #line 2266 "./typica.w"
  15196. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  15197. {
  15198. QIODevice*self= getself<QIODevice*> (context);
  15199. QScriptValue value= engine->toScriptValue<QByteArray> (
  15200. self->peek(argument<int> (0,context)));
  15201. setQByteArrayProperties(value,engine);
  15202. return value;
  15203. }
  15204. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  15205. {
  15206. QIODevice*self= getself<QIODevice*> (context);
  15207. QScriptValue value= engine->toScriptValue<QByteArray> (
  15208. self->read(argument<int> (0,context)));
  15209. setQByteArrayProperties(value,engine);
  15210. return value;
  15211. }
  15212. /*:90*//*93:*/
  15213. #line 2311 "./typica.w"
  15214. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  15215. {
  15216. QScriptValue object= engine->newQObject(new QProcess);
  15217. setQProcessProperties(object,engine);
  15218. return object;
  15219. }
  15220. /*:93*//*94:*/
  15221. #line 2322 "./typica.w"
  15222. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  15223. {
  15224. setQIODeviceProperties(value,engine);
  15225. value.setProperty("execute",engine->newFunction(QProcess_execute));
  15226. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  15227. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  15228. value.setProperty("start",engine->newFunction(QProcess_start));
  15229. }
  15230. /*:94*//*95:*/
  15231. #line 2336 "./typica.w"
  15232. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  15233. {
  15234. QProcess*self= getself<QProcess*> (context);
  15235. QString program= argument<QString> (0,context);
  15236. QStringList arguments= QStringList();
  15237. if(context->argumentCount()> 1){
  15238. arguments= argument<QVariant> (1,context).toStringList();
  15239. }
  15240. int retval= self->execute(program,arguments);
  15241. return QScriptValue(retval);
  15242. }
  15243. /*:95*//*96:*/
  15244. #line 2351 "./typica.w"
  15245. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  15246. {
  15247. QProcess*self= getself<QProcess*> (context);
  15248. QString program= argument<QString> (0,context);
  15249. QStringList arguments= QStringList();
  15250. if(context->argumentCount()> 1){
  15251. arguments= argument<QVariant> (1,context).toStringList();
  15252. }
  15253. QString workingDirectory= "";
  15254. if(context->argumentCount()> 2){
  15255. workingDirectory= argument<QString> (2,context);
  15256. }
  15257. bool retval;
  15258. switch(context->argumentCount())
  15259. {
  15260. case 1:
  15261. retval= self->startDetached(program);
  15262. break;
  15263. case 2:
  15264. retval= self->startDetached(program,arguments);
  15265. break;
  15266. case 3:
  15267. retval= self->startDetached(program,arguments,workingDirectory);
  15268. break;
  15269. default:
  15270. retval= false;
  15271. }
  15272. return QScriptValue(retval);
  15273. }
  15274. /*:96*//*97:*/
  15275. #line 2384 "./typica.w"
  15276. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  15277. {
  15278. QProcess*self= getself<QProcess*> (context);
  15279. QString directory= argument<QString> (0,context);
  15280. self->setWorkingDirectory(directory);
  15281. return QScriptValue();
  15282. }
  15283. /*:97*//*98:*/
  15284. #line 2396 "./typica.w"
  15285. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  15286. {
  15287. QProcess*self= getself<QProcess*> (context);
  15288. QString program= argument<QString> (0,context);
  15289. QStringList arguments= QStringList();
  15290. if(context->argumentCount()> 1){
  15291. arguments= argument<QVariant> (1,context).toStringList();
  15292. }
  15293. self->start(program,arguments);
  15294. return QScriptValue();
  15295. }
  15296. /*:98*//*100:*/
  15297. #line 2437 "./typica.w"
  15298. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  15299. {
  15300. QScriptValue object= engine->newVariant(QVariant(bytes));
  15301. setQByteArrayProperties(object,engine);
  15302. return object;
  15303. }
  15304. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  15305. {
  15306. bytes= value.toVariant().toByteArray();
  15307. }
  15308. /*:100*//*102:*/
  15309. #line 2460 "./typica.w"
  15310. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  15311. {
  15312. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  15313. setQByteArrayProperties(object,engine);
  15314. return object;
  15315. }
  15316. /*:102*//*103:*/
  15317. #line 2471 "./typica.w"
  15318. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  15319. {
  15320. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  15321. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  15322. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  15323. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  15324. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  15325. value.setProperty("size",engine->newFunction(QByteArray_size));
  15326. value.setProperty("left",engine->newFunction(QByteArray_left));
  15327. value.setProperty("right",engine->newFunction(QByteArray_right));
  15328. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  15329. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  15330. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  15331. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  15332. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  15333. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  15334. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  15335. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  15336. }
  15337. /*:103*//*104:*/
  15338. #line 2495 "./typica.w"
  15339. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  15340. {
  15341. QByteArray self= getself<QByteArray> (context);
  15342. QByteArray retval;
  15343. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  15344. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  15345. setQByteArrayProperties(value,engine);
  15346. return value;
  15347. }
  15348. /*:104*//*105:*/
  15349. #line 2509 "./typica.w"
  15350. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  15351. {
  15352. QByteArray self= getself<QByteArray> (context);
  15353. return QScriptValue((int)(self.at(argument<int> (0,context))));
  15354. }
  15355. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  15356. {
  15357. QByteArray self= getself<QByteArray> (context);
  15358. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  15359. return QScriptValue();
  15360. }
  15361. /*:105*//*106:*/
  15362. #line 2527 "./typica.w"
  15363. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  15364. {
  15365. QByteArray self= getself<QByteArray> (context);
  15366. QScriptValue value=
  15367. engine->toScriptValue<QByteArray> (
  15368. self.append(argument<QByteArray> (0,context)));
  15369. setQByteArrayProperties(value,engine);
  15370. return value;
  15371. }
  15372. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  15373. {
  15374. QByteArray self= getself<QByteArray> (context);
  15375. QScriptValue value= engine->toScriptValue<QByteArray> (
  15376. self.append(argument<QString> (0,context)));
  15377. setQByteArrayProperties(value,engine);
  15378. return value;
  15379. }
  15380. /*:106*//*107:*/
  15381. #line 2549 "./typica.w"
  15382. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  15383. {
  15384. QByteArray self= getself<QByteArray> (context);
  15385. return QScriptValue(self.size());
  15386. }
  15387. /*:107*//*108:*/
  15388. #line 2559 "./typica.w"
  15389. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  15390. {
  15391. QByteArray self= getself<QByteArray> (context);
  15392. QScriptValue value= engine->toScriptValue<QByteArray> (
  15393. self.left(argument<int> (0,context)));
  15394. setQByteArrayProperties(value,engine);
  15395. return value;
  15396. }
  15397. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  15398. {
  15399. QByteArray self= getself<QByteArray> (context);
  15400. QScriptValue value= engine->toScriptValue<QByteArray> (
  15401. self.right(argument<int> (0,context)));
  15402. setQByteArrayProperties(value,engine);
  15403. return value;
  15404. }
  15405. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  15406. {
  15407. QByteArray self= getself<QByteArray> (context);
  15408. int length= -1;
  15409. if(context->argumentCount()> 1)
  15410. {
  15411. length= argument<int> (1,context);
  15412. }
  15413. QScriptValue value= engine->toScriptValue<QByteArray> (
  15414. self.mid(argument<int> (0,context),length));
  15415. setQByteArrayProperties(value,engine);
  15416. return value;
  15417. }
  15418. /*:108*//*109:*/
  15419. #line 2594 "./typica.w"
  15420. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  15421. {
  15422. QByteArray self= getself<QByteArray> (context);
  15423. self.chop(argument<int> (0,context));
  15424. return QScriptValue();
  15425. }
  15426. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  15427. {
  15428. QByteArray self= getself<QByteArray> (context);
  15429. QScriptValue value= engine->toScriptValue<QByteArray> (
  15430. self.remove(argument<int> (0,context),argument<int> (1,context)));
  15431. setQByteArrayProperties(value,engine);
  15432. return value;
  15433. }
  15434. /*:109*//*110:*/
  15435. #line 2617 "./typica.w"
  15436. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  15437. {
  15438. QByteArray self= getself<QByteArray> (context);
  15439. int value= 0;
  15440. char*bytes= (char*)&value;
  15441. bytes[0]= self[0];
  15442. return QScriptValue(value);
  15443. }
  15444. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  15445. {
  15446. QByteArray self= getself<QByteArray> (context);
  15447. int value= 0;
  15448. char*bytes= (char*)&value;
  15449. bytes[0]= self[0];
  15450. bytes[1]= self[1];
  15451. return QScriptValue(value);
  15452. }
  15453. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  15454. {
  15455. QByteArray self= getself<QByteArray> (context);
  15456. int value= 0;
  15457. char*bytes= (char*)&value;
  15458. bytes[0]= self[0];
  15459. bytes[1]= self[1];
  15460. bytes[2]= self[2];
  15461. bytes[3]= self[3];
  15462. return QScriptValue(value);
  15463. }
  15464. /*:110*//*111:*/
  15465. #line 2653 "./typica.w"
  15466. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  15467. {
  15468. QByteArray self= getself<QByteArray> (context);
  15469. float value= 0.0;
  15470. char*bytes= (char*)&value;
  15471. bytes[0]= self[0];
  15472. bytes[1]= self[1];
  15473. bytes[2]= self[2];
  15474. bytes[3]= self[3];
  15475. return QScriptValue(value);
  15476. }
  15477. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  15478. {
  15479. QByteArray self= getself<QByteArray> (context);
  15480. double value= 0.0;
  15481. char*bytes= (char*)&value;
  15482. bytes[0]= self[0];
  15483. bytes[1]= self[1];
  15484. bytes[2]= self[2];
  15485. bytes[3]= self[3];
  15486. bytes[4]= self[4];
  15487. bytes[5]= self[5];
  15488. bytes[6]= self[6];
  15489. bytes[7]= self[7];
  15490. return QScriptValue(value);
  15491. }
  15492. /*:111*//*114:*/
  15493. #line 2708 "./typica.w"
  15494. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  15495. {
  15496. qint8 value= (qint8)(argument<int> (0,context));
  15497. char*bytes= (char*)&value;
  15498. QByteArray retval;
  15499. retval.resize(1);
  15500. retval[0]= bytes[0];
  15501. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15502. setQByteArrayProperties(v,engine);
  15503. return v;
  15504. }
  15505. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  15506. {
  15507. qint16 value= (qint16)(argument<int> (0,context));
  15508. char*bytes= (char*)&value;
  15509. QByteArray retval;
  15510. retval.resize(2);
  15511. retval[0]= bytes[0];
  15512. retval[1]= bytes[1];
  15513. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15514. setQByteArrayProperties(v,engine);
  15515. return v;
  15516. }
  15517. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  15518. {
  15519. qint32 value= (qint32)(argument<int> (0,context));
  15520. char*bytes= (char*)&value;
  15521. QByteArray retval;
  15522. retval.resize(4);
  15523. retval[0]= bytes[0];
  15524. retval[1]= bytes[1];
  15525. retval[2]= bytes[2];
  15526. retval[3]= bytes[3];
  15527. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15528. setQByteArrayProperties(v,engine);
  15529. return v;
  15530. }
  15531. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  15532. {
  15533. float value= (float)(argument<double> (0,context));
  15534. char*bytes= (char*)&value;
  15535. QByteArray retval;
  15536. retval.resize(4);
  15537. retval[0]= bytes[0];
  15538. retval[1]= bytes[1];
  15539. retval[2]= bytes[2];
  15540. retval[3]= bytes[3];
  15541. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15542. setQByteArrayProperties(v,engine);
  15543. return v;
  15544. }
  15545. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  15546. {
  15547. double value= (double)(argument<double> (0,context));
  15548. char*bytes= (char*)&value;
  15549. QByteArray retval;
  15550. retval.resize(8);
  15551. retval[0]= bytes[0];
  15552. retval[1]= bytes[1];
  15553. retval[2]= bytes[2];
  15554. retval[3]= bytes[3];
  15555. retval[4]= bytes[4];
  15556. retval[5]= bytes[5];
  15557. retval[6]= bytes[6];
  15558. retval[7]= bytes[7];
  15559. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15560. setQByteArrayProperties(v,engine);
  15561. return v;
  15562. }
  15563. /*:114*//*117:*/
  15564. #line 2805 "./typica.w"
  15565. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  15566. {
  15567. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  15568. QScriptValue object= engine->newQObject(new QBuffer(array));
  15569. setQBufferProperties(object,engine);
  15570. return object;
  15571. }
  15572. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  15573. {
  15574. setQIODeviceProperties(value,engine);
  15575. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  15576. }
  15577. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  15578. {
  15579. QBuffer*self= getself<QBuffer*> (context);
  15580. self->setData(argument<QString> (0,context).toAscii());
  15581. return QScriptValue();
  15582. }
  15583. /*:117*//*120:*/
  15584. #line 2854 "./typica.w"
  15585. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  15586. {
  15587. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  15588. setXQueryProperties(object,engine);
  15589. return object;
  15590. }
  15591. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  15592. {
  15593. QXmlQuery*self= getself<QXmlQuery*> (context);
  15594. delete self;
  15595. return QScriptValue();
  15596. }
  15597. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  15598. {
  15599. value.setProperty("bind",engine->newFunction(XQuery_bind));
  15600. value.setProperty("exec",engine->newFunction(XQuery_exec));
  15601. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  15602. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  15603. }
  15604. /*:120*//*121:*/
  15605. #line 2880 "./typica.w"
  15606. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  15607. {
  15608. QXmlQuery*self= getself<QXmlQuery*> (context);
  15609. QIODevice*buffer= argument<QIODevice*> (1,context);
  15610. self->bindVariable(argument<QString> (0,context),buffer);
  15611. return QScriptValue();
  15612. }
  15613. /*:121*//*122:*/
  15614. #line 2891 "./typica.w"
  15615. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  15616. {
  15617. QXmlQuery*self= getself<QXmlQuery*> (context);
  15618. self->setQuery(argument<QString> (0,context));
  15619. return QScriptValue();
  15620. }
  15621. /*:122*//*123:*/
  15622. #line 2901 "./typica.w"
  15623. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  15624. {
  15625. QXmlQuery*self= getself<QXmlQuery*> (context);
  15626. QString result;
  15627. self->evaluateTo(&result);
  15628. return QScriptValue(result);
  15629. }
  15630. /*:123*//*126:*/
  15631. #line 2956 "./typica.w"
  15632. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  15633. {
  15634. QXmlStreamWriter*retval;
  15635. if(context->argumentCount()==1)
  15636. {
  15637. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  15638. }
  15639. else
  15640. {
  15641. retval= new QXmlStreamWriter;
  15642. }
  15643. QScriptValue object= engine->toScriptValue<void*> (retval);
  15644. setXmlWriterProperties(object,engine);
  15645. return object;
  15646. }
  15647. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  15648. {
  15649. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  15650. value.setProperty("writeAttribute",
  15651. engine->newFunction(XmlWriter_writeAttribute));
  15652. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  15653. value.setProperty("writeCharacters",
  15654. engine->newFunction(XmlWriter_writeCharacters));
  15655. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  15656. value.setProperty("writeEmptyElement",
  15657. engine->newFunction(XmlWriter_writeEmptyElement));
  15658. value.setProperty("writeEndDocument",
  15659. engine->newFunction(XmlWriter_writeEndDocument));
  15660. value.setProperty("writeEndElement",
  15661. engine->newFunction(XmlWriter_writeEndElement));
  15662. value.setProperty("writeEntityReference",
  15663. engine->newFunction(XmlWriter_writeEntityReference));
  15664. value.setProperty("writeProcessingInstruction",
  15665. engine->newFunction(XmlWriter_writeProcessingInstruction));
  15666. value.setProperty("writeStartDocument",
  15667. engine->newFunction(XmlWriter_writeStartDocument));
  15668. value.setProperty("writeStartElement",
  15669. engine->newFunction(XmlWriter_writeStartElement));
  15670. value.setProperty("writeTextElement",
  15671. engine->newFunction(XmlWriter_writeTextElement));
  15672. }
  15673. /*:126*//*127:*/
  15674. #line 3003 "./typica.w"
  15675. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  15676. {
  15677. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15678. QIODevice*device= argument<QIODevice*> (0,context);
  15679. self->setDevice(device);
  15680. return QScriptValue();
  15681. }
  15682. /*:127*//*128:*/
  15683. #line 3017 "./typica.w"
  15684. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  15685. QScriptEngine*)
  15686. {
  15687. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15688. self->writeStartDocument(argument<QString> (0,context));
  15689. return QScriptValue();
  15690. }
  15691. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  15692. QScriptEngine*)
  15693. {
  15694. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15695. self->writeEndDocument();
  15696. return QScriptValue();
  15697. }
  15698. /*:128*//*129:*/
  15699. #line 3036 "./typica.w"
  15700. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  15701. {
  15702. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15703. self->writeDTD(argument<QString> (0,context));
  15704. return QScriptValue();
  15705. }
  15706. /*:129*//*130:*/
  15707. #line 3047 "./typica.w"
  15708. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  15709. QScriptEngine*)
  15710. {
  15711. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15712. self->writeStartElement(argument<QString> (0,context));
  15713. return QScriptValue();
  15714. }
  15715. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  15716. {
  15717. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15718. self->writeAttribute(argument<QString> (0,context),
  15719. argument<QString> (1,context));
  15720. return QScriptValue();
  15721. }
  15722. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  15723. {
  15724. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15725. self->writeCharacters(argument<QString> (0,context));
  15726. return QScriptValue();
  15727. }
  15728. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  15729. {
  15730. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15731. self->writeEndElement();
  15732. return QScriptValue();
  15733. }
  15734. /*:130*//*131:*/
  15735. #line 3083 "./typica.w"
  15736. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  15737. QScriptEngine*)
  15738. {
  15739. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15740. self->writeEmptyElement(argument<QString> (0,context));
  15741. return QScriptValue();
  15742. }
  15743. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  15744. QScriptEngine*)
  15745. {
  15746. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15747. self->writeTextElement(argument<QString> (0,context),
  15748. argument<QString> (1,context));
  15749. return QScriptValue();
  15750. }
  15751. /*:131*//*132:*/
  15752. #line 3104 "./typica.w"
  15753. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  15754. {
  15755. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15756. self->writeCDATA(argument<QString> (0,context));
  15757. return QScriptValue();
  15758. }
  15759. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  15760. QScriptEngine*)
  15761. {
  15762. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15763. self->writeEntityReference(argument<QString> (0,context));
  15764. return QScriptValue();
  15765. }
  15766. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  15767. QScriptEngine*)
  15768. {
  15769. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15770. self->writeProcessingInstruction(argument<QString> (0,context),
  15771. argument<QString> (1,context));
  15772. return QScriptValue();
  15773. }
  15774. /*:132*//*135:*/
  15775. #line 3163 "./typica.w"
  15776. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  15777. {
  15778. QXmlStreamReader*retval=
  15779. new QXmlStreamReader(argument<QIODevice*> (0,context));
  15780. QScriptValue object= engine->toScriptValue<void*> (retval);
  15781. setXmlReaderProperties(object,engine);
  15782. return object;
  15783. }
  15784. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  15785. {
  15786. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  15787. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  15788. value.setProperty("hasAttribute",
  15789. engine->newFunction(XmlReader_hasAttribute));
  15790. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  15791. value.setProperty("isStartElement",
  15792. engine->newFunction(XmlReader_isStartElement));
  15793. value.setProperty("name",engine->newFunction(XmlReader_name));
  15794. value.setProperty("readElementText",
  15795. engine->newFunction(XmlReader_readElementText));
  15796. value.setProperty("readNext",
  15797. engine->newFunction(XmlReader_readNext));
  15798. value.setProperty("text",engine->newFunction(XmlReader_text));
  15799. }
  15800. /*:135*//*136:*/
  15801. #line 3193 "./typica.w"
  15802. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  15803. {
  15804. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15805. QString retval=
  15806. self->attributes().value(argument<QString> (0,context)).toString();
  15807. return QScriptValue(retval);
  15808. }
  15809. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  15810. {
  15811. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15812. bool retval=
  15813. self->attributes().hasAttribute(argument<QString> (0,context));
  15814. return QScriptValue(retval);
  15815. }
  15816. /*:136*//*137:*/
  15817. #line 3213 "./typica.w"
  15818. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  15819. {
  15820. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15821. return QScriptValue(self->atEnd());
  15822. }
  15823. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  15824. {
  15825. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15826. return QScriptValue(self->isDTD());
  15827. }
  15828. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  15829. {
  15830. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15831. return QScriptValue(self->isStartElement());
  15832. }
  15833. /*:137*//*138:*/
  15834. #line 3234 "./typica.w"
  15835. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  15836. {
  15837. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15838. self->readNext();
  15839. return QScriptValue();
  15840. }
  15841. /*:138*//*139:*/
  15842. #line 3244 "./typica.w"
  15843. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  15844. {
  15845. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15846. return QScriptValue(self->name().toString());
  15847. }
  15848. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  15849. {
  15850. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15851. return QScriptValue(self->readElementText());
  15852. }
  15853. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  15854. {
  15855. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15856. return QScriptValue(self->text().toString());
  15857. }
  15858. /*:139*//*142:*/
  15859. #line 3286 "./typica.w"
  15860. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  15861. {
  15862. setQObjectProperties(value,engine);
  15863. value.setProperty("value",engine->newFunction(QSettings_value));
  15864. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  15865. }
  15866. /*:142*//*143:*/
  15867. #line 3298 "./typica.w"
  15868. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  15869. {
  15870. QScriptValue object;
  15871. if(context->argumentCount()==1||context->argumentCount()==2)
  15872. {
  15873. QSettings settings;
  15874. QString key= argument<QString> (0,context);
  15875. QVariant value;
  15876. QVariant retval;
  15877. if(context->argumentCount()> 1)
  15878. {
  15879. value= argument<QVariant> (1,context);
  15880. retval= settings.value(key,value);
  15881. }
  15882. else
  15883. {
  15884. retval= settings.value(key);
  15885. }
  15886. object= engine->newVariant(retval);
  15887. }
  15888. else
  15889. {
  15890. context->throwError("Incorrect number of arguments passed to "
  15891. "QSettings::value(). This method takes one "
  15892. "string and one optional variant type.");
  15893. }
  15894. return object;
  15895. }
  15896. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  15897. {
  15898. if(context->argumentCount()==2)
  15899. {
  15900. QSettings settings;
  15901. QString key= argument<QString> (0,context);
  15902. QVariant value= argument<QVariant> (1,context);
  15903. settings.setValue(key,value);
  15904. }
  15905. else
  15906. {
  15907. context->throwError("Incorrect number of arguments passed to "
  15908. "QSettings::setValue(). This method takes one "
  15909. "string and one variant type for a total of two "
  15910. "arguments.");
  15911. }
  15912. return QScriptValue();
  15913. }
  15914. /*:143*//*146:*/
  15915. #line 3367 "./typica.w"
  15916. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  15917. {
  15918. QScriptValue object= engine->newQObject(new QLCDNumber());
  15919. setQLCDNumberProperties(object,engine);
  15920. return object;
  15921. }
  15922. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  15923. {
  15924. setQFrameProperties(value,engine);
  15925. }
  15926. /*:146*//*149:*/
  15927. #line 3425 "./typica.w"
  15928. QScriptValue constructQTime(QScriptContext*context,
  15929. QScriptEngine*engine)
  15930. {
  15931. QScriptValue object;
  15932. if(context->argumentCount()==0||
  15933. (context->argumentCount()>=2&&context->argumentCount()<=4))
  15934. {
  15935. int arg1= 0;
  15936. int arg2= 0;
  15937. int arg3= 0;
  15938. int arg4= 0;
  15939. switch(context->argumentCount())
  15940. {
  15941. case 4:
  15942. arg4= argument<int> (3,context);
  15943. case 3:
  15944. arg3= argument<int> (2,context);
  15945. case 2:
  15946. arg2= argument<int> (1,context);
  15947. arg1= argument<int> (0,context);
  15948. default:
  15949. break;
  15950. }
  15951. if(context->argumentCount())
  15952. {
  15953. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  15954. arg4));
  15955. }
  15956. else
  15957. {
  15958. object= engine->toScriptValue<QTime> (QTime());
  15959. }
  15960. setQTimeProperties(object,engine);
  15961. }
  15962. else
  15963. {
  15964. context->throwError("Incorrect number of arguments passed to "
  15965. "QTime::QTime(). This method takes zero, two, "
  15966. "three, or four integer arguments.");
  15967. }
  15968. return object;
  15969. }
  15970. /*:149*//*150:*/
  15971. #line 3473 "./typica.w"
  15972. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  15973. {
  15974. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  15975. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  15976. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  15977. value.setProperty("hour",engine->newFunction(QTime_hour));
  15978. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  15979. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  15980. value.setProperty("minute",engine->newFunction(QTime_minute));
  15981. value.setProperty("msec",engine->newFunction(QTime_msec));
  15982. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  15983. value.setProperty("restart",engine->newFunction(QTime_restart));
  15984. value.setProperty("second",engine->newFunction(QTime_second));
  15985. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  15986. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  15987. value.setProperty("start",engine->newFunction(QTime_start));
  15988. value.setProperty("toString",engine->newFunction(QTime_toString));
  15989. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  15990. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  15991. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  15992. }
  15993. /*:150*//*151:*/
  15994. #line 3502 "./typica.w"
  15995. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  15996. {
  15997. QTime self= getself<QTime> (context);
  15998. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  15999. (self.second()*1000)+self.msec();
  16000. return QScriptValue(retval);
  16001. }
  16002. /*:151*//*152:*/
  16003. #line 3516 "./typica.w"
  16004. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  16005. {
  16006. QTime time;
  16007. QScriptValue retval;
  16008. if(context->argumentCount()==1)
  16009. {
  16010. QTime self= getself<QTime> (context);
  16011. time= self.addMSecs(argument<int> (0,context));
  16012. retval= engine->toScriptValue<QTime> (time);
  16013. setQTimeProperties(retval,engine);
  16014. }
  16015. else
  16016. {
  16017. context->throwError("Incorrect number of arguments passed to "
  16018. "QTime::addMSecs(). This method takes one "
  16019. "integer as an argument.");
  16020. }
  16021. return retval;
  16022. }
  16023. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  16024. {
  16025. QTime time;
  16026. QScriptValue retval;
  16027. if(context->argumentCount()==1)
  16028. {
  16029. QTime self= getself<QTime> (context);
  16030. time= self.addSecs(argument<int> (0,context));
  16031. retval= engine->toScriptValue<QTime> (time);
  16032. setQTimeProperties(retval,engine);
  16033. }
  16034. else
  16035. {
  16036. context->throwError("Incorrect number of arguments passed to "
  16037. "QTime::addSecs(). This method takes one "
  16038. "integer as an argument.");
  16039. }
  16040. return retval;
  16041. }
  16042. /*:152*//*153:*/
  16043. #line 3559 "./typica.w"
  16044. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  16045. {
  16046. QScriptValue retval;
  16047. if(context->argumentCount()==0)
  16048. {
  16049. QTime self= getself<QTime> (context);
  16050. retval= QScriptValue(engine,self.elapsed());
  16051. }
  16052. else
  16053. {
  16054. context->throwError("Incorrect number of arguments passed to "
  16055. "QTime::elapsed(). This method takes no "
  16056. "arguments.");
  16057. }
  16058. return retval;
  16059. }
  16060. /*:153*//*154:*/
  16061. #line 3580 "./typica.w"
  16062. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  16063. {
  16064. QScriptValue retval;
  16065. if(context->argumentCount()==0)
  16066. {
  16067. QTime self= getself<QTime> (context);
  16068. retval= QScriptValue(engine,self.hour());
  16069. }
  16070. else
  16071. {
  16072. context->throwError("Incorrect number of arguments passed to "
  16073. "QTime::hour(). This method takes no "
  16074. "arguments.");
  16075. }
  16076. return retval;
  16077. }
  16078. /*:154*//*155:*/
  16079. #line 3600 "./typica.w"
  16080. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  16081. {
  16082. QScriptValue retval;
  16083. if(context->argumentCount()==0)
  16084. {
  16085. QTime self= getself<QTime> (context);
  16086. retval= QScriptValue(engine,self.minute());
  16087. }
  16088. else
  16089. {
  16090. context->throwError("Incorrect number of arguments passed to "
  16091. "QTime::minute(). This method takes no "
  16092. "arguments.");
  16093. }
  16094. return retval;
  16095. }
  16096. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  16097. {
  16098. QScriptValue retval;
  16099. if(context->argumentCount()==0)
  16100. {
  16101. QTime self= getself<QTime> (context);
  16102. retval= QScriptValue(engine,self.second());
  16103. }
  16104. else
  16105. {
  16106. context->throwError("Incorrect number of arguments passed to "
  16107. "QTime::second(). This method takes no "
  16108. "arguments.");
  16109. }
  16110. return retval;
  16111. }
  16112. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  16113. {
  16114. QScriptValue retval;
  16115. if(context->argumentCount()==0)
  16116. {
  16117. QTime self= getself<QTime> (context);
  16118. retval= QScriptValue(engine,self.msec());
  16119. }
  16120. else
  16121. {
  16122. context->throwError("Incorrect number of arguments passed to "
  16123. "QTime::msec(). This method takes no "
  16124. "arguments.");
  16125. }
  16126. return retval;
  16127. }
  16128. /*:155*//*156:*/
  16129. #line 3656 "./typica.w"
  16130. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  16131. {
  16132. QScriptValue retval;
  16133. if(context->argumentCount()==0)
  16134. {
  16135. QTime self= getself<QTime> (context);
  16136. retval= QScriptValue(engine,self.isNull());
  16137. }
  16138. else
  16139. {
  16140. context->throwError("Incorrect number of arguments passed to "
  16141. "QTime::isNull(). This method takes no "
  16142. "arguments.");
  16143. }
  16144. return retval;
  16145. }
  16146. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  16147. {
  16148. QScriptValue retval;
  16149. if(context->argumentCount()==0)
  16150. {
  16151. QTime self= getself<QTime> (context);
  16152. retval= QScriptValue(engine,self.isValid());
  16153. }
  16154. else
  16155. {
  16156. context->throwError("Incorrect number of arguments passed to "
  16157. "QTime::isValid(). This method takes no "
  16158. "arguments.");
  16159. }
  16160. return retval;
  16161. }
  16162. /*:156*//*157:*/
  16163. #line 3694 "./typica.w"
  16164. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  16165. {
  16166. QScriptValue retval;
  16167. if(context->argumentCount()==1)
  16168. {
  16169. QTime self= getself<QTime> (context);
  16170. QTime arg= argument<QVariant> (0,context).toTime();
  16171. retval= QScriptValue(engine,self.msecsTo(arg));
  16172. }
  16173. else
  16174. {
  16175. context->throwError("Incorrect number of arguments passed to "
  16176. "QTime::msecsTo(). This method takes one QTime.");
  16177. }
  16178. return retval;
  16179. }
  16180. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  16181. {
  16182. QScriptValue retval;
  16183. if(context->argumentCount()==1)
  16184. {
  16185. QTime self= getself<QTime> (context);
  16186. QTime arg= argument<QVariant> (0,context).toTime();
  16187. retval= QScriptValue(engine,self.secsTo(arg));
  16188. }
  16189. else
  16190. {
  16191. context->throwError("Incorrect number of arguments passed to "
  16192. "QTime::secsTo(). This method takes one QTime.");
  16193. }
  16194. return retval;
  16195. }
  16196. /*:157*//*158:*/
  16197. #line 3733 "./typica.w"
  16198. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  16199. {
  16200. QScriptValue retval;
  16201. if(context->argumentCount()==0)
  16202. {
  16203. QTime self= getself<QTime> (context);
  16204. retval= QScriptValue(engine,self.restart());
  16205. }
  16206. else
  16207. {
  16208. context->throwError("Incorrect number of arguments passed to "
  16209. "QTime::restart(). This method takes no "
  16210. "arguments.");
  16211. }
  16212. return retval;
  16213. }
  16214. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  16215. {
  16216. if(context->argumentCount()==0)
  16217. {
  16218. QTime self= getself<QTime> (context);
  16219. self.start();
  16220. }
  16221. else
  16222. {
  16223. context->throwError("Incorrect number of arguments passed to "
  16224. "QTime::start(). This method takes no arguments.");
  16225. }
  16226. return QScriptValue();
  16227. }
  16228. /*:158*//*159:*/
  16229. #line 3769 "./typica.w"
  16230. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  16231. {
  16232. QScriptValue retval;
  16233. if(context->argumentCount()==3||context->argumentCount()==4)
  16234. {
  16235. QTime self= getself<QTime> (context);
  16236. int arg1= 0;
  16237. int arg2= 0;
  16238. int arg3= 0;
  16239. int arg4= 0;
  16240. switch(context->argumentCount())
  16241. {
  16242. case 4:
  16243. arg4= argument<int> (3,context);
  16244. case 3:
  16245. arg3= argument<int> (2,context);
  16246. arg2= argument<int> (1,context);
  16247. arg1= argument<int> (0,context);
  16248. default:
  16249. break;
  16250. }
  16251. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  16252. }
  16253. else
  16254. {
  16255. context->throwError("Incorrect number of arguments passed to "
  16256. "QTime::setHMS(). This method takes three or "
  16257. "four integer arguments.");
  16258. }
  16259. return retval;
  16260. }
  16261. /*:159*//*160:*/
  16262. #line 3805 "./typica.w"
  16263. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  16264. {
  16265. QScriptValue retval;
  16266. if(context->argumentCount()==1)
  16267. {
  16268. QTime self= getself<QTime> (context);
  16269. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  16270. }
  16271. else
  16272. {
  16273. context->throwError("Incorrect number of arguments passed to "
  16274. "QTime::toString(). This method takes one QString "
  16275. "as an argument.");
  16276. }
  16277. return retval;
  16278. }
  16279. /*:160*//*161:*/
  16280. #line 3826 "./typica.w"
  16281. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  16282. {
  16283. QScriptValue object;
  16284. object= engine->toScriptValue<QTime> (QTime::currentTime());
  16285. setQTimeProperties(object,engine);
  16286. return object;
  16287. }
  16288. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  16289. {
  16290. QScriptValue object;
  16291. if(context->argumentCount()==2)
  16292. {
  16293. QString time= argument<QString> (0,context);
  16294. QString format= argument<QString> (1,context);
  16295. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  16296. setQTimeProperties(object,engine);
  16297. }
  16298. else
  16299. {
  16300. context->throwError("Incorrect number of arguments passed to "
  16301. "QTime::fromString(). This method takes two "
  16302. "string arguments.");
  16303. }
  16304. return object;
  16305. }
  16306. /*:161*//*162:*/
  16307. #line 3857 "./typica.w"
  16308. template<> QTime argument(int arg,QScriptContext*context)
  16309. {
  16310. return qscriptvalue_cast<QTime> (context->argument(arg));
  16311. }
  16312. /*:162*//*164:*/
  16313. #line 3875 "./typica.w"
  16314. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  16315. {
  16316. setQFrameProperties(value,engine);
  16317. }
  16318. /*:164*//*166:*/
  16319. #line 3889 "./typica.w"
  16320. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  16321. {
  16322. setQAbstractScrollAreaProperties(value,engine);
  16323. }
  16324. /*:166*//*168:*/
  16325. #line 3903 "./typica.w"
  16326. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  16327. {
  16328. setQAbstractScrollAreaProperties(value,engine);
  16329. }
  16330. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  16331. {
  16332. setQAbstractItemViewProperties(value,engine);
  16333. }
  16334. /*:168*//*171:*/
  16335. #line 3936 "./typica.w"
  16336. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  16337. {
  16338. QScriptValue object= engine->newQObject(new QPushButton());
  16339. setQPushButtonProperties(object,engine);
  16340. return object;
  16341. }
  16342. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  16343. {
  16344. setQAbstractButtonProperties(value,engine);
  16345. }
  16346. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  16347. {
  16348. setQWidgetProperties(value,engine);
  16349. }
  16350. /*:171*//*178:*/
  16351. #line 4048 "./typica.w"
  16352. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  16353. {
  16354. SqlQueryConnection*obj= new SqlQueryConnection();
  16355. QScriptValue object=
  16356. engine->toScriptValue<void*> (obj);
  16357. setQSqlQueryProperties(object,engine);
  16358. return object;
  16359. }
  16360. /*:178*//*179:*/
  16361. #line 4061 "./typica.w"
  16362. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  16363. {
  16364. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  16365. value.setProperty("bindFileData",
  16366. engine->newFunction(QSqlQuery_bindFileData));
  16367. value.setProperty("bindDeviceData",
  16368. engine->newFunction(QSqlQuery_bindDeviceData));
  16369. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  16370. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  16371. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  16372. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  16373. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  16374. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  16375. }
  16376. /*:179*//*180:*/
  16377. #line 4079 "./typica.w"
  16378. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  16379. {
  16380. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  16381. QScriptValue retval;
  16382. if(context->argumentCount()==1)
  16383. {
  16384. retval= QScriptValue(engine,
  16385. q->exec(argument<QString> (0,context)));
  16386. }
  16387. else
  16388. {
  16389. retval= QScriptValue(engine,q->exec());
  16390. }
  16391. if(q->lastError().isValid())
  16392. {
  16393. qDebug()<<q->lastQuery();
  16394. qDebug()<<q->lastError().text();
  16395. }
  16396. return retval;
  16397. }
  16398. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  16399. {
  16400. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16401. return QScriptValue(query->lastQuery());
  16402. }
  16403. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  16404. {
  16405. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16406. return QScriptValue(engine,query->next());
  16407. }
  16408. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  16409. {
  16410. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16411. return QScriptValue(engine,
  16412. query->value(argument<int> (0,context)).toString());
  16413. }
  16414. /*:180*//*181:*/
  16415. #line 4123 "./typica.w"
  16416. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  16417. {
  16418. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16419. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  16420. }
  16421. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  16422. {
  16423. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16424. query->bindValue(argument<QString> (0,context),
  16425. argument<QVariant> (1,context));
  16426. return QScriptValue();
  16427. }
  16428. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  16429. QScriptEngine*)
  16430. {
  16431. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16432. QString placeholder= argument<QString> (0,context);
  16433. QString filename= argument<QString> (1,context);
  16434. QFile file(filename);
  16435. QByteArray data;
  16436. if(file.open(QIODevice::ReadOnly))
  16437. {
  16438. data= file.readAll();
  16439. file.close();
  16440. }
  16441. query->bindValue(placeholder,data);
  16442. return QScriptValue();
  16443. }
  16444. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  16445. QScriptEngine*)
  16446. {
  16447. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16448. QString placeholder= argument<QString> (0,context);
  16449. QIODevice*device= argument<QIODevice*> (1,context);
  16450. device->reset();
  16451. QByteArray data;
  16452. data= device->readAll();
  16453. query->bindValue(placeholder,data);
  16454. return QScriptValue();
  16455. }
  16456. /*:181*//*182:*/
  16457. #line 4175 "./typica.w"
  16458. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16459. {
  16460. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  16461. delete query;
  16462. return QScriptValue::UndefinedValue;
  16463. }
  16464. /*:182*//*185:*/
  16465. #line 4222 "./typica.w"
  16466. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  16467. {
  16468. QFileInfo info(argument<QString> (0,context));
  16469. QScriptValue retval(engine,info.baseName());
  16470. return retval;
  16471. }
  16472. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  16473. {
  16474. QFileInfo info(argument<QString> (0,context));
  16475. QDir dir= info.dir();
  16476. QScriptValue retval(engine,dir.path());
  16477. return retval;
  16478. }
  16479. /*:185*//*186:*/
  16480. #line 4241 "./typica.w"
  16481. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  16482. {
  16483. SqlQueryConnection h;
  16484. QSqlQuery*query= h.operator->();
  16485. QString q= "SELECT file FROM files WHERE id = :file";
  16486. query->prepare(q);
  16487. query->bindValue(":file",argument<int> (0,context));
  16488. query->exec();
  16489. query->next();
  16490. QByteArray array= query->value(0).toByteArray();
  16491. QFile file(argument<QString> (1,context));
  16492. file.open(QIODevice::WriteOnly);
  16493. file.write(array);
  16494. file.close();
  16495. return QScriptValue();
  16496. }
  16497. /*:186*//*187:*/
  16498. #line 4262 "./typica.w"
  16499. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  16500. {
  16501. QString source= argument<QString> (0,context);
  16502. source.remove(0,1);
  16503. source.chop(1);
  16504. QStringList elements= source.split(",");
  16505. QString element;
  16506. QScriptValue dest= engine->newArray(elements.size());
  16507. int i= 0;
  16508. foreach(element,elements)
  16509. {
  16510. if(element.startsWith("\"")&&element.endsWith("\""))
  16511. {
  16512. element.chop(1);
  16513. element= element.remove(0,1);
  16514. }
  16515. dest.setProperty(i,QScriptValue(engine,element));
  16516. i++;
  16517. }
  16518. return dest;
  16519. }
  16520. /*:187*//*188:*/
  16521. #line 4288 "./typica.w"
  16522. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  16523. {
  16524. QString font= argument<QString> (0,context);
  16525. QString classname;
  16526. if(context->argumentCount()> 1)
  16527. {
  16528. classname= argument<QString> (1,context);
  16529. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  16530. }
  16531. else
  16532. {
  16533. QApplication::setFont(QFont(font));
  16534. }
  16535. return QScriptValue();
  16536. }
  16537. /*:188*//*189:*/
  16538. #line 4308 "./typica.w"
  16539. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  16540. {
  16541. SqlQueryConnection h;
  16542. QSqlQuery*query= h.operator->();
  16543. QString q= "SELECT file FROM files WHERE id = :file";
  16544. query->prepare(q);
  16545. query->bindValue(":file",argument<int> (0,context));
  16546. query->exec();
  16547. query->next();
  16548. QByteArray array= query->value(0).toByteArray();
  16549. QBuffer buffer(&array);
  16550. buffer.open(QIODevice::ReadOnly);
  16551. QXmlQuery xquery;
  16552. xquery.bindVariable("profile",&buffer);
  16553. QString xq;
  16554. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  16555. xquery.setQuery(xq);
  16556. QString result;
  16557. xquery.evaluateTo(&result);
  16558. return QScriptValue(result);
  16559. }
  16560. /*:189*//*190:*/
  16561. #line 4335 "./typica.w"
  16562. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  16563. {
  16564. QWidget::setTabOrder(argument<QWidget*> (0,context),
  16565. argument<QWidget*> (1,context));
  16566. return QScriptValue();
  16567. }
  16568. /*:190*//*191:*/
  16569. #line 4346 "./typica.w"
  16570. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  16571. {
  16572. return QScriptValue(QCoreApplication::translate(
  16573. "configuration",
  16574. argument<QString> (1,context).toUtf8().data()));
  16575. }
  16576. /*:191*//*198:*/
  16577. #line 4600 "./typica.w"
  16578. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  16579. {
  16580. QString targetID= argument<QString> (0,context);
  16581. QDomNode element;
  16582. QScriptValue object;
  16583. /*200:*/
  16584. #line 4647 "./typica.w"
  16585. QDomNodeList windows=
  16586. AppInstance->configuration()->documentElement().elementsByTagName("window");
  16587. QDomNode nullNode;
  16588. int i= 0;
  16589. element= nullNode;
  16590. while(i<windows.count())
  16591. {
  16592. element= windows.at(i);
  16593. QDomNamedNodeMap attributes= element.attributes();
  16594. if(attributes.contains("id"))
  16595. {
  16596. if(attributes.namedItem("id").toAttr().value()==targetID)
  16597. {
  16598. break;
  16599. }
  16600. }
  16601. element= nullNode;
  16602. i++;
  16603. }
  16604. /*:200*/
  16605. #line 4606 "./typica.w"
  16606. if(!element.isNull())
  16607. {
  16608. /*201:*/
  16609. #line 4679 "./typica.w"
  16610. ScriptQMainWindow*window= new ScriptQMainWindow;
  16611. window->setObjectName(targetID);
  16612. object= engine->newQObject(window);
  16613. setQMainWindowProperties(object,engine);
  16614. QWidget*central= new(QWidget);
  16615. central->setParent(window);
  16616. central->setObjectName("centralWidget");
  16617. window->setCentralWidget(central);
  16618. if(element.hasChildNodes())
  16619. {
  16620. /*202:*/
  16621. #line 4714 "./typica.w"
  16622. QStack<QWidget*> widgetStack;
  16623. QStack<QLayout*> layoutStack;
  16624. QString windowScript;
  16625. widgetStack.push(central);
  16626. QDomNodeList windowChildren= element.childNodes();
  16627. int i= 0;
  16628. while(i<windowChildren.count())
  16629. {
  16630. QDomNode current;
  16631. QDomElement element;
  16632. current= windowChildren.at(i);
  16633. if(current.isElement())
  16634. {
  16635. element= current.toElement();
  16636. if(element.tagName()=="program")
  16637. {
  16638. windowScript.append(element.text());
  16639. }
  16640. else if(element.tagName()=="layout")
  16641. {
  16642. element.setAttribute("trcontext","configuration");
  16643. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16644. }
  16645. else if(element.tagName()=="menu")
  16646. {
  16647. /*203:*/
  16648. #line 4762 "./typica.w"
  16649. QMenuBar*bar= window->menuBar();
  16650. bar->setParent(window);
  16651. bar->setObjectName("menuBar");
  16652. if(element.hasAttribute("name"))
  16653. {
  16654. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16655. element.attribute("name").toUtf8().data()));
  16656. menu->setParent(bar);
  16657. if(element.hasAttribute("type"))
  16658. {
  16659. if(element.attribute("type")=="reports")
  16660. {
  16661. if(element.hasAttribute("src"))
  16662. {
  16663. /*662:*/
  16664. #line 14033 "./typica.w"
  16665. QSettings settings;
  16666. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16667. toString()).
  16668. arg(element.attribute("src"));
  16669. QDir::addSearchPath("reports",reportDirectory);
  16670. QDir directory(reportDirectory);
  16671. directory.setFilter(QDir::Files);
  16672. directory.setSorting(QDir::Name);
  16673. QStringList nameFilter;
  16674. nameFilter<<"*.xml";
  16675. directory.setNameFilters(nameFilter);
  16676. QFileInfoList reportFiles= directory.entryInfoList();
  16677. for(int i= 0;i<reportFiles.size();i++)
  16678. {
  16679. QFileInfo reportFile= reportFiles.at(i);
  16680. /*666:*/
  16681. #line 14113 "./typica.w"
  16682. QString path= reportFile.absoluteFilePath();
  16683. QFile file(path);
  16684. if(file.open(QIODevice::ReadOnly))
  16685. {
  16686. QDomDocument document;
  16687. document.setContent(&file,true);
  16688. QDomElement root= document.documentElement();
  16689. QString translationContext= root.attribute("id");
  16690. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16691. if(!titleNode.isNull())
  16692. {
  16693. QDomElement titleElement= titleNode.toElement();
  16694. QString title= QCoreApplication::translate("configuration",
  16695. titleElement.text().toUtf8().data());
  16696. if(!title.isEmpty())
  16697. {
  16698. QStringList hierarchy= title.split(":->");
  16699. QMenu*insertionPoint= menu;
  16700. /*667:*/
  16701. #line 14142 "./typica.w"
  16702. for(int j= 0;j<hierarchy.size()-1;j++)
  16703. {
  16704. QObjectList menuList= insertionPoint->children();
  16705. bool menuFound= false;
  16706. for(int k= 0;k<menuList.size();k++)
  16707. {
  16708. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16709. if(currentItem)
  16710. {
  16711. if(currentItem->title()==hierarchy.at(j))
  16712. {
  16713. menuFound= true;
  16714. insertionPoint= currentItem;
  16715. break;
  16716. }
  16717. }
  16718. }
  16719. if(!menuFound)
  16720. {
  16721. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16722. }
  16723. }
  16724. /*:667*/
  16725. #line 14132 "./typica.w"
  16726. ReportAction*action= new ReportAction(path,hierarchy.last());
  16727. insertionPoint->addAction(action);
  16728. }
  16729. }
  16730. }
  16731. /*:666*/
  16732. #line 14049 "./typica.w"
  16733. }
  16734. /*:662*/
  16735. #line 4777 "./typica.w"
  16736. }
  16737. }
  16738. }
  16739. if(element.hasChildNodes())
  16740. {
  16741. /*204:*/
  16742. #line 4790 "./typica.w"
  16743. QDomNodeList menuItems= element.childNodes();
  16744. int j= 0;
  16745. while(j<menuItems.count())
  16746. {
  16747. QDomNode item= menuItems.at(j);
  16748. if(item.isElement())
  16749. {
  16750. QDomElement itemElement= item.toElement();
  16751. if(itemElement.tagName()=="item")
  16752. {
  16753. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16754. itemElement.text().toUtf8().data()),menu);
  16755. if(itemElement.hasAttribute("id"))
  16756. {
  16757. itemAction->setObjectName(itemElement.attribute("id"));
  16758. }
  16759. if(itemElement.hasAttribute("shortcut"))
  16760. {
  16761. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16762. }
  16763. menu->addAction(itemAction);
  16764. }
  16765. else if(itemElement.tagName()=="separator")
  16766. {
  16767. menu->addSeparator();
  16768. }
  16769. else if(itemElement.tagName()=="plugins")
  16770. {
  16771. /*687:*/
  16772. #line 21 "./plugins.w"
  16773. QMenu*pluginMenu= new QMenu(menu);
  16774. if(itemElement.hasAttribute("id"))
  16775. {
  16776. pluginMenu->setObjectName(itemElement.attribute("id"));
  16777. }
  16778. if(itemElement.hasAttribute("title"))
  16779. {
  16780. pluginMenu->setTitle(itemElement.attribute("title"));
  16781. }
  16782. if(itemElement.hasAttribute("src"))
  16783. {
  16784. QSettings settings;
  16785. QString pluginDirectory= QString("%1/%2").
  16786. arg(settings.value("config").toString()).
  16787. arg(itemElement.attribute("src"));
  16788. QDir directory(pluginDirectory);
  16789. directory.setFilter(QDir::Files);
  16790. directory.setSorting(QDir::Name);
  16791. QStringList nameFilter;
  16792. nameFilter<<"*.js";
  16793. directory.setNameFilters(nameFilter);
  16794. QFileInfoList pluginFiles= directory.entryInfoList();
  16795. for(int k= 0;k<pluginFiles.size();k++)
  16796. {
  16797. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  16798. if(itemElement.hasAttribute("preRun"))
  16799. {
  16800. pa->setPreRun(itemElement.attribute("preRun"));
  16801. }
  16802. if(itemElement.hasAttribute("postRun"))
  16803. {
  16804. pa->setPostRun(itemElement.attribute("postRun"));
  16805. }
  16806. pluginMenu->addAction(pa);
  16807. }
  16808. }
  16809. menu->addMenu(pluginMenu);
  16810. /*:687*/
  16811. #line 4819 "./typica.w"
  16812. }
  16813. }
  16814. j++;
  16815. }
  16816. #line 1 "./helpmenu.w"
  16817. /*:204*/
  16818. #line 4783 "./typica.w"
  16819. }
  16820. }
  16821. /*:203*/
  16822. #line 4740 "./typica.w"
  16823. }
  16824. }
  16825. i++;
  16826. }
  16827. QScriptValue oldThis= context->thisObject();
  16828. context->setThisObject(object);
  16829. QScriptValue result= engine->evaluate(windowScript);
  16830. /*195:*/
  16831. #line 4494 "./typica.w"
  16832. if(engine->hasUncaughtException())
  16833. {
  16834. int line= engine->uncaughtExceptionLineNumber();
  16835. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16836. result.toString();
  16837. QString trace;
  16838. foreach(trace,engine->uncaughtExceptionBacktrace())
  16839. {
  16840. qDebug()<<trace;
  16841. }
  16842. }
  16843. /*:195*/
  16844. #line 4748 "./typica.w"
  16845. context->setThisObject(oldThis);
  16846. /*:202*/
  16847. #line 4690 "./typica.w"
  16848. }
  16849. /*205:*/
  16850. #line 9 "./helpmenu.w"
  16851. HelpMenu*helpMenu= new HelpMenu();
  16852. window->menuBar()->addMenu(helpMenu);
  16853. /*:205*/
  16854. #line 4692 "./typica.w"
  16855. window->show();
  16856. /*:201*/
  16857. #line 4609 "./typica.w"
  16858. }
  16859. return object;
  16860. }
  16861. /*:198*//*199:*/
  16862. #line 4620 "./typica.w"
  16863. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  16864. {
  16865. QString targetID= argument<QString> (0,context);
  16866. QFile file(QString("reports:%1").arg(targetID));
  16867. QScriptValue object;
  16868. if(file.open(QIODevice::ReadOnly))
  16869. {
  16870. QDomDocument document;
  16871. document.setContent(&file,true);
  16872. QDomElement element= document.documentElement();
  16873. if(!element.isNull())
  16874. {
  16875. /*201:*/
  16876. #line 4679 "./typica.w"
  16877. ScriptQMainWindow*window= new ScriptQMainWindow;
  16878. window->setObjectName(targetID);
  16879. object= engine->newQObject(window);
  16880. setQMainWindowProperties(object,engine);
  16881. QWidget*central= new(QWidget);
  16882. central->setParent(window);
  16883. central->setObjectName("centralWidget");
  16884. window->setCentralWidget(central);
  16885. if(element.hasChildNodes())
  16886. {
  16887. /*202:*/
  16888. #line 4714 "./typica.w"
  16889. QStack<QWidget*> widgetStack;
  16890. QStack<QLayout*> layoutStack;
  16891. QString windowScript;
  16892. widgetStack.push(central);
  16893. QDomNodeList windowChildren= element.childNodes();
  16894. int i= 0;
  16895. while(i<windowChildren.count())
  16896. {
  16897. QDomNode current;
  16898. QDomElement element;
  16899. current= windowChildren.at(i);
  16900. if(current.isElement())
  16901. {
  16902. element= current.toElement();
  16903. if(element.tagName()=="program")
  16904. {
  16905. windowScript.append(element.text());
  16906. }
  16907. else if(element.tagName()=="layout")
  16908. {
  16909. element.setAttribute("trcontext","configuration");
  16910. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16911. }
  16912. else if(element.tagName()=="menu")
  16913. {
  16914. /*203:*/
  16915. #line 4762 "./typica.w"
  16916. QMenuBar*bar= window->menuBar();
  16917. bar->setParent(window);
  16918. bar->setObjectName("menuBar");
  16919. if(element.hasAttribute("name"))
  16920. {
  16921. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16922. element.attribute("name").toUtf8().data()));
  16923. menu->setParent(bar);
  16924. if(element.hasAttribute("type"))
  16925. {
  16926. if(element.attribute("type")=="reports")
  16927. {
  16928. if(element.hasAttribute("src"))
  16929. {
  16930. /*662:*/
  16931. #line 14033 "./typica.w"
  16932. QSettings settings;
  16933. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16934. toString()).
  16935. arg(element.attribute("src"));
  16936. QDir::addSearchPath("reports",reportDirectory);
  16937. QDir directory(reportDirectory);
  16938. directory.setFilter(QDir::Files);
  16939. directory.setSorting(QDir::Name);
  16940. QStringList nameFilter;
  16941. nameFilter<<"*.xml";
  16942. directory.setNameFilters(nameFilter);
  16943. QFileInfoList reportFiles= directory.entryInfoList();
  16944. for(int i= 0;i<reportFiles.size();i++)
  16945. {
  16946. QFileInfo reportFile= reportFiles.at(i);
  16947. /*666:*/
  16948. #line 14113 "./typica.w"
  16949. QString path= reportFile.absoluteFilePath();
  16950. QFile file(path);
  16951. if(file.open(QIODevice::ReadOnly))
  16952. {
  16953. QDomDocument document;
  16954. document.setContent(&file,true);
  16955. QDomElement root= document.documentElement();
  16956. QString translationContext= root.attribute("id");
  16957. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16958. if(!titleNode.isNull())
  16959. {
  16960. QDomElement titleElement= titleNode.toElement();
  16961. QString title= QCoreApplication::translate("configuration",
  16962. titleElement.text().toUtf8().data());
  16963. if(!title.isEmpty())
  16964. {
  16965. QStringList hierarchy= title.split(":->");
  16966. QMenu*insertionPoint= menu;
  16967. /*667:*/
  16968. #line 14142 "./typica.w"
  16969. for(int j= 0;j<hierarchy.size()-1;j++)
  16970. {
  16971. QObjectList menuList= insertionPoint->children();
  16972. bool menuFound= false;
  16973. for(int k= 0;k<menuList.size();k++)
  16974. {
  16975. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16976. if(currentItem)
  16977. {
  16978. if(currentItem->title()==hierarchy.at(j))
  16979. {
  16980. menuFound= true;
  16981. insertionPoint= currentItem;
  16982. break;
  16983. }
  16984. }
  16985. }
  16986. if(!menuFound)
  16987. {
  16988. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16989. }
  16990. }
  16991. /*:667*/
  16992. #line 14132 "./typica.w"
  16993. ReportAction*action= new ReportAction(path,hierarchy.last());
  16994. insertionPoint->addAction(action);
  16995. }
  16996. }
  16997. }
  16998. /*:666*/
  16999. #line 14049 "./typica.w"
  17000. }
  17001. /*:662*/
  17002. #line 4777 "./typica.w"
  17003. }
  17004. }
  17005. }
  17006. if(element.hasChildNodes())
  17007. {
  17008. /*204:*/
  17009. #line 4790 "./typica.w"
  17010. QDomNodeList menuItems= element.childNodes();
  17011. int j= 0;
  17012. while(j<menuItems.count())
  17013. {
  17014. QDomNode item= menuItems.at(j);
  17015. if(item.isElement())
  17016. {
  17017. QDomElement itemElement= item.toElement();
  17018. if(itemElement.tagName()=="item")
  17019. {
  17020. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  17021. itemElement.text().toUtf8().data()),menu);
  17022. if(itemElement.hasAttribute("id"))
  17023. {
  17024. itemAction->setObjectName(itemElement.attribute("id"));
  17025. }
  17026. if(itemElement.hasAttribute("shortcut"))
  17027. {
  17028. itemAction->setShortcut(itemElement.attribute("shortcut"));
  17029. }
  17030. menu->addAction(itemAction);
  17031. }
  17032. else if(itemElement.tagName()=="separator")
  17033. {
  17034. menu->addSeparator();
  17035. }
  17036. else if(itemElement.tagName()=="plugins")
  17037. {
  17038. /*687:*/
  17039. #line 21 "./plugins.w"
  17040. QMenu*pluginMenu= new QMenu(menu);
  17041. if(itemElement.hasAttribute("id"))
  17042. {
  17043. pluginMenu->setObjectName(itemElement.attribute("id"));
  17044. }
  17045. if(itemElement.hasAttribute("title"))
  17046. {
  17047. pluginMenu->setTitle(itemElement.attribute("title"));
  17048. }
  17049. if(itemElement.hasAttribute("src"))
  17050. {
  17051. QSettings settings;
  17052. QString pluginDirectory= QString("%1/%2").
  17053. arg(settings.value("config").toString()).
  17054. arg(itemElement.attribute("src"));
  17055. QDir directory(pluginDirectory);
  17056. directory.setFilter(QDir::Files);
  17057. directory.setSorting(QDir::Name);
  17058. QStringList nameFilter;
  17059. nameFilter<<"*.js";
  17060. directory.setNameFilters(nameFilter);
  17061. QFileInfoList pluginFiles= directory.entryInfoList();
  17062. for(int k= 0;k<pluginFiles.size();k++)
  17063. {
  17064. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  17065. if(itemElement.hasAttribute("preRun"))
  17066. {
  17067. pa->setPreRun(itemElement.attribute("preRun"));
  17068. }
  17069. if(itemElement.hasAttribute("postRun"))
  17070. {
  17071. pa->setPostRun(itemElement.attribute("postRun"));
  17072. }
  17073. pluginMenu->addAction(pa);
  17074. }
  17075. }
  17076. menu->addMenu(pluginMenu);
  17077. /*:687*/
  17078. #line 4819 "./typica.w"
  17079. }
  17080. }
  17081. j++;
  17082. }
  17083. #line 1 "./helpmenu.w"
  17084. /*:204*/
  17085. #line 4783 "./typica.w"
  17086. }
  17087. }
  17088. /*:203*/
  17089. #line 4740 "./typica.w"
  17090. }
  17091. }
  17092. i++;
  17093. }
  17094. QScriptValue oldThis= context->thisObject();
  17095. context->setThisObject(object);
  17096. QScriptValue result= engine->evaluate(windowScript);
  17097. /*195:*/
  17098. #line 4494 "./typica.w"
  17099. if(engine->hasUncaughtException())
  17100. {
  17101. int line= engine->uncaughtExceptionLineNumber();
  17102. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  17103. result.toString();
  17104. QString trace;
  17105. foreach(trace,engine->uncaughtExceptionBacktrace())
  17106. {
  17107. qDebug()<<trace;
  17108. }
  17109. }
  17110. /*:195*/
  17111. #line 4748 "./typica.w"
  17112. context->setThisObject(oldThis);
  17113. /*:202*/
  17114. #line 4690 "./typica.w"
  17115. }
  17116. /*205:*/
  17117. #line 9 "./helpmenu.w"
  17118. HelpMenu*helpMenu= new HelpMenu();
  17119. window->menuBar()->addMenu(helpMenu);
  17120. /*:205*/
  17121. #line 4692 "./typica.w"
  17122. window->show();
  17123. /*:201*/
  17124. #line 4633 "./typica.w"
  17125. }
  17126. file.close();
  17127. }
  17128. return object;
  17129. }
  17130. /*:199*//*217:*/
  17131. #line 4839 "./typica.w"
  17132. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17133. QStack<QLayout*> *layoutStack)
  17134. {
  17135. if(element.hasAttribute("type"))
  17136. {
  17137. /*218:*/
  17138. #line 4860 "./typica.w"
  17139. QLayout*layout;
  17140. QString layoutType= element.attribute("type");
  17141. if(layoutType=="horizontal")
  17142. {
  17143. layout= new QHBoxLayout;
  17144. layoutStack->push(layout);
  17145. populateBoxLayout(element,widgetStack,layoutStack);
  17146. }
  17147. else if(layoutType=="vertical")
  17148. {
  17149. layout= new QVBoxLayout;
  17150. layoutStack->push(layout);
  17151. populateBoxLayout(element,widgetStack,layoutStack);
  17152. }
  17153. else if(layoutType=="grid")
  17154. {
  17155. layout= new QGridLayout;
  17156. layoutStack->push(layout);
  17157. populateGridLayout(element,widgetStack,layoutStack);
  17158. }
  17159. else if(layoutType=="stack")
  17160. {
  17161. layout= new QStackedLayout;
  17162. layoutStack->push(layout);
  17163. populateStackedLayout(element,widgetStack,layoutStack);
  17164. }
  17165. if(element.hasAttribute("id"))
  17166. {
  17167. layout->setObjectName(element.attribute("id"));
  17168. }
  17169. if(element.hasAttribute("spacing"))
  17170. {
  17171. layout->setSpacing(element.attribute("spacing").toInt());
  17172. }
  17173. if(element.hasAttribute("margin"))
  17174. {
  17175. int m= element.attribute("margin").toInt();
  17176. layout->setContentsMargins(m,m,m,m);
  17177. }
  17178. /*:218*/
  17179. #line 4845 "./typica.w"
  17180. QWidget*widget= widgetStack->top();
  17181. if(layout)
  17182. {
  17183. widget->setLayout(layout);
  17184. }
  17185. layoutStack->pop();
  17186. }
  17187. }
  17188. /*:217*//*219:*/
  17189. #line 4907 "./typica.w"
  17190. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17191. QStack<QLayout*> *layoutStack)
  17192. {
  17193. QDomNodeList children= element.childNodes();
  17194. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  17195. for(int i= 0;i<children.count();i++)
  17196. {
  17197. QDomNode current;
  17198. QDomElement currentElement;
  17199. current= children.at(i);
  17200. if(current.isElement())
  17201. {
  17202. currentElement= current.toElement();
  17203. if(currentElement.tagName()=="page")
  17204. {
  17205. QWidget*widget= new QWidget;
  17206. layout->addWidget(widget);
  17207. widgetStack->push(widget);
  17208. currentElement.setAttribute("trcontext","configuration");
  17209. populateWidget(currentElement,widgetStack,layoutStack);
  17210. widgetStack->pop();
  17211. }
  17212. }
  17213. }
  17214. }
  17215. /*:219*//*221:*/
  17216. #line 4946 "./typica.w"
  17217. void addTabBarToLayout(QDomElement element,QStack<QWidget*> *,QStack<QLayout*> *layoutStack)
  17218. {
  17219. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17220. QTabBar*widget= new QTabBar;
  17221. layout->addWidget(widget);
  17222. if(!element.attribute("id").isEmpty())
  17223. {
  17224. widget->setObjectName(element.attribute("id"));
  17225. }
  17226. }
  17227. /*:221*//*223:*/
  17228. #line 4968 "./typica.w"
  17229. QScriptValue constructQTabBar(QScriptContext*,QScriptEngine*engine)
  17230. {
  17231. QScriptValue object= engine->newQObject(new QTabBar);
  17232. setQTabBarProperties(object,engine);
  17233. return object;
  17234. }
  17235. /*:223*//*224:*/
  17236. #line 4979 "./typica.w"
  17237. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine)
  17238. {
  17239. setQWidgetProperties(value,engine);
  17240. value.setProperty("addTab",engine->newFunction(QTabBar_addTab));
  17241. }
  17242. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*)
  17243. {
  17244. QTabBar*self= getself<QTabBar*> (context);
  17245. if(context->argumentCount()> 0)
  17246. {
  17247. self->addTab(argument<QString> (0,context));
  17248. }
  17249. else
  17250. {
  17251. context->throwError("Incorrect number of arguments passed to "
  17252. "QTabBar::addTab().");
  17253. }
  17254. return QScriptValue();
  17255. }
  17256. /*:224*//*226:*/
  17257. #line 5014 "./typica.w"
  17258. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17259. QStack<QLayout*> *layoutStack)
  17260. {
  17261. QDomNodeList children= element.childNodes();
  17262. int row= -1;
  17263. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  17264. for(int i= 0;i<children.count();i++)
  17265. {
  17266. QDomNode current;
  17267. QDomElement currentElement;
  17268. current= children.at(i);
  17269. if(current.isElement())
  17270. {
  17271. currentElement= current.toElement();
  17272. if(currentElement.tagName()=="row")
  17273. {
  17274. row++;
  17275. if(currentElement.hasAttribute("height"))
  17276. {
  17277. layout->setRowMinimumHeight(row,
  17278. currentElement.attribute("height").toInt());
  17279. }
  17280. if(currentElement.hasAttribute("stretch"))
  17281. {
  17282. layout->setRowStretch(row,
  17283. currentElement.attribute("stretch").toInt());
  17284. }
  17285. /*227:*/
  17286. #line 5070 "./typica.w"
  17287. int column= -1;
  17288. QDomNodeList rowChildren= currentElement.childNodes();
  17289. for(int j= 0;j<rowChildren.count();j++)
  17290. {
  17291. QDomNode columnNode;
  17292. QDomElement columnElement;
  17293. columnNode= rowChildren.at(j);
  17294. if(columnNode.isElement())
  17295. {
  17296. columnElement= columnNode.toElement();
  17297. if(columnElement.tagName()=="column")
  17298. {
  17299. column++;
  17300. if(columnElement.hasAttribute("column"))
  17301. {
  17302. column= columnElement.attribute("column").toInt();
  17303. }
  17304. if(columnElement.hasAttribute("width"))
  17305. {
  17306. layout->setColumnMinimumWidth(column,
  17307. columnElement.attribute("width").toInt());
  17308. }
  17309. if(columnElement.hasAttribute("stretch"))
  17310. {
  17311. layout->setColumnStretch(column,
  17312. columnElement.attribute("stretch").toInt());
  17313. }
  17314. int hspan= 1;
  17315. int vspan= 1;
  17316. if(columnElement.hasAttribute("rowspan"))
  17317. {
  17318. vspan= columnElement.attribute("rowspan").toInt();
  17319. }
  17320. if(columnElement.hasAttribute("colspan"))
  17321. {
  17322. hspan= columnElement.attribute("colspan").toInt();
  17323. }
  17324. QHBoxLayout*cell= new QHBoxLayout;
  17325. layout->addLayout(cell,row,column,vspan,hspan);
  17326. layoutStack->push(cell);
  17327. columnElement.setAttribute("trcontext","configuration");
  17328. populateBoxLayout(columnElement,widgetStack,layoutStack);
  17329. layoutStack->pop();
  17330. }
  17331. }
  17332. }
  17333. /*:227*/
  17334. #line 5042 "./typica.w"
  17335. }
  17336. }
  17337. }
  17338. }
  17339. /*:226*//*228:*/
  17340. #line 5121 "./typica.w"
  17341. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17342. QStack<QLayout*> *layoutStack)
  17343. {
  17344. QDomNodeList children= element.childNodes();
  17345. for(int i= 0;i<children.count();i++)
  17346. {
  17347. QDomNode current;
  17348. QDomElement currentElement;
  17349. current= children.at(i);
  17350. if(current.isElement())
  17351. {
  17352. currentElement= current.toElement();
  17353. currentElement.setAttribute("trcontext","configuration");
  17354. if(currentElement.tagName()=="button")
  17355. {
  17356. addButtonToLayout(currentElement,widgetStack,layoutStack);
  17357. }
  17358. else if(currentElement.tagName()=="calendar")
  17359. {
  17360. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  17361. }
  17362. else if(currentElement.tagName()=="timeedit")
  17363. {
  17364. addTimeEditToLayout(currentElement,widgetStack,layoutStack);
  17365. }
  17366. else if(currentElement.tagName()=="decoration")
  17367. {
  17368. addDecorationToLayout(currentElement,widgetStack,
  17369. layoutStack);
  17370. }
  17371. else if(currentElement.tagName()=="layout")
  17372. {
  17373. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  17374. }
  17375. else if(currentElement.tagName()=="splitter")
  17376. {
  17377. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  17378. }
  17379. else if(currentElement.tagName()=="label")
  17380. {
  17381. QBoxLayout*layout=
  17382. qobject_cast<QBoxLayout*> (layoutStack->top());
  17383. QLabel*label= new QLabel(QCoreApplication::translate(
  17384. "configuration",
  17385. currentElement.text().toUtf8().data()));
  17386. layout->addWidget(label);
  17387. }
  17388. else if(currentElement.tagName()=="lcdtemperature")
  17389. {
  17390. addTemperatureDisplayToLayout(currentElement,widgetStack,
  17391. layoutStack);
  17392. }
  17393. else if(currentElement.tagName()=="lcdtimer")
  17394. {
  17395. addTimerDisplayToLayout(currentElement,widgetStack,
  17396. layoutStack);
  17397. }
  17398. else if(currentElement.tagName()=="line")
  17399. {
  17400. addLineToLayout(currentElement,widgetStack,layoutStack);
  17401. }
  17402. else if(currentElement.tagName()=="report")
  17403. {
  17404. addReportToLayout(currentElement,widgetStack,layoutStack);
  17405. }
  17406. else if(currentElement.tagName()=="sqldrop")
  17407. {
  17408. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  17409. }
  17410. else if(currentElement.tagName()=="sqltablearray")
  17411. {
  17412. addSaltToLayout(currentElement,widgetStack,layoutStack);
  17413. }
  17414. else if(currentElement.tagName()=="sqlview")
  17415. {
  17416. addSqlQueryViewToLayout(currentElement,widgetStack,
  17417. layoutStack);
  17418. }
  17419. else if(currentElement.tagName()=="textarea")
  17420. {
  17421. addTextToLayout(currentElement,widgetStack,layoutStack);
  17422. }
  17423. else if(currentElement.tagName()=="spinbox")
  17424. {
  17425. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  17426. }
  17427. else if(currentElement.tagName()=="formarray")
  17428. {
  17429. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  17430. }
  17431. else if(currentElement.tagName()=="hscale")
  17432. {
  17433. addScaleControlToLayout(currentElement,widgetStack,
  17434. layoutStack);
  17435. }
  17436. else if(currentElement.tagName()=="vscale")
  17437. {
  17438. addIntensityControlToLayout(currentElement,widgetStack,
  17439. layoutStack);
  17440. }
  17441. else if(currentElement.tagName()=="webview")
  17442. {
  17443. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  17444. }
  17445. else if(currentElement.tagName()=="stretch")
  17446. {
  17447. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17448. layout->addStretch();
  17449. }
  17450. /*54:*/
  17451. #line 1527 "./typica.w"
  17452. else if(currentElement.tagName()=="svgwidget")
  17453. {
  17454. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  17455. }
  17456. /*:54*//*220:*/
  17457. #line 4938 "./typica.w"
  17458. else if(currentElement.tagName()=="tabbar")
  17459. {
  17460. addTabBarToLayout(currentElement,widgetStack,layoutStack);
  17461. }
  17462. /*:220*//*596:*/
  17463. #line 111 "./printerselector.w"
  17464. else if(currentElement.tagName()=="printerselector")
  17465. {
  17466. addPrinterSelectorToLayout(currentElement,widgetStack,layoutStack);
  17467. }
  17468. #line 12760 "./typica.w"
  17469. /*:596*//*710:*/
  17470. #line 453 "./daterangeselector.w"
  17471. else if(currentElement.tagName()=="daterange")
  17472. {
  17473. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  17474. }
  17475. /*:710*/
  17476. #line 5231 "./typica.w"
  17477. }
  17478. }
  17479. }
  17480. /*:228*//*229:*/
  17481. #line 5239 "./typica.w"
  17482. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17483. QStack<QLayout*> *layoutStack)
  17484. {
  17485. QLayout*targetLayout= layoutStack->pop();
  17486. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  17487. if(element.hasAttribute("type"))
  17488. {
  17489. /*218:*/
  17490. #line 4860 "./typica.w"
  17491. QLayout*layout;
  17492. QString layoutType= element.attribute("type");
  17493. if(layoutType=="horizontal")
  17494. {
  17495. layout= new QHBoxLayout;
  17496. layoutStack->push(layout);
  17497. populateBoxLayout(element,widgetStack,layoutStack);
  17498. }
  17499. else if(layoutType=="vertical")
  17500. {
  17501. layout= new QVBoxLayout;
  17502. layoutStack->push(layout);
  17503. populateBoxLayout(element,widgetStack,layoutStack);
  17504. }
  17505. else if(layoutType=="grid")
  17506. {
  17507. layout= new QGridLayout;
  17508. layoutStack->push(layout);
  17509. populateGridLayout(element,widgetStack,layoutStack);
  17510. }
  17511. else if(layoutType=="stack")
  17512. {
  17513. layout= new QStackedLayout;
  17514. layoutStack->push(layout);
  17515. populateStackedLayout(element,widgetStack,layoutStack);
  17516. }
  17517. if(element.hasAttribute("id"))
  17518. {
  17519. layout->setObjectName(element.attribute("id"));
  17520. }
  17521. if(element.hasAttribute("spacing"))
  17522. {
  17523. layout->setSpacing(element.attribute("spacing").toInt());
  17524. }
  17525. if(element.hasAttribute("margin"))
  17526. {
  17527. int m= element.attribute("margin").toInt();
  17528. layout->setContentsMargins(m,m,m,m);
  17529. }
  17530. /*:218*/
  17531. #line 5247 "./typica.w"
  17532. boxLayout->addLayout(layout);
  17533. layoutStack->pop();
  17534. }
  17535. layoutStack->push(targetLayout);
  17536. }
  17537. /*:229*//*230:*/
  17538. #line 5258 "./typica.w"
  17539. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17540. QStack<QLayout*> *layoutStack)
  17541. {
  17542. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17543. QSplitter*splitter= new(QSplitter);
  17544. layout->addWidget(splitter);
  17545. /*231:*/
  17546. #line 5271 "./typica.w"
  17547. QString orientation= element.attribute("type");
  17548. if(orientation=="horizontal")
  17549. {
  17550. splitter->setOrientation(Qt::Horizontal);
  17551. }
  17552. else if(orientation=="vertical")
  17553. {
  17554. splitter->setOrientation(Qt::Vertical);
  17555. }
  17556. QString id= element.attribute("id");
  17557. if(!id.isEmpty())
  17558. {
  17559. splitter->setObjectName(id);
  17560. }
  17561. if(element.hasChildNodes())
  17562. {
  17563. widgetStack->push(splitter);
  17564. populateSplitter(element,widgetStack,layoutStack);
  17565. widgetStack->pop();
  17566. }
  17567. /*:231*/
  17568. #line 5265 "./typica.w"
  17569. }
  17570. /*:230*//*232:*/
  17571. #line 5297 "./typica.w"
  17572. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17573. QStack<QLayout*> *layoutStack)
  17574. {
  17575. QDomNodeList children= element.childNodes();
  17576. for(int i= 0;i<children.count();i++)
  17577. {
  17578. QDomNode current;
  17579. QDomElement currentElement;
  17580. current= children.at(i);
  17581. if(current.isElement())
  17582. {
  17583. currentElement= current.toElement();
  17584. currentElement.setAttribute("trcontext","configuration");
  17585. if(currentElement.tagName()=="decoration")
  17586. {
  17587. addDecorationToSplitter(currentElement,widgetStack,
  17588. layoutStack);
  17589. }
  17590. else if(currentElement.tagName()=="graph")
  17591. {
  17592. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  17593. }
  17594. else if(currentElement.tagName()=="splitter")
  17595. {
  17596. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  17597. }
  17598. else if(currentElement.tagName()=="lcdtemperature")
  17599. {
  17600. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  17601. layoutStack);
  17602. }
  17603. else if(currentElement.tagName()=="lcdtimer")
  17604. {
  17605. addTimerDisplayToSplitter(currentElement,widgetStack,
  17606. layoutStack);
  17607. }
  17608. else if(currentElement.tagName()=="measurementtable")
  17609. {
  17610. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  17611. }
  17612. else if(currentElement.tagName()=="widget")
  17613. {
  17614. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  17615. }
  17616. }
  17617. }
  17618. }
  17619. /*:232*//*233:*/
  17620. #line 5348 "./typica.w"
  17621. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17622. QStack<QLayout*> *layoutStack)
  17623. {
  17624. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  17625. QSplitter*splitter= new(QSplitter);
  17626. splitter->setParent(parent);
  17627. parent->addWidget(splitter);
  17628. /*231:*/
  17629. #line 5271 "./typica.w"
  17630. QString orientation= element.attribute("type");
  17631. if(orientation=="horizontal")
  17632. {
  17633. splitter->setOrientation(Qt::Horizontal);
  17634. }
  17635. else if(orientation=="vertical")
  17636. {
  17637. splitter->setOrientation(Qt::Vertical);
  17638. }
  17639. QString id= element.attribute("id");
  17640. if(!id.isEmpty())
  17641. {
  17642. splitter->setObjectName(id);
  17643. }
  17644. if(element.hasChildNodes())
  17645. {
  17646. widgetStack->push(splitter);
  17647. populateSplitter(element,widgetStack,layoutStack);
  17648. widgetStack->pop();
  17649. }
  17650. /*:231*/
  17651. #line 5356 "./typica.w"
  17652. }
  17653. /*:233*//*234:*/
  17654. #line 5365 "./typica.w"
  17655. void addTemperatureDisplayToSplitter(QDomElement element,
  17656. QStack<QWidget*> *widgetStack,
  17657. QStack<QLayout*> *)
  17658. {
  17659. TemperatureDisplay*display= new(TemperatureDisplay);
  17660. if(element.hasAttribute("id"))
  17661. {
  17662. display->setObjectName(element.attribute("id"));
  17663. }
  17664. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17665. splitter->addWidget(display);
  17666. }
  17667. void addTemperatureDisplayToLayout(QDomElement element,
  17668. QStack<QWidget*> *,
  17669. QStack<QLayout*> *layoutStack)
  17670. {
  17671. TemperatureDisplay*display= new(TemperatureDisplay);
  17672. if(element.hasAttribute("id"))
  17673. {
  17674. display->setObjectName(element.attribute("id"));
  17675. }
  17676. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17677. layout->addWidget(display);
  17678. }
  17679. /*:234*//*235:*/
  17680. #line 5396 "./typica.w"
  17681. void addTimerDisplayToSplitter(QDomElement element,
  17682. QStack<QWidget*> *widgetStack,
  17683. QStack<QLayout*> *)
  17684. {
  17685. TimerDisplay*display= new(TimerDisplay);
  17686. if(element.hasAttribute("id"))
  17687. {
  17688. display->setObjectName(element.attribute("id"));
  17689. }
  17690. if(element.hasAttribute("format"))
  17691. {
  17692. display->setDisplayFormat(element.attribute("format"));
  17693. }
  17694. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17695. splitter->addWidget(display);
  17696. }
  17697. void addTimerDisplayToLayout(QDomElement element,
  17698. QStack<QWidget*> *,
  17699. QStack<QLayout*> *layoutStack)
  17700. {
  17701. TimerDisplay*display= new(TimerDisplay);
  17702. if(element.hasAttribute("id"))
  17703. {
  17704. display->setObjectName(element.attribute("id"));
  17705. }
  17706. if(element.hasAttribute("format"))
  17707. {
  17708. display->setDisplayFormat(element.attribute("format"));
  17709. }
  17710. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17711. layout->addWidget(display);
  17712. }
  17713. /*:235*//*236:*/
  17714. #line 5434 "./typica.w"
  17715. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  17716. QStack<QLayout*> *layoutStack)
  17717. {
  17718. /*237:*/
  17719. #line 5455 "./typica.w"
  17720. QString labelText=
  17721. QCoreApplication::translate("configuration",
  17722. element.attribute("name").toUtf8().data());
  17723. Qt::Orientations orientation= Qt::Horizontal;
  17724. if(element.hasAttribute("type"))
  17725. {
  17726. if(element.attribute("type")=="horizontal")
  17727. {
  17728. orientation= Qt::Horizontal;
  17729. }
  17730. else if(element.attribute("type")=="vertical")
  17731. {
  17732. orientation= Qt::Vertical;
  17733. }
  17734. }
  17735. /*238:*/
  17736. #line 5482 "./typica.w"
  17737. QWidget*theWidget= NULL;
  17738. QDomNodeList children= element.childNodes();
  17739. for(int i= 0;i<children.count();i++)
  17740. {
  17741. QDomNode item= children.at(i);
  17742. if(item.isElement())
  17743. {
  17744. QDomElement itemElement= item.toElement();
  17745. if(itemElement.tagName()=="lcdtemperature")
  17746. {
  17747. TemperatureDisplay*display= new TemperatureDisplay;
  17748. if(itemElement.hasAttribute("id"))
  17749. {
  17750. display->setObjectName(itemElement.attribute("id"));
  17751. }
  17752. theWidget= display;
  17753. }
  17754. else if(itemElement.tagName()=="lcdtimer")
  17755. {
  17756. TimerDisplay*display= new TimerDisplay;
  17757. if(itemElement.hasAttribute("id"))
  17758. {
  17759. display->setObjectName(itemElement.attribute("id"));
  17760. }
  17761. if(itemElement.hasAttribute("format"))
  17762. {
  17763. display->setDisplayFormat(itemElement.attribute("format"));
  17764. }
  17765. theWidget= display;
  17766. }
  17767. }
  17768. }
  17769. /*:238*/
  17770. #line 5471 "./typica.w"
  17771. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17772. orientation);
  17773. if(element.hasAttribute("id"))
  17774. {
  17775. decoration->setObjectName(element.attribute("id"));
  17776. }
  17777. /*:237*/
  17778. #line 5438 "./typica.w"
  17779. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17780. layout->addWidget(decoration);
  17781. }
  17782. void addDecorationToSplitter(QDomElement element,
  17783. QStack<QWidget*> *widgetStack,
  17784. QStack<QLayout*> *)
  17785. {
  17786. /*237:*/
  17787. #line 5455 "./typica.w"
  17788. QString labelText=
  17789. QCoreApplication::translate("configuration",
  17790. element.attribute("name").toUtf8().data());
  17791. Qt::Orientations orientation= Qt::Horizontal;
  17792. if(element.hasAttribute("type"))
  17793. {
  17794. if(element.attribute("type")=="horizontal")
  17795. {
  17796. orientation= Qt::Horizontal;
  17797. }
  17798. else if(element.attribute("type")=="vertical")
  17799. {
  17800. orientation= Qt::Vertical;
  17801. }
  17802. }
  17803. /*238:*/
  17804. #line 5482 "./typica.w"
  17805. QWidget*theWidget= NULL;
  17806. QDomNodeList children= element.childNodes();
  17807. for(int i= 0;i<children.count();i++)
  17808. {
  17809. QDomNode item= children.at(i);
  17810. if(item.isElement())
  17811. {
  17812. QDomElement itemElement= item.toElement();
  17813. if(itemElement.tagName()=="lcdtemperature")
  17814. {
  17815. TemperatureDisplay*display= new TemperatureDisplay;
  17816. if(itemElement.hasAttribute("id"))
  17817. {
  17818. display->setObjectName(itemElement.attribute("id"));
  17819. }
  17820. theWidget= display;
  17821. }
  17822. else if(itemElement.tagName()=="lcdtimer")
  17823. {
  17824. TimerDisplay*display= new TimerDisplay;
  17825. if(itemElement.hasAttribute("id"))
  17826. {
  17827. display->setObjectName(itemElement.attribute("id"));
  17828. }
  17829. if(itemElement.hasAttribute("format"))
  17830. {
  17831. display->setDisplayFormat(itemElement.attribute("format"));
  17832. }
  17833. theWidget= display;
  17834. }
  17835. }
  17836. }
  17837. /*:238*/
  17838. #line 5471 "./typica.w"
  17839. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17840. orientation);
  17841. if(element.hasAttribute("id"))
  17842. {
  17843. decoration->setObjectName(element.attribute("id"));
  17844. }
  17845. /*:237*/
  17846. #line 5447 "./typica.w"
  17847. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17848. splitter->addWidget(decoration);
  17849. }
  17850. /*:236*//*239:*/
  17851. #line 5521 "./typica.w"
  17852. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17853. QStack<QLayout*> *layoutStack)
  17854. {
  17855. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17856. QWidget*widget= new QWidget;
  17857. if(element.hasAttribute("id"))
  17858. {
  17859. widget->setObjectName(element.attribute("id"));
  17860. }
  17861. splitter->addWidget(widget);
  17862. if(element.hasChildNodes())
  17863. {
  17864. widgetStack->push(widget);
  17865. populateWidget(element,widgetStack,layoutStack);
  17866. widgetStack->pop();
  17867. }
  17868. }
  17869. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17870. QStack<QLayout*> *layoutStack)
  17871. {
  17872. QDomNodeList children= element.childNodes();
  17873. for(int i= 0;i<children.count();i++)
  17874. {
  17875. QDomNode current;
  17876. QDomElement currentElement;
  17877. current= children.at(i);
  17878. if(current.isElement())
  17879. {
  17880. currentElement= current.toElement();
  17881. if(currentElement.tagName()=="layout")
  17882. {
  17883. currentElement.setAttribute("trcontext","configuration");
  17884. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  17885. }
  17886. }
  17887. }
  17888. }
  17889. /*:239*//*240:*/
  17890. #line 5565 "./typica.w"
  17891. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  17892. QStack<QLayout*> *layoutStack)
  17893. {
  17894. QAbstractButton*button= NULL;
  17895. QString text=
  17896. QCoreApplication::translate("configuration",
  17897. element.attribute("name").toUtf8().data());
  17898. if(element.hasAttribute("type"))
  17899. {
  17900. QString type= element.attribute("type");
  17901. if(type=="annotation")
  17902. {
  17903. AnnotationButton*abutton= new AnnotationButton(text);
  17904. if(element.hasAttribute("annotation"))
  17905. {
  17906. abutton->setAnnotation(element.attribute("annotation"));
  17907. }
  17908. if(element.hasAttribute("series"))
  17909. {
  17910. abutton->setTemperatureColumn(element.attribute("series").
  17911. toInt());
  17912. }
  17913. if(element.hasAttribute("column"))
  17914. {
  17915. abutton->setAnnotationColumn(element.attribute("column").
  17916. toInt());
  17917. }
  17918. button= abutton;
  17919. }
  17920. else if(type=="check")
  17921. {
  17922. button= new QCheckBox(text);
  17923. }
  17924. else if(type=="push")
  17925. {
  17926. button= new QPushButton(text);
  17927. }
  17928. }
  17929. if(element.hasAttribute("id"))
  17930. {
  17931. button->setObjectName(element.attribute("id"));
  17932. }
  17933. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17934. layout->addWidget(button);
  17935. }
  17936. /*:240*//*241:*/
  17937. #line 5619 "./typica.w"
  17938. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  17939. QStack<QLayout*> *layoutStack)
  17940. {
  17941. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  17942. if(element.hasAttribute("pretext"))
  17943. {
  17944. box->setPretext(QCoreApplication::translate(
  17945. "configuration",
  17946. element.attribute("pretext").toUtf8().data()));
  17947. }
  17948. if(element.hasAttribute("posttext"))
  17949. {
  17950. box->setPosttext(QCoreApplication::translate(
  17951. "configuration",
  17952. element.attribute("posttext").toUtf8().data()));
  17953. }
  17954. if(element.hasAttribute("series"))
  17955. {
  17956. box->setTemperatureColumn(element.attribute("series").toInt());
  17957. }
  17958. if(element.hasAttribute("column"))
  17959. {
  17960. box->setAnnotationColumn(element.attribute("column").toInt());
  17961. }
  17962. if(element.hasAttribute("min"))
  17963. {
  17964. box->setMinimum(element.attribute("min").toDouble());
  17965. }
  17966. if(element.hasAttribute("max"))
  17967. {
  17968. box->setMaximum(element.attribute("max").toDouble());
  17969. }
  17970. if(element.hasAttribute("decimals"))
  17971. {
  17972. box->setDecimals(element.attribute("decimals").toInt());
  17973. }
  17974. if(element.hasAttribute("step"))
  17975. {
  17976. box->setSingleStep(element.attribute("step").toDouble());
  17977. }
  17978. if(element.hasAttribute("id"))
  17979. {
  17980. box->setObjectName(element.attribute("id"));
  17981. }
  17982. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17983. layout->addWidget(box);
  17984. }
  17985. /*:241*//*242:*/
  17986. #line 5679 "./typica.w"
  17987. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17988. QStack<QLayout*> *)
  17989. {
  17990. ZoomLog*widget= new ZoomLog;
  17991. if(element.hasAttribute("id"))
  17992. {
  17993. widget->setObjectName(element.attribute("id"));
  17994. }
  17995. if(element.hasChildNodes())
  17996. {
  17997. QDomNodeList children= element.childNodes();
  17998. int column= 0;
  17999. for(int i= 0;i<children.count();i++)
  18000. {
  18001. QDomNode current;
  18002. QDomElement currentElement;
  18003. current= children.at(i);
  18004. if(current.isElement())
  18005. {
  18006. currentElement= current.toElement();
  18007. if(currentElement.tagName()=="column")
  18008. {
  18009. QString text=
  18010. QCoreApplication::translate(
  18011. "configuration",
  18012. currentElement.text().toUtf8().data());
  18013. widget->setHeaderData(column,text);
  18014. column++;
  18015. }
  18016. }
  18017. }
  18018. }
  18019. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18020. if(splitter)
  18021. {
  18022. splitter->addWidget(widget);
  18023. }
  18024. else
  18025. {
  18026. qDebug()<<"Splitter not found at top of widget stack!";
  18027. }
  18028. }
  18029. /*:242*//*243:*/
  18030. #line 5726 "./typica.w"
  18031. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18032. QStack<QLayout*> *)
  18033. {
  18034. GraphView*view= new GraphView;
  18035. if(element.hasAttribute("id"))
  18036. {
  18037. view->setObjectName(element.attribute("id"));
  18038. }
  18039. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18040. splitter->addWidget(view);
  18041. }
  18042. /*:243*//*244:*/
  18043. #line 5743 "./typica.w"
  18044. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  18045. QStack<QLayout*> *layoutStack)
  18046. {
  18047. SqlComboBox*box= new SqlComboBox();
  18048. if(element.hasAttribute("data"))
  18049. {
  18050. box->setDataColumn(element.attribute("data").toInt());
  18051. }
  18052. if(element.hasAttribute("display"))
  18053. {
  18054. box->setDisplayColumn(element.attribute("display").toInt());
  18055. }
  18056. if(element.hasAttribute("showdata"))
  18057. {
  18058. if(element.attribute("showdata")=="true")
  18059. {
  18060. box->showData(true);
  18061. }
  18062. }
  18063. if(element.hasAttribute("editable"))
  18064. {
  18065. if(element.attribute("editable")=="true")
  18066. {
  18067. box->setEditable(true);
  18068. }
  18069. }
  18070. if(element.hasChildNodes())
  18071. {
  18072. QDomNodeList children= element.childNodes();
  18073. for(int i= 0;i<children.count();i++)
  18074. {
  18075. QDomNode current;
  18076. QDomElement currentElement;
  18077. current= children.at(i);
  18078. if(current.isElement())
  18079. {
  18080. currentElement= current.toElement();
  18081. if(currentElement.tagName()=="null")
  18082. {
  18083. box->addNullOption();
  18084. }
  18085. else if(currentElement.tagName()=="query")
  18086. {
  18087. box->addSqlOptions(currentElement.text());
  18088. }
  18089. }
  18090. }
  18091. }
  18092. if(element.hasAttribute("id"))
  18093. {
  18094. box->setObjectName(element.attribute("id"));
  18095. }
  18096. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18097. layout->addWidget(box);
  18098. }
  18099. /*:244*//*245:*/
  18100. #line 5822 "./typica.w"
  18101. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  18102. QStack<QLayout*> *layoutStack)
  18103. {
  18104. QTableView*view= new QTableView;
  18105. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  18106. SaltModel*model= new SaltModel(element.childNodes().count());
  18107. if(element.hasAttribute("id"))
  18108. {
  18109. view->setObjectName(element.attribute("id"));
  18110. }
  18111. if(element.hasChildNodes())
  18112. {
  18113. QDomNodeList children= element.childNodes();
  18114. int currentColumn= 0;
  18115. for(int i= 0;i<children.count();i++)
  18116. {
  18117. QDomNode current;
  18118. QDomElement currentElement;
  18119. current= children.at(i);
  18120. if(current.isElement())
  18121. {
  18122. currentElement= current.toElement();
  18123. if(currentElement.tagName()=="column")
  18124. {
  18125. if(currentElement.hasAttribute("name"))
  18126. {
  18127. model->setHeaderData(currentColumn,
  18128. Qt::Horizontal,
  18129. QCoreApplication::translate(
  18130. "configuration",
  18131. currentElement.attribute("name").toUtf8().data()));
  18132. }
  18133. if(currentElement.hasAttribute("delegate"))
  18134. {
  18135. /*246:*/
  18136. #line 5873 "./typica.w"
  18137. if(currentElement.attribute("delegate")=="sql")
  18138. {
  18139. /*247:*/
  18140. #line 5889 "./typica.w"
  18141. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  18142. SqlComboBox*widget= new SqlComboBox();
  18143. if(currentElement.hasAttribute("nulltext"))
  18144. {
  18145. widget->setNullText(currentElement.attribute("nulltext"));
  18146. }
  18147. if(currentElement.hasAttribute("nulldata"))
  18148. {
  18149. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  18150. }
  18151. if(currentElement.hasAttribute("null"))
  18152. {
  18153. if(currentElement.attribute("null")=="true")
  18154. {
  18155. widget->addNullOption();
  18156. }
  18157. }
  18158. if(currentElement.hasAttribute("showdata"))
  18159. {
  18160. if(currentElement.attribute("showdata")=="true")
  18161. {
  18162. widget->showData(true);
  18163. }
  18164. }
  18165. if(currentElement.hasAttribute("data"))
  18166. {
  18167. widget->setDataColumn(currentElement.attribute("data").toInt());
  18168. }
  18169. if(currentElement.hasAttribute("display"))
  18170. {
  18171. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  18172. }
  18173. widget->addSqlOptions(currentElement.text());
  18174. delegate->setWidget(widget);
  18175. view->setItemDelegateForColumn(currentColumn,delegate);
  18176. /*:247*/
  18177. #line 5876 "./typica.w"
  18178. }
  18179. else if(currentElement.attribute("delegate")=="numeric")
  18180. {
  18181. /*248:*/
  18182. #line 5930 "./typica.w"
  18183. NumericDelegate*delegate= new NumericDelegate;
  18184. view->setItemDelegateForColumn(currentColumn,delegate);
  18185. /*:248*/
  18186. #line 5880 "./typica.w"
  18187. }
  18188. /*:246*/
  18189. #line 5857 "./typica.w"
  18190. }
  18191. currentColumn++;
  18192. }
  18193. }
  18194. }
  18195. }
  18196. view->setModel(model);
  18197. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18198. layout->addWidget(view);
  18199. }
  18200. /*:245*//*260:*/
  18201. #line 6103 "./typica.w"
  18202. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  18203. QStack<QLayout*> *layoutStack)
  18204. {
  18205. QLineEdit*widget= new QLineEdit(element.text());
  18206. if(element.hasAttribute("id"))
  18207. {
  18208. widget->setObjectName(element.attribute("id"));
  18209. }
  18210. if(element.hasAttribute("writable"))
  18211. {
  18212. if(element.attribute("writable")=="false")
  18213. {
  18214. widget->setReadOnly(true);
  18215. }
  18216. }
  18217. if(element.hasAttribute("validator"))
  18218. {
  18219. if(element.attribute("validator")=="numeric")
  18220. {
  18221. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  18222. }
  18223. else if(element.attribute("validator")=="integer")
  18224. {
  18225. widget->setValidator(new ScriptValidator(new QIntValidator));
  18226. }
  18227. else if(element.attribute("validator")=="expression"&&
  18228. element.hasAttribute("expression"))
  18229. {
  18230. widget->setValidator(new QRegExpValidator(
  18231. QRegExp(element.attribute("expression")),
  18232. NULL));
  18233. }
  18234. }
  18235. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18236. layout->addWidget(widget);
  18237. }
  18238. /*:260*//*261:*/
  18239. #line 6144 "./typica.w"
  18240. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  18241. QStack<QLayout*> *layoutStack)
  18242. {
  18243. QTextEdit*widget= new QTextEdit;
  18244. if(element.hasAttribute("id"))
  18245. {
  18246. widget->setObjectName(element.attribute("id"));
  18247. }
  18248. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18249. layout->addWidget(widget);
  18250. }
  18251. /*:261*//*262:*/
  18252. #line 6161 "./typica.w"
  18253. void addSqlQueryViewToLayout(QDomElement element,
  18254. QStack<QWidget*> *,
  18255. QStack<QLayout*> *layoutStack)
  18256. {
  18257. SqlQueryView*view= new SqlQueryView;
  18258. if(element.hasAttribute("id"))
  18259. {
  18260. view->setObjectName(element.attribute("id"));
  18261. }
  18262. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18263. layout->addWidget(view);
  18264. }
  18265. /*:262*//*263:*/
  18266. #line 6178 "./typica.w"
  18267. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  18268. QStack<QLayout*> *layoutStack)
  18269. {
  18270. QWidget*widget;
  18271. if(element.hasAttribute("time"))
  18272. {
  18273. if(element.attribute("time")=="true")
  18274. {
  18275. QDateTimeEdit*edit= new QDateTimeEdit;
  18276. edit->setDateTime(QDateTime::currentDateTime());
  18277. edit->setCalendarPopup(true);
  18278. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  18279. widget= qobject_cast<QWidget*> (edit);
  18280. }
  18281. else
  18282. {
  18283. QDateEdit*edit= new QDateEdit;
  18284. edit->setDate(QDate::currentDate());
  18285. edit->setCalendarPopup(true);
  18286. edit->setDisplayFormat("yyyy-MM-dd");
  18287. widget= qobject_cast<QWidget*> (edit);
  18288. }
  18289. }
  18290. else
  18291. {
  18292. QDateEdit*edit= new QDateEdit;
  18293. edit->setDate(QDate::currentDate());
  18294. edit->setCalendarPopup(true);
  18295. edit->setDisplayFormat("yyyy-MM-dd");
  18296. widget= qobject_cast<QWidget*> (edit);
  18297. }
  18298. if(element.hasAttribute("id"))
  18299. {
  18300. widget->setObjectName(element.attribute("id"));
  18301. }
  18302. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18303. layout->addWidget(widget);
  18304. }
  18305. /*:263*//*264:*/
  18306. #line 6221 "./typica.w"
  18307. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  18308. {
  18309. setQDateTimeEditProperties(value,engine);
  18310. }
  18311. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  18312. {
  18313. setQAbstractSpinBoxProperties(value,engine);
  18314. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  18315. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  18316. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  18317. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  18318. value.setProperty("setToCurrentTime",
  18319. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  18320. }
  18321. /*:264*//*265:*/
  18322. #line 6243 "./typica.w"
  18323. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  18324. {
  18325. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18326. if(context->argumentCount()==3)
  18327. {
  18328. self->setDate(QDate(argument<int> (0,context),
  18329. argument<int> (1,context),
  18330. argument<int> (2,context)));
  18331. }
  18332. else
  18333. {
  18334. context->throwError("Incorrect number of arguments passed to "
  18335. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  18336. "specifying the year, month, and day.");
  18337. }
  18338. return QScriptValue();
  18339. }
  18340. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  18341. {
  18342. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18343. return QScriptValue(self->date().day());
  18344. }
  18345. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  18346. {
  18347. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18348. return QScriptValue(self->date().month());
  18349. }
  18350. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  18351. {
  18352. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18353. return QScriptValue(self->date().year());
  18354. }
  18355. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  18356. {
  18357. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18358. self->setDateTime(QDateTime::currentDateTime());
  18359. return QScriptValue();
  18360. }
  18361. /*:265*//*267:*/
  18362. #line 6303 "./typica.w"
  18363. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *,
  18364. QStack<QLayout*> *layoutStack)
  18365. {
  18366. QTimeEdit*edit= new QTimeEdit;
  18367. if(element.hasAttribute("displayFormat"))
  18368. {
  18369. edit->setDisplayFormat(element.attribute("displayFormat"));
  18370. }
  18371. else
  18372. {
  18373. edit->setDisplayFormat("mm:ss.zzz");
  18374. }
  18375. if(element.hasAttribute("id"))
  18376. {
  18377. edit->setObjectName(element.attribute("id"));
  18378. }
  18379. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18380. layout->addWidget(edit);
  18381. }
  18382. /*:267*//*268:*/
  18383. #line 6326 "./typica.w"
  18384. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  18385. {
  18386. setQDateTimeEditProperties(value,engine);
  18387. }
  18388. /*:268*//*272:*/
  18389. #line 6355 "./typica.w"
  18390. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  18391. {
  18392. QObject*parent= argument<QObject*> (0,context);
  18393. QString name= argument<QString> (1,context);
  18394. QObject*object= parent->findChild<QObject*> (name);
  18395. QScriptValue value;
  18396. if(object)
  18397. {
  18398. value= engine->newQObject(object);
  18399. QString className= object->metaObject()->className();
  18400. /*273:*/
  18401. #line 6373 "./typica.w"
  18402. if(className=="TemperatureDisplay")
  18403. {
  18404. setTemperatureDisplayProperties(value,engine);
  18405. }
  18406. else if(className=="TimerDisplay")
  18407. {
  18408. setTimerDisplayProperties(value,engine);
  18409. }
  18410. else if(className=="QAction")
  18411. {
  18412. setQActionProperties(value,engine);
  18413. }
  18414. else if(className=="QBoxLayout")
  18415. {
  18416. setQBoxLayoutProperties(value,engine);
  18417. }
  18418. else if(className=="QDateEdit")
  18419. {
  18420. setQDateEditProperties(value,engine);
  18421. }
  18422. else if(className=="QDateTimeEdit")
  18423. {
  18424. setQDateTimeEditProperties(value,engine);
  18425. }
  18426. else if(className=="QFrame")
  18427. {
  18428. setQFrameProperties(value,engine);
  18429. }
  18430. else if(className=="QHBoxLayout")
  18431. {
  18432. setQBoxLayoutProperties(value,engine);
  18433. }
  18434. else if(className=="QLCDNumber")
  18435. {
  18436. setQLCDNumberProperties(value,engine);
  18437. }
  18438. else if(className=="QMenu")
  18439. {
  18440. setQMenuProperties(value,engine);
  18441. }
  18442. else if(className=="QMenuBar")
  18443. {
  18444. setQMenuBarProperties(value,engine);
  18445. }
  18446. else if(className=="QPushButton")
  18447. {
  18448. setQPushButtonProperties(value,engine);
  18449. }
  18450. else if(className=="QSplitter")
  18451. {
  18452. setQSplitterProperties(value,engine);
  18453. }
  18454. else if(className=="QTableView")
  18455. {
  18456. if(object->property("tabletype").isValid())
  18457. {
  18458. if(object->property("tabletype").toString()=="SaltTable")
  18459. {
  18460. setSaltTableProperties(value,engine);
  18461. }
  18462. }
  18463. }
  18464. else if(className=="QVBoxLayout")
  18465. {
  18466. setQBoxLayoutProperties(value,engine);
  18467. }
  18468. else if(className=="QWidget")
  18469. {
  18470. setQWidgetProperties(value,engine);
  18471. }
  18472. else if(className=="ScriptQMainWindow")
  18473. {
  18474. setQMainWindowProperties(value,engine);
  18475. }
  18476. else if(className=="SqlComboBox")
  18477. {
  18478. setSqlComboBoxProperties(value,engine);
  18479. }
  18480. else if(className=="SqlQueryView")
  18481. {
  18482. setSqlQueryViewProperties(value,engine);
  18483. }
  18484. else if(className=="ZoomLog")
  18485. {
  18486. setZoomLogProperties(value,engine);
  18487. }
  18488. else if(className=="QTextEdit")
  18489. {
  18490. setQTextEditProperties(value,engine);
  18491. }
  18492. else if(className=="QWebView")
  18493. {
  18494. setQWebViewProperties(value,engine);
  18495. }
  18496. else if(className=="QLineEdit")
  18497. {
  18498. setQLineEditProperties(value,engine);
  18499. }
  18500. else if(className=="QSvgWidget")
  18501. {
  18502. setQSvgWidgetProperties(value,engine);
  18503. }
  18504. else if(className=="QTabBar")
  18505. {
  18506. setQTabBarProperties(value,engine);
  18507. }
  18508. else if(className=="PrinterSelector")
  18509. {
  18510. setQComboBoxProperties(value,engine);
  18511. }
  18512. /*:273*/
  18513. #line 6366 "./typica.w"
  18514. }
  18515. return value;
  18516. }
  18517. /*:272*//*275:*/
  18518. #line 6514 "./typica.w"
  18519. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  18520. {
  18521. QTableView*self= getself<QTableView*> (context);
  18522. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18523. QString datum;
  18524. double total= 0.0;
  18525. int column= argument<int> (0,context);
  18526. int role= argument<int> (1,context);
  18527. for(int i= 0;i<model->rowCount();i++)
  18528. {
  18529. datum= model->data(model->index(i,column),role).toString();
  18530. if(!datum.isEmpty())
  18531. {
  18532. total+= datum.toDouble();
  18533. }
  18534. }
  18535. return QScriptValue(engine,total);
  18536. }
  18537. /*:275*//*276:*/
  18538. #line 6538 "./typica.w"
  18539. QScriptValue SaltTable_columnArray(QScriptContext*context,
  18540. QScriptEngine*engine)
  18541. {
  18542. QTableView*self= getself<QTableView*> (context);
  18543. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18544. int column= argument<int> (0,context);
  18545. int role= argument<int> (1,context);
  18546. QString literal= model->arrayLiteral(column,role);
  18547. return QScriptValue(engine,literal);
  18548. }
  18549. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  18550. QScriptEngine*engine)
  18551. {
  18552. QTableView*self= getself<QTableView*> (context);
  18553. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18554. int column= argument<int> (0,context);
  18555. int role= argument<int> (1,context);
  18556. QString literal= model->quotedArrayLiteral(column,role);
  18557. return QScriptValue(engine,literal);
  18558. }
  18559. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  18560. QScriptEngine*engine)
  18561. {
  18562. QTableView*self= getself<QTableView*> (context);
  18563. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18564. int column= argument<int> (0,context);
  18565. int role= argument<int> (1,context);
  18566. QString literal= model->arrayLiteral(column,role);
  18567. literal.chop(1);
  18568. literal= literal.remove(0,1);
  18569. return QScriptValue(engine,literal);
  18570. }
  18571. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  18572. QScriptEngine*engine)
  18573. {
  18574. QTableView*self= getself<QTableView*> (context);
  18575. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18576. int column= argument<int> (0,context);
  18577. int role= argument<int> (1,context);
  18578. QString literal= model->quotedArrayLiteral(column,role);
  18579. literal.chop(1);
  18580. literal= literal.remove(0,1);
  18581. return QScriptValue(engine,literal);
  18582. }
  18583. /*:276*//*277:*/
  18584. #line 6590 "./typica.w"
  18585. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  18586. {
  18587. QTableView*self= getself<QTableView*> (context);
  18588. QScriptValue value= engine->newQObject(self->model());
  18589. return value;
  18590. }
  18591. /*:277*//*278:*/
  18592. #line 6604 "./typica.w"
  18593. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  18594. {
  18595. QTableView*self= getself<QTableView*> (context);
  18596. int row= argument<int> (0,context);
  18597. int column= argument<int> (1,context);
  18598. QVariant value= argument<QVariant> (2,context);
  18599. int role= argument<int> (3,context);
  18600. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18601. QModelIndex cell= model->index(row,column);
  18602. model->setData(cell,value,role);
  18603. self->update(cell);
  18604. return QScriptValue();
  18605. }
  18606. /*:278*//*279:*/
  18607. #line 6622 "./typica.w"
  18608. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  18609. {
  18610. QTableView*self= getself<QTableView*> (context);
  18611. int row= argument<int> (0,context);
  18612. int column= argument<int> (1,context);
  18613. int role= argument<int> (2,context);
  18614. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18615. QModelIndex cell= model->index(row,column);
  18616. QVariant value= model->data(cell,role);
  18617. QScriptValue retval= engine->newVariant(value);
  18618. retval.setProperty("value",QScriptValue(value.toString()));
  18619. return retval;
  18620. }
  18621. /*:279*//*280:*/
  18622. #line 6642 "./typica.w"
  18623. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  18624. {
  18625. QTableView*self= getself<QTableView*> (context);
  18626. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18627. model->clear();
  18628. return QScriptValue();
  18629. }
  18630. /*:280*//*281:*/
  18631. #line 6654 "./typica.w"
  18632. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  18633. {
  18634. QTableView*self= getself<QTableView*> (context);
  18635. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18636. int row= argument<int> (0,context);
  18637. return engine->newVariant(model->removeRow(row));
  18638. }
  18639. /*:281*//*282:*/
  18640. #line 6667 "./typica.w"
  18641. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  18642. {
  18643. QTableView*self= getself<QTableView*> (context);
  18644. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18645. QVariant value= argument<QVariant> (0,context);
  18646. int column= argument<int> (1,context);
  18647. return engine->newVariant(model->findData(value,column));
  18648. }
  18649. /*:282*//*283:*/
  18650. #line 6680 "./typica.w"
  18651. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  18652. {
  18653. setQWidgetProperties(value,engine);
  18654. value.setProperty("columnArray",
  18655. engine->newFunction(SaltTable_columnArray));
  18656. value.setProperty("quotedColumnArray",
  18657. engine->newFunction(SaltTable_quotedColumnArray));
  18658. value.setProperty("bindableColumnArray",
  18659. engine->newFunction(SaltTable_bindableColumnArray));
  18660. value.setProperty("bindableQuotedColumnArray",
  18661. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  18662. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  18663. value.setProperty("data",engine->newFunction(SaltTable_data));
  18664. value.setProperty("model",engine->newFunction(SaltTable_model));
  18665. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  18666. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  18667. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  18668. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  18669. }
  18670. /*:283*//*285:*/
  18671. #line 6717 "./typica.w"
  18672. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18673. {
  18674. setQComboBoxProperties(value,engine);
  18675. }
  18676. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18677. {
  18678. setQWidgetProperties(value,engine);
  18679. value.setProperty("currentData",
  18680. engine->newFunction(QComboBox_currentData));
  18681. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  18682. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  18683. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  18684. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  18685. }
  18686. QScriptValue QComboBox_currentData(QScriptContext*context,
  18687. QScriptEngine*engine)
  18688. {
  18689. QComboBox*self= getself<QComboBox*> (context);
  18690. return QScriptValue(engine,
  18691. self->itemData(self->currentIndex()).toString());
  18692. }
  18693. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  18694. {
  18695. QComboBox*self= getself<QComboBox*> (context);
  18696. self->addItem(argument<QString> (0,context));
  18697. return QScriptValue();
  18698. }
  18699. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  18700. {
  18701. QComboBox*self= getself<QComboBox*> (context);
  18702. self->setModel(argument<QAbstractItemModel*> (0,context));
  18703. return QScriptValue();
  18704. }
  18705. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  18706. {
  18707. QComboBox*self= getself<QComboBox*> (context);
  18708. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  18709. }
  18710. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  18711. {
  18712. QComboBox*self= getself<QComboBox*> (context);
  18713. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  18714. }
  18715. #line 1 "./abouttypica.w"
  18716. /*:285*//*298:*/
  18717. #line 401 "./units.w"
  18718. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  18719. {
  18720. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  18721. argument<Units::Unit> (1,context),
  18722. argument<Units::Unit> (2,context)));
  18723. }
  18724. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  18725. QScriptEngine*)
  18726. {
  18727. return QScriptValue(Units::convertRelativeTemperature(
  18728. argument<double> (0,context),
  18729. argument<Units::Unit> (1,context),
  18730. argument<Units::Unit> (2,context)));
  18731. }
  18732. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  18733. {
  18734. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  18735. }
  18736. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  18737. {
  18738. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  18739. argument<Units::Unit> (1,context),
  18740. argument<Units::Unit> (2,context)));
  18741. }
  18742. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  18743. {
  18744. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  18745. }
  18746. /*:298*//*301:*/
  18747. #line 449 "./units.w"
  18748. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  18749. {
  18750. return engine->newVariant(QVariant(value));
  18751. }
  18752. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  18753. {
  18754. value= sv.toVariant().value<Units::Unit> ();
  18755. }
  18756. /*:301*//*311:*/
  18757. #line 149 "./measurement.w"
  18758. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  18759. {
  18760. QScriptValue object;
  18761. if(context->argumentCount()==2||context->argumentCount()==3)
  18762. {
  18763. double measurement= argument<double> (0,context);
  18764. QTime timestamp= argument<QTime> (1,context);
  18765. Units::Unit unit= Units::Fahrenheit;
  18766. if(context->argumentCount()==3)
  18767. {
  18768. unit= argument<Units::Unit> (2,context);
  18769. }
  18770. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  18771. setMeasurementProperties(object,engine);
  18772. }
  18773. else
  18774. {
  18775. context->throwError("Incorrect number of arguments passed to "
  18776. "Measurement::Measurement(). This method takes two "
  18777. "or three arguments.");
  18778. }
  18779. return object;
  18780. }
  18781. /*:311*//*312:*/
  18782. #line 176 "./measurement.w"
  18783. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  18784. {
  18785. }
  18786. /*:312*//*313:*/
  18787. #line 184 "./measurement.w"
  18788. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  18789. {
  18790. QVariant var;
  18791. var.setValue(measurement);
  18792. return engine->newVariant(var);
  18793. }
  18794. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  18795. {
  18796. measurement= value.toVariant().value<Measurement> ();
  18797. }
  18798. #line 6786 "./typica.w"
  18799. /*:313*//*331:*/
  18800. #line 7364 "./typica.w"
  18801. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  18802. {
  18803. QScriptValue object;
  18804. if(context->argumentCount()==1)
  18805. {
  18806. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  18807. QScriptEngine::ScriptOwnership);
  18808. setDAQProperties(object,engine);
  18809. }
  18810. else if(context->argumentCount()==2)
  18811. {
  18812. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  18813. argument<QString> (1,context)),
  18814. QScriptEngine::ScriptOwnership);
  18815. setDAQProperties(object,engine);
  18816. }
  18817. else
  18818. {
  18819. context->throwError("Incorrect number of arguments passed to DAQ"
  18820. "constructor. The DAQ constructor takes one"
  18821. "string as an argument specifying a device name."
  18822. "Example: Dev1");
  18823. }
  18824. return object;
  18825. }
  18826. /*:331*//*332:*/
  18827. #line 7394 "./typica.w"
  18828. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  18829. {
  18830. setQObjectProperties(value,engine);
  18831. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  18832. }
  18833. /*:332*//*333:*/
  18834. #line 7404 "./typica.w"
  18835. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18836. {
  18837. DAQ*self= getself<DAQ*> (context);
  18838. QScriptValue object;
  18839. if(self)
  18840. {
  18841. object=
  18842. engine->newQObject(self->newChannel(argument<int> (0,context),
  18843. argument<int> (1,context)));
  18844. setChannelProperties(object,engine);
  18845. }
  18846. return object;
  18847. }
  18848. /*:333*//*340:*/
  18849. #line 7560 "./typica.w"
  18850. QScriptValue constructFakeDAQ(QScriptContext*context,
  18851. QScriptEngine*engine)
  18852. {
  18853. QScriptValue object;
  18854. if(context->argumentCount()==1)
  18855. {
  18856. object=
  18857. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  18858. QScriptEngine::ScriptOwnership);
  18859. setFakeDAQProperties(object,engine);
  18860. }
  18861. else
  18862. {
  18863. context->throwError("Incorrect number of arguments passed to DAQ"
  18864. "constructor. The DAQ constructor takes one"
  18865. "string as an argument specifying a device name."
  18866. "Example: Dev1");
  18867. }
  18868. return object;
  18869. }
  18870. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  18871. {
  18872. setQObjectProperties(value,engine);
  18873. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  18874. }
  18875. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18876. {
  18877. FakeDAQ*self= getself<FakeDAQ*> (context);
  18878. QScriptValue object;
  18879. if(self)
  18880. {
  18881. object=
  18882. engine->newQObject(self->newChannel(argument<int> (0,context),
  18883. argument<int> (1,context)));
  18884. setChannelProperties(object,engine);
  18885. }
  18886. return object;
  18887. }
  18888. /*:340*//*344:*/
  18889. #line 7651 "./typica.w"
  18890. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  18891. {
  18892. setQObjectProperties(value,engine);
  18893. }
  18894. /*:344*//*351:*/
  18895. #line 7843 "./typica.w"
  18896. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  18897. {
  18898. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  18899. setLinearCalibratorProperties(object,engine);
  18900. return object;
  18901. }
  18902. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  18903. {
  18904. setQObjectProperties(value,engine);
  18905. }
  18906. /*:351*//*356:*/
  18907. #line 7981 "./typica.w"
  18908. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  18909. {
  18910. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  18911. setLinearSplineInterpolatorProperties(object,engine);
  18912. return object;
  18913. }
  18914. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  18915. {
  18916. setQObjectProperties(value,engine);
  18917. }
  18918. /*:356*//*366:*/
  18919. #line 8190 "./typica.w"
  18920. QScriptValue constructTemperatureDisplay(QScriptContext*,
  18921. QScriptEngine*engine)
  18922. {
  18923. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  18924. setTemperatureDisplayProperties(object,engine);
  18925. return object;
  18926. }
  18927. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18928. {
  18929. setQLCDNumberProperties(value,engine);
  18930. value.setProperty("setDisplayUnits",
  18931. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  18932. }
  18933. /*:366*//*367:*/
  18934. #line 8214 "./typica.w"
  18935. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18936. {
  18937. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  18938. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18939. return QScriptValue();
  18940. }
  18941. /*:367*//*374:*/
  18942. #line 8351 "./typica.w"
  18943. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  18944. QScriptEngine*engine)
  18945. {
  18946. QScriptValue object=
  18947. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  18948. setMeasurementTimeOffsetProperties(object,engine);
  18949. return object;
  18950. }
  18951. void setMeasurementTimeOffsetProperties(QScriptValue value,
  18952. QScriptEngine*engine)
  18953. {
  18954. setQObjectProperties(value,engine);
  18955. }
  18956. /*:374*//*379:*/
  18957. #line 8470 "./typica.w"
  18958. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  18959. {
  18960. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  18961. return object;
  18962. }
  18963. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  18964. {
  18965. setQObjectProperties(value,engine);
  18966. }
  18967. /*:379*//*384:*/
  18968. #line 8567 "./typica.w"
  18969. QScriptValue constructZeroEmitter(QScriptContext*context,
  18970. QScriptEngine*engine)
  18971. {
  18972. QScriptValue object=
  18973. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  18974. setZeroEmitterProperties(object,engine);
  18975. return object;
  18976. }
  18977. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  18978. {
  18979. setQObjectProperties(value,engine);
  18980. }
  18981. /*:384*//*389:*/
  18982. #line 8647 "./typica.w"
  18983. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  18984. QScriptEngine*engine)
  18985. {
  18986. QScriptValue object=
  18987. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  18988. setMeasurementAdapterProperties(object,engine);
  18989. return object;
  18990. }
  18991. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  18992. {
  18993. setQObjectProperties(value,engine);
  18994. }
  18995. /*:389*//*406:*/
  18996. #line 9109 "./typica.w"
  18997. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  18998. {
  18999. QScriptValue object= engine->newQObject(new GraphView);
  19000. setGraphViewProperties(object,engine);
  19001. return object;
  19002. }
  19003. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  19004. {
  19005. setQGraphicsViewProperties(value,engine);
  19006. }
  19007. /*:406*//*429:*/
  19008. #line 9747 "./typica.w"
  19009. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  19010. {
  19011. QScriptValue object= engine->newQObject(new ZoomLog);
  19012. setZoomLogProperties(object,engine);
  19013. return object;
  19014. }
  19015. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  19016. {
  19017. setQTableViewProperties(value,engine);
  19018. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  19019. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  19020. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  19021. value.setProperty("restoreState",
  19022. engine->newFunction(ZoomLog_restoreState));
  19023. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  19024. value.setProperty("saveTemporary",
  19025. engine->newFunction(ZoomLog_saveTemporary));
  19026. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  19027. }
  19028. /*:429*//*430:*/
  19029. #line 9774 "./typica.w"
  19030. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  19031. {
  19032. ZoomLog*self= getself<ZoomLog*> (context);
  19033. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  19034. return QScriptValue(engine,retval);
  19035. }
  19036. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  19037. {
  19038. ZoomLog*self= getself<ZoomLog*> (context);
  19039. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  19040. return QScriptValue(engine,retval);
  19041. }
  19042. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  19043. QScriptEngine*engine)
  19044. {
  19045. ZoomLog*self= getself<ZoomLog*> (context);
  19046. QString filename= QDir::tempPath();
  19047. filename.append("/");
  19048. filename.append(QUuid::createUuid().toString());
  19049. filename.append(".xml");
  19050. QFile*file= new QFile(filename);
  19051. self->saveXML(file);
  19052. file->close();
  19053. delete file;
  19054. return QScriptValue(engine,filename);
  19055. }
  19056. /*:430*//*431:*/
  19057. #line 9822 "./typica.w"
  19058. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  19059. {
  19060. ZoomLog*self= getself<ZoomLog*> (context);
  19061. QString key= argument<QString> (0,context);
  19062. int columns= argument<int> (1,context);
  19063. QSettings settings;
  19064. for(int i= 0;i<columns;i++)
  19065. {
  19066. if(self->columnWidth(i))
  19067. {
  19068. settings.beginGroup(key);
  19069. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  19070. settings.endGroup();
  19071. }
  19072. }
  19073. return QScriptValue();
  19074. }
  19075. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  19076. {
  19077. ZoomLog*self= getself<ZoomLog*> (context);
  19078. QString key= argument<QString> (0,context);
  19079. int columns= argument<int> (1,context);
  19080. QSettings settings;
  19081. for(int i= 0;i<columns;i++)
  19082. {
  19083. settings.beginGroup(key);
  19084. self->setColumnWidth(i,
  19085. settings.value(QString("%1").arg(i),80).toInt());
  19086. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  19087. {
  19088. self->setColumnWidth(i,80);
  19089. }
  19090. settings.endGroup();
  19091. }
  19092. return QScriptValue();
  19093. }
  19094. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  19095. {
  19096. ZoomLog*self= getself<ZoomLog*> (context);
  19097. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  19098. }
  19099. /*:431*//*432:*/
  19100. #line 9875 "./typica.w"
  19101. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  19102. {
  19103. ZoomLog*self= getself<ZoomLog*> (context);
  19104. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  19105. return QScriptValue();
  19106. }
  19107. /*:432*//*467:*/
  19108. #line 10695 "./typica.w"
  19109. QScriptValue constructAnnotationButton(QScriptContext*context,
  19110. QScriptEngine*engine)
  19111. {
  19112. QScriptValue object=
  19113. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  19114. setAnnotationButtonProperties(object,engine);
  19115. return object;
  19116. }
  19117. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  19118. {
  19119. setQPushButtonProperties(value,engine);
  19120. }
  19121. /*:467*//*475:*/
  19122. #line 10838 "./typica.w"
  19123. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  19124. QScriptEngine*engine)
  19125. {
  19126. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  19127. argument<QString> (0,context),argument<QString> (1,context)));
  19128. setAnnotationSpinBoxProperties(object,engine);
  19129. return object;
  19130. }
  19131. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19132. {
  19133. setQDoubleSpinBoxProperties(value,engine);
  19134. }
  19135. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19136. {
  19137. setQAbstractSpinBoxProperties(value,engine);
  19138. }
  19139. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19140. {
  19141. setQWidgetProperties(value,engine);
  19142. }
  19143. /*:475*//*496:*/
  19144. #line 11261 "./typica.w"
  19145. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  19146. {
  19147. QScriptValue object= engine->newQObject(new TimerDisplay);
  19148. setTimerDisplayProperties(object,engine);
  19149. return object;
  19150. }
  19151. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  19152. {
  19153. setQLCDNumberProperties(value,engine);
  19154. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  19155. }
  19156. /*:496*//*497:*/
  19157. #line 11280 "./typica.w"
  19158. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  19159. {
  19160. TimerDisplay*self= getself<TimerDisplay*> (context);
  19161. if(self)
  19162. {
  19163. switch(argument<int> (0,context))
  19164. {
  19165. case 0:
  19166. self->setMode(TimerDisplay::CountUp);
  19167. break;
  19168. case 1:
  19169. self->setMode(TimerDisplay::CountDown);
  19170. break;
  19171. case 2:
  19172. self->setMode(TimerDisplay::Clock);
  19173. break;
  19174. default:
  19175. break;
  19176. }
  19177. }
  19178. return QScriptValue();
  19179. }
  19180. /*:497*//*524:*/
  19181. #line 11786 "./typica.w"
  19182. QScriptValue constructWidgetDecorator(QScriptContext*context,
  19183. QScriptEngine*engine)
  19184. {
  19185. QWidget*widget= argument<QWidget*> (0,context);
  19186. QString text= argument<QString> (1,context);
  19187. Qt::Orientations orientation;
  19188. switch(argument<int> (2,context))
  19189. {
  19190. case 2:
  19191. orientation= Qt::Vertical;
  19192. break;
  19193. default:
  19194. orientation= Qt::Horizontal;
  19195. break;
  19196. }
  19197. QScriptValue object=
  19198. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  19199. setWidgetDecoratorProperties(object,engine);
  19200. return object;
  19201. }
  19202. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  19203. {
  19204. setQWidgetProperties(value,engine);
  19205. }
  19206. /*:524*//*537:*/
  19207. #line 12067 "./typica.w"
  19208. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  19209. {
  19210. QScriptValue object= engine->newQObject(new LogEditWindow);
  19211. return object;
  19212. }
  19213. /*:537*//*556:*/
  19214. #line 12594 "./typica.w"
  19215. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  19216. {
  19217. QIODevice*device= argument<QIODevice*> (0,context);
  19218. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  19219. argument<int> (1,context)));
  19220. object.setProperty("input",engine->newFunction(XMLInput_input));
  19221. return object;
  19222. }
  19223. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  19224. {
  19225. XMLInput*self= getself<XMLInput*> (context);
  19226. self->input();
  19227. return QScriptValue();
  19228. }
  19229. /*:556*//*571:*/
  19230. #line 172 "./webview.w"
  19231. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  19232. {
  19233. QScriptValue object= engine->newQObject(new TypicaWebView);
  19234. setQWebViewProperties(object,engine);
  19235. return object;
  19236. }
  19237. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  19238. {
  19239. setQWidgetProperties(value,engine);
  19240. }
  19241. /*:571*//*572:*/
  19242. #line 189 "./webview.w"
  19243. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  19244. QStack<QLayout*> *layoutStack)
  19245. {
  19246. TypicaWebView*view= new TypicaWebView;
  19247. if(element.hasAttribute("id"))
  19248. {
  19249. view->setObjectName(element.attribute("id"));
  19250. }
  19251. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19252. layout->addWidget(view);
  19253. }
  19254. /*:572*//*577:*/
  19255. #line 240 "./webview.w"
  19256. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  19257. {
  19258. QVariant var;
  19259. var.setValue(element);
  19260. QScriptValue object= engine->newVariant(var);
  19261. return object;
  19262. }
  19263. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  19264. {
  19265. element= value.toVariant().value<QWebElement> ();
  19266. }
  19267. /*:577*//*582:*/
  19268. #line 305 "./webview.w"
  19269. template<> QWebElement argument(int arg,QScriptContext*context)
  19270. {
  19271. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  19272. }
  19273. /*:582*//*583:*/
  19274. #line 314 "./webview.w"
  19275. QScriptValue constructWebElement(QScriptContext*context,
  19276. QScriptEngine*engine)
  19277. {
  19278. QWebElement element= argument<QWebElement> (0,context);
  19279. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  19280. return object;
  19281. }
  19282. /*:583*//*594:*/
  19283. #line 85 "./printerselector.w"
  19284. QScriptValue constructPrinterSelector(QScriptContext*,QScriptEngine*engine)
  19285. {
  19286. QScriptValue object= engine->newQObject(new PrinterSelector);
  19287. setQComboBoxProperties(object,engine);
  19288. return object;
  19289. }
  19290. /*:594*//*595:*/
  19291. #line 96 "./printerselector.w"
  19292. void addPrinterSelectorToLayout(QDomElement element,QStack<QWidget*> *,
  19293. QStack<QLayout*> *layoutStack)
  19294. {
  19295. PrinterSelector*selector= new PrinterSelector;
  19296. if(element.hasAttribute("id"))
  19297. {
  19298. selector->setObjectName(element.attribute("id"));
  19299. }
  19300. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19301. layout->addWidget(selector);
  19302. }
  19303. /*:595*//*660:*/
  19304. #line 13954 "./typica.w"
  19305. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  19306. {
  19307. QScriptValue object= engine->newQObject(new SqlQueryView);
  19308. setSqlQueryViewProperties(object,engine);
  19309. return object;
  19310. }
  19311. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  19312. {
  19313. setQTableViewProperties(value,engine);
  19314. value.setProperty("setHeaderData",
  19315. engine->newFunction(SqlQueryView_setHeaderData));
  19316. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  19317. }
  19318. /*:660*//*661:*/
  19319. #line 13972 "./typica.w"
  19320. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  19321. {
  19322. SqlQueryView*self= getself<SqlQueryView*> (context);
  19323. QString query= argument<QString> (0,context);
  19324. self->setQuery(query);
  19325. self->reset();
  19326. return QScriptValue();
  19327. }
  19328. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  19329. QScriptEngine*)
  19330. {
  19331. SqlQueryView*self= getself<SqlQueryView*> (context);
  19332. int section= argument<int> (0,context);
  19333. QString data= argument<QString> (1,context);
  19334. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  19335. return QScriptValue();
  19336. }
  19337. /*:661*//*669:*/
  19338. #line 14181 "./typica.w"
  19339. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  19340. QStack<QLayout*> *layoutStack)
  19341. {
  19342. QTextEdit*widget= new QTextEdit;
  19343. if(element.hasAttribute("id"))
  19344. {
  19345. widget->setObjectName(element.attribute("id"));
  19346. }
  19347. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19348. layout->addWidget(widget);
  19349. QTextDocument*document= new QTextDocument;
  19350. QFont defaultFont;
  19351. defaultFont.setPointSize(11);
  19352. document->setDefaultFont(defaultFont);
  19353. QTextCursor cursor(document);
  19354. /*670:*/
  19355. #line 14204 "./typica.w"
  19356. QDomNodeList children= element.childNodes();
  19357. for(int i= 0;i<children.count();i++)
  19358. {
  19359. QDomNode current;
  19360. QDomElement currentElement;
  19361. current= children.at(i);
  19362. if(current.isElement())
  19363. {
  19364. currentElement= current.toElement();
  19365. /*671:*/
  19366. #line 14221 "./typica.w"
  19367. if(currentElement.tagName()=="style")
  19368. {
  19369. document->setDefaultStyleSheet(currentElement.text());
  19370. }
  19371. /*:671*//*672:*/
  19372. #line 14232 "./typica.w"
  19373. if(currentElement.tagName()=="html")
  19374. {
  19375. cursor.insertHtml(currentElement.text());
  19376. }
  19377. /*:672*//*673:*/
  19378. #line 14242 "./typica.w"
  19379. if(currentElement.tagName()=="text")
  19380. {
  19381. cursor.insertText(currentElement.text());
  19382. }
  19383. /*:673*//*674:*/
  19384. #line 14252 "./typica.w"
  19385. if(currentElement.tagName()=="table")
  19386. {
  19387. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  19388. ReportTable*table= new ReportTable(frame,currentElement);
  19389. table->setParent(widget);
  19390. if(currentElement.hasAttribute("id"))
  19391. {
  19392. table->setObjectName(currentElement.attribute("id"));
  19393. }
  19394. }
  19395. /*:674*/
  19396. #line 14214 "./typica.w"
  19397. }
  19398. }
  19399. /*:670*/
  19400. #line 14197 "./typica.w"
  19401. widget->setDocument(document);
  19402. }
  19403. /*:669*//*685:*/
  19404. #line 14465 "./typica.w"
  19405. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  19406. {
  19407. QTextEdit*self= getself<QTextEdit*> (context);
  19408. QTextDocument*document= self->document();
  19409. QPrinter printer;
  19410. QPrintDialog printwindow(&printer,self);
  19411. if(printwindow.exec()!=QDialog::Accepted)
  19412. {
  19413. return QScriptValue();
  19414. }
  19415. document->print(&printer);
  19416. return QScriptValue();
  19417. }
  19418. /*:685*//*686:*/
  19419. #line 14483 "./typica.w"
  19420. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  19421. {
  19422. setQAbstractScrollAreaProperties(value,engine);
  19423. value.setProperty("print",engine->newFunction(QTextEdit_print));
  19424. }
  19425. #line 1 "./plugins.w"
  19426. /*:686*//*711:*/
  19427. #line 463 "./daterangeselector.w"
  19428. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  19429. QStack<QLayout*> *layoutStack)
  19430. {
  19431. DateRangeSelector*widget= new DateRangeSelector;
  19432. if(element.hasAttribute("id"))
  19433. {
  19434. widget->setObjectName(element.attribute("id"));
  19435. }
  19436. if(element.hasAttribute("initial"))
  19437. {
  19438. widget->setCurrentIndex(element.attribute("initial").toInt());
  19439. }
  19440. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19441. layout->addWidget(widget);
  19442. }
  19443. /*:711*//*722:*/
  19444. #line 14665 "./typica.w"
  19445. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  19446. QStack<QLayout*> *layoutStack)
  19447. {
  19448. FormArray*widget= new FormArray(element);
  19449. if(element.hasAttribute("id"))
  19450. {
  19451. widget->setObjectName(element.attribute("id"));
  19452. }
  19453. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19454. layout->addWidget(widget);
  19455. }
  19456. /*:722*//*743:*/
  19457. #line 15252 "./typica.w"
  19458. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  19459. QStack<QLayout*> *layoutStack)
  19460. {
  19461. ScaleControl*scale= new ScaleControl;
  19462. if(element.hasAttribute("id"))
  19463. {
  19464. scale->setObjectName(element.attribute("id"));
  19465. }
  19466. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19467. layout->addWidget(scale);
  19468. }
  19469. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  19470. QStack<QLayout*> *layoutStack)
  19471. {
  19472. IntensityControl*scale= new IntensityControl;
  19473. if(element.hasAttribute("id"))
  19474. {
  19475. scale->setObjectName(element.attribute("id"));
  19476. }
  19477. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19478. layout->addWidget(scale);
  19479. }
  19480. /*:743*//*769:*/
  19481. #line 15842 "./typica.w"
  19482. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  19483. {
  19484. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  19485. setDeviceTreeModelProperties(object,engine);
  19486. return object;
  19487. }
  19488. /*:769*//*771:*/
  19489. #line 15865 "./typica.w"
  19490. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  19491. {
  19492. setQAbstractItemModelProperties(value,engine);
  19493. value.setProperty("referenceElement",
  19494. engine->newFunction(DeviceTreeModel_referenceElement));
  19495. }
  19496. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  19497. {
  19498. setQObjectProperties(value,engine);
  19499. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  19500. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  19501. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  19502. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  19503. }
  19504. /*:771*//*772:*/
  19505. #line 15892 "./typica.w"
  19506. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  19507. QScriptEngine*engine)
  19508. {
  19509. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  19510. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  19511. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  19512. QDomElement node;
  19513. QVariantMap retval;
  19514. retval.insert("driver",referenceElement.attribute("driver"));
  19515. for(int i= 0;i<configData.size();i++)
  19516. {
  19517. node= configData.at(i).toElement();
  19518. retval.insert(node.attribute("name"),node.attribute("value"));
  19519. }
  19520. return engine->toScriptValue(retval);
  19521. }
  19522. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  19523. {
  19524. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19525. QModelIndex index= argument<QModelIndex> (0,context);
  19526. int role= argument<int> (1,context);
  19527. return engine->toScriptValue(model->data(index,role));
  19528. }
  19529. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  19530. {
  19531. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19532. int row= 0;
  19533. int column= 0;
  19534. QModelIndex index;
  19535. if(context->argumentCount()> 1)
  19536. {
  19537. row= argument<int> (0,context);
  19538. column= argument<int> (1,context);
  19539. }
  19540. if(context->argumentCount()> 2)
  19541. {
  19542. index= argument<QModelIndex> (2,context);
  19543. }
  19544. QModelIndex retval= model->index(row,column,index);
  19545. return engine->toScriptValue(retval);
  19546. }
  19547. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  19548. QScriptEngine*)
  19549. {
  19550. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19551. QModelIndex index;
  19552. if(context->argumentCount()==1)
  19553. {
  19554. index= argument<QModelIndex> (0,context);
  19555. }
  19556. return QScriptValue(model->rowCount(index));
  19557. }
  19558. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  19559. QScriptEngine*engine)
  19560. {
  19561. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19562. QModelIndex index;
  19563. if(context->argumentCount()==1)
  19564. {
  19565. index= argument<QModelIndex> (0,context);
  19566. }
  19567. return QScriptValue(engine,model->hasChildren(index));
  19568. }
  19569. /*:772*//*775:*/
  19570. #line 15976 "./typica.w"
  19571. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  19572. {
  19573. QVariant var;
  19574. var.setValue(index);
  19575. QScriptValue object= engine->newVariant(var);
  19576. return object;
  19577. }
  19578. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  19579. {
  19580. index= value.toVariant().value<QModelIndex> ();
  19581. }
  19582. /*:775*//*791:*/
  19583. #line 16274 "./typica.w"
  19584. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  19585. QScriptEngine*engine)
  19586. {
  19587. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  19588. return object;
  19589. }
  19590. /*:791*//*862:*/
  19591. #line 47 "./settings.w"
  19592. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  19593. {
  19594. QScriptValue object= engine->newQObject(new SettingsWindow);
  19595. return object;
  19596. }
  19597. /*:862*//*887:*/
  19598. #line 18928 "./typica.w"
  19599. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  19600. {
  19601. QScriptValue object;
  19602. if(context->argumentCount()==2)
  19603. {
  19604. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  19605. argument<QModelIndex> (1,context)),
  19606. QScriptEngine::ScriptOwnership);
  19607. setModbusRTUDeviceProperties(object,engine);
  19608. }
  19609. else
  19610. {
  19611. context->throwError("Incorrect number of arguments passed to "
  19612. "ModbusRTUDevice constructor. This takes the configuration model "
  19613. "and an index.");
  19614. }
  19615. return object;
  19616. }
  19617. /*:887*//*888:*/
  19618. #line 18950 "./typica.w"
  19619. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  19620. {
  19621. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19622. QScriptValue object;
  19623. if(self)
  19624. {
  19625. if(self->channels.size()> 0)
  19626. {
  19627. object= engine->newQObject(self->channels.at(0));
  19628. setChannelProperties(object,engine);
  19629. }
  19630. }
  19631. return object;
  19632. }
  19633. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  19634. {
  19635. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19636. QScriptValue object;
  19637. if(self)
  19638. {
  19639. if(self->channels.size()> 1)
  19640. {
  19641. object= engine->newQObject(self->channels.at(1));
  19642. setChannelProperties(object,engine);
  19643. }
  19644. }
  19645. return object;
  19646. }
  19647. /*:888*//*889:*/
  19648. #line 18983 "./typica.w"
  19649. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19650. {
  19651. setQObjectProperties(value,engine);
  19652. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  19653. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  19654. }
  19655. /*:889*//*905:*/
  19656. #line 713 "./modbus.w"
  19657. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  19658. {
  19659. QScriptValue object;
  19660. if(context->argumentCount()==2)
  19661. {
  19662. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  19663. argument<QModelIndex> (1,context)),
  19664. QScriptEngine::ScriptOwnership);
  19665. setModbusNGProperties(object,engine);
  19666. }
  19667. else
  19668. {
  19669. context->throwError("Incorrect number of arguments passed to "
  19670. "ModbusNG constructor.");
  19671. }
  19672. return object;
  19673. }
  19674. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  19675. {
  19676. setQObjectProperties(value,engine);
  19677. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  19678. }
  19679. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  19680. {
  19681. ModbusNG*self= getself<ModbusNG*> (context);
  19682. QScriptValue object;
  19683. if(self)
  19684. {
  19685. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19686. setChannelProperties(object,engine);
  19687. }
  19688. return object;
  19689. }
  19690. #line 19534 "./typica.w"
  19691. #line 1 "./unsupportedserial.w"
  19692. /*:905*//*919:*/
  19693. #line 357 "./unsupportedserial.w"
  19694. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  19695. {
  19696. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  19697. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  19698. QScriptValue object= engine->newQObject(device);
  19699. setQObjectProperties(object,engine);
  19700. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  19701. return object;
  19702. }
  19703. /*:919*//*924:*/
  19704. #line 430 "./unsupportedserial.w"
  19705. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  19706. {
  19707. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  19708. QScriptValue object;
  19709. if(self)
  19710. {
  19711. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19712. setChannelProperties(object,engine);
  19713. }
  19714. return object;
  19715. }
  19716. /*:924*//*931:*/
  19717. #line 630 "./unsupportedserial.w"
  19718. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  19719. {
  19720. return engine->toScriptValue<QTime> (QTime::currentTime());
  19721. }
  19722. /*:931*//*935:*/
  19723. #line 667 "./unsupportedserial.w"
  19724. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  19725. {
  19726. QScriptValue object= engine->newQObject(new QextSerialPort());
  19727. setSerialPortProperties(object,engine);
  19728. return object;
  19729. }
  19730. /*:935*//*936:*/
  19731. #line 678 "./unsupportedserial.w"
  19732. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  19733. {
  19734. setQIODeviceProperties(value,engine);
  19735. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  19736. }
  19737. /*:936*//*937:*/
  19738. #line 687 "./unsupportedserial.w"
  19739. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  19740. {
  19741. QextSerialPort*self= getself<QextSerialPort*> (context);
  19742. self->flush();
  19743. return QScriptValue();
  19744. }
  19745. #line 19536 "./typica.w"
  19746. #line 1 "./phidgets.w"
  19747. /*:937*//*958:*/
  19748. #line 463 "./phidgets.w"
  19749. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  19750. {
  19751. if(context->argumentCount()!=1)
  19752. {
  19753. context->throwError("Incorrect number of arguments passed to "
  19754. "PhidgetsTemperatureSensor constructor. This takes "
  19755. "a QModelIndex.");
  19756. }
  19757. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  19758. setQObjectProperties(object,engine);
  19759. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  19760. return object;
  19761. }
  19762. /*:958*//*959:*/
  19763. #line 480 "./phidgets.w"
  19764. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  19765. {
  19766. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  19767. QScriptValue object;
  19768. if(self)
  19769. {
  19770. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19771. setChannelProperties(object,engine);
  19772. }
  19773. return object;
  19774. }
  19775. #line 19538 "./typica.w"
  19776. /*:959*//*991:*/
  19777. #line 151 "./rate.w"
  19778. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  19779. {
  19780. int cachetime= 1;
  19781. int scaletime= 1;
  19782. if(context->argumentCount()> 0)
  19783. {
  19784. cachetime= argument<int> (0,context);
  19785. if(context->argumentCount()> 1)
  19786. {
  19787. scaletime= argument<int> (1,context);
  19788. }
  19789. }
  19790. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  19791. setRateOfChangeProperties(object,engine);
  19792. return object;
  19793. }
  19794. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  19795. {
  19796. setQObjectProperties(value,engine);
  19797. }
  19798. /*:991*//*1016:*/
  19799. #line 614 "./dataqsdk.w"
  19800. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  19801. {
  19802. QScriptValue object;
  19803. if(context->argumentCount()==1)
  19804. {
  19805. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  19806. QScriptEngine::ScriptOwnership);
  19807. setDataqSdkDeviceProperties(object,engine);
  19808. }
  19809. else
  19810. {
  19811. context->throwError("Incorrect number of arguments passed to "
  19812. "DataqSdkDevice. The constructor takes one string "
  19813. "as an argument specifying a device name. "
  19814. "Example: Dev1");
  19815. }
  19816. return object;
  19817. }
  19818. /*:1016*//*1017:*/
  19819. #line 637 "./dataqsdk.w"
  19820. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19821. {
  19822. setQObjectProperties(value,engine);
  19823. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  19824. }
  19825. /*:1017*//*1018:*/
  19826. #line 647 "./dataqsdk.w"
  19827. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  19828. {
  19829. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  19830. QScriptValue object;
  19831. if(self)
  19832. {
  19833. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  19834. setChannelProperties(object,engine);
  19835. }
  19836. return object;
  19837. }
  19838. /*:1018*//*1043:*/
  19839. #line 80 "./scales.w"
  19840. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  19841. {
  19842. QScriptValue object;
  19843. QString labelText= "";
  19844. if(context->argumentCount()==1)
  19845. {
  19846. labelText= argument<QString> (0,context);
  19847. }
  19848. object= engine->newQObject(new DragLabel(labelText));
  19849. setDragLabelProperties(object,engine);
  19850. return object;
  19851. }
  19852. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  19853. {
  19854. setQLabelProperties(value,engine);
  19855. }
  19856. /*:1043*//*1053:*/
  19857. #line 298 "./scales.w"
  19858. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  19859. {
  19860. return engine->newVariant(QVariant((int)(value)));
  19861. }
  19862. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  19863. {
  19864. value= (BaudRateType)(sv.toVariant().toInt());
  19865. }
  19866. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  19867. {
  19868. return engine->newVariant(QVariant((int)(value)));
  19869. }
  19870. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  19871. {
  19872. value= (DataBitsType)(sv.toVariant().toInt());
  19873. }
  19874. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  19875. {
  19876. return engine->newVariant(QVariant((int)(value)));
  19877. }
  19878. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  19879. {
  19880. value= (ParityType)(sv.toVariant().toInt());
  19881. }
  19882. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  19883. {
  19884. return engine->newVariant(QVariant((int)(value)));
  19885. }
  19886. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  19887. {
  19888. value= (StopBitsType)(sv.toVariant().toInt());
  19889. }
  19890. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  19891. {
  19892. return engine->newVariant(QVariant((int)(value)));
  19893. }
  19894. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  19895. {
  19896. value= (FlowType)(sv.toVariant().toInt());
  19897. }
  19898. /*:1053*//*1056:*/
  19899. #line 367 "./scales.w"
  19900. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  19901. {
  19902. setQIODeviceProperties(value,engine);
  19903. }
  19904. /*:1056*//*1057:*/
  19905. #line 375 "./scales.w"
  19906. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  19907. {
  19908. QScriptValue object;
  19909. if(context->argumentCount()==1)
  19910. {
  19911. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  19912. setSerialScaleProperties(object,engine);
  19913. }
  19914. else
  19915. {
  19916. context->throwError("Incorrect number of arguments passed to "
  19917. "SerialScale. The constructor takes one string "
  19918. "as an argument specifying a port name.");
  19919. }
  19920. return object;
  19921. }
  19922. /*:1057*//*1079:*/
  19923. #line 278 "./valueannotation.w"
  19924. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  19925. {
  19926. QScriptValue object= engine->newQObject(new ValueAnnotation);
  19927. setValueAnnotationProperties(object,engine);
  19928. return object;
  19929. }
  19930. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  19931. {
  19932. setQObjectProperties(value,engine);
  19933. }
  19934. #line 20200 "./typica.w"
  19935. #line 1 "./thresholdannotation.w"
  19936. /*:1079*//*1090:*/
  19937. #line 208 "./thresholdannotation.w"
  19938. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  19939. {
  19940. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  19941. setAnnotatorProperties(object,engine);
  19942. return object;
  19943. }
  19944. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  19945. {
  19946. setQObjectProperties(value,engine);
  19947. }
  19948. #line 20202 "./typica.w"
  19949. /*:1090*/
  19950. #line 530 "./typica.w"
  19951. /*639:*/
  19952. #line 13584 "./typica.w"
  19953. void messageFileOutput(QtMsgType,const char*msg)
  19954. {
  19955. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  19956. output.open(QIODevice::WriteOnly|QIODevice::Append);
  19957. QTextStream outstream(&output);
  19958. outstream<<msg<<"\r\n";
  19959. }
  19960. /*:639*/
  19961. #line 531 "./typica.w"
  19962. /*636:*/
  19963. #line 13545 "./typica.w"
  19964. int main(int argc,char**argv)
  19965. {
  19966. int*c= &argc;
  19967. Application app(*c,argv);
  19968. QSettings settings;
  19969. /*637:*/
  19970. #line 13571 "./typica.w"
  19971. if(settings.value("settings/advanced/logging",false).toBool())
  19972. {
  19973. qInstallMsgHandler(messageFileOutput);
  19974. }
  19975. /*:637*/
  19976. #line 13551 "./typica.w"
  19977. /*640:*/
  19978. #line 13597 "./typica.w"
  19979. QStringList themeSearchPath= QIcon::themeSearchPaths();
  19980. themeSearchPath.append(":/resources/icons/tango");
  19981. QIcon::setThemeSearchPaths(themeSearchPath);
  19982. QIcon::setThemeName(":/resources/icons/tango");
  19983. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  19984. /*:640*/
  19985. #line 13552 "./typica.w"
  19986. /*641:*/
  19987. #line 13617 "./typica.w"
  19988. QFile entypo(":/resources/fonts/entypo.ttf");
  19989. entypo.open(QIODevice::ReadOnly);
  19990. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  19991. entypo.close();
  19992. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  19993. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  19994. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  19995. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  19996. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  19997. /*:641*/
  19998. #line 13553 "./typica.w"
  19999. /*801:*/
  20000. #line 16564 "./typica.w"
  20001. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  20002. /*:801*//*811:*/
  20003. #line 16806 "./typica.w"
  20004. app.registerDeviceConfigurationWidget("nidaqmxbase",
  20005. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  20006. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  20007. NiDaqMxBase9211ConfWidget::staticMetaObject);
  20008. app.registerDeviceConfigurationWidget("ni9211seriestc",
  20009. Ni9211TcConfWidget::staticMetaObject);
  20010. /*:811*//*819:*/
  20011. #line 17037 "./typica.w"
  20012. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  20013. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  20014. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  20015. /*:819*//*843:*/
  20016. #line 18006 "./typica.w"
  20017. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  20018. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  20019. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  20020. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  20021. /*:843*//*848:*/
  20022. #line 18091 "./typica.w"
  20023. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  20024. /*:848*//*851:*/
  20025. #line 18161 "./typica.w"
  20026. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  20027. /*:851*//*854:*/
  20028. #line 18288 "./typica.w"
  20029. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  20030. #line 1 "./freeannotation.w"
  20031. /*:854*//*858:*/
  20032. #line 57 "./freeannotation.w"
  20033. app.registerDeviceConfigurationWidget("freeannotation",
  20034. FreeAnnotationConfWidget::staticMetaObject);
  20035. #line 18292 "./typica.w"
  20036. #line 1 "./settings.w"
  20037. /*:858*//*892:*/
  20038. #line 19524 "./typica.w"
  20039. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  20040. /*:892*//*898:*/
  20041. #line 321 "./modbus.w"
  20042. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  20043. app.registerDeviceConfigurationWidget("modbusnginput",
  20044. ModbusNGInputConfWidget::staticMetaObject);
  20045. /*:898*//*914:*/
  20046. #line 264 "./unsupportedserial.w"
  20047. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  20048. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  20049. app.registerDeviceConfigurationWidget("unsupporteddevice",
  20050. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  20051. /*:914*//*945:*/
  20052. #line 181 "./phidgets.w"
  20053. app.registerDeviceConfigurationWidget("phidgets1048",
  20054. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  20055. app.registerDeviceConfigurationWidget("phidgets1048channel",
  20056. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  20057. /*:945*//*965:*/
  20058. #line 19660 "./typica.w"
  20059. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  20060. /*:965*//*968:*/
  20061. #line 19720 "./typica.w"
  20062. app.registerDeviceConfigurationWidget("coolingtimer",
  20063. CoolingTimerConfWidget::staticMetaObject);
  20064. /*:968*//*973:*/
  20065. #line 19979 "./typica.w"
  20066. app.registerDeviceConfigurationWidget("rangetimer",
  20067. RangeTimerConfWidget::staticMetaObject);
  20068. /*:973*//*978:*/
  20069. #line 20080 "./typica.w"
  20070. app.registerDeviceConfigurationWidget("multirangetimer",
  20071. MultiRangeTimerConfWidget::staticMetaObject);
  20072. /*:978*//*983:*/
  20073. #line 20190 "./typica.w"
  20074. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  20075. #line 1 "./rate.w"
  20076. /*:983*//*995:*/
  20077. #line 253 "./rate.w"
  20078. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  20079. /*:995*//*1036:*/
  20080. #line 1233 "./dataqsdk.w"
  20081. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  20082. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  20083. DataqSdkChannelConfWidget::staticMetaObject);
  20084. /*:1036*//*1061:*/
  20085. #line 552 "./scales.w"
  20086. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  20087. /*:1061*//*1069:*/
  20088. #line 138 "./valueannotation.w"
  20089. app.registerDeviceConfigurationWidget("valueannotation",
  20090. ValueAnnotationConfWidget::staticMetaObject);
  20091. /*:1069*//*1083:*/
  20092. #line 109 "./thresholdannotation.w"
  20093. app.registerDeviceConfigurationWidget("thresholdannotation",
  20094. ThresholdAnnotationConfWidget::staticMetaObject);
  20095. /*:1083*/
  20096. #line 13555 "./typica.w"
  20097. /*642:*/
  20098. #line 13634 "./typica.w"
  20099. if(settings.value("database/exists","false").toString()=="true")
  20100. {
  20101. /*647:*/
  20102. #line 13768 "./typica.w"
  20103. QSqlDatabase database=
  20104. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  20105. database.setConnectOptions("application_name=Typica");
  20106. database.setHostName(settings.value("database/hostname").toString());
  20107. database.setPort(settings.value("database/portnumber",5432).toInt());
  20108. database.setDatabaseName(settings.value("database/dbname").toString());
  20109. database.setUserName(settings.value("database/user").toString());
  20110. database.setPassword(settings.value("database/password").toString());
  20111. if(!database.open())
  20112. {
  20113. settings.setValue("database/exists","false");
  20114. }
  20115. else
  20116. {
  20117. database.close();
  20118. }
  20119. /*:647*/
  20120. #line 13637 "./typica.w"
  20121. }
  20122. if(settings.value("database/exists","false").toString()=="false")
  20123. {
  20124. /*646:*/
  20125. #line 13759 "./typica.w"
  20126. SqlConnectionSetup dialog;
  20127. dialog.exec();
  20128. /*:646*/
  20129. #line 13641 "./typica.w"
  20130. }
  20131. /*:642*/
  20132. #line 13556 "./typica.w"
  20133. /*192:*/
  20134. #line 4380 "./typica.w"
  20135. QStringList arguments= QCoreApplication::arguments();
  20136. int position= arguments.indexOf("-c");
  20137. QString filename= QString();
  20138. if(position!=-1)
  20139. {
  20140. if(arguments.size()>=position+1)
  20141. {
  20142. filename= arguments.at(position+1);
  20143. }
  20144. }
  20145. if(filename.isEmpty())
  20146. {
  20147. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  20148. settings.value("config","").toString());
  20149. }
  20150. QDir directory;
  20151. if(!filename.isEmpty())
  20152. {
  20153. QFile file(filename);
  20154. QFileInfo info(filename);
  20155. directory= info.dir();
  20156. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  20157. QTranslator*configtr= new QTranslator;
  20158. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  20159. QString("%1/Translations").arg(directory.canonicalPath())))
  20160. {
  20161. QCoreApplication::installTranslator(configtr);
  20162. }
  20163. settings.setValue("config",directory.path());
  20164. if(file.open(QIODevice::ReadOnly))
  20165. {
  20166. app.configuration()->setContent(&file,true);
  20167. }
  20168. }
  20169. /*193:*/
  20170. #line 4421 "./typica.w"
  20171. QDomElement root= app.configuration()->documentElement();
  20172. QDomNodeList children= root.childNodes();
  20173. QString replacementDoc;
  20174. QDomDocument includedDoc;
  20175. QDomDocumentFragment fragment;
  20176. for(int i= 0;i<children.size();i++)
  20177. {
  20178. QDomNode currentNode= children.at(i);
  20179. QDomElement currentElement;
  20180. if(currentNode.nodeName()=="include")
  20181. {
  20182. currentElement= currentNode.toElement();
  20183. if(currentElement.hasAttribute("src"))
  20184. {
  20185. replacementDoc= directory.path();
  20186. replacementDoc.append('/');
  20187. replacementDoc.append(currentElement.attribute("src"));
  20188. QFile doc(replacementDoc);
  20189. if(doc.open(QIODevice::ReadOnly))
  20190. {
  20191. includedDoc.setContent(&doc,true);
  20192. fragment= includedDoc.createDocumentFragment();
  20193. fragment.appendChild(includedDoc.documentElement());
  20194. root.replaceChild(fragment,currentNode);
  20195. doc.close();
  20196. }
  20197. }
  20198. }
  20199. }
  20200. /*:193*/
  20201. #line 4415 "./typica.w"
  20202. /*:192*/
  20203. #line 13557 "./typica.w"
  20204. /*7:*/
  20205. #line 663 "./typica.w"
  20206. QScriptEngine*engine= new QScriptEngine;
  20207. QScriptValue constructor;
  20208. QScriptValue value;
  20209. /*:7*//*17:*/
  20210. #line 866 "./typica.w"
  20211. constructor= engine->newFunction(constructQTimer);
  20212. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  20213. engine->globalObject().setProperty("Timer",value);
  20214. /*:17*//*20:*/
  20215. #line 905 "./typica.w"
  20216. constructor= engine->newFunction(constructQWidget);
  20217. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  20218. engine->globalObject().setProperty("QWidget",value);
  20219. /*:20*//*24:*/
  20220. #line 992 "./typica.w"
  20221. constructor= engine->newFunction(displayWarning);
  20222. engine->globalObject().setProperty("displayWarning",constructor);
  20223. constructor= engine->newFunction(displayError);
  20224. engine->globalObject().setProperty("displayError",constructor);
  20225. /*:24*//*34:*/
  20226. #line 1198 "./typica.w"
  20227. constructor= engine->newFunction(constructQMainWindow);
  20228. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  20229. constructor);
  20230. engine->globalObject().setProperty("QMainWindow",value);
  20231. /*:34*//*45:*/
  20232. #line 1403 "./typica.w"
  20233. constructor= engine->newFunction(constructQFrame);
  20234. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  20235. engine->globalObject().setProperty("QFrame",value);
  20236. /*:45*//*48:*/
  20237. #line 1436 "./typica.w"
  20238. constructor= engine->newFunction(constructQLabel);
  20239. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  20240. engine->globalObject().setProperty("QLabel",value);
  20241. /*:48*//*51:*/
  20242. #line 1479 "./typica.w"
  20243. constructor= engine->newFunction(constructQSvgWidget);
  20244. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  20245. engine->globalObject().setProperty("QSvgWidget",value);
  20246. /*:51*//*57:*/
  20247. #line 1561 "./typica.w"
  20248. constructor= engine->newFunction(constructQLineEdit);
  20249. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  20250. engine->globalObject().setProperty("QLineEdit",value);
  20251. /*:57*//*61:*/
  20252. #line 1608 "./typica.w"
  20253. constructor= engine->newFunction(constructQSplitter);
  20254. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  20255. engine->globalObject().setProperty("QSplitter",value);
  20256. /*:61*//*69:*/
  20257. #line 1797 "./typica.w"
  20258. constructor= engine->newFunction(constructQBoxLayout);
  20259. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  20260. engine->globalObject().setProperty("QBoxLayout",value);
  20261. /*:69*//*73:*/
  20262. #line 1909 "./typica.w"
  20263. constructor= engine->newFunction(constructQAction);
  20264. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  20265. engine->globalObject().setProperty("QAction",value);
  20266. /*:73*//*76:*/
  20267. #line 1968 "./typica.w"
  20268. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  20269. value.setProperty("getOpenFileName",
  20270. engine->newFunction(QFileDialog_getOpenFileName));
  20271. value.setProperty("getSaveFileName",
  20272. engine->newFunction(QFileDialog_getSaveFileName));
  20273. engine->globalObject().setProperty("QFileDialog",value);
  20274. /*:76*//*81:*/
  20275. #line 2086 "./typica.w"
  20276. constructor= engine->newFunction(constructQFile);
  20277. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  20278. engine->globalObject().setProperty("QFile",value);
  20279. /*:81*//*92:*/
  20280. #line 2304 "./typica.w"
  20281. constructor= engine->newFunction(constructQProcess);
  20282. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  20283. engine->globalObject().setProperty("QProcess",value);
  20284. /*:92*//*101:*/
  20285. #line 2453 "./typica.w"
  20286. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  20287. constructor= engine->newFunction(constructQByteArray);
  20288. engine->globalObject().setProperty("QByteArray",constructor);
  20289. /*:101*//*113:*/
  20290. #line 2695 "./typica.w"
  20291. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  20292. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  20293. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  20294. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  20295. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  20296. /*:113*//*116:*/
  20297. #line 2798 "./typica.w"
  20298. constructor= engine->newFunction(constructQBuffer);
  20299. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  20300. engine->globalObject().setProperty("QBuffer",value);
  20301. /*:116*//*119:*/
  20302. #line 2847 "./typica.w"
  20303. constructor= engine->newFunction(constructXQuery);
  20304. engine->globalObject().setProperty("XQuery",constructor);
  20305. /*:119*//*125:*/
  20306. #line 2949 "./typica.w"
  20307. constructor= engine->newFunction(constructXmlWriter);
  20308. engine->globalObject().setProperty("XmlWriter",constructor);
  20309. /*:125*//*134:*/
  20310. #line 3155 "./typica.w"
  20311. constructor= engine->newFunction(constructXmlReader);
  20312. engine->globalObject().setProperty("XmlReader",constructor);
  20313. /*:134*//*141:*/
  20314. #line 3279 "./typica.w"
  20315. value= engine->newQObject(&settings);
  20316. setQSettingsProperties(value,engine);
  20317. engine->globalObject().setProperty("QSettings",value);
  20318. /*:141*//*145:*/
  20319. #line 3360 "./typica.w"
  20320. constructor= engine->newFunction(constructQLCDNumber);
  20321. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  20322. engine->globalObject().setProperty("QLCDNumber",value);
  20323. /*:145*//*148:*/
  20324. #line 3416 "./typica.w"
  20325. constructor= engine->newFunction(constructQTime);
  20326. engine->globalObject().setProperty("QTime",constructor);
  20327. /*:148*//*170:*/
  20328. #line 3929 "./typica.w"
  20329. constructor= engine->newFunction(constructQPushButton);
  20330. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  20331. engine->globalObject().setProperty("QPushButton",value);
  20332. /*:170*//*177:*/
  20333. #line 4040 "./typica.w"
  20334. constructor= engine->newFunction(constructQSqlQuery);
  20335. engine->globalObject().setProperty("QSqlQuery",constructor);
  20336. /*:177*//*184:*/
  20337. #line 4204 "./typica.w"
  20338. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  20339. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  20340. engine->globalObject().setProperty("sqlToArray",
  20341. engine->newFunction(sqlToArray));
  20342. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  20343. engine->globalObject().setProperty("annotationFromRecord",
  20344. engine->newFunction(annotationFromRecord));
  20345. engine->globalObject().setProperty("setTabOrder",
  20346. engine->newFunction(setTabOrder));
  20347. engine->globalObject().setProperty("saveFileFromDatabase",
  20348. engine->newFunction(saveFileFromDatabase));
  20349. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  20350. /*:184*//*197:*/
  20351. #line 4590 "./typica.w"
  20352. engine->globalObject().setProperty("createWindow",
  20353. engine->newFunction(createWindow));
  20354. engine->globalObject().setProperty("createReport",
  20355. engine->newFunction(createReport));
  20356. /*:197*//*222:*/
  20357. #line 4961 "./typica.w"
  20358. constructor= engine->newFunction(constructQTabBar);
  20359. value= engine->newQMetaObject(&QTabBar::staticMetaObject,constructor);
  20360. engine->globalObject().setProperty("QTabBar",value);
  20361. /*:222*//*271:*/
  20362. #line 6347 "./typica.w"
  20363. engine->globalObject().setProperty("findChildObject",
  20364. engine->newFunction(findChildObject));
  20365. /*:271*//*297:*/
  20366. #line 389 "./units.w"
  20367. value= engine->newQMetaObject(&Units::staticMetaObject);
  20368. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  20369. value.setProperty("convertRelativeTemperature",
  20370. engine->newFunction(Units_convertRelativeTemperature));
  20371. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  20372. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  20373. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  20374. engine->globalObject().setProperty("Units",value);
  20375. /*:297*//*302:*/
  20376. #line 462 "./units.w"
  20377. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  20378. #line 6779 "./typica.w"
  20379. /*:302*//*310:*/
  20380. #line 141 "./measurement.w"
  20381. constructor= engine->newFunction(constructMeasurement);
  20382. engine->globalObject().setProperty("Measurement",constructor);
  20383. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  20384. /*:310*//*330:*/
  20385. #line 7350 "./typica.w"
  20386. constructor= engine->newFunction(constructDAQ);
  20387. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  20388. value.setProperty("Fahrenheit",Units::Fahrenheit);
  20389. value.setProperty("Celsius",Units::Celsius);
  20390. value.setProperty("Kelvin",Units::Kelvin);
  20391. value.setProperty("Rankine",Units::Rankine);
  20392. engine->globalObject().setProperty("DAQ",value);
  20393. /*:330*//*339:*/
  20394. #line 7552 "./typica.w"
  20395. constructor= engine->newFunction(constructFakeDAQ);
  20396. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  20397. engine->globalObject().setProperty("FakeDAQ",value);
  20398. /*:339*//*350:*/
  20399. #line 7835 "./typica.w"
  20400. constructor= engine->newFunction(constructLinearCalibrator);
  20401. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  20402. constructor);
  20403. engine->globalObject().setProperty("LinearCalibrator",value);
  20404. /*:350*//*355:*/
  20405. #line 7974 "./typica.w"
  20406. constructor= engine->newFunction(constructLinearSplineInterpolator);
  20407. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  20408. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  20409. /*:355*//*365:*/
  20410. #line 8182 "./typica.w"
  20411. constructor= engine->newFunction(constructTemperatureDisplay);
  20412. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  20413. constructor);
  20414. engine->globalObject().setProperty("TemperatureDisplay",value);
  20415. /*:365*//*373:*/
  20416. #line 8340 "./typica.w"
  20417. constructor= engine->newFunction(constructMeasurementTimeOffset);
  20418. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  20419. constructor);
  20420. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  20421. /*:373*//*378:*/
  20422. #line 8461 "./typica.w"
  20423. constructor= engine->newFunction(constructThresholdDetector);
  20424. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  20425. engine->globalObject().setProperty("ThresholdDetector",value);
  20426. /*:378*//*383:*/
  20427. #line 8560 "./typica.w"
  20428. constructor= engine->newFunction(constructZeroEmitter);
  20429. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  20430. engine->globalObject().setProperty("ZeroEmitter",value);
  20431. /*:383*//*388:*/
  20432. #line 8639 "./typica.w"
  20433. constructor= engine->newFunction(constructMeasurementAdapter);
  20434. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  20435. constructor);
  20436. engine->globalObject().setProperty("MeasurementAdapter",value);
  20437. /*:388*//*405:*/
  20438. #line 9102 "./typica.w"
  20439. constructor= engine->newFunction(constructGraphView);
  20440. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  20441. engine->globalObject().setProperty("GraphView",value);
  20442. /*:405*//*428:*/
  20443. #line 9739 "./typica.w"
  20444. constructor= engine->newFunction(constructZoomLog);
  20445. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  20446. engine->globalObject().setProperty("ZoomLog",value);
  20447. /*:428*//*466:*/
  20448. #line 10687 "./typica.w"
  20449. constructor= engine->newFunction(constructAnnotationButton);
  20450. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  20451. constructor);
  20452. engine->globalObject().setProperty("AnnotationButton",value);
  20453. /*:466*//*474:*/
  20454. #line 10829 "./typica.w"
  20455. constructor= engine->newFunction(constructAnnotationSpinBox);
  20456. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  20457. constructor);
  20458. engine->globalObject().setProperty("AnnotationSpinBox",value);
  20459. /*:474*//*495:*/
  20460. #line 11254 "./typica.w"
  20461. constructor= engine->newFunction(constructTimerDisplay);
  20462. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  20463. engine->globalObject().setProperty("TimerDisplay",value);
  20464. /*:495*//*523:*/
  20465. #line 11778 "./typica.w"
  20466. constructor= engine->newFunction(constructWidgetDecorator);
  20467. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  20468. engine->globalObject().setProperty("WidgetDecorator",value);
  20469. /*:523*//*536:*/
  20470. #line 12060 "./typica.w"
  20471. constructor= engine->newFunction(constructLogEditWindow);
  20472. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  20473. engine->globalObject().setProperty("LogEditWindow",value);
  20474. /*:536*//*555:*/
  20475. #line 12587 "./typica.w"
  20476. constructor= engine->newFunction(constructXMLInput);
  20477. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  20478. engine->globalObject().setProperty("XMLInput",value);
  20479. /*:555*//*570:*/
  20480. #line 164 "./webview.w"
  20481. constructor= engine->newFunction(constructWebView);
  20482. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  20483. engine->globalObject().setProperty("WebView",value);
  20484. /*:570*//*578:*/
  20485. #line 256 "./webview.w"
  20486. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  20487. /*:578*//*581:*/
  20488. #line 298 "./webview.w"
  20489. constructor= engine->newFunction(constructWebElement);
  20490. engine->globalObject().setProperty("WebElement",constructor);
  20491. /*:581*//*593:*/
  20492. #line 76 "./printerselector.w"
  20493. constructor= engine->newFunction(constructPrinterSelector);
  20494. engine->globalObject().setProperty("PrinterSelector",constructor);
  20495. /*:593*//*601:*/
  20496. #line 12832 "./typica.w"
  20497. value= engine->newQObject(AppInstance);
  20498. engine->globalObject().setProperty("Application",value);
  20499. /*:601*//*659:*/
  20500. #line 13946 "./typica.w"
  20501. constructor= engine->newFunction(constructSqlQueryView);
  20502. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  20503. engine->globalObject().setProperty("SqlQueryView",value);
  20504. /*:659*//*770:*/
  20505. #line 15852 "./typica.w"
  20506. constructor= engine->newFunction(constructDeviceTreeModel);
  20507. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  20508. constructor);
  20509. engine->globalObject().setProperty("DeviceTreeModel",value);
  20510. /*:770*//*776:*/
  20511. #line 15992 "./typica.w"
  20512. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  20513. /*:776*//*792:*/
  20514. #line 16284 "./typica.w"
  20515. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  20516. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  20517. constructor);
  20518. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  20519. /*:792*//*863:*/
  20520. #line 56 "./settings.w"
  20521. constructor= engine->newFunction(constructSettingsWindow);
  20522. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  20523. engine->globalObject().setProperty("SettingsWindow",value);
  20524. #line 1 "./graphsettings.w"
  20525. /*:863*//*886:*/
  20526. #line 18919 "./typica.w"
  20527. constructor= engine->newFunction(constructModbusRTUDevice);
  20528. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  20529. engine->globalObject().setProperty("ModbusRTUDevice",value);
  20530. /*:886*//*904:*/
  20531. #line 705 "./modbus.w"
  20532. constructor= engine->newFunction(constructModbusNG);
  20533. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  20534. engine->globalObject().setProperty("ModbusNG",value);
  20535. /*:904*//*918:*/
  20536. #line 350 "./unsupportedserial.w"
  20537. engine->globalObject().setProperty("createDevice",
  20538. engine->newFunction(createDevice));
  20539. /*:918*//*930:*/
  20540. #line 622 "./unsupportedserial.w"
  20541. engine->globalObject().setProperty("getMeasurementTimestamp",
  20542. engine->newFunction(getMeasurementTimestamp));
  20543. /*:930*//*934:*/
  20544. #line 658 "./unsupportedserial.w"
  20545. constructor= engine->newFunction(constructSerialPort);
  20546. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  20547. engine->globalObject().setProperty("SerialPort",value);
  20548. /*:934*//*956:*/
  20549. #line 450 "./phidgets.w"
  20550. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  20551. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  20552. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  20553. /*:956*//*990:*/
  20554. #line 144 "./rate.w"
  20555. constructor= engine->newFunction(constructRateOfChange);
  20556. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  20557. engine->globalObject().setProperty("RateOfChange",value);
  20558. /*:990*//*1015:*/
  20559. #line 604 "./dataqsdk.w"
  20560. constructor= engine->newFunction(constructDataqSdkDevice);
  20561. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  20562. engine->globalObject().setProperty("DataqSdkDevice",value);
  20563. /*:1015*//*1042:*/
  20564. #line 73 "./scales.w"
  20565. constructor= engine->newFunction(constructDragLabel);
  20566. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  20567. engine->globalObject().setProperty("DragLabel",value);
  20568. /*:1042*//*1050:*/
  20569. #line 265 "./scales.w"
  20570. constructor= engine->newFunction(constructSerialScale);
  20571. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  20572. engine->globalObject().setProperty("SerialScale",value);
  20573. /*:1050*//*1054:*/
  20574. #line 351 "./scales.w"
  20575. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  20576. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  20577. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  20578. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  20579. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  20580. /*:1054*//*1078:*/
  20581. #line 271 "./valueannotation.w"
  20582. constructor= engine->newFunction(constructValueAnnotation);
  20583. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  20584. engine->globalObject().setProperty("ValueAnnotation",value);
  20585. /*:1078*//*1089:*/
  20586. #line 201 "./thresholdannotation.w"
  20587. constructor= engine->newFunction(constructAnnotator);
  20588. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  20589. engine->globalObject().setProperty("Annotator",value);
  20590. /*:1089*/
  20591. #line 13558 "./typica.w"
  20592. app.engine= engine;
  20593. /*194:*/
  20594. #line 4469 "./typica.w"
  20595. QString styleText;
  20596. QString programText;
  20597. QDomElement currentElement;
  20598. for(int i= 0;i<children.size();i++)
  20599. {
  20600. QDomNode currentNode= children.at(i);
  20601. if(currentNode.nodeName()=="style")
  20602. {
  20603. currentElement= currentNode.toElement();
  20604. styleText.append(currentElement.text());
  20605. }
  20606. else if(currentNode.nodeName()=="program")
  20607. {
  20608. currentElement= currentNode.toElement();
  20609. programText.append(currentElement.text());
  20610. }
  20611. }
  20612. app.setStyleSheet(styleText);
  20613. QScriptValue result= engine->evaluate(programText);
  20614. /*195:*/
  20615. #line 4494 "./typica.w"
  20616. if(engine->hasUncaughtException())
  20617. {
  20618. int line= engine->uncaughtExceptionLineNumber();
  20619. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  20620. result.toString();
  20621. QString trace;
  20622. foreach(trace,engine->uncaughtExceptionBacktrace())
  20623. {
  20624. qDebug()<<trace;
  20625. }
  20626. }
  20627. /*:195*/
  20628. #line 4489 "./typica.w"
  20629. /*:194*/
  20630. #line 13560 "./typica.w"
  20631. int retval= app.exec();
  20632. delete engine;
  20633. return retval;
  20634. }
  20635. /*:636*/
  20636. #line 532 "./typica.w"
  20637. #include "moc_typica.cpp"
  20638. /*:3*/