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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422
  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 6821 "./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 12809 "./typica.w"
  30. #line 1 "./printerselector.w"
  31. /*:587*//*589:*/
  32. #line 40 "./printerselector.w"
  33. #include "printerselector.h"
  34. /*:589*//*714:*/
  35. #line 489 "./daterangeselector.w"
  36. #include "daterangeselector.h"
  37. #line 14571 "./typica.w"
  38. /*:714*//*822:*/
  39. #line 17142 "./typica.w"
  40. #include "qextserialport.h"
  41. #include "qextserialenumerator.h"
  42. /*:822*//*1016:*/
  43. #line 124 "./dataqsdk.w"
  44. #ifdef Q_OS_WIN32
  45. #include <windef.h>
  46. #else
  47. #define PASCAL
  48. #endif
  49. /*:1016*//*1040:*/
  50. #line 862 "./dataqsdk.w"
  51. #include <limits>
  52. /*:1040*//*1055:*/
  53. #line 62 "./scales.w"
  54. #include "draglabel.h"
  55. /*:1055*//*1070:*/
  56. #line 361 "./scales.w"
  57. #include "scale.h"
  58. /*:1070*/
  59. #line 525 "./typica.w"
  60. /*26:*/
  61. #line 1051 "./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. void setupFinished();
  76. signals:
  77. void aboutToClose(void);
  78. void windowReady(void);
  79. protected:
  80. void closeEvent(QCloseEvent*event);
  81. void showEvent(QShowEvent*event);
  82. private:
  83. QString cprompt;
  84. };
  85. /*:26*//*172:*/
  86. #line 3989 "./typica.w"
  87. class SqlQueryConnection:public QSqlQuery
  88. {
  89. public:
  90. SqlQueryConnection(const QString&query= QString());
  91. ~SqlQueryConnection();
  92. QSqlQuery*operator->()const;
  93. private:
  94. QString connection;
  95. QSqlQuery*q;
  96. };
  97. /*:172*//*249:*/
  98. #line 5978 "./typica.w"
  99. class NumericDelegate:public QItemDelegate
  100. {
  101. Q_OBJECT
  102. public:
  103. NumericDelegate(QObject*parent= NULL);
  104. QWidget*createEditor(QWidget*parent,
  105. const QStyleOptionViewItem&option,
  106. const QModelIndex&index)const;
  107. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  108. void setModelData(QWidget*editor,QAbstractItemModel*model,
  109. const QModelIndex&index)const;
  110. void updateEditorGeometry(QWidget*editor,
  111. const QStyleOptionViewItem&option,
  112. const QModelIndex&index)const;
  113. };
  114. /*:249*//*255:*/
  115. #line 6071 "./typica.w"
  116. class ScriptValidator:public QValidator
  117. {
  118. Q_OBJECT
  119. public:
  120. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  121. void fixup(QString&input)const;
  122. QValidator::State validate(QString&input,int&pos)const;
  123. private:
  124. QValidator*v;
  125. };
  126. /*:255*//*299:*/
  127. #line 438 "./units.w"
  128. Q_DECLARE_METATYPE(Units::Unit)
  129. /*:299*//*304:*/
  130. #line 19 "./measurement.w"
  131. class Measurement:public QVariantMap
  132. {
  133. public:
  134. Measurement(double temperature= 0,QTime time= QTime(),
  135. Units::Unit sc= Units::Fahrenheit);
  136. Measurement(double temperature);
  137. double temperature()const;
  138. QTime time()const;
  139. void setTemperature(double temperature);
  140. void setTime(QTime time);
  141. void setUnit(Units::Unit scale);
  142. Units::Unit scale()const;
  143. Measurement toFahrenheit();
  144. Measurement toCelsius();
  145. Measurement toKelvin();
  146. Measurement toRankine();
  147. };
  148. /*:304*//*308:*/
  149. #line 128 "./measurement.w"
  150. Q_DECLARE_METATYPE(Measurement)
  151. /*:308*//*315:*/
  152. #line 6885 "./typica.w"
  153. class Channel;
  154. class DAQImplementation;
  155. class DAQ:public QObject
  156. {
  157. Q_OBJECT
  158. Q_ENUMS(ThermocoupleType)
  159. DAQImplementation*imp;
  160. private slots:
  161. void threadFinished();
  162. public:
  163. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  164. ~DAQ();
  165. Channel*newChannel(int units,int thermocouple);
  166. Q_INVOKABLE void setClockRate(double Hz);
  167. Q_INVOKABLE void start();
  168. Q_INVOKABLE void stop();
  169. enum ThermocoupleType
  170. {
  171. TypeJ= 10072,
  172. TypeK= 10073,
  173. TypeN= 10077,
  174. TypeR= 10082,
  175. TypeS= 10085,
  176. TypeT= 10086,
  177. TypeB= 10047,
  178. TypeE= 10055
  179. };
  180. };
  181. /*:315*//*316:*/
  182. #line 6923 "./typica.w"
  183. class DAQImplementation:public QThread
  184. {
  185. Q_OBJECT
  186. public:
  187. DAQImplementation(const QString&driverinfo);
  188. ~DAQImplementation();
  189. void run();
  190. void measure();
  191. /*317:*/
  192. #line 6943 "./typica.w"
  193. typedef int(*daqfp)(...);
  194. daqfp read;
  195. daqfp errorInfo;
  196. daqfp startTask;
  197. daqfp createTask;
  198. daqfp createChannel;
  199. daqfp setClock;
  200. daqfp stopTask;
  201. daqfp clearTask;
  202. daqfp resetDevice;
  203. daqfp waitForMeasurement;
  204. /*:317*/
  205. #line 6932 "./typica.w"
  206. /*318:*/
  207. #line 6959 "./typica.w"
  208. bool useBase;
  209. QString device;
  210. QVector<Channel*> channelMap;
  211. unsigned int handle;
  212. int error;
  213. int channels;
  214. bool ready;
  215. QLibrary driver;
  216. QVector<Units::Unit> unitMap;
  217. /*:318*/
  218. #line 6933 "./typica.w"
  219. };
  220. /*:316*//*334:*/
  221. #line 7464 "./typica.w"
  222. class FakeDAQImplementation:public QThread
  223. {
  224. Q_OBJECT
  225. public:
  226. FakeDAQImplementation();
  227. ~FakeDAQImplementation();
  228. void run();
  229. void measure();
  230. QVector<Channel*> channelMap;
  231. int channels;
  232. bool ready;
  233. double clockRate;
  234. };
  235. class FakeDAQ:public QObject
  236. {
  237. Q_OBJECT
  238. FakeDAQImplementation*imp;
  239. public:
  240. FakeDAQ(QString device);
  241. ~FakeDAQ();
  242. Channel*newChannel(int units,int thermocouple);
  243. Q_INVOKABLE void setClockRate(double Hz);
  244. Q_INVOKABLE void start();
  245. };
  246. /*:334*//*341:*/
  247. #line 7651 "./typica.w"
  248. class Channel:public QObject
  249. {
  250. Q_OBJECT
  251. public:
  252. Channel();
  253. ~Channel();
  254. public slots:
  255. void input(Measurement measurement);
  256. signals:
  257. void newData(Measurement);
  258. };
  259. /*:341*//*345:*/
  260. #line 7718 "./typica.w"
  261. class LinearCalibrator:public QObject
  262. {
  263. Q_OBJECT
  264. Q_PROPERTY(double measuredLower READ measuredLower
  265. WRITE setMeasuredLower)
  266. Q_PROPERTY(double measuredUpper READ measuredUpper
  267. WRITE setMeasuredUpper)
  268. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  269. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  270. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  271. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  272. public:
  273. LinearCalibrator(QObject*parent= NULL);
  274. double measuredLower();
  275. double measuredUpper();
  276. double mappedLower();
  277. double mappedUpper();
  278. bool isClosedRange();
  279. double sensitivity();
  280. public slots:
  281. void setMeasuredLower(double lower);
  282. void setMeasuredUpper(double upper);
  283. void setMappedLower(double lower);
  284. void setMappedUpper(double upper);
  285. void setClosedRange(bool closed);
  286. void setSensitivity(double sensitivity);
  287. Measurement newMeasurement(Measurement measure);
  288. signals:
  289. void measurement(Measurement measure);
  290. void newData(Measurement measure);
  291. private:
  292. double Lo1;
  293. double Lo2;
  294. double Up1;
  295. double Up2;
  296. double sensitivitySetting;
  297. bool clamp;
  298. };
  299. /*:345*//*352:*/
  300. #line 7914 "./typica.w"
  301. class LinearSplineInterpolator:public QObject
  302. {
  303. Q_OBJECT
  304. public:
  305. LinearSplineInterpolator(QObject*parent= NULL);
  306. Q_INVOKABLE void add_pair(double source,double destination);
  307. public slots:
  308. Measurement newMeasurement(Measurement measure);
  309. signals:
  310. void newData(Measurement measure);
  311. private:
  312. void make_interpolators();
  313. QMap<double,double> *pairs;
  314. QList<LinearCalibrator*> *interpolators;
  315. };
  316. /*:352*//*357:*/
  317. #line 8050 "./typica.w"
  318. class TemperatureDisplay:public QLCDNumber
  319. {
  320. Q_OBJECT
  321. int unit;
  322. bool r;
  323. public:
  324. TemperatureDisplay(QWidget*parent= NULL);
  325. ~TemperatureDisplay();
  326. public slots:
  327. void setValue(Measurement temperature);
  328. void invalidate();
  329. void setDisplayUnits(Units::Unit scale);
  330. void setRelativeMode(bool relative);
  331. };
  332. /*:357*//*368:*/
  333. #line 8269 "./typica.w"
  334. class MeasurementTimeOffset:public QObject
  335. {
  336. Q_OBJECT
  337. QTime epoch;
  338. QTime previous;
  339. bool hasPrevious;
  340. public:
  341. MeasurementTimeOffset(QTime zero);
  342. QTime zeroTime();
  343. public slots:
  344. void newMeasurement(Measurement measure);
  345. void setZeroTime(QTime zero);
  346. signals:
  347. void measurement(Measurement measure);
  348. };
  349. /*:368*//*375:*/
  350. #line 8421 "./typica.w"
  351. class ThresholdDetector:public QObject
  352. {
  353. Q_OBJECT
  354. Q_ENUMS(EdgeDirection)
  355. public:
  356. enum EdgeDirection{
  357. Ascending,Descending
  358. };
  359. ThresholdDetector(double value);
  360. public slots:
  361. void newMeasurement(Measurement measure);
  362. void setThreshold(double value);
  363. void setEdgeDirection(EdgeDirection direction);
  364. signals:
  365. void timeForValue(double);
  366. private:
  367. bool previousValueValid;
  368. double previousValue;
  369. double threshold;
  370. EdgeDirection currentDirection;
  371. };
  372. /*:375*//*380:*/
  373. #line 8537 "./typica.w"
  374. class ZeroEmitter:public QObject
  375. {
  376. Q_OBJECT
  377. Q_PROPERTY(int column READ column WRITE setColumn)
  378. Measurement cache;
  379. int col;
  380. public:
  381. ZeroEmitter(int tempcolumn= 1);
  382. int column();
  383. double lastTemperature();
  384. public slots:
  385. void newMeasurement(Measurement measure);
  386. void setColumn(int column);
  387. void emitZero();
  388. signals:
  389. void measurement(Measurement measure,int tempcolumn);
  390. };
  391. /*:380*//*385:*/
  392. #line 8631 "./typica.w"
  393. class MeasurementAdapter:public QObject
  394. {
  395. Q_OBJECT
  396. int col;
  397. public:
  398. MeasurementAdapter(int tempcolumn);
  399. int column();
  400. public slots:
  401. void newMeasurement(Measurement measure);
  402. void setColumn(int column);
  403. signals:
  404. void measurement(Measurement measure,int tempcolumn);
  405. };
  406. /*:385*//*390:*/
  407. #line 8720 "./typica.w"
  408. class GraphView:public QGraphicsView
  409. {
  410. Q_OBJECT
  411. QGraphicsScene*theScene;
  412. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  413. QMap<int,QPointF> *prevPoints;
  414. QMap<int,double> *translations;
  415. QList<QGraphicsItem*> *gridLinesF;
  416. QList<QGraphicsItem*> *gridLinesC;
  417. QList<QGraphicsItem*> *relativeGridLines;
  418. bool relativeEnabled;
  419. bool timeIndicatorEnabled;
  420. QGraphicsLineItem*timeLine;
  421. LinearSplineInterpolator*relativeAdjuster;
  422. public:
  423. GraphView(QWidget*parent= NULL);
  424. void removeSeries(int column);
  425. protected:
  426. void resizeEvent(QResizeEvent*event);
  427. public slots:
  428. void newMeasurement(Measurement measure,int tempcolumn);
  429. void setSeriesTranslation(int column,double offset);
  430. void setTimeIndicatorEnabled(bool enabled);
  431. void clear();
  432. void showF();
  433. void showC();
  434. };
  435. /*:390*//*407:*/
  436. #line 9188 "./typica.w"
  437. class MeasurementModel;
  438. class ZoomLog:public QTableView
  439. {
  440. Q_OBJECT
  441. /*408:*/
  442. #line 9237 "./typica.w"
  443. MeasurementModel*model_ms;
  444. MeasurementModel*model_1s;
  445. MeasurementModel*model_5s;
  446. MeasurementModel*model_10s;
  447. MeasurementModel*model_15s;
  448. MeasurementModel*model_30s;
  449. MeasurementModel*model_1m;
  450. QList<MeasurementModel*> modelSet;
  451. QHash<int,Measurement> lastMeasurement;
  452. MeasurementModel*currentModel;
  453. QList<int> saveTempCols;
  454. QList<int> saveControlCols;
  455. QList<int> saveNoteCols;
  456. QList<int> currentColumnSet;
  457. /*:408*/
  458. #line 9193 "./typica.w"
  459. void switchLOD(MeasurementModel*m);
  460. private slots:
  461. void centerOn(int row);
  462. void persistColumnResize(int column,int oldsize,int newsize);
  463. void restoreColumnWidths();
  464. public:
  465. ZoomLog();
  466. QVariant data(int row,int column)const;
  467. Q_INVOKABLE int rowCount();
  468. bool saveXML(QIODevice*device);
  469. bool saveCSV(QIODevice*device);
  470. QString lastTime(int series);
  471. Q_INVOKABLE Units::Unit displayUnits();
  472. public slots:
  473. void setVisible(bool visibility);
  474. void setHeaderData(int section,QString text);
  475. void LOD_ms();
  476. void LOD_1s();
  477. void LOD_5s();
  478. void LOD_10s();
  479. void LOD_15s();
  480. void LOD_30s();
  481. void LOD_1m();
  482. void newMeasurement(Measurement measure,int tempcolumn);
  483. void newAnnotation(QString annotation,int tempcolumn,
  484. int annotationcolumn);
  485. void clear();
  486. void addOutputTemperatureColumn(int column);
  487. void addOutputControlColumn(int column);
  488. void addOutputAnnotationColumn(int column);
  489. void clearOutputColumns();
  490. void setDisplayUnits(Units::Unit scale);
  491. void addToCurrentColumnSet(int column);
  492. void clearCurrentColumnSet();
  493. protected:
  494. virtual void showEvent(QShowEvent*event);
  495. };
  496. /*:407*//*433:*/
  497. #line 9942 "./typica.w"
  498. class MeasurementList;
  499. class MeasurementModel:public QAbstractItemModel
  500. {
  501. Q_OBJECT
  502. Units::Unit unit;
  503. QList<MeasurementList*> *entries;
  504. QStringList*hData;
  505. int colcount;
  506. QHash<int,int> *lastTemperature;
  507. QList<MeasurementList*> ::iterator lastInsertion;
  508. QHash<int,bool> *controlColumns;
  509. public:
  510. MeasurementModel(QObject*parent= NULL);
  511. ~MeasurementModel();
  512. int rowCount(const QModelIndex&parent= QModelIndex())const;
  513. int columnCount(const QModelIndex&parent= QModelIndex())const;
  514. bool setHeaderData(int section,Qt::Orientation orientation,
  515. const QVariant&value,int role= Qt::DisplayRole);
  516. QVariant data(const QModelIndex&index,int role)const;
  517. bool setData(const QModelIndex&index,const QVariant&value,
  518. int role= Qt::EditRole);
  519. Qt::ItemFlags flags(const QModelIndex&index)const;
  520. QVariant headerData(int section,Qt::Orientation orientation,
  521. int role= Qt::DisplayRole)const;
  522. QModelIndex index(int row,int column,
  523. const QModelIndex&parent= QModelIndex())const;
  524. QModelIndex parent(const QModelIndex&index)const;
  525. Units::Unit displayUnits();
  526. public slots:
  527. void newMeasurement(Measurement measure,int tempcolumn);
  528. void newAnnotation(QString annotation,int tempcolumn,
  529. int annotationColumn);
  530. void clear();
  531. void setDisplayUnits(Units::Unit scale);
  532. signals:
  533. void rowChanged(int);
  534. };
  535. /*:433*//*434:*/
  536. #line 9986 "./typica.w"
  537. class MeasurementList:public QVariantList
  538. {
  539. public:
  540. bool operator<(const MeasurementList&other)const;
  541. bool operator==(const MeasurementList&other)const;
  542. };
  543. /*:434*//*460:*/
  544. #line 10644 "./typica.w"
  545. class AnnotationButton:public QPushButton
  546. {
  547. Q_OBJECT
  548. QString note;
  549. int tc;
  550. int ac;
  551. int count;
  552. public:
  553. AnnotationButton(const QString&text,QWidget*parent= NULL);
  554. public slots:
  555. void setAnnotation(const QString&annotation);
  556. void setTemperatureColumn(int tempcolumn);
  557. void setAnnotationColumn(int annotationcolumn);
  558. void annotate();
  559. void resetCount();
  560. signals:
  561. void annotation(QString annotation,int tempcolumn,
  562. int notecolumn);
  563. };
  564. /*:460*//*468:*/
  565. #line 10769 "./typica.w"
  566. class AnnotationSpinBox:public QDoubleSpinBox
  567. {
  568. Q_OBJECT
  569. QString pretext;
  570. QString posttext;
  571. int tc;
  572. int ac;
  573. bool change;
  574. public:
  575. AnnotationSpinBox(const QString&pret,const QString&postt,
  576. QWidget*parent= NULL);
  577. public slots:
  578. void setPretext(const QString&pret);
  579. void setPosttext(const QString&postt);
  580. void setTemperatureColumn(int tempcolumn);
  581. void setAnnotationColumn(int annotationcolumn);
  582. void annotate();
  583. void resetChange();
  584. signals:
  585. void annotation(QString annotation,int tempcolumn,
  586. int notecolumn);
  587. };
  588. /*:468*//*476:*/
  589. #line 10928 "./typica.w"
  590. class TimerDisplay:public QLCDNumber
  591. {
  592. Q_OBJECT
  593. /*477:*/
  594. #line 10978 "./typica.w"
  595. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  596. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  597. Q_PROPERTY(bool running READ isRunning)
  598. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  599. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  600. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  601. Q_PROPERTY(QString value READ value)
  602. /*:477*/
  603. #line 10932 "./typica.w"
  604. private slots:
  605. void updateTime();
  606. void setCountUpMode();
  607. void setCountDownMode();
  608. void setClockMode();
  609. public:
  610. TimerDisplay(QWidget*parent= NULL);
  611. ~TimerDisplay();
  612. enum TimerMode
  613. {
  614. CountUp,
  615. CountDown,
  616. Clock
  617. };
  618. QString value();
  619. QTime seconds();
  620. TimerMode mode();
  621. bool isRunning();
  622. QTime resetValue();
  623. QString displayFormat();
  624. bool autoReset();
  625. public slots:
  626. void setTimer(QTime value= QTime(0,0,0));
  627. void setMode(TimerMode mode);
  628. void startTimer();
  629. void stopTimer();
  630. void copyTimer();
  631. void setResetValue(QTime value= QTime(0,0,0));
  632. void reset();
  633. void setDisplayFormat(QString format);
  634. void setAutoReset(bool reset);
  635. void updateDisplay();
  636. signals:
  637. void valueChanged(QTime);
  638. void runStateChanged(bool);
  639. private:
  640. /*478:*/
  641. #line 10989 "./typica.w"
  642. QTime s;
  643. QTime r;
  644. QTimer clock;
  645. TimerDisplay::TimerMode m;
  646. bool running;
  647. bool ar;
  648. QAction*startAction;
  649. QAction*stopAction;
  650. QAction*resetAction;
  651. QString f;
  652. QTime relative;
  653. QTime base;
  654. /*:478*/
  655. #line 10969 "./typica.w"
  656. };
  657. /*:476*//*499:*/
  658. #line 11381 "./typica.w"
  659. class PackLayout:public QLayout
  660. {
  661. int doLayout(const QRect&rect,bool testOnly)const;
  662. QList<QLayoutItem*> itemList;
  663. Qt::Orientations orientation;
  664. public:
  665. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  666. PackLayout(int spacing= -1);
  667. ~PackLayout();
  668. void addItem(QLayoutItem*item);
  669. Qt::Orientations expandingDirections()const;
  670. bool hasHeightForWidth()const;
  671. int heightForWidth(int width)const;
  672. int count()const;
  673. QLayoutItem*itemAt(int index)const;
  674. QSize minimumSize()const;
  675. void setGeometry(const QRect&rect);
  676. void setOrientation(Qt::Orientations direction);
  677. QSize sizeHint()const;
  678. QLayoutItem*takeAt(int index);
  679. };
  680. /*:499*//*512:*/
  681. #line 11659 "./typica.w"
  682. class SceneButton:public QGraphicsScene
  683. {
  684. Q_OBJECT
  685. public:
  686. SceneButton();
  687. ~SceneButton();
  688. protected:
  689. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  690. signals:
  691. void clicked(QPoint pos);
  692. };
  693. /*:512*//*514:*/
  694. #line 11701 "./typica.w"
  695. class WidgetDecorator:public QWidget
  696. {
  697. Q_OBJECT
  698. PackLayout*layout;
  699. QGraphicsView*label;
  700. QGraphicsTextItem*text;
  701. SceneButton*scene;
  702. public:
  703. WidgetDecorator(QWidget*widget,const QString&labeltext,
  704. Qt::Orientations orientation= Qt::Horizontal,
  705. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  706. ~WidgetDecorator();
  707. void setBackgroundBrush(QBrush background);
  708. void setTextColor(QColor color);
  709. };
  710. /*:514*//*525:*/
  711. #line 11876 "./typica.w"
  712. class LogEditWindow:public QMainWindow
  713. {
  714. Q_OBJECT
  715. QWidget*centralWidget;
  716. PackLayout*mainLayout;
  717. QHBoxLayout*addRowsLayout;
  718. QLabel*startTimeLabel;
  719. QTimeEdit*startTime;
  720. QLabel*endTimeLabel;
  721. QTimeEdit*endTime;
  722. QLabel*intervalLabel;
  723. QSpinBox*interval;
  724. QPushButton*addRows;
  725. QAction*saveXml;
  726. QAction*saveCsv;
  727. QAction*openXml;
  728. MeasurementModel*model;
  729. QTableView*log;
  730. private slots:
  731. void addTheRows();
  732. void saveXML();
  733. void saveCSV();
  734. void openXML();
  735. protected:
  736. void closeEvent(QCloseEvent*event);
  737. public:
  738. LogEditWindow();
  739. };
  740. /*:525*//*539:*/
  741. #line 12184 "./typica.w"
  742. class XMLOutput:public QObject
  743. {
  744. Q_OBJECT
  745. MeasurementModel*data;
  746. QIODevice*out;
  747. int time;
  748. QMap<int,QString> temperatureColumns;
  749. QMap<int,QString> controlColumns;
  750. QMap<int,QString> annotationColumns;
  751. public:
  752. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  753. void addTemperatureColumn(const QString&series,int column);
  754. void addControlColumn(const QString&series,int column);
  755. void addAnnotationColumn(const QString&series,int column);
  756. void setModel(MeasurementModel*model);
  757. void setTimeColumn(int column);
  758. void setDevice(QIODevice*device);
  759. bool output();
  760. };
  761. /*:539*//*546:*/
  762. #line 12420 "./typica.w"
  763. class XMLInput:public QObject
  764. {
  765. Q_OBJECT
  766. int firstc;
  767. QIODevice*in;
  768. public:
  769. XMLInput(QIODevice*input,int c);
  770. void setFirstColumn(int column);
  771. void setDevice(QIODevice*device);
  772. bool input();
  773. signals:
  774. void measure(Measurement,int);
  775. void annotation(QString,int,int);
  776. void newTemperatureColumn(int,QString);
  777. void newAnnotationColumn(int,QString);
  778. void lastColumn(int);
  779. };
  780. /*:546*//*557:*/
  781. #line 12674 "./typica.w"
  782. class CSVOutput
  783. {
  784. MeasurementModel*data;
  785. QIODevice*out;
  786. int time;
  787. QMap<int,QString> temperatureColumns;
  788. QMap<int,QString> controlColumns;
  789. QMap<int,QString> annotationColumns;
  790. public:
  791. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  792. void addTemperatureColumn(const QString&series,int column);
  793. void addControlColumn(const QString&series,int column);
  794. void addAnnotationColumn(const QString&series,int column);
  795. void setModel(MeasurementModel*model);
  796. void setTimeColumn(int column);
  797. void setDevice(QIODevice*device);
  798. bool output();
  799. };
  800. /*:557*//*597:*/
  801. #line 12819 "./typica.w"
  802. #define AppInstance (qobject_cast<Application *> (qApp))
  803. class NodeInserter;
  804. class DeviceTreeModel;
  805. class Application:public QApplication
  806. {
  807. Q_OBJECT
  808. public:
  809. Application(int&argc,char**argv);
  810. QDomDocument*configuration();
  811. /*746:*/
  812. #line 15417 "./typica.w"
  813. QDomDocument deviceConfiguration();
  814. /*:746*//*779:*/
  815. #line 16090 "./typica.w"
  816. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  817. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  818. const QModelIndex&index);
  819. /*:779*//*784:*/
  820. #line 16194 "./typica.w"
  821. QList<NodeInserter*> topLevelNodeInserters;
  822. /*:784*/
  823. #line 12830 "./typica.w"
  824. QSqlDatabase database();
  825. Q_INVOKABLE bool databaseConnected();
  826. Q_INVOKABLE QString currentTypicaUser();
  827. Q_INVOKABLE bool login(const QString&user,const QString&password);
  828. Q_INVOKABLE bool autoLogin();
  829. QScriptEngine*engine;
  830. public slots:
  831. void setDatabaseConnected(bool status);
  832. void setCurrentTypicaUser(const QString&user);
  833. /*747:*/
  834. #line 15424 "./typica.w"
  835. void saveDeviceConfiguration();
  836. /*:747*/
  837. #line 12840 "./typica.w"
  838. signals:
  839. void userChanged(const QString&user);
  840. private:
  841. /*745:*/
  842. #line 15408 "./typica.w"
  843. QDomDocument deviceConfigurationDocument;
  844. /*:745*//*778:*/
  845. #line 16084 "./typica.w"
  846. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  847. /*:778*/
  848. #line 12844 "./typica.w"
  849. QDomDocument conf;
  850. bool connectionStatus;
  851. QString currentUser;
  852. };
  853. /*:597*//*606:*/
  854. #line 12986 "./typica.w"
  855. class SaltModel:public QAbstractItemModel
  856. {
  857. Q_OBJECT
  858. QList<QList<QMap<int,QVariant> > > modelData;
  859. QStringList hData;
  860. int colcount;
  861. public:
  862. SaltModel(int columns);
  863. ~SaltModel();
  864. int rowCount(const QModelIndex&parent= QModelIndex())const;
  865. int columnCount(const QModelIndex&parent= QModelIndex())const;
  866. bool setHeaderData(int section,Qt::Orientation orientation,
  867. const QVariant&value,int role= Qt::DisplayRole);
  868. QVariant data(const QModelIndex&index,int role)const;
  869. bool setData(const QModelIndex&index,const QVariant&value,
  870. int role= Qt::EditRole);
  871. Qt::ItemFlags flags(const QModelIndex&index)const;
  872. QVariant headerData(int section,Qt::Orientation orientation,
  873. int role= Qt::DisplayRole)const;
  874. QModelIndex index(int row,int column,
  875. const QModelIndex&parent= QModelIndex())const;
  876. QModelIndex parent(const QModelIndex&index)const;
  877. QString arrayLiteral(int column,int role)const;
  878. QString quotedArrayLiteral(int column,int role)const;
  879. void clear();
  880. bool removeRows(int row,int count,
  881. const QModelIndex&parent= QModelIndex());
  882. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  883. };
  884. /*:606*//*622:*/
  885. #line 13371 "./typica.w"
  886. class SqlComboBox:public QComboBox
  887. {
  888. Q_OBJECT
  889. int dataColumn;
  890. int displayColumn;
  891. bool dataColumnShown;
  892. QString specialNullText;
  893. QVariant specialNullData;
  894. public:
  895. SqlComboBox();
  896. ~SqlComboBox();
  897. SqlComboBox*clone(QWidget*parent);
  898. public slots:
  899. void addNullOption();
  900. void addSqlOptions(QString query);
  901. void setDataColumn(int column);
  902. void setDisplayColumn(int column);
  903. void showData(bool show);
  904. void setNullText(QString nullText);
  905. void setNullData(QVariant nullData);
  906. };
  907. /*:622*//*629:*/
  908. #line 13518 "./typica.w"
  909. class SqlComboBoxDelegate:public QItemDelegate
  910. {
  911. Q_OBJECT
  912. SqlComboBox*delegate;
  913. public:
  914. SqlComboBoxDelegate(QObject*parent= NULL);
  915. QWidget*createEditor(QWidget*parent,
  916. const QStyleOptionViewItem&option,
  917. const QModelIndex&index)const;
  918. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  919. void setModelData(QWidget*editor,QAbstractItemModel*model,
  920. const QModelIndex&index)const;
  921. void setWidget(SqlComboBox*widget);
  922. virtual QSize sizeHint()const;
  923. void updateEditorGeometry(QWidget*editor,
  924. const QStyleOptionViewItem&option,
  925. const QModelIndex&index)const;
  926. };
  927. /*:629*//*644:*/
  928. #line 13729 "./typica.w"
  929. class SqlConnectionSetup:public QDialog
  930. {
  931. Q_OBJECT
  932. public:
  933. SqlConnectionSetup();
  934. ~SqlConnectionSetup();
  935. public slots:
  936. void testConnection();
  937. private:
  938. QFormLayout*formLayout;
  939. QComboBox*driver;
  940. QLineEdit*hostname;
  941. QLineEdit*portnumber;
  942. QLineEdit*dbname;
  943. QLineEdit*user;
  944. QLineEdit*password;
  945. QVBoxLayout*layout;
  946. QHBoxLayout*buttons;
  947. QPushButton*cancelButton;
  948. QPushButton*connectButton;
  949. };
  950. /*:644*//*649:*/
  951. #line 13879 "./typica.w"
  952. class SqlQueryView:public QTableView
  953. {
  954. Q_OBJECT
  955. public:
  956. SqlQueryView(QWidget*parent= NULL);
  957. void setQuery(const QString&query);
  958. bool setHeaderData(int section,Qt::Orientation orientation,
  959. const QVariant&value,int role);
  960. Q_INVOKABLE QVariant data(int row,int column,
  961. int role= Qt::DisplayRole);
  962. signals:
  963. void openEntry(QString key);
  964. void openEntryRow(int row);
  965. protected:
  966. virtual void showEvent(QShowEvent*event);
  967. private slots:
  968. void openRow(const QModelIndex&index);
  969. void persistColumnResize(int column,int oldsize,int newsize);
  970. };
  971. /*:649*//*664:*/
  972. #line 14134 "./typica.w"
  973. class ReportAction:public QAction
  974. {
  975. Q_OBJECT
  976. public:
  977. ReportAction(const QString&fileName,const QString&reportName,
  978. QObject*parent= NULL);
  979. private slots:
  980. void createReport();
  981. private:
  982. QString reportFile;
  983. };
  984. /*:664*//*676:*/
  985. #line 14345 "./typica.w"
  986. class ReportTable:public QObject
  987. {
  988. Q_OBJECT
  989. QTextFrame*area;
  990. QDomElement configuration;
  991. QMap<QString,QVariant> bindings;
  992. public:
  993. ReportTable(QTextFrame*frame,QDomElement description);
  994. ~ReportTable();
  995. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  996. public slots:
  997. void refresh();
  998. };
  999. /*:676*//*689:*/
  1000. #line 63 "./plugins.w"
  1001. class PluginAction:public QAction
  1002. {
  1003. Q_OBJECT
  1004. Q_PROPERTY(QString preRun READ preRun WRITE setPreRun);
  1005. Q_PROPERTY(QString postRun READ postRun WRITE setPostRun);
  1006. public:
  1007. PluginAction(const QFileInfo&info,QObject*parent);
  1008. QString preRun();
  1009. QString postRun();
  1010. public slots:
  1011. void setPreRun(const QString&script);
  1012. void setPostRun(const QString&script);
  1013. private slots:
  1014. void runScript();
  1015. private:
  1016. QString pluginFile;
  1017. QString preRunScript;
  1018. QString postRunScript;
  1019. };
  1020. /*:689*//*692:*/
  1021. #line 155 "./plugins.w"
  1022. Q_DECLARE_METATYPE(QScriptValue)
  1023. /*:692*//*715:*/
  1024. #line 14586 "./typica.w"
  1025. class FormArray:public QScrollArea
  1026. {
  1027. Q_OBJECT
  1028. QDomElement configuration;
  1029. QWidget itemContainer;
  1030. QVBoxLayout itemLayout;
  1031. int maxwidth;
  1032. int maxheight;
  1033. public:
  1034. FormArray(QDomElement description);
  1035. Q_INVOKABLE QWidget*elementAt(int index);
  1036. Q_INVOKABLE int elements();
  1037. public slots:
  1038. void addElements(int copies= 1);
  1039. void removeAllElements();
  1040. void setMaximumElementWidth(int width);
  1041. void setMaximumElementHeight(int height);
  1042. };
  1043. /*:715*//*725:*/
  1044. #line 14802 "./typica.w"
  1045. class ScaleControl:public QGraphicsView
  1046. {
  1047. Q_OBJECT
  1048. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1049. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1050. /*726:*/
  1051. #line 14828 "./typica.w"
  1052. QGraphicsScene scene;
  1053. QGraphicsPolygonItem initialDecrement;
  1054. QGraphicsPolygonItem initialIncrement;
  1055. QGraphicsPolygonItem finalDecrement;
  1056. QGraphicsPolygonItem finalIncrement;
  1057. QGraphicsPolygonItem initialIndicator;
  1058. QGraphicsPolygonItem finalIndicator;
  1059. QGraphicsPathItem scaleLine;
  1060. QPolygonF left;
  1061. QPolygonF right;
  1062. QPolygonF down;
  1063. QPolygonF up;
  1064. QPainterPath scalePath;
  1065. QBrush initialBrush;
  1066. QBrush finalBrush;
  1067. double nonScoredValue;
  1068. double scoredValue;
  1069. bool initialSet;
  1070. bool finalSet;
  1071. bool scaleDown;
  1072. /*:726*/
  1073. #line 14808 "./typica.w"
  1074. public:
  1075. ScaleControl();
  1076. double initialValue(void);
  1077. double finalValue(void);
  1078. virtual QSize sizeHint()const;
  1079. public slots:
  1080. void setInitialValue(double value);
  1081. void setFinalValue(double value);
  1082. signals:
  1083. void initialChanged(double);
  1084. void finalChanged(double);
  1085. protected:
  1086. virtual void mousePressEvent(QMouseEvent*event);
  1087. virtual void mouseReleaseEvent(QMouseEvent*event);
  1088. };
  1089. /*:725*//*737:*/
  1090. #line 15125 "./typica.w"
  1091. class IntensityControl:public QGraphicsView
  1092. {
  1093. Q_OBJECT
  1094. Q_PROPERTY(double value READ value WRITE setValue)
  1095. QGraphicsScene scene;
  1096. QGraphicsPolygonItem decrement;
  1097. QGraphicsPolygonItem increment;
  1098. QGraphicsPolygonItem indicator;
  1099. QGraphicsPathItem scaleLine;
  1100. QPolygonF left;
  1101. QPolygonF up;
  1102. QPolygonF down;
  1103. QPainterPath scalePath;
  1104. QBrush theBrush;
  1105. double theValue;
  1106. bool valueSet;
  1107. bool scaleDown;
  1108. public:
  1109. IntensityControl();
  1110. double value();
  1111. virtual QSize sizeHint()const;
  1112. public slots:
  1113. void setValue(double val);
  1114. signals:
  1115. void valueChanged(double);
  1116. protected:
  1117. virtual void mousePressEvent(QMouseEvent*event);
  1118. virtual void mouseReleaseEvent(QMouseEvent*event);
  1119. };
  1120. /*:737*//*753:*/
  1121. #line 15513 "./typica.w"
  1122. class DeviceTreeModelNode
  1123. {
  1124. public:
  1125. DeviceTreeModelNode(QDomNode&node,int row,
  1126. DeviceTreeModelNode*parent= NULL);
  1127. ~DeviceTreeModelNode();
  1128. DeviceTreeModelNode*child(int index);
  1129. DeviceTreeModelNode*parent();
  1130. QDomNode node()const;
  1131. int row();
  1132. private:
  1133. QDomNode domNode;
  1134. QHash<int,DeviceTreeModelNode*> children;
  1135. int rowNumber;
  1136. DeviceTreeModelNode*parentItem;
  1137. };
  1138. /*:753*//*755:*/
  1139. #line 15588 "./typica.w"
  1140. class DeviceTreeModel:public QAbstractItemModel
  1141. {
  1142. Q_OBJECT
  1143. public:
  1144. DeviceTreeModel(QObject*parent= NULL);
  1145. ~DeviceTreeModel();
  1146. QVariant data(const QModelIndex&index,int role)const;
  1147. Qt::ItemFlags flags(const QModelIndex&index)const;
  1148. QVariant headerData(int section,Qt::Orientation orientation,
  1149. int role= Qt::DisplayRole)const;
  1150. QModelIndex index(int row,int column,
  1151. const QModelIndex&parent= QModelIndex())const;
  1152. QModelIndex parent(const QModelIndex&child)const;
  1153. Q_INVOKABLE int rowCount(const QModelIndex&parent= QModelIndex())const;
  1154. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1155. bool setData(const QModelIndex&index,const QVariant&value,
  1156. int role);
  1157. bool removeRows(int row,int count,const QModelIndex&parent);
  1158. QDomElement referenceElement(const QString&id);
  1159. public slots:
  1160. void newNode(const QString&name,const QString&driver,
  1161. const QModelIndex&parent);
  1162. private:
  1163. QDomDocument document;
  1164. DeviceTreeModelNode*root;
  1165. QDomNode referenceSection;
  1166. QDomNode treeRoot;
  1167. };
  1168. /*:755*//*774:*/
  1169. #line 16042 "./typica.w"
  1170. Q_DECLARE_METATYPE(QModelIndex)
  1171. /*:774*//*782:*/
  1172. #line 16149 "./typica.w"
  1173. class NodeInserter:public QAction
  1174. {
  1175. Q_OBJECT
  1176. public:
  1177. NodeInserter(const QString&title,const QString&name,
  1178. const QString&driver,QObject*parent= NULL);
  1179. signals:
  1180. void triggered(QString name,QString driver);
  1181. private slots:
  1182. void onTriggered();
  1183. private:
  1184. QString defaultNodeName;
  1185. QString driverString;
  1186. };
  1187. /*:782*//*785:*/
  1188. #line 16204 "./typica.w"
  1189. class DeviceConfigurationWindow:public QWidget
  1190. {
  1191. Q_OBJECT
  1192. public:
  1193. DeviceConfigurationWindow();
  1194. public slots:
  1195. void addDevice();
  1196. void removeNode();
  1197. void newSelection(const QModelIndex&index);
  1198. private slots:
  1199. void resizeColumn();
  1200. private:
  1201. QDomDocument document;
  1202. DeviceTreeModel*model;
  1203. QTreeView*view;
  1204. QScrollArea*configArea;
  1205. };
  1206. /*:785*//*794:*/
  1207. #line 16374 "./typica.w"
  1208. class BasicDeviceConfigurationWidget:public QWidget
  1209. {
  1210. Q_OBJECT
  1211. public:
  1212. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1213. const QModelIndex&index);
  1214. public slots:
  1215. void insertChildNode(const QString&name,const QString&driver);
  1216. void updateAttribute(const QString&name,const QString&value);
  1217. protected:
  1218. DeviceTreeModel*deviceModel;
  1219. QModelIndex currentNode;
  1220. };
  1221. /*:794*//*798:*/
  1222. #line 16459 "./typica.w"
  1223. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1224. {
  1225. Q_OBJECT
  1226. public:
  1227. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1228. const QModelIndex&index);
  1229. private slots:
  1230. void updateRoasterId(int id);
  1231. void updateCapacityCheck(int value);
  1232. void updateCapacity(const QString&value);
  1233. void updateCapacityUnit(const QString&value);
  1234. };
  1235. /*:798*//*803:*/
  1236. #line 16664 "./typica.w"
  1237. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1238. {
  1239. Q_OBJECT
  1240. public:
  1241. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1242. const QModelIndex&index);
  1243. };
  1244. /*:803*//*805:*/
  1245. #line 16710 "./typica.w"
  1246. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1247. {
  1248. Q_OBJECT
  1249. public:
  1250. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1251. const QModelIndex&index);
  1252. private slots:
  1253. void addChannel();
  1254. void updateDeviceId(const QString&newId);
  1255. };
  1256. /*:805*//*809:*/
  1257. #line 16796 "./typica.w"
  1258. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1259. {
  1260. Q_OBJECT
  1261. public:
  1262. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1263. const QModelIndex&index);
  1264. private slots:
  1265. void updateThermocoupleType(const QString&type);
  1266. void updateColumnName(const QString&name);
  1267. void updateHidden(bool hidden);
  1268. };
  1269. /*:809*//*814:*/
  1270. #line 16912 "./typica.w"
  1271. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1272. {
  1273. Q_OBJECT
  1274. public:
  1275. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1276. const QModelIndex&index);
  1277. };
  1278. /*:814*//*816:*/
  1279. #line 16953 "./typica.w"
  1280. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1281. {
  1282. Q_OBJECT
  1283. public:
  1284. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1285. const QModelIndex&index);
  1286. private slots:
  1287. void addChannel();
  1288. void updateDeviceId(const QString&newId);
  1289. };
  1290. /*:816*//*818:*/
  1291. #line 17022 "./typica.w"
  1292. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1293. {
  1294. Q_OBJECT
  1295. public:
  1296. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1297. const QModelIndex&index);
  1298. private slots:
  1299. void updateDeviceId(const QString&newId);
  1300. void updateThermocoupleType(const QString&type);
  1301. void updateColumnName(const QString&name);
  1302. void updateHidden(bool hidden);
  1303. };
  1304. /*:818*//*823:*/
  1305. #line 17153 "./typica.w"
  1306. class PortSelector:public QComboBox
  1307. {
  1308. Q_OBJECT
  1309. public:
  1310. PortSelector(QWidget*parent= NULL);
  1311. private slots:
  1312. void addDevice(QextPortInfo port);
  1313. private:
  1314. QextSerialEnumerator*lister;
  1315. };
  1316. /*:823*//*825:*/
  1317. #line 17201 "./typica.w"
  1318. class BaudSelector:public QComboBox
  1319. {
  1320. Q_OBJECT
  1321. Q_ENUMS(BaudRateType)
  1322. public:
  1323. BaudSelector(QWidget*parent= NULL);
  1324. enum BaudRateType
  1325. {
  1326. #if defined(Q_OS_UNIX) || defined(qdoc)
  1327. BAUD50= 50,
  1328. BAUD75= 75,
  1329. BAUD134= 134,
  1330. BAUD150= 150,
  1331. BAUD200= 200,
  1332. BAUD1800= 1800,
  1333. #if defined(B76800) || defined(qdoc)
  1334. BAUD76800= 76800,
  1335. #endif
  1336. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1337. BAUD230400= 230400,
  1338. BAUD460800= 460800,
  1339. BAUD500000= 500000,
  1340. BAUD576000= 576000,
  1341. BAUD921600= 921600,
  1342. BAUD1000000= 1000000,
  1343. BAUD1152000= 1152000,
  1344. BAUD1500000= 1500000,
  1345. BAUD2000000= 2000000,
  1346. BAUD2500000= 2500000,
  1347. BAUD3000000= 3000000,
  1348. BAUD3500000= 3500000,
  1349. BAUD4000000= 4000000,
  1350. #endif
  1351. #endif
  1352. #if defined(Q_OS_WIN) || defined(qdoc)
  1353. BAUD14400= 14400,
  1354. BAUD56000= 56000,
  1355. BAUD128000= 128000,
  1356. BAUD256000= 256000,
  1357. #endif
  1358. BAUD110= 110,
  1359. BAUD300= 300,
  1360. BAUD600= 600,
  1361. BAUD1200= 1200,
  1362. BAUD2400= 2400,
  1363. BAUD4800= 4800,
  1364. BAUD9600= 9600,
  1365. BAUD19200= 19200,
  1366. BAUD38400= 38400,
  1367. BAUD57600= 57600,
  1368. BAUD115200= 115200
  1369. };
  1370. };
  1371. /*:825*//*827:*/
  1372. #line 17272 "./typica.w"
  1373. class ParitySelector:public QComboBox
  1374. {
  1375. Q_OBJECT
  1376. Q_ENUMS(ParityType)
  1377. public:
  1378. ParitySelector(QWidget*parent= NULL);
  1379. enum ParityType
  1380. {
  1381. PAR_NONE,
  1382. PAR_ODD,
  1383. PAR_EVEN,
  1384. #if defined(Q_OS_WIN) || defined(qdoc)
  1385. PAR_MARK,
  1386. #endif
  1387. PAR_SPACE
  1388. };
  1389. };
  1390. /*:827*//*829:*/
  1391. #line 17310 "./typica.w"
  1392. class FlowSelector:public QComboBox
  1393. {
  1394. Q_OBJECT
  1395. Q_ENUMS(FlowType)
  1396. public:
  1397. FlowSelector(QWidget*parent= NULL);
  1398. enum FlowType
  1399. {
  1400. FLOW_OFF,
  1401. FLOW_HARDWARE,
  1402. FLOW_XONXOFF
  1403. };
  1404. };
  1405. /*:829*//*831:*/
  1406. #line 17343 "./typica.w"
  1407. class StopSelector:public QComboBox
  1408. {
  1409. Q_OBJECT
  1410. Q_ENUMS(StopBitsType)
  1411. public:
  1412. StopSelector(QWidget*parent= NULL);
  1413. enum StopBitsType
  1414. {
  1415. STOP_1,
  1416. #if defined(Q_OS_WIN) || defined(qdoc)
  1417. STOP_1_5,
  1418. #endif
  1419. STOP_2
  1420. };
  1421. };
  1422. /*:831*//*834:*/
  1423. #line 17400 "./typica.w"
  1424. class ShortHexSpinBox:public QSpinBox
  1425. {
  1426. Q_OBJECT
  1427. public:
  1428. ShortHexSpinBox(QWidget*parent= NULL);
  1429. virtual QValidator::State validate(QString&input,int&pos)const;
  1430. protected:
  1431. virtual int valueFromText(const QString&text)const;
  1432. virtual QString textFromValue(int value)const;
  1433. };
  1434. /*:834*//*836:*/
  1435. #line 17462 "./typica.w"
  1436. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1437. {
  1438. Q_OBJECT
  1439. public:
  1440. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1441. const QModelIndex&index);
  1442. private slots:
  1443. void updatePort(const QString&newPort);
  1444. void updateBaudRate(const QString&newRate);
  1445. void updateParity(const QString&newParity);
  1446. void updateFlowControl(const QString&newFlow);
  1447. void updateStopBits(const QString&newStopBits);
  1448. };
  1449. /*:836*//*838:*/
  1450. #line 17613 "./typica.w"
  1451. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1452. {
  1453. Q_OBJECT
  1454. public:
  1455. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1456. const QModelIndex&index);
  1457. private slots:
  1458. void updateStationNumber(int newStation);
  1459. void updateFixedUnit(bool newFixed);
  1460. void updateFixedDecimal(bool newFixed);
  1461. void updateUnit(const QString&newUnit);
  1462. void updateUnitAddress(int newAddress);
  1463. void updateValueF(int newValue);
  1464. void updateValueC(int newValue);
  1465. void updatePrecisionAddress(int newAddress);
  1466. void updatePrecisionValue(int newValue);
  1467. private:
  1468. QStackedLayout*unitSpecificationLayout;
  1469. QStackedLayout*decimalSpecificationLayout;
  1470. };
  1471. /*:838*//*840:*/
  1472. #line 17872 "./typica.w"
  1473. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1474. {
  1475. Q_OBJECT
  1476. public:
  1477. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1478. const QModelIndex&index);
  1479. private slots:
  1480. void updateAddress(int newAddress);
  1481. };
  1482. /*:840*//*842:*/
  1483. #line 17918 "./typica.w"
  1484. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1485. {
  1486. Q_OBJECT
  1487. public:
  1488. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1489. const QModelIndex&index);
  1490. private slots:
  1491. void updateReadAddress(int newAddress);
  1492. void updateWriteAddress(int newAddress);
  1493. void updateFixedRange(bool fixed);
  1494. void updateLower(const QString&lower);
  1495. void updateUpper(const QString&upper);
  1496. void updateLowerAddress(int newAddress);
  1497. void updateUpperAddress(int newAddress);
  1498. private:
  1499. QStackedLayout*boundsLayout;
  1500. };
  1501. /*:842*//*846:*/
  1502. #line 18112 "./typica.w"
  1503. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1504. {
  1505. Q_OBJECT
  1506. public:
  1507. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1508. private slots:
  1509. void updateButtonText(const QString&text);
  1510. void updateAnnotationText(const QString&text);
  1511. };
  1512. /*:846*//*850:*/
  1513. #line 18180 "./typica.w"
  1514. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1515. {
  1516. Q_OBJECT
  1517. public:
  1518. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1519. private slots:
  1520. void updateButtonText(const QString&text);
  1521. void updateAnnotationText(const QString&text);
  1522. };
  1523. /*:850*//*853:*/
  1524. #line 18254 "./typica.w"
  1525. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1526. {
  1527. Q_OBJECT
  1528. public:
  1529. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1530. private slots:
  1531. void updateLabel(const QString&text);
  1532. void updateMinimum(const QString&minimum);
  1533. void updateMaximum(const QString&maximum);
  1534. void updatePrecision(int precision);
  1535. void updatePretext(const QString&text);
  1536. void updatePosttext(const QString&text);
  1537. };
  1538. /*:853*//*856:*/
  1539. #line 12 "./freeannotation.w"
  1540. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1541. {
  1542. Q_OBJECT
  1543. public:
  1544. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1545. private slots:
  1546. void updateLabel(const QString&text);
  1547. };
  1548. /*:856*//*860:*/
  1549. #line 11 "./settings.w"
  1550. class SettingsWindow:public QMainWindow
  1551. {
  1552. Q_OBJECT
  1553. public:
  1554. SettingsWindow();
  1555. };
  1556. /*:860*//*865:*/
  1557. #line 8 "./graphsettings.w"
  1558. class GraphSettingsWidget:public QWidget
  1559. {
  1560. Q_OBJECT
  1561. public:
  1562. GraphSettingsWidget();
  1563. };
  1564. /*:865*//*867:*/
  1565. #line 46 "./graphsettings.w"
  1566. class GraphSettingsRelativeTab:public QWidget
  1567. {
  1568. Q_OBJECT
  1569. public:
  1570. GraphSettingsRelativeTab();
  1571. public slots:
  1572. void updateEnableSetting(bool enable);
  1573. void updateColorSetting(const QString&color);
  1574. void updateAxisSetting(const QString&gridList);
  1575. void updateUnit(int unit);
  1576. void showColorPicker();
  1577. private:
  1578. QLineEdit*colorEdit;
  1579. };
  1580. /*:867*//*871:*/
  1581. #line 7 "./advancedsettings.w"
  1582. class AdvancedSettingsWidget:public QWidget
  1583. {
  1584. Q_OBJECT
  1585. public:
  1586. AdvancedSettingsWidget();
  1587. public slots:
  1588. void enableDiagnosticLogging(bool enabled);
  1589. };
  1590. /*:871*//*875:*/
  1591. #line 18379 "./typica.w"
  1592. class ModbusRTUDevice:public QObject
  1593. {
  1594. Q_OBJECT
  1595. public:
  1596. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1597. ~ModbusRTUDevice();
  1598. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1599. Q_INVOKABLE double SVLower();
  1600. Q_INVOKABLE double SVUpper();
  1601. Q_INVOKABLE int decimals();
  1602. QList<Channel*> channels;
  1603. public slots:
  1604. void outputSV(double sv);
  1605. signals:
  1606. void SVLowerChanged(double);
  1607. void SVUpperChanged(double);
  1608. void SVDecimalChanged(int);
  1609. void queueEmpty();
  1610. private slots:
  1611. void dataAvailable();
  1612. void sendNextMessage();
  1613. void decimalResponse(QByteArray response);
  1614. void unitResponse(QByteArray response);
  1615. void svlResponse(QByteArray response);
  1616. void svuResponse(QByteArray response);
  1617. void requestMeasurement();
  1618. void mResponse(QByteArray response);
  1619. void ignore(QByteArray response);
  1620. void timeout();
  1621. private:
  1622. QextSerialPort*port;
  1623. QByteArray responseBuffer;
  1624. QList<QByteArray> messageQueue;
  1625. QList<QObject*> retObjQueue;
  1626. QList<char*> callbackQueue;
  1627. quint16 calculateCRC(QByteArray data);
  1628. QTimer*messageDelayTimer;
  1629. QTimer*commTimeout;
  1630. int delayTime;
  1631. char station;
  1632. int decimalPosition;
  1633. int valueF;
  1634. int valueC;
  1635. bool unitIsF;
  1636. double outputSVLower;
  1637. double outputSVUpper;
  1638. QByteArray outputSVStub;
  1639. QByteArray pvStub;
  1640. QByteArray svStub;
  1641. QByteArray mStub;
  1642. quint16 pvaddress;
  1643. quint16 svaddress;
  1644. bool svenabled;
  1645. bool readingsv;
  1646. double savedpv;
  1647. bool waiting;
  1648. };
  1649. /*:875*//*891:*/
  1650. #line 19082 "./typica.w"
  1651. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1652. {
  1653. Q_OBJECT
  1654. public:
  1655. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1656. private slots:
  1657. void updatePort(const QString&newPort);
  1658. void updateBaudRate(const QString&newRate);
  1659. void updateParity(const QString&newParity);
  1660. void updateFlowControl(const QString&newFlow);
  1661. void updateStopBits(const QString&newStopBits);
  1662. void updateStation(int station);
  1663. void updateFixedDecimal(bool fixed);
  1664. void updateDecimalAddress(int address);
  1665. void updateDecimalPosition(int position);
  1666. void updateFixedUnit(bool fixed);
  1667. void updateUnitAddress(int address);
  1668. void updateValueForF(int value);
  1669. void updateValueForC(int value);
  1670. void updateUnit(const QString&newUnit);
  1671. void updatePVAddress(int address);
  1672. void updateSVEnabled(bool enabled);
  1673. void updateSVReadAddress(int address);
  1674. void updateDeviceLimit(bool query);
  1675. void updateSVLowerAddress(int address);
  1676. void updateSVUpperAddress(int address);
  1677. void updateSVLower(double value);
  1678. void updateSVUpper(double value);
  1679. void updateSVWritable(bool canWriteSV);
  1680. void updateSVWriteAddress(int address);
  1681. void updatePVColumnName(const QString&name);
  1682. void updateSVColumnName(const QString&name);
  1683. void updatePVHidden(bool hidden);
  1684. void updateSVHidden(bool hidden);
  1685. private:
  1686. PortSelector*port;
  1687. BaudSelector*baud;
  1688. ParitySelector*parity;
  1689. FlowSelector*flow;
  1690. StopSelector*stop;
  1691. QSpinBox*station;
  1692. QCheckBox*decimalQuery;
  1693. ShortHexSpinBox*decimalAddress;
  1694. QSpinBox*decimalPosition;
  1695. QCheckBox*unitQuery;
  1696. ShortHexSpinBox*unitAddress;
  1697. QSpinBox*valueF;
  1698. QSpinBox*valueC;
  1699. QComboBox*fixedUnit;
  1700. ShortHexSpinBox*pVAddress;
  1701. QCheckBox*sVEnabled;
  1702. ShortHexSpinBox*sVReadAddress;
  1703. QCheckBox*deviceLimit;
  1704. ShortHexSpinBox*sVLowerAddr;
  1705. ShortHexSpinBox*sVUpperAddr;
  1706. QDoubleSpinBox*sVLower;
  1707. QDoubleSpinBox*sVUpper;
  1708. QCheckBox*sVWritable;
  1709. ShortHexSpinBox*sVOutputAddr;
  1710. QLineEdit*pVColumnName;
  1711. QLineEdit*sVColumnName;
  1712. };
  1713. /*:891*//*895:*/
  1714. #line 22 "./modbus.w"
  1715. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1716. {
  1717. Q_OBJECT
  1718. public:
  1719. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1720. private slots:
  1721. void updatePort(const QString&value);
  1722. void updateBaudRate(const QString&value);
  1723. void updateParity(int value);
  1724. void updateFlowControl(int value);
  1725. void updateStopBits(int value);
  1726. void addInput();
  1727. private:
  1728. ParitySelector*m_parity;
  1729. FlowSelector*m_flow;
  1730. StopSelector*m_stop;
  1731. };
  1732. /*:895*//*897:*/
  1733. #line 144 "./modbus.w"
  1734. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1735. {
  1736. Q_OBJECT
  1737. public:
  1738. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1739. private slots:
  1740. void updateStation(int value);
  1741. void updateAddress(int value);
  1742. void updateFunction(int value);
  1743. void updateFormat(int value);
  1744. void updateDecimals(int value);
  1745. void updateUnit(int value);
  1746. void updateColumnName(const QString&value);
  1747. void updateHidden(bool value);
  1748. };
  1749. /*:897*//*901:*/
  1750. #line 342 "./modbus.w"
  1751. enum ModbusDataFormat
  1752. {
  1753. Int16,
  1754. FloatHL,
  1755. FloatLH
  1756. };
  1757. struct ModbusScanItem
  1758. {
  1759. QByteArray request;
  1760. ModbusDataFormat format;
  1761. int decimalPosition;
  1762. Units::Unit unit;
  1763. mutable double lastValue;
  1764. };
  1765. /*:901*//*902:*/
  1766. #line 362 "./modbus.w"
  1767. class ModbusNG:public QObject
  1768. {
  1769. Q_OBJECT
  1770. public:
  1771. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1772. ~ModbusNG();
  1773. Q_INVOKABLE int channelCount();
  1774. Channel*getChannel(int);
  1775. Q_INVOKABLE QString channelColumnName(int);
  1776. Q_INVOKABLE QString channelIndicatorText(int);
  1777. Q_INVOKABLE bool isChannelHidden(int);
  1778. Q_INVOKABLE QString channelType(int);
  1779. private slots:
  1780. void sendNextMessage();
  1781. void timeout();
  1782. void dataAvailable();
  1783. void rateLimitTimeout();
  1784. private:
  1785. quint16 calculateCRC(QByteArray data);
  1786. QextSerialPort*port;
  1787. int delayTime;
  1788. QTimer*messageDelayTimer;
  1789. QTimer*commTimeout;
  1790. QTimer*rateLimiter;
  1791. int scanPosition;
  1792. bool waiting;
  1793. QByteArray responseBuffer;
  1794. QList<Channel*> channels;
  1795. QList<ModbusScanItem> scanList;
  1796. QList<QString> channelNames;
  1797. QList<QString> channelLabels;
  1798. QList<bool> hiddenStates;
  1799. QList<QString> channelTypeList;
  1800. QVector<double> lastMeasurement;
  1801. };
  1802. /*:902*//*907:*/
  1803. #line 36 "./unsupportedserial.w"
  1804. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1805. {
  1806. Q_OBJECT
  1807. public:
  1808. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1809. const QModelIndex&index);
  1810. private slots:
  1811. void updateConfiguration();
  1812. void saveScript();
  1813. void addChannel();
  1814. private:
  1815. SaltModel*deviceSettingsModel;
  1816. QTextEdit*scriptEditor;
  1817. };
  1818. /*:907*//*912:*/
  1819. #line 166 "./unsupportedserial.w"
  1820. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1821. {
  1822. Q_OBJECT
  1823. public:
  1824. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1825. const QModelIndex&index);
  1826. private slots:
  1827. void updateColumnName(const QString&value);
  1828. void updateHidden(bool hidden);
  1829. void updateConfiguration();
  1830. private:
  1831. SaltModel*channelSettingsModel;
  1832. };
  1833. /*:912*//*917:*/
  1834. #line 298 "./unsupportedserial.w"
  1835. class JavaScriptDevice:public QObject
  1836. {
  1837. Q_OBJECT
  1838. public:
  1839. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1840. QScriptEngine*engine);
  1841. Q_INVOKABLE int channelCount();
  1842. Channel*getChannel(int channel);
  1843. Q_INVOKABLE bool isChannelHidden(int channel);
  1844. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1845. Q_INVOKABLE QString channelColumnName(int channel);
  1846. Q_INVOKABLE QString channelIndicatorText(int channel);
  1847. public slots:
  1848. void setTemperatureColumn(int tcol);
  1849. void setAnnotationColumn(int ncol);
  1850. void start();
  1851. void stop();
  1852. signals:
  1853. void annotation(QString note,int tcol,int ncol);
  1854. void triggerStartBatch();
  1855. void triggerStopBatch();
  1856. void deviceStopRequested();
  1857. private:
  1858. QVariantMap deviceSettings;
  1859. QString deviceScript;
  1860. QList<Channel*> channelList;
  1861. QList<bool> hiddenState;
  1862. QList<Units::Unit> channelUnits;
  1863. QList<QString> columnNames;
  1864. QList<QString> indicatorTexts;
  1865. QList<QVariantMap> channelSettings;
  1866. int annotationTemperatureColumn;
  1867. int annotationNoteColumn;
  1868. QScriptEngine*scriptengine;
  1869. };
  1870. /*:917*//*939:*/
  1871. #line 11 "./phidgets.w"
  1872. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1873. {
  1874. Q_OBJECT
  1875. public:
  1876. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1877. const QModelIndex&index);
  1878. private slots:
  1879. void addChannel();
  1880. void updateRate(int ms);
  1881. };
  1882. /*:939*//*943:*/
  1883. #line 82 "./phidgets.w"
  1884. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1885. {
  1886. Q_OBJECT
  1887. public:
  1888. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1889. const QModelIndex&index);
  1890. private slots:
  1891. void updateColumnName(const QString&value);
  1892. void updateHidden(bool hidden);
  1893. void updateTC(int index);
  1894. void updateChannel(int channel);
  1895. private:
  1896. QComboBox*tcType;
  1897. };
  1898. /*:943*//*948:*/
  1899. #line 213 "./phidgets.w"
  1900. class PhidgetsTemperatureSensor:public QObject
  1901. {
  1902. Q_OBJECT
  1903. public:
  1904. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1905. Q_INVOKABLE int channelCount();
  1906. Channel*getChannel(int channel);
  1907. Q_INVOKABLE bool isChannelHidden(int channel);
  1908. Q_INVOKABLE QString channelColumnName(int channel);
  1909. Q_INVOKABLE QString channelIndicatorText(int channel);
  1910. public slots:
  1911. void start();
  1912. void stop();
  1913. private slots:
  1914. void getMeasurements();
  1915. private:
  1916. QList<int> channelIndices;
  1917. QList<int> tctypes;
  1918. QList<Channel*> channelList;
  1919. QMap<int,Channel*> channelMap;
  1920. QList<bool> hiddenState;
  1921. QList<QString> columnNames;
  1922. QList<QString> indicatorTexts;
  1923. QLibrary driver;
  1924. QTimer sampleTimer;
  1925. void*device;
  1926. /*952:*/
  1927. #line 349 "./phidgets.w"
  1928. #ifdef _WIN32
  1929. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1930. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1931. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1932. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1933. #else
  1934. typedef int(*PhidgetHandleOnly)(void*);
  1935. typedef int(*PhidgetHandleInt)(void*,int);
  1936. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1937. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1938. #endif
  1939. PhidgetHandleOnly createDevice;
  1940. PhidgetHandleInt openDevice;
  1941. PhidgetHandleInt waitForOpen;
  1942. PhidgetHandleIntInt setTCType;
  1943. PhidgetHandleIntDoubleOut getTemperature;
  1944. PhidgetHandleOnly closeDevice;
  1945. PhidgetHandleOnly deleteDevice;
  1946. /*:952*/
  1947. #line 240 "./phidgets.w"
  1948. };
  1949. /*:948*//*961:*/
  1950. #line 19622 "./typica.w"
  1951. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1952. {
  1953. Q_OBJECT
  1954. public:
  1955. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1956. const QModelIndex&index);
  1957. private slots:
  1958. void updateSourceColumn(const QString&source);
  1959. void updateDestinationColumn(const QString&dest);
  1960. void updateKnots();
  1961. private:
  1962. SaltModel*tablemodel;
  1963. };
  1964. /*:961*//*967:*/
  1965. #line 19752 "./typica.w"
  1966. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1967. {
  1968. Q_OBJECT
  1969. public:
  1970. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1971. const QModelIndex&index);
  1972. private slots:
  1973. void updateResetTime(QTime time);
  1974. };
  1975. /*:967*//*971:*/
  1976. #line 19818 "./typica.w"
  1977. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1978. {
  1979. Q_OBJECT
  1980. public:
  1981. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1982. private slots:
  1983. void updateStartButtonText(const QString&text);
  1984. void updateStopButtonText(const QString&text);
  1985. void updateStartColumnName(const QString&text);
  1986. void updateStopColumnName(const QString&text);
  1987. void updateStartValue(const QString&text);
  1988. void updateStopValue(const QString&text);
  1989. void updateStartTrigger(int option);
  1990. void updateStopTrigger(int option);
  1991. };
  1992. /*:971*//*976:*/
  1993. #line 20070 "./typica.w"
  1994. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1995. {
  1996. Q_OBJECT
  1997. public:
  1998. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1999. const QModelIndex&index);
  2000. private slots:
  2001. void updateColumnName(const QString&text);
  2002. void updateRangeData();
  2003. private:
  2004. SaltModel*tablemodel;
  2005. };
  2006. /*:976*//*981:*/
  2007. #line 20172 "./typica.w"
  2008. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  2009. {
  2010. Q_OBJECT
  2011. public:
  2012. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2013. private slots:
  2014. void updateMatchingColumn(const QString&column);
  2015. void updateTemperature();
  2016. void updateDelay();
  2017. private:
  2018. QDoubleSpinBox*temperatureValue;
  2019. QComboBox*unitSelector;
  2020. QSpinBox*delaySelector;
  2021. };
  2022. /*:981*//*985:*/
  2023. #line 16 "./rate.w"
  2024. class RateOfChange:public QObject
  2025. {
  2026. Q_OBJECT
  2027. public:
  2028. RateOfChange(int cachetime= 1,int scaletime= 1);
  2029. public slots:
  2030. void newMeasurement(Measurement measure);
  2031. void setCacheTime(int seconds);
  2032. void setScaleTime(int seconds);
  2033. signals:
  2034. void newData(Measurement measure);
  2035. private:
  2036. int ct;
  2037. int st;
  2038. QList<Measurement> cache;
  2039. };
  2040. /*:985*//*993:*/
  2041. #line 177 "./rate.w"
  2042. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  2043. {
  2044. Q_OBJECT
  2045. public:
  2046. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2047. private slots:
  2048. void updateColumn(const QString&column);
  2049. void updateCacheTime(const QString&seconds);
  2050. void updateScaleTime(const QString&seconds);
  2051. };
  2052. /*:993*//*999:*/
  2053. #line 15 "./mergeseries.w"
  2054. class MergeSeries:public QObject
  2055. {
  2056. Q_OBJECT
  2057. public:
  2058. MergeSeries();
  2059. public slots:
  2060. void in1(Measurement measure);
  2061. void in2(Measurement measure);
  2062. signals:
  2063. void newData(Measurement measure);
  2064. protected:
  2065. virtual void calculate(Measurement m1,Measurement m2)= 0;
  2066. private:
  2067. Measurement last1;
  2068. Measurement last2;
  2069. bool received1;
  2070. bool received2;
  2071. };
  2072. class DifferenceSeries:public MergeSeries
  2073. {
  2074. Q_OBJECT
  2075. public:
  2076. DifferenceSeries();
  2077. protected:
  2078. void calculate(Measurement m1,Measurement m2);
  2079. };
  2080. class MeanSeries:public MergeSeries
  2081. {
  2082. Q_OBJECT
  2083. public:
  2084. MeanSeries();
  2085. protected:
  2086. void calculate(Measurement m1,Measurement m2);
  2087. };
  2088. /*:999*//*1007:*/
  2089. #line 167 "./mergeseries.w"
  2090. class MergeSeriesConfWidget:public BasicDeviceConfigurationWidget
  2091. {
  2092. Q_OBJECT
  2093. public:
  2094. Q_INVOKABLE MergeSeriesConfWidget(DeviceTreeModel*model,
  2095. const QModelIndex&index);
  2096. private slots:
  2097. void updateColumn1(const QString&column);
  2098. void updateColumn2(const QString&column);
  2099. void updateOutput(const QString&column);
  2100. void updateType(int type);
  2101. };
  2102. /*:1007*//*1013:*/
  2103. #line 19 "./dataqsdk.w"
  2104. class DataqSdkDeviceImplementation;
  2105. class DataqSdkDevice:public QObject
  2106. {
  2107. Q_OBJECT
  2108. DataqSdkDeviceImplementation*imp;
  2109. private slots:
  2110. void threadFinished();
  2111. public:
  2112. DataqSdkDevice(QString device);
  2113. ~DataqSdkDevice();
  2114. Channel*newChannel(Units::Unit scale);
  2115. Q_INVOKABLE void setClockRate(double Hz);
  2116. Q_INVOKABLE void start();
  2117. static QStringList detectPorts();
  2118. static QStringList detectHardware();
  2119. };
  2120. /*:1013*//*1014:*/
  2121. #line 49 "./dataqsdk.w"
  2122. class DataqSdkDeviceImplementation:public QThread
  2123. {
  2124. Q_OBJECT
  2125. public:
  2126. DataqSdkDeviceImplementation();
  2127. ~DataqSdkDeviceImplementation();
  2128. void run();
  2129. /*1015:*/
  2130. #line 70 "./dataqsdk.w"
  2131. typedef struct di_inlist_struct{
  2132. unsigned short chan;
  2133. unsigned short diff;
  2134. unsigned short gain;
  2135. unsigned short unipolar;
  2136. unsigned short dig_out_enable;
  2137. unsigned short dig_out;
  2138. unsigned short ave;
  2139. unsigned short counter;
  2140. }DI_INLIST_STRUCT;
  2141. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2142. typedef int(PASCAL*FPDICLOSE)(void);
  2143. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2144. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2145. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2146. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2147. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2148. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2149. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2150. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2151. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2152. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2153. FPDIOPEN di_open;
  2154. FPDICLOSE di_close;
  2155. FPDISAMPLERATE di_sample_rate;
  2156. FPDIMAXIMUMRATE di_maximum_rate;
  2157. FPDILISTLENGTH di_list_length;
  2158. FPDIINLIST di_inlist;
  2159. FPDIBUFFERALLOC di_buffer_alloc;
  2160. FPDISTARTSCAN di_start_scan;
  2161. FPDISTATUSREAD di_status_read;
  2162. FPDIBUFFERSTATUS di_buffer_status;
  2163. FPDIBURSTRATE di_burst_rate;
  2164. FPDISTOPSCAN di_stop_scan;
  2165. /*:1015*/
  2166. #line 57 "./dataqsdk.w"
  2167. /*1017:*/
  2168. #line 134 "./dataqsdk.w"
  2169. bool isOpen;
  2170. double sampleRate;
  2171. long oversample;
  2172. long burstDivisor;
  2173. QString device;
  2174. unsigned deviceNumber;
  2175. QVector<Channel*> channelMap;
  2176. int error;
  2177. int channels;
  2178. bool ready;
  2179. QLibrary*driver;
  2180. QVector<Units::Unit> unitMap;
  2181. int*input_buffer;
  2182. QTimer*eventClock;
  2183. QMultiMap<int,double> smoother;
  2184. /*:1017*/
  2185. #line 58 "./dataqsdk.w"
  2186. public slots:
  2187. void measure();
  2188. private:
  2189. qint16*buffer;
  2190. };
  2191. /*:1014*//*1034:*/
  2192. #line 663 "./dataqsdk.w"
  2193. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2194. {
  2195. Q_OBJECT
  2196. public:
  2197. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2198. const QModelIndex&index);
  2199. private slots:
  2200. void updateAutoSelect(bool automatic);
  2201. void updateDeviceNumber(int deviceNumber);
  2202. void updatePort(QString portId);
  2203. void addChannel();
  2204. private:
  2205. QStackedWidget*deviceIdStack;
  2206. };
  2207. /*:1034*//*1039:*/
  2208. #line 808 "./dataqsdk.w"
  2209. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2210. {
  2211. Q_OBJECT
  2212. public:
  2213. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2214. const QModelIndex&index);
  2215. private slots:
  2216. void updateUnits(const QString&unit);
  2217. void updateColumnName(const QString&value);
  2218. void updateMeasuredLower(const QString&value);
  2219. void updateMeasuredUpper(const QString&value);
  2220. void updateMappedLower(const QString&value);
  2221. void updateMappedUpper(const QString&value);
  2222. void updateClosedInterval(bool closed);
  2223. void updateSmoothingEnabled(bool enabled);
  2224. void updateSensitivity(const QString&value);
  2225. void startCalibration();
  2226. void stopCalibration();
  2227. void resetCalibration();
  2228. void updateInput(Measurement measure);
  2229. void updateOutput(Measurement measure);
  2230. void updateHidden(bool hidden);
  2231. private:
  2232. QPushButton*startButton;
  2233. QPushButton*resetButton;
  2234. QPushButton*stopButton;
  2235. /*1044:*/
  2236. #line 1098 "./dataqsdk.w"
  2237. bool autoSelect;
  2238. QString deviceID;
  2239. unsigned int channelOfInterest;
  2240. /*:1044*/
  2241. #line 835 "./dataqsdk.w"
  2242. DataqSdkDevice*calibrationDevice;
  2243. LinearCalibrator*calibrator;
  2244. QLineEdit*currentMeasurement;
  2245. QLineEdit*minimumMeasurement;
  2246. QLineEdit*maximumMeasurement;
  2247. QLineEdit*averageMeasurement;
  2248. QLineEdit*currentMapped;
  2249. QLineEdit*minimumMapped;
  2250. QLineEdit*maximumMapped;
  2251. QLineEdit*averageMapped;
  2252. int rmCount;
  2253. int cmCount;
  2254. double rmin;
  2255. double rmax;
  2256. double rmean;
  2257. double cmin;
  2258. double cmax;
  2259. double cmean;
  2260. };
  2261. /*:1039*//*1066:*/
  2262. #line 273 "./scales.w"
  2263. Q_DECLARE_METATYPE(BaudRateType)
  2264. Q_DECLARE_METATYPE(DataBitsType)
  2265. Q_DECLARE_METATYPE(ParityType)
  2266. Q_DECLARE_METATYPE(StopBitsType)
  2267. Q_DECLARE_METATYPE(FlowType)
  2268. /*:1066*//*1073:*/
  2269. #line 396 "./scales.w"
  2270. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2271. {
  2272. Q_OBJECT
  2273. public:
  2274. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2275. const QModelIndex&index);
  2276. private slots:
  2277. void updatePort(const QString&newPort);
  2278. void updateBaudRate(const QString&rate);
  2279. void updateParity(int index);
  2280. void updateFlowControl(int index);
  2281. void updateStopBits(int index);
  2282. void updateWeighCommand(const QString&command);
  2283. void updateCommandTerminator(const QString&terminator);
  2284. private:
  2285. PortSelector*port;
  2286. BaudSelector*baud;
  2287. ParitySelector*parity;
  2288. FlowSelector*flow;
  2289. StopSelector*stop;
  2290. QLineEdit*weighcommand;
  2291. QComboBox*commandterminator;
  2292. };
  2293. /*:1073*//*1078:*/
  2294. #line 14 "./valueannotation.w"
  2295. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2296. {
  2297. Q_OBJECT
  2298. public:
  2299. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2300. const QModelIndex&index);
  2301. private slots:
  2302. void updateSourceColumn(const QString&source);
  2303. void updateAnnotations();
  2304. void updateStart(bool noteOnStart);
  2305. private:
  2306. SaltModel*tablemodel;
  2307. };
  2308. /*:1078*//*1086:*/
  2309. #line 165 "./valueannotation.w"
  2310. class ValueAnnotation:public QObject
  2311. {
  2312. Q_OBJECT
  2313. public:
  2314. ValueAnnotation();
  2315. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2316. public slots:
  2317. void newMeasurement(Measurement measure);
  2318. void annotate();
  2319. void setAnnotationColumn(int column);
  2320. void setTemperatureColumn(int column);
  2321. void setTolerance(double epsilon);
  2322. signals:
  2323. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2324. private:
  2325. int lastIndex;
  2326. int annotationColumn;
  2327. int measurementColumn;
  2328. QList<double> values;
  2329. QStringList annotations;
  2330. double tolerance;
  2331. };
  2332. /*:1086*//*1095:*/
  2333. #line 14 "./thresholdannotation.w"
  2334. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2335. {
  2336. Q_OBJECT
  2337. public:
  2338. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2339. const QModelIndex&index);
  2340. private slots:
  2341. void updateSourceColumn(const QString&source);
  2342. void updateThreshold(double value);
  2343. void updateDirection(int index);
  2344. void updateAnnotation(const QString&note);
  2345. };
  2346. /*:1095*//*1100:*/
  2347. #line 127 "./thresholdannotation.w"
  2348. class Annotator:public QObject
  2349. {
  2350. Q_OBJECT
  2351. QString note;
  2352. int tc;
  2353. int ac;
  2354. QTimer t;
  2355. public:
  2356. Annotator(const QString&text);
  2357. public slots:
  2358. void setAnnotation(const QString&annotation);
  2359. void setTemperatureColumn(int tempcolumn);
  2360. void setAnnotationColumn(int annotationcolumn);
  2361. void annotate();
  2362. private slots:
  2363. void catchTimer();
  2364. signals:
  2365. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2366. };
  2367. /*:1100*//*1111:*/
  2368. #line 78 "./user.w"
  2369. class LoginDialog:public QDialog
  2370. {
  2371. Q_OBJECT
  2372. public:
  2373. LoginDialog();
  2374. public slots:
  2375. void attemptLogin();
  2376. private:
  2377. QLineEdit*user;
  2378. QLineEdit*password;
  2379. QLabel*warning;
  2380. QPushButton*login;
  2381. };
  2382. /*:1111*//*1117:*/
  2383. #line 162 "./user.w"
  2384. class UserLabel:public QLabel
  2385. {
  2386. Q_OBJECT
  2387. public:
  2388. UserLabel();
  2389. public slots:
  2390. void updateLabel(const QString&user);
  2391. protected:
  2392. void mouseReleaseEvent(QMouseEvent*event);
  2393. };
  2394. /*:1117*//*1121:*/
  2395. #line 209 "./user.w"
  2396. class NewTypicaUser:public QDialog
  2397. {
  2398. Q_OBJECT
  2399. public:
  2400. NewTypicaUser();
  2401. public slots:
  2402. void createAndReset();
  2403. void createAndClose();
  2404. void validate();
  2405. void cancelValidate();
  2406. private:
  2407. void createNewUser();
  2408. QLineEdit*userField;
  2409. QLineEdit*passwordField;
  2410. QCheckBox*autoLogin;
  2411. QPushButton*saveAndCloseButton;
  2412. QPushButton*saveAndNewButton;
  2413. QPushButton*cancelButton;
  2414. };
  2415. /*:1121*/
  2416. #line 526 "./typica.w"
  2417. /*12:*/
  2418. #line 811 "./typica.w"
  2419. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2420. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*engine);
  2421. /*:12*//*14:*/
  2422. #line 836 "./typica.w"
  2423. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2424. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2425. /*:14*//*19:*/
  2426. #line 896 "./typica.w"
  2427. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2428. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2429. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2430. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2431. QScriptEngine*engine);
  2432. /*:19*//*23:*/
  2433. #line 986 "./typica.w"
  2434. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2435. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2436. /*:23*//*33:*/
  2437. #line 1210 "./typica.w"
  2438. QScriptValue constructQMainWindow(QScriptContext*context,
  2439. QScriptEngine*engine);
  2440. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2441. QScriptEngine*engine);
  2442. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2443. QScriptEngine*engine);
  2444. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2445. /*:33*//*38:*/
  2446. #line 1309 "./typica.w"
  2447. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2448. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2449. /*:38*//*41:*/
  2450. #line 1354 "./typica.w"
  2451. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2452. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2453. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2454. /*:41*//*44:*/
  2455. #line 1420 "./typica.w"
  2456. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2457. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2458. /*:44*//*47:*/
  2459. #line 1453 "./typica.w"
  2460. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2461. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2462. /*:47*//*50:*/
  2463. #line 1491 "./typica.w"
  2464. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2465. QScriptValue constructQSvgWidget(QScriptContext*context,
  2466. QScriptEngine*engine);
  2467. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2468. QScriptEngine*engine);
  2469. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2470. QStack<QLayout*> *layoutStack);
  2471. /*:50*//*56:*/
  2472. #line 1578 "./typica.w"
  2473. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2474. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2475. /*:56*//*60:*/
  2476. #line 1617 "./typica.w"
  2477. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2478. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2479. QScriptEngine*engine);
  2480. QScriptValue QSplitter_saveState(QScriptContext*context,
  2481. QScriptEngine*engine);
  2482. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2483. QScriptEngine*engine);
  2484. QScriptValue QSplitter_count(QScriptContext*context,
  2485. QScriptEngine*engine);
  2486. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2487. /*:60*//*66:*/
  2488. #line 1756 "./typica.w"
  2489. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2490. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2491. /*:66*//*68:*/
  2492. #line 1811 "./typica.w"
  2493. QScriptValue constructQBoxLayout(QScriptContext*context,
  2494. QScriptEngine*engine);
  2495. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2496. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2497. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2498. /*:68*//*72:*/
  2499. #line 1924 "./typica.w"
  2500. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2501. QScriptValue QAction_setShortcut(QScriptContext*context,
  2502. QScriptEngine*engine);
  2503. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2504. /*:72*//*75:*/
  2505. #line 1980 "./typica.w"
  2506. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2507. QScriptEngine*engine);
  2508. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2509. QScriptEngine*engine);
  2510. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2511. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2512. /*:75*//*80:*/
  2513. #line 2091 "./typica.w"
  2514. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2515. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2516. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2517. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2518. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2519. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2520. QScriptValue QIODevice_readToString(QScriptContext*context,
  2521. QScriptEngine*engine);
  2522. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2523. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2524. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2525. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2526. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2527. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2528. /*:80*//*91:*/
  2529. #line 2317 "./typica.w"
  2530. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2531. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2532. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2533. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2534. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2535. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2536. /*:91*//*99:*/
  2537. #line 2435 "./typica.w"
  2538. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2539. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2540. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2541. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2542. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2544. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2545. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2546. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2547. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2548. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2549. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2550. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2551. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2552. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2553. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2554. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2555. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2556. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2557. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2558. /*:99*//*112:*/
  2559. #line 2709 "./typica.w"
  2560. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2561. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2562. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2563. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2564. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2565. /*:112*//*115:*/
  2566. #line 2814 "./typica.w"
  2567. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2568. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2569. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2570. /*:115*//*118:*/
  2571. #line 2859 "./typica.w"
  2572. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2573. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2574. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2575. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2576. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2577. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2578. /*:118*//*124:*/
  2579. #line 2941 "./typica.w"
  2580. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2581. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2582. QScriptEngine*engine);
  2583. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2584. QScriptEngine*engine);
  2585. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2586. QScriptEngine*engine);
  2587. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2588. QScriptEngine*engine);
  2589. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2590. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2591. QScriptEngine*engine);
  2592. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2593. QScriptEngine*engine);
  2594. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2595. QScriptEngine*engine);
  2596. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2597. QScriptEngine*engine);
  2598. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2599. QScriptEngine*engine);
  2600. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2601. QScriptEngine*engine);
  2602. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2603. QScriptEngine*engine);
  2604. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2605. QScriptEngine*engine);
  2606. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2607. /*:124*//*133:*/
  2608. #line 3159 "./typica.w"
  2609. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2610. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2611. QScriptValue XmlReader_attribute(QScriptContext*context,
  2612. QScriptEngine*engine);
  2613. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2614. QScriptEngine*engine);
  2615. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2616. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2617. QScriptEngine*engine);
  2618. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2619. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2620. QScriptEngine*engine);
  2621. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2622. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2623. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2624. /*:133*//*140:*/
  2625. #line 3294 "./typica.w"
  2626. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2627. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2628. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2629. /*:140*//*144:*/
  2630. #line 3376 "./typica.w"
  2631. QScriptValue constructQLCDNumber(QScriptContext*context,
  2632. QScriptEngine*engine);
  2633. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2634. /*:144*//*147:*/
  2635. #line 3414 "./typica.w"
  2636. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2637. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2638. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2639. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2640. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2641. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2642. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2643. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2644. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2645. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2646. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2647. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2648. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2649. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2650. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2651. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2652. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2653. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2654. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2655. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2656. /*:147*//*163:*/
  2657. #line 3892 "./typica.w"
  2658. void setQAbstractScrollAreaProperties(QScriptValue value,
  2659. QScriptEngine*engine);
  2660. /*:163*//*165:*/
  2661. #line 3907 "./typica.w"
  2662. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2663. /*:165*//*167:*/
  2664. #line 3920 "./typica.w"
  2665. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2666. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2667. /*:167*//*169:*/
  2668. #line 3944 "./typica.w"
  2669. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2670. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2671. QScriptValue constructQPushButton(QScriptContext*context,
  2672. QScriptEngine*engine);
  2673. /*:169*//*176:*/
  2674. #line 4043 "./typica.w"
  2675. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2676. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2677. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2678. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2679. QScriptEngine*engine);
  2680. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2681. QScriptEngine*engine);
  2682. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2683. QScriptEngine*engine);
  2684. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2685. QScriptEngine*engine);
  2686. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2687. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2688. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2689. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2690. /*:176*//*183:*/
  2691. #line 4214 "./typica.w"
  2692. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2693. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2694. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2695. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2696. QScriptValue annotationFromRecord(QScriptContext*context,
  2697. QScriptEngine*engine);
  2698. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2699. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2700. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2701. /*:183*//*196:*/
  2702. #line 4561 "./typica.w"
  2703. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2704. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2705. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2706. QStack<QLayout*> *layoutStack);
  2707. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2708. QStack<QLayout*> *layoutStack);
  2709. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2710. QStack<QLayout*> *layoutStack);
  2711. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2712. QStack<QLayout*> *layoutStack);
  2713. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2714. QStack<QLayout*> *layoutStack);
  2715. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2716. QStack<QLayout*> *layoutStack);
  2717. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2718. QStack<QLayout*> *layoutStack);
  2719. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2720. QStack<QLayout*> *layoutStack);
  2721. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2722. QStack<QLayout*> *layoutStack);
  2723. void addTemperatureDisplayToSplitter(QDomElement element,
  2724. QStack<QWidget*> *widgetStack,
  2725. QStack<QLayout*> *layoutStack);
  2726. void addTemperatureDisplayToLayout(QDomElement element,
  2727. QStack<QWidget*> *widgetStack,
  2728. QStack<QLayout*> *layoutStack);
  2729. void addTimerDisplayToSplitter(QDomElement element,
  2730. QStack<QWidget*> *widgetStack,
  2731. QStack<QLayout*> *layoutStack);
  2732. void addTimerDisplayToLayout(QDomElement element,
  2733. QStack<QWidget*> *widgetStack,
  2734. QStack<QLayout*> *layoutStack);
  2735. void addDecorationToSplitter(QDomElement element,
  2736. QStack<QWidget*> *widgetStack,
  2737. QStack<QLayout*> *layoutStack);
  2738. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2739. QStack<QLayout*> *layoutStack);
  2740. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2741. QStack<QLayout*> *layoutStack);
  2742. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2743. QStack<QLayout*> *layoutStack);
  2744. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2745. QStack<QLayout*> *layoutStack);
  2746. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2747. QStack<QLayout*> *layoutStack);
  2748. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2749. QStack<QLayout*> *layoutStack);
  2750. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2751. QStack<QLayout*> *layoutStack);
  2752. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2753. QStack<QLayout*> *layoutStack);
  2754. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2755. QStack<QLayout*> *layoutStack);
  2756. void addSqlQueryViewToLayout(QDomElement element,
  2757. QStack<QWidget*> *widgetStack,
  2758. QStack<QLayout*> *layoutStack);
  2759. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2760. QStack<QLayout*> *layoutStack);
  2761. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2762. QStack<QLayout*> *layoutStack);
  2763. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2764. QStack<QLayout*> *layoutStack);
  2765. /*:196*//*225:*/
  2766. #line 5042 "./typica.w"
  2767. QScriptValue constructQTabBar(QScriptContext*context,QScriptEngine*engine);
  2768. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine);
  2769. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*engine);
  2770. /*:225*//*266:*/
  2771. #line 6328 "./typica.w"
  2772. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2773. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2774. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2775. QScriptEngine*engine);
  2776. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2777. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2778. QScriptEngine*engine);
  2779. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2780. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2781. /*:266*//*269:*/
  2782. #line 6373 "./typica.w"
  2783. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2784. /*:269*//*270:*/
  2785. #line 6381 "./typica.w"
  2786. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2787. /*:270*//*274:*/
  2788. #line 6528 "./typica.w"
  2789. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2790. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2791. QScriptEngine*engine);
  2792. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2793. QScriptEngine*engine);
  2794. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2795. QScriptEngine*engine);
  2796. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2797. QScriptEngine*engine);
  2798. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2799. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2800. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2801. QScriptEngine*engine);
  2802. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2803. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2804. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2805. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2806. /*:274*//*284:*/
  2807. #line 6744 "./typica.w"
  2808. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2809. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2810. QScriptValue QComboBox_currentData(QScriptContext*context,
  2811. QScriptEngine*engine);
  2812. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2813. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2814. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2815. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2816. /*:284*//*296:*/
  2817. #line 379 "./units.w"
  2818. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2819. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2820. QScriptEngine*engine);
  2821. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2822. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2823. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2824. /*:296*//*300:*/
  2825. #line 443 "./units.w"
  2826. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2827. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2828. /*:300*//*309:*/
  2829. #line 133 "./measurement.w"
  2830. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2831. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2832. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2833. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2834. /*:309*//*329:*/
  2835. #line 7379 "./typica.w"
  2836. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2837. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2838. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2839. /*:329*//*338:*/
  2840. #line 7584 "./typica.w"
  2841. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2842. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2843. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2844. /*:338*//*343:*/
  2845. #line 7685 "./typica.w"
  2846. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2847. /*:343*//*349:*/
  2848. #line 7867 "./typica.w"
  2849. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2850. QScriptEngine*engine);
  2851. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2852. /*:349*//*354:*/
  2853. #line 8007 "./typica.w"
  2854. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2855. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2856. /*:354*//*364:*/
  2857. #line 8212 "./typica.w"
  2858. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2859. QScriptEngine*engine);
  2860. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2861. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2862. QScriptEngine*engine);
  2863. /*:364*//*372:*/
  2864. #line 8371 "./typica.w"
  2865. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2866. QScriptEngine*engine);
  2867. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2868. QScriptEngine*engine);
  2869. /*:372*//*377:*/
  2870. #line 8494 "./typica.w"
  2871. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2872. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2873. /*:377*//*382:*/
  2874. #line 8592 "./typica.w"
  2875. QScriptValue constructZeroEmitter(QScriptContext*context,
  2876. QScriptEngine*engine);
  2877. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2878. /*:382*//*387:*/
  2879. #line 8671 "./typica.w"
  2880. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2881. QScriptEngine*engine);
  2882. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2883. /*:387*//*404:*/
  2884. #line 9135 "./typica.w"
  2885. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2886. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2887. /*:404*//*427:*/
  2888. #line 9774 "./typica.w"
  2889. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2890. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2891. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2892. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2893. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2894. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2895. QScriptEngine*engine);
  2896. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2897. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2898. QScriptEngine*engnie);
  2899. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2900. QScriptEngine*engine);
  2901. /*:427*//*465:*/
  2902. #line 10731 "./typica.w"
  2903. QScriptValue constructAnnotationButton(QScriptContext*context,
  2904. QScriptEngine*engine);
  2905. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2906. /*:465*//*473:*/
  2907. #line 10871 "./typica.w"
  2908. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2909. QScriptEngine*engine);
  2910. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2911. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2912. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2913. /*:473*//*494:*/
  2914. #line 11297 "./typica.w"
  2915. QScriptValue constructTimerDisplay(QScriptContext*context,
  2916. QScriptEngine*engine);
  2917. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2918. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2919. /*:494*//*522:*/
  2920. #line 11822 "./typica.w"
  2921. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2922. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2923. QScriptEngine*engine);
  2924. /*:522*//*535:*/
  2925. #line 12105 "./typica.w"
  2926. QScriptValue constructLogEditWindow(QScriptContext*context,
  2927. QScriptEngine*engine);
  2928. /*:535*//*554:*/
  2929. #line 12632 "./typica.w"
  2930. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2931. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2932. /*:554*//*573:*/
  2933. #line 204 "./webview.w"
  2934. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2935. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2936. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2937. QStack<QLayout*> *layoutStack);
  2938. /*:573*//*576:*/
  2939. #line 234 "./webview.w"
  2940. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2941. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2942. /*:576*//*580:*/
  2943. #line 292 "./webview.w"
  2944. QScriptValue constructWebElement(QScriptContext*context,
  2945. QScriptEngine*engine);
  2946. /*:580*//*592:*/
  2947. #line 67 "./printerselector.w"
  2948. QScriptValue constructPrinterSelector(QScriptContext*context,
  2949. QScriptEngine*engine);
  2950. void addPrinterSelectorToLayout(QDomElement element,
  2951. QStack<QWidget*> *widgetStack,
  2952. QStack<QLayout*> *layoutStack);
  2953. /*:592*//*659:*/
  2954. #line 14013 "./typica.w"
  2955. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2956. QScriptValue constructSqlQueryView(QScriptContext*context,
  2957. QScriptEngine*engine);
  2958. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2959. QScriptEngine*engine);
  2960. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2961. QScriptEngine*engine);
  2962. /*:659*//*669:*/
  2963. #line 14252 "./typica.w"
  2964. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2965. QStack<QLayout*> *layoutStack);
  2966. /*:669*//*685:*/
  2967. #line 14537 "./typica.w"
  2968. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2969. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2970. /*:685*//*713:*/
  2971. #line 482 "./daterangeselector.w"
  2972. void addDateRangeToLayout(QDomElement element,
  2973. QStack<QWidget*> *widgetStack,
  2974. QStack<QLayout*> *layoutStack);
  2975. /*:713*//*722:*/
  2976. #line 14736 "./typica.w"
  2977. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2978. QStack<QLayout*> *layoutStack);
  2979. /*:722*//*743:*/
  2980. #line 15320 "./typica.w"
  2981. void addScaleControlToLayout(QDomElement element,
  2982. QStack<QWidget*> *widgetStack,
  2983. QStack<QLayout*> *layoutStack);
  2984. void addIntensityControlToLayout(QDomElement element,
  2985. QStack<QWidget*> *widgetStack,
  2986. QStack<QLayout*> *layoutStack);
  2987. /*:743*//*769:*/
  2988. #line 15906 "./typica.w"
  2989. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2990. QScriptEngine*engine);
  2991. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2992. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2993. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2994. QScriptEngine*engine);
  2995. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2996. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2997. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2998. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2999. /*:769*//*775:*/
  3000. #line 16048 "./typica.w"
  3001. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  3002. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  3003. /*:775*//*791:*/
  3004. #line 16346 "./typica.w"
  3005. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  3006. QScriptEngine*engine);
  3007. /*:791*//*862:*/
  3008. #line 42 "./settings.w"
  3009. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  3010. /*:862*//*886:*/
  3011. #line 18989 "./typica.w"
  3012. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  3013. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  3014. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  3015. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3016. /*:886*//*904:*/
  3017. #line 698 "./modbus.w"
  3018. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  3019. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  3020. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  3021. /*:904*//*918:*/
  3022. #line 345 "./unsupportedserial.w"
  3023. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  3024. /*:918*//*924:*/
  3025. #line 425 "./unsupportedserial.w"
  3026. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  3027. /*:924*//*930:*/
  3028. #line 617 "./unsupportedserial.w"
  3029. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  3030. /*:930*//*934:*/
  3031. #line 651 "./unsupportedserial.w"
  3032. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  3033. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  3034. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  3035. /*:934*//*958:*/
  3036. #line 457 "./phidgets.w"
  3037. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  3038. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  3039. /*:958*//*990:*/
  3040. #line 138 "./rate.w"
  3041. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  3042. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  3043. /*:990*//*1004:*/
  3044. #line 129 "./mergeseries.w"
  3045. QScriptValue constructDifferenceSeries(QScriptContext*context,
  3046. QScriptEngine*engine);
  3047. QScriptValue constructMeanSeries(QScriptContext*context,
  3048. QScriptEngine*engine);
  3049. /*:1004*//*1029:*/
  3050. #line 597 "./dataqsdk.w"
  3051. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  3052. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  3053. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3054. /*:1029*//*1056:*/
  3055. #line 67 "./scales.w"
  3056. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  3057. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  3058. /*:1056*//*1064:*/
  3059. #line 259 "./scales.w"
  3060. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  3061. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  3062. /*:1064*//*1067:*/
  3063. #line 284 "./scales.w"
  3064. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  3065. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  3066. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  3067. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  3068. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  3069. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  3070. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  3071. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  3072. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  3073. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  3074. /*:1067*//*1092:*/
  3075. #line 265 "./valueannotation.w"
  3076. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  3077. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  3078. /*:1092*//*1103:*/
  3079. #line 194 "./thresholdannotation.w"
  3080. QScriptValue constructAnnotator(QScriptContext*context,
  3081. QScriptEngine*engine);
  3082. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  3083. /*:1103*//*1116:*/
  3084. #line 151 "./user.w"
  3085. QScriptValue constructLoginDialog(QScriptContext*context,QScriptEngine*engine);
  3086. /*:1116*//*1126:*/
  3087. #line 339 "./user.w"
  3088. QScriptValue constructNewTypicaUser(QScriptContext*context,QScriptEngine*engine);
  3089. /*:1126*/
  3090. #line 527 "./typica.w"
  3091. /*639:*/
  3092. #line 13655 "./typica.w"
  3093. void messageFileOutput(QtMsgType type,const char*msg);
  3094. /*:639*/
  3095. #line 528 "./typica.w"
  3096. /*4:*/
  3097. #line 537 "./typica.w"
  3098. /*783:*/
  3099. #line 16169 "./typica.w"
  3100. NodeInserter::NodeInserter(const QString&title,const QString&name,
  3101. const QString&driver,QObject*parent):
  3102. QAction(title,parent),defaultNodeName(name),driverString(driver)
  3103. {
  3104. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  3105. }
  3106. void NodeInserter::onTriggered()
  3107. {
  3108. emit triggered(defaultNodeName,driverString);
  3109. }
  3110. /*:783*/
  3111. #line 538 "./typica.w"
  3112. /*305:*/
  3113. #line 40 "./measurement.w"
  3114. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  3115. {
  3116. insert("measurement",temperature);
  3117. insert("time",time);
  3118. insert("unit",sc);
  3119. }
  3120. Measurement::Measurement(double temperature)
  3121. {
  3122. insert("measurement",temperature);
  3123. insert("time",QTime::currentTime());
  3124. insert("unit",Units::Fahrenheit);
  3125. }
  3126. void Measurement::setTemperature(double temperature)
  3127. {
  3128. insert("measurement",temperature);
  3129. }
  3130. void Measurement::setTime(QTime time)
  3131. {
  3132. insert("time",time);
  3133. }
  3134. void Measurement::setUnit(Units::Unit scale)
  3135. {
  3136. insert("unit",scale);
  3137. }
  3138. double Measurement::temperature()const
  3139. {
  3140. return value("measurement").toDouble();
  3141. }
  3142. QTime Measurement::time()const
  3143. {
  3144. return value("time").toTime();
  3145. }
  3146. Units::Unit Measurement::scale()const
  3147. {
  3148. return(Units::Unit)(value("unit").toInt());
  3149. }
  3150. /*:305*//*306:*/
  3151. #line 88 "./measurement.w"
  3152. Measurement Measurement::toFahrenheit()
  3153. {
  3154. return Measurement(Units::convertTemperature(this->temperature(),
  3155. this->scale(),Units::Fahrenheit),
  3156. this->time(),Units::Fahrenheit);
  3157. }
  3158. Measurement Measurement::toCelsius()
  3159. {
  3160. return Measurement(Units::convertTemperature(this->temperature(),
  3161. this->scale(),Units::Celsius),
  3162. this->time(),Units::Celsius);
  3163. }
  3164. Measurement Measurement::toKelvin()
  3165. {
  3166. return Measurement(Units::convertTemperature(this->temperature(),
  3167. this->scale(),Units::Kelvin),
  3168. this->time(),Units::Kelvin);
  3169. }
  3170. Measurement Measurement::toRankine()
  3171. {
  3172. return Measurement(Units::convertTemperature(this->temperature(),
  3173. this->scale(),Units::Rankine),
  3174. this->time(),Units::Rankine);
  3175. }
  3176. /*:306*/
  3177. #line 539 "./typica.w"
  3178. /*319:*/
  3179. #line 6984 "./typica.w"
  3180. void DAQImplementation::measure()
  3181. {
  3182. int samplesRead= 0;
  3183. double buffer[channels];
  3184. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3185. (unsigned long)(0),buffer,(unsigned long)(channels),
  3186. &samplesRead,(signed long)(0));
  3187. if(error)
  3188. {
  3189. ready= false;
  3190. }
  3191. else
  3192. {
  3193. if(samplesRead)
  3194. {
  3195. QTime time= QTime::currentTime();
  3196. for(int i= 0;i<samplesRead;i++)
  3197. {
  3198. for(int j= 0;j<channels;j++)
  3199. {
  3200. double measuredValue= buffer[j+(i*channels)];
  3201. Measurement measure(measuredValue,time,
  3202. unitMap[j]);
  3203. channelMap[j]->input(measure);
  3204. }
  3205. }
  3206. }
  3207. }
  3208. }
  3209. /*:319*//*320:*/
  3210. #line 7027 "./typica.w"
  3211. void DAQImplementation::run()
  3212. {
  3213. setPriority(QThread::TimeCriticalPriority);
  3214. while(ready)
  3215. {
  3216. measure();
  3217. }
  3218. }
  3219. /*:320*//*321:*/
  3220. #line 7043 "./typica.w"
  3221. void DAQ::threadFinished()
  3222. {
  3223. if(imp->error)
  3224. {
  3225. /*322:*/
  3226. #line 7094 "./typica.w"
  3227. imp->ready= false;
  3228. QMessageBox warning;
  3229. warning.setStandardButtons(QMessageBox::Cancel);
  3230. warning.setIcon(QMessageBox::Warning);
  3231. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3232. unsigned long bytes= imp->errorInfo(NULL,0);
  3233. char string[bytes];
  3234. imp->errorInfo(string,bytes);
  3235. warning.setInformativeText(QString(string));
  3236. warning.setWindowTitle(QString(PROGRAM_NAME));
  3237. warning.exec();
  3238. /*:322*/
  3239. #line 7048 "./typica.w"
  3240. }
  3241. }
  3242. /*:321*//*323:*/
  3243. #line 7119 "./typica.w"
  3244. void DAQ::start()
  3245. {
  3246. if(imp->ready)
  3247. {
  3248. imp->error= imp->startTask(imp->handle);
  3249. if(imp->error)
  3250. {
  3251. /*322:*/
  3252. #line 7094 "./typica.w"
  3253. imp->ready= false;
  3254. QMessageBox warning;
  3255. warning.setStandardButtons(QMessageBox::Cancel);
  3256. warning.setIcon(QMessageBox::Warning);
  3257. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3258. unsigned long bytes= imp->errorInfo(NULL,0);
  3259. char string[bytes];
  3260. imp->errorInfo(string,bytes);
  3261. warning.setInformativeText(QString(string));
  3262. warning.setWindowTitle(QString(PROGRAM_NAME));
  3263. warning.exec();
  3264. /*:322*/
  3265. #line 7127 "./typica.w"
  3266. }
  3267. else
  3268. {
  3269. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3270. imp->start();
  3271. }
  3272. }
  3273. }
  3274. void DAQ::stop()
  3275. {
  3276. if(imp->useBase)
  3277. {
  3278. imp->ready= false;
  3279. imp->wait(ULONG_MAX);
  3280. imp->stopTask(imp->handle);
  3281. }
  3282. else
  3283. {
  3284. imp->ready= false;
  3285. imp->error= imp->stopTask(imp->handle);
  3286. if(imp->error)
  3287. {
  3288. /*322:*/
  3289. #line 7094 "./typica.w"
  3290. imp->ready= false;
  3291. QMessageBox warning;
  3292. warning.setStandardButtons(QMessageBox::Cancel);
  3293. warning.setIcon(QMessageBox::Warning);
  3294. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3295. unsigned long bytes= imp->errorInfo(NULL,0);
  3296. char string[bytes];
  3297. imp->errorInfo(string,bytes);
  3298. warning.setInformativeText(QString(string));
  3299. warning.setWindowTitle(QString(PROGRAM_NAME));
  3300. warning.exec();
  3301. /*:322*/
  3302. #line 7151 "./typica.w"
  3303. }
  3304. imp->error= imp->clearTask(imp->handle);
  3305. if(imp->error)
  3306. {
  3307. /*322:*/
  3308. #line 7094 "./typica.w"
  3309. imp->ready= false;
  3310. QMessageBox warning;
  3311. warning.setStandardButtons(QMessageBox::Cancel);
  3312. warning.setIcon(QMessageBox::Warning);
  3313. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3314. unsigned long bytes= imp->errorInfo(NULL,0);
  3315. char string[bytes];
  3316. imp->errorInfo(string,bytes);
  3317. warning.setInformativeText(QString(string));
  3318. warning.setWindowTitle(QString(PROGRAM_NAME));
  3319. warning.exec();
  3320. /*:322*/
  3321. #line 7156 "./typica.w"
  3322. }
  3323. }
  3324. }
  3325. /*:323*//*324:*/
  3326. #line 7166 "./typica.w"
  3327. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3328. {
  3329. imp->device= device;
  3330. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3331. if(imp->error)
  3332. {
  3333. /*322:*/
  3334. #line 7094 "./typica.w"
  3335. imp->ready= false;
  3336. QMessageBox warning;
  3337. warning.setStandardButtons(QMessageBox::Cancel);
  3338. warning.setIcon(QMessageBox::Warning);
  3339. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3340. unsigned long bytes= imp->errorInfo(NULL,0);
  3341. char string[bytes];
  3342. imp->errorInfo(string,bytes);
  3343. warning.setInformativeText(QString(string));
  3344. warning.setWindowTitle(QString(PROGRAM_NAME));
  3345. warning.exec();
  3346. /*:322*/
  3347. #line 7173 "./typica.w"
  3348. }
  3349. else
  3350. {
  3351. imp->ready= true;
  3352. }
  3353. }
  3354. /*:324*//*325:*/
  3355. #line 7187 "./typica.w"
  3356. Channel*DAQ::newChannel(int units,int thermocouple)
  3357. {
  3358. Channel*retval= new Channel();
  3359. imp->channelMap[imp->channels]= retval;
  3360. imp->unitMap[imp->channels]= (Units::Unit)units;
  3361. imp->channels++;
  3362. if(imp->ready)
  3363. {
  3364. if(imp->useBase)
  3365. {
  3366. imp->error= imp->createChannel(imp->handle,
  3367. QString("%1/ai%2").arg(imp->device).
  3368. arg(imp->channels-1).
  3369. toAscii().data(),
  3370. "",(double)(-1.0),(double)(100.0),
  3371. (signed long)(units),
  3372. (signed long)(thermocouple),
  3373. (signed long)(10200),(double)(0),
  3374. "");
  3375. }
  3376. else
  3377. {
  3378. imp->error= imp->createChannel(imp->handle,
  3379. QString("%1/ai%2").arg(imp->device).
  3380. arg(imp->channels-1).
  3381. toAscii().data(),
  3382. "",(double)(50.0),(double)(500.0),
  3383. (signed long)(units),
  3384. (signed long)(thermocouple),
  3385. (signed long)(10200),(double)(0),
  3386. "");
  3387. }
  3388. if(imp->error)
  3389. {
  3390. /*322:*/
  3391. #line 7094 "./typica.w"
  3392. imp->ready= false;
  3393. QMessageBox warning;
  3394. warning.setStandardButtons(QMessageBox::Cancel);
  3395. warning.setIcon(QMessageBox::Warning);
  3396. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3397. unsigned long bytes= imp->errorInfo(NULL,0);
  3398. char string[bytes];
  3399. imp->errorInfo(string,bytes);
  3400. warning.setInformativeText(QString(string));
  3401. warning.setWindowTitle(QString(PROGRAM_NAME));
  3402. warning.exec();
  3403. /*:322*/
  3404. #line 7222 "./typica.w"
  3405. }
  3406. }
  3407. return retval;
  3408. }
  3409. /*:325*//*326:*/
  3410. #line 7236 "./typica.w"
  3411. void DAQ::setClockRate(double Hz)
  3412. {
  3413. if(imp->ready)
  3414. {
  3415. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3416. (signed long)(10280),(signed long)(10123),
  3417. (unsigned long long)(1));
  3418. if(imp->error)
  3419. {
  3420. /*322:*/
  3421. #line 7094 "./typica.w"
  3422. imp->ready= false;
  3423. QMessageBox warning;
  3424. warning.setStandardButtons(QMessageBox::Cancel);
  3425. warning.setIcon(QMessageBox::Warning);
  3426. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3427. unsigned long bytes= imp->errorInfo(NULL,0);
  3428. char string[bytes];
  3429. imp->errorInfo(string,bytes);
  3430. warning.setInformativeText(QString(string));
  3431. warning.setWindowTitle(QString(PROGRAM_NAME));
  3432. warning.exec();
  3433. /*:322*/
  3434. #line 7246 "./typica.w"
  3435. }
  3436. }
  3437. }
  3438. /*:326*//*327:*/
  3439. #line 7256 "./typica.w"
  3440. DAQ::~DAQ()
  3441. {
  3442. if(imp->useBase)
  3443. {
  3444. imp->resetDevice(imp->device.toAscii().data());
  3445. imp->clearTask(imp->handle);
  3446. }
  3447. else
  3448. {
  3449. if(imp->ready)
  3450. {
  3451. imp->ready= false;
  3452. imp->wait(ULONG_MAX);
  3453. imp->stopTask(imp->handle);
  3454. imp->resetDevice(imp->device.toAscii().data());
  3455. imp->clearTask(imp->handle);
  3456. }
  3457. }
  3458. delete imp;
  3459. }
  3460. /*:327*//*328:*/
  3461. #line 7287 "./typica.w"
  3462. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3463. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3464. unitMap(4)
  3465. {
  3466. if(driverinfo=="nidaqmxbase")
  3467. {
  3468. useBase= true;
  3469. }
  3470. else
  3471. {
  3472. useBase= false;
  3473. }
  3474. if(useBase)
  3475. {
  3476. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3477. if(!driver.load())
  3478. {
  3479. driver.setFileName("nidaqmxbase");
  3480. if(!driver.load())
  3481. {
  3482. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3483. tr("Failed to find nidaqmxbase. Please install it."));
  3484. QApplication::quit();
  3485. }
  3486. }
  3487. }
  3488. else
  3489. {
  3490. driver.setFileName("nicaiu");
  3491. if(!driver.load())
  3492. {
  3493. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3494. tr("Failed to find nidaqmx. Please install it."));
  3495. QApplication::quit();
  3496. }
  3497. }
  3498. if(useBase)
  3499. {
  3500. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3501. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3502. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3503. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3504. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3505. ==0||
  3506. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3507. 0||
  3508. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3509. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3510. 0||
  3511. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3512. {
  3513. waitForMeasurement= NULL;
  3514. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3515. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3516. QApplication::quit();
  3517. }
  3518. }
  3519. else
  3520. {
  3521. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3522. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3523. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3524. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3525. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3526. ==0||
  3527. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3528. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3529. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3530. 0||
  3531. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3532. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3533. {
  3534. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3535. tr("Failed to link a required symbol in NI-DAQmx."));
  3536. QApplication::quit();
  3537. }
  3538. }
  3539. }
  3540. DAQImplementation::~DAQImplementation()
  3541. {
  3542. driver.unload();
  3543. }
  3544. /*:328*/
  3545. #line 540 "./typica.w"
  3546. /*1018:*/
  3547. #line 197 "./dataqsdk.w"
  3548. void DataqSdkDeviceImplementation::measure()
  3549. {
  3550. unsigned count= channels*40;
  3551. di_status_read(buffer,count);
  3552. QTime time= QTime::currentTime();
  3553. for(unsigned int i= 0;i<count;i++)
  3554. {
  3555. buffer[i]= buffer[i]&0xFFFC;
  3556. }
  3557. QList<int> countList;
  3558. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3559. {
  3560. QList<double> channelBuffer;
  3561. for(unsigned int j= 0;j<40;j++)
  3562. {
  3563. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3564. if(i==0)
  3565. {
  3566. countList<<buffer[i+(channels*j)];
  3567. }
  3568. }
  3569. double value= 0.0;
  3570. for(unsigned int j= 0;j<40;j++)
  3571. {
  3572. value+= channelBuffer[j];
  3573. }
  3574. value/= 40.0;
  3575. if(i==0)
  3576. {
  3577. QList<double> smoothingList;
  3578. smoothingList<<value;
  3579. QList<int> smoothingKeys= smoother.uniqueKeys();
  3580. for(int j= 0;j<smoothingKeys.size();j++)
  3581. {
  3582. if(countList.contains(smoothingKeys[j]))
  3583. {
  3584. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3585. for(int k= 0;k<keyValues.size();k++)
  3586. {
  3587. smoothingList<<keyValues[k];
  3588. }
  3589. }
  3590. else
  3591. {
  3592. smoother.remove(smoothingKeys[j]);
  3593. }
  3594. }
  3595. qSort(countList);
  3596. int lastCount= 0;
  3597. for(int j= 0;j<countList.size();j++)
  3598. {
  3599. if(j==0||countList[j]!=lastCount)
  3600. {
  3601. smoother.insert(countList[j],value);
  3602. lastCount= countList[j];
  3603. }
  3604. }
  3605. value= 0.0;
  3606. for(int j= 0;j<smoothingList.size();j++)
  3607. {
  3608. value+= smoothingList[j];
  3609. }
  3610. value/= smoothingList.size();
  3611. }
  3612. Measurement measure(value,time,unitMap[i]);
  3613. channelMap[i]->input(measure);
  3614. }
  3615. }
  3616. /*:1018*//*1019:*/
  3617. #line 290 "./dataqsdk.w"
  3618. void DataqSdkDeviceImplementation::run()
  3619. {
  3620. if(!ready)
  3621. {
  3622. error= 9;
  3623. return;
  3624. }
  3625. driver= new QLibrary(device);
  3626. if(!driver->load())
  3627. {
  3628. error= 1;
  3629. qDebug()<<"Failed to load driver: "<<device;
  3630. return;
  3631. }
  3632. di_open= (FPDIOPEN)driver->resolve("di_open");
  3633. di_close= (FPDICLOSE)driver->resolve("di_close");
  3634. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3635. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3636. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3637. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3638. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3639. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3640. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3641. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3642. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3643. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3644. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3645. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3646. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3647. (!di_burst_rate)||(!di_stop_scan))
  3648. {
  3649. error= 2;
  3650. return;
  3651. }
  3652. error= di_open(deviceNumber);
  3653. if(error)
  3654. {
  3655. di_close();
  3656. error= di_open(deviceNumber);
  3657. if(error)
  3658. {
  3659. error= 3;
  3660. di_close();
  3661. return;
  3662. }
  3663. }
  3664. isOpen= true;
  3665. di_maximum_rate(240.0);
  3666. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3667. &burstDivisor);
  3668. buffer= new qint16[(int)sampleRate];
  3669. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3670. for(unsigned short i= 0;i<channels;i++)
  3671. {
  3672. inlist[i].chan= i;
  3673. inlist[i].gain= 0;
  3674. inlist[i].ave= 1;
  3675. inlist[i].counter= (oversample-1);
  3676. }
  3677. error= di_list_length(channels,0);
  3678. if(error)
  3679. {
  3680. error= 4;
  3681. return;
  3682. }
  3683. error= di_inlist(inlist);
  3684. if(error)
  3685. {
  3686. error= 5;
  3687. return;
  3688. }
  3689. input_buffer= di_buffer_alloc(0,4096);
  3690. if(input_buffer==NULL)
  3691. {
  3692. error= 6;
  3693. return;
  3694. }
  3695. error= di_start_scan();
  3696. if(error)
  3697. {
  3698. error= 7;
  3699. return;
  3700. }
  3701. while(ready)
  3702. {
  3703. measure();
  3704. }
  3705. }
  3706. /*:1019*//*1020:*/
  3707. #line 386 "./dataqsdk.w"
  3708. void DataqSdkDevice::threadFinished()
  3709. {
  3710. if(imp->error)
  3711. {
  3712. /*1021:*/
  3713. #line 400 "./dataqsdk.w"
  3714. imp->ready= false;
  3715. QMessageBox warning;
  3716. warning.setStandardButtons(QMessageBox::Cancel);
  3717. warning.setIcon(QMessageBox::Warning);
  3718. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3719. warning.setInformativeText(tr("An error occurred"));
  3720. warning.setWindowTitle(QString(PROGRAM_NAME));
  3721. warning.exec();
  3722. /*:1021*/
  3723. #line 391 "./dataqsdk.w"
  3724. }
  3725. }
  3726. /*:1020*//*1022:*/
  3727. #line 417 "./dataqsdk.w"
  3728. void DataqSdkDevice::start()
  3729. {
  3730. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3731. imp->start();
  3732. }
  3733. /*:1022*//*1023:*/
  3734. #line 428 "./dataqsdk.w"
  3735. QStringList DataqSdkDevice::detectHardware()
  3736. {
  3737. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3738. QSettings::NativeFormat);
  3739. QStringList keys= deviceLookup.childKeys();
  3740. QStringList devices;
  3741. for(int i= 0;i<keys.size();i++)
  3742. {
  3743. QString value= deviceLookup.value(keys.at(i)).toString();
  3744. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3745. {
  3746. devices.append(value.split("\\").at(2));
  3747. }
  3748. }
  3749. QStringList portList;
  3750. foreach(QString device,devices)
  3751. {
  3752. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3753. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3754. portList.append(deviceEntry.value("FriendlyName").toString());
  3755. }
  3756. return portList;
  3757. }
  3758. QStringList DataqSdkDevice::detectPorts()
  3759. {
  3760. QStringList friendlyNames= detectHardware();
  3761. QStringList portList;
  3762. foreach(QString name,friendlyNames)
  3763. {
  3764. name.remove(0,name.indexOf("COM"));
  3765. name.chop(1);
  3766. portList.append(name);
  3767. }
  3768. return portList;
  3769. }
  3770. /*:1023*//*1024:*/
  3771. #line 473 "./dataqsdk.w"
  3772. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3773. {
  3774. bool usesAuto= false;
  3775. int autoIndex= device.toInt(&usesAuto);
  3776. QString finalizedPort;
  3777. if(usesAuto)
  3778. {
  3779. QStringList portList= detectPorts();
  3780. if(autoIndex> 0&&autoIndex<=portList.size())
  3781. {
  3782. finalizedPort= portList.at(autoIndex-1);
  3783. }
  3784. else
  3785. {
  3786. imp->error= 8;
  3787. qDebug()<<"Failed to detect port.";
  3788. }
  3789. }
  3790. else
  3791. {
  3792. finalizedPort= device;
  3793. }
  3794. int rstart= finalizedPort.indexOf("COM");
  3795. finalizedPort.remove(0,rstart+3);
  3796. bool chopFinished= false;
  3797. int finalizedPortNumber= 0;
  3798. while(finalizedPort.size()> 0&&!chopFinished)
  3799. {
  3800. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3801. if(!chopFinished)
  3802. {
  3803. finalizedPort.chop(1);
  3804. }
  3805. }
  3806. if(finalizedPortNumber<10)
  3807. {
  3808. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3809. }
  3810. else
  3811. {
  3812. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3813. }
  3814. imp->deviceNumber= 0x12C02D00;
  3815. imp->deviceNumber+= finalizedPortNumber;
  3816. imp->ready= true;
  3817. }
  3818. /*:1024*//*1025:*/
  3819. #line 523 "./dataqsdk.w"
  3820. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3821. {
  3822. Channel*retval= NULL;
  3823. if(imp->ready)
  3824. {
  3825. retval= new Channel();
  3826. imp->channelMap[imp->channels]= retval;
  3827. imp->unitMap[imp->channels]= scale;
  3828. imp->channels++;
  3829. }
  3830. return retval;
  3831. }
  3832. /*:1025*//*1026:*/
  3833. #line 547 "./dataqsdk.w"
  3834. void DataqSdkDevice::setClockRate(double Hz)
  3835. {
  3836. imp->sampleRate= Hz;
  3837. }
  3838. /*:1026*//*1027:*/
  3839. #line 557 "./dataqsdk.w"
  3840. DataqSdkDevice::~DataqSdkDevice()
  3841. {
  3842. if(imp->ready)
  3843. {
  3844. imp->ready= false;
  3845. }
  3846. imp->wait(ULONG_MAX);
  3847. delete imp;
  3848. }
  3849. /*:1027*//*1028:*/
  3850. #line 575 "./dataqsdk.w"
  3851. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3852. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3853. {
  3854. }
  3855. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3856. {
  3857. if(isOpen)
  3858. {
  3859. di_stop_scan();
  3860. di_close();
  3861. }
  3862. if(driver->isLoaded())
  3863. {
  3864. driver->unload();
  3865. }
  3866. }
  3867. /*:1028*/
  3868. #line 541 "./typica.w"
  3869. /*335:*/
  3870. #line 7496 "./typica.w"
  3871. void FakeDAQImplementation::measure()
  3872. {
  3873. msleep((int)(1000/clockRate));
  3874. QTime time= QTime::currentTime();
  3875. for(int i= 0;i<channels;i++)
  3876. {
  3877. Measurement measure(qrand()%500,time);
  3878. channelMap[i]->input(measure);
  3879. }
  3880. }
  3881. /*:335*//*336:*/
  3882. #line 7510 "./typica.w"
  3883. void FakeDAQImplementation::run()
  3884. {
  3885. setPriority(QThread::TimeCriticalPriority);
  3886. while(ready)
  3887. {
  3888. measure();
  3889. }
  3890. }
  3891. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3892. channels(0),ready(false),clockRate(1)
  3893. {
  3894. }
  3895. FakeDAQImplementation::~FakeDAQImplementation()
  3896. {
  3897. }
  3898. /*:336*//*337:*/
  3899. #line 7535 "./typica.w"
  3900. void FakeDAQ::start()
  3901. {
  3902. if(imp->ready)
  3903. {
  3904. imp->start();
  3905. }
  3906. }
  3907. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3908. {
  3909. imp->ready= true;
  3910. }
  3911. Channel*FakeDAQ::newChannel(int,int)
  3912. {
  3913. Channel*retval;
  3914. if(imp->ready)
  3915. {
  3916. retval= new Channel();
  3917. imp->channelMap[imp->channels]= retval;
  3918. imp->channels++;
  3919. }
  3920. else
  3921. {
  3922. return NULL;
  3923. }
  3924. return retval;
  3925. }
  3926. void FakeDAQ::setClockRate(double Hz)
  3927. {
  3928. if(imp->ready)
  3929. {
  3930. imp->clockRate= Hz;
  3931. }
  3932. }
  3933. FakeDAQ::~FakeDAQ()
  3934. {
  3935. imp->ready= false;
  3936. imp->wait(ULONG_MAX);
  3937. delete imp;
  3938. }
  3939. /*:337*/
  3940. #line 542 "./typica.w"
  3941. /*342:*/
  3942. #line 7666 "./typica.w"
  3943. Channel::Channel():QObject(NULL)
  3944. {
  3945. }
  3946. Channel::~Channel()
  3947. {
  3948. }
  3949. void Channel::input(Measurement measurement)
  3950. {
  3951. emit newData(measurement);
  3952. }
  3953. /*:342*/
  3954. #line 543 "./typica.w"
  3955. /*358:*/
  3956. #line 8071 "./typica.w"
  3957. void TemperatureDisplay::setRelativeMode(bool relative)
  3958. {
  3959. r= relative;
  3960. }
  3961. /*:358*//*359:*/
  3962. #line 8088 "./typica.w"
  3963. void TemperatureDisplay::setValue(Measurement temperature)
  3964. {
  3965. QString number;
  3966. switch(unit)
  3967. {
  3968. case Units::Fahrenheit:
  3969. display(QString("%1'F").
  3970. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3971. 2)));
  3972. break;
  3973. case Units::Celsius:
  3974. if(!r){
  3975. display(QString("%1'C").
  3976. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3977. 2)));
  3978. }else{
  3979. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3980. display(QString("%1'C").arg(number));
  3981. }
  3982. break;
  3983. case Units::Kelvin:
  3984. if(!r){
  3985. display(QString("%1").
  3986. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3987. 2)));
  3988. }else{
  3989. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3990. display(QString("%1").arg(number));
  3991. }
  3992. break;
  3993. case Units::Rankine:
  3994. display(QString("%1'r").
  3995. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3996. 2)));
  3997. break;
  3998. case Units::Unitless:
  3999. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4000. break;
  4001. default:
  4002. switch(temperature.scale())
  4003. {
  4004. case Units::Fahrenheit:
  4005. display(QString("%1'F").
  4006. arg(number.setNum(temperature.temperature(),'f',2)));
  4007. break;
  4008. case Units::Celsius:
  4009. display(QString("%1'C").
  4010. arg(number.setNum(temperature.temperature(),'f',2)));
  4011. break;
  4012. case Units::Kelvin:
  4013. display(QString("%1").
  4014. arg(number.setNum(temperature.temperature(),'f',2)));
  4015. break;
  4016. case Units::Rankine:
  4017. display(QString("%1'r").
  4018. arg(number.setNum(temperature.temperature(),'f',2)));
  4019. break;
  4020. case Units::Unitless:
  4021. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4022. break;
  4023. default:
  4024. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  4025. break;
  4026. }
  4027. break;
  4028. }
  4029. }
  4030. /*:359*//*360:*/
  4031. #line 8167 "./typica.w"
  4032. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  4033. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  4034. {
  4035. setSegmentStyle(Filled);
  4036. display("---.--'F");
  4037. }
  4038. /*:360*//*361:*/
  4039. #line 8183 "./typica.w"
  4040. void TemperatureDisplay::invalidate()
  4041. {
  4042. display("---.--'F");
  4043. }
  4044. /*:361*//*362:*/
  4045. #line 8195 "./typica.w"
  4046. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  4047. {
  4048. unit= scale;
  4049. }
  4050. /*:362*//*363:*/
  4051. #line 8203 "./typica.w"
  4052. TemperatureDisplay::~TemperatureDisplay()
  4053. {
  4054. }
  4055. /*:363*/
  4056. #line 544 "./typica.w"
  4057. /*369:*/
  4058. #line 8303 "./typica.w"
  4059. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  4060. {
  4061. if(measure.time()<epoch)
  4062. {
  4063. if(hasPrevious)
  4064. {
  4065. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  4066. epoch.msec());
  4067. QTime jitComp(epoch.hour(),measure.time().minute(),
  4068. measure.time().second(),measure.time().msec());
  4069. int relTime= jitBase.msecsTo(jitComp);
  4070. /*370:*/
  4071. #line 8337 "./typica.w"
  4072. QTime newTime(0,0,0,0);
  4073. newTime= newTime.addMSecs(relTime);
  4074. if(newTime.hour()> 0)
  4075. {
  4076. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4077. }
  4078. Measurement rel= measure;
  4079. rel.setTime(newTime);
  4080. emit measurement(rel);
  4081. /*:370*/
  4082. #line 8315 "./typica.w"
  4083. }
  4084. else
  4085. {
  4086. Measurement rel= measure;
  4087. rel.setTime(QTime(0,0,0,0));
  4088. emit measurement(rel);
  4089. }
  4090. }
  4091. else
  4092. {
  4093. int relTime= epoch.msecsTo(measure.time());
  4094. /*370:*/
  4095. #line 8337 "./typica.w"
  4096. QTime newTime(0,0,0,0);
  4097. newTime= newTime.addMSecs(relTime);
  4098. if(newTime.hour()> 0)
  4099. {
  4100. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4101. }
  4102. Measurement rel= measure;
  4103. rel.setTime(newTime);
  4104. emit measurement(rel);
  4105. /*:370*/
  4106. #line 8327 "./typica.w"
  4107. }
  4108. hasPrevious= true;
  4109. previous= measure.time();
  4110. }
  4111. /*:369*//*371:*/
  4112. #line 8350 "./typica.w"
  4113. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  4114. previous(0,0,0,0),hasPrevious(false)
  4115. {
  4116. }
  4117. QTime MeasurementTimeOffset::zeroTime()
  4118. {
  4119. return epoch;
  4120. }
  4121. void MeasurementTimeOffset::setZeroTime(QTime zero)
  4122. {
  4123. epoch= zero;
  4124. hasPrevious= false;
  4125. }
  4126. /*:371*/
  4127. #line 545 "./typica.w"
  4128. /*381:*/
  4129. #line 8558 "./typica.w"
  4130. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  4131. {
  4132. }
  4133. int ZeroEmitter::column()
  4134. {
  4135. return col;
  4136. }
  4137. double ZeroEmitter::lastTemperature()
  4138. {
  4139. return cache.temperature();
  4140. }
  4141. void ZeroEmitter::newMeasurement(Measurement measure)
  4142. {
  4143. cache= measure;
  4144. }
  4145. void ZeroEmitter::setColumn(int column)
  4146. {
  4147. col= column;
  4148. }
  4149. void ZeroEmitter::emitZero()
  4150. {
  4151. cache.setTime(QTime(0,0,0,0));
  4152. emit measurement(cache,col);
  4153. }
  4154. /*:381*/
  4155. #line 546 "./typica.w"
  4156. /*386:*/
  4157. #line 8648 "./typica.w"
  4158. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  4159. {
  4160. }
  4161. int MeasurementAdapter::column()
  4162. {
  4163. return col;
  4164. }
  4165. void MeasurementAdapter::newMeasurement(Measurement measure)
  4166. {
  4167. emit measurement(measure,col);
  4168. }
  4169. void MeasurementAdapter::setColumn(int column)
  4170. {
  4171. col= column;
  4172. }
  4173. /*:386*/
  4174. #line 547 "./typica.w"
  4175. /*391:*/
  4176. #line 8770 "./typica.w"
  4177. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4178. theScene(new QGraphicsScene),
  4179. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4180. prevPoints(new QMap<int,QPointF> ),
  4181. translations(new QMap<int,double> ),
  4182. gridLinesF(new QList<QGraphicsItem*> ),
  4183. gridLinesC(new QList<QGraphicsItem*> ),
  4184. relativeGridLines(new QList<QGraphicsItem*> ),
  4185. relativeEnabled(false),
  4186. timeIndicatorEnabled(false),
  4187. timeLine(new QGraphicsLineItem),
  4188. relativeAdjuster(new LinearSplineInterpolator)
  4189. {
  4190. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4191. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4192. setScene(theScene);
  4193. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4194. QPen timePen;
  4195. timePen.setColor(QColor(160,160,164,127));
  4196. timeLine->setPen(timePen);
  4197. timeLine->setLine(0,0,0,-500);
  4198. timeLine->hide();
  4199. theScene->addItem(timeLine);
  4200. /*392:*/
  4201. #line 8810 "./typica.w"
  4202. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4203. tempaxis->setLine(-10,-500,-10,0);
  4204. theScene->addItem(tempaxis);
  4205. QGraphicsLineItem*gridLine;
  4206. QGraphicsTextItem*label;
  4207. for(int y= -100;y> -600;y-= 100)
  4208. {
  4209. gridLine= new QGraphicsLineItem;
  4210. gridLine->setLine(0,y,1200,y);
  4211. theScene->addItem(gridLine);
  4212. label= new QGraphicsTextItem;
  4213. label->setHtml(QString("%1&deg;F").arg(-y));
  4214. label->setPos(-55,y-(label->boundingRect().height()/2));
  4215. theScene->addItem(label);
  4216. gridLinesF->append(gridLine);
  4217. gridLinesF->append(label);
  4218. }
  4219. for(int degC= 50;degC<=250;degC+= 50)
  4220. {
  4221. gridLine= new QGraphicsLineItem;
  4222. int y= -(degC*(9.0/5.0)+32);
  4223. gridLine->setLine(0,y,1200,y);
  4224. gridLine->hide();
  4225. theScene->addItem(gridLine);
  4226. gridLinesC->append(gridLine);
  4227. label= new QGraphicsTextItem;
  4228. label->setHtml(QString("%1&deg;C").arg(degC));
  4229. label->setPos(-55,y-(label->boundingRect().height()/2));
  4230. label->hide();
  4231. theScene->addItem(label);
  4232. gridLinesC->append(label);
  4233. }
  4234. /*:392*/
  4235. #line 8794 "./typica.w"
  4236. ;
  4237. /*393:*/
  4238. #line 8851 "./typica.w"
  4239. QSettings settings;
  4240. if(settings.contains("settings/graph/relative/enable"))
  4241. {
  4242. if(settings.value("settings/graph/relative/enable").toBool())
  4243. {
  4244. relativeEnabled= true;
  4245. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4246. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4247. QMap<double,QString> relativeAxisPairs;
  4248. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4249. foreach(QString item,relativeAxisLabels)
  4250. {
  4251. relativeAxisPairs.insert(item.toDouble(),item);
  4252. }
  4253. if(relativeAxisPairs.size()> 1)
  4254. {
  4255. double skip= 500.0/(relativeAxisPairs.size()-1);
  4256. double y= 0;
  4257. foreach(double key,relativeAxisPairs.keys())
  4258. {
  4259. gridLine= new QGraphicsLineItem;
  4260. gridLine->setLine(0,y,1205,y);
  4261. gridLine->setPen(QPen(relativeColor));
  4262. theScene->addItem(gridLine);
  4263. relativeGridLines->append(gridLine);
  4264. label= new QGraphicsTextItem;
  4265. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4266. label->setPos(1210,y-(label->boundingRect().height()/2));
  4267. theScene->addItem(label);
  4268. relativeGridLines->append(label);
  4269. if(unit=="F")
  4270. {
  4271. relativeAdjuster->add_pair(key,-y);
  4272. }
  4273. else
  4274. {
  4275. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4276. }
  4277. y-= skip;
  4278. }
  4279. }
  4280. }
  4281. }
  4282. /*:393*/
  4283. #line 8795 "./typica.w"
  4284. /*395:*/
  4285. #line 8928 "./typica.w"
  4286. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4287. timeaxis->setLine(0,10,1200,10);
  4288. theScene->addItem(timeaxis);
  4289. for(int x= 0;x<1201;x+= 120)
  4290. {
  4291. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4292. tick->setLine(x,0,x,20);
  4293. theScene->addItem(tick);
  4294. QGraphicsTextItem*label= new QGraphicsTextItem;
  4295. label->setPlainText(QString("%1").arg(x/60));
  4296. label->setPos(x-(label->boundingRect().width()/2),20);
  4297. theScene->addItem(label);
  4298. }
  4299. /*:395*/
  4300. #line 8796 "./typica.w"
  4301. ;
  4302. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4303. }
  4304. /*:391*//*394:*/
  4305. #line 8898 "./typica.w"
  4306. void GraphView::showF()
  4307. {
  4308. for(int i= 0;i<gridLinesF->size();i++)
  4309. {
  4310. gridLinesF->at(i)->show();
  4311. }
  4312. for(int i= 0;i<gridLinesC->size();i++)
  4313. {
  4314. gridLinesC->at(i)->hide();
  4315. }
  4316. }
  4317. void GraphView::showC()
  4318. {
  4319. for(int i= 0;i<gridLinesF->size();i++)
  4320. {
  4321. gridLinesF->at(i)->hide();
  4322. }
  4323. for(int i= 0;i<gridLinesC->size();i++)
  4324. {
  4325. gridLinesC->at(i)->show();
  4326. }
  4327. }
  4328. /*:394*//*396:*/
  4329. #line 8947 "./typica.w"
  4330. void GraphView::resizeEvent(QResizeEvent*)
  4331. {
  4332. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4333. }
  4334. /*:396*//*397:*/
  4335. #line 8961 "./typica.w"
  4336. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4337. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4338. {
  4339. double offset= 0;
  4340. if(measure.contains("relative"))
  4341. {
  4342. if(measure.value("relative").toBool())
  4343. {
  4344. if(relativeEnabled)
  4345. {
  4346. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4347. }
  4348. else
  4349. {
  4350. return;
  4351. }
  4352. }
  4353. }
  4354. if(translations->contains(tempcolumn))
  4355. {
  4356. offset= translations->value(tempcolumn);
  4357. }
  4358. if(prevPoints->contains(tempcolumn))
  4359. {
  4360. /*399:*/
  4361. #line 9038 "./typica.w"
  4362. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4363. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4364. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4365. -(prevPoints->value(tempcolumn).y()),
  4366. nextPoint.x()+offset,-(nextPoint.y()));
  4367. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4368. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4369. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4370. Qt::darkYellow};
  4371. segment->setPen(p[tempcolumn%12]);
  4372. theScene->addItem(segment);
  4373. prevPoints->insert(tempcolumn,nextPoint);
  4374. if(timeIndicatorEnabled)
  4375. {
  4376. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4377. }
  4378. /*:399*/
  4379. #line 8987 "./typica.w"
  4380. if(graphLines->contains(tempcolumn))
  4381. {
  4382. graphLines->value(tempcolumn)->append(segment);
  4383. }
  4384. else
  4385. {
  4386. QList<QGraphicsLineItem*> *newLine=
  4387. new QList<QGraphicsLineItem*> ;
  4388. newLine->append(segment);
  4389. graphLines->insert(tempcolumn,newLine);
  4390. }
  4391. }
  4392. else
  4393. {
  4394. /*398:*/
  4395. #line 9023 "./typica.w"
  4396. int x= FULLTIMETOINT(measure.time())/1000;
  4397. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4398. if(timeIndicatorEnabled)
  4399. {
  4400. timeLine->setLine(x,0,x,-500);
  4401. }
  4402. /*:398*/
  4403. #line 9004 "./typica.w"
  4404. }
  4405. }
  4406. /*:397*//*400:*/
  4407. #line 9059 "./typica.w"
  4408. void GraphView::clear()
  4409. {
  4410. int i;
  4411. foreach(i,prevPoints->keys())
  4412. {
  4413. removeSeries(i);
  4414. }
  4415. translations->clear();
  4416. }
  4417. /*:400*//*401:*/
  4418. #line 9073 "./typica.w"
  4419. void GraphView::removeSeries(int column)
  4420. {
  4421. if(graphLines->contains(column))
  4422. {
  4423. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4424. QGraphicsLineItem*segment;
  4425. foreach(segment,*series)
  4426. {
  4427. theScene->removeItem(segment);
  4428. }
  4429. qDeleteAll(*series);
  4430. }
  4431. graphLines->remove(column);
  4432. prevPoints->remove(column);
  4433. }
  4434. /*:401*//*402:*/
  4435. #line 9092 "./typica.w"
  4436. void GraphView::setSeriesTranslation(int column,double offset)
  4437. {
  4438. if(graphLines->contains(column))
  4439. {
  4440. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4441. QGraphicsLineItem*segment;
  4442. foreach(segment,*series)
  4443. {
  4444. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4445. }
  4446. }
  4447. if(translations->contains(column))
  4448. {
  4449. translations->insert(column,offset+translations->value(column));
  4450. }
  4451. else
  4452. {
  4453. translations->insert(column,offset);
  4454. }
  4455. }
  4456. /*:402*//*403:*/
  4457. #line 9119 "./typica.w"
  4458. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4459. {
  4460. timeIndicatorEnabled= enabled;
  4461. if(enabled)
  4462. {
  4463. timeLine->show();
  4464. }
  4465. else
  4466. {
  4467. timeLine->hide();
  4468. }
  4469. }
  4470. /*:403*/
  4471. #line 548 "./typica.w"
  4472. /*409:*/
  4473. #line 9266 "./typica.w"
  4474. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4475. {
  4476. if(measure.time()!=QTime(0,0,0,0))
  4477. {
  4478. /*411:*/
  4479. #line 9340 "./typica.w"
  4480. if(lastMeasurement.contains(tempcolumn))
  4481. {
  4482. if(lastMeasurement[tempcolumn].time()<measure.time())
  4483. {
  4484. QList<QTime> timelist;
  4485. QList<double> templist;
  4486. QTime z= QTime(0,0,0,0);
  4487. double ptime= (double)(z.secsTo(lastMeasurement[tempcolumn].time()));
  4488. double ptemp= lastMeasurement[tempcolumn].temperature();
  4489. double ctime= (double)(z.secsTo(measure.time()));
  4490. double ctemp= measure.temperature();
  4491. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4492. {
  4493. timelist.append(i);
  4494. double v= ((ptemp*(ctime-z.secsTo(i)))+(ctemp*(z.secsTo(i)-ptime)))/(ctime-ptime);
  4495. templist.append(v);
  4496. }
  4497. for(int i= 0;i<timelist.size();i++)
  4498. {
  4499. Measurement synthesized= measure;
  4500. synthesized.setTime(timelist[i]);
  4501. synthesized.setTemperature(templist[i]);
  4502. newMeasurement(synthesized,tempcolumn);
  4503. }
  4504. }
  4505. }
  4506. /*:411*/
  4507. #line 9271 "./typica.w"
  4508. }
  4509. model_ms->newMeasurement(measure,tempcolumn);
  4510. if(lastMeasurement.contains(tempcolumn))
  4511. {
  4512. if(measure.time().second()!=
  4513. lastMeasurement.value(tempcolumn).time().second())
  4514. {
  4515. Measurement adjusted= measure;
  4516. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4517. adjusted.setTime(adjtime);
  4518. model_1s->newMeasurement(adjusted,tempcolumn);
  4519. if(adjusted.time().second()%5==0)
  4520. {
  4521. model_5s->newMeasurement(adjusted,tempcolumn);
  4522. if(adjusted.time().second()%10==0)
  4523. {
  4524. model_10s->newMeasurement(adjusted,tempcolumn);
  4525. }
  4526. if(adjusted.time().second()%15==0)
  4527. {
  4528. model_15s->newMeasurement(adjusted,tempcolumn);
  4529. if(adjusted.time().second()%30==0)
  4530. {
  4531. model_30s->newMeasurement(adjusted,tempcolumn);
  4532. if(adjusted.time().second()==0)
  4533. {
  4534. model_1m->newMeasurement(adjusted,tempcolumn);
  4535. }
  4536. }
  4537. }
  4538. }
  4539. }
  4540. /*413:*/
  4541. #line 9393 "./typica.w"
  4542. if(currentColumnSet.contains(tempcolumn))
  4543. {
  4544. int replicationcolumn;
  4545. foreach(replicationcolumn,currentColumnSet)
  4546. {
  4547. if(replicationcolumn!=tempcolumn)
  4548. {
  4549. if(lastMeasurement.contains(replicationcolumn))
  4550. {
  4551. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4552. {
  4553. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4554. synthetic.setTime(measure.time());
  4555. model_ms->newMeasurement(synthetic,replicationcolumn);
  4556. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4557. {
  4558. Measurement adjusted= synthetic;
  4559. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4560. model_1s->newMeasurement(adjusted,replicationcolumn);
  4561. if(adjusted.time().second()%5==0)
  4562. {
  4563. model_5s->newMeasurement(adjusted,replicationcolumn);
  4564. if(adjusted.time().second()%10==0)
  4565. {
  4566. model_10s->newMeasurement(adjusted,replicationcolumn);
  4567. }
  4568. if(adjusted.time().second()%15==0)
  4569. {
  4570. model_15s->newMeasurement(adjusted,replicationcolumn);
  4571. if(adjusted.time().second()%30==0)
  4572. {
  4573. model_30s->newMeasurement(adjusted,replicationcolumn);
  4574. if(adjusted.time().second()==0)
  4575. {
  4576. model_1m->newMeasurement(adjusted,replicationcolumn);
  4577. }
  4578. }
  4579. }
  4580. }
  4581. }
  4582. lastMeasurement[replicationcolumn]= synthetic;
  4583. }
  4584. }
  4585. }
  4586. }
  4587. }
  4588. /*:413*/
  4589. #line 9304 "./typica.w"
  4590. }
  4591. else
  4592. {
  4593. /*410:*/
  4594. #line 9316 "./typica.w"
  4595. MeasurementModel*m;
  4596. foreach(m,modelSet)
  4597. {
  4598. m->newMeasurement(measure,tempcolumn);
  4599. }
  4600. /*:410*/
  4601. #line 9308 "./typica.w"
  4602. }
  4603. lastMeasurement.insert(tempcolumn,measure);
  4604. }
  4605. /*:409*//*412:*/
  4606. #line 9379 "./typica.w"
  4607. void ZoomLog::addToCurrentColumnSet(int column)
  4608. {
  4609. currentColumnSet.append(column);
  4610. }
  4611. void ZoomLog::clearCurrentColumnSet()
  4612. {
  4613. currentColumnSet.clear();
  4614. }
  4615. /*:412*//*414:*/
  4616. #line 9463 "./typica.w"
  4617. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4618. int annotationcolumn)
  4619. {
  4620. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4621. MeasurementModel*m;
  4622. if(lastMeasurement.contains(tempcolumn))
  4623. {
  4624. foreach(m,modelSet)
  4625. {
  4626. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4627. }
  4628. }
  4629. foreach(m,modelSet)
  4630. {
  4631. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4632. }
  4633. }
  4634. /*:414*//*415:*/
  4635. #line 9487 "./typica.w"
  4636. void ZoomLog::centerOn(int row)
  4637. {
  4638. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4639. }
  4640. /*:415*//*416:*/
  4641. #line 9497 "./typica.w"
  4642. void ZoomLog::clear()
  4643. {
  4644. MeasurementModel*m;
  4645. foreach(m,modelSet)
  4646. {
  4647. m->clear();
  4648. }
  4649. lastMeasurement.clear();
  4650. saveTempCols.clear();
  4651. saveControlCols.clear();
  4652. saveNoteCols.clear();
  4653. }
  4654. /*:416*//*417:*/
  4655. #line 9515 "./typica.w"
  4656. QVariant ZoomLog::data(int row,int column)const
  4657. {
  4658. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4659. Qt::DisplayRole);
  4660. }
  4661. int ZoomLog::rowCount()
  4662. {
  4663. return model_ms->rowCount();
  4664. }
  4665. /*:417*//*418:*/
  4666. #line 9538 "./typica.w"
  4667. bool ZoomLog::saveXML(QIODevice*device)
  4668. {
  4669. Units::Unit prevUnits= model_ms->displayUnits();
  4670. if(prevUnits!=Units::Fahrenheit)
  4671. {
  4672. model_ms->setDisplayUnits(Units::Fahrenheit);
  4673. }
  4674. XMLOutput writer(model_ms,device,0);
  4675. int c;
  4676. foreach(c,saveTempCols)
  4677. {
  4678. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4679. toString(),c);
  4680. }
  4681. foreach(c,saveControlCols)
  4682. {
  4683. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4684. toString(),c);
  4685. }
  4686. foreach(c,saveNoteCols)
  4687. {
  4688. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4689. toString(),c);
  4690. }
  4691. bool retval= writer.output();
  4692. if(prevUnits!=Units::Fahrenheit)
  4693. {
  4694. model_ms->setDisplayUnits(prevUnits);
  4695. }
  4696. return retval;
  4697. }
  4698. /*:418*//*419:*/
  4699. #line 9574 "./typica.w"
  4700. bool ZoomLog::saveCSV(QIODevice*device)
  4701. {
  4702. CSVOutput writer(currentModel,device,0);
  4703. int c;
  4704. foreach(c,saveTempCols)
  4705. {
  4706. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4707. toString(),c);
  4708. }
  4709. foreach(c,saveControlCols)
  4710. {
  4711. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4712. toString(),c);
  4713. }
  4714. foreach(c,saveNoteCols)
  4715. {
  4716. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4717. toString(),c);
  4718. }
  4719. return writer.output();
  4720. }
  4721. /*:419*//*420:*/
  4722. #line 9603 "./typica.w"
  4723. void ZoomLog::switchLOD(MeasurementModel*m)
  4724. {
  4725. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4726. setModel(m);
  4727. currentModel= m;
  4728. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4729. }
  4730. void ZoomLog::LOD_ms()
  4731. {
  4732. switchLOD(model_ms);
  4733. }
  4734. void ZoomLog::LOD_1s()
  4735. {
  4736. switchLOD(model_1s);
  4737. }
  4738. void ZoomLog::LOD_5s()
  4739. {
  4740. switchLOD(model_5s);
  4741. }
  4742. void ZoomLog::LOD_10s()
  4743. {
  4744. switchLOD(model_10s);
  4745. }
  4746. void ZoomLog::LOD_15s()
  4747. {
  4748. switchLOD(model_15s);
  4749. }
  4750. void ZoomLog::LOD_30s()
  4751. {
  4752. switchLOD(model_30s);
  4753. }
  4754. void ZoomLog::LOD_1m()
  4755. {
  4756. switchLOD(model_1m);
  4757. }
  4758. /*:420*//*421:*/
  4759. #line 9651 "./typica.w"
  4760. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4761. {
  4762. model_ms->setDisplayUnits(scale);
  4763. model_1s->setDisplayUnits(scale);
  4764. model_5s->setDisplayUnits(scale);
  4765. model_10s->setDisplayUnits(scale);
  4766. model_15s->setDisplayUnits(scale);
  4767. model_30s->setDisplayUnits(scale);
  4768. model_1m->setDisplayUnits(scale);
  4769. }
  4770. Units::Unit ZoomLog::displayUnits()
  4771. {
  4772. return model_ms->displayUnits();
  4773. }
  4774. /*:421*//*422:*/
  4775. #line 9671 "./typica.w"
  4776. QString ZoomLog::lastTime(int series)
  4777. {
  4778. Measurement measure= lastMeasurement.value(series);
  4779. QTime time= measure.time();
  4780. return time.toString("h:mm:ss.zzz");
  4781. }
  4782. /*:422*//*423:*/
  4783. #line 9681 "./typica.w"
  4784. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4785. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4786. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4787. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4788. {
  4789. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4790. setSelectionMode(QAbstractItemView::NoSelection);
  4791. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4792. model_30s<<model_1m;
  4793. currentModel= model_30s;
  4794. setModel(currentModel);
  4795. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4796. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4797. this,SLOT(persistColumnResize(int,int,int)));
  4798. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4799. this,SLOT(restoreColumnWidths()));
  4800. }
  4801. /*:423*//*424:*/
  4802. #line 9704 "./typica.w"
  4803. void ZoomLog::setHeaderData(int section,QString text)
  4804. {
  4805. MeasurementModel*m;
  4806. foreach(m,modelSet)
  4807. {
  4808. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4809. }
  4810. }
  4811. /*:424*//*425:*/
  4812. #line 9722 "./typica.w"
  4813. void ZoomLog::addOutputTemperatureColumn(int column)
  4814. {
  4815. saveTempCols.append(column);
  4816. }
  4817. void ZoomLog::addOutputControlColumn(int column)
  4818. {
  4819. saveControlCols.append(column);
  4820. }
  4821. void ZoomLog::addOutputAnnotationColumn(int column)
  4822. {
  4823. saveNoteCols.append(column);
  4824. }
  4825. void ZoomLog::clearOutputColumns()
  4826. {
  4827. saveTempCols.clear();
  4828. saveControlCols.clear();
  4829. saveNoteCols.clear();
  4830. }
  4831. /*:425*//*426:*/
  4832. #line 9748 "./typica.w"
  4833. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4834. {
  4835. /*652:*/
  4836. #line 13928 "./typica.w"
  4837. QSettings settings;
  4838. /*653:*/
  4839. #line 13941 "./typica.w"
  4840. QWidget*topLevelWidget= this;
  4841. while(topLevelWidget->parentWidget())
  4842. {
  4843. topLevelWidget= topLevelWidget->parentWidget();
  4844. }
  4845. /*:653*/
  4846. #line 13930 "./typica.w"
  4847. settings.setValue(QString("columnWidths/%1/%2/%3").
  4848. arg(topLevelWidget->objectName()).
  4849. arg(objectName()).arg(column),
  4850. QVariant(newsize));
  4851. /*:652*/
  4852. #line 9751 "./typica.w"
  4853. }
  4854. void ZoomLog::restoreColumnWidths()
  4855. {
  4856. /*655:*/
  4857. #line 13961 "./typica.w"
  4858. QSettings settings;
  4859. /*653:*/
  4860. #line 13941 "./typica.w"
  4861. QWidget*topLevelWidget= this;
  4862. while(topLevelWidget->parentWidget())
  4863. {
  4864. topLevelWidget= topLevelWidget->parentWidget();
  4865. }
  4866. /*:653*/
  4867. #line 13963 "./typica.w"
  4868. QString baseKey=
  4869. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4870. arg(objectName());
  4871. for(int i= 0;i<model()->columnCount();i++)
  4872. {
  4873. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4874. if(settings.contains(key))
  4875. {
  4876. setColumnWidth(i,settings.value(key).toInt());
  4877. }
  4878. }
  4879. /*:655*/
  4880. #line 9756 "./typica.w"
  4881. }
  4882. void ZoomLog::setVisible(bool visibility)
  4883. {
  4884. QTableView::setVisible(visibility);
  4885. }
  4886. void ZoomLog::showEvent(QShowEvent*)
  4887. {
  4888. /*655:*/
  4889. #line 13961 "./typica.w"
  4890. QSettings settings;
  4891. /*653:*/
  4892. #line 13941 "./typica.w"
  4893. QWidget*topLevelWidget= this;
  4894. while(topLevelWidget->parentWidget())
  4895. {
  4896. topLevelWidget= topLevelWidget->parentWidget();
  4897. }
  4898. /*:653*/
  4899. #line 13963 "./typica.w"
  4900. QString baseKey=
  4901. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4902. arg(objectName());
  4903. for(int i= 0;i<model()->columnCount();i++)
  4904. {
  4905. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4906. if(settings.contains(key))
  4907. {
  4908. setColumnWidth(i,settings.value(key).toInt());
  4909. }
  4910. }
  4911. /*:655*/
  4912. #line 9766 "./typica.w"
  4913. }
  4914. /*:426*/
  4915. #line 549 "./typica.w"
  4916. /*435:*/
  4917. #line 9999 "./typica.w"
  4918. bool MeasurementList::operator<(const MeasurementList&other)const
  4919. {
  4920. return this->first().toTime()<other.first().toTime();
  4921. }
  4922. bool MeasurementList::operator==(const MeasurementList&other)const
  4923. {
  4924. return this->first().toTime()==other.first().toTime();
  4925. }
  4926. /*:435*//*436:*/
  4927. #line 10015 "./typica.w"
  4928. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4929. {
  4930. return QModelIndex();
  4931. }
  4932. /*:436*//*437:*/
  4933. #line 10025 "./typica.w"
  4934. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4935. {
  4936. if(measure.scale()==Units::Unitless)
  4937. {
  4938. controlColumns->insert(tempcolumn,true);
  4939. }
  4940. else
  4941. {
  4942. controlColumns->insert(tempcolumn,false);
  4943. }
  4944. MeasurementList*temp;
  4945. temp= new MeasurementList;
  4946. temp->append(QVariant(measure.time()));
  4947. /*438:*/
  4948. #line 10084 "./typica.w"
  4949. /*439:*/
  4950. #line 10129 "./typica.w"
  4951. QList<MeasurementList*> ::iterator i= lastInsertion;
  4952. bool quickscan= false;
  4953. if(entries->size()> 5)
  4954. {
  4955. if(**i<*temp)
  4956. {
  4957. i+= 1;
  4958. for(int j= 10;j> 0;j--)
  4959. {
  4960. if(i!=entries->end())
  4961. {
  4962. if(**i<*temp)
  4963. {
  4964. i+= 1;
  4965. }
  4966. else
  4967. {
  4968. quickscan= true;
  4969. break;
  4970. }
  4971. }
  4972. else
  4973. {
  4974. quickscan= true;
  4975. break;
  4976. }
  4977. }
  4978. }
  4979. else
  4980. {
  4981. if(**i==*temp)
  4982. {
  4983. quickscan= true;
  4984. }
  4985. }
  4986. }
  4987. /*:439*/
  4988. #line 10085 "./typica.w"
  4989. if(quickscan==false)
  4990. {
  4991. i= entries->begin();
  4992. QList<MeasurementList*> ::iterator u= entries->end();
  4993. QList<MeasurementList*> ::iterator midpoint;
  4994. int n= u-i;
  4995. int rA;
  4996. while(n> 0)
  4997. {
  4998. rA= n>>1;
  4999. midpoint= i+rA;
  5000. if(**midpoint<*temp)
  5001. {
  5002. i= midpoint+1;
  5003. n-= rA+1;
  5004. }
  5005. else
  5006. {
  5007. n= rA;
  5008. }
  5009. }
  5010. }
  5011. /*:438*/
  5012. #line 10039 "./typica.w"
  5013. MeasurementList*newEntry;
  5014. int insertion;
  5015. if(i!=entries->end())
  5016. {
  5017. insertion= entries->indexOf(*i);
  5018. if((*i)->first().toTime()==measure.time())
  5019. {
  5020. /*440:*/
  5021. #line 10171 "./typica.w"
  5022. if((*i)->size()<tempcolumn+1)
  5023. {
  5024. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  5025. {
  5026. (*i)->append(QVariant());
  5027. }
  5028. }
  5029. (*i)->replace(tempcolumn,measure);
  5030. lastInsertion= i;
  5031. emit dataChanged(createIndex(insertion,tempcolumn),
  5032. createIndex(insertion,tempcolumn));
  5033. lastTemperature->insert(tempcolumn,insertion);
  5034. /*:440*/
  5035. #line 10047 "./typica.w"
  5036. }
  5037. else
  5038. {
  5039. /*441:*/
  5040. #line 10189 "./typica.w"
  5041. beginInsertRows(QModelIndex(),insertion,insertion);
  5042. newEntry= new MeasurementList;
  5043. newEntry->append(QVariant(measure.time()));
  5044. for(int j= 0;j<tempcolumn+1;j++)
  5045. {
  5046. newEntry->append(QVariant());
  5047. }
  5048. newEntry->replace(tempcolumn,measure);
  5049. lastInsertion= entries->insert(i,newEntry);
  5050. endInsertRows();
  5051. lastTemperature->insert(tempcolumn,insertion);
  5052. /*:441*/
  5053. #line 10051 "./typica.w"
  5054. }
  5055. }
  5056. else
  5057. {
  5058. /*442:*/
  5059. #line 10207 "./typica.w"
  5060. insertion= entries->size();
  5061. /*441:*/
  5062. #line 10189 "./typica.w"
  5063. beginInsertRows(QModelIndex(),insertion,insertion);
  5064. newEntry= new MeasurementList;
  5065. newEntry->append(QVariant(measure.time()));
  5066. for(int j= 0;j<tempcolumn+1;j++)
  5067. {
  5068. newEntry->append(QVariant());
  5069. }
  5070. newEntry->replace(tempcolumn,measure);
  5071. lastInsertion= entries->insert(i,newEntry);
  5072. endInsertRows();
  5073. lastTemperature->insert(tempcolumn,insertion);
  5074. /*:441*/
  5075. #line 10209 "./typica.w"
  5076. /*:442*/
  5077. #line 10056 "./typica.w"
  5078. }
  5079. if(tempcolumn>=colcount)
  5080. {
  5081. colcount= tempcolumn+1;
  5082. }
  5083. emit rowChanged(insertion);
  5084. delete temp;
  5085. }
  5086. /*:437*//*443:*/
  5087. #line 10219 "./typica.w"
  5088. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  5089. int annotationColumn)
  5090. {
  5091. int r;
  5092. if(lastTemperature->contains(tempcolumn))
  5093. {
  5094. r= lastTemperature->value(tempcolumn);
  5095. }
  5096. else
  5097. {
  5098. r= 0;
  5099. }
  5100. if(r==0&&entries->size()==0)
  5101. {
  5102. /*444:*/
  5103. #line 10257 "./typica.w"
  5104. beginInsertRows(QModelIndex(),0,0);
  5105. MeasurementList*newEntry= new MeasurementList;
  5106. newEntry->append(QVariant(QTime(0,0,0,0)));
  5107. entries->append(newEntry);
  5108. endInsertRows();
  5109. /*:444*/
  5110. #line 10234 "./typica.w"
  5111. }
  5112. MeasurementList*row= entries->at(r);
  5113. if(row->size()<=annotationColumn)
  5114. {
  5115. for(int i= row->size()-1;i<annotationColumn+1;i++)
  5116. {
  5117. row->append(QVariant());
  5118. }
  5119. }
  5120. row->replace(annotationColumn,annotation);
  5121. emit dataChanged(createIndex(r,annotationColumn),
  5122. createIndex(r,annotationColumn));
  5123. emit rowChanged(r);
  5124. if(annotationColumn> colcount-1)
  5125. {
  5126. colcount= annotationColumn+1;
  5127. }
  5128. }
  5129. /*:443*//*445:*/
  5130. #line 10268 "./typica.w"
  5131. void MeasurementModel::clear()
  5132. {
  5133. beginRemoveRows(QModelIndex(),0,entries->size());
  5134. while(entries->size()!=0)
  5135. {
  5136. MeasurementList*row= entries->takeFirst();
  5137. delete row;
  5138. }
  5139. endRemoveRows();
  5140. colcount= hData->size();
  5141. lastTemperature->clear();
  5142. reset();
  5143. }
  5144. /*:445*//*446:*/
  5145. #line 10301 "./typica.w"
  5146. bool MeasurementModel::setData(const QModelIndex&index,
  5147. const QVariant&value,int role)
  5148. {
  5149. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  5150. {
  5151. return false;
  5152. }
  5153. /*447:*/
  5154. #line 10333 "./typica.w"
  5155. bool valid= false;
  5156. if(index.isValid())
  5157. {
  5158. if(index.row()<entries->size())
  5159. {
  5160. if(index.column()<colcount)
  5161. {
  5162. valid= true;
  5163. }
  5164. }
  5165. }
  5166. /*:447*/
  5167. #line 10309 "./typica.w"
  5168. if(!valid)
  5169. {
  5170. return false;
  5171. }
  5172. MeasurementList*row= entries->at(index.row());
  5173. if(index.column()>=row->size())
  5174. {
  5175. /*448:*/
  5176. #line 10350 "./typica.w"
  5177. for(int i= row->size()-1;i<index.column();i++)
  5178. {
  5179. row->append(QVariant());
  5180. }
  5181. /*:448*/
  5182. #line 10317 "./typica.w"
  5183. }
  5184. if(index.column()==0)
  5185. {
  5186. /*449:*/
  5187. #line 10365 "./typica.w"
  5188. QTime time;
  5189. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5190. {
  5191. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5192. {
  5193. return false;
  5194. }
  5195. }
  5196. row= entries->takeAt(index.row());
  5197. row->replace(index.column(),QVariant(time));
  5198. MeasurementList*temp= row;
  5199. /*438:*/
  5200. #line 10084 "./typica.w"
  5201. /*439:*/
  5202. #line 10129 "./typica.w"
  5203. QList<MeasurementList*> ::iterator i= lastInsertion;
  5204. bool quickscan= false;
  5205. if(entries->size()> 5)
  5206. {
  5207. if(**i<*temp)
  5208. {
  5209. i+= 1;
  5210. for(int j= 10;j> 0;j--)
  5211. {
  5212. if(i!=entries->end())
  5213. {
  5214. if(**i<*temp)
  5215. {
  5216. i+= 1;
  5217. }
  5218. else
  5219. {
  5220. quickscan= true;
  5221. break;
  5222. }
  5223. }
  5224. else
  5225. {
  5226. quickscan= true;
  5227. break;
  5228. }
  5229. }
  5230. }
  5231. else
  5232. {
  5233. if(**i==*temp)
  5234. {
  5235. quickscan= true;
  5236. }
  5237. }
  5238. }
  5239. /*:439*/
  5240. #line 10085 "./typica.w"
  5241. if(quickscan==false)
  5242. {
  5243. i= entries->begin();
  5244. QList<MeasurementList*> ::iterator u= entries->end();
  5245. QList<MeasurementList*> ::iterator midpoint;
  5246. int n= u-i;
  5247. int rA;
  5248. while(n> 0)
  5249. {
  5250. rA= n>>1;
  5251. midpoint= i+rA;
  5252. if(**midpoint<*temp)
  5253. {
  5254. i= midpoint+1;
  5255. n-= rA+1;
  5256. }
  5257. else
  5258. {
  5259. n= rA;
  5260. }
  5261. }
  5262. }
  5263. /*:438*/
  5264. #line 10377 "./typica.w"
  5265. entries->insert(i,row);
  5266. int newRow= entries->indexOf(*i);
  5267. if(newRow<index.row())
  5268. {
  5269. emit dataChanged(createIndex(newRow,index.column()),index);
  5270. }
  5271. else
  5272. {
  5273. emit dataChanged(index,createIndex(newRow,index.column()));
  5274. }
  5275. /*:449*/
  5276. #line 10321 "./typica.w"
  5277. }
  5278. else
  5279. {
  5280. /*450:*/
  5281. #line 10391 "./typica.w"
  5282. row->replace(index.column(),value);
  5283. emit dataChanged(index,index);
  5284. /*:450*/
  5285. #line 10325 "./typica.w"
  5286. }
  5287. return true;
  5288. }
  5289. /*:446*//*451:*/
  5290. #line 10399 "./typica.w"
  5291. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5292. unit(Units::Fahrenheit),hData(new QStringList),
  5293. lastTemperature(new QHash<int,int> ),
  5294. controlColumns(new QHash<int,bool> )
  5295. {
  5296. colcount= 1;
  5297. entries= new QList<MeasurementList*> ;
  5298. lastInsertion= entries->begin();
  5299. hData->append(tr("Time"));
  5300. }
  5301. /*:451*//*452:*/
  5302. #line 10413 "./typica.w"
  5303. MeasurementModel::~MeasurementModel()
  5304. {
  5305. clear();
  5306. delete entries;
  5307. delete hData;
  5308. }
  5309. /*:452*//*453:*/
  5310. #line 10425 "./typica.w"
  5311. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5312. {
  5313. if(parent==QModelIndex())
  5314. {
  5315. return entries->size();
  5316. }
  5317. return 0;
  5318. }
  5319. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5320. {
  5321. if(parent==QModelIndex())
  5322. {
  5323. return colcount;
  5324. }
  5325. return 0;
  5326. }
  5327. /*:453*//*454:*/
  5328. #line 10452 "./typica.w"
  5329. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5330. const QVariant&value,int)
  5331. {
  5332. if(orientation==Qt::Horizontal)
  5333. {
  5334. if(hData->size()<section+1)
  5335. {
  5336. for(int i= hData->size();i<section+1;i++)
  5337. {
  5338. if(colcount<i)
  5339. {
  5340. beginInsertColumns(QModelIndex(),i,i);
  5341. }
  5342. hData->append(QString());
  5343. if(colcount<i)
  5344. {
  5345. endInsertColumns();
  5346. }
  5347. }
  5348. }
  5349. hData->replace(section,value.toString());
  5350. emit headerDataChanged(orientation,section,section);
  5351. if(colcount<section+1)
  5352. {
  5353. colcount= section+1;
  5354. }
  5355. return true;
  5356. }
  5357. return false;
  5358. }
  5359. /*:454*//*455:*/
  5360. #line 10492 "./typica.w"
  5361. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5362. {
  5363. beginResetModel();
  5364. unit= scale;
  5365. endResetModel();
  5366. }
  5367. Units::Unit MeasurementModel::displayUnits()
  5368. {
  5369. return unit;
  5370. }
  5371. /*:455*//*456:*/
  5372. #line 10518 "./typica.w"
  5373. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5374. {
  5375. /*447:*/
  5376. #line 10333 "./typica.w"
  5377. bool valid= false;
  5378. if(index.isValid())
  5379. {
  5380. if(index.row()<entries->size())
  5381. {
  5382. if(index.column()<colcount)
  5383. {
  5384. valid= true;
  5385. }
  5386. }
  5387. }
  5388. /*:447*/
  5389. #line 10521 "./typica.w"
  5390. if(!valid)
  5391. {
  5392. return QVariant();
  5393. }
  5394. MeasurementList*row= entries->at(index.row());
  5395. if(role==Qt::UserRole)
  5396. {
  5397. return QVariant(row->at(index.column()));
  5398. }
  5399. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5400. {
  5401. if(index.column()> row->size())
  5402. {
  5403. return QVariant();
  5404. }
  5405. else
  5406. {
  5407. if(index.column()==0)
  5408. {
  5409. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5410. }
  5411. else if(lastTemperature->contains(index.column()))
  5412. {
  5413. QVariantMap v= row->at(index.column()).toMap();
  5414. if(!v.contains("measurement"))
  5415. {
  5416. return QVariant();
  5417. }
  5418. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5419. {
  5420. return v.value("measurement");
  5421. }
  5422. else
  5423. {
  5424. if(v.contains("relative"))
  5425. {
  5426. if(v.value("relative").toBool())
  5427. {
  5428. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5429. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5430. }
  5431. }
  5432. return QVariant(QString("%1").
  5433. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5434. (Units::Unit)(v.value("unit").toInt()),unit)));
  5435. }
  5436. }
  5437. return QVariant(row->at(index.column()).toString());
  5438. }
  5439. }
  5440. return QVariant();
  5441. }
  5442. /*:456*//*457:*/
  5443. #line 10577 "./typica.w"
  5444. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5445. int role)const
  5446. {
  5447. if(orientation==Qt::Horizontal)
  5448. {
  5449. if(role==Qt::DisplayRole)
  5450. {
  5451. if(section<hData->size())
  5452. {
  5453. return QVariant(hData->at(section));
  5454. }
  5455. }
  5456. }
  5457. return QVariant();
  5458. }
  5459. /*:457*//*458:*/
  5460. #line 10604 "./typica.w"
  5461. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5462. {
  5463. /*447:*/
  5464. #line 10333 "./typica.w"
  5465. bool valid= false;
  5466. if(index.isValid())
  5467. {
  5468. if(index.row()<entries->size())
  5469. {
  5470. if(index.column()<colcount)
  5471. {
  5472. valid= true;
  5473. }
  5474. }
  5475. }
  5476. /*:447*/
  5477. #line 10607 "./typica.w"
  5478. if(valid)
  5479. {
  5480. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5481. }
  5482. return 0;
  5483. }
  5484. /*:458*//*459:*/
  5485. #line 10619 "./typica.w"
  5486. QModelIndex MeasurementModel::index(int row,int column,
  5487. const QModelIndex&parent)const
  5488. {
  5489. if(parent==QModelIndex())
  5490. {
  5491. if(row<entries->size()&&entries->isEmpty()==false)
  5492. {
  5493. if(column<entries->at(row)->size())
  5494. {
  5495. return createIndex(row,column);
  5496. }
  5497. }
  5498. }
  5499. return QModelIndex();
  5500. }
  5501. /*:459*/
  5502. #line 550 "./typica.w"
  5503. /*461:*/
  5504. #line 10670 "./typica.w"
  5505. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5506. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5507. {
  5508. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5509. }
  5510. /*:461*//*462:*/
  5511. #line 10685 "./typica.w"
  5512. void AnnotationButton::annotate()
  5513. {
  5514. if(note.contains("%1"))
  5515. {
  5516. count++;
  5517. emit annotation(note.arg(count),tc,ac);
  5518. }
  5519. else
  5520. {
  5521. emit annotation(note,tc,ac);
  5522. }
  5523. }
  5524. /*:462*//*463:*/
  5525. #line 10703 "./typica.w"
  5526. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5527. {
  5528. tc= tempcolumn;
  5529. }
  5530. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5531. {
  5532. ac= annotationcolumn;
  5533. }
  5534. void AnnotationButton::setAnnotation(const QString&annotation)
  5535. {
  5536. note= annotation;
  5537. }
  5538. /*:463*//*464:*/
  5539. #line 10722 "./typica.w"
  5540. void AnnotationButton::resetCount()
  5541. {
  5542. count= 0;
  5543. }
  5544. /*:464*/
  5545. #line 551 "./typica.w"
  5546. /*469:*/
  5547. #line 10805 "./typica.w"
  5548. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5549. const QString&postt,
  5550. QWidget*parent)
  5551. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5552. {
  5553. resetChange();
  5554. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5555. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5556. }
  5557. /*:469*//*470:*/
  5558. #line 10822 "./typica.w"
  5559. void AnnotationSpinBox::resetChange()
  5560. {
  5561. change= true;
  5562. }
  5563. /*:470*//*471:*/
  5564. #line 10833 "./typica.w"
  5565. void AnnotationSpinBox::annotate()
  5566. {
  5567. if(change)
  5568. {
  5569. change= false;
  5570. emit annotation(QString("%1%2%3").arg(pretext).
  5571. arg(value()).arg(posttext),tc,ac);
  5572. }
  5573. }
  5574. /*:471*//*472:*/
  5575. #line 10846 "./typica.w"
  5576. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5577. {
  5578. tc= tempcolumn;
  5579. }
  5580. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5581. {
  5582. ac= annotationcolumn;
  5583. }
  5584. void AnnotationSpinBox::setPretext(const QString&pret)
  5585. {
  5586. pretext= pret;
  5587. }
  5588. void AnnotationSpinBox::setPosttext(const QString&postt)
  5589. {
  5590. posttext= postt;
  5591. }
  5592. /*:472*/
  5593. #line 552 "./typica.w"
  5594. /*479:*/
  5595. #line 11015 "./typica.w"
  5596. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5597. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5598. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5599. stopAction(new QAction(tr("Stop"),NULL)),
  5600. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5601. relative(QTime::currentTime()),base(QTime(0,0,0))
  5602. {
  5603. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5604. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5605. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5606. clock.setInterval(500);
  5607. clock.setSingleShot(false);
  5608. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5609. setSegmentStyle(Filled);
  5610. updateDisplay();
  5611. }
  5612. /*:479*//*480:*/
  5613. #line 11036 "./typica.w"
  5614. void TimerDisplay::updateTime()
  5615. {
  5616. QTime time;
  5617. int cseconds= 0;
  5618. int oseconds= 0;
  5619. int r= 0;
  5620. QTime nt= QTime(0,0,0);
  5621. int n= 0;
  5622. int bseconds= 0;
  5623. switch(m)
  5624. {
  5625. case TimerDisplay::CountUp:
  5626. /*481:*/
  5627. #line 11068 "./typica.w"
  5628. /*482:*/
  5629. #line 11081 "./typica.w"
  5630. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5631. time= QTime::currentTime();
  5632. cseconds= TIMETOINT(time);
  5633. oseconds= TIMETOINT(relative);
  5634. r= cseconds-oseconds;
  5635. /*:482*/
  5636. #line 11069 "./typica.w"
  5637. nt= nt.addSecs(r);
  5638. if(nt!=s)
  5639. {
  5640. s= nt;
  5641. emit valueChanged(s);
  5642. }
  5643. /*:481*/
  5644. #line 11049 "./typica.w"
  5645. ;
  5646. break;
  5647. case TimerDisplay::CountDown:
  5648. /*483:*/
  5649. #line 11093 "./typica.w"
  5650. if(s> QTime(0,0,0))
  5651. {
  5652. /*482:*/
  5653. #line 11081 "./typica.w"
  5654. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5655. time= QTime::currentTime();
  5656. cseconds= TIMETOINT(time);
  5657. oseconds= TIMETOINT(relative);
  5658. r= cseconds-oseconds;
  5659. /*:482*/
  5660. #line 11096 "./typica.w"
  5661. bseconds= TIMETOINT(base);
  5662. n= bseconds-r;
  5663. nt= nt.addSecs(n);
  5664. if(nt!=s)
  5665. {
  5666. s= nt;
  5667. emit valueChanged(s);
  5668. }
  5669. }else{
  5670. stopTimer();
  5671. }
  5672. /*:483*/
  5673. #line 11052 "./typica.w"
  5674. ;
  5675. break;
  5676. case TimerDisplay::Clock:
  5677. /*484:*/
  5678. #line 11112 "./typica.w"
  5679. time= QTime::currentTime();
  5680. if(time!=s)
  5681. {
  5682. s= time;
  5683. emit valueChanged(s);
  5684. }
  5685. /*:484*/
  5686. #line 11055 "./typica.w"
  5687. ;
  5688. break;
  5689. default:
  5690. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5691. break;
  5692. }
  5693. updateDisplay();
  5694. }
  5695. /*:480*//*485:*/
  5696. #line 11124 "./typica.w"
  5697. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5698. void TimerDisplay::startTimer()
  5699. {
  5700. if(!running)
  5701. {
  5702. relative= QTime::currentTime();
  5703. if(ar)
  5704. {
  5705. reset();
  5706. }
  5707. else
  5708. {
  5709. relative= TIMESUBTRACT(relative,s);
  5710. }
  5711. if(m==Clock)
  5712. {
  5713. updateTime();
  5714. }
  5715. base= s;
  5716. clock.start();
  5717. running= true;
  5718. emit runStateChanged(true);
  5719. }
  5720. }
  5721. /*:485*//*486:*/
  5722. #line 11154 "./typica.w"
  5723. void TimerDisplay::stopTimer()
  5724. {
  5725. if(running)
  5726. {
  5727. clock.stop();
  5728. running= false;
  5729. emit runStateChanged(false);
  5730. }
  5731. }
  5732. /*:486*//*487:*/
  5733. #line 11167 "./typica.w"
  5734. TimerDisplay::~TimerDisplay()
  5735. {
  5736. clock.stop();
  5737. }
  5738. /*:487*//*488:*/
  5739. #line 11176 "./typica.w"
  5740. void TimerDisplay::setCountUpMode()
  5741. {
  5742. m= TimerDisplay::CountUp;
  5743. }
  5744. void TimerDisplay::setCountDownMode()
  5745. {
  5746. m= TimerDisplay::CountDown;
  5747. }
  5748. void TimerDisplay::setClockMode()
  5749. {
  5750. m= TimerDisplay::Clock;
  5751. }
  5752. /*:488*//*489:*/
  5753. #line 11194 "./typica.w"
  5754. QString TimerDisplay::value()
  5755. {
  5756. return s.toString(f);
  5757. }
  5758. QTime TimerDisplay::seconds()
  5759. {
  5760. return s;
  5761. }
  5762. TimerDisplay::TimerMode TimerDisplay::mode()
  5763. {
  5764. return m;
  5765. }
  5766. bool TimerDisplay::isRunning()
  5767. {
  5768. return running;
  5769. }
  5770. QTime TimerDisplay::resetValue()
  5771. {
  5772. return r;
  5773. }
  5774. QString TimerDisplay::displayFormat()
  5775. {
  5776. return f;
  5777. }
  5778. bool TimerDisplay::autoReset()
  5779. {
  5780. return ar;
  5781. }
  5782. /*:489*//*490:*/
  5783. #line 11232 "./typica.w"
  5784. void TimerDisplay::setTimer(QTime value)
  5785. {
  5786. if(value.isValid())
  5787. {
  5788. s= value;
  5789. updateDisplay();
  5790. emit valueChanged(value);
  5791. }
  5792. }
  5793. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5794. {
  5795. m= mode;
  5796. }
  5797. void TimerDisplay::setResetValue(QTime value)
  5798. {
  5799. r= value;
  5800. }
  5801. void TimerDisplay::setDisplayFormat(QString format)
  5802. {
  5803. f= format;
  5804. setNumDigits(format.length());
  5805. }
  5806. void TimerDisplay::setAutoReset(bool reset)
  5807. {
  5808. ar= reset;
  5809. }
  5810. /*:490*//*491:*/
  5811. #line 11267 "./typica.w"
  5812. void TimerDisplay::copyTimer()
  5813. {
  5814. QApplication::clipboard()->setText(value());
  5815. }
  5816. /*:491*//*492:*/
  5817. #line 11276 "./typica.w"
  5818. void TimerDisplay::reset()
  5819. {
  5820. if(!running)
  5821. {
  5822. s= r;
  5823. updateDisplay();
  5824. }
  5825. }
  5826. /*:492*//*493:*/
  5827. #line 11289 "./typica.w"
  5828. void TimerDisplay::updateDisplay()
  5829. {
  5830. display(value());
  5831. }
  5832. /*:493*/
  5833. #line 553 "./typica.w"
  5834. /*500:*/
  5835. #line 11414 "./typica.w"
  5836. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5837. {
  5838. int x= rect.x();
  5839. int y= rect.y();
  5840. QLayoutItem*item;
  5841. if(orientation==Qt::Horizontal)
  5842. {
  5843. /*501:*/
  5844. #line 11438 "./typica.w"
  5845. foreach(item,itemList)
  5846. {
  5847. int nextX= x+item->sizeHint().width()+spacing();
  5848. int right= x+item->sizeHint().width();
  5849. if(item==itemList.last())
  5850. {
  5851. right= rect.right();
  5852. }
  5853. int bottom= rect.bottom();
  5854. if(!testOnly)
  5855. {
  5856. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5857. }
  5858. x= nextX;
  5859. }
  5860. /*:501*/
  5861. #line 11422 "./typica.w"
  5862. }
  5863. else
  5864. {
  5865. /*502:*/
  5866. #line 11457 "./typica.w"
  5867. foreach(item,itemList)
  5868. {
  5869. int nextY= y+item->sizeHint().height()+spacing();
  5870. int bottom= y+item->sizeHint().height();
  5871. if(item==itemList.last())
  5872. {
  5873. bottom= rect.bottom();
  5874. }
  5875. int right= rect.right();
  5876. if(!testOnly)
  5877. {
  5878. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5879. }
  5880. y= nextY;
  5881. }
  5882. /*:502*/
  5883. #line 11426 "./typica.w"
  5884. }
  5885. return y;
  5886. }
  5887. /*:500*//*503:*/
  5888. #line 11481 "./typica.w"
  5889. QSize PackLayout::minimumSize()const
  5890. {
  5891. QSize size;
  5892. QLayoutItem*item;
  5893. foreach(item,itemList)
  5894. {
  5895. if(orientation==Qt::Horizontal)
  5896. {
  5897. size+= QSize(item->minimumSize().width(),0);
  5898. if(size.height()<item->minimumSize().height())
  5899. {
  5900. size.setHeight(item->minimumSize().height());
  5901. }
  5902. }
  5903. else
  5904. {
  5905. size+= QSize(0,item->minimumSize().height());
  5906. if(size.width()<item->minimumSize().width())
  5907. {
  5908. size.setWidth(item->minimumSize().width());
  5909. }
  5910. }
  5911. }
  5912. size+= QSize(2*margin(),2*margin());
  5913. return size;
  5914. }
  5915. /*:503*//*504:*/
  5916. #line 11513 "./typica.w"
  5917. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5918. QLayout(parent)
  5919. {
  5920. setMargin(margin);
  5921. setSpacing(spacing);
  5922. setOrientation(Qt::Horizontal);
  5923. }
  5924. PackLayout::PackLayout(int spacing)
  5925. {
  5926. setSpacing(spacing);
  5927. setOrientation(Qt::Horizontal);
  5928. }
  5929. /*:504*//*505:*/
  5930. #line 11531 "./typica.w"
  5931. PackLayout::~PackLayout()
  5932. {
  5933. QLayoutItem*item;
  5934. while((item= takeAt(0)))
  5935. {
  5936. delete item;
  5937. }
  5938. }
  5939. /*:505*//*506:*/
  5940. #line 11545 "./typica.w"
  5941. QLayoutItem*PackLayout::takeAt(int index)
  5942. {
  5943. if(index>=0&&index<itemList.size())
  5944. {
  5945. return itemList.takeAt(index);
  5946. }
  5947. else
  5948. {
  5949. return NULL;
  5950. }
  5951. }
  5952. /*:506*//*507:*/
  5953. #line 11561 "./typica.w"
  5954. QLayoutItem*PackLayout::itemAt(int index)const
  5955. {
  5956. if(index>=0&&index<itemList.size())
  5957. {
  5958. return itemList.at(index);
  5959. }
  5960. else
  5961. {
  5962. return NULL;
  5963. }
  5964. }
  5965. /*:507*//*508:*/
  5966. #line 11584 "./typica.w"
  5967. void PackLayout::addItem(QLayoutItem*item)
  5968. {
  5969. itemList.append(item);
  5970. }
  5971. /*:508*//*509:*/
  5972. #line 11592 "./typica.w"
  5973. int PackLayout::count()const
  5974. {
  5975. return itemList.size();
  5976. }
  5977. /*:509*//*510:*/
  5978. #line 11604 "./typica.w"
  5979. Qt::Orientations PackLayout::expandingDirections()const
  5980. {
  5981. return Qt::Vertical|Qt::Horizontal;
  5982. }
  5983. bool PackLayout::hasHeightForWidth()const
  5984. {
  5985. return false;
  5986. }
  5987. int PackLayout::heightForWidth(int width)const
  5988. {
  5989. return doLayout(QRect(0,0,width,0),true);
  5990. }
  5991. void PackLayout::setGeometry(const QRect&rect)
  5992. {
  5993. QLayout::setGeometry(rect);
  5994. doLayout(rect,false);
  5995. }
  5996. QSize PackLayout::sizeHint()const
  5997. {
  5998. return minimumSize();
  5999. }
  6000. /*:510*//*511:*/
  6001. #line 11635 "./typica.w"
  6002. void PackLayout::setOrientation(Qt::Orientations direction)
  6003. {
  6004. orientation= direction;
  6005. doLayout(geometry(),false);
  6006. }
  6007. /*:511*/
  6008. #line 554 "./typica.w"
  6009. /*513:*/
  6010. #line 11674 "./typica.w"
  6011. SceneButton::SceneButton():QGraphicsScene()
  6012. {
  6013. }
  6014. SceneButton::~SceneButton()
  6015. {
  6016. }
  6017. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  6018. {
  6019. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  6020. }
  6021. /*:513*/
  6022. #line 555 "./typica.w"
  6023. /*515:*/
  6024. #line 11720 "./typica.w"
  6025. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  6026. Qt::Orientations orientation,
  6027. QWidget*parent,Qt::WindowFlags f):
  6028. QWidget(parent,f),label(new QGraphicsView()),
  6029. scene(new SceneButton())
  6030. {
  6031. layout= new PackLayout(this);
  6032. layout->setOrientation(orientation);
  6033. /*516:*/
  6034. #line 11740 "./typica.w"
  6035. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6036. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6037. label->setFrameShape(QFrame::NoFrame);
  6038. label->setInteractive(true);
  6039. /*:516*/
  6040. #line 11729 "./typica.w"
  6041. /*517:*/
  6042. #line 11751 "./typica.w"
  6043. scene->setBackgroundBrush(Qt::cyan);
  6044. text= scene->addText(labeltext);
  6045. if(orientation==Qt::Horizontal)
  6046. {
  6047. text->rotate(270.0);
  6048. }
  6049. label->setScene(scene);
  6050. /*:517*/
  6051. #line 11730 "./typica.w"
  6052. /*518:*/
  6053. #line 11769 "./typica.w"
  6054. if(orientation==Qt::Horizontal)
  6055. {
  6056. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  6057. }
  6058. else
  6059. {
  6060. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  6061. }
  6062. label->centerOn(text);
  6063. /*:518*/
  6064. #line 11731 "./typica.w"
  6065. /*519:*/
  6066. #line 11784 "./typica.w"
  6067. layout->addWidget(label);
  6068. layout->addWidget(widget);
  6069. if(orientation==Qt::Horizontal)
  6070. {
  6071. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  6072. widget->sizeHint().height());
  6073. }
  6074. else
  6075. {
  6076. setMinimumSize(widget->sizeHint().width(),
  6077. widget->sizeHint().height()+label->sizeHint().height());
  6078. }
  6079. /*:519*/
  6080. #line 11732 "./typica.w"
  6081. }
  6082. /*:515*//*520:*/
  6083. #line 11801 "./typica.w"
  6084. void WidgetDecorator::setBackgroundBrush(QBrush background)
  6085. {
  6086. scene->setBackgroundBrush(background);
  6087. }
  6088. void WidgetDecorator::setTextColor(QColor color)
  6089. {
  6090. text->setDefaultTextColor(color);
  6091. }
  6092. /*:520*//*521:*/
  6093. #line 11814 "./typica.w"
  6094. WidgetDecorator::~WidgetDecorator()
  6095. {
  6096. }
  6097. /*:521*/
  6098. #line 556 "./typica.w"
  6099. /*526:*/
  6100. #line 11913 "./typica.w"
  6101. void LogEditWindow::addTheRows()
  6102. {
  6103. QTime s= startTime->time();
  6104. while(s<endTime->time())
  6105. {
  6106. model->newMeasurement(Measurement(0,s),1);
  6107. s= s.addSecs(interval->value());
  6108. }
  6109. model->newMeasurement(Measurement(0,endTime->time()),1);
  6110. }
  6111. /*:526*//*527:*/
  6112. #line 11927 "./typica.w"
  6113. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  6114. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  6115. addRowsLayout(new QHBoxLayout(NULL)),
  6116. startTimeLabel(new QLabel("Start Time")),
  6117. startTime(new QTimeEdit(QTime(0,0,0,0))),
  6118. endTimeLabel(new QLabel("End Time")),
  6119. endTime(new QTimeEdit(QTime(0,20,0,0))),
  6120. intervalLabel(new QLabel("Interval (seconds)")),
  6121. interval(new QSpinBox()),
  6122. addRows(new QPushButton("Add Rows")),
  6123. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  6124. saveCsv(new QAction(tr("Export CSV"),NULL)),
  6125. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  6126. model(new MeasurementModel()),
  6127. log(new QTableView())
  6128. {
  6129. /*528:*/
  6130. #line 11964 "./typica.w"
  6131. QSettings settings;
  6132. resize(settings.value("logSize",QSize(620,400)).toSize());
  6133. move(settings.value("logPos",QPoint(200,60)).toPoint());
  6134. /*:528*/
  6135. #line 11944 "./typica.w"
  6136. /*529:*/
  6137. #line 11977 "./typica.w"
  6138. mainLayout->setOrientation(Qt::Vertical);
  6139. addRowsLayout->addSpacing(10);
  6140. addRowsLayout->addWidget(startTimeLabel);
  6141. addRowsLayout->addWidget(startTime);
  6142. addRowsLayout->addSpacing(10);
  6143. startTime->setDisplayFormat("mm:ss");
  6144. addRowsLayout->addWidget(endTimeLabel);
  6145. addRowsLayout->addWidget(endTime);
  6146. addRowsLayout->addSpacing(10);
  6147. endTime->setDisplayFormat("mm:ss");
  6148. addRowsLayout->addWidget(intervalLabel);
  6149. addRowsLayout->addWidget(interval);
  6150. addRowsLayout->addSpacing(10);
  6151. interval->setRange(0,60);
  6152. interval->setValue(30);
  6153. addRowsLayout->addWidget(addRows);
  6154. addRowsLayout->addSpacing(10);
  6155. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  6156. /*:529*/
  6157. #line 11945 "./typica.w"
  6158. /*530:*/
  6159. #line 12000 "./typica.w"
  6160. model->setHeaderData(0,Qt::Horizontal,"Time");
  6161. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  6162. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  6163. model->clear();
  6164. /*:530*/
  6165. #line 11946 "./typica.w"
  6166. /*531:*/
  6167. #line 12009 "./typica.w"
  6168. log->setModel(model);
  6169. log->setColumnWidth(0,100);
  6170. log->setColumnWidth(1,100);
  6171. log->setColumnWidth(2,100);
  6172. /*:531*/
  6173. #line 11947 "./typica.w"
  6174. mainLayout->addItem(addRowsLayout);
  6175. mainLayout->addWidget(log);
  6176. centralWidget->setLayout(mainLayout);
  6177. setCentralWidget(centralWidget);
  6178. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  6179. fileMenu->addAction(openXml);
  6180. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  6181. fileMenu->addAction(saveXml);
  6182. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6183. fileMenu->addAction(saveCsv);
  6184. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6185. }
  6186. /*:527*//*532:*/
  6187. #line 12020 "./typica.w"
  6188. void LogEditWindow::saveXML()
  6189. {
  6190. QSettings settings;
  6191. QString lastDir= settings.value("lastDirectory").toString();
  6192. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6193. lastDir,"",0);
  6194. QFile file(filename);
  6195. XMLOutput writer(model,&file,0);
  6196. writer.addTemperatureColumn("Temperature",1);
  6197. writer.addAnnotationColumn("Annotation",2);
  6198. if(writer.output())
  6199. {
  6200. QFileInfo info(filename);
  6201. QDir directory= info.dir();
  6202. lastDir= directory.path();
  6203. settings.setValue("lastDirectory",lastDir);
  6204. }
  6205. }
  6206. void LogEditWindow::saveCSV()
  6207. {
  6208. QSettings settings;
  6209. QString lastDir= settings.value("lastDirectory").toString();
  6210. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6211. lastDir,"",0);
  6212. QFile file(filename);
  6213. CSVOutput writer(model,&file,0);
  6214. writer.addTemperatureColumn("Temperature",1);
  6215. writer.addAnnotationColumn("Annotation",2);
  6216. if(writer.output())
  6217. {
  6218. QFileInfo info(filename);
  6219. QDir directory= info.dir();
  6220. lastDir= directory.path();
  6221. settings.setValue("lastDirectory",lastDir);
  6222. }
  6223. }
  6224. /*:532*//*533:*/
  6225. #line 12063 "./typica.w"
  6226. void LogEditWindow::openXML()
  6227. {
  6228. QSettings settings;
  6229. QString lastDir= settings.value("lastDirectory").toString();
  6230. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6231. lastDir,"",0);
  6232. if(filename.isNull())
  6233. {
  6234. return;
  6235. }
  6236. QFile file(filename);
  6237. XMLInput reader(&file,1);
  6238. connect(&reader,SIGNAL(measure(Measurement,int)),
  6239. model,SLOT(newMeasurement(Measurement,int)));
  6240. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6241. model,SLOT(newAnnotation(QString,int,int)));
  6242. if(reader.input())
  6243. {
  6244. QFileInfo info(filename);
  6245. setWindowTitle(QString(tr("%1 - %2")).
  6246. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6247. QDir directory= info.dir();
  6248. lastDir= directory.path();
  6249. settings.setValue("lastDirectory",lastDir);
  6250. }
  6251. }
  6252. /*:533*//*534:*/
  6253. #line 12094 "./typica.w"
  6254. void LogEditWindow::closeEvent(QCloseEvent*event)
  6255. {
  6256. QSettings settings;
  6257. settings.setValue("logSize",size());
  6258. settings.setValue("logPos",pos());
  6259. event->accept();
  6260. }
  6261. /*:534*/
  6262. #line 557 "./typica.w"
  6263. /*540:*/
  6264. #line 12209 "./typica.w"
  6265. bool XMLOutput::output()
  6266. {
  6267. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6268. {
  6269. return false;
  6270. }
  6271. QXmlStreamWriter xmlout(out);
  6272. xmlout.writeStartDocument("1.0");
  6273. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6274. xmlout.writeStartElement("roastlog");
  6275. /*541:*/
  6276. #line 12242 "./typica.w"
  6277. foreach(int c,temperatureColumns.keys())
  6278. {
  6279. xmlout.writeStartElement("tempseries");
  6280. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6281. xmlout.writeEndElement();
  6282. }
  6283. foreach(int c,controlColumns.keys())
  6284. {
  6285. xmlout.writeStartElement("controlseries");
  6286. xmlout.writeAttribute("name",controlColumns.value(c));
  6287. xmlout.writeEndElement();
  6288. }
  6289. foreach(int c,annotationColumns.keys())
  6290. {
  6291. xmlout.writeStartElement("noteseries");
  6292. xmlout.writeAttribute("name",annotationColumns.value(c));
  6293. xmlout.writeEndElement();
  6294. }
  6295. /*:541*/
  6296. #line 12220 "./typica.w"
  6297. xmlout.writeStartElement("roast");
  6298. bool oresult;
  6299. for(int i= 0;i<data->rowCount();i++)
  6300. {
  6301. /*542:*/
  6302. #line 12267 "./typica.w"
  6303. oresult= false;
  6304. foreach(int c,temperatureColumns.keys())
  6305. {
  6306. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6307. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6308. {
  6309. oresult= true;
  6310. break;
  6311. }
  6312. }
  6313. foreach(int c,controlColumns.keys())
  6314. {
  6315. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6316. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6317. {
  6318. oresult= true;
  6319. break;
  6320. }
  6321. }
  6322. if(oresult==false)
  6323. {
  6324. foreach(int c,annotationColumns.keys())
  6325. {
  6326. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6327. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6328. isEmpty()))
  6329. {
  6330. oresult= true;
  6331. break;
  6332. }
  6333. }
  6334. }
  6335. /*:542*/
  6336. #line 12225 "./typica.w"
  6337. if(oresult)
  6338. {
  6339. /*543:*/
  6340. #line 12306 "./typica.w"
  6341. xmlout.writeStartElement("tuple");
  6342. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6343. Qt::DisplayRole).toString());
  6344. foreach(int c,temperatureColumns.keys())
  6345. {
  6346. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6347. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6348. {
  6349. xmlout.writeStartElement("temperature");
  6350. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6351. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6352. {
  6353. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6354. {
  6355. xmlout.writeAttribute("relative","true");
  6356. }
  6357. }
  6358. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6359. toString());
  6360. xmlout.writeEndElement();
  6361. }
  6362. }
  6363. foreach(int c,controlColumns.keys())
  6364. {
  6365. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6366. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6367. {
  6368. xmlout.writeStartElement("control");
  6369. xmlout.writeAttribute("series",controlColumns.value(c));
  6370. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6371. xmlout.writeEndElement();
  6372. }
  6373. }
  6374. foreach(int c,annotationColumns.keys())
  6375. {
  6376. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6377. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6378. {
  6379. xmlout.writeStartElement("annotation");
  6380. xmlout.writeAttribute("series",annotationColumns.value(c));
  6381. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6382. toString());
  6383. xmlout.writeEndElement();
  6384. }
  6385. }
  6386. xmlout.writeEndElement();
  6387. /*:543*/
  6388. #line 12228 "./typica.w"
  6389. }
  6390. }
  6391. xmlout.writeEndElement();
  6392. xmlout.writeEndElement();
  6393. xmlout.writeEndDocument();
  6394. out->close();
  6395. return true;
  6396. }
  6397. /*:540*//*544:*/
  6398. #line 12356 "./typica.w"
  6399. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6400. :QObject(NULL),data(model),out(device),time(timec)
  6401. {
  6402. }
  6403. void XMLOutput::setModel(MeasurementModel*model)
  6404. {
  6405. data= model;
  6406. }
  6407. void XMLOutput::setTimeColumn(int column)
  6408. {
  6409. time= column;
  6410. }
  6411. void XMLOutput::setDevice(QIODevice*device)
  6412. {
  6413. out= device;
  6414. }
  6415. /*:544*//*545:*/
  6416. #line 12385 "./typica.w"
  6417. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6418. {
  6419. temperatureColumns.insert(column,series);
  6420. }
  6421. void XMLOutput::addControlColumn(const QString&series,int column)
  6422. {
  6423. controlColumns.insert(column,series);
  6424. }
  6425. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6426. {
  6427. annotationColumns.insert(column,series);
  6428. }
  6429. /*:545*/
  6430. #line 558 "./typica.w"
  6431. /*547:*/
  6432. #line 12442 "./typica.w"
  6433. bool XMLInput::input()
  6434. {
  6435. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6436. {
  6437. return false;
  6438. }
  6439. QXmlStreamReader xmlin(in);
  6440. QMap<QString,int> temperatureColumns;
  6441. QMap<QString,int> annotationColumns;
  6442. int nextColumn= firstc;
  6443. /*548:*/
  6444. #line 12473 "./typica.w"
  6445. while(!xmlin.isDTD())
  6446. {
  6447. xmlin.readNext();
  6448. }
  6449. if(xmlin.isDTD())
  6450. {
  6451. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6452. {
  6453. /*549:*/
  6454. #line 12495 "./typica.w"
  6455. emit newTemperatureColumn(firstc,"Bean");
  6456. emit newAnnotationColumn(firstc+1,"Note");
  6457. emit lastColumn(firstc+1);
  6458. /*:549*/
  6459. #line 12482 "./typica.w"
  6460. }
  6461. else
  6462. {
  6463. xmlin.readNext();
  6464. /*550:*/
  6465. #line 12504 "./typica.w"
  6466. while(xmlin.name()!="roast")
  6467. {
  6468. if(xmlin.isStartElement())
  6469. {
  6470. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6471. {
  6472. temperatureColumns.insert(xmlin.attributes().value("name").
  6473. toString(),
  6474. nextColumn);
  6475. emit newTemperatureColumn(nextColumn,
  6476. xmlin.attributes().value("name").
  6477. toString());
  6478. nextColumn++;
  6479. }
  6480. else if(xmlin.name()=="noteseries")
  6481. {
  6482. annotationColumns.insert(xmlin.attributes().value("name").
  6483. toString(),nextColumn);
  6484. emit newAnnotationColumn(nextColumn,
  6485. xmlin.attributes().value("name").
  6486. toString());
  6487. nextColumn++;
  6488. }
  6489. }
  6490. xmlin.readNext();
  6491. }
  6492. emit lastColumn(nextColumn-1);
  6493. /*:550*/
  6494. #line 12487 "./typica.w"
  6495. }
  6496. }
  6497. /*:548*/
  6498. #line 12453 "./typica.w"
  6499. QTime timeval= QTime();
  6500. double tempval= 0;
  6501. QString noteval= QString();
  6502. int column;
  6503. int counter= 0;
  6504. while(!xmlin.atEnd())
  6505. {
  6506. /*551:*/
  6507. #line 12545 "./typica.w"
  6508. xmlin.readNext();
  6509. if(xmlin.isStartElement())
  6510. {
  6511. /*552:*/
  6512. #line 12571 "./typica.w"
  6513. if(xmlin.name()=="time")
  6514. {
  6515. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6516. }
  6517. else if(xmlin.name()=="temperature")
  6518. {
  6519. column= xmlin.attributes().hasAttribute("series")?
  6520. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6521. bool relative= (xmlin.attributes().value("relative")=="true");
  6522. tempval= xmlin.readElementText().toDouble();
  6523. Measurement measurement(tempval,timeval);
  6524. if(relative)
  6525. {
  6526. measurement.insert("relative",true);
  6527. }
  6528. emit measure(measurement,column);
  6529. }
  6530. else if(xmlin.name()=="control")
  6531. {
  6532. column= xmlin.attributes().value("series").toString().isEmpty()?
  6533. firstc:temperatureColumns.value(xmlin.attributes().
  6534. value("series").toString());
  6535. tempval= xmlin.readElementText().toDouble();
  6536. Measurement measurement(tempval,timeval,Units::Unitless);
  6537. emit measure(measurement,column);
  6538. }
  6539. else if(xmlin.name()=="annotation")
  6540. {
  6541. column= xmlin.attributes().value("series").toString().isEmpty()?
  6542. firstc+1:annotationColumns.value(xmlin.attributes().
  6543. value("series").toString());
  6544. noteval= xmlin.readElementText();
  6545. if(!noteval.isEmpty())
  6546. {
  6547. emit annotation(noteval,firstc,column);
  6548. }
  6549. }
  6550. /*:552*/
  6551. #line 12549 "./typica.w"
  6552. }
  6553. counter++;
  6554. if(counter%100==0)
  6555. {
  6556. QCoreApplication::processEvents();
  6557. }
  6558. /*:551*/
  6559. #line 12461 "./typica.w"
  6560. }
  6561. return true;
  6562. }
  6563. /*:547*//*553:*/
  6564. #line 12612 "./typica.w"
  6565. XMLInput::XMLInput(QIODevice*input,int c):
  6566. firstc(c),in(input)
  6567. {
  6568. }
  6569. void XMLInput::setFirstColumn(int column)
  6570. {
  6571. firstc= column;
  6572. }
  6573. void XMLInput::setDevice(QIODevice*device)
  6574. {
  6575. in= device;
  6576. }
  6577. /*:553*/
  6578. #line 559 "./typica.w"
  6579. /*558:*/
  6580. #line 12703 "./typica.w"
  6581. bool CSVOutput::output()
  6582. {
  6583. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6584. {
  6585. return false;
  6586. }
  6587. QTextStream output(out);
  6588. /*559:*/
  6589. #line 12727 "./typica.w"
  6590. output<<"Time";
  6591. foreach(int c,temperatureColumns.keys())
  6592. {
  6593. output<<','<<temperatureColumns.value(c);
  6594. }
  6595. foreach(int c,controlColumns.keys())
  6596. {
  6597. output<<','<<controlColumns.value(c);
  6598. }
  6599. foreach(int c,annotationColumns.keys())
  6600. {
  6601. output<<','<<annotationColumns.value(c);
  6602. }
  6603. output<<'\n';
  6604. /*:559*/
  6605. #line 12711 "./typica.w"
  6606. bool oresult;
  6607. for(int i= 0;i<data->rowCount();i++)
  6608. {
  6609. /*542:*/
  6610. #line 12267 "./typica.w"
  6611. oresult= false;
  6612. foreach(int c,temperatureColumns.keys())
  6613. {
  6614. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6615. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6616. {
  6617. oresult= true;
  6618. break;
  6619. }
  6620. }
  6621. foreach(int c,controlColumns.keys())
  6622. {
  6623. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6624. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6625. {
  6626. oresult= true;
  6627. break;
  6628. }
  6629. }
  6630. if(oresult==false)
  6631. {
  6632. foreach(int c,annotationColumns.keys())
  6633. {
  6634. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6635. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6636. isEmpty()))
  6637. {
  6638. oresult= true;
  6639. break;
  6640. }
  6641. }
  6642. }
  6643. /*:542*/
  6644. #line 12715 "./typica.w"
  6645. if(oresult)
  6646. {
  6647. /*560:*/
  6648. #line 12752 "./typica.w"
  6649. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6650. foreach(int c,temperatureColumns.keys())
  6651. {
  6652. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6653. }
  6654. foreach(int c,controlColumns.keys())
  6655. {
  6656. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6657. }
  6658. foreach(int c,annotationColumns.keys())
  6659. {
  6660. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6661. }
  6662. output<<'\n';
  6663. /*:560*/
  6664. #line 12718 "./typica.w"
  6665. }
  6666. }
  6667. out->close();
  6668. return true;
  6669. }
  6670. /*:558*//*561:*/
  6671. #line 12771 "./typica.w"
  6672. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6673. data(model),out(device),time(timec)
  6674. {
  6675. }
  6676. void CSVOutput::setModel(MeasurementModel*model)
  6677. {
  6678. data= model;
  6679. }
  6680. void CSVOutput::setTimeColumn(int column)
  6681. {
  6682. time= column;
  6683. }
  6684. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6685. {
  6686. temperatureColumns.insert(column,series);
  6687. }
  6688. void CSVOutput::addControlColumn(const QString&series,int column)
  6689. {
  6690. controlColumns.insert(column,series);
  6691. }
  6692. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6693. {
  6694. annotationColumns.insert(column,series);
  6695. }
  6696. void CSVOutput::setDevice(QIODevice*device)
  6697. {
  6698. out= device;
  6699. }
  6700. #line 1 "./webview.w"
  6701. /*:561*/
  6702. #line 560 "./typica.w"
  6703. /*607:*/
  6704. #line 13059 "./typica.w"
  6705. QString SaltModel::arrayLiteral(int column,int role)const
  6706. {
  6707. QString literal= "'{";
  6708. for(int i= 0;i<rowCount();i++)
  6709. {
  6710. QString datum= data(index(i,column),role).toString();
  6711. if(!datum.isEmpty())
  6712. {
  6713. literal.append(datum);
  6714. literal.append(", ");
  6715. }
  6716. }
  6717. if(literal.size()> 2)
  6718. {
  6719. literal.chop(2);
  6720. }
  6721. literal.append("}'");
  6722. return literal;
  6723. }
  6724. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6725. {
  6726. QString literal= "'{";
  6727. for(int i= 0;i<rowCount();i++)
  6728. {
  6729. QString datum= data(index(i,column),role).toString();
  6730. if(!datum.isEmpty())
  6731. {
  6732. literal.append("\"");
  6733. literal.append(datum);
  6734. literal.append("\", ");
  6735. }
  6736. }
  6737. if(literal.size()> 2)
  6738. {
  6739. literal.chop(2);
  6740. }
  6741. literal.append("}'");
  6742. return literal;
  6743. }
  6744. /*:607*//*608:*/
  6745. #line 13103 "./typica.w"
  6746. QModelIndex SaltModel::parent(const QModelIndex&)const
  6747. {
  6748. return QModelIndex();
  6749. }
  6750. /*:608*//*609:*/
  6751. #line 13122 "./typica.w"
  6752. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6753. int role)
  6754. {
  6755. /*610:*/
  6756. #line 13153 "./typica.w"
  6757. bool valid= false;
  6758. if(index.isValid())
  6759. {
  6760. if(index.row()<modelData.size())
  6761. {
  6762. if(index.column()<colcount)
  6763. {
  6764. valid= true;
  6765. }
  6766. }
  6767. }
  6768. /*:610*/
  6769. #line 13126 "./typica.w"
  6770. if(!valid)
  6771. {
  6772. return false;
  6773. }
  6774. if(index.row()==modelData.size()-1)
  6775. {
  6776. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6777. /*611:*/
  6778. #line 13169 "./typica.w"
  6779. QList<QMap<int,QVariant> > newRow;
  6780. QMap<int,QVariant> defaults;
  6781. for(int i= 0;i<colcount;i++)
  6782. {
  6783. newRow.append(defaults);
  6784. }
  6785. modelData.append(newRow);
  6786. /*:611*/
  6787. #line 13134 "./typica.w"
  6788. endInsertRows();
  6789. }
  6790. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6791. QMap<int,QVariant> cell= row.at(index.column());
  6792. cell.insert(role,value);
  6793. if(role==Qt::EditRole)
  6794. {
  6795. cell.insert(Qt::DisplayRole,value);
  6796. }
  6797. row.replace(index.column(),cell);
  6798. modelData.replace(index.row(),row);
  6799. emit dataChanged(index,index);
  6800. return true;
  6801. }
  6802. /*:609*//*612:*/
  6803. #line 13180 "./typica.w"
  6804. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6805. {
  6806. for(int i= 0;i<columns;i++)
  6807. {
  6808. hData<<"";
  6809. }
  6810. /*611:*/
  6811. #line 13169 "./typica.w"
  6812. QList<QMap<int,QVariant> > newRow;
  6813. QMap<int,QVariant> defaults;
  6814. for(int i= 0;i<colcount;i++)
  6815. {
  6816. newRow.append(defaults);
  6817. }
  6818. modelData.append(newRow);
  6819. /*:611*/
  6820. #line 13187 "./typica.w"
  6821. }
  6822. /*:612*//*613:*/
  6823. #line 13192 "./typica.w"
  6824. SaltModel::~SaltModel()
  6825. {
  6826. }
  6827. /*:613*//*614:*/
  6828. #line 13202 "./typica.w"
  6829. int SaltModel::rowCount(const QModelIndex&parent)const
  6830. {
  6831. return(parent==QModelIndex()?modelData.size():0);
  6832. }
  6833. int SaltModel::columnCount(const QModelIndex&parent)const
  6834. {
  6835. return(parent==QModelIndex()?colcount:0);
  6836. }
  6837. /*:614*//*615:*/
  6838. #line 13215 "./typica.w"
  6839. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6840. const QVariant&value,int)
  6841. {
  6842. if(orientation==Qt::Horizontal&&section<colcount)
  6843. {
  6844. hData.replace(section,value.toString());
  6845. emit headerDataChanged(orientation,section,section);
  6846. return true;
  6847. }
  6848. return false;
  6849. }
  6850. /*:615*//*616:*/
  6851. #line 13230 "./typica.w"
  6852. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6853. {
  6854. /*610:*/
  6855. #line 13153 "./typica.w"
  6856. bool valid= false;
  6857. if(index.isValid())
  6858. {
  6859. if(index.row()<modelData.size())
  6860. {
  6861. if(index.column()<colcount)
  6862. {
  6863. valid= true;
  6864. }
  6865. }
  6866. }
  6867. /*:610*/
  6868. #line 13233 "./typica.w"
  6869. if(!valid)
  6870. {
  6871. return QVariant();
  6872. }
  6873. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6874. QMap<int,QVariant> cell= row.at(index.column());
  6875. return cell.value(role,QVariant());
  6876. }
  6877. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6878. int role)const
  6879. {
  6880. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6881. section<colcount)
  6882. {
  6883. return QVariant(hData.at(section));
  6884. }
  6885. return QVariant();
  6886. }
  6887. /*:616*//*617:*/
  6888. #line 13257 "./typica.w"
  6889. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6890. {
  6891. /*610:*/
  6892. #line 13153 "./typica.w"
  6893. bool valid= false;
  6894. if(index.isValid())
  6895. {
  6896. if(index.row()<modelData.size())
  6897. {
  6898. if(index.column()<colcount)
  6899. {
  6900. valid= true;
  6901. }
  6902. }
  6903. }
  6904. /*:610*/
  6905. #line 13260 "./typica.w"
  6906. if(valid)
  6907. {
  6908. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6909. }
  6910. return 0;
  6911. }
  6912. /*:617*//*618:*/
  6913. #line 13271 "./typica.w"
  6914. QModelIndex SaltModel::index(int row,int column,
  6915. const QModelIndex&parent)const
  6916. {
  6917. if(parent==QModelIndex())
  6918. {
  6919. if(row<modelData.size()&&column<colcount)
  6920. {
  6921. return createIndex(row,column);
  6922. }
  6923. }
  6924. return QModelIndex();
  6925. }
  6926. /*:618*//*619:*/
  6927. #line 13289 "./typica.w"
  6928. void SaltModel::clear()
  6929. {
  6930. beginResetModel();
  6931. modelData.clear();
  6932. /*611:*/
  6933. #line 13169 "./typica.w"
  6934. QList<QMap<int,QVariant> > newRow;
  6935. QMap<int,QVariant> defaults;
  6936. for(int i= 0;i<colcount;i++)
  6937. {
  6938. newRow.append(defaults);
  6939. }
  6940. modelData.append(newRow);
  6941. /*:611*/
  6942. #line 13294 "./typica.w"
  6943. endResetModel();
  6944. }
  6945. /*:619*//*620:*/
  6946. #line 13303 "./typica.w"
  6947. bool SaltModel::removeRows(int row,int count,
  6948. const QModelIndex&parent)
  6949. {
  6950. if(parent==QModelIndex())
  6951. {
  6952. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6953. {
  6954. beginRemoveRows(parent,row,row+count-1);
  6955. for(int i= 0;i<count;i++)
  6956. {
  6957. modelData.removeAt(row);
  6958. }
  6959. endRemoveRows();
  6960. if(modelData.size()==0)
  6961. {
  6962. beginInsertRows(parent,0,0);
  6963. /*611:*/
  6964. #line 13169 "./typica.w"
  6965. QList<QMap<int,QVariant> > newRow;
  6966. QMap<int,QVariant> defaults;
  6967. for(int i= 0;i<colcount;i++)
  6968. {
  6969. newRow.append(defaults);
  6970. }
  6971. modelData.append(newRow);
  6972. /*:611*/
  6973. #line 13320 "./typica.w"
  6974. endInsertRows();
  6975. }
  6976. return true;
  6977. }
  6978. }
  6979. return false;
  6980. }
  6981. /*:620*//*621:*/
  6982. #line 13334 "./typica.w"
  6983. int SaltModel::findData(const QVariant&value,int column,int role)
  6984. {
  6985. for(int i= 0;i<modelData.size();i++)
  6986. {
  6987. if(modelData.at(i).size()> column)
  6988. {
  6989. if(modelData.at(i).at(column).contains(role))
  6990. {
  6991. if(modelData.at(i).at(column).value(role)==value)
  6992. {
  6993. return i;
  6994. }
  6995. }
  6996. }
  6997. }
  6998. return-1;
  6999. }
  7000. /*:621*/
  7001. #line 561 "./typica.w"
  7002. /*623:*/
  7003. #line 13398 "./typica.w"
  7004. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  7005. {
  7006. SqlComboBox*widget= new SqlComboBox();
  7007. widget->setParent(parent);
  7008. for(int i= 0;i<count();i++)
  7009. {
  7010. widget->addItem(itemText(i),itemData(i));
  7011. }
  7012. return widget;
  7013. }
  7014. /*:623*//*624:*/
  7015. #line 13415 "./typica.w"
  7016. void SqlComboBox::showData(bool show)
  7017. {
  7018. dataColumnShown= show;
  7019. }
  7020. /*:624*//*625:*/
  7021. #line 13429 "./typica.w"
  7022. void SqlComboBox::addNullOption()
  7023. {
  7024. addItem(specialNullText,specialNullData);
  7025. }
  7026. void SqlComboBox::setNullText(QString nullText)
  7027. {
  7028. specialNullText= nullText;
  7029. }
  7030. void SqlComboBox::setNullData(QVariant nullData)
  7031. {
  7032. specialNullData= nullData;
  7033. }
  7034. /*:625*//*626:*/
  7035. #line 13452 "./typica.w"
  7036. void SqlComboBox::setDataColumn(int column)
  7037. {
  7038. dataColumn= column;
  7039. }
  7040. void SqlComboBox::setDisplayColumn(int column)
  7041. {
  7042. displayColumn= column;
  7043. }
  7044. /*:626*//*627:*/
  7045. #line 13466 "./typica.w"
  7046. void SqlComboBox::addSqlOptions(QString query)
  7047. {
  7048. SqlQueryConnection h;
  7049. QSqlQuery*dbquery= h.operator->();
  7050. if(!dbquery->exec(query))
  7051. {
  7052. QSqlError error= dbquery->lastError();
  7053. qDebug()<<error.databaseText();
  7054. qDebug()<<error.driverText();
  7055. qDebug()<<error.text();
  7056. qDebug()<<dbquery->lastQuery();
  7057. }
  7058. while(dbquery->next())
  7059. {
  7060. QString displayValue(dbquery->value(displayColumn).toString());
  7061. QString dataValue(dbquery->value(dataColumn).toString());
  7062. if(dataColumnShown)
  7063. {
  7064. displayValue.append(QString(" (%1)").arg(dataValue));
  7065. }
  7066. addItem(displayValue,dataValue);
  7067. }
  7068. }
  7069. /*:627*//*628:*/
  7070. #line 13502 "./typica.w"
  7071. SqlComboBox::SqlComboBox():
  7072. dataColumn(0),displayColumn(0),dataColumnShown(false),
  7073. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  7074. {
  7075. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  7076. }
  7077. SqlComboBox::~SqlComboBox()
  7078. {
  7079. }
  7080. /*:628*/
  7081. #line 562 "./typica.w"
  7082. /*630:*/
  7083. #line 13541 "./typica.w"
  7084. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  7085. {
  7086. delegate= widget;
  7087. }
  7088. /*:630*//*631:*/
  7089. #line 13550 "./typica.w"
  7090. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  7091. const QStyleOptionViewItem&,
  7092. const QModelIndex&)const
  7093. {
  7094. return delegate->clone(parent);
  7095. }
  7096. /*:631*//*632:*/
  7097. #line 13561 "./typica.w"
  7098. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  7099. const QModelIndex&index)const
  7100. {
  7101. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7102. self->setCurrentIndex(self->findData(
  7103. index.model()->data(index,
  7104. Qt::UserRole).toString()));
  7105. }
  7106. /*:632*//*633:*/
  7107. #line 13574 "./typica.w"
  7108. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  7109. QAbstractItemModel*model,
  7110. const QModelIndex&index)const
  7111. {
  7112. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7113. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  7114. Qt::UserRole);
  7115. model->setData(index,self->currentText(),Qt::DisplayRole);
  7116. }
  7117. /*:633*//*634:*/
  7118. #line 13587 "./typica.w"
  7119. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  7120. const QStyleOptionViewItem&option,
  7121. const QModelIndex&)const
  7122. {
  7123. editor->setGeometry(option.rect);
  7124. }
  7125. /*:634*//*635:*/
  7126. #line 13598 "./typica.w"
  7127. QSize SqlComboBoxDelegate::sizeHint()const
  7128. {
  7129. return delegate->sizeHint();
  7130. }
  7131. /*:635*//*636:*/
  7132. #line 13606 "./typica.w"
  7133. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  7134. :QItemDelegate(parent)
  7135. {
  7136. }
  7137. /*:636*/
  7138. #line 563 "./typica.w"
  7139. /*598:*/
  7140. #line 12853 "./typica.w"
  7141. Application::Application(int&argc,char**argv):QApplication(argc,argv),
  7142. connectionStatus(false),currentUser(QString())
  7143. {
  7144. /*599:*/
  7145. #line 12869 "./typica.w"
  7146. setOrganizationName("Wilson's Coffee & Tea");
  7147. setOrganizationDomain("wilsonscoffee.com");
  7148. setApplicationName(PROGRAM_NAME);
  7149. /*:599*/
  7150. #line 12857 "./typica.w"
  7151. /*600:*/
  7152. #line 12878 "./typica.w"
  7153. QTranslator*base= new QTranslator;
  7154. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7155. {
  7156. installTranslator(base);
  7157. }
  7158. QTranslator*app= new QTranslator;
  7159. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7160. {
  7161. installTranslator(app);
  7162. }
  7163. /*:600*/
  7164. #line 12858 "./typica.w"
  7165. /*307:*/
  7166. #line 123 "./measurement.w"
  7167. qRegisterMetaType<Measurement> ("Measurement");
  7168. /*:307*/
  7169. #line 12859 "./typica.w"
  7170. /*813:*/
  7171. #line 16896 "./typica.w"
  7172. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  7173. tr("NI DAQmx Base"),
  7174. "nidaqmxbase",NULL);
  7175. topLevelNodeInserters.append(inserter);
  7176. /*:813*//*821:*/
  7177. #line 17127 "./typica.w"
  7178. #ifdef Q_OS_WIN32
  7179. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  7180. topLevelNodeInserters.append(inserter);
  7181. #endif
  7182. /*:821*//*845:*/
  7183. #line 18094 "./typica.w"
  7184. #if 0
  7185. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7186. topLevelNodeInserters.append(inserter);
  7187. #endif
  7188. /*:845*//*894:*/
  7189. #line 19607 "./typica.w"
  7190. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7191. topLevelNodeInserters.append(inserter);
  7192. #line 1 "./modbus.w"
  7193. /*:894*//*900:*/
  7194. #line 328 "./modbus.w"
  7195. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7196. topLevelNodeInserters.append(inserter);
  7197. /*:900*//*916:*/
  7198. #line 272 "./unsupportedserial.w"
  7199. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7200. "unsupporteddevice",NULL);
  7201. topLevelNodeInserters.append(inserter);
  7202. /*:916*//*947:*/
  7203. #line 190 "./phidgets.w"
  7204. QLibrary phidgetsCheck("phidget21");
  7205. if(phidgetsCheck.load())
  7206. {
  7207. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7208. "phidgets1048",NULL);
  7209. topLevelNodeInserters.append(inserter);
  7210. phidgetsCheck.unload();
  7211. }
  7212. else
  7213. {
  7214. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7215. if(phidgetsCheck.load())
  7216. {
  7217. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7218. "phidgets1048",NULL);
  7219. topLevelNodeInserters.append(inserter);
  7220. phidgetsCheck.unload();
  7221. }
  7222. }
  7223. /*:947*//*1052:*/
  7224. #line 1241 "./dataqsdk.w"
  7225. #ifdef Q_OS_WIN32
  7226. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7227. "dataqsdk",NULL);
  7228. topLevelNodeInserters.append(inserter);
  7229. #endif
  7230. #line 20276 "./typica.w"
  7231. #line 1 "./scales.w"
  7232. /*:1052*//*1077:*/
  7233. #line 557 "./scales.w"
  7234. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7235. topLevelNodeInserters.append(inserter);
  7236. #line 20278 "./typica.w"
  7237. #line 1 "./valueannotation.w"
  7238. /*:1077*/
  7239. #line 12860 "./typica.w"
  7240. }
  7241. /*:598*//*602:*/
  7242. #line 12901 "./typica.w"
  7243. QDomDocument*Application::configuration()
  7244. {
  7245. return&conf;
  7246. }
  7247. /*:602*//*603:*/
  7248. #line 12910 "./typica.w"
  7249. QSqlDatabase Application::database()
  7250. {
  7251. QString connectionName;
  7252. QSqlDatabase connection=
  7253. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7254. do
  7255. {
  7256. connectionName= QUuid::createUuid().toString();
  7257. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7258. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7259. }
  7260. /*:603*//*604:*/
  7261. #line 12926 "./typica.w"
  7262. void Application::setDatabaseConnected(bool status)
  7263. {
  7264. connectionStatus= status;
  7265. }
  7266. bool Application::databaseConnected()
  7267. {
  7268. return connectionStatus;
  7269. }
  7270. /*:604*//*748:*/
  7271. #line 15429 "./typica.w"
  7272. void Application::saveDeviceConfiguration()
  7273. {
  7274. QSettings settings;
  7275. settings.setValue("DeviceConfiguration",
  7276. QVariant(deviceConfigurationDocument.toByteArray()));
  7277. }
  7278. /*:748*//*749:*/
  7279. #line 15441 "./typica.w"
  7280. QDomDocument Application::deviceConfiguration()
  7281. {
  7282. if(deviceConfigurationDocument.isNull())
  7283. {
  7284. /*750:*/
  7285. #line 15455 "./typica.w"
  7286. QSettings settings;
  7287. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7288. QString etext;
  7289. int eline;
  7290. int ecol;
  7291. if(document.length()==0)
  7292. {
  7293. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7294. /*751:*/
  7295. #line 15479 "./typica.w"
  7296. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7297. emptyDocument.open(QIODevice::ReadOnly);
  7298. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7299. &etext,&eline,&ecol))
  7300. {
  7301. /*752:*/
  7302. #line 15496 "./typica.w"
  7303. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7304. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7305. qDebug()<<etext;
  7306. /*:752*/
  7307. #line 15485 "./typica.w"
  7308. }
  7309. else
  7310. {
  7311. saveDeviceConfiguration();
  7312. }
  7313. /*:751*/
  7314. #line 15464 "./typica.w"
  7315. }
  7316. else
  7317. {
  7318. if(!deviceConfigurationDocument.setContent(document,false,
  7319. &etext,&eline,&ecol))
  7320. {
  7321. /*752:*/
  7322. #line 15496 "./typica.w"
  7323. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7324. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7325. qDebug()<<etext;
  7326. /*:752*/
  7327. #line 15471 "./typica.w"
  7328. /*751:*/
  7329. #line 15479 "./typica.w"
  7330. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7331. emptyDocument.open(QIODevice::ReadOnly);
  7332. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7333. &etext,&eline,&ecol))
  7334. {
  7335. /*752:*/
  7336. #line 15496 "./typica.w"
  7337. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7338. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7339. qDebug()<<etext;
  7340. /*:752*/
  7341. #line 15485 "./typica.w"
  7342. }
  7343. else
  7344. {
  7345. saveDeviceConfiguration();
  7346. }
  7347. /*:751*/
  7348. #line 15472 "./typica.w"
  7349. }
  7350. }
  7351. /*:750*/
  7352. #line 15446 "./typica.w"
  7353. }
  7354. return deviceConfigurationDocument;
  7355. }
  7356. /*:749*//*780:*/
  7357. #line 16097 "./typica.w"
  7358. void Application::registerDeviceConfigurationWidget(QString driver,
  7359. QMetaObject widget)
  7360. {
  7361. deviceConfigurationWidgets.insert(driver,widget);
  7362. }
  7363. /*:780*//*781:*/
  7364. #line 16113 "./typica.w"
  7365. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7366. const QModelIndex&index)
  7367. {
  7368. QVariant nodeReference= index.data(Qt::UserRole);
  7369. QDomElement referenceElement= model->referenceElement(
  7370. model->data(index,Qt::UserRole).toString());
  7371. QMetaObject metaObject=
  7372. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7373. QWidget::staticMetaObject);
  7374. QWidget*editor;
  7375. if(metaObject.className()==QWidget::staticMetaObject.className())
  7376. {
  7377. editor= NULL;
  7378. }
  7379. else
  7380. {
  7381. editor= qobject_cast<QWidget*> (
  7382. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7383. Q_ARG(QModelIndex,index)));
  7384. }
  7385. return editor;
  7386. }
  7387. /*:781*//*1107:*/
  7388. #line 16 "./user.w"
  7389. QString Application::currentTypicaUser()
  7390. {
  7391. return currentUser;
  7392. }
  7393. /*:1107*//*1108:*/
  7394. #line 26 "./user.w"
  7395. void Application::setCurrentTypicaUser(const QString&user)
  7396. {
  7397. currentUser= user;
  7398. emit userChanged(currentUser);
  7399. }
  7400. /*:1108*//*1109:*/
  7401. #line 37 "./user.w"
  7402. bool Application::login(const QString&user,const QString&password)
  7403. {
  7404. SqlQueryConnection h;
  7405. QSqlQuery*dbquery= h.operator->();
  7406. dbquery->prepare("SELECT 1 FROM typica_users WHERE name = :name AND password = :password AND active = TRUE");
  7407. dbquery->bindValue(":name",user);
  7408. dbquery->bindValue(":password",password);
  7409. dbquery->exec();
  7410. if(dbquery->next())
  7411. {
  7412. currentUser= user;
  7413. emit userChanged(currentUser);
  7414. return true;
  7415. }
  7416. return false;
  7417. }
  7418. /*:1109*//*1110:*/
  7419. #line 58 "./user.w"
  7420. bool Application::autoLogin()
  7421. {
  7422. SqlQueryConnection h;
  7423. QSqlQuery*dbquery= h.operator->();
  7424. dbquery->exec("SELECT name FROM typica_users WHERE auto_login = TRUE");
  7425. if(dbquery->next())
  7426. {
  7427. currentUser= dbquery->value(0).toString();
  7428. emit userChanged(currentUser);
  7429. return true;
  7430. }
  7431. return false;
  7432. }
  7433. /*:1110*/
  7434. #line 564 "./typica.w"
  7435. /*645:*/
  7436. #line 13754 "./typica.w"
  7437. SqlConnectionSetup::SqlConnectionSetup():
  7438. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7439. portnumber(new QLineEdit),
  7440. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7441. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7442. cancelButton(new QPushButton(tr("Cancel"))),
  7443. connectButton(new QPushButton(tr("Connect")))
  7444. {
  7445. QSettings settings;
  7446. driver->addItem("PostgreSQL","QPSQL");
  7447. formLayout->addRow(tr("Database driver:"),driver);
  7448. formLayout->addRow(tr("Host name:"),hostname);
  7449. hostname->setText(settings.value("database/hostname").toString());
  7450. formLayout->addRow(tr("Port number:"),portnumber);
  7451. portnumber->setText(settings.value("database/portnumber","5432").toString());
  7452. formLayout->addRow(tr("Database name:"),dbname);
  7453. dbname->setText(settings.value("database/dbname").toString());
  7454. formLayout->addRow(tr("User name:"),user);
  7455. user->setText(settings.value("database/user").toString());
  7456. password->setEchoMode(QLineEdit::Password);
  7457. formLayout->addRow(tr("Password:"),password);
  7458. password->setText(settings.value("database/password").toString());
  7459. layout->addLayout(formLayout);
  7460. buttons->addStretch(1);
  7461. buttons->addWidget(cancelButton);
  7462. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7463. buttons->addWidget(connectButton);
  7464. layout->addLayout(buttons);
  7465. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7466. connectButton->setDefault(true);
  7467. setLayout(layout);
  7468. setModal(true);
  7469. }
  7470. SqlConnectionSetup::~SqlConnectionSetup()
  7471. {
  7472. }
  7473. /*:645*//*646:*/
  7474. #line 13797 "./typica.w"
  7475. void SqlConnectionSetup::testConnection()
  7476. {
  7477. QSqlDatabase database=
  7478. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7479. toString());
  7480. database.setConnectOptions("application_name=Typica");
  7481. database.setHostName(hostname->text());
  7482. database.setPort(portnumber->text().toInt());
  7483. database.setDatabaseName(dbname->text());
  7484. database.setUserName(user->text());
  7485. database.setPassword(password->text());
  7486. if(database.open())
  7487. {
  7488. QSettings settings;
  7489. settings.setValue("database/exists","true");
  7490. settings.setValue("database/driver",
  7491. driver->itemData(driver->currentIndex()).toString());
  7492. settings.setValue("database/hostname",hostname->text());
  7493. settings.setValue("database/portnumber",portnumber->text());
  7494. settings.setValue("database/dbname",dbname->text());
  7495. settings.setValue("database/user",user->text());
  7496. settings.setValue("database/password",password->text());
  7497. database.close();
  7498. AppInstance->setDatabaseConnected(true);
  7499. accept();
  7500. }
  7501. else
  7502. {
  7503. QMessageBox::information(this,tr("Database connection failed"),
  7504. tr("Failed to connect to database."));
  7505. }
  7506. }
  7507. /*:646*/
  7508. #line 565 "./typica.w"
  7509. /*650:*/
  7510. #line 13904 "./typica.w"
  7511. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7512. {
  7513. setModel(new QSqlQueryModel);
  7514. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7515. this,SLOT(openRow(QModelIndex)));
  7516. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7517. this,SLOT(persistColumnResize(int,int,int)));
  7518. }
  7519. /*:650*//*651:*/
  7520. #line 13919 "./typica.w"
  7521. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7522. {
  7523. /*652:*/
  7524. #line 13928 "./typica.w"
  7525. QSettings settings;
  7526. /*653:*/
  7527. #line 13941 "./typica.w"
  7528. QWidget*topLevelWidget= this;
  7529. while(topLevelWidget->parentWidget())
  7530. {
  7531. topLevelWidget= topLevelWidget->parentWidget();
  7532. }
  7533. /*:653*/
  7534. #line 13930 "./typica.w"
  7535. settings.setValue(QString("columnWidths/%1/%2/%3").
  7536. arg(topLevelWidget->objectName()).
  7537. arg(objectName()).arg(column),
  7538. QVariant(newsize));
  7539. /*:652*/
  7540. #line 13922 "./typica.w"
  7541. }
  7542. /*:651*//*654:*/
  7543. #line 13951 "./typica.w"
  7544. void SqlQueryView::showEvent(QShowEvent*event)
  7545. {
  7546. /*655:*/
  7547. #line 13961 "./typica.w"
  7548. QSettings settings;
  7549. /*653:*/
  7550. #line 13941 "./typica.w"
  7551. QWidget*topLevelWidget= this;
  7552. while(topLevelWidget->parentWidget())
  7553. {
  7554. topLevelWidget= topLevelWidget->parentWidget();
  7555. }
  7556. /*:653*/
  7557. #line 13963 "./typica.w"
  7558. QString baseKey=
  7559. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7560. arg(objectName());
  7561. for(int i= 0;i<model()->columnCount();i++)
  7562. {
  7563. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7564. if(settings.contains(key))
  7565. {
  7566. setColumnWidth(i,settings.value(key).toInt());
  7567. }
  7568. }
  7569. /*:655*/
  7570. #line 13954 "./typica.w"
  7571. event->accept();
  7572. }
  7573. /*:654*//*656:*/
  7574. #line 13978 "./typica.w"
  7575. void SqlQueryView::openRow(const QModelIndex&index)
  7576. {
  7577. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7578. emit openEntryRow(index.row());
  7579. }
  7580. /*:656*//*657:*/
  7581. #line 13987 "./typica.w"
  7582. void SqlQueryView::setQuery(const QString&query)
  7583. {
  7584. QSqlDatabase database= AppInstance->database();
  7585. database.open();
  7586. QSqlQuery q(query,database);
  7587. ((QSqlQueryModel*)model())->setQuery(q);
  7588. database.close();
  7589. }
  7590. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7591. const QVariant&value,int role)
  7592. {
  7593. return model()->setHeaderData(section,orientation,value,role);
  7594. }
  7595. /*:657*//*658:*/
  7596. #line 14005 "./typica.w"
  7597. QVariant SqlQueryView::data(int row,int column,int role)
  7598. {
  7599. return model()->data(model()->index(row,column),role);
  7600. }
  7601. /*:658*/
  7602. #line 566 "./typica.w"
  7603. /*173:*/
  7604. #line 4007 "./typica.w"
  7605. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7606. {
  7607. QSqlDatabase database= AppInstance->database();
  7608. database.open();
  7609. q= new QSqlQuery(query,database);
  7610. connection= database.connectionName();
  7611. }
  7612. /*:173*//*174:*/
  7613. #line 4020 "./typica.w"
  7614. SqlQueryConnection::~SqlQueryConnection()
  7615. {
  7616. delete q;
  7617. {
  7618. QSqlDatabase database= QSqlDatabase::database(connection);
  7619. database.close();
  7620. }
  7621. QSqlDatabase::removeDatabase(connection);
  7622. }
  7623. /*:174*//*175:*/
  7624. #line 4034 "./typica.w"
  7625. QSqlQuery*SqlQueryConnection::operator->()const
  7626. {
  7627. return q;
  7628. }
  7629. /*:175*/
  7630. #line 567 "./typica.w"
  7631. /*677:*/
  7632. #line 14364 "./typica.w"
  7633. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7634. area(frame),configuration(description)
  7635. {
  7636. refresh();
  7637. }
  7638. ReportTable::~ReportTable()
  7639. {
  7640. }
  7641. /*:677*//*678:*/
  7642. #line 14380 "./typica.w"
  7643. void ReportTable::bind(QString placeholder,QVariant value)
  7644. {
  7645. bindings.insert(placeholder,value);
  7646. }
  7647. /*:678*//*679:*/
  7648. #line 14390 "./typica.w"
  7649. void ReportTable::refresh()
  7650. {
  7651. /*680:*/
  7652. #line 14411 "./typica.w"
  7653. QTextCursor cursor= area->firstCursorPosition();
  7654. while(cursor<area->lastCursorPosition())
  7655. {
  7656. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7657. }
  7658. cursor.removeSelectedText();
  7659. /*:680*/
  7660. #line 14393 "./typica.w"
  7661. int rows= 1;
  7662. int columns= 1;
  7663. int currentRow= 0;
  7664. QTextTable*table= cursor.insertTable(rows,columns);
  7665. /*681:*/
  7666. #line 14424 "./typica.w"
  7667. QTextTableFormat format= table->format();
  7668. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7669. if(configuration.hasAttribute("align"))
  7670. {
  7671. if(configuration.attribute("align")=="center")
  7672. {
  7673. format.setAlignment(Qt::AlignHCenter);
  7674. }
  7675. }
  7676. table->setFormat(format);
  7677. /*:681*/
  7678. #line 14398 "./typica.w"
  7679. /*682:*/
  7680. #line 14438 "./typica.w"
  7681. QDomNodeList children= configuration.childNodes();
  7682. for(int i= 0;i<children.count();i++)
  7683. {
  7684. QDomNode current;
  7685. QDomElement currentElement;
  7686. current= children.at(i);
  7687. if(current.isElement())
  7688. {
  7689. currentElement= current.toElement();
  7690. if(currentElement.tagName()=="query")
  7691. {
  7692. /*683:*/
  7693. #line 14465 "./typica.w"
  7694. SqlQueryConnection h;
  7695. QSqlQuery*query= h.operator->();
  7696. query->prepare(currentElement.text());
  7697. foreach(QString key,bindings.uniqueKeys())
  7698. {
  7699. if(currentElement.text().contains(key))
  7700. {
  7701. query->bindValue(key,bindings.value(key));
  7702. }
  7703. }
  7704. query->exec();
  7705. if(!query->next())
  7706. {
  7707. continue;
  7708. }
  7709. if(query->record().count()> columns)
  7710. {
  7711. table->appendColumns(query->record().count()-columns);
  7712. }
  7713. do
  7714. {
  7715. table->appendRows(1);
  7716. rows++;
  7717. currentRow++;
  7718. for(int j= 0;j<query->record().count();j++)
  7719. {
  7720. QTextTableCell cell= table->cellAt(currentRow,j);
  7721. cursor= cell.firstCursorPosition();
  7722. cursor.insertText(query->value(j).toString());
  7723. }
  7724. }while(query->next());
  7725. /*:683*/
  7726. #line 14450 "./typica.w"
  7727. }
  7728. else if(currentElement.tagName()=="row")
  7729. {
  7730. /*684:*/
  7731. #line 14505 "./typica.w"
  7732. table->appendRows(1);
  7733. currentRow++;
  7734. rows++;
  7735. QDomNodeList rowChildren= currentElement.childNodes();
  7736. int currentColumn= 0;
  7737. for(int j= 0;j<rowChildren.count();j++)
  7738. {
  7739. QDomNode node;
  7740. QDomElement nodeElement;
  7741. node= rowChildren.at(j);
  7742. if(node.isElement())
  7743. {
  7744. nodeElement= node.toElement();
  7745. if(nodeElement.tagName()=="cell")
  7746. {
  7747. if(currentColumn==columns)
  7748. {
  7749. table->appendColumns(1);
  7750. columns++;
  7751. }
  7752. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7753. cursor= cell.firstCursorPosition();
  7754. cursor.insertText(nodeElement.text());
  7755. currentColumn++;
  7756. }
  7757. }
  7758. }
  7759. /*:684*/
  7760. #line 14454 "./typica.w"
  7761. }
  7762. }
  7763. }
  7764. /*:682*/
  7765. #line 14399 "./typica.w"
  7766. if(rows> 1)
  7767. {
  7768. table->removeRows(0,1);
  7769. }
  7770. }
  7771. /*:679*/
  7772. #line 568 "./typica.w"
  7773. /*716:*/
  7774. #line 14611 "./typica.w"
  7775. FormArray::FormArray(QDomElement description):configuration(description),
  7776. maxwidth(-1),maxheight(-1)
  7777. {
  7778. setWidget(&itemContainer);
  7779. itemContainer.setLayout(&itemLayout);
  7780. }
  7781. /*:716*//*717:*/
  7782. #line 14628 "./typica.w"
  7783. void FormArray::addElements(int copies)
  7784. {
  7785. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7786. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7787. QWidget*widget;
  7788. for(int i= 0;i<copies;i++)
  7789. {
  7790. widget= new QWidget;
  7791. if(maxwidth> -1)
  7792. {
  7793. widget->setMaximumWidth(maxwidth);
  7794. }
  7795. if(maxheight> -1)
  7796. {
  7797. widget->setMaximumHeight(maxheight);
  7798. }
  7799. if(configuration.hasChildNodes())
  7800. {
  7801. widgetStack->push(widget);
  7802. populateWidget(configuration,widgetStack,layoutStack);
  7803. widgetStack->pop();
  7804. widget->setMinimumHeight(widget->sizeHint().height());
  7805. itemLayout.addWidget(widget);
  7806. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7807. {
  7808. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7809. }
  7810. else
  7811. {
  7812. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7813. +widget->sizeHint().height());
  7814. }
  7815. if(maxwidth> -1)
  7816. {
  7817. itemContainer.setMinimumWidth(maxwidth+50);
  7818. }
  7819. else
  7820. {
  7821. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7822. }
  7823. }
  7824. }
  7825. }
  7826. /*:717*//*718:*/
  7827. #line 14678 "./typica.w"
  7828. QWidget*FormArray::elementAt(int index)
  7829. {
  7830. if(index<itemLayout.count())
  7831. {
  7832. QLayoutItem*item= itemLayout.itemAt(index);
  7833. return item->widget();
  7834. }
  7835. else
  7836. {
  7837. return NULL;
  7838. }
  7839. }
  7840. /*:718*//*719:*/
  7841. #line 14695 "./typica.w"
  7842. void FormArray::removeAllElements()
  7843. {
  7844. while(itemLayout.count()> 0)
  7845. {
  7846. QLayoutItem*item;
  7847. item= itemLayout.itemAt(0);
  7848. item->widget()->hide();
  7849. itemLayout.removeWidget(item->widget());
  7850. }
  7851. itemContainer.setMinimumHeight(0);
  7852. }
  7853. /*:719*//*720:*/
  7854. #line 14711 "./typica.w"
  7855. int FormArray::elements()
  7856. {
  7857. return itemLayout.count();
  7858. }
  7859. /*:720*//*721:*/
  7860. #line 14722 "./typica.w"
  7861. void FormArray::setMaximumElementWidth(int width)
  7862. {
  7863. maxwidth= width;
  7864. }
  7865. void FormArray::setMaximumElementHeight(int height)
  7866. {
  7867. maxheight= height;
  7868. }
  7869. /*:721*/
  7870. #line 569 "./typica.w"
  7871. /*727:*/
  7872. #line 14853 "./typica.w"
  7873. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7874. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7875. {
  7876. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7877. QPointF(0,5);
  7878. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7879. QPointF(10,5);
  7880. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7881. QPointF(0,0);
  7882. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7883. initialBrush.setColor(QColor(170,170,255));
  7884. initialBrush.setStyle(Qt::SolidPattern);
  7885. finalBrush.setColor(Qt::blue);
  7886. finalBrush.setStyle(Qt::SolidPattern);
  7887. initialDecrement.setPolygon(left);
  7888. initialDecrement.setBrush(initialBrush);
  7889. initialDecrement.setPos(0,0);
  7890. scene.addItem(&initialDecrement);
  7891. initialIncrement.setPolygon(right);
  7892. initialIncrement.setBrush(initialBrush);
  7893. initialIncrement.setPos(122,0);
  7894. scene.addItem(&initialIncrement);
  7895. finalDecrement.setPolygon(left);
  7896. finalDecrement.setBrush(finalBrush);
  7897. finalDecrement.setPos(0,12);
  7898. scene.addItem(&finalDecrement);
  7899. finalIncrement.setPolygon(right);
  7900. finalIncrement.setBrush(finalBrush);
  7901. finalIncrement.setPos(122,12);
  7902. scene.addItem(&finalIncrement);
  7903. scalePath.moveTo(0,10);
  7904. scalePath.lineTo(100,10);
  7905. scalePath.moveTo(0,0);
  7906. scalePath.lineTo(0,20);
  7907. scalePath.moveTo(10,5);
  7908. scalePath.lineTo(10,15);
  7909. scalePath.moveTo(20,5);
  7910. scalePath.lineTo(20,15);
  7911. scalePath.moveTo(30,5);
  7912. scalePath.lineTo(30,15);
  7913. scalePath.moveTo(40,5);
  7914. scalePath.lineTo(40,15);
  7915. scalePath.moveTo(50,0);
  7916. scalePath.lineTo(50,20);
  7917. scalePath.moveTo(60,5);
  7918. scalePath.lineTo(60,15);
  7919. scalePath.moveTo(70,5);
  7920. scalePath.lineTo(70,15);
  7921. scalePath.moveTo(80,5);
  7922. scalePath.lineTo(80,15);
  7923. scalePath.moveTo(90,5);
  7924. scalePath.lineTo(90,15);
  7925. scalePath.moveTo(100,0);
  7926. scalePath.lineTo(100,20);
  7927. scaleLine.setPath(scalePath);
  7928. scaleLine.setPos(16,1);
  7929. scene.addItem(&scaleLine);
  7930. setScene(&scene);
  7931. initialIndicator.setPolygon(down);
  7932. initialIndicator.setBrush(initialBrush);
  7933. finalIndicator.setPolygon(up);
  7934. finalIndicator.setBrush(finalBrush);
  7935. setMinimumSize(sizeHint());
  7936. setMaximumSize(sizeHint());
  7937. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7938. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7939. setMinimumSize(sizeHint());
  7940. }
  7941. /*:727*//*728:*/
  7942. #line 14926 "./typica.w"
  7943. QSize ScaleControl::sizeHint()const
  7944. {
  7945. return QSize(140,30);
  7946. }
  7947. /*:728*//*729:*/
  7948. #line 14935 "./typica.w"
  7949. void ScaleControl::setInitialValue(double value)
  7950. {
  7951. if(value>=0&&value<=10)
  7952. {
  7953. nonScoredValue= value;
  7954. if(!initialSet)
  7955. {
  7956. scene.addItem(&initialIndicator);
  7957. }
  7958. initialSet= true;
  7959. initialIndicator.setPos(value*10+16,10);
  7960. emit initialChanged(value);
  7961. if(!finalSet)
  7962. {
  7963. setFinalValue(value);
  7964. }
  7965. }
  7966. }
  7967. void ScaleControl::setFinalValue(double value)
  7968. {
  7969. if(value>=0&&value<=10)
  7970. {
  7971. scoredValue= value;
  7972. if(!finalSet)
  7973. {
  7974. scene.addItem(&finalIndicator);
  7975. }
  7976. finalSet= true;
  7977. finalIndicator.setPos(value*10+16,11);
  7978. emit finalChanged(value);
  7979. }
  7980. }
  7981. /*:729*//*730:*/
  7982. #line 14972 "./typica.w"
  7983. double ScaleControl::initialValue(void)
  7984. {
  7985. return nonScoredValue;
  7986. }
  7987. double ScaleControl::finalValue(void)
  7988. {
  7989. return scoredValue;
  7990. }
  7991. /*:730*//*731:*/
  7992. #line 14993 "./typica.w"
  7993. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7994. {
  7995. /*732:*/
  7996. #line 15005 "./typica.w"
  7997. if(event->button()!=Qt::LeftButton)
  7998. {
  7999. event->ignore();
  8000. return;
  8001. }
  8002. /*:732*/
  8003. #line 14996 "./typica.w"
  8004. scaleDown= true;
  8005. event->accept();
  8006. }
  8007. /*:731*//*733:*/
  8008. #line 15016 "./typica.w"
  8009. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  8010. {
  8011. /*732:*/
  8012. #line 15005 "./typica.w"
  8013. if(event->button()!=Qt::LeftButton)
  8014. {
  8015. event->ignore();
  8016. return;
  8017. }
  8018. /*:732*/
  8019. #line 15019 "./typica.w"
  8020. if(!scaleDown)
  8021. {
  8022. event->ignore();
  8023. return;
  8024. }
  8025. scaleDown= false;
  8026. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8027. /*734:*/
  8028. #line 15041 "./typica.w"
  8029. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  8030. {
  8031. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8032. {
  8033. if(initialSet)
  8034. {
  8035. setInitialValue(nonScoredValue-0.05);
  8036. }
  8037. event->accept();
  8038. return;
  8039. }
  8040. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8041. {
  8042. if(finalSet)
  8043. {
  8044. setFinalValue(scoredValue-0.05);
  8045. event->accept();
  8046. return;
  8047. }
  8048. }
  8049. }
  8050. /*:734*/
  8051. #line 15027 "./typica.w"
  8052. /*735:*/
  8053. #line 15067 "./typica.w"
  8054. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  8055. {
  8056. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8057. {
  8058. if(initialSet)
  8059. {
  8060. setInitialValue(nonScoredValue+0.05);
  8061. event->accept();
  8062. return;
  8063. }
  8064. }
  8065. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8066. {
  8067. if(finalSet)
  8068. {
  8069. setFinalValue(scoredValue+0.05);
  8070. event->accept();
  8071. return;
  8072. }
  8073. }
  8074. }
  8075. /*:735*/
  8076. #line 15028 "./typica.w"
  8077. /*736:*/
  8078. #line 15093 "./typica.w"
  8079. double relativeX= sceneCoordinate.x()-16;
  8080. if(initialSet)
  8081. {
  8082. if(relativeX>=0&&relativeX<=100)
  8083. {
  8084. setFinalValue(relativeX/10.0);
  8085. event->accept();
  8086. return;
  8087. }
  8088. }
  8089. else
  8090. {
  8091. if(relativeX>=0&&relativeX<=100)
  8092. {
  8093. setInitialValue(relativeX/10.0);
  8094. event->accept();
  8095. return;
  8096. }
  8097. }
  8098. /*:736*/
  8099. #line 15029 "./typica.w"
  8100. event->ignore();
  8101. return;
  8102. }
  8103. /*:733*/
  8104. #line 570 "./typica.w"
  8105. /*738:*/
  8106. #line 15159 "./typica.w"
  8107. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  8108. valueSet(false),scaleDown(false)
  8109. {
  8110. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8111. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8112. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  8113. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  8114. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  8115. theBrush.setColor(Qt::blue);
  8116. theBrush.setStyle(Qt::SolidPattern);
  8117. increment.setPolygon(up);
  8118. increment.setBrush(theBrush);
  8119. increment.setPos(0,0);
  8120. scene.addItem(&increment);
  8121. decrement.setPolygon(down);
  8122. decrement.setBrush(theBrush);
  8123. decrement.setPos(0,122);
  8124. scene.addItem(&decrement);
  8125. scalePath.moveTo(5,0);
  8126. scalePath.lineTo(5,100);
  8127. scalePath.moveTo(0,0);
  8128. scalePath.lineTo(10,0);
  8129. scalePath.moveTo(0,10);
  8130. scalePath.lineTo(10,10);
  8131. scalePath.moveTo(0,20);
  8132. scalePath.lineTo(10,20);
  8133. scalePath.moveTo(0,30);
  8134. scalePath.lineTo(10,30);
  8135. scalePath.moveTo(0,40);
  8136. scalePath.lineTo(10,40);
  8137. scalePath.moveTo(0,50);
  8138. scalePath.lineTo(10,50);
  8139. scalePath.moveTo(0,60);
  8140. scalePath.lineTo(10,60);
  8141. scalePath.moveTo(0,70);
  8142. scalePath.lineTo(10,70);
  8143. scalePath.moveTo(0,80);
  8144. scalePath.lineTo(10,80);
  8145. scalePath.moveTo(0,90);
  8146. scalePath.lineTo(10,90);
  8147. scalePath.moveTo(0,100);
  8148. scalePath.lineTo(10,100);
  8149. scaleLine.setPath(scalePath);
  8150. scaleLine.setPos(0,16);
  8151. scene.addItem(&scaleLine);
  8152. setScene(&scene);
  8153. indicator.setPolygon(left);
  8154. indicator.setBrush(theBrush);
  8155. setMinimumSize(sizeHint());
  8156. setMaximumSize(sizeHint());
  8157. }
  8158. /*:738*//*739:*/
  8159. #line 15214 "./typica.w"
  8160. QSize IntensityControl::sizeHint()const
  8161. {
  8162. return QSize(25,160);
  8163. }
  8164. /*:739*//*740:*/
  8165. #line 15229 "./typica.w"
  8166. void IntensityControl::setValue(double val)
  8167. {
  8168. if(val>=0&&val<=10)
  8169. {
  8170. theValue= val;
  8171. if(!valueSet)
  8172. {
  8173. scene.addItem(&indicator);
  8174. }
  8175. valueSet= true;
  8176. indicator.setPos(6,(100-(val*10))+16);
  8177. emit(valueChanged(val));
  8178. }
  8179. else if(val<1)
  8180. {
  8181. setValue(0);
  8182. }
  8183. else
  8184. {
  8185. setValue(10);
  8186. }
  8187. }
  8188. double IntensityControl::value()
  8189. {
  8190. return theValue;
  8191. }
  8192. /*:740*//*741:*/
  8193. #line 15261 "./typica.w"
  8194. void IntensityControl::mousePressEvent(QMouseEvent*event)
  8195. {
  8196. /*732:*/
  8197. #line 15005 "./typica.w"
  8198. if(event->button()!=Qt::LeftButton)
  8199. {
  8200. event->ignore();
  8201. return;
  8202. }
  8203. /*:732*/
  8204. #line 15264 "./typica.w"
  8205. scaleDown= true;
  8206. event->accept();
  8207. }
  8208. /*:741*//*742:*/
  8209. #line 15275 "./typica.w"
  8210. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  8211. {
  8212. /*732:*/
  8213. #line 15005 "./typica.w"
  8214. if(event->button()!=Qt::LeftButton)
  8215. {
  8216. event->ignore();
  8217. return;
  8218. }
  8219. /*:732*/
  8220. #line 15278 "./typica.w"
  8221. if(!scaleDown)
  8222. {
  8223. event->ignore();
  8224. return;
  8225. }
  8226. scaleDown= false;
  8227. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8228. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  8229. {
  8230. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8231. {
  8232. if(valueSet)
  8233. {
  8234. setValue(theValue+0.05);
  8235. }
  8236. event->accept();
  8237. return;
  8238. }
  8239. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  8240. {
  8241. if(valueSet)
  8242. {
  8243. setValue(theValue-0.05);
  8244. }
  8245. event->accept();
  8246. return;
  8247. }
  8248. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8249. {
  8250. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8251. event->accept();
  8252. return;
  8253. }
  8254. }
  8255. }
  8256. /*:742*/
  8257. #line 571 "./typica.w"
  8258. /*376:*/
  8259. #line 8454 "./typica.w"
  8260. void ThresholdDetector::newMeasurement(Measurement measure)
  8261. {
  8262. if((currentDirection==Ascending&&previousValue<threshold&&
  8263. previousValueValid)||(currentDirection==Descending&&
  8264. previousValue> threshold&&previousValueValid))
  8265. {
  8266. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8267. (currentDirection==Descending&&measure.temperature()<=threshold))
  8268. {
  8269. double offset= measure.time().hour()*60*60;
  8270. offset+= measure.time().minute()*60;
  8271. offset+= measure.time().second();
  8272. offset+= measure.time().msec()/1000;
  8273. emit timeForValue(offset);
  8274. }
  8275. }
  8276. previousValue= measure.temperature();
  8277. previousValueValid= true;
  8278. }
  8279. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8280. previousValueValid(false),
  8281. previousValue(-1),threshold(value),currentDirection(Ascending)
  8282. {
  8283. }
  8284. void ThresholdDetector::setThreshold(double value)
  8285. {
  8286. threshold= value;
  8287. }
  8288. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8289. {
  8290. currentDirection= direction;
  8291. }
  8292. /*:376*/
  8293. #line 572 "./typica.w"
  8294. /*824:*/
  8295. #line 17167 "./typica.w"
  8296. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8297. lister(new QextSerialEnumerator)
  8298. {
  8299. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8300. QextPortInfo port;
  8301. foreach(port,ports)
  8302. {
  8303. #ifdef Q_OS_WIN32
  8304. addItem(port.portName);
  8305. #else
  8306. addItem(port.physName);
  8307. #endif
  8308. }
  8309. lister->setUpNotifications();
  8310. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8311. this,SLOT(addDevice(QextPortInfo)));
  8312. setEditable(true);
  8313. }
  8314. void PortSelector::addDevice(QextPortInfo port)
  8315. {
  8316. addItem(port.portName);
  8317. }
  8318. /*:824*/
  8319. #line 573 "./typica.w"
  8320. /*826:*/
  8321. #line 17259 "./typica.w"
  8322. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8323. {
  8324. QMetaObject meta= BaudSelector::staticMetaObject;
  8325. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8326. for(int i= 0;i<type.keyCount();i++)
  8327. {
  8328. addItem(QString("%1").arg(type.value(i)));
  8329. }
  8330. }
  8331. /*:826*/
  8332. #line 574 "./typica.w"
  8333. /*828:*/
  8334. #line 17297 "./typica.w"
  8335. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8336. {
  8337. QMetaObject meta= ParitySelector::staticMetaObject;
  8338. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8339. for(int i= 0;i<type.keyCount();i++)
  8340. {
  8341. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8342. }
  8343. }
  8344. /*:828*/
  8345. #line 575 "./typica.w"
  8346. /*830:*/
  8347. #line 17327 "./typica.w"
  8348. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8349. {
  8350. QMetaObject meta= FlowSelector::staticMetaObject;
  8351. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8352. for(int i= 0;i<type.keyCount();i++)
  8353. {
  8354. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8355. }
  8356. }
  8357. /*:830*/
  8358. #line 576 "./typica.w"
  8359. /*832:*/
  8360. #line 17362 "./typica.w"
  8361. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8362. {
  8363. QMetaObject meta= StopSelector::staticMetaObject;
  8364. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8365. for(int i= 0;i<type.keyCount();i++)
  8366. {
  8367. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8368. }
  8369. }
  8370. /*:832*/
  8371. #line 577 "./typica.w"
  8372. /*892:*/
  8373. #line 19148 "./typica.w"
  8374. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8375. :BasicDeviceConfigurationWidget(model,index),
  8376. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8377. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8378. decimalQuery(new QCheckBox(tr("Enable"))),
  8379. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8380. unitQuery(new QCheckBox(tr("Enable"))),
  8381. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8382. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8383. pVAddress(new ShortHexSpinBox),
  8384. sVEnabled(new QCheckBox(tr("Enable"))),
  8385. sVReadAddress(new ShortHexSpinBox),
  8386. deviceLimit(new QCheckBox(tr("Enable"))),
  8387. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8388. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8389. sVWritable(new QCheckBox(tr("Enable"))),
  8390. sVOutputAddr(new ShortHexSpinBox),
  8391. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8392. {
  8393. QHBoxLayout*layout= new QHBoxLayout;
  8394. QWidget*form= new QWidget;
  8395. QHBoxLayout*masterLayout= new QHBoxLayout;
  8396. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8397. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8398. QFormLayout*serialSection= new QFormLayout;
  8399. serialSection->addRow(QString(tr("Port:")),port);
  8400. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8401. serialSection->addRow(QString(tr("Parity:")),parity);
  8402. serialSection->addRow(QString(tr("Flow control:")),flow);
  8403. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8404. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8405. serialSectionBox->setLayout(serialSection);
  8406. portAndDeviceLayout->addWidget(serialSectionBox);
  8407. QFormLayout*deviceSection= new QFormLayout;
  8408. station->setMinimum(1);
  8409. station->setMaximum(255);
  8410. decimalPosition->setMinimum(0);
  8411. decimalPosition->setMaximum(9);
  8412. valueF->setMinimum(0);
  8413. valueF->setMaximum(0xFFFF);
  8414. valueC->setMinimum(0);
  8415. valueC->setMaximum(0xFFFF);
  8416. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8417. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8418. deviceSection->addRow(tr("Station:"),station);
  8419. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8420. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8421. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8422. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8423. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8424. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8425. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8426. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8427. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8428. deviceSectionBox->setLayout(deviceSection);
  8429. portAndDeviceLayout->addWidget(deviceSectionBox);
  8430. QFormLayout*pVSection= new QFormLayout;
  8431. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8432. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8433. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8434. pVSection->addRow(pVHideBox);
  8435. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8436. processValueBox->setLayout(pVSection);
  8437. seriesLayout->addWidget(processValueBox);
  8438. QFormLayout*sVSection= new QFormLayout;
  8439. sVLower->setDecimals(1);
  8440. sVLower->setMinimum(0.0);
  8441. sVLower->setMaximum(999.9);
  8442. sVUpper->setDecimals(1);
  8443. sVUpper->setMinimum(0.0);
  8444. sVUpper->setMaximum(999.9);
  8445. sVSection->addRow(tr("Set value:"),sVEnabled);
  8446. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8447. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8448. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8449. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8450. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8451. sVSection->addRow(tr("Lower limit:"),sVLower);
  8452. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8453. sVSection->addRow(tr("Output set value:"),sVWritable);
  8454. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8455. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8456. sVSection->addRow(sVHideBox);
  8457. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8458. setValueBox->setLayout(sVSection);
  8459. seriesLayout->addWidget(setValueBox);
  8460. masterLayout->addLayout(portAndDeviceLayout);
  8461. masterLayout->addLayout(seriesLayout);
  8462. form->setLayout(masterLayout);
  8463. /*800:*/
  8464. #line 16608 "./typica.w"
  8465. QDomElement referenceElement=
  8466. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8467. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8468. QDomElement node;
  8469. /*:800*/
  8470. #line 19238 "./typica.w"
  8471. for(int i= 0;i<configData.size();i++)
  8472. {
  8473. node= configData.at(i).toElement();
  8474. if(node.attribute("name")=="port")
  8475. {
  8476. QString portname= node.attribute("value");
  8477. int idx= port->findText(portname);
  8478. if(idx>=0)
  8479. {
  8480. port->setCurrentIndex(idx);
  8481. }
  8482. else
  8483. {
  8484. port->addItem(portname);
  8485. }
  8486. }
  8487. else if(node.attribute("name")=="baud")
  8488. {
  8489. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8490. }
  8491. else if(node.attribute("name")=="parity")
  8492. {
  8493. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8494. }
  8495. else if(node.attribute("name")=="flow")
  8496. {
  8497. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8498. }
  8499. else if(node.attribute("name")=="stop")
  8500. {
  8501. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8502. }
  8503. else if(node.attribute("name")=="station")
  8504. {
  8505. station->setValue(node.attribute("value").toInt());
  8506. }
  8507. else if(node.attribute("name")=="decimalQuery")
  8508. {
  8509. if(node.attribute("value")=="true")
  8510. {
  8511. decimalQuery->setChecked(true);
  8512. }
  8513. else
  8514. {
  8515. decimalQuery->setChecked(false);
  8516. }
  8517. }
  8518. else if(node.attribute("name")=="decimalAddress")
  8519. {
  8520. decimalAddress->setValue(node.attribute("value").toInt());
  8521. }
  8522. else if(node.attribute("name")=="decimalPosition")
  8523. {
  8524. decimalPosition->setValue(node.attribute("value").toInt());
  8525. }
  8526. else if(node.attribute("name")=="unitQuery")
  8527. {
  8528. if(node.attribute("value")=="true")
  8529. {
  8530. unitQuery->setChecked(true);
  8531. }
  8532. else
  8533. {
  8534. unitQuery->setChecked(false);
  8535. }
  8536. }
  8537. else if(node.attribute("name")=="unitAddress")
  8538. {
  8539. unitAddress->setValue(node.attribute("value").toInt());
  8540. }
  8541. else if(node.attribute("name")=="valueF")
  8542. {
  8543. valueF->setValue(node.attribute("value").toInt());
  8544. }
  8545. else if(node.attribute("name")=="valueC")
  8546. {
  8547. valueC->setValue(node.attribute("value").toInt());
  8548. }
  8549. else if(node.attribute("name")=="fixedUnit")
  8550. {
  8551. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8552. }
  8553. else if(node.attribute("name")=="pVAddress")
  8554. {
  8555. pVAddress->setValue(node.attribute("value").toInt());
  8556. }
  8557. else if(node.attribute("name")=="sVEnabled")
  8558. {
  8559. if(node.attribute("value")=="true")
  8560. {
  8561. sVEnabled->setChecked(true);
  8562. }
  8563. else
  8564. {
  8565. sVEnabled->setChecked(false);
  8566. }
  8567. }
  8568. else if(node.attribute("name")=="sVReadAddress")
  8569. {
  8570. sVReadAddress->setValue(node.attribute("value").toInt());
  8571. }
  8572. else if(node.attribute("name")=="deviceLimit")
  8573. {
  8574. if(node.attribute("value")=="true")
  8575. {
  8576. deviceLimit->setChecked(true);
  8577. }
  8578. else
  8579. {
  8580. deviceLimit->setChecked(false);
  8581. }
  8582. }
  8583. else if(node.attribute("name")=="sVLowerAddr")
  8584. {
  8585. sVLowerAddr->setValue(node.attribute("value").toInt());
  8586. }
  8587. else if(node.attribute("name")=="sVUpperAddr")
  8588. {
  8589. sVUpperAddr->setValue(node.attribute("value").toInt());
  8590. }
  8591. else if(node.attribute("name")=="sVLower")
  8592. {
  8593. sVLower->setValue(node.attribute("value").toDouble());
  8594. }
  8595. else if(node.attribute("name")=="sVUpper")
  8596. {
  8597. sVUpper->setValue(node.attribute("value").toDouble());
  8598. }
  8599. else if(node.attribute("name")=="sVWritable")
  8600. {
  8601. if(node.attribute("value")=="true")
  8602. {
  8603. sVWritable->setChecked(true);
  8604. }
  8605. else
  8606. {
  8607. sVWritable->setChecked(false);
  8608. }
  8609. }
  8610. else if(node.attribute("name")=="sVOutputAddr")
  8611. {
  8612. sVOutputAddr->setValue(node.attribute("value").toInt());
  8613. }
  8614. else if(node.attribute("name")=="pvcolname")
  8615. {
  8616. pVColumnName->setText(node.attribute("value"));
  8617. }
  8618. else if(node.attribute("name")=="svcolname")
  8619. {
  8620. sVColumnName->setText(node.attribute("value"));
  8621. }
  8622. else if(node.attribute("name")=="pvhidden")
  8623. {
  8624. pVHideBox->setChecked(node.attribute("value")=="true");
  8625. }
  8626. else if(node.attribute("name")=="svhidden")
  8627. {
  8628. sVHideBox->setChecked(node.attribute("value")=="true");
  8629. }
  8630. }
  8631. updatePort(port->currentText());
  8632. updateBaudRate(baud->currentText());
  8633. updateParity(parity->itemData(parity->currentIndex()).toString());
  8634. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8635. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8636. updateStation(station->value());
  8637. updateFixedDecimal(decimalQuery->isChecked());
  8638. updateDecimalAddress(decimalAddress->value());
  8639. updateDecimalPosition(decimalPosition->value());
  8640. updateFixedUnit(unitQuery->isChecked());
  8641. updateUnitAddress(unitAddress->value());
  8642. updateValueForF(valueF->value());
  8643. updateValueForC(valueC->value());
  8644. updateUnit(fixedUnit->currentText());
  8645. updatePVAddress(pVAddress->value());
  8646. updateSVEnabled(sVEnabled->isChecked());
  8647. updateSVReadAddress(sVReadAddress->value());
  8648. updateDeviceLimit(deviceLimit->isChecked());
  8649. updateSVLowerAddress(sVLowerAddr->value());
  8650. updateSVUpperAddress(sVUpperAddr->value());
  8651. updateSVLower(sVLower->value());
  8652. updateSVUpper(sVUpper->value());
  8653. updateSVWritable(sVWritable->isChecked());
  8654. updateSVWriteAddress(sVOutputAddr->value());
  8655. updatePVColumnName(pVColumnName->text());
  8656. updateSVColumnName(sVColumnName->text());
  8657. updatePVHidden(pVHideBox->isChecked());
  8658. updateSVHidden(sVHideBox->isChecked());
  8659. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8660. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8661. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8662. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8663. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8664. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8665. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8666. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8667. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8668. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8669. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8670. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8671. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8672. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8673. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8674. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8675. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8676. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8677. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8678. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8679. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8680. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8681. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8682. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8683. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8684. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8685. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8686. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8687. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8688. layout->addWidget(form);
  8689. setLayout(layout);
  8690. }
  8691. void ModbusConfigurator::updatePort(const QString&newPort)
  8692. {
  8693. updateAttribute("port",newPort);
  8694. }
  8695. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8696. {
  8697. updateAttribute("baud",newRate);
  8698. }
  8699. void ModbusConfigurator::updateParity(const QString&)
  8700. {
  8701. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8702. }
  8703. void ModbusConfigurator::updateFlowControl(const QString&)
  8704. {
  8705. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8706. }
  8707. void ModbusConfigurator::updateStopBits(const QString&)
  8708. {
  8709. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8710. }
  8711. void ModbusConfigurator::updateStation(int station)
  8712. {
  8713. updateAttribute("station",QString("%1").arg(station));
  8714. }
  8715. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8716. {
  8717. updateAttribute("decimalQuery",fixed?"true":"false");
  8718. }
  8719. void ModbusConfigurator::updateDecimalAddress(int address)
  8720. {
  8721. updateAttribute("decimalAddress",QString("%1").arg(address));
  8722. }
  8723. void ModbusConfigurator::updateDecimalPosition(int position)
  8724. {
  8725. updateAttribute("decimalPosition",QString("%1").arg(position));
  8726. }
  8727. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8728. {
  8729. updateAttribute("unitQuery",fixed?"true":"false");
  8730. }
  8731. void ModbusConfigurator::updateUnitAddress(int address)
  8732. {
  8733. updateAttribute("unitAddress",QString("%1").arg(address));
  8734. }
  8735. void ModbusConfigurator::updateValueForF(int value)
  8736. {
  8737. updateAttribute("valueF",QString("%1").arg(value));
  8738. }
  8739. void ModbusConfigurator::updateValueForC(int value)
  8740. {
  8741. updateAttribute("valueC",QString("%1").arg(value));
  8742. }
  8743. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8744. {
  8745. updateAttribute("fixedUnit",newUnit);
  8746. }
  8747. void ModbusConfigurator::updatePVAddress(int address)
  8748. {
  8749. updateAttribute("pVAddress",QString("%1").arg(address));
  8750. }
  8751. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8752. {
  8753. updateAttribute("sVEnabled",enabled?"true":"false");
  8754. }
  8755. void ModbusConfigurator::updateSVReadAddress(int address)
  8756. {
  8757. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8758. }
  8759. void ModbusConfigurator::updateDeviceLimit(bool query)
  8760. {
  8761. updateAttribute("deviceLimit",query?"true":"false");
  8762. }
  8763. void ModbusConfigurator::updateSVLowerAddress(int address)
  8764. {
  8765. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8766. }
  8767. void ModbusConfigurator::updateSVUpperAddress(int address)
  8768. {
  8769. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8770. }
  8771. void ModbusConfigurator::updateSVLower(double value)
  8772. {
  8773. updateAttribute("sVLower",QString("%1").arg(value));
  8774. }
  8775. void ModbusConfigurator::updateSVUpper(double value)
  8776. {
  8777. updateAttribute("sVUpper",QString("%1").arg(value));
  8778. }
  8779. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8780. {
  8781. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8782. }
  8783. void ModbusConfigurator::updateSVWriteAddress(int address)
  8784. {
  8785. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8786. }
  8787. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8788. {
  8789. updateAttribute("pvcolname",name);
  8790. }
  8791. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8792. {
  8793. updateAttribute("svcolname",name);
  8794. }
  8795. void ModbusConfigurator::updatePVHidden(bool hidden)
  8796. {
  8797. updateAttribute("pvhidden",hidden?"true":"false");
  8798. }
  8799. void ModbusConfigurator::updateSVHidden(bool hidden)
  8800. {
  8801. updateAttribute("svhidden",hidden?"true":"false");
  8802. }
  8803. /*:892*/
  8804. #line 578 "./typica.w"
  8805. /*835:*/
  8806. #line 17415 "./typica.w"
  8807. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8808. {
  8809. setMinimum(0);
  8810. setMaximum(0xFFFF);
  8811. setPrefix("0x");
  8812. setMinimumWidth(65);
  8813. }
  8814. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8815. {
  8816. if(input.size()==2)
  8817. {
  8818. return QValidator::Intermediate;
  8819. }
  8820. bool okay;
  8821. input.toInt(&okay,16);
  8822. if(okay)
  8823. {
  8824. return QValidator::Acceptable;
  8825. }
  8826. return QValidator::Invalid;
  8827. }
  8828. int ShortHexSpinBox::valueFromText(const QString&text)const
  8829. {
  8830. return text.toInt(NULL,16);
  8831. }
  8832. QString ShortHexSpinBox::textFromValue(int value)const
  8833. {
  8834. QString retval;
  8835. retval.setNum(value,16);
  8836. while(retval.size()<4)
  8837. {
  8838. retval.prepend("0");
  8839. }
  8840. return retval.toUpper();
  8841. }
  8842. /*:835*/
  8843. #line 579 "./typica.w"
  8844. /*876:*/
  8845. #line 18447 "./typica.w"
  8846. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8847. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8848. waiting(false)
  8849. {
  8850. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8851. Qt::UserRole).toString());
  8852. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8853. QDomElement node;
  8854. QVariantMap attributes;
  8855. for(int i= 0;i<portConfigData.size();i++)
  8856. {
  8857. node= portConfigData.at(i).toElement();
  8858. attributes.insert(node.attribute("name"),node.attribute("value"));
  8859. }
  8860. port= new QextSerialPort(attributes.value("port").toString(),
  8861. QextSerialPort::EventDriven);
  8862. int baudRate= attributes.value("baud").toInt();
  8863. port->setBaudRate((BaudRateType)baudRate);
  8864. double temp= ((double)(1)/(double)(baudRate))*48;
  8865. delayTime= (int)(temp*3000);
  8866. messageDelayTimer->setSingleShot(true);
  8867. commTimeout->setSingleShot(true);
  8868. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8869. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8870. port->setDataBits(DATA_8);
  8871. port->setParity((ParityType)attributes.value("parity").toInt());
  8872. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8873. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8874. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8875. port->open(QIODevice::ReadWrite);
  8876. station= (char)attributes.value("station").toInt();
  8877. if(attributes.value("decimalQuery")=="true")
  8878. {
  8879. decimalPosition= 0;
  8880. QByteArray message;
  8881. message.append(station);
  8882. message.append((char)0x03);
  8883. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8884. char*addressBytes= (char*)&address;
  8885. message.append(addressBytes[1]);
  8886. message.append(addressBytes[0]);
  8887. message.append((char)0x00);
  8888. message.append((char)0x01);
  8889. queueMessage(message,this,"decimalResponse(QByteArray)");
  8890. }
  8891. else
  8892. {
  8893. decimalPosition= attributes.value("decimalPosition").toInt();
  8894. }
  8895. valueF= attributes.value("valueF").toInt();
  8896. valueC= attributes.value("valueC").toInt();
  8897. if(attributes.value("unitQuery")=="true")
  8898. {
  8899. QByteArray message;
  8900. message.append(station);
  8901. message.append((char)0x03);
  8902. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8903. char*addressBytes= (char*)&address;
  8904. message.append(addressBytes[1]);
  8905. message.append(addressBytes[0]);
  8906. message.append((char)0x00);
  8907. message.append((char)0x01);
  8908. queueMessage(message,this,"unitResponse(QByteArray)");
  8909. }
  8910. else
  8911. {
  8912. if(attributes.value("fixedUnit")=="Celsius")
  8913. {
  8914. unitIsF= false;
  8915. }
  8916. }
  8917. if(attributes.value("sVWritable")=="true")
  8918. {
  8919. if(attributes.value("deviceLimit")=="true")
  8920. {
  8921. QByteArray lmessage;
  8922. lmessage.append(station);
  8923. lmessage.append((char)0x03);
  8924. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8925. char*addressBytes= (char*)&laddress;
  8926. lmessage.append(addressBytes[1]);
  8927. lmessage.append(addressBytes[0]);
  8928. lmessage.append((char)0x00);
  8929. lmessage.append((char)0x01);
  8930. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8931. QByteArray umessage;
  8932. umessage.append(station);
  8933. umessage.append((char)0x03);
  8934. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8935. addressBytes= (char*)&uaddress;
  8936. umessage.append(addressBytes[1]);
  8937. umessage.append(addressBytes[0]);
  8938. umessage.append((char)0x00);
  8939. umessage.append((char)0x01);
  8940. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8941. }
  8942. else
  8943. {
  8944. outputSVLower= attributes.value("sVLower").toDouble();
  8945. outputSVUpper= attributes.value("sVUpper").toDouble();
  8946. }
  8947. outputSVStub.append(station);
  8948. outputSVStub.append((char)0x06);
  8949. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8950. char*addressBytes= (char*)&address;
  8951. outputSVStub.append(addressBytes[1]);
  8952. outputSVStub.append(addressBytes[0]);
  8953. }
  8954. Channel*pv= new Channel;
  8955. channels.append(pv);
  8956. pvStub.append(station);
  8957. pvStub.append((char)0x04);
  8958. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8959. char*pvac= (char*)&pvaddress;
  8960. pvStub.append(pvac[1]);
  8961. pvStub.append(pvac[0]);
  8962. pvStub.append((char)0x00);
  8963. pvStub.append((char)0x01);
  8964. svenabled= attributes.value("sVEnabled").toBool();
  8965. if(svenabled)
  8966. {
  8967. Channel*sv= new Channel;
  8968. channels.append(sv);
  8969. svStub.append(station);
  8970. svStub.append((char)0x04);
  8971. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8972. char*svac= (char*)&svaddress;
  8973. svStub.append(svac[1]);
  8974. svStub.append(svac[0]);
  8975. svStub.append((char)0x00);
  8976. svStub.append((char)0x01);
  8977. if(svaddress-pvaddress==1)
  8978. {
  8979. mStub.append(station);
  8980. mStub.append((char)0x04);
  8981. mStub.append(pvac[1]);
  8982. mStub.append(pvac[0]);
  8983. mStub.append((char)0x00);
  8984. mStub.append((char)0x02);
  8985. }
  8986. }
  8987. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8988. requestMeasurement();
  8989. }
  8990. double ModbusRTUDevice::SVLower()
  8991. {
  8992. return outputSVLower;
  8993. }
  8994. double ModbusRTUDevice::SVUpper()
  8995. {
  8996. return outputSVUpper;
  8997. }
  8998. int ModbusRTUDevice::decimals()
  8999. {
  9000. return decimalPosition;
  9001. }
  9002. void ModbusRTUDevice::decimalResponse(QByteArray response)
  9003. {
  9004. quint16 temp;
  9005. char*tchar= (char*)&temp;
  9006. tchar[1]= response.at(3);
  9007. tchar[0]= response.at(4);
  9008. decimalPosition= temp;
  9009. emit SVDecimalChanged(decimalPosition);
  9010. qDebug()<<"Received decimal response";
  9011. }
  9012. void ModbusRTUDevice::unitResponse(QByteArray response)
  9013. {
  9014. quint16 temp;
  9015. char*tchar= (char*)&temp;
  9016. tchar[1]= response.at(3);
  9017. tchar[0]= response.at(4);
  9018. int value= temp;
  9019. if(value==valueF)
  9020. {
  9021. unitIsF= true;
  9022. }
  9023. else
  9024. {
  9025. unitIsF= false;
  9026. }
  9027. qDebug()<<"Received unit response";
  9028. }
  9029. void ModbusRTUDevice::svlResponse(QByteArray response)
  9030. {
  9031. quint16 temp;
  9032. char*tchar= (char*)&temp;
  9033. tchar[1]= response.at(3);
  9034. tchar[0]= response.at(4);
  9035. outputSVLower= (double)temp;
  9036. for(int i= 0;i<decimalPosition;i++)
  9037. {
  9038. outputSVLower/= 10;
  9039. }
  9040. emit SVLowerChanged(outputSVLower);
  9041. qDebug()<<"Received set value lower bound response";
  9042. }
  9043. void ModbusRTUDevice::svuResponse(QByteArray response)
  9044. {
  9045. quint16 temp;
  9046. char*tchar= (char*)&temp;
  9047. tchar[1]= response.at(3);
  9048. tchar[0]= response.at(4);
  9049. outputSVUpper= (double)temp;
  9050. for(int i= 0;i<decimalPosition;i++)
  9051. {
  9052. outputSVUpper/= 10;
  9053. }
  9054. emit SVUpperChanged(outputSVUpper);
  9055. qDebug()<<"Received set value upper bound response";
  9056. }
  9057. void ModbusRTUDevice::requestMeasurement()
  9058. {
  9059. if(mStub.length()> 0)
  9060. {
  9061. queueMessage(mStub,this,"mResponse(QByteArray)");
  9062. }
  9063. else
  9064. {
  9065. queueMessage(pvStub,this,"mResponse(QByteArray)");
  9066. if(svenabled)
  9067. {
  9068. queueMessage(svStub,this,"mResponse(QByteArray)");
  9069. }
  9070. }
  9071. }
  9072. void ModbusRTUDevice::mResponse(QByteArray response)
  9073. {
  9074. QTime time= QTime::currentTime();
  9075. if(response.at(2)==0x04)
  9076. {
  9077. /*877:*/
  9078. #line 18701 "./typica.w"
  9079. quint16 pv;
  9080. quint16 sv;
  9081. char*pvBytes= (char*)&pv;
  9082. char*svBytes= (char*)&sv;
  9083. pvBytes[1]= response.at(3);
  9084. pvBytes[0]= response.at(4);
  9085. svBytes[1]= response.at(5);
  9086. svBytes[0]= response.at(6);
  9087. double pvOut= (double)pv;
  9088. double svOut= (double)sv;
  9089. for(int i= 0;i<decimalPosition;i++)
  9090. {
  9091. pvOut/= 10;
  9092. svOut/= 10;
  9093. }
  9094. if(!unitIsF)
  9095. {
  9096. pvOut= pvOut*9/5+32;
  9097. svOut= svOut*9/5+32;
  9098. }
  9099. Measurement pvm(pvOut,time,Units::Fahrenheit);
  9100. Measurement svm(svOut,time,Units::Fahrenheit);
  9101. channels.at(0)->input(pvm);
  9102. channels.at(1)->input(svm);
  9103. /*:877*/
  9104. #line 18688 "./typica.w"
  9105. }
  9106. else
  9107. {
  9108. /*878:*/
  9109. #line 18731 "./typica.w"
  9110. quint16 value;
  9111. char*valueBytes= (char*)&value;
  9112. valueBytes[1]= response.at(3);
  9113. valueBytes[0]= response.at(4);
  9114. double valueOut= (double)value;
  9115. for(int i= 0;i<decimalPosition;i++)
  9116. {
  9117. valueOut/= 10;
  9118. }
  9119. if(!unitIsF)
  9120. {
  9121. valueOut= valueOut*9/5+32;
  9122. }
  9123. if(!svenabled)
  9124. {
  9125. Measurement vm(valueOut,time,Units::Fahrenheit);
  9126. channels.at(0)->input(vm);
  9127. }
  9128. else
  9129. {
  9130. if(readingsv)
  9131. {
  9132. Measurement pvm(savedpv,time,Units::Fahrenheit);
  9133. Measurement svm(valueOut,time,Units::Fahrenheit);
  9134. channels.at(0)->input(pvm);
  9135. channels.at(1)->input(svm);
  9136. readingsv= false;
  9137. }
  9138. else
  9139. {
  9140. savedpv= valueOut;
  9141. readingsv= true;
  9142. }
  9143. }
  9144. /*:878*/
  9145. #line 18692 "./typica.w"
  9146. }
  9147. }
  9148. /*:876*//*879:*/
  9149. #line 18769 "./typica.w"
  9150. ModbusRTUDevice::~ModbusRTUDevice()
  9151. {
  9152. commTimeout->stop();
  9153. messageDelayTimer->stop();
  9154. port->close();
  9155. }
  9156. /*:879*//*880:*/
  9157. #line 18796 "./typica.w"
  9158. void ModbusRTUDevice::dataAvailable()
  9159. {
  9160. if(messageDelayTimer->isActive())
  9161. {
  9162. messageDelayTimer->stop();
  9163. }
  9164. responseBuffer.append(port->readAll());
  9165. /*881:*/
  9166. #line 18842 "./typica.w"
  9167. if(responseBuffer.size()<5)
  9168. {
  9169. return;
  9170. }
  9171. switch(responseBuffer.at(1))
  9172. {
  9173. case 0x01:
  9174. case 0x02:
  9175. if(responseBuffer.size()<6)
  9176. {
  9177. return;
  9178. }
  9179. responseBuffer= responseBuffer.left(6);
  9180. break;
  9181. case 0x03:
  9182. case 0x04:
  9183. if(responseBuffer.size()<5+responseBuffer.at(2))
  9184. {
  9185. return;
  9186. }
  9187. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  9188. break;
  9189. case 0x05:
  9190. case 0x06:
  9191. case 0x10:
  9192. if(responseBuffer.size()<8)
  9193. {
  9194. return;
  9195. }
  9196. responseBuffer= responseBuffer.left(8);
  9197. break;
  9198. }
  9199. /*:881*/
  9200. #line 18804 "./typica.w"
  9201. commTimeout->stop();
  9202. if(calculateCRC(responseBuffer)==0)
  9203. {
  9204. QObject*object= retObjQueue.at(0);
  9205. char*method= callbackQueue.at(0);
  9206. QMetaMethod metamethod= object->metaObject()->
  9207. method(object->metaObject()->
  9208. indexOfMethod(QMetaObject::normalizedSignature(method)));
  9209. metamethod.invoke(object,Qt::QueuedConnection,
  9210. Q_ARG(QByteArray,responseBuffer));
  9211. messageQueue.removeAt(0);
  9212. retObjQueue.removeAt(0);
  9213. callbackQueue.removeAt(0);
  9214. }
  9215. else
  9216. {
  9217. qDebug()<<"CRC failed";
  9218. }
  9219. messageDelayTimer->start(delayTime);
  9220. waiting= false;
  9221. responseBuffer.clear();
  9222. }
  9223. /*:880*//*882:*/
  9224. #line 18884 "./typica.w"
  9225. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  9226. {
  9227. quint16 retval= 0xFFFF;
  9228. int i= 0;
  9229. while(i<data.size())
  9230. {
  9231. retval^= 0x00FF&(quint16)data.at(i);
  9232. for(int j= 0;j<8;j++)
  9233. {
  9234. if(retval&1)
  9235. {
  9236. retval= (retval>>1)^0xA001;
  9237. }
  9238. else
  9239. {
  9240. retval>>= 1;
  9241. }
  9242. }
  9243. i++;
  9244. }
  9245. return retval;
  9246. }
  9247. /*:882*//*883:*/
  9248. #line 18915 "./typica.w"
  9249. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9250. const char*callback)
  9251. {
  9252. messageQueue.append(request);
  9253. retObjQueue.append(object);
  9254. callbackQueue.append(const_cast<char*> (callback));
  9255. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9256. {
  9257. sendNextMessage();
  9258. }
  9259. }
  9260. void ModbusRTUDevice::sendNextMessage()
  9261. {
  9262. if(messageQueue.size()> 0&&!waiting)
  9263. {
  9264. QByteArray message= messageQueue.at(0);
  9265. quint16 crc= calculateCRC(message);
  9266. char*check= (char*)&crc;
  9267. message.append(check[0]);
  9268. message.append(check[1]);
  9269. qDebug()<<"Writing"<<message.toHex();
  9270. port->write(message);
  9271. commTimeout->start(2000);
  9272. messageDelayTimer->start(delayTime);
  9273. waiting= true;
  9274. }
  9275. else
  9276. {
  9277. emit queueEmpty();
  9278. }
  9279. }
  9280. void ModbusRTUDevice::outputSV(double value)
  9281. {
  9282. for(int i= 0;i<decimalPosition;i++)
  9283. {
  9284. value*= 10;
  9285. }
  9286. quint16 outval= (quint16)value;
  9287. QByteArray message(outputSVStub);
  9288. char*valBytes= (char*)&outval;
  9289. message.append(valBytes[1]);
  9290. message.append(valBytes[0]);
  9291. queueMessage(message,this,"ignore(QByteArray)");
  9292. }
  9293. /*:883*//*884:*/
  9294. #line 18965 "./typica.w"
  9295. void ModbusRTUDevice::ignore(QByteArray)
  9296. {
  9297. return;
  9298. }
  9299. /*:884*//*885:*/
  9300. #line 18978 "./typica.w"
  9301. void ModbusRTUDevice::timeout()
  9302. {
  9303. qDebug()<<"Communications timeout.";
  9304. responseBuffer.clear();
  9305. waiting= false;
  9306. messageDelayTimer->start();
  9307. }
  9308. /*:885*/
  9309. #line 580 "./typica.w"
  9310. /*754:*/
  9311. #line 15533 "./typica.w"
  9312. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9313. DeviceTreeModelNode*parent)
  9314. :domNode(node),rowNumber(row),parentItem(parent)
  9315. {
  9316. }
  9317. DeviceTreeModelNode::~DeviceTreeModelNode()
  9318. {
  9319. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9320. for(i= children.begin();i!=children.end();i++)
  9321. {
  9322. delete i.value();
  9323. }
  9324. }
  9325. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9326. {
  9327. return parentItem;
  9328. }
  9329. int DeviceTreeModelNode::row()
  9330. {
  9331. return rowNumber;
  9332. }
  9333. QDomNode DeviceTreeModelNode::node()const
  9334. {
  9335. return domNode;
  9336. }
  9337. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9338. {
  9339. if(children.contains(index))
  9340. {
  9341. return children[index];
  9342. }
  9343. if(index>=0&&index<domNode.childNodes().count())
  9344. {
  9345. QDomNode childNode= domNode.childNodes().item(index);
  9346. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9347. index,this);
  9348. children[index]= childItem;
  9349. return childItem;
  9350. }
  9351. return NULL;
  9352. }
  9353. /*:754*/
  9354. #line 581 "./typica.w"
  9355. /*756:*/
  9356. #line 15622 "./typica.w"
  9357. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9358. :QAbstractItemModel(parent)
  9359. {
  9360. document= AppInstance->deviceConfiguration();
  9361. QDomNodeList elements= document.elementsByTagName("devices");
  9362. if(elements.size()!=1)
  9363. {
  9364. qDebug()<<"Unexpected result when loading device map.";
  9365. }
  9366. treeRoot= elements.at(0);
  9367. root= new DeviceTreeModelNode(treeRoot,0);
  9368. elements= document.elementsByTagName("references");
  9369. if(elements.size()!=1)
  9370. {
  9371. qDebug()<<"No references section. Creating.";
  9372. referenceSection= document.createElement("references");
  9373. document.appendChild(referenceSection);
  9374. }
  9375. else
  9376. {
  9377. referenceSection= elements.at(0);
  9378. }
  9379. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9380. AppInstance,SLOT(saveDeviceConfiguration()));
  9381. connect(this,SIGNAL(modelReset()),
  9382. AppInstance,SLOT(saveDeviceConfiguration()));
  9383. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9384. AppInstance,SLOT(saveDeviceConfiguration()));
  9385. }
  9386. /*:756*//*757:*/
  9387. #line 15657 "./typica.w"
  9388. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9389. {
  9390. return 1;
  9391. }
  9392. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9393. {
  9394. if(parent.column()> 0)
  9395. {
  9396. return 0;
  9397. }
  9398. /*758:*/
  9399. #line 15676 "./typica.w"
  9400. DeviceTreeModelNode*parentItem;
  9401. if(!parent.isValid())
  9402. {
  9403. parentItem= root;
  9404. }
  9405. else
  9406. {
  9407. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9408. }
  9409. /*:758*/
  9410. #line 15669 "./typica.w"
  9411. return parentItem->node().childNodes().count();
  9412. }
  9413. /*:757*//*759:*/
  9414. #line 15690 "./typica.w"
  9415. QModelIndex DeviceTreeModel::index(int row,int column,
  9416. const QModelIndex&parent)const
  9417. {
  9418. if(!hasIndex(row,column,parent))
  9419. {
  9420. return QModelIndex();
  9421. }
  9422. /*758:*/
  9423. #line 15676 "./typica.w"
  9424. DeviceTreeModelNode*parentItem;
  9425. if(!parent.isValid())
  9426. {
  9427. parentItem= root;
  9428. }
  9429. else
  9430. {
  9431. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9432. }
  9433. /*:758*/
  9434. #line 15698 "./typica.w"
  9435. DeviceTreeModelNode*childItem= parentItem->child(row);
  9436. if(childItem)
  9437. {
  9438. return createIndex(row,column,childItem);
  9439. }
  9440. return QModelIndex();
  9441. }
  9442. /*:759*//*760:*/
  9443. #line 15709 "./typica.w"
  9444. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9445. {
  9446. if(!child.isValid())
  9447. {
  9448. return QModelIndex();
  9449. }
  9450. DeviceTreeModelNode*childItem=
  9451. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9452. DeviceTreeModelNode*parentItem= childItem->parent();
  9453. if(!parentItem||parentItem==root)
  9454. {
  9455. return QModelIndex();
  9456. }
  9457. return createIndex(parentItem->row(),0,parentItem);
  9458. }
  9459. /*:760*//*761:*/
  9460. #line 15728 "./typica.w"
  9461. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9462. {
  9463. if(!index.isValid())
  9464. {
  9465. return 0;
  9466. }
  9467. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9468. }
  9469. /*:761*//*762:*/
  9470. #line 15743 "./typica.w"
  9471. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9472. {
  9473. if(!index.isValid())
  9474. {
  9475. return QVariant();
  9476. }
  9477. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9478. {
  9479. return QVariant();
  9480. }
  9481. DeviceTreeModelNode*item=
  9482. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9483. QDomNode node= item->node();
  9484. QDomElement element= node.toElement();
  9485. switch(role)
  9486. {
  9487. case Qt::DisplayRole:
  9488. case Qt::EditRole:
  9489. return QVariant(element.attribute("name"));
  9490. case Qt::UserRole:
  9491. return QVariant(element.attribute("reference"));
  9492. default:
  9493. return QVariant();
  9494. }
  9495. return QVariant();
  9496. }
  9497. /*:762*//*763:*/
  9498. #line 15775 "./typica.w"
  9499. bool DeviceTreeModel::setData(const QModelIndex&index,
  9500. const QVariant&value,int)
  9501. {
  9502. if(!index.isValid())
  9503. {
  9504. return false;
  9505. }
  9506. DeviceTreeModelNode*item=
  9507. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9508. QDomNode node= item->node();
  9509. QDomElement element= node.toElement();
  9510. element.setAttribute("name",value.toString());
  9511. emit dataChanged(index,index);
  9512. return true;
  9513. }
  9514. /*:763*//*764:*/
  9515. #line 15798 "./typica.w"
  9516. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9517. const QModelIndex&parent)
  9518. {
  9519. QString referenceID= QUuid::createUuid().toString();
  9520. /*758:*/
  9521. #line 15676 "./typica.w"
  9522. DeviceTreeModelNode*parentItem;
  9523. if(!parent.isValid())
  9524. {
  9525. parentItem= root;
  9526. }
  9527. else
  9528. {
  9529. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9530. }
  9531. /*:758*/
  9532. #line 15803 "./typica.w"
  9533. QDomNode parentNode= parentItem->node();
  9534. int newRowNumber= rowCount(parent);
  9535. beginInsertRows(parent,newRowNumber,newRowNumber);
  9536. QDomElement deviceElement= document.createElement("node");
  9537. deviceElement.setAttribute("name",name);
  9538. deviceElement.setAttribute("reference",referenceID);
  9539. parentNode.appendChild(deviceElement);
  9540. QDomElement referenceElement= document.createElement("reference");
  9541. referenceElement.setAttribute("id",referenceID);
  9542. referenceElement.setAttribute("driver",driver);
  9543. referenceSection.appendChild(referenceElement);
  9544. endInsertRows();
  9545. }
  9546. /*:764*//*765:*/
  9547. #line 15821 "./typica.w"
  9548. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9549. {
  9550. /*758:*/
  9551. #line 15676 "./typica.w"
  9552. DeviceTreeModelNode*parentItem;
  9553. if(!parent.isValid())
  9554. {
  9555. parentItem= root;
  9556. }
  9557. else
  9558. {
  9559. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9560. }
  9561. /*:758*/
  9562. #line 15824 "./typica.w"
  9563. QDomNode parentNode= parentItem->node();
  9564. QDomNodeList childNodes= parentNode.childNodes();
  9565. if(childNodes.size()<row+count)
  9566. {
  9567. return false;
  9568. }
  9569. beginRemoveRows(parent,row,row+count-1);
  9570. QList<QDomElement> removalList;
  9571. for(int i= row;i<row+count;i++)
  9572. {
  9573. removalList.append(childNodes.at(i).toElement());
  9574. }
  9575. QDomElement element;
  9576. QDomElement reference;
  9577. for(int i= 0;i<count;i++)
  9578. {
  9579. element= removalList.at(i);
  9580. if(element.hasAttribute("reference"))
  9581. {
  9582. reference= referenceElement(element.attribute("reference"));
  9583. if(!reference.isNull())
  9584. {
  9585. referenceSection.removeChild(reference);
  9586. }
  9587. }
  9588. parentNode.removeChild(element);
  9589. }
  9590. endRemoveRows();
  9591. beginResetModel();
  9592. delete root;
  9593. root= new DeviceTreeModelNode(treeRoot,0);
  9594. endResetModel();
  9595. return true;
  9596. }
  9597. /*:765*//*766:*/
  9598. #line 15863 "./typica.w"
  9599. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9600. {
  9601. QDomNodeList childNodes= referenceSection.childNodes();
  9602. QDomElement element;
  9603. for(int i= 0;i<childNodes.size();i++)
  9604. {
  9605. element= childNodes.at(i).toElement();
  9606. if(element.hasAttribute("id"))
  9607. {
  9608. if(element.attribute("id")==id)
  9609. {
  9610. return element;
  9611. }
  9612. }
  9613. }
  9614. return QDomElement();
  9615. }
  9616. /*:766*//*767:*/
  9617. #line 15884 "./typica.w"
  9618. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9619. {
  9620. return QVariant();
  9621. }
  9622. /*:767*//*768:*/
  9623. #line 15893 "./typica.w"
  9624. DeviceTreeModel::~DeviceTreeModel()
  9625. {
  9626. delete root;
  9627. }
  9628. /*:768*/
  9629. #line 582 "./typica.w"
  9630. /*795:*/
  9631. #line 16393 "./typica.w"
  9632. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9633. DeviceTreeModel*model,const QModelIndex&index)
  9634. :QWidget(NULL),deviceModel(model),currentNode(index)
  9635. {
  9636. }
  9637. /*:795*//*796:*/
  9638. #line 16405 "./typica.w"
  9639. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9640. const QString&value)
  9641. {
  9642. QDomElement referenceElement= deviceModel->referenceElement(
  9643. deviceModel->data(currentNode,Qt::UserRole).toString());
  9644. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9645. QDomElement node;
  9646. bool found= false;
  9647. for(int i= 0;i<configData.size();i++)
  9648. {
  9649. node= configData.at(i).toElement();
  9650. if(node.attribute("name")==name)
  9651. {
  9652. node.setAttribute("value",value);
  9653. found= true;
  9654. break;
  9655. }
  9656. }
  9657. if(!found)
  9658. {
  9659. node= AppInstance->deviceConfiguration().createElement("attribute");
  9660. node.setAttribute("name",name);
  9661. node.setAttribute("value",value);
  9662. referenceElement.appendChild(node);
  9663. }
  9664. AppInstance->saveDeviceConfiguration();
  9665. }
  9666. /*:796*//*797:*/
  9667. #line 16439 "./typica.w"
  9668. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9669. const QString&driver)
  9670. {
  9671. deviceModel->newNode(name,driver,currentNode);
  9672. }
  9673. /*:797*/
  9674. #line 583 "./typica.w"
  9675. /*786:*/
  9676. #line 16237 "./typica.w"
  9677. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9678. view(new QTreeView),configArea(new QScrollArea)
  9679. {
  9680. QSplitter*splitter= new QSplitter;
  9681. QWidget*leftWidget= new QWidget;
  9682. leftWidget->setMinimumWidth(200);
  9683. QVBoxLayout*left= new QVBoxLayout;
  9684. view->setAnimated(true);
  9685. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9686. document= AppInstance->deviceConfiguration();
  9687. model= new DeviceTreeModel;
  9688. view->setModel(model);
  9689. view->setTextElideMode(Qt::ElideNone);
  9690. view->expandAll();
  9691. view->resizeColumnToContents(0);
  9692. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9693. QHBoxLayout*treeButtons= new QHBoxLayout;
  9694. QToolButton*addDeviceButton= new QToolButton;
  9695. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9696. addDeviceButton->setToolTip(tr("New Roaster"));
  9697. connect(addDeviceButton,SIGNAL(clicked()),
  9698. this,SLOT(addDevice()));
  9699. QToolButton*removeNodeButton= new QToolButton;
  9700. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9701. removeNodeButton->setToolTip(tr("Delete Selection"));
  9702. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9703. treeButtons->addWidget(addDeviceButton);
  9704. treeButtons->addWidget(removeNodeButton);
  9705. left->addWidget(view);
  9706. left->addLayout(treeButtons);
  9707. leftWidget->setLayout(left);
  9708. splitter->addWidget(leftWidget);
  9709. configArea->setMinimumWidth(580);
  9710. configArea->setMinimumHeight(460);
  9711. configArea->setWidgetResizable(true);
  9712. splitter->addWidget(configArea);
  9713. QVBoxLayout*centralLayout= new QVBoxLayout;
  9714. centralLayout->addWidget(splitter);
  9715. setLayout(centralLayout);
  9716. connect(view,SIGNAL(activated(QModelIndex)),
  9717. this,SLOT(newSelection(QModelIndex)));
  9718. connect(view,SIGNAL(clicked(QModelIndex)),
  9719. this,SLOT(newSelection(QModelIndex)));
  9720. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9721. view,SLOT(expand(QModelIndex)));
  9722. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9723. this,SLOT(resizeColumn()));
  9724. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9725. this,SLOT(resizeColumn()));
  9726. }
  9727. /*:786*//*787:*/
  9728. #line 16292 "./typica.w"
  9729. void DeviceConfigurationWindow::addDevice()
  9730. {
  9731. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9732. }
  9733. /*:787*//*788:*/
  9734. #line 16300 "./typica.w"
  9735. void DeviceConfigurationWindow::removeNode()
  9736. {
  9737. QModelIndex index= view->currentIndex();
  9738. if(index.isValid())
  9739. {
  9740. int row= index.row();
  9741. QModelIndex parent= index.parent();
  9742. model->removeRow(row,parent);
  9743. }
  9744. }
  9745. /*:788*//*789:*/
  9746. #line 16316 "./typica.w"
  9747. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9748. {
  9749. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9750. if(editor)
  9751. {
  9752. configArea->setWidget(editor);
  9753. editor->show();
  9754. }
  9755. }
  9756. /*:789*//*790:*/
  9757. #line 16333 "./typica.w"
  9758. void DeviceConfigurationWindow::resizeColumn()
  9759. {
  9760. view->resizeColumnToContents(0);
  9761. }
  9762. /*:790*/
  9763. #line 584 "./typica.w"
  9764. /*810:*/
  9765. #line 16814 "./typica.w"
  9766. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9767. const QModelIndex&index):
  9768. BasicDeviceConfigurationWidget(model,index)
  9769. {
  9770. QFormLayout*layout= new QFormLayout;
  9771. QLineEdit*columnName= new QLineEdit;
  9772. layout->addRow(tr("Column Name:"),columnName);
  9773. QComboBox*typeSelector= new QComboBox;
  9774. typeSelector->addItem("J");
  9775. typeSelector->addItem("K");
  9776. typeSelector->addItem("T");
  9777. typeSelector->addItem("B");
  9778. typeSelector->addItem("E");
  9779. typeSelector->addItem("N");
  9780. typeSelector->addItem("R");
  9781. typeSelector->addItem("S");
  9782. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9783. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9784. layout->addRow(hideSeries);
  9785. setLayout(layout);
  9786. /*800:*/
  9787. #line 16608 "./typica.w"
  9788. QDomElement referenceElement=
  9789. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9790. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9791. QDomElement node;
  9792. /*:800*/
  9793. #line 16835 "./typica.w"
  9794. for(int i= 0;i<configData.size();i++)
  9795. {
  9796. node= configData.at(i).toElement();
  9797. if(node.attribute("name")=="type")
  9798. {
  9799. typeSelector->setCurrentIndex(
  9800. typeSelector->findText(node.attribute("value")));
  9801. }
  9802. else if(node.attribute("name")=="columnname")
  9803. {
  9804. columnName->setText(node.attribute("value"));
  9805. }
  9806. else if(node.attribute("name")=="hidden")
  9807. {
  9808. hideSeries->setChecked(node.attribute("value")=="true");
  9809. }
  9810. }
  9811. updateThermocoupleType(typeSelector->currentText());
  9812. updateColumnName(columnName->text());
  9813. updateHidden(hideSeries->isChecked());
  9814. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9815. this,SLOT(updateThermocoupleType(QString)));
  9816. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9817. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9818. }
  9819. /*:810*//*811:*/
  9820. #line 16865 "./typica.w"
  9821. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9822. {
  9823. updateAttribute("type",type);
  9824. }
  9825. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9826. {
  9827. updateAttribute("columnname",name);
  9828. }
  9829. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9830. {
  9831. updateAttribute("hidden",hidden?"true":"false");
  9832. }
  9833. /*:811*/
  9834. #line 585 "./typica.w"
  9835. /*806:*/
  9836. #line 16728 "./typica.w"
  9837. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9838. const QModelIndex&index)
  9839. :BasicDeviceConfigurationWidget(model,index)
  9840. {
  9841. QVBoxLayout*layout= new QVBoxLayout;
  9842. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9843. QLabel*label= new QLabel(tr("Device ID:"));
  9844. QLineEdit*deviceId= new QLineEdit;
  9845. deviceIdLayout->addWidget(label);
  9846. deviceIdLayout->addWidget(deviceId);
  9847. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9848. layout->addLayout(deviceIdLayout);
  9849. layout->addWidget(addChannelButton);
  9850. /*800:*/
  9851. #line 16608 "./typica.w"
  9852. QDomElement referenceElement=
  9853. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9854. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9855. QDomElement node;
  9856. /*:800*/
  9857. #line 16742 "./typica.w"
  9858. for(int i= 0;i<configData.size();i++)
  9859. {
  9860. node= configData.at(i).toElement();
  9861. if(node.attribute("name")=="deviceID")
  9862. {
  9863. deviceId->setText(node.attribute("value","Dev1"));
  9864. break;
  9865. }
  9866. }
  9867. updateDeviceId(deviceId->text());
  9868. connect(addChannelButton,SIGNAL(clicked()),
  9869. this,SLOT(addChannel()));
  9870. connect(deviceId,SIGNAL(textEdited(QString)),
  9871. this,SLOT(updateDeviceId(QString)));
  9872. setLayout(layout);
  9873. }
  9874. /*:806*//*807:*/
  9875. #line 16764 "./typica.w"
  9876. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9877. {
  9878. updateAttribute("deviceID",newId);
  9879. }
  9880. /*:807*//*808:*/
  9881. #line 16772 "./typica.w"
  9882. void NiDaqMxBase9211ConfWidget::addChannel()
  9883. {
  9884. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9885. }
  9886. /*:808*/
  9887. #line 586 "./typica.w"
  9888. /*804:*/
  9889. #line 16679 "./typica.w"
  9890. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9891. DeviceTreeModel*model,const QModelIndex&index):
  9892. BasicDeviceConfigurationWidget(model,index)
  9893. {
  9894. QHBoxLayout*layout= new QHBoxLayout;
  9895. QToolButton*addDeviceButton= new QToolButton;
  9896. addDeviceButton->setText(tr("Add Device"));
  9897. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9898. "nidaqmxbase9211series");
  9899. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9900. "nidaqmxbase9211series");
  9901. connect(add9211,SIGNAL(triggered(QString,QString)),
  9902. this,SLOT(insertChildNode(QString,QString)));
  9903. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9904. this,SLOT(insertChildNode(QString,QString)));
  9905. QMenu*deviceMenu= new QMenu;
  9906. deviceMenu->addAction(add9211);
  9907. deviceMenu->addAction(add9211a);
  9908. addDeviceButton->setMenu(deviceMenu);
  9909. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9910. layout->addWidget(addDeviceButton);
  9911. setLayout(layout);
  9912. }
  9913. /*:804*/
  9914. #line 587 "./typica.w"
  9915. /*665:*/
  9916. #line 14151 "./typica.w"
  9917. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9918. QObject*parent):
  9919. QAction(reportName,parent),reportFile(fileName)
  9920. {
  9921. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9922. }
  9923. /*:665*//*666:*/
  9924. #line 14167 "./typica.w"
  9925. void ReportAction::createReport()
  9926. {
  9927. QFile file(reportFile);
  9928. QDomDocument document;
  9929. if(file.open(QIODevice::ReadOnly))
  9930. {
  9931. document.setContent(&file,true);
  9932. QDomElement element= document.documentElement();
  9933. QScriptEngine*engine= AppInstance->engine;
  9934. QScriptContext*context= engine->pushContext();
  9935. QScriptValue object;
  9936. QString targetID= reportFile;
  9937. /*201:*/
  9938. #line 4717 "./typica.w"
  9939. ScriptQMainWindow*window= new ScriptQMainWindow;
  9940. window->setObjectName(targetID);
  9941. object= engine->newQObject(window);
  9942. setQMainWindowProperties(object,engine);
  9943. QWidget*central= new(QWidget);
  9944. central->setParent(window);
  9945. central->setObjectName("centralWidget");
  9946. window->setCentralWidget(central);
  9947. if(element.hasChildNodes())
  9948. {
  9949. /*202:*/
  9950. #line 4753 "./typica.w"
  9951. QStack<QWidget*> widgetStack;
  9952. QStack<QLayout*> layoutStack;
  9953. QString windowScript;
  9954. widgetStack.push(central);
  9955. QDomNodeList windowChildren= element.childNodes();
  9956. int i= 0;
  9957. while(i<windowChildren.count())
  9958. {
  9959. QDomNode current;
  9960. QDomElement element;
  9961. current= windowChildren.at(i);
  9962. if(current.isElement())
  9963. {
  9964. element= current.toElement();
  9965. if(element.tagName()=="program")
  9966. {
  9967. windowScript.append(element.text());
  9968. }
  9969. else if(element.tagName()=="layout")
  9970. {
  9971. element.setAttribute("trcontext","configuration");
  9972. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9973. }
  9974. else if(element.tagName()=="menu")
  9975. {
  9976. /*203:*/
  9977. #line 4801 "./typica.w"
  9978. QMenuBar*bar= window->menuBar();
  9979. bar->setParent(window);
  9980. bar->setObjectName("menuBar");
  9981. if(element.hasAttribute("name"))
  9982. {
  9983. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  9984. element.attribute("name").toUtf8().data()));
  9985. menu->setParent(bar);
  9986. if(element.hasAttribute("type"))
  9987. {
  9988. if(element.attribute("type")=="reports")
  9989. {
  9990. if(element.hasAttribute("src"))
  9991. {
  9992. /*663:*/
  9993. #line 14111 "./typica.w"
  9994. QSettings settings;
  9995. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9996. toString()).
  9997. arg(element.attribute("src"));
  9998. QDir::addSearchPath("reports",reportDirectory);
  9999. QDir directory(reportDirectory);
  10000. directory.setFilter(QDir::Files);
  10001. directory.setSorting(QDir::Name);
  10002. QStringList nameFilter;
  10003. nameFilter<<"*.xml";
  10004. directory.setNameFilters(nameFilter);
  10005. QFileInfoList reportFiles= directory.entryInfoList();
  10006. for(int i= 0;i<reportFiles.size();i++)
  10007. {
  10008. QFileInfo reportFile= reportFiles.at(i);
  10009. /*667:*/
  10010. #line 14191 "./typica.w"
  10011. QString path= reportFile.absoluteFilePath();
  10012. QFile file(path);
  10013. if(file.open(QIODevice::ReadOnly))
  10014. {
  10015. QDomDocument document;
  10016. document.setContent(&file,true);
  10017. QDomElement root= document.documentElement();
  10018. QString translationContext= root.attribute("id");
  10019. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  10020. if(!titleNode.isNull())
  10021. {
  10022. QDomElement titleElement= titleNode.toElement();
  10023. QString title= QCoreApplication::translate("configuration",
  10024. titleElement.text().toUtf8().data());
  10025. if(!title.isEmpty())
  10026. {
  10027. QStringList hierarchy= title.split(":->");
  10028. QMenu*insertionPoint= menu;
  10029. /*668:*/
  10030. #line 14220 "./typica.w"
  10031. for(int j= 0;j<hierarchy.size()-1;j++)
  10032. {
  10033. QObjectList menuList= insertionPoint->children();
  10034. bool menuFound= false;
  10035. for(int k= 0;k<menuList.size();k++)
  10036. {
  10037. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  10038. if(currentItem)
  10039. {
  10040. if(currentItem->title()==hierarchy.at(j))
  10041. {
  10042. menuFound= true;
  10043. insertionPoint= currentItem;
  10044. break;
  10045. }
  10046. }
  10047. }
  10048. if(!menuFound)
  10049. {
  10050. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  10051. }
  10052. }
  10053. /*:668*/
  10054. #line 14210 "./typica.w"
  10055. ReportAction*action= new ReportAction(path,hierarchy.last());
  10056. insertionPoint->addAction(action);
  10057. }
  10058. }
  10059. }
  10060. /*:667*/
  10061. #line 14127 "./typica.w"
  10062. }
  10063. /*:663*/
  10064. #line 4816 "./typica.w"
  10065. }
  10066. }
  10067. }
  10068. if(element.hasChildNodes())
  10069. {
  10070. /*204:*/
  10071. #line 4829 "./typica.w"
  10072. QDomNodeList menuItems= element.childNodes();
  10073. int j= 0;
  10074. while(j<menuItems.count())
  10075. {
  10076. QDomNode item= menuItems.at(j);
  10077. if(item.isElement())
  10078. {
  10079. QDomElement itemElement= item.toElement();
  10080. if(itemElement.tagName()=="item")
  10081. {
  10082. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  10083. itemElement.text().toUtf8().data()),menu);
  10084. if(itemElement.hasAttribute("id"))
  10085. {
  10086. itemAction->setObjectName(itemElement.attribute("id"));
  10087. }
  10088. if(itemElement.hasAttribute("shortcut"))
  10089. {
  10090. itemAction->setShortcut(itemElement.attribute("shortcut"));
  10091. }
  10092. menu->addAction(itemAction);
  10093. }
  10094. else if(itemElement.tagName()=="separator")
  10095. {
  10096. menu->addSeparator();
  10097. }
  10098. else if(itemElement.tagName()=="plugins")
  10099. {
  10100. /*688:*/
  10101. #line 21 "./plugins.w"
  10102. QMenu*pluginMenu= new QMenu(menu);
  10103. if(itemElement.hasAttribute("id"))
  10104. {
  10105. pluginMenu->setObjectName(itemElement.attribute("id"));
  10106. }
  10107. if(itemElement.hasAttribute("title"))
  10108. {
  10109. pluginMenu->setTitle(itemElement.attribute("title"));
  10110. }
  10111. if(itemElement.hasAttribute("src"))
  10112. {
  10113. QSettings settings;
  10114. QString pluginDirectory= QString("%1/%2").
  10115. arg(settings.value("config").toString()).
  10116. arg(itemElement.attribute("src"));
  10117. QDir directory(pluginDirectory);
  10118. directory.setFilter(QDir::Files);
  10119. directory.setSorting(QDir::Name);
  10120. QStringList nameFilter;
  10121. nameFilter<<"*.js";
  10122. directory.setNameFilters(nameFilter);
  10123. QFileInfoList pluginFiles= directory.entryInfoList();
  10124. for(int k= 0;k<pluginFiles.size();k++)
  10125. {
  10126. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  10127. if(itemElement.hasAttribute("preRun"))
  10128. {
  10129. pa->setPreRun(itemElement.attribute("preRun"));
  10130. }
  10131. if(itemElement.hasAttribute("postRun"))
  10132. {
  10133. pa->setPostRun(itemElement.attribute("postRun"));
  10134. }
  10135. pluginMenu->addAction(pa);
  10136. }
  10137. }
  10138. menu->addMenu(pluginMenu);
  10139. /*:688*/
  10140. #line 4858 "./typica.w"
  10141. }
  10142. }
  10143. j++;
  10144. }
  10145. #line 1 "./helpmenu.w"
  10146. /*:204*/
  10147. #line 4822 "./typica.w"
  10148. }
  10149. }
  10150. /*:203*/
  10151. #line 4779 "./typica.w"
  10152. }
  10153. }
  10154. i++;
  10155. }
  10156. QScriptValue oldThis= context->thisObject();
  10157. context->setThisObject(object);
  10158. QScriptValue result= engine->evaluate(windowScript);
  10159. /*195:*/
  10160. #line 4532 "./typica.w"
  10161. if(engine->hasUncaughtException())
  10162. {
  10163. int line= engine->uncaughtExceptionLineNumber();
  10164. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  10165. result.toString();
  10166. QString trace;
  10167. foreach(trace,engine->uncaughtExceptionBacktrace())
  10168. {
  10169. qDebug()<<trace;
  10170. }
  10171. }
  10172. /*:195*/
  10173. #line 4787 "./typica.w"
  10174. context->setThisObject(oldThis);
  10175. /*:202*/
  10176. #line 4728 "./typica.w"
  10177. }
  10178. /*205:*/
  10179. #line 9 "./helpmenu.w"
  10180. HelpMenu*helpMenu= new HelpMenu();
  10181. window->menuBar()->addMenu(helpMenu);
  10182. /*:205*/
  10183. #line 4730 "./typica.w"
  10184. window->show();
  10185. window->setupFinished();
  10186. /*:201*/
  10187. #line 14180 "./typica.w"
  10188. file.close();
  10189. engine->popContext();
  10190. }
  10191. }
  10192. /*:666*/
  10193. #line 588 "./typica.w"
  10194. /*250:*/
  10195. #line 5997 "./typica.w"
  10196. NumericDelegate::NumericDelegate(QObject*parent):
  10197. QItemDelegate(parent)
  10198. {
  10199. }
  10200. /*:250*//*251:*/
  10201. #line 6009 "./typica.w"
  10202. void NumericDelegate::setEditorData(QWidget*editor,
  10203. const QModelIndex&index)const
  10204. {
  10205. QString value= index.model()->data(index,Qt::EditRole).toString();
  10206. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10207. line->setText(value);
  10208. }
  10209. /*:251*//*252:*/
  10210. #line 6024 "./typica.w"
  10211. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  10212. const QModelIndex&index)const
  10213. {
  10214. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10215. model->setData(index,line->text(),Qt::EditRole);
  10216. QScriptEngine*engine= AppInstance->engine;
  10217. engine->pushContext();
  10218. QString script= QString("Number(%1)").arg(line->text());
  10219. QScriptValue result= engine->evaluate(line->text());
  10220. if(result.isNumber())
  10221. {
  10222. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10223. }
  10224. else
  10225. {
  10226. model->setData(index,QVariant(),Qt::DisplayRole);
  10227. }
  10228. engine->popContext();
  10229. }
  10230. /*:252*//*253:*/
  10231. #line 6047 "./typica.w"
  10232. QWidget*NumericDelegate::createEditor(QWidget*parent,
  10233. const QStyleOptionViewItem&,
  10234. const QModelIndex&)const
  10235. {
  10236. return(new QLineEdit(parent));
  10237. }
  10238. /*:253*//*254:*/
  10239. #line 6058 "./typica.w"
  10240. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  10241. const QStyleOptionViewItem&option,
  10242. const QModelIndex&)const
  10243. {
  10244. editor->setGeometry(option.rect);
  10245. }
  10246. /*:254*/
  10247. #line 589 "./typica.w"
  10248. /*815:*/
  10249. #line 16924 "./typica.w"
  10250. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  10251. const QModelIndex&index)
  10252. :BasicDeviceConfigurationWidget(model,index)
  10253. {
  10254. QHBoxLayout*layout= new QHBoxLayout;
  10255. QToolButton*addDeviceButton= new QToolButton;
  10256. addDeviceButton->setText(tr("Add Device"));
  10257. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10258. "nidaqmx9211series");
  10259. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  10260. "nidaqmxtc01");
  10261. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10262. this,SLOT(insertChildNode(QString,QString)));
  10263. connect(addtc01,SIGNAL(triggered(QString,QString)),
  10264. this,SLOT(insertChildNode(QString,QString)));
  10265. QMenu*deviceMenu= new QMenu;
  10266. deviceMenu->addAction(add9211a);
  10267. deviceMenu->addAction(addtc01);
  10268. addDeviceButton->setMenu(deviceMenu);
  10269. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10270. layout->addWidget(addDeviceButton);
  10271. setLayout(layout);
  10272. }
  10273. /*:815*/
  10274. #line 590 "./typica.w"
  10275. /*817:*/
  10276. #line 16973 "./typica.w"
  10277. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  10278. const QModelIndex&index)
  10279. :BasicDeviceConfigurationWidget(model,index)
  10280. {
  10281. QVBoxLayout*layout= new QVBoxLayout;
  10282. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10283. QLabel*label= new QLabel(tr("Device ID:"));
  10284. QLineEdit*deviceId= new QLineEdit;
  10285. deviceIdLayout->addWidget(label);
  10286. deviceIdLayout->addWidget(deviceId);
  10287. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10288. layout->addLayout(deviceIdLayout);
  10289. layout->addWidget(addChannelButton);
  10290. /*800:*/
  10291. #line 16608 "./typica.w"
  10292. QDomElement referenceElement=
  10293. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10294. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10295. QDomElement node;
  10296. /*:800*/
  10297. #line 16987 "./typica.w"
  10298. for(int i= 0;i<configData.size();i++)
  10299. {
  10300. node= configData.at(i).toElement();
  10301. if(node.attribute("name")=="deviceID")
  10302. {
  10303. deviceId->setText(node.attribute("value","Dev1"));
  10304. break;
  10305. }
  10306. }
  10307. updateDeviceId(deviceId->text());
  10308. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10309. connect(deviceId,SIGNAL(textEdited(QString)),
  10310. this,SLOT(updateDeviceId(QString)));
  10311. setLayout(layout);
  10312. }
  10313. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10314. {
  10315. updateAttribute("deviceID",newId);
  10316. }
  10317. void NiDaqMx9211ConfWidget::addChannel()
  10318. {
  10319. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10320. }
  10321. /*:817*/
  10322. #line 591 "./typica.w"
  10323. /*819:*/
  10324. #line 17038 "./typica.w"
  10325. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10326. const QModelIndex&index)
  10327. :BasicDeviceConfigurationWidget(model,index)
  10328. {
  10329. QFormLayout*layout= new QFormLayout;
  10330. QLineEdit*deviceId= new QLineEdit;
  10331. layout->addRow(tr("Device ID:"),deviceId);
  10332. QLineEdit*columnName= new QLineEdit;
  10333. layout->addRow(tr("Column Name:"),columnName);
  10334. QComboBox*typeSelector= new QComboBox;
  10335. typeSelector->addItem("J");
  10336. typeSelector->addItem("K");
  10337. typeSelector->addItem("T");
  10338. typeSelector->addItem("B");
  10339. typeSelector->addItem("E");
  10340. typeSelector->addItem("N");
  10341. typeSelector->addItem("R");
  10342. typeSelector->addItem("S");
  10343. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10344. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10345. layout->addRow(hideSeries);
  10346. /*800:*/
  10347. #line 16608 "./typica.w"
  10348. QDomElement referenceElement=
  10349. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10350. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10351. QDomElement node;
  10352. /*:800*/
  10353. #line 17060 "./typica.w"
  10354. for(int i= 0;i<configData.size();i++)
  10355. {
  10356. node= configData.at(i).toElement();
  10357. if(node.attribute("name")=="deviceID")
  10358. {
  10359. deviceId->setText(node.attribute("value"));
  10360. }
  10361. else if(node.attribute("name")=="type")
  10362. {
  10363. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10364. }
  10365. else if(node.attribute("name")=="columnname")
  10366. {
  10367. columnName->setText(node.attribute("value"));
  10368. }
  10369. else if(node.attribute("name")=="hidden")
  10370. {
  10371. hideSeries->setChecked(node.attribute("value")=="true");
  10372. }
  10373. }
  10374. updateDeviceId(deviceId->text());
  10375. updateThermocoupleType(typeSelector->currentText());
  10376. updateColumnName(columnName->text());
  10377. updateHidden(hideSeries->isChecked());
  10378. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10379. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10380. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10381. setLayout(layout);
  10382. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10383. }
  10384. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10385. {
  10386. updateAttribute("deviceID",newId);
  10387. }
  10388. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10389. {
  10390. updateAttribute("type",type);
  10391. }
  10392. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10393. {
  10394. updateAttribute("columnname",name);
  10395. }
  10396. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10397. {
  10398. updateAttribute("hidden",hidden?"true":"false");
  10399. }
  10400. /*:819*/
  10401. #line 592 "./typica.w"
  10402. /*837:*/
  10403. #line 17480 "./typica.w"
  10404. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10405. const QModelIndex&index)
  10406. :BasicDeviceConfigurationWidget(model,index)
  10407. {
  10408. QFormLayout*layout= new QFormLayout;
  10409. QToolButton*addDeviceButton= new QToolButton;
  10410. addDeviceButton->setText(tr("Add Device"));
  10411. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10412. "Modbus RTU Device",
  10413. "modbusrtudevice");
  10414. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10415. this,SLOT(insertChildNode(QString,QString)));
  10416. QMenu*deviceMenu= new QMenu;
  10417. deviceMenu->addAction(addModbusRtuDevice);
  10418. addDeviceButton->setMenu(deviceMenu);
  10419. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10420. layout->addRow(QString(),addDeviceButton);
  10421. PortSelector*port= new PortSelector;
  10422. layout->addRow(tr("Port:"),port);
  10423. connect(port,SIGNAL(currentIndexChanged(QString)),
  10424. this,SLOT(updatePort(QString)));
  10425. connect(port,SIGNAL(editTextChanged(QString)),
  10426. this,SLOT(updatePort(QString)));
  10427. BaudSelector*rate= new BaudSelector;
  10428. layout->addRow(tr("Baud:"),rate);
  10429. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10430. this,SLOT(updateBaudRate(QString)));
  10431. ParitySelector*parity= new ParitySelector;
  10432. layout->addRow(tr("Parity:"),parity);
  10433. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10434. this,SLOT(updateParity(QString)));
  10435. FlowSelector*flow= new FlowSelector;
  10436. layout->addRow(tr("Flow Control:"),flow);
  10437. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10438. this,SLOT(updateFlowControl(QString)));
  10439. StopSelector*stop= new StopSelector;
  10440. layout->addRow(tr("Stop Bits:"),stop);
  10441. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10442. this,SLOT(updateStopBits(QString)));
  10443. /*800:*/
  10444. #line 16608 "./typica.w"
  10445. QDomElement referenceElement=
  10446. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10447. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10448. QDomElement node;
  10449. /*:800*/
  10450. #line 17520 "./typica.w"
  10451. for(int i= 0;i<configData.size();i++)
  10452. {
  10453. node= configData.at(i).toElement();
  10454. if(node.attribute("name")=="port")
  10455. {
  10456. int j= port->findText(node.attribute("value"));
  10457. if(j>=0)
  10458. {
  10459. port->setCurrentIndex(j);
  10460. }
  10461. else
  10462. {
  10463. port->insertItem(0,node.attribute("value"));
  10464. port->setCurrentIndex(0);
  10465. }
  10466. }
  10467. else if(node.attribute("name")=="baudrate")
  10468. {
  10469. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10470. }
  10471. else if(node.attribute("name")=="parity")
  10472. {
  10473. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10474. }
  10475. else if(node.attribute("name")=="flowcontrol")
  10476. {
  10477. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10478. }
  10479. else if(node.attribute("name")=="stopbits")
  10480. {
  10481. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10482. }
  10483. }
  10484. updatePort(port->currentText());
  10485. updateBaudRate(rate->currentText());
  10486. updateParity(parity->currentText());
  10487. updateFlowControl(flow->currentText());
  10488. updateStopBits(stop->currentText());
  10489. setLayout(layout);
  10490. }
  10491. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10492. {
  10493. updateAttribute("port",newPort);
  10494. }
  10495. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10496. {
  10497. updateAttribute("baudrate",newRate);
  10498. }
  10499. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10500. {
  10501. updateAttribute("parity",newParity);
  10502. }
  10503. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10504. {
  10505. updateAttribute("flowcontrol",newFlow);
  10506. }
  10507. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10508. {
  10509. updateAttribute("stopbits",newStopBits);
  10510. }
  10511. /*:837*/
  10512. #line 593 "./typica.w"
  10513. /*839:*/
  10514. #line 17643 "./typica.w"
  10515. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10516. const QModelIndex&index)
  10517. :BasicDeviceConfigurationWidget(model,index),
  10518. unitSpecificationLayout(new QStackedLayout),
  10519. decimalSpecificationLayout(new QStackedLayout)
  10520. {
  10521. QVBoxLayout*layout= new QVBoxLayout;
  10522. QToolButton*addChannelButton= new QToolButton;
  10523. addChannelButton->setText(tr("Add Channel"));
  10524. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10525. "Temperature Process Value",
  10526. "modbustemperaturepv");
  10527. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10528. "Temperature Set Value",
  10529. "modbustemperaturesv");
  10530. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10531. this,SLOT(insertChildNode(QString,QString)));
  10532. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10533. this,SLOT(insertChildNode(QString,QString)));
  10534. QMenu*channelMenu= new QMenu;
  10535. channelMenu->addAction(addTemperaturePV);
  10536. channelMenu->addAction(addTemperatureSV);
  10537. addChannelButton->setMenu(channelMenu);
  10538. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10539. layout->addWidget(addChannelButton);
  10540. QHBoxLayout*stationLayout= new QHBoxLayout;
  10541. QLabel*stationLabel= new QLabel(tr("Station:"));
  10542. QSpinBox*stationNumber= new QSpinBox;
  10543. stationNumber->setMinimum(0);
  10544. stationNumber->setMaximum(255);
  10545. stationLayout->addWidget(stationLabel);
  10546. stationLayout->addWidget(stationNumber);
  10547. layout->addLayout(stationLayout);
  10548. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10549. layout->addWidget(fixedUnit);
  10550. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10551. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10552. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10553. QComboBox*fixedUnitSelector= new QComboBox;
  10554. fixedUnitSelector->addItem("Fahrenheit");
  10555. fixedUnitSelector->addItem("Celsius");
  10556. fixedUnitLayout->addWidget(fixedUnitLabel);
  10557. fixedUnitLayout->addWidget(fixedUnitSelector);
  10558. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10559. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10560. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10561. QFormLayout*queriedUnitLayout= new QFormLayout;
  10562. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10563. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10564. QSpinBox*valueF= new QSpinBox;
  10565. valueF->setMinimum(0);
  10566. valueF->setMaximum(65535);
  10567. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10568. QSpinBox*valueC= new QSpinBox;
  10569. valueC->setMinimum(0);
  10570. valueC->setMaximum(65535);
  10571. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10572. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10573. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10574. layout->addLayout(unitSpecificationLayout);
  10575. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10576. layout->addWidget(fixedPrecision);
  10577. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10578. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10579. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10580. fixedPrecisionValue->setMinimum(0);
  10581. fixedPrecisionValue->setMaximum(9);
  10582. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10583. fixedPrecisionValue);
  10584. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10585. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10586. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10587. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10588. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10589. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10590. precisionAddress);
  10591. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10592. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10593. layout->addLayout(decimalSpecificationLayout);
  10594. /*800:*/
  10595. #line 16608 "./typica.w"
  10596. QDomElement referenceElement=
  10597. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10598. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10599. QDomElement node;
  10600. /*:800*/
  10601. #line 17723 "./typica.w"
  10602. for(int i= 0;i<configData.size();i++)
  10603. {
  10604. node= configData.at(i).toElement();
  10605. if(node.attribute("name")=="station")
  10606. {
  10607. stationNumber->setValue(node.attribute("value").toInt());
  10608. }
  10609. else if(node.attribute("name")=="fixedunit")
  10610. {
  10611. if(node.attribute("value")=="true")
  10612. {
  10613. fixedUnit->setCheckState(Qt::Checked);
  10614. }
  10615. else if(node.attribute("value")=="false")
  10616. {
  10617. fixedUnit->setCheckState(Qt::Unchecked);
  10618. }
  10619. }
  10620. else if(node.attribute("name")=="fixedprecision")
  10621. {
  10622. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10623. }
  10624. else if(node.attribute("name")=="unit")
  10625. {
  10626. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10627. }
  10628. else if(node.attribute("name")=="unitaddress")
  10629. {
  10630. unitAddress->setValue(node.attribute("value").toInt());
  10631. }
  10632. else if(node.attribute("name")=="fvalue")
  10633. {
  10634. valueF->setValue(node.attribute("value").toInt());
  10635. }
  10636. else if(node.attribute("name")=="cvalue")
  10637. {
  10638. valueC->setValue(node.attribute("value").toInt());
  10639. }
  10640. else if(node.attribute("name")=="precisionaddress")
  10641. {
  10642. precisionAddress->setValue(node.attribute("value").toInt());
  10643. }
  10644. else if(node.attribute("name")=="precision")
  10645. {
  10646. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10647. }
  10648. }
  10649. updateStationNumber(stationNumber->value());
  10650. updateFixedUnit(fixedUnit->isChecked());
  10651. updateFixedDecimal(fixedPrecision->isChecked());
  10652. updateUnit(fixedUnitSelector->currentText());
  10653. updateUnitAddress(unitAddress->value());
  10654. updateValueF(valueF->value());
  10655. updateValueC(valueC->value());
  10656. updatePrecisionAddress(precisionAddress->value());
  10657. updatePrecisionValue(fixedPrecisionValue->value());
  10658. connect(stationNumber,SIGNAL(valueChanged(int)),
  10659. this,SLOT(updateStationNumber(int)));
  10660. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10661. this,SLOT(updateUnit(QString)));
  10662. connect(unitAddress,SIGNAL(valueChanged(int)),
  10663. this,SLOT(updateUnitAddress(int)));
  10664. connect(valueF,SIGNAL(valueChanged(int)),
  10665. this,SLOT(updateValueF(int)));
  10666. connect(valueC,SIGNAL(valueChanged(int)),
  10667. this,SLOT(updateValueC(int)));
  10668. connect(fixedUnit,SIGNAL(toggled(bool)),
  10669. this,SLOT(updateFixedUnit(bool)));
  10670. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10671. this,SLOT(updateFixedDecimal(bool)));
  10672. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10673. this,SLOT(updatePrecisionValue(int)));
  10674. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10675. this,SLOT(updatePrecisionAddress(int)));
  10676. setLayout(layout);
  10677. }
  10678. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10679. {
  10680. updateAttribute("station",QString("%1").arg(newStation));
  10681. }
  10682. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10683. {
  10684. if(newFixed)
  10685. {
  10686. unitSpecificationLayout->setCurrentIndex(0);
  10687. updateAttribute("fixedunit","true");
  10688. }
  10689. else
  10690. {
  10691. unitSpecificationLayout->setCurrentIndex(1);
  10692. updateAttribute("fixedunit","false");
  10693. }
  10694. }
  10695. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10696. {
  10697. if(newFixed)
  10698. {
  10699. decimalSpecificationLayout->setCurrentIndex(0);
  10700. updateAttribute("fixedprecision","true");
  10701. }
  10702. else
  10703. {
  10704. decimalSpecificationLayout->setCurrentIndex(1);
  10705. updateAttribute("fixedprecision","false");
  10706. }
  10707. }
  10708. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10709. {
  10710. updateAttribute("unit",newUnit);
  10711. }
  10712. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10713. {
  10714. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10715. }
  10716. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10717. {
  10718. updateAttribute("fvalue",QString("%1").arg(newValue));
  10719. }
  10720. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10721. {
  10722. updateAttribute("cvalue",QString("%1").arg(newValue));
  10723. }
  10724. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10725. {
  10726. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10727. }
  10728. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10729. {
  10730. updateAttribute("precision",QString("%1").arg(newValue));
  10731. }
  10732. /*:839*/
  10733. #line 594 "./typica.w"
  10734. /*841:*/
  10735. #line 17886 "./typica.w"
  10736. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10737. const QModelIndex&index)
  10738. :BasicDeviceConfigurationWidget(model,index)
  10739. {
  10740. QFormLayout*layout= new QFormLayout;
  10741. ShortHexSpinBox*address= new ShortHexSpinBox;
  10742. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10743. /*800:*/
  10744. #line 16608 "./typica.w"
  10745. QDomElement referenceElement=
  10746. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10747. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10748. QDomElement node;
  10749. /*:800*/
  10750. #line 17894 "./typica.w"
  10751. for(int i= 0;i<configData.size();i++)
  10752. {
  10753. node= configData.at(i).toElement();
  10754. if(node.attribute("name")=="address")
  10755. {
  10756. address->setValue(node.attribute("value").toInt());
  10757. break;
  10758. }
  10759. }
  10760. updateAddress(address->value());
  10761. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10762. setLayout(layout);
  10763. }
  10764. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10765. {
  10766. updateAttribute("address",QString("%1").arg(newAddress));
  10767. }
  10768. /*:841*/
  10769. #line 595 "./typica.w"
  10770. /*843:*/
  10771. #line 17942 "./typica.w"
  10772. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10773. const QModelIndex&index)
  10774. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10775. {
  10776. QVBoxLayout*layout= new QVBoxLayout;
  10777. QFormLayout*addressLayout= new QFormLayout;
  10778. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10779. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10780. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10781. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10782. layout->addLayout(addressLayout);
  10783. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10784. layout->addWidget(fixedRange);
  10785. QWidget*queriedRangePlaceholder= new QWidget(this);
  10786. QFormLayout*queriedRangeLayout= new QFormLayout;
  10787. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10788. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10789. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10790. lowerAddress);
  10791. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10792. upperAddress);
  10793. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10794. boundsLayout->addWidget(queriedRangePlaceholder);
  10795. QWidget*fixedRangePlaceholder= new QWidget(this);
  10796. QFormLayout*fixedRangeLayout= new QFormLayout;
  10797. QLineEdit*fixedLower= new QLineEdit;
  10798. QLineEdit*fixedUpper= new QLineEdit;
  10799. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10800. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10801. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10802. boundsLayout->addWidget(fixedRangePlaceholder);
  10803. layout->addLayout(boundsLayout);
  10804. /*800:*/
  10805. #line 16608 "./typica.w"
  10806. QDomElement referenceElement=
  10807. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10808. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10809. QDomElement node;
  10810. /*:800*/
  10811. #line 17975 "./typica.w"
  10812. for(int i= 0;i<configData.size();i++)
  10813. {
  10814. node= configData.at(i).toElement();
  10815. if(node.attribute("name")=="readaddress")
  10816. {
  10817. readAddress->setValue(node.attribute("value").toInt());
  10818. }
  10819. else if(node.attribute("name")=="writeaddress")
  10820. {
  10821. writeAddress->setValue(node.attribute("value").toInt());
  10822. }
  10823. else if(node.attribute("name")=="fixedrange")
  10824. {
  10825. if(node.attribute("value")=="true")
  10826. {
  10827. fixedRange->setCheckState(Qt::Checked);
  10828. }
  10829. else if(node.attribute("value")=="false")
  10830. {
  10831. fixedRange->setCheckState(Qt::Unchecked);
  10832. }
  10833. }
  10834. else if(node.attribute("name")=="fixedlower")
  10835. {
  10836. fixedLower->setText(node.attribute("value"));
  10837. }
  10838. else if(node.attribute("name")=="fixedupper")
  10839. {
  10840. fixedUpper->setText(node.attribute("value"));
  10841. }
  10842. else if(node.attribute("name")=="loweraddress")
  10843. {
  10844. lowerAddress->setValue(node.attribute("value").toInt());
  10845. }
  10846. else if(node.attribute("name")=="upperaddress")
  10847. {
  10848. upperAddress->setValue(node.attribute("value").toInt());
  10849. }
  10850. }
  10851. updateReadAddress(readAddress->value());
  10852. updateWriteAddress(writeAddress->value());
  10853. updateFixedRange(fixedRange->isChecked());
  10854. updateLower(fixedLower->text());
  10855. updateUpper(fixedUpper->text());
  10856. updateLowerAddress(lowerAddress->value());
  10857. updateUpperAddress(upperAddress->value());
  10858. connect(readAddress,SIGNAL(valueChanged(int)),
  10859. this,SLOT(updateReadAddress(int)));
  10860. connect(writeAddress,SIGNAL(valueChanged(int)),
  10861. this,SLOT(updateWriteAddress(int)));
  10862. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10863. connect(fixedLower,SIGNAL(textChanged(QString)),
  10864. this,SLOT(updateLower(QString)));
  10865. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10866. this,SLOT(updateUpper(QString)));
  10867. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10868. this,SLOT(updateLowerAddress(int)));
  10869. connect(upperAddress,SIGNAL(valueChanged(int)),
  10870. this,SLOT(updateUpperAddress(int)));
  10871. setLayout(layout);
  10872. }
  10873. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10874. {
  10875. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10876. }
  10877. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10878. {
  10879. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10880. }
  10881. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10882. {
  10883. if(fixed)
  10884. {
  10885. updateAttribute("fixedrange","true");
  10886. boundsLayout->setCurrentIndex(1);
  10887. }
  10888. else
  10889. {
  10890. updateAttribute("fixedrange","false");
  10891. boundsLayout->setCurrentIndex(0);
  10892. }
  10893. }
  10894. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10895. {
  10896. updateAttribute("fixedlower",lower);
  10897. }
  10898. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10899. {
  10900. updateAttribute("fixedupper",upper);
  10901. }
  10902. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10903. {
  10904. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10905. }
  10906. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10907. {
  10908. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10909. }
  10910. /*:843*/
  10911. #line 596 "./typica.w"
  10912. /*799:*/
  10913. #line 16478 "./typica.w"
  10914. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10915. :BasicDeviceConfigurationWidget(model,index)
  10916. {
  10917. QVBoxLayout*layout= new QVBoxLayout;
  10918. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10919. QMenu*deviceMenu= new QMenu;
  10920. NodeInserter*insertAction;
  10921. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10922. {
  10923. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10924. this,SLOT(insertChildNode(QString,QString)));
  10925. deviceMenu->addAction(insertAction);
  10926. }
  10927. addDeviceButton->setMenu(deviceMenu);
  10928. layout->addWidget(addDeviceButton);
  10929. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10930. QMenu*annotationMenu= new QMenu;
  10931. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10932. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10933. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10934. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10935. tr("Free Text"),
  10936. "freeannotation");
  10937. annotationMenu->addAction(basicButtonInserter);
  10938. annotationMenu->addAction(countingButtonInserter);
  10939. annotationMenu->addAction(spinBoxInserter);
  10940. annotationMenu->addAction(freeAnnotationInserter);
  10941. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10942. this,SLOT(insertChildNode(QString,QString)));
  10943. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10944. this,SLOT(insertChildNode(QString,QString)));
  10945. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10946. this,SLOT(insertChildNode(QString,QString)));
  10947. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10948. this,SLOT(insertChildNode(QString,QString)));
  10949. /*1085:*/
  10950. #line 144 "./valueannotation.w"
  10951. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10952. tr("Value Annotation"),
  10953. "valueannotation");
  10954. annotationMenu->addAction(valueAnnotationInserter);
  10955. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10956. this,SLOT(insertChildNode(QString,QString)));
  10957. /*:1085*//*1099:*/
  10958. #line 115 "./thresholdannotation.w"
  10959. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  10960. tr("Threshold Annotation"),
  10961. "thresholdannotation");
  10962. annotationMenu->addAction(thresholdAnnotationInserter);
  10963. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10964. this,SLOT(insertChildNode(QString,QString)));
  10965. /*:1099*/
  10966. #line 16514 "./typica.w"
  10967. addAnnotationControlButton->setMenu(annotationMenu);
  10968. layout->addWidget(addAnnotationControlButton);
  10969. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10970. QMenu*timersMenu= new QMenu;
  10971. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10972. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10973. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10974. timersMenu->addAction(coolingTimerInserter);
  10975. timersMenu->addAction(rangeTimerInserter);
  10976. timersMenu->addAction(multirangeTimerInserter);
  10977. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10978. this,SLOT(insertChildNode(QString,QString)));
  10979. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10980. this,SLOT(insertChildNode(QString,QString)));
  10981. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10982. this,SLOT(insertChildNode(QString,QString)));
  10983. timersButton->setMenu(timersMenu);
  10984. layout->addWidget(timersButton);
  10985. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10986. QMenu*advancedMenu= new QMenu;
  10987. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10988. advancedMenu->addAction(linearsplineinserter);
  10989. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10990. advancedMenu->addAction(translationinserter);
  10991. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10992. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10993. /*997:*/
  10994. #line 258 "./rate.w"
  10995. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10996. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10997. advancedMenu->addAction(rateOfChangeInserter);
  10998. /*:997*//*1011:*/
  10999. #line 272 "./mergeseries.w"
  11000. NodeInserter*mergeSeriesInserter= new NodeInserter(tr("Merge Series"),
  11001. tr("Merge"),
  11002. "mergeseries");
  11003. connect(mergeSeriesInserter,SIGNAL(triggered(QString,QString)),
  11004. this,SLOT(insertChildNode(QString,QString)));
  11005. advancedMenu->addAction(mergeSeriesInserter);
  11006. /*:1011*/
  11007. #line 16543 "./typica.w"
  11008. advancedButton->setMenu(advancedMenu);
  11009. layout->addWidget(advancedButton);
  11010. QHBoxLayout*idLayout= new QHBoxLayout;
  11011. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  11012. idLayout->addWidget(idLabel);
  11013. QSpinBox*id= new QSpinBox;
  11014. idLayout->addWidget(id);
  11015. idLayout->addStretch();
  11016. layout->addLayout(idLayout);
  11017. QHBoxLayout*capacityLayout= new QHBoxLayout;
  11018. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  11019. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  11020. capacity->setMinimum(0.0);
  11021. capacity->setDecimals(3);
  11022. capacity->setMaximum(999999.999);
  11023. QComboBox*capacityUnit= new QComboBox;
  11024. capacityUnit->addItem("g");
  11025. capacityUnit->addItem("Kg");
  11026. capacityUnit->addItem("oz");
  11027. capacityUnit->addItem("Lb");
  11028. capacityUnit->setCurrentIndex(3);
  11029. capacityLayout->addWidget(capacityCheckEnabled);
  11030. capacityLayout->addWidget(capacity);
  11031. capacityLayout->addWidget(capacityUnit);
  11032. capacityLayout->addStretch();
  11033. layout->addLayout(capacityLayout);
  11034. layout->addStretch();
  11035. /*800:*/
  11036. #line 16608 "./typica.w"
  11037. QDomElement referenceElement=
  11038. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11039. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11040. QDomElement node;
  11041. /*:800*/
  11042. #line 16572 "./typica.w"
  11043. for(int i= 0;i<configData.size();i++)
  11044. {
  11045. node= configData.at(i).toElement();
  11046. if(node.attribute("name")=="databaseid")
  11047. {
  11048. id->setValue(node.attribute("value").toInt());
  11049. }
  11050. else if(node.attribute("name")=="checkcapacity")
  11051. {
  11052. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  11053. }
  11054. else if(node.attribute("name")=="capacity")
  11055. {
  11056. capacity->setValue(node.attribute("value").toDouble());
  11057. }
  11058. else if(node.attribute("name")=="capacityunit")
  11059. {
  11060. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  11061. }
  11062. }
  11063. updateRoasterId(id->value());
  11064. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  11065. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  11066. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  11067. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  11068. setLayout(layout);
  11069. }
  11070. /*:799*//*801:*/
  11071. #line 16618 "./typica.w"
  11072. void RoasterConfWidget::updateRoasterId(int id)
  11073. {
  11074. updateAttribute("databaseid",QString("%1").arg(id));
  11075. }
  11076. void RoasterConfWidget::updateCapacityCheck(int value)
  11077. {
  11078. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  11079. }
  11080. void RoasterConfWidget::updateCapacity(const QString&value)
  11081. {
  11082. updateAttribute("capacity",value);
  11083. }
  11084. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  11085. {
  11086. updateAttribute("capacityunit",value);
  11087. }
  11088. /*:801*/
  11089. #line 597 "./typica.w"
  11090. /*847:*/
  11091. #line 18125 "./typica.w"
  11092. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11093. :BasicDeviceConfigurationWidget(model,index)
  11094. {
  11095. QFormLayout*layout= new QFormLayout;
  11096. QLineEdit*buttonTextEdit= new QLineEdit;
  11097. QLineEdit*annotationTextEdit= new QLineEdit;
  11098. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11099. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11100. /*800:*/
  11101. #line 16608 "./typica.w"
  11102. QDomElement referenceElement=
  11103. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11104. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11105. QDomElement node;
  11106. /*:800*/
  11107. #line 18134 "./typica.w"
  11108. for(int i= 0;i<configData.size();i++)
  11109. {
  11110. node= configData.at(i).toElement();
  11111. if(node.attribute("name")=="buttontext")
  11112. {
  11113. buttonTextEdit->setText(node.attribute("value"));
  11114. }
  11115. else if(node.attribute("name")=="annotationtext")
  11116. {
  11117. annotationTextEdit->setText(node.attribute("value"));
  11118. }
  11119. }
  11120. updateButtonText(buttonTextEdit->text());
  11121. updateAnnotationText(annotationTextEdit->text());
  11122. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11123. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11124. setLayout(layout);
  11125. }
  11126. /*:847*//*848:*/
  11127. #line 18156 "./typica.w"
  11128. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  11129. {
  11130. updateAttribute("buttontext",text);
  11131. }
  11132. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11133. {
  11134. updateAttribute("annotationtext",text);
  11135. }
  11136. /*:848*//*851:*/
  11137. #line 18194 "./typica.w"
  11138. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11139. :BasicDeviceConfigurationWidget(model,index)
  11140. {
  11141. QFormLayout*layout= new QFormLayout;
  11142. QLineEdit*buttonTextEdit= new QLineEdit;
  11143. QLineEdit*annotationTextEdit= new QLineEdit;
  11144. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11145. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11146. /*800:*/
  11147. #line 16608 "./typica.w"
  11148. QDomElement referenceElement=
  11149. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11150. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11151. QDomElement node;
  11152. /*:800*/
  11153. #line 18203 "./typica.w"
  11154. for(int i= 0;i<configData.size();i++)
  11155. {
  11156. node= configData.at(i).toElement();
  11157. if(node.attribute("name")=="buttontext")
  11158. {
  11159. buttonTextEdit->setText(node.attribute("value"));
  11160. }
  11161. else if(node.attribute("name")=="annotationtext")
  11162. {
  11163. annotationTextEdit->setText(node.attribute("value"));
  11164. }
  11165. }
  11166. updateButtonText(buttonTextEdit->text());
  11167. updateAnnotationText(annotationTextEdit->text());
  11168. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11169. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11170. QTextEdit*documentation= new QTextEdit;
  11171. 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."));
  11172. documentation->setReadOnly(true);
  11173. layout->addRow("",documentation);
  11174. setLayout(layout);
  11175. }
  11176. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  11177. {
  11178. updateAttribute("buttontext",text);
  11179. }
  11180. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11181. {
  11182. updateAttribute("annotationtext",text);
  11183. }
  11184. /*:851*/
  11185. #line 598 "./typica.w"
  11186. /*854:*/
  11187. #line 18271 "./typica.w"
  11188. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11189. :BasicDeviceConfigurationWidget(model,index)
  11190. {
  11191. QFormLayout*layout= new QFormLayout;
  11192. QLineEdit*labelEdit= new QLineEdit;
  11193. layout->addRow(tr("Control Label: "),labelEdit);
  11194. QLineEdit*minimumEdit= new QLineEdit;
  11195. layout->addRow(tr("Minimum Value: "),minimumEdit);
  11196. QLineEdit*maximumEdit= new QLineEdit;
  11197. layout->addRow(tr("Maximum Value: "),maximumEdit);
  11198. QSpinBox*precisionEdit= new QSpinBox;
  11199. precisionEdit->setMinimum(0);
  11200. precisionEdit->setMaximum(9);
  11201. layout->addRow(tr("Precision"),precisionEdit);
  11202. QLineEdit*pretext= new QLineEdit;
  11203. layout->addRow(tr("Prefix text"),pretext);
  11204. QLineEdit*posttext= new QLineEdit;
  11205. layout->addRow(tr("Suffix text"),posttext);
  11206. /*800:*/
  11207. #line 16608 "./typica.w"
  11208. QDomElement referenceElement=
  11209. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11210. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11211. QDomElement node;
  11212. /*:800*/
  11213. #line 18290 "./typica.w"
  11214. for(int i= 0;i<configData.size();i++)
  11215. {
  11216. node= configData.at(i).toElement();
  11217. if(node.attribute("name")=="label")
  11218. {
  11219. labelEdit->setText(node.attribute("value"));
  11220. }
  11221. else if(node.attribute("name")=="minimum")
  11222. {
  11223. minimumEdit->setText(node.attribute("value"));
  11224. }
  11225. else if(node.attribute("name")=="maximum")
  11226. {
  11227. maximumEdit->setText(node.attribute("value"));
  11228. }
  11229. else if(node.attribute("name")=="precision")
  11230. {
  11231. precisionEdit->setValue(node.attribute("value").toInt());
  11232. }
  11233. else if(node.attribute("name")=="pretext")
  11234. {
  11235. pretext->setText(node.attribute("value"));
  11236. }
  11237. else if(node.attribute("name")=="posttext")
  11238. {
  11239. posttext->setText(node.attribute("value"));
  11240. }
  11241. }
  11242. updateLabel(labelEdit->text());
  11243. updateMinimum(minimumEdit->text());
  11244. updateMaximum(maximumEdit->text());
  11245. updatePrecision(precisionEdit->value());
  11246. updatePretext(pretext->text());
  11247. updatePosttext(posttext->text());
  11248. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  11249. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  11250. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  11251. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  11252. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  11253. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  11254. setLayout(layout);
  11255. }
  11256. void NoteSpinConfWidget::updateLabel(const QString&text)
  11257. {
  11258. updateAttribute("label",text);
  11259. }
  11260. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  11261. {
  11262. updateAttribute("minimum",minimum);
  11263. }
  11264. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  11265. {
  11266. updateAttribute("maximum",maximum);
  11267. }
  11268. void NoteSpinConfWidget::updatePrecision(int precision)
  11269. {
  11270. updateAttribute("precision",QString("%1").arg(precision));
  11271. }
  11272. void NoteSpinConfWidget::updatePretext(const QString&text)
  11273. {
  11274. updateAttribute("pretext",text);
  11275. }
  11276. void NoteSpinConfWidget::updatePosttext(const QString&text)
  11277. {
  11278. updateAttribute("posttext",text);
  11279. }
  11280. /*:854*/
  11281. #line 599 "./typica.w"
  11282. /*346:*/
  11283. #line 7762 "./typica.w"
  11284. LinearCalibrator::LinearCalibrator(QObject*parent):
  11285. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  11286. {
  11287. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11288. }
  11289. /*:346*//*347:*/
  11290. #line 7776 "./typica.w"
  11291. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  11292. {
  11293. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  11294. if(clamp)
  11295. {
  11296. if(outval<Lo1)
  11297. {
  11298. outval= Lo1;
  11299. }
  11300. else if(outval> Up1)
  11301. {
  11302. outval= Up1;
  11303. }
  11304. }
  11305. if(sensitivitySetting>=0.05)
  11306. {
  11307. int temp= qRound(outval/sensitivitySetting);
  11308. outval= temp*sensitivitySetting;
  11309. }
  11310. Measurement adjusted(outval,measure.time(),measure.scale());
  11311. emit measurement(adjusted);
  11312. return adjusted;
  11313. }
  11314. /*:347*//*348:*/
  11315. #line 7803 "./typica.w"
  11316. double LinearCalibrator::measuredLower()
  11317. {
  11318. return Lo2;
  11319. }
  11320. double LinearCalibrator::measuredUpper()
  11321. {
  11322. return Up2;
  11323. }
  11324. double LinearCalibrator::mappedLower()
  11325. {
  11326. return Lo1;
  11327. }
  11328. double LinearCalibrator::mappedUpper()
  11329. {
  11330. return Up1;
  11331. }
  11332. bool LinearCalibrator::isClosedRange()
  11333. {
  11334. return clamp;
  11335. }
  11336. void LinearCalibrator::setMeasuredLower(double lower)
  11337. {
  11338. Lo2= lower;
  11339. }
  11340. void LinearCalibrator::setMeasuredUpper(double upper)
  11341. {
  11342. Up2= upper;
  11343. }
  11344. void LinearCalibrator::setMappedLower(double lower)
  11345. {
  11346. Lo1= lower;
  11347. }
  11348. void LinearCalibrator::setMappedUpper(double upper)
  11349. {
  11350. Up1= upper;
  11351. }
  11352. void LinearCalibrator::setClosedRange(bool closed)
  11353. {
  11354. clamp= closed;
  11355. }
  11356. void LinearCalibrator::setSensitivity(double sensitivity)
  11357. {
  11358. sensitivitySetting= sensitivity;
  11359. }
  11360. double LinearCalibrator::sensitivity()
  11361. {
  11362. return sensitivitySetting;
  11363. }
  11364. /*:348*/
  11365. #line 600 "./typica.w"
  11366. /*353:*/
  11367. #line 7936 "./typica.w"
  11368. void LinearSplineInterpolator::add_pair(double source,double destination)
  11369. {
  11370. pairs->insert(source,destination);
  11371. make_interpolators();
  11372. }
  11373. void LinearSplineInterpolator::make_interpolators()
  11374. {
  11375. if(pairs->size()> 1)
  11376. {
  11377. while(interpolators->size()> 0)
  11378. {
  11379. LinearCalibrator*removed= interpolators->takeFirst();
  11380. removed->deleteLater();
  11381. }
  11382. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11383. QMap<double,double> ::const_iterator j= i+1;
  11384. while(j!=pairs->constEnd())
  11385. {
  11386. LinearCalibrator*segment= new LinearCalibrator();
  11387. segment->setMeasuredLower(i.key());
  11388. segment->setMappedLower(i.value());
  11389. segment->setMeasuredUpper(j.key());
  11390. segment->setMappedUpper(j.value());
  11391. segment->setClosedRange(false);
  11392. interpolators->append(segment);
  11393. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11394. i++;
  11395. j++;
  11396. }
  11397. }
  11398. }
  11399. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11400. QObject(parent),pairs(new QMap<double,double> ),
  11401. interpolators(new QList<LinearCalibrator*> )
  11402. {
  11403. }
  11404. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11405. {
  11406. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11407. int index= -1;
  11408. while(i!=pairs->constEnd())
  11409. {
  11410. if(measure.temperature()<=i.key())
  11411. {
  11412. break;
  11413. }
  11414. i++;
  11415. index++;
  11416. }
  11417. if(index<0)
  11418. {
  11419. index= 0;
  11420. }
  11421. if(index>=interpolators->size())
  11422. {
  11423. index= interpolators->size()-1;
  11424. }
  11425. if(interpolators->at(index)!=NULL)
  11426. {
  11427. return interpolators->at(index)->newMeasurement(measure);
  11428. }
  11429. return Measurement();
  11430. }
  11431. /*:353*/
  11432. #line 601 "./typica.w"
  11433. /*962:*/
  11434. #line 19641 "./typica.w"
  11435. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11436. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11437. {
  11438. QFormLayout*layout= new QFormLayout;
  11439. QLineEdit*source= new QLineEdit;
  11440. layout->addRow(tr("Source column name:"),source);
  11441. QLineEdit*destination= new QLineEdit;
  11442. layout->addRow(tr("Destination column name:"),destination);
  11443. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11444. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11445. QTableView*mappingTable= new QTableView;
  11446. mappingTable->setModel(tablemodel);
  11447. NumericDelegate*delegate= new NumericDelegate;
  11448. mappingTable->setItemDelegate(delegate);
  11449. layout->addRow(tr("Mapping data:"),mappingTable);
  11450. /*800:*/
  11451. #line 16608 "./typica.w"
  11452. QDomElement referenceElement=
  11453. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11454. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11455. QDomElement node;
  11456. /*:800*/
  11457. #line 19657 "./typica.w"
  11458. for(int i= 0;i<configData.size();i++)
  11459. {
  11460. node= configData.at(i).toElement();
  11461. if(node.attribute("name")=="source")
  11462. {
  11463. source->setText(node.attribute("value"));
  11464. }
  11465. else if(node.attribute("name")=="destination")
  11466. {
  11467. destination->setText(node.attribute("value"));
  11468. }
  11469. else if(node.attribute("name")=="sourcevalues")
  11470. {
  11471. /*963:*/
  11472. #line 19696 "./typica.w"
  11473. QString data= node.attribute("value");
  11474. if(data.length()> 3)
  11475. {
  11476. data.chop(2);
  11477. data= data.remove(0,2);
  11478. }
  11479. QStringList itemList= data.split(",");
  11480. /*:963*/
  11481. #line 19671 "./typica.w"
  11482. int column= 0;
  11483. /*964:*/
  11484. #line 19708 "./typica.w"
  11485. for(int j= 0;j<itemList.size();j++)
  11486. {
  11487. tablemodel->setData(tablemodel->index(j,column),
  11488. QVariant(itemList.at(j).toDouble()),
  11489. Qt::DisplayRole);
  11490. }
  11491. /*:964*/
  11492. #line 19673 "./typica.w"
  11493. }
  11494. else if(node.attribute("name")=="destinationvalues")
  11495. {
  11496. /*963:*/
  11497. #line 19696 "./typica.w"
  11498. QString data= node.attribute("value");
  11499. if(data.length()> 3)
  11500. {
  11501. data.chop(2);
  11502. data= data.remove(0,2);
  11503. }
  11504. QStringList itemList= data.split(",");
  11505. /*:963*/
  11506. #line 19678 "./typica.w"
  11507. int column= 1;
  11508. /*964:*/
  11509. #line 19708 "./typica.w"
  11510. for(int j= 0;j<itemList.size();j++)
  11511. {
  11512. tablemodel->setData(tablemodel->index(j,column),
  11513. QVariant(itemList.at(j).toDouble()),
  11514. Qt::DisplayRole);
  11515. }
  11516. /*:964*/
  11517. #line 19680 "./typica.w"
  11518. }
  11519. }
  11520. updateSourceColumn(source->text());
  11521. updateDestinationColumn(destination->text());
  11522. updateKnots();
  11523. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11524. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11525. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11526. setLayout(layout);
  11527. }
  11528. /*:962*//*965:*/
  11529. #line 19719 "./typica.w"
  11530. void LinearSplineInterpolationConfWidget::updateKnots()
  11531. {
  11532. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11533. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11534. }
  11535. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11536. {
  11537. updateAttribute("source",source);
  11538. }
  11539. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11540. {
  11541. updateAttribute("destination",dest);
  11542. }
  11543. /*:965*/
  11544. #line 602 "./typica.w"
  11545. /*982:*/
  11546. #line 20190 "./typica.w"
  11547. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11548. :BasicDeviceConfigurationWidget(model,index),
  11549. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox),
  11550. delaySelector(new QSpinBox)
  11551. {
  11552. unitSelector->addItem("Fahrenheit");
  11553. unitSelector->addItem("Celsius");
  11554. temperatureValue->setMinimum(0);
  11555. temperatureValue->setMaximum(1000);
  11556. QFormLayout*layout= new QFormLayout;
  11557. QLineEdit*column= new QLineEdit;
  11558. layout->addRow(tr("Column to match:"),column);
  11559. layout->addRow(tr("Unit:"),unitSelector);
  11560. layout->addRow(tr("Value:"),temperatureValue);
  11561. layout->addRow(tr("Start of batch safety delay:"),delaySelector);
  11562. /*800:*/
  11563. #line 16608 "./typica.w"
  11564. QDomElement referenceElement=
  11565. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11566. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11567. QDomElement node;
  11568. /*:800*/
  11569. #line 20206 "./typica.w"
  11570. for(int i= 0;i<configData.size();i++)
  11571. {
  11572. node= configData.at(i).toElement();
  11573. if(node.attribute("name")=="column")
  11574. {
  11575. column->setText(node.attribute("value"));
  11576. }
  11577. else if(node.attribute("name")=="unit")
  11578. {
  11579. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11580. }
  11581. else if(node.attribute("name")=="value")
  11582. {
  11583. temperatureValue->setValue(node.attribute("value").toDouble());
  11584. }
  11585. else if(node.attribute("name")=="delay")
  11586. {
  11587. delaySelector->setValue(node.attribute("value").toInt());
  11588. }
  11589. }
  11590. updateMatchingColumn(column->text());
  11591. updateTemperature();
  11592. updateDelay();
  11593. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11594. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11595. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11596. connect(delaySelector,SIGNAL(valueChanged(int)),this,SLOT(updateDelay()));
  11597. setLayout(layout);
  11598. }
  11599. /*:982*//*983:*/
  11600. #line 20241 "./typica.w"
  11601. void TranslationConfWidget::updateTemperature()
  11602. {
  11603. updateAttribute("unit",unitSelector->currentText());
  11604. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11605. if(unitSelector->currentText()=="Fahrenheit")
  11606. {
  11607. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11608. }
  11609. else
  11610. {
  11611. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11612. }
  11613. }
  11614. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11615. {
  11616. updateAttribute("column",column);
  11617. }
  11618. void TranslationConfWidget::updateDelay()
  11619. {
  11620. updateAttribute("delay",QString("%1").arg(delaySelector->value()));
  11621. }
  11622. /*:983*/
  11623. #line 603 "./typica.w"
  11624. /*857:*/
  11625. #line 24 "./freeannotation.w"
  11626. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11627. const QModelIndex&index)
  11628. :BasicDeviceConfigurationWidget(model,index)
  11629. {
  11630. QFormLayout*layout= new QFormLayout;
  11631. QLineEdit*labelEdit= new QLineEdit;
  11632. layout->addRow(tr("Label Text:"),labelEdit);
  11633. /*800:*/
  11634. #line 16608 "./typica.w"
  11635. QDomElement referenceElement=
  11636. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11637. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11638. QDomElement node;
  11639. /*:800*/
  11640. #line 32 "./freeannotation.w"
  11641. for(int i= 0;i<configData.size();i++)
  11642. {
  11643. node= configData.at(i).toElement();
  11644. if(node.attribute("name")=="labeltext")
  11645. {
  11646. labelEdit->setText(node.attribute("value"));
  11647. }
  11648. }
  11649. updateLabel(labelEdit->text());
  11650. connect(labelEdit,SIGNAL(textEdited(QString)),
  11651. this,SLOT(updateLabel(QString)));
  11652. setLayout(layout);
  11653. }
  11654. /*:857*//*858:*/
  11655. #line 49 "./freeannotation.w"
  11656. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11657. {
  11658. updateAttribute("labeltext",text);
  11659. }
  11660. /*:858*/
  11661. #line 604 "./typica.w"
  11662. /*986:*/
  11663. #line 39 "./rate.w"
  11664. void RateOfChange::newMeasurement(Measurement measure)
  11665. {
  11666. cache.append(measure);
  11667. /*987:*/
  11668. #line 64 "./rate.w"
  11669. if(cache.size()> 2)
  11670. {
  11671. bool done= false;
  11672. while(!done)
  11673. {
  11674. if(cache.front().time().secsTo(cache.back().time())> ct)
  11675. {
  11676. cache.removeFirst();
  11677. }
  11678. else if(cache.back().time()<cache.front().time())
  11679. {
  11680. cache.removeFirst();
  11681. done= true;
  11682. }
  11683. else
  11684. {
  11685. done= true;
  11686. }
  11687. if(cache.size()<3)
  11688. {
  11689. done= true;
  11690. }
  11691. }
  11692. }
  11693. /*:987*/
  11694. #line 43 "./rate.w"
  11695. if(cache.size()>=2)
  11696. {
  11697. /*988:*/
  11698. #line 96 "./rate.w"
  11699. int N= cache.size();
  11700. double SXY= 0;
  11701. double SX= 0;
  11702. double SXX= 0;
  11703. double SY= 0;
  11704. double y;
  11705. double x;
  11706. for(int i= 0;i<N;i++)
  11707. {
  11708. y= cache.at(i).temperature();
  11709. SY+= y;
  11710. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11711. SX+= x;
  11712. SXX+= (x*x);
  11713. SXY+= (x*y);
  11714. }
  11715. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11716. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11717. value.insert("relative",true);
  11718. emit newData(value);
  11719. /*:988*/
  11720. #line 46 "./rate.w"
  11721. }
  11722. }
  11723. /*:986*//*989:*/
  11724. #line 120 "./rate.w"
  11725. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11726. {
  11727. setScaleTime(scaletime);
  11728. }
  11729. void RateOfChange::setCacheTime(int seconds)
  11730. {
  11731. ct= seconds;
  11732. }
  11733. void RateOfChange::setScaleTime(int seconds)
  11734. {
  11735. st= (seconds> 0?seconds:1);
  11736. }
  11737. /*:989*/
  11738. #line 605 "./typica.w"
  11739. /*861:*/
  11740. #line 26 "./settings.w"
  11741. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11742. {
  11743. QTabWidget*settingsTab= new QTabWidget;
  11744. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11745. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11746. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11747. settingsTab->addTab(graphSettings,tr("Graph"));
  11748. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11749. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11750. setCentralWidget(settingsTab);
  11751. }
  11752. /*:861*/
  11753. #line 606 "./typica.w"
  11754. /*866:*/
  11755. #line 27 "./graphsettings.w"
  11756. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11757. {
  11758. QTabWidget*graphCategories= new QTabWidget;
  11759. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11760. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11761. QVBoxLayout*layout= new QVBoxLayout;
  11762. layout->addWidget(graphCategories);
  11763. setLayout(layout);
  11764. }
  11765. /*:866*//*868:*/
  11766. #line 69 "./graphsettings.w"
  11767. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11768. colorEdit(new QLineEdit)
  11769. {
  11770. QSettings settings;
  11771. QVBoxLayout*layout= new QVBoxLayout;
  11772. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11773. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11774. updateEnableSetting(enable->isChecked());
  11775. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11776. layout->addWidget(enable);
  11777. QHBoxLayout*colorLayout= new QHBoxLayout;
  11778. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11779. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11780. updateColorSetting(colorEdit->text());
  11781. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11782. QToolButton*colorPickerButton= new QToolButton();
  11783. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11784. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11785. colorLayout->addWidget(colorLabel);
  11786. colorLayout->addWidget(colorEdit);
  11787. colorLayout->addWidget(colorPickerButton);
  11788. colorLayout->addStretch();
  11789. layout->addLayout(colorLayout);
  11790. QHBoxLayout*unitLayout= new QHBoxLayout;
  11791. QLabel*unitLabel= new QLabel(tr("Unit"));
  11792. QComboBox*unitSelector= new QComboBox;
  11793. unitSelector->addItem(tr("Fahrenheit"));
  11794. unitSelector->addItem(tr("Celsius"));
  11795. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11796. updateUnit(unitSelector->currentIndex());
  11797. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11798. unitLayout->addWidget(unitLabel);
  11799. unitLayout->addWidget(unitSelector);
  11800. unitLayout->addStretch();
  11801. layout->addLayout(unitLayout);
  11802. QHBoxLayout*axisLayout= new QHBoxLayout;
  11803. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11804. QLineEdit*axisEdit= new QLineEdit;
  11805. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, 0, 30, 65, 100").toString());
  11806. updateAxisSetting(axisEdit->text());
  11807. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11808. axisLayout->addWidget(axisLabel);
  11809. axisLayout->addWidget(axisEdit);
  11810. layout->addLayout(axisLayout);
  11811. layout->addStretch();
  11812. setLayout(layout);
  11813. }
  11814. /*:868*//*869:*/
  11815. #line 120 "./graphsettings.w"
  11816. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11817. {
  11818. QSettings settings;
  11819. settings.setValue("settings/graph/relative/enable",enabled);
  11820. }
  11821. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11822. {
  11823. QSettings settings;
  11824. settings.setValue("settings/graph/relative/color",color);
  11825. }
  11826. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11827. {
  11828. QSettings settings;
  11829. QString settingValue;
  11830. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11831. QStringList numbers;
  11832. foreach(QString text,points)
  11833. {
  11834. bool okay= false;
  11835. text.toDouble(&okay);
  11836. if(okay)
  11837. {
  11838. numbers.append(text);
  11839. }
  11840. }
  11841. numbers.removeDuplicates();
  11842. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11843. }
  11844. void GraphSettingsRelativeTab::updateUnit(int unit)
  11845. {
  11846. QSettings settings;
  11847. settings.setValue("settings/graph/relative/unit",unit);
  11848. }
  11849. /*:869*//*870:*/
  11850. #line 163 "./graphsettings.w"
  11851. void GraphSettingsRelativeTab::showColorPicker()
  11852. {
  11853. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11854. colorEdit->setText(color.name());
  11855. }
  11856. #line 62 "./settings.w"
  11857. #line 1 "./advancedsettings.w"
  11858. /*:870*/
  11859. #line 607 "./typica.w"
  11860. /*1035:*/
  11861. #line 682 "./dataqsdk.w"
  11862. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11863. const QModelIndex&index)
  11864. :BasicDeviceConfigurationWidget(model,index),
  11865. deviceIdStack(new QStackedWidget)
  11866. {
  11867. QVBoxLayout*layout= new QVBoxLayout;
  11868. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11869. layout->addWidget(autoDetect);
  11870. QWidget*autoLayerWidget= new QWidget;
  11871. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11872. QLabel*autoLabel= new QLabel(tr("Device number"));
  11873. QSpinBox*autoNumber= new QSpinBox;
  11874. autoNumber->setMinimum(1);
  11875. autoNumber->setMaximum(99);
  11876. autoLayerLayout->addWidget(autoLabel);
  11877. autoLayerLayout->addWidget(autoNumber);
  11878. autoLayerWidget->setLayout(autoLayerLayout);
  11879. QWidget*fixedLayerWidget= new QWidget;
  11880. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11881. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11882. QComboBox*portSelection= new QComboBox;
  11883. portSelection->setEditable(true);
  11884. portSelection->addItems(DataqSdkDevice::detectHardware());
  11885. fixedLayerLayout->addWidget(fixedLabel);
  11886. fixedLayerLayout->addWidget(portSelection);
  11887. fixedLayerWidget->setLayout(fixedLayerLayout);
  11888. deviceIdStack->addWidget(autoLayerWidget);
  11889. deviceIdStack->addWidget(fixedLayerWidget);
  11890. layout->addWidget(deviceIdStack);
  11891. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11892. layout->addWidget(addChannelButton);
  11893. /*800:*/
  11894. #line 16608 "./typica.w"
  11895. QDomElement referenceElement=
  11896. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11897. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11898. QDomElement node;
  11899. /*:800*/
  11900. #line 714 "./dataqsdk.w"
  11901. for(int i= 0;i<configData.size();i++)
  11902. {
  11903. node= configData.at(i).toElement();
  11904. if(node.attribute("name")=="autoSelect")
  11905. {
  11906. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11907. }
  11908. else if(node.attribute("name")=="deviceNumber")
  11909. {
  11910. autoNumber->setValue(node.attribute("value").toInt());
  11911. }
  11912. else if(node.attribute("name")=="port")
  11913. {
  11914. int index= portSelection->findText(node.attribute("value"));
  11915. if(index> -1)
  11916. {
  11917. portSelection->setCurrentIndex(index);
  11918. }
  11919. else
  11920. {
  11921. portSelection->setEditText(node.attribute("value"));
  11922. }
  11923. }
  11924. }
  11925. updateAutoSelect(autoDetect->isChecked());
  11926. updateDeviceNumber(autoNumber->value());
  11927. updatePort(portSelection->currentText());
  11928. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11929. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11930. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11931. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11932. setLayout(layout);
  11933. }
  11934. /*:1035*//*1036:*/
  11935. #line 758 "./dataqsdk.w"
  11936. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11937. {
  11938. if(automatic)
  11939. {
  11940. updateAttribute("autoSelect","true");
  11941. deviceIdStack->setCurrentIndex(0);
  11942. }
  11943. else
  11944. {
  11945. updateAttribute("autoSelect","false");
  11946. deviceIdStack->setCurrentIndex(1);
  11947. }
  11948. }
  11949. /*:1036*//*1037:*/
  11950. #line 775 "./dataqsdk.w"
  11951. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11952. {
  11953. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11954. }
  11955. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11956. {
  11957. updateAttribute("port",portId);
  11958. }
  11959. /*:1037*//*1038:*/
  11960. #line 788 "./dataqsdk.w"
  11961. void DataqSdkDeviceConfWidget::addChannel()
  11962. {
  11963. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11964. }
  11965. /*:1038*//*1041:*/
  11966. #line 868 "./dataqsdk.w"
  11967. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11968. const QModelIndex&index)
  11969. :BasicDeviceConfigurationWidget(model,index),
  11970. startButton(new QPushButton(tr("Start"))),
  11971. resetButton(new QPushButton(tr("Reset"))),
  11972. stopButton(new QPushButton(tr("Stop"))),
  11973. calibrator(new LinearCalibrator),
  11974. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11975. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11976. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11977. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11978. rmCount(0),cmCount(0),
  11979. rmin(std::numeric_limits<double> ::max()),
  11980. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11981. cmin(std::numeric_limits<double> ::max()),
  11982. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11983. {
  11984. /*1045:*/
  11985. #line 1107 "./dataqsdk.w"
  11986. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11987. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11988. QDomElement deviceNode;
  11989. QString configPort;
  11990. QString configAuto;
  11991. for(int i= 0;i<deviceConfigData.size();i++)
  11992. {
  11993. deviceNode= deviceConfigData.at(i).toElement();
  11994. if(deviceNode.attribute("name")=="autoSelect")
  11995. {
  11996. autoSelect= (deviceNode.attribute("value")=="true");
  11997. }
  11998. else if(deviceNode.attribute("name")=="deviceNumber")
  11999. {
  12000. configAuto= deviceNode.attribute("value");
  12001. }
  12002. else if(deviceNode.attribute("name")=="port")
  12003. {
  12004. configPort= deviceNode.attribute("value");
  12005. }
  12006. }
  12007. deviceID= autoSelect?configAuto:configPort;
  12008. channelOfInterest= index.row();
  12009. /*:1045*/
  12010. #line 886 "./dataqsdk.w"
  12011. resetButton->setEnabled(false);
  12012. stopButton->setEnabled(false);
  12013. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  12014. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  12015. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  12016. QVBoxLayout*layout= new QVBoxLayout;
  12017. QFormLayout*topLayout= new QFormLayout;
  12018. QLineEdit*columnEdit= new QLineEdit;
  12019. topLayout->addRow(tr("Column name"),columnEdit);
  12020. QComboBox*unitSelector= new QComboBox;
  12021. unitSelector->addItem(tr("Temperature"));
  12022. unitSelector->addItem(tr("Control"));
  12023. topLayout->addRow(tr("Measurement type"),unitSelector);
  12024. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  12025. topLayout->addRow(smoothingBox);
  12026. layout->addLayout(topLayout);
  12027. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  12028. topLayout->addRow(hideSeries);
  12029. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  12030. layout->addWidget(calibrationLabel);
  12031. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  12032. QFormLayout*calibrationControlsLayout= new QFormLayout;
  12033. QLineEdit*measuredLowerEdit= new QLineEdit;
  12034. measuredLowerEdit->setText("0");
  12035. QLineEdit*measuredUpperEdit= new QLineEdit;
  12036. measuredUpperEdit->setText("10");
  12037. QLineEdit*mappedLowerEdit= new QLineEdit;
  12038. mappedLowerEdit->setText("0");
  12039. QLineEdit*mappedUpperEdit= new QLineEdit;
  12040. mappedUpperEdit->setText("10");
  12041. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  12042. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  12043. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  12044. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  12045. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  12046. calibrationControlsLayout->addRow(closedBox);
  12047. QLineEdit*sensitivityEdit= new QLineEdit;
  12048. sensitivityEdit->setText("0");
  12049. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  12050. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  12051. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  12052. deviceControlLayout->addWidget(startButton);
  12053. deviceControlLayout->addWidget(resetButton);
  12054. deviceControlLayout->addWidget(stopButton);
  12055. QFormLayout*indicatorLayout= new QFormLayout;
  12056. currentMeasurement->setReadOnly(true);
  12057. minimumMeasurement->setReadOnly(true);
  12058. maximumMeasurement->setReadOnly(true);
  12059. averageMeasurement->setReadOnly(true);
  12060. currentMapped->setReadOnly(true);
  12061. minimumMapped->setReadOnly(true);
  12062. maximumMapped->setReadOnly(true);
  12063. averageMapped->setReadOnly(true);
  12064. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  12065. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  12066. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  12067. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  12068. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  12069. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  12070. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  12071. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  12072. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  12073. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  12074. calibrationTestLayout->addLayout(deviceControlLayout);
  12075. calibrationTestLayout->addLayout(indicatorLayout);
  12076. calibrationLayout->addLayout(calibrationControlsLayout);
  12077. calibrationLayout->addLayout(calibrationTestLayout);
  12078. layout->addLayout(calibrationLayout);
  12079. /*800:*/
  12080. #line 16608 "./typica.w"
  12081. QDomElement referenceElement=
  12082. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12083. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12084. QDomElement node;
  12085. /*:800*/
  12086. #line 955 "./dataqsdk.w"
  12087. for(int i= 0;i<configData.size();i++)
  12088. {
  12089. node= configData.at(i).toElement();
  12090. if(node.attribute("name")=="column")
  12091. {
  12092. columnEdit->setText(node.attribute("value"));
  12093. }
  12094. else if(node.attribute("name")=="type")
  12095. {
  12096. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  12097. }
  12098. else if(node.attribute("name")=="smoothing")
  12099. {
  12100. smoothingBox->setChecked(node.attribute("value")=="true");
  12101. }
  12102. else if(node.attribute("name")=="calibrationMeasuredLower")
  12103. {
  12104. measuredLowerEdit->setText(node.attribute("value"));
  12105. }
  12106. else if(node.attribute("name")=="calibrationMeasuredUpper")
  12107. {
  12108. measuredUpperEdit->setText(node.attribute("value"));
  12109. }
  12110. else if(node.attribute("name")=="calibrationMappedLower")
  12111. {
  12112. mappedLowerEdit->setText(node.attribute("value"));
  12113. }
  12114. else if(node.attribute("name")=="calibrationMappedUpper")
  12115. {
  12116. mappedUpperEdit->setText(node.attribute("value"));
  12117. }
  12118. else if(node.attribute("name")=="calibrationClosedInterval")
  12119. {
  12120. closedBox->setChecked(node.attribute("value")=="true");
  12121. }
  12122. else if(node.attribute("name")=="calibrationSensitivity")
  12123. {
  12124. sensitivityEdit->setText(node.attribute("value"));
  12125. }
  12126. else if(node.attribute("name")=="hidden")
  12127. {
  12128. hideSeries->setChecked(node.attribute("value")=="true");
  12129. }
  12130. }
  12131. updateColumnName(columnEdit->text());
  12132. updateUnits(unitSelector->currentText());
  12133. updateSmoothingEnabled(smoothingBox->isChecked());
  12134. updateMeasuredLower(measuredLowerEdit->text());
  12135. updateMeasuredUpper(measuredUpperEdit->text());
  12136. updateMappedLower(mappedLowerEdit->text());
  12137. updateMappedUpper(mappedUpperEdit->text());
  12138. updateClosedInterval(closedBox->isChecked());
  12139. updateSensitivity(sensitivityEdit->text());
  12140. updateHidden(hideSeries->isChecked());
  12141. connect(columnEdit,SIGNAL(textChanged(QString)),
  12142. this,SLOT(updateColumnName(QString)));
  12143. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  12144. this,SLOT(updateUnits(QString)));
  12145. connect(smoothingBox,SIGNAL(toggled(bool)),
  12146. this,SLOT(updateSmoothingEnabled(bool)));
  12147. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  12148. this,SLOT(updateMeasuredLower(QString)));
  12149. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  12150. this,SLOT(updateMappedLower(QString)));
  12151. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  12152. this,SLOT(updateMeasuredUpper(QString)));
  12153. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  12154. this,SLOT(updateMappedUpper(QString)));
  12155. connect(closedBox,SIGNAL(toggled(bool)),
  12156. this,SLOT(updateClosedInterval(bool)));
  12157. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  12158. this,SLOT(updateSensitivity(QString)));
  12159. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12160. setLayout(layout);
  12161. }
  12162. /*:1041*//*1042:*/
  12163. #line 1038 "./dataqsdk.w"
  12164. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  12165. {
  12166. updateAttribute("type",unit);
  12167. }
  12168. /*:1042*//*1043:*/
  12169. #line 1047 "./dataqsdk.w"
  12170. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  12171. {
  12172. updateAttribute("calibrationMeasuredLower",value);
  12173. calibrator->setMeasuredLower(value.toDouble());
  12174. }
  12175. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  12176. {
  12177. updateAttribute("calibrationMeasuredUpper",value);
  12178. calibrator->setMeasuredUpper(value.toDouble());
  12179. }
  12180. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  12181. {
  12182. updateAttribute("calibrationMappedLower",value);
  12183. calibrator->setMappedLower(value.toDouble());
  12184. }
  12185. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  12186. {
  12187. updateAttribute("calibrationMappedUpper",value);
  12188. calibrator->setMappedUpper(value.toDouble());
  12189. }
  12190. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  12191. {
  12192. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  12193. calibrator->setClosedRange(closed);
  12194. }
  12195. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  12196. {
  12197. updateAttribute("smoothing",enabled?"true":"false");
  12198. }
  12199. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  12200. {
  12201. updateAttribute("calibrationSensitivity",value);
  12202. calibrator->setSensitivity(value.toDouble());
  12203. }
  12204. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  12205. {
  12206. updateAttribute("hidden",hidden?"true":"false");
  12207. }
  12208. /*:1043*//*1046:*/
  12209. #line 1136 "./dataqsdk.w"
  12210. void DataqSdkChannelConfWidget::startCalibration()
  12211. {
  12212. startButton->setEnabled(false);
  12213. stopButton->setEnabled(true);
  12214. resetButton->setEnabled(true);
  12215. calibrationDevice= new DataqSdkDevice(deviceID);
  12216. Channel*channel;
  12217. for(unsigned int i= 0;i<=channelOfInterest;i++)
  12218. {
  12219. channel= calibrationDevice->newChannel(Units::Unitless);
  12220. }
  12221. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  12222. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  12223. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  12224. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  12225. calibrationDevice->start();
  12226. }
  12227. void DataqSdkChannelConfWidget::stopCalibration()
  12228. {
  12229. startButton->setEnabled(true);
  12230. stopButton->setEnabled(false);
  12231. resetButton->setEnabled(false);
  12232. calibrationDevice->deleteLater();
  12233. /*1048:*/
  12234. #line 1181 "./dataqsdk.w"
  12235. rmCount= 0;
  12236. cmCount= 0;
  12237. rmin= std::numeric_limits<double> ::max();
  12238. rmax= std::numeric_limits<double> ::min();
  12239. rmean= 0;
  12240. cmin= std::numeric_limits<double> ::max();
  12241. cmax= std::numeric_limits<double> ::min();
  12242. cmean= 0;
  12243. /*:1048*/
  12244. #line 1161 "./dataqsdk.w"
  12245. }
  12246. /*:1046*//*1047:*/
  12247. #line 1172 "./dataqsdk.w"
  12248. void DataqSdkChannelConfWidget::resetCalibration()
  12249. {
  12250. /*1048:*/
  12251. #line 1181 "./dataqsdk.w"
  12252. rmCount= 0;
  12253. cmCount= 0;
  12254. rmin= std::numeric_limits<double> ::max();
  12255. rmax= std::numeric_limits<double> ::min();
  12256. rmean= 0;
  12257. cmin= std::numeric_limits<double> ::max();
  12258. cmax= std::numeric_limits<double> ::min();
  12259. cmean= 0;
  12260. /*:1048*/
  12261. #line 1175 "./dataqsdk.w"
  12262. }
  12263. /*:1047*//*1049:*/
  12264. #line 1195 "./dataqsdk.w"
  12265. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  12266. {
  12267. double nv= measure.temperature();
  12268. currentMeasurement->setText(QString("%1").arg(nv));
  12269. rmin= qMin(nv,rmin);
  12270. minimumMeasurement->setText(QString("%1").arg(rmin));
  12271. rmax= qMax(nv,rmax);
  12272. maximumMeasurement->setText(QString("%1").arg(rmax));
  12273. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  12274. rmCount++;
  12275. averageMeasurement->setText(QString("%1").arg(rmean));
  12276. }
  12277. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  12278. {
  12279. double nv= measure.temperature();
  12280. currentMapped->setText(QString("%1").arg(nv));
  12281. cmin= qMin(nv,cmin);
  12282. minimumMapped->setText(QString("%1").arg(cmin));
  12283. cmax= qMax(nv,cmax);
  12284. maximumMapped->setText(QString("%1").arg(cmax));
  12285. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  12286. cmCount++;
  12287. averageMapped->setText(QString("%1").arg(cmean));
  12288. }
  12289. /*:1049*//*1050:*/
  12290. #line 1224 "./dataqsdk.w"
  12291. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  12292. {
  12293. updateAttribute("column",value);
  12294. }
  12295. /*:1050*/
  12296. #line 608 "./typica.w"
  12297. /*1074:*/
  12298. #line 423 "./scales.w"
  12299. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  12300. const QModelIndex&index)
  12301. :BasicDeviceConfigurationWidget(model,index),
  12302. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  12303. flow(new FlowSelector),stop(new StopSelector),
  12304. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  12305. {
  12306. QFormLayout*layout= new QFormLayout;
  12307. layout->addRow(tr("Port:"),port);
  12308. connect(port,SIGNAL(currentIndexChanged(QString)),
  12309. this,SLOT(updatePort(QString)));
  12310. connect(port,SIGNAL(editTextChanged(QString)),
  12311. this,SLOT(updatePort(QString)));
  12312. layout->addRow(tr("Baud:"),baud);
  12313. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12314. this,SLOT(updateBaudRate(QString)));
  12315. layout->addRow(tr("Parity:"),parity);
  12316. connect(parity,SIGNAL(currentIndexChanged(int)),
  12317. this,SLOT(updateParity(int)));
  12318. layout->addRow(tr("Flow Control:"),flow);
  12319. connect(flow,SIGNAL(currentIndexChanged(int)),
  12320. this,SLOT(updateFlowControl(int)));
  12321. layout->addRow(tr("Stop Bits:"),stop);
  12322. connect(stop,SIGNAL(currentIndexChanged(int)),
  12323. this,SLOT(updateStopBits(int)));
  12324. layout->addRow(tr("Weigh Command:"),weighcommand);
  12325. connect(weighcommand,SIGNAL(textChanged(QString)),
  12326. this,SLOT(updateWeighCommand(QString)));
  12327. commandterminator->addItem("CRLF");
  12328. commandterminator->addItem("CR");
  12329. commandterminator->addItem("LF");
  12330. layout->addRow(tr("Command Terminator:"),commandterminator);
  12331. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12332. this,SLOT(updateCommandTerminator(QString)));
  12333. /*800:*/
  12334. #line 16608 "./typica.w"
  12335. QDomElement referenceElement=
  12336. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12337. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12338. QDomElement node;
  12339. /*:800*/
  12340. #line 459 "./scales.w"
  12341. for(int i= 0;i<configData.size();i++)
  12342. {
  12343. node= configData.at(i).toElement();
  12344. if(node.attribute("name")=="port")
  12345. {
  12346. int j= port->findText(node.attribute("value"));
  12347. if(j>=0)
  12348. {
  12349. port->setCurrentIndex(j);
  12350. }
  12351. else
  12352. {
  12353. port->insertItem(0,node.attribute("value"));
  12354. port->setCurrentIndex(0);
  12355. }
  12356. }
  12357. else if(node.attribute("name")=="baudrate")
  12358. {
  12359. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12360. }
  12361. else if(node.attribute("name")=="parity")
  12362. {
  12363. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12364. }
  12365. else if(node.attribute("name")=="flowcontrol")
  12366. {
  12367. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12368. }
  12369. else if(node.attribute("name")=="stopbits")
  12370. {
  12371. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12372. }
  12373. else if(node.attribute("name")=="weighcommand")
  12374. {
  12375. weighcommand->setText(node.attribute("value"));
  12376. }
  12377. else if(node.attribute("name")=="commandterminator")
  12378. {
  12379. commandterminator->setCurrentIndex(
  12380. commandterminator->findText(node.attribute("value")));
  12381. }
  12382. }
  12383. updatePort(port->currentText());
  12384. updateBaudRate(baud->currentText());
  12385. updateParity(parity->currentIndex());
  12386. updateFlowControl(flow->currentIndex());
  12387. updateStopBits(stop->currentIndex());
  12388. updateWeighCommand(weighcommand->text());
  12389. updateCommandTerminator(commandterminator->currentText());
  12390. setLayout(layout);
  12391. }
  12392. /*:1074*//*1075:*/
  12393. #line 514 "./scales.w"
  12394. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12395. {
  12396. updateAttribute("port",newPort);
  12397. }
  12398. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12399. {
  12400. updateAttribute("baudrate",rate);
  12401. }
  12402. void SerialScaleConfWidget::updateParity(int index)
  12403. {
  12404. updateAttribute("parity",parity->itemData(index).toString());
  12405. }
  12406. void SerialScaleConfWidget::updateFlowControl(int index)
  12407. {
  12408. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12409. }
  12410. void SerialScaleConfWidget::updateStopBits(int index)
  12411. {
  12412. updateAttribute("stopbits",stop->itemData(index).toString());
  12413. }
  12414. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12415. {
  12416. updateAttribute("weighcommand",command);
  12417. }
  12418. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12419. {
  12420. updateAttribute("commandterminator",terminator);
  12421. }
  12422. /*:1075*/
  12423. #line 609 "./typica.w"
  12424. /*1087:*/
  12425. #line 195 "./valueannotation.w"
  12426. void ValueAnnotation::newMeasurement(Measurement measure)
  12427. {
  12428. for(int i= 0;i<values.size();i++)
  12429. {
  12430. if(measure.temperature()> values.at(i)-tolerance&&
  12431. measure.temperature()<values.at(i)+tolerance)
  12432. {
  12433. if(i!=lastIndex)
  12434. {
  12435. lastIndex= i;
  12436. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12437. }
  12438. }
  12439. }
  12440. }
  12441. /*:1087*//*1088:*/
  12442. #line 216 "./valueannotation.w"
  12443. void ValueAnnotation::annotate()
  12444. {
  12445. if(lastIndex> -1)
  12446. {
  12447. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12448. }
  12449. }
  12450. /*:1088*//*1089:*/
  12451. #line 228 "./valueannotation.w"
  12452. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12453. {
  12454. values.append(value);
  12455. annotations.append(annotation);
  12456. }
  12457. /*:1089*//*1090:*/
  12458. #line 237 "./valueannotation.w"
  12459. void ValueAnnotation::setAnnotationColumn(int column)
  12460. {
  12461. annotationColumn= column;
  12462. }
  12463. void ValueAnnotation::setTemperatureColumn(int column)
  12464. {
  12465. measurementColumn= column;
  12466. }
  12467. void ValueAnnotation::setTolerance(double epsilon)
  12468. {
  12469. tolerance= epsilon;
  12470. }
  12471. /*:1090*//*1091:*/
  12472. #line 255 "./valueannotation.w"
  12473. ValueAnnotation::ValueAnnotation():QObject(),
  12474. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12475. {
  12476. }
  12477. /*:1091*/
  12478. #line 610 "./typica.w"
  12479. /*1079:*/
  12480. #line 33 "./valueannotation.w"
  12481. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12482. const QModelIndex&index)
  12483. :BasicDeviceConfigurationWidget(model,index),
  12484. tablemodel(new SaltModel(2))
  12485. {
  12486. QFormLayout*layout= new QFormLayout;
  12487. QLineEdit*source= new QLineEdit;
  12488. layout->addRow(tr("Source column name:"),source);
  12489. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12490. noteOnStart->setChecked(true);
  12491. layout->addRow(noteOnStart);
  12492. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12493. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12494. QTableView*annotationTable= new QTableView;
  12495. annotationTable->setModel(tablemodel);
  12496. NumericDelegate*delegate= new NumericDelegate;
  12497. annotationTable->setItemDelegateForColumn(0,delegate);
  12498. layout->addRow(tr("Annotations for values:"),annotationTable);
  12499. /*800:*/
  12500. #line 16608 "./typica.w"
  12501. QDomElement referenceElement=
  12502. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12503. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12504. QDomElement node;
  12505. /*:800*/
  12506. #line 52 "./valueannotation.w"
  12507. for(int i= 0;i<configData.size();i++)
  12508. {
  12509. node= configData.at(i).toElement();
  12510. if(node.attribute("name")=="source")
  12511. {
  12512. source->setText(node.attribute("value"));
  12513. }
  12514. else if(node.attribute("name")=="emitOnStart")
  12515. {
  12516. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12517. }
  12518. else if(node.attribute("name")=="measuredValues")
  12519. {
  12520. /*963:*/
  12521. #line 19696 "./typica.w"
  12522. QString data= node.attribute("value");
  12523. if(data.length()> 3)
  12524. {
  12525. data.chop(2);
  12526. data= data.remove(0,2);
  12527. }
  12528. QStringList itemList= data.split(",");
  12529. /*:963*/
  12530. #line 66 "./valueannotation.w"
  12531. int column= 0;
  12532. /*964:*/
  12533. #line 19708 "./typica.w"
  12534. for(int j= 0;j<itemList.size();j++)
  12535. {
  12536. tablemodel->setData(tablemodel->index(j,column),
  12537. QVariant(itemList.at(j).toDouble()),
  12538. Qt::DisplayRole);
  12539. }
  12540. /*:964*/
  12541. #line 68 "./valueannotation.w"
  12542. }
  12543. else if(node.attribute("name")=="annotations")
  12544. {
  12545. /*1080:*/
  12546. #line 89 "./valueannotation.w"
  12547. QString data= node.attribute("value");
  12548. if(data.length()> 3)
  12549. {
  12550. data.chop(2);
  12551. data= data.remove(0,2);
  12552. }
  12553. QStringList itemList= data.split(",");
  12554. for(int i= 0;i<itemList.size();i++)
  12555. {
  12556. itemList[i]= itemList[i].simplified();
  12557. }
  12558. /*:1080*/
  12559. #line 72 "./valueannotation.w"
  12560. int column= 1;
  12561. /*1081:*/
  12562. #line 104 "./valueannotation.w"
  12563. for(int i= 0;i<itemList.size();i++)
  12564. {
  12565. tablemodel->setData(tablemodel->index(i,column),
  12566. QVariant(itemList.at(i)),
  12567. Qt::DisplayRole);
  12568. }
  12569. /*:1081*/
  12570. #line 74 "./valueannotation.w"
  12571. }
  12572. }
  12573. updateSourceColumn(source->text());
  12574. updateStart(noteOnStart->isChecked());
  12575. updateAnnotations();
  12576. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12577. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12578. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12579. setLayout(layout);
  12580. }
  12581. /*:1079*//*1082:*/
  12582. #line 115 "./valueannotation.w"
  12583. void ValueAnnotationConfWidget::updateAnnotations()
  12584. {
  12585. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12586. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12587. }
  12588. /*:1082*//*1083:*/
  12589. #line 125 "./valueannotation.w"
  12590. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12591. {
  12592. updateAttribute("source",source);
  12593. }
  12594. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12595. {
  12596. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12597. }
  12598. /*:1083*/
  12599. #line 611 "./typica.w"
  12600. /*896:*/
  12601. #line 44 "./modbus.w"
  12602. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12603. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12604. m_flow(new FlowSelector),m_stop(new StopSelector)
  12605. {
  12606. QFormLayout*layout= new QFormLayout;
  12607. PortSelector*port= new PortSelector;
  12608. BaudSelector*baud= new BaudSelector;
  12609. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12610. layout->addRow(QString(tr("Port:")),port);
  12611. layout->addRow(QString(tr("Baud rate:")),baud);
  12612. layout->addRow(QString(tr("Parity:")),m_parity);
  12613. layout->addRow(QString(tr("Flow control:")),m_flow);
  12614. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12615. layout->addRow(newInput);
  12616. /*800:*/
  12617. #line 16608 "./typica.w"
  12618. QDomElement referenceElement=
  12619. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12620. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12621. QDomElement node;
  12622. /*:800*/
  12623. #line 60 "./modbus.w"
  12624. for(int i= 0;i<configData.size();i++)
  12625. {
  12626. node= configData.at(i).toElement();
  12627. if(node.attribute("name")=="port")
  12628. {
  12629. int idx= port->findText(node.attribute("value"));
  12630. if(idx>=0)
  12631. {
  12632. port->setCurrentIndex(idx);
  12633. }
  12634. else
  12635. {
  12636. port->addItem(node.attribute("value"));
  12637. }
  12638. }
  12639. else if(node.attribute("name")=="baud")
  12640. {
  12641. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12642. }
  12643. else if(node.attribute("name")=="parity")
  12644. {
  12645. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12646. }
  12647. else if(node.attribute("name")=="flow")
  12648. {
  12649. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12650. }
  12651. else if(node.attribute("name")=="stop")
  12652. {
  12653. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12654. }
  12655. }
  12656. updatePort(port->currentText());
  12657. updateBaudRate(baud->currentText());
  12658. updateParity(m_parity->currentIndex());
  12659. updateFlowControl(m_flow->currentIndex());
  12660. updateStopBits(m_stop->currentIndex());
  12661. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12662. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12663. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12664. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12665. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12666. this,SLOT(updateFlowControl(int)));
  12667. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12668. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12669. setLayout(layout);
  12670. }
  12671. void ModbusNGConfWidget::updatePort(const QString&value)
  12672. {
  12673. updateAttribute("port",value);
  12674. }
  12675. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12676. {
  12677. updateAttribute("baud",value);
  12678. }
  12679. void ModbusNGConfWidget::updateParity(int value)
  12680. {
  12681. updateAttribute("parity",m_parity->itemData(value).toString());
  12682. }
  12683. void ModbusNGConfWidget::updateFlowControl(int value)
  12684. {
  12685. updateAttribute("flow",m_flow->itemData(value).toString());
  12686. }
  12687. void ModbusNGConfWidget::updateStopBits(int value)
  12688. {
  12689. updateAttribute("stop",m_stop->itemData(value).toString());
  12690. }
  12691. void ModbusNGConfWidget::addInput()
  12692. {
  12693. insertChildNode(tr("Input"),"modbusnginput");
  12694. }
  12695. /*:896*//*898:*/
  12696. #line 164 "./modbus.w"
  12697. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12698. {
  12699. QFormLayout*layout= new QFormLayout;
  12700. QSpinBox*station= new QSpinBox;
  12701. station->setMinimum(1);
  12702. station->setMaximum(247);
  12703. layout->addRow(tr("Station ID"),station);
  12704. QComboBox*function= new QComboBox;
  12705. function->addItem("3","3");
  12706. function->addItem("4","4");
  12707. function->setCurrentIndex(1);
  12708. layout->addRow(tr("Function"),function);
  12709. ShortHexSpinBox*address= new ShortHexSpinBox;
  12710. layout->addRow(tr("Address"),address);
  12711. QComboBox*format= new QComboBox;
  12712. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12713. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12714. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12715. layout->addRow(tr("Data format"),format);
  12716. QSpinBox*decimals= new QSpinBox;
  12717. decimals->setMinimum(0);
  12718. decimals->setMaximum(9);
  12719. layout->addRow(tr("Decimal places"),decimals);
  12720. QComboBox*unit= new QComboBox;
  12721. unit->addItem("Celsius","C");
  12722. unit->addItem("Fahrenheit","F");
  12723. unit->addItem("Control","Control");
  12724. unit->setCurrentIndex(1);
  12725. layout->addRow(tr("Unit"),unit);
  12726. QLineEdit*column= new QLineEdit;
  12727. layout->addRow(tr("Column name"),column);
  12728. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12729. layout->addRow(hidden);
  12730. /*800:*/
  12731. #line 16608 "./typica.w"
  12732. QDomElement referenceElement=
  12733. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12734. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12735. QDomElement node;
  12736. /*:800*/
  12737. #line 199 "./modbus.w"
  12738. for(int i= 0;i<configData.size();i++)
  12739. {
  12740. node= configData.at(i).toElement();
  12741. if(node.attribute("name")=="station")
  12742. {
  12743. station->setValue(node.attribute("value").toInt());
  12744. }
  12745. else if(node.attribute("name")=="function")
  12746. {
  12747. function->setCurrentIndex(function->findText(node.attribute("value")));
  12748. }
  12749. else if(node.attribute("name")=="address")
  12750. {
  12751. address->setValue(node.attribute("value").toInt());
  12752. }
  12753. else if(node.attribute("name")=="format")
  12754. {
  12755. format->setCurrentIndex(format->findData(node.attribute("value")));
  12756. }
  12757. else if(node.attribute("name")=="decimals")
  12758. {
  12759. decimals->setValue(node.attribute("value").toInt());
  12760. }
  12761. else if(node.attribute("name")=="unit")
  12762. {
  12763. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12764. }
  12765. else if(node.attribute("name")=="column")
  12766. {
  12767. column->setText(node.attribute("value"));
  12768. }
  12769. else if(node.attribute("name")=="hidden")
  12770. {
  12771. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12772. }
  12773. }
  12774. updateStation(station->value());
  12775. updateFunction(function->currentIndex());
  12776. updateAddress(address->value());
  12777. updateFormat(format->currentIndex());
  12778. updateDecimals(decimals->value());
  12779. updateUnit(unit->currentIndex());
  12780. updateColumnName(column->text());
  12781. updateHidden(hidden->isChecked());
  12782. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12783. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12784. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12785. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12786. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12787. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12788. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12789. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12790. setLayout(layout);
  12791. }
  12792. void ModbusNGInputConfWidget::updateStation(int value)
  12793. {
  12794. updateAttribute("station",QString("%1").arg(value));
  12795. }
  12796. void ModbusNGInputConfWidget::updateFunction(int value)
  12797. {
  12798. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12799. }
  12800. void ModbusNGInputConfWidget::updateAddress(int value)
  12801. {
  12802. updateAttribute("address",QString("%1").arg(value));
  12803. }
  12804. void ModbusNGInputConfWidget::updateFormat(int value)
  12805. {
  12806. switch(value)
  12807. {
  12808. case 0:
  12809. updateAttribute("format","16fixedint");
  12810. break;
  12811. case 1:
  12812. updateAttribute("format","32floathl");
  12813. break;
  12814. case 2:
  12815. updateAttribute("format","32floatlh");
  12816. break;
  12817. }
  12818. }
  12819. void ModbusNGInputConfWidget::updateDecimals(int value)
  12820. {
  12821. updateAttribute("decimals",QString("%1").arg(value));
  12822. }
  12823. void ModbusNGInputConfWidget::updateUnit(int value)
  12824. {
  12825. switch(value)
  12826. {
  12827. case 0:
  12828. updateAttribute("unit","C");
  12829. break;
  12830. case 1:
  12831. updateAttribute("unit","F");
  12832. break;
  12833. case 2:
  12834. updateAttribute("unit","Control");
  12835. break;
  12836. }
  12837. }
  12838. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  12839. {
  12840. updateAttribute("column",value);
  12841. }
  12842. void ModbusNGInputConfWidget::updateHidden(bool value)
  12843. {
  12844. updateAttribute("hidden",value?"true":"false");
  12845. }
  12846. /*:898*//*903:*/
  12847. #line 403 "./modbus.w"
  12848. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  12849. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  12850. rateLimiter(new QTimer),scanPosition(0),waiting(false)
  12851. {
  12852. QDomElement portReferenceElement=
  12853. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12854. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  12855. QDomElement node;
  12856. QVariantMap attributes;
  12857. for(int i= 0;i<portConfigData.size();i++)
  12858. {
  12859. node= portConfigData.at(i).toElement();
  12860. attributes.insert(node.attribute("name"),node.attribute("value"));
  12861. }
  12862. port= new QextSerialPort(attributes.value("port").toString(),
  12863. QextSerialPort::EventDriven);
  12864. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  12865. port->setDataBits(DATA_8);
  12866. port->setParity((ParityType)attributes.value("parity").toInt());
  12867. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  12868. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  12869. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  12870. messageDelayTimer->setSingleShot(true);
  12871. commTimeout->setSingleShot(true);
  12872. rateLimiter->setSingleShot(true);
  12873. rateLimiter->setInterval(0);
  12874. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  12875. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  12876. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  12877. connect(rateLimiter,SIGNAL(timeout()),this,SLOT(rateLimitTimeout()));
  12878. if(!port->open(QIODevice::ReadWrite))
  12879. {
  12880. qDebug()<<"Failed to open serial port";
  12881. }
  12882. for(int i= 0;i<model->rowCount(index);i++)
  12883. {
  12884. QModelIndex channelIndex= model->index(i,0,index);
  12885. QDomElement channelReferenceElement=
  12886. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12887. QDomNodeList channelConfigData=
  12888. channelReferenceElement.elementsByTagName("attribute");
  12889. QDomElement channelNode;
  12890. QVariantMap channelAttributes;
  12891. for(int j= 0;j<channelConfigData.size();j++)
  12892. {
  12893. channelNode= channelConfigData.at(j).toElement();
  12894. channelAttributes.insert(channelNode.attribute("name"),
  12895. channelNode.attribute("value"));
  12896. }
  12897. ModbusScanItem scanItem;
  12898. QString format= channelAttributes.value("format").toString();
  12899. if(format=="16fixedint")
  12900. {
  12901. scanItem.format= Int16;
  12902. }
  12903. else if(format=="32floathl")
  12904. {
  12905. scanItem.format= FloatHL;
  12906. }
  12907. else if(format=="32floatlh")
  12908. {
  12909. scanItem.format= FloatLH;
  12910. }
  12911. scanItem.request.append((char)channelAttributes.value("station").toInt());
  12912. scanItem.request.append((char)channelAttributes.value("function").toInt());
  12913. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  12914. char*startAddressBytes= (char*)&startAddress;
  12915. scanItem.request.append(startAddressBytes[1]);
  12916. scanItem.request.append(startAddressBytes[0]);
  12917. scanItem.request.append((char)0x00);
  12918. if(scanItem.format==Int16)
  12919. {
  12920. scanItem.request.append((char)0x01);
  12921. }
  12922. else
  12923. {
  12924. scanItem.request.append((char)0x02);
  12925. }
  12926. quint16 crc= calculateCRC(scanItem.request);
  12927. char*crcBytes= (char*)&crc;
  12928. scanItem.request.append(crcBytes[0]);
  12929. scanItem.request.append(crcBytes[1]);
  12930. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  12931. if(channelAttributes.value("unit").toString()=="C")
  12932. {
  12933. scanItem.unit= Units::Celsius;
  12934. channelTypeList.append("T");
  12935. }
  12936. else if(channelAttributes.value("unit").toString()=="F")
  12937. {
  12938. scanItem.unit= Units::Fahrenheit;
  12939. channelTypeList.append("T");
  12940. }
  12941. else
  12942. {
  12943. scanItem.unit= Units::Unitless;
  12944. channelTypeList.append("C");
  12945. }
  12946. scanList.append(scanItem);
  12947. lastMeasurement.append(0.0);
  12948. channels.append(new Channel);
  12949. channelNames.append(channelAttributes.value("column").toString());
  12950. hiddenStates.append(
  12951. channelAttributes.value("hidden").toString()=="true"?true:false);
  12952. channelLabels.append(model->data(channelIndex,0).toString());
  12953. }
  12954. messageDelayTimer->start();
  12955. }
  12956. ModbusNG::~ModbusNG()
  12957. {
  12958. commTimeout->stop();
  12959. messageDelayTimer->stop();
  12960. port->close();
  12961. }
  12962. void ModbusNG::sendNextMessage()
  12963. {
  12964. if(scanList.length()> 0&&!waiting)
  12965. {
  12966. port->write(scanList.at(scanPosition).request);
  12967. commTimeout->start(2000);
  12968. messageDelayTimer->start(delayTime);
  12969. waiting= true;
  12970. }
  12971. }
  12972. void ModbusNG::timeout()
  12973. {
  12974. qDebug()<<"Communications timeout.";
  12975. messageDelayTimer->start();
  12976. }
  12977. void ModbusNG::rateLimitTimeout()
  12978. {
  12979. messageDelayTimer->start();
  12980. }
  12981. void ModbusNG::dataAvailable()
  12982. {
  12983. if(messageDelayTimer->isActive())
  12984. {
  12985. messageDelayTimer->stop();
  12986. }
  12987. responseBuffer.append(port->readAll());
  12988. if(responseBuffer.size()<5)
  12989. {
  12990. return;
  12991. }
  12992. if(responseBuffer.size()<5+responseBuffer.at(2))
  12993. {
  12994. return;
  12995. }
  12996. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  12997. commTimeout->stop();
  12998. if(calculateCRC(responseBuffer)==0)
  12999. {
  13000. quint16 intresponse;
  13001. float floatresponse;
  13002. char*ibytes= (char*)&intresponse;
  13003. char*fbytes= (char*)&floatresponse;
  13004. double output;
  13005. switch(scanList.at(scanPosition).format)
  13006. {
  13007. case Int16:
  13008. ibytes[0]= responseBuffer.at(4);
  13009. ibytes[1]= responseBuffer.at(3);
  13010. output= intresponse;
  13011. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  13012. {
  13013. output/= 10;
  13014. }
  13015. break;
  13016. case FloatHL:
  13017. fbytes[0]= responseBuffer.at(4);
  13018. fbytes[1]= responseBuffer.at(3);
  13019. fbytes[2]= responseBuffer.at(6);
  13020. fbytes[3]= responseBuffer.at(5);
  13021. output= floatresponse;
  13022. break;
  13023. case FloatLH:
  13024. fbytes[0]= responseBuffer.at(6);
  13025. fbytes[1]= responseBuffer.at(5);
  13026. fbytes[2]= responseBuffer.at(4);
  13027. fbytes[3]= responseBuffer.at(3);
  13028. output= floatresponse;
  13029. break;
  13030. }
  13031. if(scanList.at(scanPosition).unit==Units::Celsius)
  13032. {
  13033. output= output*9.0/5.0+32.0;
  13034. }
  13035. scanList.at(scanPosition).lastValue= output;
  13036. }
  13037. else
  13038. {
  13039. qDebug()<<"CRC failed";
  13040. }
  13041. scanPosition= (scanPosition+1)%scanList.size();
  13042. if(scanPosition==0)
  13043. {
  13044. QTime time= QTime::currentTime();
  13045. bool doOutput= false;
  13046. for(int i= 0;i<scanList.size();i++)
  13047. {
  13048. if(scanList.at(i).lastValue!=lastMeasurement.at(i))
  13049. {
  13050. doOutput= true;
  13051. break;
  13052. }
  13053. }
  13054. if(doOutput)
  13055. {
  13056. for(int i= 0;i<scanList.size();i++)
  13057. {
  13058. lastMeasurement[i]= scanList.at(i).lastValue;
  13059. if(scanList.at(scanPosition).unit==Units::Unitless)
  13060. {
  13061. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Unitless));
  13062. }
  13063. else
  13064. {
  13065. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  13066. }
  13067. }
  13068. }
  13069. }
  13070. responseBuffer.clear();
  13071. waiting= false;
  13072. if(scanPosition==0)
  13073. {
  13074. rateLimiter->start();
  13075. }
  13076. else
  13077. {
  13078. messageDelayTimer->start(delayTime);
  13079. }
  13080. }
  13081. quint16 ModbusNG::calculateCRC(QByteArray data)
  13082. {
  13083. quint16 retval= 0xFFFF;
  13084. int i= 0;
  13085. while(i<data.size())
  13086. {
  13087. retval^= 0x00FF&(quint16)data.at(i);
  13088. for(int j= 0;j<8;j++)
  13089. {
  13090. if(retval&1)
  13091. {
  13092. retval= (retval>>1)^0xA001;
  13093. }
  13094. else
  13095. {
  13096. retval>>= 1;
  13097. }
  13098. }
  13099. i++;
  13100. }
  13101. return retval;
  13102. }
  13103. int ModbusNG::channelCount()
  13104. {
  13105. return channels.size();
  13106. }
  13107. Channel*ModbusNG::getChannel(int channel)
  13108. {
  13109. return channels.at(channel);
  13110. }
  13111. QString ModbusNG::channelColumnName(int channel)
  13112. {
  13113. return channelNames.at(channel);
  13114. }
  13115. QString ModbusNG::channelIndicatorText(int channel)
  13116. {
  13117. return channelLabels.at(channel);
  13118. }
  13119. bool ModbusNG::isChannelHidden(int channel)
  13120. {
  13121. return hiddenStates.at(channel);
  13122. }
  13123. QString ModbusNG::channelType(int channel)
  13124. {
  13125. return channelTypeList.at(channel);
  13126. }
  13127. /*:903*/
  13128. #line 612 "./typica.w"
  13129. /*1096:*/
  13130. #line 33 "./thresholdannotation.w"
  13131. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  13132. const QModelIndex&index)
  13133. :BasicDeviceConfigurationWidget(model,index)
  13134. {
  13135. QFormLayout*layout= new QFormLayout;
  13136. QLineEdit*source= new QLineEdit;
  13137. layout->addRow(tr("Source column name:"),source);
  13138. QDoubleSpinBox*value= new QDoubleSpinBox;
  13139. value->setMinimum(-9999.99);
  13140. value->setMaximum(9999.99);
  13141. value->setDecimals(2);
  13142. layout->addRow(tr("Threshold value:"),value);
  13143. QComboBox*direction= new QComboBox;
  13144. direction->addItem(tr("Ascending"));
  13145. direction->addItem(tr("Descending"));
  13146. layout->addRow(tr("Direction:"),direction);
  13147. QLineEdit*annotation= new QLineEdit;
  13148. layout->addRow(tr("Annotation:"),annotation);
  13149. /*800:*/
  13150. #line 16608 "./typica.w"
  13151. QDomElement referenceElement=
  13152. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13153. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13154. QDomElement node;
  13155. /*:800*/
  13156. #line 52 "./thresholdannotation.w"
  13157. for(int i= 0;i<configData.size();i++)
  13158. {
  13159. node= configData.at(i).toElement();
  13160. if(node.attribute("name")=="source")
  13161. {
  13162. source->setText(node.attribute("value"));
  13163. }
  13164. else if(node.attribute("name")=="value")
  13165. {
  13166. value->setValue(node.attribute("value").toDouble());
  13167. }
  13168. else if(node.attribute("name")=="direction")
  13169. {
  13170. direction->setCurrentIndex(node.attribute("value").toInt());
  13171. }
  13172. else if(node.attribute("name")=="annotation")
  13173. {
  13174. annotation->setText(node.attribute("value"));
  13175. }
  13176. }
  13177. updateSourceColumn(source->text());
  13178. updateThreshold(value->value());
  13179. updateDirection(direction->currentIndex());
  13180. updateAnnotation(annotation->text());
  13181. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  13182. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  13183. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  13184. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  13185. setLayout(layout);
  13186. }
  13187. /*:1096*//*1097:*/
  13188. #line 86 "./thresholdannotation.w"
  13189. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  13190. {
  13191. updateAttribute("source",source);
  13192. }
  13193. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  13194. {
  13195. updateAttribute("value",QString("%1").arg(value));
  13196. }
  13197. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  13198. {
  13199. updateAttribute("direction",QString("%1").arg(direction));
  13200. }
  13201. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  13202. {
  13203. updateAttribute("annotation",annotation);
  13204. }
  13205. /*:1097*/
  13206. #line 613 "./typica.w"
  13207. /*1101:*/
  13208. #line 152 "./thresholdannotation.w"
  13209. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  13210. {
  13211. t.setInterval(0);
  13212. t.setSingleShot(true);
  13213. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  13214. }
  13215. void Annotator::setAnnotation(const QString&annotation)
  13216. {
  13217. note= annotation;
  13218. }
  13219. void Annotator::setTemperatureColumn(int tempcolumn)
  13220. {
  13221. tc= tempcolumn;
  13222. }
  13223. void Annotator::setAnnotationColumn(int annotationcolumn)
  13224. {
  13225. ac= annotationcolumn;
  13226. }
  13227. /*:1101*//*1102:*/
  13228. #line 181 "./thresholdannotation.w"
  13229. void Annotator::catchTimer()
  13230. {
  13231. emit annotation(note,tc,ac);
  13232. }
  13233. void Annotator::annotate()
  13234. {
  13235. t.start();
  13236. }
  13237. /*:1102*/
  13238. #line 614 "./typica.w"
  13239. /*:4*//*259:*/
  13240. #line 6123 "./typica.w"
  13241. /*256:*/
  13242. #line 6086 "./typica.w"
  13243. void ScriptValidator::fixup(QString&input)const
  13244. {
  13245. QScriptEngine*engine= AppInstance->engine;
  13246. engine->pushContext();
  13247. input= engine->evaluate(input).toString();
  13248. engine->popContext();
  13249. }
  13250. /*:256*//*257:*/
  13251. #line 6099 "./typica.w"
  13252. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  13253. {
  13254. if(v)
  13255. {
  13256. if(v->validate(input,pos)==QValidator::Acceptable)
  13257. {
  13258. return QValidator::Acceptable;
  13259. }
  13260. }
  13261. return QValidator::Intermediate;
  13262. }
  13263. /*:257*//*258:*/
  13264. #line 6114 "./typica.w"
  13265. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  13266. :QValidator(parent),v(validator)
  13267. {
  13268. }
  13269. /*:258*/
  13270. #line 6124 "./typica.w"
  13271. /*:259*//*693:*/
  13272. #line 160 "./plugins.w"
  13273. /*690:*/
  13274. #line 92 "./plugins.w"
  13275. PluginAction::PluginAction(const QFileInfo&info,QObject*parent):
  13276. QAction(parent),preRunScript(""),postRunScript("")
  13277. {
  13278. pluginFile= info.absoluteFilePath();
  13279. setText(info.baseName());
  13280. connect(this,SIGNAL(triggered()),this,SLOT(runScript()));
  13281. }
  13282. void PluginAction::runScript()
  13283. {
  13284. QFile file(pluginFile);
  13285. if(file.open(QIODevice::ReadOnly))
  13286. {
  13287. QScriptEngine*engine= AppInstance->engine;
  13288. QScriptContext*context= engine->pushContext();
  13289. if(parent()->dynamicPropertyNames().contains("activationObject"))
  13290. {
  13291. QScriptValue activationObject=
  13292. parent()->property("activationObject").value<QScriptValue> ();
  13293. context->setActivationObject(activationObject);
  13294. }
  13295. QString script(file.readAll());
  13296. QScriptValue retval= engine->evaluate(preRunScript+script+postRunScript,pluginFile);
  13297. if(engine->hasUncaughtException())
  13298. {
  13299. qDebug()<<"Uncaught exception: "<<
  13300. engine->uncaughtException().toString()<<
  13301. " in "<<pluginFile<<" line: "<<
  13302. engine->uncaughtExceptionLineNumber();
  13303. }
  13304. engine->popContext();
  13305. file.close();
  13306. }
  13307. }
  13308. /*:690*//*691:*/
  13309. #line 131 "./plugins.w"
  13310. QString PluginAction::preRun()
  13311. {
  13312. return preRunScript;
  13313. }
  13314. QString PluginAction::postRun()
  13315. {
  13316. return postRunScript;
  13317. }
  13318. void PluginAction::setPreRun(const QString&script)
  13319. {
  13320. preRunScript= script;
  13321. }
  13322. void PluginAction::setPostRun(const QString&script)
  13323. {
  13324. postRunScript= script;
  13325. }
  13326. /*:691*/
  13327. #line 161 "./plugins.w"
  13328. #line 14569 "./typica.w"
  13329. #line 1 "./daterangeselector.w"
  13330. /*:693*//*874:*/
  13331. #line 60 "./advancedsettings.w"
  13332. /*872:*/
  13333. #line 26 "./advancedsettings.w"
  13334. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  13335. {
  13336. QSettings settings;
  13337. QFormLayout*layout= new QFormLayout;
  13338. QCheckBox*logDiagnostics= new QCheckBox;
  13339. logDiagnostics->setCheckState(
  13340. settings.value("settings/advanced/logging",false).toBool()?
  13341. Qt::Checked:Qt::Unchecked);
  13342. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  13343. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  13344. setLayout(layout);
  13345. }
  13346. /*:872*//*873:*/
  13347. #line 43 "./advancedsettings.w"
  13348. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  13349. {
  13350. QSettings settings;
  13351. settings.setValue("settings/advanced/logging",enabled);
  13352. if(enabled)
  13353. {
  13354. qInstallMsgHandler(messageFileOutput);
  13355. }
  13356. else
  13357. {
  13358. qInstallMsgHandler(0);
  13359. }
  13360. }
  13361. /*:873*/
  13362. #line 61 "./advancedsettings.w"
  13363. #line 18372 "./typica.w"
  13364. /*:874*//*933:*/
  13365. #line 639 "./unsupportedserial.w"
  13366. /*908:*/
  13367. #line 58 "./unsupportedserial.w"
  13368. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  13369. const QModelIndex&index)
  13370. :BasicDeviceConfigurationWidget(model,index),
  13371. deviceSettingsModel(new SaltModel(2)),
  13372. scriptEditor(new QTextEdit)
  13373. {
  13374. scriptEditor->setTabStopWidth(20);
  13375. QVBoxLayout*dummyLayout= new QVBoxLayout;
  13376. QTabWidget*central= new QTabWidget;
  13377. QWidget*deviceConfigurationWidget= new QWidget;
  13378. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  13379. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13380. deviceConfigurationLayout->addWidget(addChannelButton);
  13381. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13382. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  13383. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  13384. QTableView*deviceSettingsView= new QTableView;
  13385. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  13386. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  13387. deviceSettingsView->setModel(deviceSettingsModel);
  13388. deviceConfigurationLayout->addWidget(deviceSettingsView);
  13389. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  13390. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  13391. central->addTab(scriptEditor,tr("Script"));
  13392. dummyLayout->addWidget(central);
  13393. /*800:*/
  13394. #line 16608 "./typica.w"
  13395. QDomElement referenceElement=
  13396. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13397. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13398. QDomElement node;
  13399. /*:800*/
  13400. #line 86 "./unsupportedserial.w"
  13401. for(int i= 0;i<configData.size();i++)
  13402. {
  13403. node= configData.at(i).toElement();
  13404. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13405. {
  13406. int column= 0;
  13407. if(node.attribute("name")=="values")
  13408. {
  13409. column= 1;
  13410. }
  13411. QString data= node.attribute("value");
  13412. if(data.length()> 3)
  13413. {
  13414. data.chop(2);
  13415. data= data.remove(0,2);
  13416. }
  13417. QStringList keyList= data.split(", ");
  13418. for(int j= 0;j<keyList.size();j++)
  13419. {
  13420. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  13421. QVariant(keyList.at(j)),
  13422. Qt::EditRole);
  13423. }
  13424. }
  13425. else if(node.attribute("name")=="script")
  13426. {
  13427. scriptEditor->setPlainText(node.attribute("value"));
  13428. }
  13429. }
  13430. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13431. this,SLOT(updateConfiguration()));
  13432. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13433. setLayout(dummyLayout);
  13434. }
  13435. /*:908*//*909:*/
  13436. #line 131 "./unsupportedserial.w"
  13437. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13438. {
  13439. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13440. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13441. }
  13442. /*:909*//*910:*/
  13443. #line 144 "./unsupportedserial.w"
  13444. void UnsupportedSerialDeviceConfWidget::saveScript()
  13445. {
  13446. updateAttribute("script",scriptEditor->toPlainText());
  13447. }
  13448. /*:910*//*911:*/
  13449. #line 155 "./unsupportedserial.w"
  13450. void UnsupportedSerialDeviceConfWidget::addChannel()
  13451. {
  13452. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13453. }
  13454. /*:911*//*913:*/
  13455. #line 183 "./unsupportedserial.w"
  13456. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13457. const QModelIndex&index)
  13458. :BasicDeviceConfigurationWidget(model,index),
  13459. channelSettingsModel(new SaltModel(2))
  13460. {
  13461. QFormLayout*layout= new QFormLayout;
  13462. QLineEdit*columnName= new QLineEdit;
  13463. layout->addRow(tr("Column Name:"),columnName);
  13464. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13465. layout->addRow(hideSeries);
  13466. QTableView*channelSettings= new QTableView;
  13467. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13468. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13469. channelSettings->setModel(channelSettingsModel);
  13470. layout->addRow(channelSettings);
  13471. setLayout(layout);
  13472. /*800:*/
  13473. #line 16608 "./typica.w"
  13474. QDomElement referenceElement=
  13475. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13476. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13477. QDomElement node;
  13478. /*:800*/
  13479. #line 200 "./unsupportedserial.w"
  13480. for(int i= 0;i<configData.size();i++)
  13481. {
  13482. node= configData.at(i).toElement();
  13483. if(node.attribute("name")=="columnname")
  13484. {
  13485. columnName->setText(node.attribute("value"));
  13486. }
  13487. else if(node.attribute("name")=="hidden")
  13488. {
  13489. hideSeries->setChecked(node.attribute("value")=="true");
  13490. }
  13491. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13492. {
  13493. int column= 0;
  13494. if(node.attribute("name")=="values")
  13495. {
  13496. column= 1;
  13497. }
  13498. QString data= node.attribute("value");
  13499. if(data.length()> 3)
  13500. {
  13501. data.chop(2);
  13502. data= data.remove(0,2);
  13503. }
  13504. QStringList keyList= data.split(", ");
  13505. for(int j= 0;j<keyList.size();j++)
  13506. {
  13507. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13508. QVariant(keyList.at(j)),
  13509. Qt::EditRole);
  13510. }
  13511. }
  13512. }
  13513. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13514. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13515. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13516. this,SLOT(updateConfiguration()));
  13517. }
  13518. /*:913*//*914:*/
  13519. #line 244 "./unsupportedserial.w"
  13520. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13521. {
  13522. updateAttribute("columnname",value);
  13523. }
  13524. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13525. {
  13526. updateAttribute("hidden",hidden?"true":"false");
  13527. }
  13528. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13529. {
  13530. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13531. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13532. }
  13533. /*:914*/
  13534. #line 640 "./unsupportedserial.w"
  13535. /*921:*/
  13536. #line 371 "./unsupportedserial.w"
  13537. void JavaScriptDevice::start()
  13538. {
  13539. QScriptValue object= scriptengine->newQObject(this);
  13540. /*922:*/
  13541. #line 390 "./unsupportedserial.w"
  13542. QScriptValue settingsObject= scriptengine->newObject();
  13543. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13544. while(i!=deviceSettings.constEnd())
  13545. {
  13546. settingsObject.setProperty(i.key(),i.value().toString());
  13547. i++;
  13548. }
  13549. object.setProperty("settings",settingsObject);
  13550. /*:922*/
  13551. #line 375 "./unsupportedserial.w"
  13552. /*923:*/
  13553. #line 405 "./unsupportedserial.w"
  13554. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13555. for(int i= 0;i<channelCount();i++)
  13556. {
  13557. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13558. QScriptValue channelSettingsObject= scriptengine->newObject();
  13559. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13560. while(j!=channelSettings.at(i).constEnd())
  13561. {
  13562. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13563. j++;
  13564. }
  13565. channelObject.setProperty("settings",channelSettingsObject);
  13566. channelsArray.setProperty(i,channelObject);
  13567. }
  13568. object.setProperty("channels",channelsArray);
  13569. /*:923*/
  13570. #line 376 "./unsupportedserial.w"
  13571. QScriptContext*context= scriptengine->currentContext();
  13572. QScriptValue oldThis= context->thisObject();
  13573. context->setThisObject(object);
  13574. QScriptValue result= scriptengine->evaluate(deviceScript);
  13575. QScriptEngine*engine= scriptengine;
  13576. /*195:*/
  13577. #line 4532 "./typica.w"
  13578. if(engine->hasUncaughtException())
  13579. {
  13580. int line= engine->uncaughtExceptionLineNumber();
  13581. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13582. result.toString();
  13583. QString trace;
  13584. foreach(trace,engine->uncaughtExceptionBacktrace())
  13585. {
  13586. qDebug()<<trace;
  13587. }
  13588. }
  13589. /*:195*/
  13590. #line 382 "./unsupportedserial.w"
  13591. context->setThisObject(oldThis);
  13592. }
  13593. /*:921*//*926:*/
  13594. #line 446 "./unsupportedserial.w"
  13595. void JavaScriptDevice::stop()
  13596. {
  13597. emit deviceStopRequested();
  13598. }
  13599. /*:926*//*927:*/
  13600. #line 459 "./unsupportedserial.w"
  13601. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13602. QScriptEngine*engine):
  13603. QObject(NULL),scriptengine(engine)
  13604. {
  13605. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13606. QDomElement deviceReferenceElement=
  13607. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13608. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13609. QDomElement node;
  13610. QStringList deviceKeys;
  13611. QStringList deviceValues;
  13612. for(int i= 0;i<deviceConfigData.size();i++)
  13613. {
  13614. node= deviceConfigData.at(i).toElement();
  13615. if(node.attribute("name")=="keys")
  13616. {
  13617. QString data= node.attribute("value");
  13618. if(data.length()> 3)
  13619. {
  13620. data.chop(2);
  13621. data= data.remove(0,2);
  13622. }
  13623. deviceKeys= data.split(", ");
  13624. }
  13625. else if(node.attribute("name")=="values")
  13626. {
  13627. QString data= node.attribute("value");
  13628. if(data.length()> 3)
  13629. {
  13630. data.chop(2);
  13631. data= data.remove(0,2);
  13632. }
  13633. deviceValues= data.split(", ");
  13634. }
  13635. else if(node.attribute("name")=="script")
  13636. {
  13637. deviceScript= node.attribute("value");
  13638. }
  13639. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13640. }
  13641. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13642. {
  13643. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13644. }
  13645. if(model->hasChildren(index))
  13646. {
  13647. for(int i= 0;i<model->rowCount(index);i++)
  13648. {
  13649. QModelIndex channelIndex= model->index(i,0,index);
  13650. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13651. channelList.append(new Channel);
  13652. QDomElement channelReferenceElement=
  13653. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13654. QDomNodeList channelConfigData=
  13655. channelReferenceElement.elementsByTagName("attribute");
  13656. QStringList channelKeys;
  13657. QStringList channelValues;
  13658. for(int j= 0;j<channelConfigData.size();j++)
  13659. {
  13660. node= channelConfigData.at(j).toElement();
  13661. if(node.attribute("name")=="keys")
  13662. {
  13663. QString data= node.attribute("value");
  13664. if(data.length()> 3)
  13665. {
  13666. data.chop(2);
  13667. data= data.remove(0,2);
  13668. }
  13669. channelKeys= data.split(", ");
  13670. }
  13671. else if(node.attribute("name")=="values")
  13672. {
  13673. QString data= node.attribute("value");
  13674. if(data.length()> 3)
  13675. {
  13676. data.chop(2);
  13677. data= data.remove(0,2);
  13678. }
  13679. channelValues= data.split(", ");
  13680. }
  13681. else if(node.attribute("name")=="hidden")
  13682. {
  13683. hiddenState.append(node.attribute("value")=="true");
  13684. }
  13685. else if(node.attribute("name")=="columnname")
  13686. {
  13687. columnNames.append(node.attribute("value"));
  13688. }
  13689. }
  13690. QVariantMap cs;
  13691. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13692. {
  13693. cs.insert(channelKeys[j],channelValues[j]);
  13694. }
  13695. channelSettings.append(cs);
  13696. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13697. channelUnits.append(Units::Fahrenheit);
  13698. }
  13699. }
  13700. }
  13701. /*:927*//*928:*/
  13702. #line 564 "./unsupportedserial.w"
  13703. int JavaScriptDevice::channelCount()
  13704. {
  13705. return channelList.length();
  13706. }
  13707. Channel*JavaScriptDevice::getChannel(int channel)
  13708. {
  13709. return channelList.at(channel);
  13710. }
  13711. bool JavaScriptDevice::isChannelHidden(int channel)
  13712. {
  13713. return hiddenState.at(channel);
  13714. }
  13715. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13716. {
  13717. return channelUnits.at(channel);
  13718. }
  13719. QString JavaScriptDevice::channelColumnName(int channel)
  13720. {
  13721. if(channel>=0&&channel<columnNames.length())
  13722. {
  13723. return columnNames.at(channel);
  13724. }
  13725. return QString();
  13726. }
  13727. QString JavaScriptDevice::channelIndicatorText(int channel)
  13728. {
  13729. return indicatorTexts.at(channel);
  13730. }
  13731. /*:928*//*929:*/
  13732. #line 601 "./unsupportedserial.w"
  13733. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13734. {
  13735. annotationTemperatureColumn= tcol;
  13736. }
  13737. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13738. {
  13739. annotationNoteColumn= ncol;
  13740. }
  13741. /*:929*/
  13742. #line 641 "./unsupportedserial.w"
  13743. /*:933*//*956:*/
  13744. #line 444 "./phidgets.w"
  13745. /*940:*/
  13746. #line 31 "./phidgets.w"
  13747. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13748. const QModelIndex&index)
  13749. :BasicDeviceConfigurationWidget(model,index)
  13750. {
  13751. QFormLayout*layout= new QFormLayout;
  13752. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13753. QSpinBox*sampleRate= new QSpinBox;
  13754. sampleRate->setMinimum(40);
  13755. sampleRate->setMaximum(600);
  13756. sampleRate->setSingleStep(40);
  13757. sampleRate->setValue(360);
  13758. /*800:*/
  13759. #line 16608 "./typica.w"
  13760. QDomElement referenceElement=
  13761. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13762. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13763. QDomElement node;
  13764. /*:800*/
  13765. #line 44 "./phidgets.w"
  13766. for(int i= 0;i<configData.size();i++)
  13767. {
  13768. node= configData.at(i).toElement();
  13769. if(node.attribute("name")=="sampleRate")
  13770. {
  13771. sampleRate->setValue(node.attribute("value").toInt());
  13772. }
  13773. }
  13774. updateRate(sampleRate->value());
  13775. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13776. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13777. layout->addRow(addChannelButton);
  13778. layout->addRow(tr("Sample rate:"),sampleRate);
  13779. setLayout(layout);
  13780. }
  13781. /*:940*//*941:*/
  13782. #line 66 "./phidgets.w"
  13783. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13784. {
  13785. insertChildNode(tr("Channel"),"phidgets1048channel");
  13786. }
  13787. /*:941*//*942:*/
  13788. #line 74 "./phidgets.w"
  13789. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13790. {
  13791. updateAttribute("sampleRate",QString("%1").arg(ms));
  13792. }
  13793. /*:942*//*944:*/
  13794. #line 103 "./phidgets.w"
  13795. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13796. DeviceTreeModel*model,const QModelIndex&index)
  13797. :BasicDeviceConfigurationWidget(model,index),
  13798. tcType(new QComboBox)
  13799. {
  13800. QFormLayout*layout= new QFormLayout;
  13801. QLineEdit*columnName= new QLineEdit;
  13802. layout->addRow(tr("Column Name:"),columnName);
  13803. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13804. layout->addRow(hideSeries);
  13805. layout->addRow(tr("Thermocouple Type:"),tcType);
  13806. tcType->addItem("Type K","1");
  13807. tcType->addItem("Type J","2");
  13808. tcType->addItem("Type E","3");
  13809. tcType->addItem("Type T","4");
  13810. QSpinBox*channel= new QSpinBox;
  13811. layout->addRow(tr("Channel:"),channel);
  13812. channel->setMinimum(0);
  13813. channel->setMaximum(3);
  13814. setLayout(layout);
  13815. /*800:*/
  13816. #line 16608 "./typica.w"
  13817. QDomElement referenceElement=
  13818. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13819. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13820. QDomElement node;
  13821. /*:800*/
  13822. #line 124 "./phidgets.w"
  13823. for(int i= 0;i<configData.size();i++)
  13824. {
  13825. node= configData.at(i).toElement();
  13826. if(node.attribute("name")=="columnname")
  13827. {
  13828. columnName->setText(node.attribute("value"));
  13829. }
  13830. else if(node.attribute("name")=="hidden")
  13831. {
  13832. hideSeries->setChecked(node.attribute("value")=="true");
  13833. }
  13834. else if(node.attribute("name")=="tctype")
  13835. {
  13836. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  13837. }
  13838. else if(node.attribute("name")=="channel")
  13839. {
  13840. channel->setValue(node.attribute("value").toInt());
  13841. }
  13842. }
  13843. updateColumnName(columnName->text());
  13844. updateHidden(hideSeries->isChecked());
  13845. updateTC(tcType->currentIndex());
  13846. updateChannel(channel->value());
  13847. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13848. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13849. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  13850. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  13851. }
  13852. /*:944*//*945:*/
  13853. #line 157 "./phidgets.w"
  13854. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  13855. {
  13856. updateAttribute("columnname",value);
  13857. }
  13858. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  13859. {
  13860. updateAttribute("hidden",hidden?"true":"false");
  13861. }
  13862. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  13863. {
  13864. updateAttribute("tctype",tcType->itemData(index).toString());
  13865. }
  13866. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  13867. {
  13868. updateAttribute("channel",QString("%1").arg(channel));
  13869. }
  13870. /*:945*//*949:*/
  13871. #line 246 "./phidgets.w"
  13872. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  13873. :QObject(NULL),driver("phidget21"),device(NULL)
  13874. {
  13875. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13876. QDomElement deviceReferenceElement=
  13877. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13878. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13879. QDomElement node;
  13880. for(int i= 0;i<deviceConfigData.size();i++)
  13881. {
  13882. node= deviceConfigData.at(i).toElement();
  13883. if(node.attribute("name")=="sampleRate")
  13884. {
  13885. sampleTimer.setInterval(node.attribute("value").toInt());
  13886. }
  13887. }
  13888. if(model->hasChildren(index))
  13889. {
  13890. for(int i= 0;i<model->rowCount(index);i++)
  13891. {
  13892. QModelIndex channelIndex= model->index(i,0,index);
  13893. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13894. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13895. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  13896. for(int j= 0;j<channelConfigData.size();j++)
  13897. {
  13898. node= channelConfigData.at(j).toElement();
  13899. if(node.attribute("name")=="channel")
  13900. {
  13901. int channelID= node.attribute("value").toInt();
  13902. channelIndices.append(channelID);
  13903. Channel*channel= new Channel;
  13904. channelList.append(channel);
  13905. channelMap.insert(channelID,channel);
  13906. }
  13907. else if(node.attribute("name")=="hidden")
  13908. {
  13909. hiddenState.append(node.attribute("value")=="true");
  13910. }
  13911. else if(node.attribute("name")=="columnname")
  13912. {
  13913. columnNames.append(node.attribute("value"));
  13914. }
  13915. else if(node.attribute("name")=="tctype")
  13916. {
  13917. tctypes.append(node.attribute("value").toInt());
  13918. }
  13919. }
  13920. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13921. }
  13922. }
  13923. }
  13924. /*:949*//*950:*/
  13925. #line 306 "./phidgets.w"
  13926. int PhidgetsTemperatureSensor::channelCount()
  13927. {
  13928. return channelList.length();
  13929. }
  13930. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  13931. {
  13932. return channelList.at(channel);
  13933. }
  13934. /*:950*//*951:*/
  13935. #line 319 "./phidgets.w"
  13936. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  13937. {
  13938. return hiddenState.at(channel);
  13939. }
  13940. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  13941. {
  13942. if(channel>=0&&channel<columnNames.length())
  13943. {
  13944. return columnNames.at(channel);
  13945. }
  13946. return QString();
  13947. }
  13948. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  13949. {
  13950. if(channel>=0&&channel<indicatorTexts.length())
  13951. {
  13952. return indicatorTexts.at(channel);
  13953. }
  13954. return QString();
  13955. }
  13956. /*:951*//*953:*/
  13957. #line 371 "./phidgets.w"
  13958. void PhidgetsTemperatureSensor::start()
  13959. {
  13960. if(!driver.load())
  13961. {
  13962. driver.setFileName("Phidget21.framework/Phidget21");
  13963. if(!driver.load())
  13964. {
  13965. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  13966. tr("Failed to find phidget21. Please install it."));
  13967. return;
  13968. }
  13969. }
  13970. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  13971. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  13972. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  13973. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  13974. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  13975. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  13976. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  13977. {
  13978. QMessageBox::critical(NULL,tr("Typica: Link error"),
  13979. tr("Failed to link a required symbol in phidget21."));
  13980. return;
  13981. }
  13982. createDevice(&device);
  13983. openDevice(device,-1);
  13984. int error;
  13985. if((error= waitForOpen(device,10000)))
  13986. {
  13987. closeDevice(device);
  13988. deleteDevice(device);
  13989. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  13990. tr("CPhidget_waitForAttachment returns error %n",0,error));
  13991. return;
  13992. }
  13993. for(int i= 0;i<channelIndices.length();i++)
  13994. {
  13995. setTCType(device,channelIndices.at(i),tctypes.at(i));
  13996. }
  13997. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  13998. sampleTimer.start();
  13999. }
  14000. /*:953*//*954:*/
  14001. #line 418 "./phidgets.w"
  14002. void PhidgetsTemperatureSensor::getMeasurements()
  14003. {
  14004. double value= 0.0;
  14005. QTime time= QTime::currentTime();
  14006. foreach(int i,channelIndices)
  14007. {
  14008. getTemperature(device,i,&value);
  14009. Measurement measure(value*9.0/5.0+32.0,time);
  14010. channelMap[i]->input(measure);
  14011. }
  14012. }
  14013. /*:954*//*955:*/
  14014. #line 433 "./phidgets.w"
  14015. void PhidgetsTemperatureSensor::stop()
  14016. {
  14017. sampleTimer.stop();
  14018. closeDevice(device);
  14019. deleteDevice(device);
  14020. driver.unload();
  14021. }
  14022. /*:955*/
  14023. #line 445 "./phidgets.w"
  14024. /*:956*//*970:*/
  14025. #line 19804 "./typica.w"
  14026. /*968:*/
  14027. #line 19766 "./typica.w"
  14028. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  14029. const QModelIndex&index)
  14030. :BasicDeviceConfigurationWidget(model,index)
  14031. {
  14032. QHBoxLayout*layout= new QHBoxLayout;
  14033. QLabel*label= new QLabel(tr("Cooling Time: "));
  14034. QTimeEdit*editor= new QTimeEdit;
  14035. editor->setDisplayFormat("mm:ss");
  14036. /*800:*/
  14037. #line 16608 "./typica.w"
  14038. QDomElement referenceElement=
  14039. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14040. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14041. QDomElement node;
  14042. /*:800*/
  14043. #line 19775 "./typica.w"
  14044. for(int i= 0;i<configData.size();i++)
  14045. {
  14046. node= configData.at(i).toElement();
  14047. if(node.attribute("name")=="reset")
  14048. {
  14049. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  14050. }
  14051. }
  14052. updateResetTime(editor->time());
  14053. connect(editor,SIGNAL(timeChanged(QTime)),
  14054. this,SLOT(updateResetTime(QTime)));
  14055. layout->addWidget(label);
  14056. layout->addWidget(editor);
  14057. setLayout(layout);
  14058. }
  14059. void CoolingTimerConfWidget::updateResetTime(QTime time)
  14060. {
  14061. updateAttribute("reset",time.toString("mm:ss"));
  14062. }
  14063. /*:968*/
  14064. #line 19805 "./typica.w"
  14065. /*:970*//*975:*/
  14066. #line 20063 "./typica.w"
  14067. /*972:*/
  14068. #line 19837 "./typica.w"
  14069. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14070. :BasicDeviceConfigurationWidget(model,index)
  14071. {
  14072. QVBoxLayout*layout= new QVBoxLayout;
  14073. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  14074. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  14075. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  14076. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  14077. QButtonGroup*startOptionGroup= new QButtonGroup;
  14078. startOptionGroup->addButton(startBatchOption,1);
  14079. startOptionGroup->addButton(buttonOption,2);
  14080. startOptionGroup->addButton(thresholdOption,3);
  14081. startBatchOption->setChecked(true);
  14082. QGridLayout*startOptions= new QGridLayout;
  14083. startOptions->addWidget(startBatchOption,0,0);
  14084. startOptions->addWidget(buttonOption,1,0);
  14085. startOptions->addWidget(thresholdOption,2,0);
  14086. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  14087. QLineEdit*buttonTextEdit= new QLineEdit;
  14088. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  14089. buttonTextOptions->addWidget(buttonTextLabel);
  14090. buttonTextOptions->addWidget(buttonTextEdit);
  14091. startOptions->addLayout(buttonTextOptions,1,1);
  14092. QFormLayout*thresholdOptions= new QFormLayout;
  14093. QLineEdit*startColumnName= new QLineEdit;
  14094. QLineEdit*startValue= new QLineEdit;
  14095. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  14096. thresholdOptions->addRow(tr("Value: "),startValue);
  14097. startOptions->addLayout(thresholdOptions,2,1);
  14098. startConfigurationGroup->setLayout(startOptions);
  14099. layout->addWidget(startConfigurationGroup);
  14100. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  14101. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  14102. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  14103. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  14104. QButtonGroup*stopOptionGroup= new QButtonGroup;
  14105. stopOptionGroup->addButton(stopBatchOption,1);
  14106. stopOptionGroup->addButton(stopButtonOption,2);
  14107. stopOptionGroup->addButton(stopThresholdOption,3);
  14108. stopBatchOption->setChecked(true);
  14109. QGridLayout*stopOptions= new QGridLayout;
  14110. stopOptions->addWidget(stopBatchOption,0,0);
  14111. stopOptions->addWidget(stopButtonOption,1,0);
  14112. stopOptions->addWidget(stopThresholdOption,2,0);
  14113. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  14114. QLineEdit*stopButtonEdit= new QLineEdit;
  14115. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  14116. stopButtonTextOptions->addWidget(stopButtonLabel);
  14117. stopButtonTextOptions->addWidget(stopButtonEdit);
  14118. stopOptions->addLayout(stopButtonTextOptions,1,1);
  14119. QLineEdit*stopColumnName= new QLineEdit;
  14120. QLineEdit*stopValue= new QLineEdit;
  14121. QFormLayout*stopThresholdOptions= new QFormLayout;
  14122. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  14123. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  14124. stopOptions->addLayout(stopThresholdOptions,2,1);
  14125. stopConfigurationGroup->setLayout(stopOptions);
  14126. layout->addWidget(stopConfigurationGroup);
  14127. /*800:*/
  14128. #line 16608 "./typica.w"
  14129. QDomElement referenceElement=
  14130. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14131. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14132. QDomElement node;
  14133. /*:800*/
  14134. #line 19899 "./typica.w"
  14135. for(int i= 0;i<configData.size();i++)
  14136. {
  14137. node= configData.at(i).toElement();
  14138. if(node.attribute("name")=="startbuttontext")
  14139. {
  14140. buttonTextEdit->setText(node.attribute("value"));
  14141. }
  14142. else if(node.attribute("name")=="stopbuttontext")
  14143. {
  14144. stopButtonEdit->setText(node.attribute("value"));
  14145. }
  14146. else if(node.attribute("name")=="startcolumnname")
  14147. {
  14148. startColumnName->setText(node.attribute("value"));
  14149. }
  14150. else if(node.attribute("name")=="stopcolumnname")
  14151. {
  14152. stopColumnName->setText(node.attribute("value"));
  14153. }
  14154. else if(node.attribute("name")=="startvalue")
  14155. {
  14156. startValue->setText(node.attribute("value"));
  14157. }
  14158. else if(node.attribute("name")=="stopvalue")
  14159. {
  14160. stopValue->setText(node.attribute("value"));
  14161. }
  14162. else if(node.attribute("name")=="starttrigger")
  14163. {
  14164. if(node.attribute("value")=="batch")
  14165. {
  14166. startBatchOption->setChecked(true);
  14167. }
  14168. else if(node.attribute("value")=="manual")
  14169. {
  14170. buttonOption->setChecked(true);
  14171. }
  14172. else if(node.attribute("value")=="value")
  14173. {
  14174. thresholdOption->setChecked(true);
  14175. }
  14176. }
  14177. else if(node.attribute("name")=="stoptrigger")
  14178. {
  14179. if(node.attribute("value")=="batch")
  14180. {
  14181. stopBatchOption->setChecked(true);
  14182. }
  14183. else if(node.attribute("value")=="manual")
  14184. {
  14185. stopButtonOption->setChecked(true);
  14186. }
  14187. else if(node.attribute("value")=="value")
  14188. {
  14189. stopThresholdOption->setChecked(true);
  14190. }
  14191. }
  14192. }
  14193. updateStartButtonText(buttonTextEdit->text());
  14194. updateStopButtonText(stopButtonEdit->text());
  14195. updateStartColumnName(startColumnName->text());
  14196. updateStopColumnName(stopColumnName->text());
  14197. updateStartValue(startValue->text());
  14198. updateStopValue(stopValue->text());
  14199. updateStartTrigger(startOptionGroup->checkedId());
  14200. updateStopTrigger(stopOptionGroup->checkedId());
  14201. setLayout(layout);
  14202. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  14203. this,SLOT(updateStartButtonText(QString)));
  14204. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  14205. this,SLOT(updateStopButtonText(QString)));
  14206. connect(startColumnName,SIGNAL(textChanged(QString)),
  14207. this,SLOT(updateStartColumnName(QString)));
  14208. connect(stopColumnName,SIGNAL(textChanged(QString)),
  14209. this,SLOT(updateStopColumnName(QString)));
  14210. connect(startValue,SIGNAL(textChanged(QString)),
  14211. this,SLOT(updateStartValue(QString)));
  14212. connect(stopValue,SIGNAL(textChanged(QString)),
  14213. this,SLOT(updateStopValue(QString)));
  14214. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  14215. this,SLOT(updateStartTrigger(int)));
  14216. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  14217. this,SLOT(updateStopTrigger(int)));
  14218. }
  14219. /*:972*//*973:*/
  14220. #line 19989 "./typica.w"
  14221. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  14222. {
  14223. updateAttribute("startbuttontext",text);
  14224. }
  14225. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  14226. {
  14227. updateAttribute("stopbuttontext",text);
  14228. }
  14229. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  14230. {
  14231. updateAttribute("startcolumnname",text);
  14232. }
  14233. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  14234. {
  14235. updateAttribute("stopcolumnname",text);
  14236. }
  14237. void RangeTimerConfWidget::updateStartValue(const QString&text)
  14238. {
  14239. updateAttribute("startvalue",text);
  14240. }
  14241. void RangeTimerConfWidget::updateStopValue(const QString&text)
  14242. {
  14243. updateAttribute("stopvalue",text);
  14244. }
  14245. void RangeTimerConfWidget::updateStartTrigger(int option)
  14246. {
  14247. switch(option)
  14248. {
  14249. case 1:
  14250. updateAttribute("starttrigger","batch");
  14251. break;
  14252. case 2:
  14253. updateAttribute("starttrigger","manual");
  14254. break;
  14255. case 3:
  14256. updateAttribute("starttrigger","value");
  14257. break;
  14258. default:
  14259. break;
  14260. }
  14261. }
  14262. void RangeTimerConfWidget::updateStopTrigger(int option)
  14263. {
  14264. switch(option)
  14265. {
  14266. case 1:
  14267. updateAttribute("stoptrigger","batch");
  14268. break;
  14269. case 2:
  14270. updateAttribute("stoptrigger","manual");
  14271. break;
  14272. case 3:
  14273. updateAttribute("stoptrigger","value");
  14274. break;
  14275. default:
  14276. break;
  14277. }
  14278. }
  14279. /*:973*/
  14280. #line 20064 "./typica.w"
  14281. /*:975*//*980:*/
  14282. #line 20164 "./typica.w"
  14283. /*977:*/
  14284. #line 20088 "./typica.w"
  14285. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  14286. const QModelIndex&index)
  14287. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  14288. {
  14289. QFormLayout*layout= new QFormLayout;
  14290. QLineEdit*trigger= new QLineEdit;
  14291. layout->addRow(tr("Trigger column name:"),trigger);
  14292. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  14293. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  14294. QTableView*rangeTable= new QTableView;
  14295. rangeTable->setModel(tablemodel);
  14296. layout->addRow(tr("Range data:"),rangeTable);
  14297. /*800:*/
  14298. #line 16608 "./typica.w"
  14299. QDomElement referenceElement=
  14300. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14301. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14302. QDomElement node;
  14303. /*:800*/
  14304. #line 20101 "./typica.w"
  14305. for(int i= 0;i<configData.size();i++)
  14306. {
  14307. node= configData.at(i).toElement();
  14308. if(node.attribute("name")=="trigger")
  14309. {
  14310. trigger->setText(node.attribute("value"));
  14311. }
  14312. else if(node.attribute("name")=="rangenames")
  14313. {
  14314. QString data= node.attribute("value");
  14315. if(data.length()> 3)
  14316. {
  14317. data.chop(2);
  14318. data= data.remove(0,2);
  14319. }
  14320. QStringList itemList= data.split(", ");
  14321. for(int j= 0;j<itemList.size();j++)
  14322. {
  14323. QString item= itemList.at(j);
  14324. item.chop(1);
  14325. item= item.remove(0,1);
  14326. tablemodel->setData(tablemodel->index(j,0),
  14327. QVariant(item),Qt::DisplayRole);
  14328. }
  14329. }
  14330. else if(node.attribute("name")=="endtemps")
  14331. {
  14332. /*963:*/
  14333. #line 19696 "./typica.w"
  14334. QString data= node.attribute("value");
  14335. if(data.length()> 3)
  14336. {
  14337. data.chop(2);
  14338. data= data.remove(0,2);
  14339. }
  14340. QStringList itemList= data.split(",");
  14341. /*:963*/
  14342. #line 20129 "./typica.w"
  14343. int column= 1;
  14344. /*964:*/
  14345. #line 19708 "./typica.w"
  14346. for(int j= 0;j<itemList.size();j++)
  14347. {
  14348. tablemodel->setData(tablemodel->index(j,column),
  14349. QVariant(itemList.at(j).toDouble()),
  14350. Qt::DisplayRole);
  14351. }
  14352. /*:964*/
  14353. #line 20131 "./typica.w"
  14354. }
  14355. }
  14356. updateColumnName(trigger->text());
  14357. updateRangeData();
  14358. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  14359. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  14360. setLayout(layout);
  14361. }
  14362. /*:977*//*978:*/
  14363. #line 20145 "./typica.w"
  14364. void MultiRangeTimerConfWidget::updateRangeData()
  14365. {
  14366. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  14367. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  14368. }
  14369. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  14370. {
  14371. updateAttribute("trigger",text);
  14372. }
  14373. /*:978*/
  14374. #line 20165 "./typica.w"
  14375. /*:980*//*998:*/
  14376. #line 265 "./rate.w"
  14377. /*994:*/
  14378. #line 191 "./rate.w"
  14379. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14380. :BasicDeviceConfigurationWidget(model,index)
  14381. {
  14382. QFormLayout*layout= new QFormLayout;
  14383. QLineEdit*column= new QLineEdit;
  14384. layout->addRow(tr("Primary series column name:"),column);
  14385. QSpinBox*cacheTime= new QSpinBox;
  14386. cacheTime->setMinimum(0);
  14387. cacheTime->setMaximum(300);
  14388. layout->addRow(tr("Cache time:"),cacheTime);
  14389. QSpinBox*scaleTime= new QSpinBox;
  14390. scaleTime->setMinimum(1);
  14391. scaleTime->setMaximum(300);
  14392. layout->addRow(tr("Scale time:"),scaleTime);
  14393. /*800:*/
  14394. #line 16608 "./typica.w"
  14395. QDomElement referenceElement=
  14396. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14397. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14398. QDomElement node;
  14399. /*:800*/
  14400. #line 206 "./rate.w"
  14401. for(int i= 0;i<configData.size();i++)
  14402. {
  14403. node= configData.at(i).toElement();
  14404. if(node.attribute("name")=="column")
  14405. {
  14406. column->setText(node.attribute("value"));
  14407. }
  14408. else if(node.attribute("name")=="cache")
  14409. {
  14410. cacheTime->setValue(node.attribute("value").toInt());
  14411. }
  14412. else if(node.attribute("name")=="scale")
  14413. {
  14414. scaleTime->setValue(node.attribute("value").toInt());
  14415. }
  14416. }
  14417. updateColumn(column->text());
  14418. updateCacheTime(cacheTime->text());
  14419. updateScaleTime(scaleTime->text());
  14420. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  14421. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  14422. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  14423. setLayout(layout);
  14424. }
  14425. /*:994*//*995:*/
  14426. #line 235 "./rate.w"
  14427. void RateOfChangeConfWidget::updateColumn(const QString&column)
  14428. {
  14429. updateAttribute("column",column);
  14430. }
  14431. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  14432. {
  14433. updateAttribute("cache",seconds);
  14434. }
  14435. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  14436. {
  14437. updateAttribute("scale",seconds);
  14438. }
  14439. /*:995*/
  14440. #line 266 "./rate.w"
  14441. #line 20272 "./typica.w"
  14442. #line 1 "./mergeseries.w"
  14443. /*:998*//*1012:*/
  14444. #line 282 "./mergeseries.w"
  14445. /*1008:*/
  14446. #line 183 "./mergeseries.w"
  14447. MergeSeriesConfWidget::MergeSeriesConfWidget(DeviceTreeModel*model,
  14448. const QModelIndex&index)
  14449. :BasicDeviceConfigurationWidget(model,index)
  14450. {
  14451. QFormLayout*layout= new QFormLayout;
  14452. QComboBox*type= new QComboBox;
  14453. type->addItem(tr("Difference"),QVariant("Difference"));
  14454. type->addItem(tr("Mean"),QVariant("Mean"));
  14455. layout->addRow(tr("Series type:"),type);
  14456. QLineEdit*column1= new QLineEdit;
  14457. layout->addRow(tr("First input column name:"),column1);
  14458. QLineEdit*column2= new QLineEdit;
  14459. layout->addRow(tr("Second input column name:"),column2);
  14460. QLineEdit*output= new QLineEdit;
  14461. layout->addRow(tr("Output column name:"),output);
  14462. /*800:*/
  14463. #line 16608 "./typica.w"
  14464. QDomElement referenceElement=
  14465. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14466. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14467. QDomElement node;
  14468. /*:800*/
  14469. #line 199 "./mergeseries.w"
  14470. for(int i= 0;i<configData.size();i++)
  14471. {
  14472. node= configData.at(i).toElement();
  14473. if(node.attribute("name")=="type")
  14474. {
  14475. type->setCurrentIndex(type->findData(node.attribute("value")));
  14476. }
  14477. else if(node.attribute("name")=="column1")
  14478. {
  14479. column1->setText(node.attribute("value"));
  14480. }
  14481. else if(node.attribute("name")=="column2")
  14482. {
  14483. column2->setText(node.attribute("value"));
  14484. }
  14485. else if(node.attribute("name")=="output")
  14486. {
  14487. output->setText(node.attribute("value"));
  14488. }
  14489. }
  14490. updateColumn1(column1->text());
  14491. updateColumn2(column2->text());
  14492. updateOutput(output->text());
  14493. updateType(type->currentIndex());
  14494. connect(column1,SIGNAL(textEdited(QString)),this,SLOT(updateColumn1(QString)));
  14495. connect(column2,SIGNAL(textEdited(QString)),this,SLOT(updateColumn2(QString)));
  14496. connect(output,SIGNAL(textEdited(QString)),this,SLOT(updateOutput(QString)));
  14497. connect(type,SIGNAL(currentIndexChanged(int)),this,SLOT(updateType(int)));
  14498. setLayout(layout);
  14499. }
  14500. /*:1008*//*1009:*/
  14501. #line 233 "./mergeseries.w"
  14502. void MergeSeriesConfWidget::updateColumn1(const QString&column)
  14503. {
  14504. updateAttribute("column1",column);
  14505. }
  14506. void MergeSeriesConfWidget::updateColumn2(const QString&column)
  14507. {
  14508. updateAttribute("column2",column);
  14509. }
  14510. void MergeSeriesConfWidget::updateOutput(const QString&column)
  14511. {
  14512. updateAttribute("output",column);
  14513. }
  14514. void MergeSeriesConfWidget::updateType(int index)
  14515. {
  14516. switch(index)
  14517. {
  14518. case 0:
  14519. updateAttribute("type","Difference");
  14520. break;
  14521. case 1:
  14522. updateAttribute("type","Mean");
  14523. break;
  14524. default:
  14525. break;
  14526. }
  14527. }
  14528. /*:1009*/
  14529. #line 283 "./mergeseries.w"
  14530. /*1000:*/
  14531. #line 59 "./mergeseries.w"
  14532. void MergeSeries::in1(Measurement measure)
  14533. {
  14534. last1= measure;
  14535. received1= true;
  14536. if(received1&&received2)
  14537. {
  14538. calculate(last1,last2);
  14539. received1= false;
  14540. received2= false;
  14541. }
  14542. }
  14543. void MergeSeries::in2(Measurement measure)
  14544. {
  14545. last2= measure;
  14546. received2= true;
  14547. if(received1&&received2)
  14548. {
  14549. calculate(last1,last2);
  14550. received1= false;
  14551. received2= false;
  14552. }
  14553. }
  14554. /*:1000*//*1001:*/
  14555. #line 86 "./mergeseries.w"
  14556. MergeSeries::MergeSeries():QObject(NULL),received1(false),received2(false)
  14557. {
  14558. }
  14559. /*:1001*//*1002:*/
  14560. #line 97 "./mergeseries.w"
  14561. void DifferenceSeries::calculate(Measurement m1,Measurement m2)
  14562. {
  14563. Measurement outval(m1.temperature()-m2.temperature(),
  14564. (m1.time()> m2.time()?m1.time():m2.time()));
  14565. outval.insert("relative",true);
  14566. emit newData(outval);
  14567. }
  14568. void MeanSeries::calculate(Measurement m1,Measurement m2)
  14569. {
  14570. Measurement outval((m1.temperature()+m2.temperature())/2,
  14571. (m1.time()> m2.time()?m1.time():m2.time()));
  14572. emit newData(outval);
  14573. }
  14574. /*:1002*//*1003:*/
  14575. #line 115 "./mergeseries.w"
  14576. DifferenceSeries::DifferenceSeries():MergeSeries()
  14577. {
  14578. }
  14579. MeanSeries::MeanSeries():MergeSeries()
  14580. {
  14581. }
  14582. /*:1003*/
  14583. #line 284 "./mergeseries.w"
  14584. #line 20274 "./typica.w"
  14585. #line 1 "./dataqsdk.w"
  14586. /*:1012*//*1127:*/
  14587. #line 344 "./user.w"
  14588. /*1122:*/
  14589. #line 232 "./user.w"
  14590. NewTypicaUser::NewTypicaUser():QDialog(),
  14591. userField(new QLineEdit),passwordField(new QLineEdit),
  14592. autoLogin(new QCheckBox(tr("Log in automatically"))),
  14593. saveAndCloseButton(new QPushButton(tr("Save and Close"))),
  14594. saveAndNewButton(new QPushButton(tr("Save and Create Another"))),
  14595. cancelButton(new QPushButton(tr("Cancel")))
  14596. {
  14597. setModal(true);
  14598. QVBoxLayout*mainLayout= new QVBoxLayout;
  14599. QFormLayout*form= new QFormLayout;
  14600. QHBoxLayout*buttons= new QHBoxLayout;
  14601. form->addRow(tr("Name:"),userField);
  14602. passwordField->setEchoMode(QLineEdit::Password);
  14603. form->addRow(tr("Password:"),passwordField);
  14604. form->addRow(autoLogin);
  14605. buttons->addWidget(cancelButton);
  14606. buttons->addStretch();
  14607. buttons->addWidget(saveAndNewButton);
  14608. buttons->addWidget(saveAndCloseButton);
  14609. mainLayout->addLayout(form);
  14610. mainLayout->addLayout(buttons);
  14611. setLayout(mainLayout);
  14612. setWindowTitle(tr("Create New User"));
  14613. connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
  14614. connect(saveAndCloseButton,SIGNAL(clicked()),this,SLOT(createAndClose()));
  14615. connect(saveAndNewButton,SIGNAL(clicked()),this,SLOT(createAndReset()));
  14616. connect(userField,SIGNAL(textChanged(QString)),this,SLOT(validate()));
  14617. }
  14618. /*:1122*//*1123:*/
  14619. #line 264 "./user.w"
  14620. void NewTypicaUser::createAndReset()
  14621. {
  14622. createNewUser();
  14623. userField->setText("");
  14624. passwordField->setText("");
  14625. autoLogin->setChecked(false);
  14626. }
  14627. void NewTypicaUser::createAndClose()
  14628. {
  14629. createNewUser();
  14630. accept();
  14631. }
  14632. void NewTypicaUser::createNewUser()
  14633. {
  14634. SqlQueryConnection h;
  14635. QSqlQuery*dbquery= h.operator->();
  14636. dbquery->prepare("INSERT INTO typica_users (name, password, active, auto_login) VALUES (:name, :password, true, :auto)");
  14637. dbquery->bindValue(":name",userField->text());
  14638. dbquery->bindValue(":password",passwordField->text());
  14639. dbquery->bindValue(":auto",autoLogin->isChecked());
  14640. dbquery->exec();
  14641. cancelButton->setEnabled(true);
  14642. }
  14643. void NewTypicaUser::validate()
  14644. {
  14645. if(!userField->text().isEmpty())
  14646. {
  14647. saveAndCloseButton->setEnabled(true);
  14648. saveAndNewButton->setEnabled(true);
  14649. }
  14650. else
  14651. {
  14652. saveAndCloseButton->setEnabled(false);
  14653. saveAndNewButton->setEnabled(false);
  14654. }
  14655. }
  14656. void NewTypicaUser::cancelValidate()
  14657. {
  14658. SqlQueryConnection h;
  14659. QSqlQuery*dbquery= h.operator->();
  14660. dbquery->exec("SELECT count(1) FROM typica_users");
  14661. if(dbquery->next())
  14662. {
  14663. if(dbquery->value(0).toInt()> 0)
  14664. {
  14665. cancelButton->setEnabled(true);
  14666. return;
  14667. }
  14668. }
  14669. cancelButton->setEnabled(false);
  14670. }
  14671. /*:1123*/
  14672. #line 345 "./user.w"
  14673. /*1118:*/
  14674. #line 177 "./user.w"
  14675. UserLabel::UserLabel():QLabel()
  14676. {
  14677. setTextFormat(Qt::PlainText);
  14678. updateLabel(AppInstance->currentTypicaUser());
  14679. connect(AppInstance,SIGNAL(userChanged(QString)),
  14680. this,SLOT(updateLabel(QString)));
  14681. }
  14682. /*:1118*//*1119:*/
  14683. #line 188 "./user.w"
  14684. void UserLabel::updateLabel(const QString&user)
  14685. {
  14686. setText(QString(tr("Current operator: %1").arg(user)));
  14687. }
  14688. /*:1119*//*1120:*/
  14689. #line 196 "./user.w"
  14690. void UserLabel::mouseReleaseEvent(QMouseEvent*event)
  14691. {
  14692. LoginDialog*dialog= new LoginDialog;
  14693. dialog->exec();
  14694. }
  14695. /*:1120*/
  14696. #line 346 "./user.w"
  14697. /*1112:*/
  14698. #line 95 "./user.w"
  14699. LoginDialog::LoginDialog():QDialog(),
  14700. user(new QLineEdit),password(new QLineEdit),
  14701. warning(new QLabel(tr("Log in failed."))),
  14702. login(new QPushButton(tr("Log In")))
  14703. {
  14704. setModal(true);
  14705. QVBoxLayout*mainLayout= new QVBoxLayout;
  14706. warning->setVisible(false);
  14707. password->setEchoMode(QLineEdit::Password);
  14708. QFormLayout*form= new QFormLayout;
  14709. form->addRow(tr("Name:"),user);
  14710. form->addRow(tr("Password:"),password);
  14711. form->addRow(warning);
  14712. QHBoxLayout*buttonBox= new QHBoxLayout;
  14713. buttonBox->addStretch();
  14714. buttonBox->addWidget(login);
  14715. mainLayout->addLayout(form);
  14716. mainLayout->addLayout(buttonBox);
  14717. connect(login,SIGNAL(clicked()),this,SLOT(attemptLogin()));
  14718. setLayout(mainLayout);
  14719. }
  14720. /*:1112*//*1113:*/
  14721. #line 120 "./user.w"
  14722. void LoginDialog::attemptLogin()
  14723. {
  14724. if(AppInstance->login(user->text(),password->text()))
  14725. {
  14726. accept();
  14727. }
  14728. else
  14729. {
  14730. warning->setVisible(true);
  14731. }
  14732. }
  14733. /*:1113*/
  14734. #line 347 "./user.w"
  14735. #line 20284 "./typica.w"
  14736. /*:1127*/
  14737. #line 529 "./typica.w"
  14738. /*8:*/
  14739. #line 675 "./typica.w"
  14740. template<class TYPE> TYPE getself(QScriptContext*context)
  14741. {
  14742. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  14743. return self;
  14744. }
  14745. template<> QTime getself(QScriptContext*context)
  14746. {
  14747. QTime self= context->thisObject().toVariant().toTime();
  14748. return self;
  14749. }
  14750. template<> QByteArray getself(QScriptContext*context)
  14751. {
  14752. QByteArray self= context->thisObject().toVariant().toByteArray();
  14753. return self;
  14754. }
  14755. template<> SqlQueryConnection*getself(QScriptContext*context)
  14756. {
  14757. SqlQueryConnection*self=
  14758. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  14759. return self;
  14760. }
  14761. template<> QXmlQuery*getself(QScriptContext*context)
  14762. {
  14763. QXmlQuery*self=
  14764. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  14765. return self;
  14766. }
  14767. template<> QXmlStreamWriter*getself(QScriptContext*context)
  14768. {
  14769. QXmlStreamWriter*self=
  14770. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  14771. return self;
  14772. }
  14773. template<> QXmlStreamReader*getself(QScriptContext*context)
  14774. {
  14775. QXmlStreamReader*self=
  14776. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  14777. return self;
  14778. }
  14779. /*:8*//*9:*/
  14780. #line 726 "./typica.w"
  14781. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  14782. {
  14783. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  14784. return argument;
  14785. }
  14786. template<> QString argument(int arg,QScriptContext*context)
  14787. {
  14788. return context->argument(arg).toString();
  14789. }
  14790. template<> QVariant argument(int arg,QScriptContext*context)
  14791. {
  14792. return context->argument(arg).toVariant();
  14793. }
  14794. template<> int argument(int arg,QScriptContext*context)
  14795. {
  14796. return context->argument(arg).toInt32();
  14797. }
  14798. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  14799. {
  14800. return(SqlQueryConnection*)
  14801. qscriptvalue_cast<void*> (context->argument(arg));
  14802. }
  14803. template<> QModelIndex argument(int arg,QScriptContext*context)
  14804. {
  14805. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  14806. }
  14807. template<> double argument(int arg,QScriptContext*context)
  14808. {
  14809. return(double)(context->argument(arg).toNumber());
  14810. }
  14811. template<> Units::Unit argument(int arg,QScriptContext*context)
  14812. {
  14813. return(Units::Unit)(context->argument(arg).toInt32());
  14814. }
  14815. template<> QByteArray argument(int arg,QScriptContext*context)
  14816. {
  14817. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  14818. }
  14819. /*:9*//*13:*/
  14820. #line 820 "./typica.w"
  14821. void setQObjectProperties(QScriptValue value,QScriptEngine*engine)
  14822. {
  14823. value.setProperty("setProperty",engine->newFunction(QObject_setProperty));
  14824. }
  14825. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*)
  14826. {
  14827. QObject*self= getself<QObject*> (context);
  14828. self->setProperty(argument<QString> (0,context).toUtf8().constData(),
  14829. argument<QVariant> (1,context));
  14830. return QScriptValue();
  14831. }
  14832. /*:13*//*15:*/
  14833. #line 842 "./typica.w"
  14834. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  14835. {
  14836. }
  14837. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  14838. {
  14839. }
  14840. /*:15*//*18:*/
  14841. #line 874 "./typica.w"
  14842. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  14843. {
  14844. setQObjectProperties(value,engine);
  14845. }
  14846. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  14847. {
  14848. QScriptValue object= engine->newQObject(new QTimer);
  14849. setQTimerProperties(object,engine);
  14850. return object;
  14851. }
  14852. /*:18*//*21:*/
  14853. #line 916 "./typica.w"
  14854. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  14855. {
  14856. QScriptValue object= engine->newQObject(new QWidget);
  14857. setQWidgetProperties(object,engine);
  14858. return object;
  14859. }
  14860. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14861. {
  14862. setQObjectProperties(value,engine);
  14863. setQPaintDeviceProperties(value,engine);
  14864. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  14865. value.setProperty("activateWindow",
  14866. engine->newFunction(QWidget_activateWindow));
  14867. }
  14868. /*:21*//*22:*/
  14869. #line 938 "./typica.w"
  14870. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  14871. {
  14872. if(context->argumentCount()==1)
  14873. {
  14874. QWidget*self= getself<QWidget*> (context);
  14875. QLayout*layout= argument<QLayout*> (0,context);
  14876. if(layout)
  14877. {
  14878. self->setLayout(layout);
  14879. }
  14880. else
  14881. {
  14882. context->throwError("Incorrect argument type passed to "
  14883. "QWidget::setLayout(). This method requires "
  14884. "a QLayout.");
  14885. }
  14886. }
  14887. else
  14888. {
  14889. context->throwError("Incorrect number of arguments passed to "
  14890. "QWidget::setLayout(). This method takes one "
  14891. "QLayout as an argument.");
  14892. }
  14893. return QScriptValue();
  14894. }
  14895. QScriptValue QWidget_activateWindow(QScriptContext*context,
  14896. QScriptEngine*)
  14897. {
  14898. QWidget*self= getself<QWidget*> (context);
  14899. self->activateWindow();
  14900. return QScriptValue();
  14901. }
  14902. /*:22*//*25:*/
  14903. #line 1000 "./typica.w"
  14904. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  14905. {
  14906. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  14907. argument<QString> (0,context),
  14908. argument<QString> (1,context),
  14909. QMessageBox::Ok|QMessageBox::Cancel);
  14910. if(selection==QMessageBox::Ok){
  14911. return QScriptValue(true);
  14912. }
  14913. return QScriptValue(false);
  14914. }
  14915. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  14916. {
  14917. QMessageBox::critical(NULL,argument<QString> (0,context),
  14918. argument<QString> (1,context));
  14919. return QScriptValue();
  14920. }
  14921. /*:25*//*27:*/
  14922. #line 1078 "./typica.w"
  14923. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  14924. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  14925. {
  14926. if(!AppInstance->databaseConnected())
  14927. {
  14928. statusBar()->addWidget(new QLabel(tr("Not connected to database")));
  14929. }
  14930. else
  14931. {
  14932. statusBar()->addWidget(new UserLabel);
  14933. }
  14934. }
  14935. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  14936. {
  14937. QSettings settings;
  14938. settings.beginGroup(key);
  14939. settings.setValue("pos",pos());
  14940. settings.setValue("size",size());
  14941. settings.endGroup();
  14942. }
  14943. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  14944. {
  14945. QSettings settings;
  14946. settings.beginGroup(key);
  14947. if(settings.contains("size"))
  14948. {
  14949. resize(settings.value("size").toSize());
  14950. }
  14951. if(settings.contains("pos"))
  14952. {
  14953. move(settings.value("pos").toPoint());
  14954. }
  14955. settings.endGroup();
  14956. }
  14957. void ScriptQMainWindow::displayStatus(const QString&message)
  14958. {
  14959. statusBar()->showMessage(message);
  14960. }
  14961. void ScriptQMainWindow::showEvent(QShowEvent*event)
  14962. {
  14963. if(!event->spontaneous())
  14964. {
  14965. /*32:*/
  14966. #line 1202 "./typica.w"
  14967. QSettings settings;
  14968. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  14969. toByteArray());
  14970. /*:32*/
  14971. #line 1125 "./typica.w"
  14972. event->accept();
  14973. }
  14974. else
  14975. {
  14976. event->ignore();
  14977. }
  14978. }
  14979. void ScriptQMainWindow::show()
  14980. {
  14981. QMainWindow::show();
  14982. }
  14983. void ScriptQMainWindow::setupFinished()
  14984. {
  14985. emit windowReady();
  14986. }
  14987. /*:27*//*28:*/
  14988. #line 1151 "./typica.w"
  14989. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  14990. {
  14991. if(isWindowModified()){
  14992. /*29:*/
  14993. #line 1165 "./typica.w"
  14994. QMessageBox::StandardButton result;
  14995. result= QMessageBox::warning(this,"Typica",closePrompt(),
  14996. QMessageBox::Ok|QMessageBox::Cancel);
  14997. if(result==QMessageBox::Cancel)
  14998. {
  14999. event->ignore();
  15000. return;
  15001. }
  15002. /*:29*/
  15003. #line 1155 "./typica.w"
  15004. }
  15005. emit aboutToClose();
  15006. /*31:*/
  15007. #line 1196 "./typica.w"
  15008. QSettings settings;
  15009. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  15010. /*:31*/
  15011. #line 1158 "./typica.w"
  15012. event->accept();
  15013. }
  15014. /*:28*//*30:*/
  15015. #line 1177 "./typica.w"
  15016. QString ScriptQMainWindow::closePrompt()
  15017. {
  15018. return cprompt;
  15019. }
  15020. void ScriptQMainWindow::setClosePrompt(QString prompt)
  15021. {
  15022. cprompt= prompt;
  15023. }
  15024. /*:30*//*35:*/
  15025. #line 1230 "./typica.w"
  15026. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  15027. {
  15028. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  15029. setQMainWindowProperties(object,engine);
  15030. return object;
  15031. }
  15032. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  15033. {
  15034. setQWidgetProperties(value,engine);
  15035. value.setProperty("setCentralWidget",
  15036. engine->newFunction(QMainWindow_setCentralWidget));
  15037. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  15038. }
  15039. /*:35*//*36:*/
  15040. #line 1252 "./typica.w"
  15041. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  15042. QScriptEngine*)
  15043. {
  15044. if(context->argumentCount()==1)
  15045. {
  15046. QMainWindow*self= getself<QMainWindow*> (context);
  15047. QWidget*widget= argument<QWidget*> (0,context);
  15048. if(widget)
  15049. {
  15050. self->setCentralWidget(widget);
  15051. }
  15052. else
  15053. {
  15054. context->throwError("Incorrect argument type passed to "
  15055. "QMainWindow::setCentralWidget(). This "
  15056. "method requires a QWidget.");
  15057. }
  15058. }
  15059. else
  15060. {
  15061. context->throwError("Incorrect number of arguments passed to "
  15062. "QMainWindow::setCentralWidget(). This method "
  15063. "takes one QWidget as an argument.");
  15064. }
  15065. return QScriptValue();
  15066. }
  15067. /*:36*//*37:*/
  15068. #line 1286 "./typica.w"
  15069. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  15070. {
  15071. QScriptValue object;
  15072. if(context->argumentCount()==0)
  15073. {
  15074. QMainWindow*self= getself<QMainWindow*> (context);
  15075. QMenuBar*bar= self->menuBar();
  15076. object= engine->newQObject(bar);
  15077. setQMenuBarProperties(object,engine);
  15078. }
  15079. else
  15080. {
  15081. context->throwError("Incorrect number of arguments passed to "
  15082. "QMainWindow::menuBar(). This method takes no "
  15083. "arguments.");
  15084. }
  15085. return object;
  15086. }
  15087. /*:37*//*39:*/
  15088. #line 1316 "./typica.w"
  15089. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  15090. {
  15091. setQWidgetProperties(value,engine);
  15092. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  15093. }
  15094. /*:39*//*40:*/
  15095. #line 1331 "./typica.w"
  15096. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  15097. {
  15098. QScriptValue object;
  15099. if(context->argumentCount()==1)
  15100. {
  15101. QMenuBar*self= getself<QMenuBar*> (context);
  15102. QString title= argument<QString> (0,context);
  15103. object= engine->newQObject(self->addMenu(title));
  15104. setQMenuProperties(object,engine);
  15105. }
  15106. else
  15107. {
  15108. context->throwError("Incorrect number of arguments passed to "
  15109. "QMenuBar::addMenu(). This method takes one "
  15110. "string as an argument.");
  15111. }
  15112. return object;
  15113. }
  15114. /*:40*//*42:*/
  15115. #line 1361 "./typica.w"
  15116. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  15117. {
  15118. setQWidgetProperties(value,engine);
  15119. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  15120. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  15121. }
  15122. /*:42*//*43:*/
  15123. #line 1371 "./typica.w"
  15124. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  15125. {
  15126. if(context->argumentCount()==1)
  15127. {
  15128. QMenu*self= getself<QMenu*> (context);
  15129. QAction*action= argument<QAction*> (0,context);
  15130. if(action)
  15131. {
  15132. self->addAction(action);
  15133. }
  15134. else
  15135. {
  15136. context->throwError("Incorrect argument type passed to "
  15137. "QMenu::addAction(). This method requires a "
  15138. "QAction.");
  15139. }
  15140. }
  15141. else
  15142. {
  15143. context->throwError("Incorrect number of arguments passed to "
  15144. "QMenu::addAction(). This method takes one "
  15145. "QAction as an argument.");
  15146. }
  15147. return QScriptValue();
  15148. }
  15149. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  15150. {
  15151. if(context->argumentCount()==0)
  15152. {
  15153. QMenu*self= getself<QMenu*> (context);
  15154. self->addSeparator();
  15155. }
  15156. else
  15157. {
  15158. context->throwError("Incorrect number of arguments passed to "
  15159. "QMenu::addSeparator(). This method takes no "
  15160. "arguments.");
  15161. }
  15162. return QScriptValue();
  15163. }
  15164. /*:43*//*46:*/
  15165. #line 1433 "./typica.w"
  15166. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  15167. {
  15168. QScriptValue object= engine->newQObject(new QFrame);
  15169. setQFrameProperties(object,engine);
  15170. return object;
  15171. }
  15172. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  15173. {
  15174. setQWidgetProperties(value,engine);
  15175. }
  15176. /*:46*//*49:*/
  15177. #line 1467 "./typica.w"
  15178. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  15179. {
  15180. QString text;
  15181. if(context->argumentCount()==1)
  15182. {
  15183. text= argument<QString> (0,context);
  15184. }
  15185. QScriptValue object= engine->newQObject(new QLabel(text));
  15186. setQLabelProperties(object,engine);
  15187. return object;
  15188. }
  15189. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  15190. {
  15191. setQFrameProperties(value,engine);
  15192. }
  15193. /*:49*//*52:*/
  15194. #line 1509 "./typica.w"
  15195. QScriptValue constructQSvgWidget(QScriptContext*,
  15196. QScriptEngine*engine)
  15197. {
  15198. QScriptValue object= engine->newQObject(new QSvgWidget);
  15199. setQSvgWidgetProperties(object,engine);
  15200. return object;
  15201. }
  15202. /*:52*//*53:*/
  15203. #line 1520 "./typica.w"
  15204. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  15205. {
  15206. setQWidgetProperties(value,engine);
  15207. value.setProperty("loadDevice",
  15208. engine->newFunction(QSvgWidget_loadDevice));
  15209. }
  15210. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  15211. {
  15212. if(context->argumentCount()==1)
  15213. {
  15214. QSvgWidget*self= getself<QSvgWidget*> (context);
  15215. QIODevice*device= argument<QIODevice*> (0,context);
  15216. device->reset();
  15217. QByteArray data= device->readAll();
  15218. self->load(data);
  15219. }
  15220. else
  15221. {
  15222. context->throwError("Incorrect number of arguments passed to "
  15223. "QSvgWidget::loadData(). This method takes one "
  15224. "QIODevice as an argument.");
  15225. }
  15226. return QScriptValue();
  15227. }
  15228. /*:53*//*55:*/
  15229. #line 1558 "./typica.w"
  15230. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  15231. QStack<QLayout*> *layoutStack)
  15232. {
  15233. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15234. QSvgWidget*widget= new QSvgWidget;
  15235. layout->addWidget(widget);
  15236. QString id= element.attribute("id");
  15237. if(!id.isEmpty())
  15238. {
  15239. widget->setObjectName(id);
  15240. }
  15241. }
  15242. /*:55*//*58:*/
  15243. #line 1591 "./typica.w"
  15244. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  15245. {
  15246. QScriptValue object= engine->newQObject(new QLineEdit());
  15247. setQLineEditProperties(object,engine);
  15248. return object;
  15249. }
  15250. /*:58*//*59:*/
  15251. #line 1602 "./typica.w"
  15252. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  15253. {
  15254. setQWidgetProperties(value,engine);
  15255. }
  15256. /*:59*//*62:*/
  15257. #line 1638 "./typica.w"
  15258. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  15259. {
  15260. QScriptValue object= engine->newQObject(new QSplitter);
  15261. setQSplitterProperties(object,engine);
  15262. return object;
  15263. }
  15264. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  15265. {
  15266. setQFrameProperties(value,engine);
  15267. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  15268. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  15269. value.setProperty("restoreState",
  15270. engine->newFunction(QSplitter_restoreState));
  15271. value.setProperty("count",engine->newFunction(QSplitter_count));
  15272. }
  15273. /*:62*//*63:*/
  15274. #line 1659 "./typica.w"
  15275. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  15276. {
  15277. if(context->argumentCount()==1)
  15278. {
  15279. QSplitter*self= getself<QSplitter*> (context);
  15280. QWidget*widget= argument<QWidget*> (0,context);
  15281. if(widget)
  15282. {
  15283. self->addWidget(widget);
  15284. }
  15285. else
  15286. {
  15287. context->throwError("Incorrect argument type passed to "
  15288. "QSplitter::addWidget(). This method "
  15289. "requires a QWidget.");
  15290. }
  15291. }
  15292. else
  15293. {
  15294. context->throwError("Incorrect number of arguments passed to "
  15295. "QSplitter::addWidget(). This method takes one "
  15296. "QWidget as an argument.");
  15297. }
  15298. return QScriptValue();
  15299. }
  15300. /*:63*//*64:*/
  15301. #line 1696 "./typica.w"
  15302. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  15303. {
  15304. QSplitter*self= getself<QSplitter*> (context);
  15305. return QScriptValue(self->count());
  15306. }
  15307. /*:64*//*65:*/
  15308. #line 1709 "./typica.w"
  15309. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  15310. {
  15311. if(context->argumentCount()==1)
  15312. {
  15313. QSplitter*self= getself<QSplitter*> (context);
  15314. QString key= argument<QString> (0,context);
  15315. QSettings settings;
  15316. settings.setValue(key,self->saveState());
  15317. }
  15318. else
  15319. {
  15320. context->throwError("Incorrect number of arguments passed to "
  15321. "QSplitter::saveState(). This method takes one "
  15322. "string as an argument.");
  15323. }
  15324. return QScriptValue();
  15325. }
  15326. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  15327. {
  15328. if(context->argumentCount()==1)
  15329. {
  15330. QSplitter*self= getself<QSplitter*> (context);
  15331. QString key= argument<QString> (0,context);
  15332. QSettings settings;
  15333. self->restoreState(settings.value(key).toByteArray());
  15334. }
  15335. else
  15336. {
  15337. context->throwError("Incorrect number of arguments passed to "
  15338. "QSplitter::restoreState(). This method takes "
  15339. "one string as an argument.");
  15340. }
  15341. return QScriptValue();
  15342. }
  15343. /*:65*//*67:*/
  15344. #line 1762 "./typica.w"
  15345. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  15346. {
  15347. setQLayoutItemProperties(value,engine);
  15348. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  15349. }
  15350. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  15351. {
  15352. if(context->argumentCount()==1)
  15353. {
  15354. QLayout*self= getself<QLayout*> (context);
  15355. QWidget*widget= argument<QWidget*> (0,context);
  15356. if(widget)
  15357. {
  15358. self->addWidget(widget);
  15359. }
  15360. else
  15361. {
  15362. context->throwError("Incorrect argument type passed to "
  15363. "QLayout::addWidget(). This method requires "
  15364. "a QWidget.");
  15365. }
  15366. }
  15367. else
  15368. {
  15369. context->throwError("Incorrect number of arguments passed to "
  15370. "QLayout::addWidget(). This method takes one "
  15371. "QWidget as an argument.");
  15372. }
  15373. return QScriptValue();
  15374. }
  15375. /*:67*//*70:*/
  15376. #line 1829 "./typica.w"
  15377. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  15378. {
  15379. QScriptValue object=
  15380. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  15381. setQBoxLayoutProperties(object,engine);
  15382. return object;
  15383. }
  15384. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  15385. {
  15386. setQLayoutProperties(value,engine);
  15387. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  15388. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  15389. }
  15390. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  15391. {
  15392. if(context->argumentCount()> 0&&context->argumentCount()<3)
  15393. {
  15394. QBoxLayout*self= getself<QBoxLayout*> (context);
  15395. QLayout*layout= argument<QLayout*> (0,context);
  15396. int stretch= 0;
  15397. if(context->argumentCount()==2)
  15398. {
  15399. stretch= argument<int> (1,context);
  15400. }
  15401. if(layout)
  15402. {
  15403. self->addLayout(layout,stretch);
  15404. }
  15405. else
  15406. {
  15407. context->throwError("Incorrect argument type passed to "
  15408. "QLayout::addLayout(). This method requires "
  15409. "a QLayout.");
  15410. }
  15411. }
  15412. else
  15413. {
  15414. context->throwError("Incorrect number of arguments passed to "
  15415. "QLayout::addLayout(). This method takes one "
  15416. "QLayout as an argument and optionally one integer.");
  15417. }
  15418. return QScriptValue();
  15419. }
  15420. /*:70*//*71:*/
  15421. #line 1880 "./typica.w"
  15422. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  15423. {
  15424. if(context->argumentCount()> 0&&context->argumentCount()<4)
  15425. {
  15426. QBoxLayout*self= getself<QBoxLayout*> (context);
  15427. QWidget*widget= argument<QWidget*> (0,context);
  15428. int stretch= 0;
  15429. Qt::Alignment alignment= 0;
  15430. if(context->argumentCount()> 1)
  15431. {
  15432. stretch= argument<int> (1,context);
  15433. }
  15434. if(context->argumentCount()> 2)
  15435. {
  15436. alignment= (Qt::Alignment)(argument<int> (2,context));
  15437. }
  15438. if(widget)
  15439. {
  15440. self->addWidget(widget,stretch,alignment);
  15441. }
  15442. else
  15443. {
  15444. context->throwError("Incorrect argument type passed to "
  15445. "QBoxLayout::addWidget(). This method requires "
  15446. "a QWidget.");
  15447. }
  15448. }
  15449. else
  15450. {
  15451. context->throwError("Incorrect number of arguments passed to "
  15452. "QBoxLayout::addWidget(). This method takes one "
  15453. "QWidget and optionally up to two integers as "
  15454. "arguments.");
  15455. }
  15456. return QScriptValue();
  15457. }
  15458. /*:71*//*74:*/
  15459. #line 1944 "./typica.w"
  15460. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  15461. {
  15462. QScriptValue object= engine->newQObject(new QAction(NULL));
  15463. setQActionProperties(object,engine);
  15464. return object;
  15465. }
  15466. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  15467. {
  15468. setQObjectProperties(value,engine);
  15469. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  15470. }
  15471. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  15472. {
  15473. if(context->argumentCount()==1)
  15474. {
  15475. QAction*self= getself<QAction*> (context);
  15476. self->setShortcut(argument<QString> (0,context));
  15477. }
  15478. else
  15479. {
  15480. context->throwError("Incorrect number of arguments passed to "
  15481. "QAction::setShortcut(). This method takes one "
  15482. "string as an argument.");
  15483. }
  15484. return QScriptValue();
  15485. }
  15486. /*:74*//*77:*/
  15487. #line 2002 "./typica.w"
  15488. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  15489. QScriptEngine*engine)
  15490. {
  15491. QScriptValue retval;
  15492. if(context->argumentCount()==3)
  15493. {
  15494. QWidget*widget= argument<QWidget*> (0,context);
  15495. if(widget)
  15496. {
  15497. QString caption= argument<QString> (1,context);
  15498. QString dir= argument<QString> (2,context);
  15499. retval= QScriptValue(engine,
  15500. QFileDialog::getOpenFileName(widget,caption,
  15501. dir,"",0,0));
  15502. setQFileDialogProperties(retval,engine);
  15503. }
  15504. else
  15505. {
  15506. context->throwError("Incorrect argument type passed to "
  15507. "QFileDialog::getOpenFileName(). The first "
  15508. "argument to this method must be a QWidget.");
  15509. }
  15510. }
  15511. else
  15512. {
  15513. context->throwError("Incorrect number of arguments passed to "
  15514. "QFileDialog::getOpenFileName(). This method "
  15515. "takes one QWidget followed by two strings for a "
  15516. "total of three arguments.");
  15517. }
  15518. return retval;
  15519. }
  15520. /*:77*//*78:*/
  15521. #line 2038 "./typica.w"
  15522. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  15523. QScriptEngine*engine)
  15524. {
  15525. QScriptValue retval;
  15526. if(context->argumentCount()==3)
  15527. {
  15528. QWidget*widget= argument<QWidget*> (0,context);
  15529. if(widget)
  15530. {
  15531. QString caption= argument<QString> (1,context);
  15532. QString dir= argument<QString> (2,context);
  15533. retval= QScriptValue(engine,
  15534. QFileDialog::getSaveFileName(widget,caption,
  15535. dir,"",0,0));
  15536. setQFileDialogProperties(retval,engine);
  15537. }
  15538. else
  15539. {
  15540. context->throwError("Incorrect argument type passed to "
  15541. "QFileDialog::getSaveFileName(). The first "
  15542. "argument to this method must be a QWidget.");
  15543. }
  15544. }
  15545. else
  15546. {
  15547. context->throwError("Incorrect number of arguments passed to "
  15548. "QFileDialog::getSaveFileName(). This method "
  15549. "takes one QWidget followed by two strings for a "
  15550. "total of three arguments.");
  15551. }
  15552. return retval;
  15553. }
  15554. /*:78*//*79:*/
  15555. #line 2075 "./typica.w"
  15556. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  15557. {
  15558. setQDialogProperties(value,engine);
  15559. }
  15560. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  15561. {
  15562. setQWidgetProperties(value,engine);
  15563. }
  15564. /*:79*//*82:*/
  15565. #line 2116 "./typica.w"
  15566. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  15567. {
  15568. QScriptValue object=
  15569. engine->newQObject(new QFile(argument<QString> (0,context)));
  15570. setQFileProperties(object,engine);
  15571. return object;
  15572. }
  15573. /*:82*//*83:*/
  15574. #line 2127 "./typica.w"
  15575. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  15576. {
  15577. setQIODeviceProperties(value,engine);
  15578. value.setProperty("remove",engine->newFunction(QFile_remove));
  15579. }
  15580. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  15581. {
  15582. QFile*self= getself<QFile*> (context);
  15583. bool retval= self->remove();
  15584. return QScriptValue(engine,retval);
  15585. }
  15586. /*:83*//*84:*/
  15587. #line 2149 "./typica.w"
  15588. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  15589. {
  15590. setQObjectProperties(value,engine);
  15591. value.setProperty("open",engine->newFunction(QIODevice_open));
  15592. value.setProperty("close",engine->newFunction(QIODevice_close));
  15593. value.setProperty("readToString",
  15594. engine->newFunction(QIODevice_readToString));
  15595. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  15596. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  15597. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  15598. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  15599. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  15600. value.setProperty("read",engine->newFunction(QIODevice_read));
  15601. }
  15602. /*:84*//*85:*/
  15603. #line 2170 "./typica.w"
  15604. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  15605. {
  15606. QIODevice*self= getself<QIODevice*> (context);
  15607. bool retval= false;
  15608. if(context->argumentCount()==1)
  15609. {
  15610. switch(argument<int> (0,context))
  15611. {
  15612. case 1:
  15613. retval= self->open(QIODevice::ReadOnly);
  15614. break;
  15615. case 2:
  15616. retval= self->open(QIODevice::WriteOnly);
  15617. break;
  15618. case 3:
  15619. retval= self->open(QIODevice::ReadWrite);
  15620. break;
  15621. default:
  15622. break;
  15623. }
  15624. }
  15625. else
  15626. {
  15627. retval= self->open(QIODevice::ReadWrite);
  15628. }
  15629. return QScriptValue(retval);
  15630. }
  15631. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  15632. {
  15633. QIODevice*self= getself<QIODevice*> (context);
  15634. self->close();
  15635. return QScriptValue();
  15636. }
  15637. /*:85*//*86:*/
  15638. #line 2210 "./typica.w"
  15639. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  15640. {
  15641. QIODevice*self= getself<QIODevice*> (context);
  15642. self->reset();
  15643. return QScriptValue(QString(self->readAll()));
  15644. }
  15645. /*:86*//*87:*/
  15646. #line 2226 "./typica.w"
  15647. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  15648. {
  15649. QIODevice*self= getself<QIODevice*> (context);
  15650. if(context->argumentCount()==1)
  15651. {
  15652. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  15653. }
  15654. context->throwError("Incorrect number of arguments passed to "
  15655. "QIODevice::putChar()");
  15656. return QScriptValue();
  15657. }
  15658. /*:87*//*88:*/
  15659. #line 2244 "./typica.w"
  15660. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  15661. {
  15662. QIODevice*self= getself<QIODevice*> (context);
  15663. if(context->argumentCount()==1)
  15664. {
  15665. self->write(argument<QString> (0,context).toUtf8());
  15666. }
  15667. else
  15668. {
  15669. context->throwError("Incorrect number of arguments passed to "
  15670. "QIODevice::writeString()");
  15671. }
  15672. return QScriptValue();
  15673. }
  15674. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  15675. {
  15676. QIODevice*self= getself<QIODevice*> (context);
  15677. if(context->argumentCount()==1)
  15678. {
  15679. self->write(argument<QByteArray> (0,context));
  15680. }
  15681. else
  15682. {
  15683. context->throwError("Incorrect number of arguments passed to "
  15684. "QIODevice::writeBytes()");
  15685. }
  15686. return QScriptValue();
  15687. }
  15688. /*:88*//*89:*/
  15689. #line 2278 "./typica.w"
  15690. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  15691. {
  15692. QIODevice*self= getself<QIODevice*> (context);
  15693. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  15694. setQByteArrayProperties(value,engine);
  15695. return value;
  15696. }
  15697. /*:89*//*90:*/
  15698. #line 2289 "./typica.w"
  15699. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  15700. {
  15701. QIODevice*self= getself<QIODevice*> (context);
  15702. QScriptValue value= engine->toScriptValue<QByteArray> (
  15703. self->peek(argument<int> (0,context)));
  15704. setQByteArrayProperties(value,engine);
  15705. return value;
  15706. }
  15707. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  15708. {
  15709. QIODevice*self= getself<QIODevice*> (context);
  15710. QScriptValue value= engine->toScriptValue<QByteArray> (
  15711. self->read(argument<int> (0,context)));
  15712. setQByteArrayProperties(value,engine);
  15713. return value;
  15714. }
  15715. /*:90*//*93:*/
  15716. #line 2334 "./typica.w"
  15717. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  15718. {
  15719. QScriptValue object= engine->newQObject(new QProcess);
  15720. setQProcessProperties(object,engine);
  15721. return object;
  15722. }
  15723. /*:93*//*94:*/
  15724. #line 2345 "./typica.w"
  15725. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  15726. {
  15727. setQIODeviceProperties(value,engine);
  15728. value.setProperty("execute",engine->newFunction(QProcess_execute));
  15729. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  15730. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  15731. value.setProperty("start",engine->newFunction(QProcess_start));
  15732. }
  15733. /*:94*//*95:*/
  15734. #line 2359 "./typica.w"
  15735. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  15736. {
  15737. QProcess*self= getself<QProcess*> (context);
  15738. QString program= argument<QString> (0,context);
  15739. QStringList arguments= QStringList();
  15740. if(context->argumentCount()> 1){
  15741. arguments= argument<QVariant> (1,context).toStringList();
  15742. }
  15743. int retval= self->execute(program,arguments);
  15744. return QScriptValue(retval);
  15745. }
  15746. /*:95*//*96:*/
  15747. #line 2374 "./typica.w"
  15748. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  15749. {
  15750. QProcess*self= getself<QProcess*> (context);
  15751. QString program= argument<QString> (0,context);
  15752. QStringList arguments= QStringList();
  15753. if(context->argumentCount()> 1){
  15754. arguments= argument<QVariant> (1,context).toStringList();
  15755. }
  15756. QString workingDirectory= "";
  15757. if(context->argumentCount()> 2){
  15758. workingDirectory= argument<QString> (2,context);
  15759. }
  15760. bool retval;
  15761. switch(context->argumentCount())
  15762. {
  15763. case 1:
  15764. retval= self->startDetached(program);
  15765. break;
  15766. case 2:
  15767. retval= self->startDetached(program,arguments);
  15768. break;
  15769. case 3:
  15770. retval= self->startDetached(program,arguments,workingDirectory);
  15771. break;
  15772. default:
  15773. retval= false;
  15774. }
  15775. return QScriptValue(retval);
  15776. }
  15777. /*:96*//*97:*/
  15778. #line 2407 "./typica.w"
  15779. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  15780. {
  15781. QProcess*self= getself<QProcess*> (context);
  15782. QString directory= argument<QString> (0,context);
  15783. self->setWorkingDirectory(directory);
  15784. return QScriptValue();
  15785. }
  15786. /*:97*//*98:*/
  15787. #line 2419 "./typica.w"
  15788. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  15789. {
  15790. QProcess*self= getself<QProcess*> (context);
  15791. QString program= argument<QString> (0,context);
  15792. QStringList arguments= QStringList();
  15793. if(context->argumentCount()> 1){
  15794. arguments= argument<QVariant> (1,context).toStringList();
  15795. }
  15796. self->start(program,arguments);
  15797. return QScriptValue();
  15798. }
  15799. /*:98*//*100:*/
  15800. #line 2460 "./typica.w"
  15801. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  15802. {
  15803. QScriptValue object= engine->newVariant(QVariant(bytes));
  15804. setQByteArrayProperties(object,engine);
  15805. return object;
  15806. }
  15807. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  15808. {
  15809. bytes= value.toVariant().toByteArray();
  15810. }
  15811. /*:100*//*102:*/
  15812. #line 2483 "./typica.w"
  15813. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  15814. {
  15815. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  15816. setQByteArrayProperties(object,engine);
  15817. return object;
  15818. }
  15819. /*:102*//*103:*/
  15820. #line 2494 "./typica.w"
  15821. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  15822. {
  15823. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  15824. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  15825. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  15826. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  15827. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  15828. value.setProperty("size",engine->newFunction(QByteArray_size));
  15829. value.setProperty("left",engine->newFunction(QByteArray_left));
  15830. value.setProperty("right",engine->newFunction(QByteArray_right));
  15831. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  15832. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  15833. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  15834. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  15835. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  15836. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  15837. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  15838. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  15839. }
  15840. /*:103*//*104:*/
  15841. #line 2518 "./typica.w"
  15842. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  15843. {
  15844. QByteArray self= getself<QByteArray> (context);
  15845. QByteArray retval;
  15846. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  15847. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  15848. setQByteArrayProperties(value,engine);
  15849. return value;
  15850. }
  15851. /*:104*//*105:*/
  15852. #line 2532 "./typica.w"
  15853. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  15854. {
  15855. QByteArray self= getself<QByteArray> (context);
  15856. return QScriptValue((int)(self.at(argument<int> (0,context))));
  15857. }
  15858. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  15859. {
  15860. QByteArray self= getself<QByteArray> (context);
  15861. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  15862. return QScriptValue();
  15863. }
  15864. /*:105*//*106:*/
  15865. #line 2550 "./typica.w"
  15866. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  15867. {
  15868. QByteArray self= getself<QByteArray> (context);
  15869. QScriptValue value=
  15870. engine->toScriptValue<QByteArray> (
  15871. self.append(argument<QByteArray> (0,context)));
  15872. setQByteArrayProperties(value,engine);
  15873. return value;
  15874. }
  15875. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  15876. {
  15877. QByteArray self= getself<QByteArray> (context);
  15878. QScriptValue value= engine->toScriptValue<QByteArray> (
  15879. self.append(argument<QString> (0,context)));
  15880. setQByteArrayProperties(value,engine);
  15881. return value;
  15882. }
  15883. /*:106*//*107:*/
  15884. #line 2572 "./typica.w"
  15885. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  15886. {
  15887. QByteArray self= getself<QByteArray> (context);
  15888. return QScriptValue(self.size());
  15889. }
  15890. /*:107*//*108:*/
  15891. #line 2582 "./typica.w"
  15892. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  15893. {
  15894. QByteArray self= getself<QByteArray> (context);
  15895. QScriptValue value= engine->toScriptValue<QByteArray> (
  15896. self.left(argument<int> (0,context)));
  15897. setQByteArrayProperties(value,engine);
  15898. return value;
  15899. }
  15900. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  15901. {
  15902. QByteArray self= getself<QByteArray> (context);
  15903. QScriptValue value= engine->toScriptValue<QByteArray> (
  15904. self.right(argument<int> (0,context)));
  15905. setQByteArrayProperties(value,engine);
  15906. return value;
  15907. }
  15908. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  15909. {
  15910. QByteArray self= getself<QByteArray> (context);
  15911. int length= -1;
  15912. if(context->argumentCount()> 1)
  15913. {
  15914. length= argument<int> (1,context);
  15915. }
  15916. QScriptValue value= engine->toScriptValue<QByteArray> (
  15917. self.mid(argument<int> (0,context),length));
  15918. setQByteArrayProperties(value,engine);
  15919. return value;
  15920. }
  15921. /*:108*//*109:*/
  15922. #line 2617 "./typica.w"
  15923. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  15924. {
  15925. QByteArray self= getself<QByteArray> (context);
  15926. self.chop(argument<int> (0,context));
  15927. return QScriptValue();
  15928. }
  15929. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  15930. {
  15931. QByteArray self= getself<QByteArray> (context);
  15932. QScriptValue value= engine->toScriptValue<QByteArray> (
  15933. self.remove(argument<int> (0,context),argument<int> (1,context)));
  15934. setQByteArrayProperties(value,engine);
  15935. return value;
  15936. }
  15937. /*:109*//*110:*/
  15938. #line 2640 "./typica.w"
  15939. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  15940. {
  15941. QByteArray self= getself<QByteArray> (context);
  15942. int value= 0;
  15943. char*bytes= (char*)&value;
  15944. bytes[0]= self[0];
  15945. return QScriptValue(value);
  15946. }
  15947. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  15948. {
  15949. QByteArray self= getself<QByteArray> (context);
  15950. int value= 0;
  15951. char*bytes= (char*)&value;
  15952. bytes[0]= self[0];
  15953. bytes[1]= self[1];
  15954. return QScriptValue(value);
  15955. }
  15956. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  15957. {
  15958. QByteArray self= getself<QByteArray> (context);
  15959. int value= 0;
  15960. char*bytes= (char*)&value;
  15961. bytes[0]= self[0];
  15962. bytes[1]= self[1];
  15963. bytes[2]= self[2];
  15964. bytes[3]= self[3];
  15965. return QScriptValue(value);
  15966. }
  15967. /*:110*//*111:*/
  15968. #line 2676 "./typica.w"
  15969. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  15970. {
  15971. QByteArray self= getself<QByteArray> (context);
  15972. float value= 0.0;
  15973. char*bytes= (char*)&value;
  15974. bytes[0]= self[0];
  15975. bytes[1]= self[1];
  15976. bytes[2]= self[2];
  15977. bytes[3]= self[3];
  15978. return QScriptValue(value);
  15979. }
  15980. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  15981. {
  15982. QByteArray self= getself<QByteArray> (context);
  15983. double value= 0.0;
  15984. char*bytes= (char*)&value;
  15985. bytes[0]= self[0];
  15986. bytes[1]= self[1];
  15987. bytes[2]= self[2];
  15988. bytes[3]= self[3];
  15989. bytes[4]= self[4];
  15990. bytes[5]= self[5];
  15991. bytes[6]= self[6];
  15992. bytes[7]= self[7];
  15993. return QScriptValue(value);
  15994. }
  15995. /*:111*//*114:*/
  15996. #line 2731 "./typica.w"
  15997. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  15998. {
  15999. qint8 value= (qint8)(argument<int> (0,context));
  16000. char*bytes= (char*)&value;
  16001. QByteArray retval;
  16002. retval.resize(1);
  16003. retval[0]= bytes[0];
  16004. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16005. setQByteArrayProperties(v,engine);
  16006. return v;
  16007. }
  16008. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  16009. {
  16010. qint16 value= (qint16)(argument<int> (0,context));
  16011. char*bytes= (char*)&value;
  16012. QByteArray retval;
  16013. retval.resize(2);
  16014. retval[0]= bytes[0];
  16015. retval[1]= bytes[1];
  16016. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16017. setQByteArrayProperties(v,engine);
  16018. return v;
  16019. }
  16020. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  16021. {
  16022. qint32 value= (qint32)(argument<int> (0,context));
  16023. char*bytes= (char*)&value;
  16024. QByteArray retval;
  16025. retval.resize(4);
  16026. retval[0]= bytes[0];
  16027. retval[1]= bytes[1];
  16028. retval[2]= bytes[2];
  16029. retval[3]= bytes[3];
  16030. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16031. setQByteArrayProperties(v,engine);
  16032. return v;
  16033. }
  16034. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  16035. {
  16036. float value= (float)(argument<double> (0,context));
  16037. char*bytes= (char*)&value;
  16038. QByteArray retval;
  16039. retval.resize(4);
  16040. retval[0]= bytes[0];
  16041. retval[1]= bytes[1];
  16042. retval[2]= bytes[2];
  16043. retval[3]= bytes[3];
  16044. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16045. setQByteArrayProperties(v,engine);
  16046. return v;
  16047. }
  16048. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  16049. {
  16050. double value= (double)(argument<double> (0,context));
  16051. char*bytes= (char*)&value;
  16052. QByteArray retval;
  16053. retval.resize(8);
  16054. retval[0]= bytes[0];
  16055. retval[1]= bytes[1];
  16056. retval[2]= bytes[2];
  16057. retval[3]= bytes[3];
  16058. retval[4]= bytes[4];
  16059. retval[5]= bytes[5];
  16060. retval[6]= bytes[6];
  16061. retval[7]= bytes[7];
  16062. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16063. setQByteArrayProperties(v,engine);
  16064. return v;
  16065. }
  16066. /*:114*//*117:*/
  16067. #line 2828 "./typica.w"
  16068. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  16069. {
  16070. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  16071. QScriptValue object= engine->newQObject(new QBuffer(array));
  16072. setQBufferProperties(object,engine);
  16073. return object;
  16074. }
  16075. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  16076. {
  16077. setQIODeviceProperties(value,engine);
  16078. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  16079. }
  16080. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  16081. {
  16082. QBuffer*self= getself<QBuffer*> (context);
  16083. self->setData(argument<QString> (0,context).toAscii());
  16084. return QScriptValue();
  16085. }
  16086. /*:117*//*120:*/
  16087. #line 2877 "./typica.w"
  16088. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  16089. {
  16090. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  16091. setXQueryProperties(object,engine);
  16092. return object;
  16093. }
  16094. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16095. {
  16096. QXmlQuery*self= getself<QXmlQuery*> (context);
  16097. delete self;
  16098. return QScriptValue();
  16099. }
  16100. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  16101. {
  16102. value.setProperty("bind",engine->newFunction(XQuery_bind));
  16103. value.setProperty("exec",engine->newFunction(XQuery_exec));
  16104. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  16105. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  16106. }
  16107. /*:120*//*121:*/
  16108. #line 2903 "./typica.w"
  16109. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  16110. {
  16111. QXmlQuery*self= getself<QXmlQuery*> (context);
  16112. QIODevice*buffer= argument<QIODevice*> (1,context);
  16113. self->bindVariable(argument<QString> (0,context),buffer);
  16114. return QScriptValue();
  16115. }
  16116. /*:121*//*122:*/
  16117. #line 2914 "./typica.w"
  16118. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  16119. {
  16120. QXmlQuery*self= getself<QXmlQuery*> (context);
  16121. self->setQuery(argument<QString> (0,context));
  16122. return QScriptValue();
  16123. }
  16124. /*:122*//*123:*/
  16125. #line 2924 "./typica.w"
  16126. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  16127. {
  16128. QXmlQuery*self= getself<QXmlQuery*> (context);
  16129. QString result;
  16130. self->evaluateTo(&result);
  16131. return QScriptValue(result);
  16132. }
  16133. /*:123*//*126:*/
  16134. #line 2979 "./typica.w"
  16135. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  16136. {
  16137. QXmlStreamWriter*retval;
  16138. if(context->argumentCount()==1)
  16139. {
  16140. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  16141. }
  16142. else
  16143. {
  16144. retval= new QXmlStreamWriter;
  16145. }
  16146. QScriptValue object= engine->toScriptValue<void*> (retval);
  16147. setXmlWriterProperties(object,engine);
  16148. return object;
  16149. }
  16150. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  16151. {
  16152. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  16153. value.setProperty("writeAttribute",
  16154. engine->newFunction(XmlWriter_writeAttribute));
  16155. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  16156. value.setProperty("writeCharacters",
  16157. engine->newFunction(XmlWriter_writeCharacters));
  16158. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  16159. value.setProperty("writeEmptyElement",
  16160. engine->newFunction(XmlWriter_writeEmptyElement));
  16161. value.setProperty("writeEndDocument",
  16162. engine->newFunction(XmlWriter_writeEndDocument));
  16163. value.setProperty("writeEndElement",
  16164. engine->newFunction(XmlWriter_writeEndElement));
  16165. value.setProperty("writeEntityReference",
  16166. engine->newFunction(XmlWriter_writeEntityReference));
  16167. value.setProperty("writeProcessingInstruction",
  16168. engine->newFunction(XmlWriter_writeProcessingInstruction));
  16169. value.setProperty("writeStartDocument",
  16170. engine->newFunction(XmlWriter_writeStartDocument));
  16171. value.setProperty("writeStartElement",
  16172. engine->newFunction(XmlWriter_writeStartElement));
  16173. value.setProperty("writeTextElement",
  16174. engine->newFunction(XmlWriter_writeTextElement));
  16175. }
  16176. /*:126*//*127:*/
  16177. #line 3026 "./typica.w"
  16178. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  16179. {
  16180. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16181. QIODevice*device= argument<QIODevice*> (0,context);
  16182. self->setDevice(device);
  16183. return QScriptValue();
  16184. }
  16185. /*:127*//*128:*/
  16186. #line 3040 "./typica.w"
  16187. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  16188. QScriptEngine*)
  16189. {
  16190. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16191. self->writeStartDocument(argument<QString> (0,context));
  16192. return QScriptValue();
  16193. }
  16194. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  16195. QScriptEngine*)
  16196. {
  16197. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16198. self->writeEndDocument();
  16199. return QScriptValue();
  16200. }
  16201. /*:128*//*129:*/
  16202. #line 3059 "./typica.w"
  16203. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  16204. {
  16205. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16206. self->writeDTD(argument<QString> (0,context));
  16207. return QScriptValue();
  16208. }
  16209. /*:129*//*130:*/
  16210. #line 3070 "./typica.w"
  16211. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  16212. QScriptEngine*)
  16213. {
  16214. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16215. self->writeStartElement(argument<QString> (0,context));
  16216. return QScriptValue();
  16217. }
  16218. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  16219. {
  16220. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16221. self->writeAttribute(argument<QString> (0,context),
  16222. argument<QString> (1,context));
  16223. return QScriptValue();
  16224. }
  16225. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  16226. {
  16227. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16228. self->writeCharacters(argument<QString> (0,context));
  16229. return QScriptValue();
  16230. }
  16231. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  16232. {
  16233. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16234. self->writeEndElement();
  16235. return QScriptValue();
  16236. }
  16237. /*:130*//*131:*/
  16238. #line 3106 "./typica.w"
  16239. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  16240. QScriptEngine*)
  16241. {
  16242. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16243. self->writeEmptyElement(argument<QString> (0,context));
  16244. return QScriptValue();
  16245. }
  16246. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  16247. QScriptEngine*)
  16248. {
  16249. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16250. self->writeTextElement(argument<QString> (0,context),
  16251. argument<QString> (1,context));
  16252. return QScriptValue();
  16253. }
  16254. /*:131*//*132:*/
  16255. #line 3127 "./typica.w"
  16256. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  16257. {
  16258. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16259. self->writeCDATA(argument<QString> (0,context));
  16260. return QScriptValue();
  16261. }
  16262. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  16263. QScriptEngine*)
  16264. {
  16265. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16266. self->writeEntityReference(argument<QString> (0,context));
  16267. return QScriptValue();
  16268. }
  16269. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  16270. QScriptEngine*)
  16271. {
  16272. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16273. self->writeProcessingInstruction(argument<QString> (0,context),
  16274. argument<QString> (1,context));
  16275. return QScriptValue();
  16276. }
  16277. /*:132*//*135:*/
  16278. #line 3186 "./typica.w"
  16279. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  16280. {
  16281. QXmlStreamReader*retval=
  16282. new QXmlStreamReader(argument<QIODevice*> (0,context));
  16283. QScriptValue object= engine->toScriptValue<void*> (retval);
  16284. setXmlReaderProperties(object,engine);
  16285. return object;
  16286. }
  16287. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  16288. {
  16289. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  16290. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  16291. value.setProperty("hasAttribute",
  16292. engine->newFunction(XmlReader_hasAttribute));
  16293. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  16294. value.setProperty("isStartElement",
  16295. engine->newFunction(XmlReader_isStartElement));
  16296. value.setProperty("name",engine->newFunction(XmlReader_name));
  16297. value.setProperty("readElementText",
  16298. engine->newFunction(XmlReader_readElementText));
  16299. value.setProperty("readNext",
  16300. engine->newFunction(XmlReader_readNext));
  16301. value.setProperty("text",engine->newFunction(XmlReader_text));
  16302. }
  16303. /*:135*//*136:*/
  16304. #line 3216 "./typica.w"
  16305. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  16306. {
  16307. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16308. QString retval=
  16309. self->attributes().value(argument<QString> (0,context)).toString();
  16310. return QScriptValue(retval);
  16311. }
  16312. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  16313. {
  16314. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16315. bool retval=
  16316. self->attributes().hasAttribute(argument<QString> (0,context));
  16317. return QScriptValue(retval);
  16318. }
  16319. /*:136*//*137:*/
  16320. #line 3236 "./typica.w"
  16321. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  16322. {
  16323. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16324. return QScriptValue(self->atEnd());
  16325. }
  16326. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  16327. {
  16328. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16329. return QScriptValue(self->isDTD());
  16330. }
  16331. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  16332. {
  16333. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16334. return QScriptValue(self->isStartElement());
  16335. }
  16336. /*:137*//*138:*/
  16337. #line 3257 "./typica.w"
  16338. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  16339. {
  16340. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16341. self->readNext();
  16342. return QScriptValue();
  16343. }
  16344. /*:138*//*139:*/
  16345. #line 3267 "./typica.w"
  16346. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  16347. {
  16348. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16349. return QScriptValue(self->name().toString());
  16350. }
  16351. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  16352. {
  16353. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16354. return QScriptValue(self->readElementText());
  16355. }
  16356. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  16357. {
  16358. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16359. return QScriptValue(self->text().toString());
  16360. }
  16361. /*:139*//*142:*/
  16362. #line 3309 "./typica.w"
  16363. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  16364. {
  16365. setQObjectProperties(value,engine);
  16366. value.setProperty("value",engine->newFunction(QSettings_value));
  16367. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  16368. }
  16369. /*:142*//*143:*/
  16370. #line 3321 "./typica.w"
  16371. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  16372. {
  16373. QScriptValue object;
  16374. if(context->argumentCount()==1||context->argumentCount()==2)
  16375. {
  16376. QSettings settings;
  16377. QString key= argument<QString> (0,context);
  16378. QVariant value;
  16379. QVariant retval;
  16380. if(context->argumentCount()> 1)
  16381. {
  16382. value= argument<QVariant> (1,context);
  16383. retval= settings.value(key,value);
  16384. }
  16385. else
  16386. {
  16387. retval= settings.value(key);
  16388. }
  16389. object= engine->newVariant(retval);
  16390. }
  16391. else
  16392. {
  16393. context->throwError("Incorrect number of arguments passed to "
  16394. "QSettings::value(). This method takes one "
  16395. "string and one optional variant type.");
  16396. }
  16397. return object;
  16398. }
  16399. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  16400. {
  16401. if(context->argumentCount()==2)
  16402. {
  16403. QSettings settings;
  16404. QString key= argument<QString> (0,context);
  16405. QVariant value= argument<QVariant> (1,context);
  16406. settings.setValue(key,value);
  16407. }
  16408. else
  16409. {
  16410. context->throwError("Incorrect number of arguments passed to "
  16411. "QSettings::setValue(). This method takes one "
  16412. "string and one variant type for a total of two "
  16413. "arguments.");
  16414. }
  16415. return QScriptValue();
  16416. }
  16417. /*:143*//*146:*/
  16418. #line 3390 "./typica.w"
  16419. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  16420. {
  16421. QScriptValue object= engine->newQObject(new QLCDNumber());
  16422. setQLCDNumberProperties(object,engine);
  16423. return object;
  16424. }
  16425. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  16426. {
  16427. setQFrameProperties(value,engine);
  16428. }
  16429. /*:146*//*149:*/
  16430. #line 3448 "./typica.w"
  16431. QScriptValue constructQTime(QScriptContext*context,
  16432. QScriptEngine*engine)
  16433. {
  16434. QScriptValue object;
  16435. if(context->argumentCount()==0||
  16436. (context->argumentCount()>=2&&context->argumentCount()<=4))
  16437. {
  16438. int arg1= 0;
  16439. int arg2= 0;
  16440. int arg3= 0;
  16441. int arg4= 0;
  16442. switch(context->argumentCount())
  16443. {
  16444. case 4:
  16445. arg4= argument<int> (3,context);
  16446. case 3:
  16447. arg3= argument<int> (2,context);
  16448. case 2:
  16449. arg2= argument<int> (1,context);
  16450. arg1= argument<int> (0,context);
  16451. default:
  16452. break;
  16453. }
  16454. if(context->argumentCount())
  16455. {
  16456. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  16457. arg4));
  16458. }
  16459. else
  16460. {
  16461. object= engine->toScriptValue<QTime> (QTime());
  16462. }
  16463. setQTimeProperties(object,engine);
  16464. }
  16465. else
  16466. {
  16467. context->throwError("Incorrect number of arguments passed to "
  16468. "QTime::QTime(). This method takes zero, two, "
  16469. "three, or four integer arguments.");
  16470. }
  16471. return object;
  16472. }
  16473. /*:149*//*150:*/
  16474. #line 3496 "./typica.w"
  16475. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  16476. {
  16477. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  16478. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  16479. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  16480. value.setProperty("hour",engine->newFunction(QTime_hour));
  16481. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  16482. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  16483. value.setProperty("minute",engine->newFunction(QTime_minute));
  16484. value.setProperty("msec",engine->newFunction(QTime_msec));
  16485. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  16486. value.setProperty("restart",engine->newFunction(QTime_restart));
  16487. value.setProperty("second",engine->newFunction(QTime_second));
  16488. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  16489. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  16490. value.setProperty("start",engine->newFunction(QTime_start));
  16491. value.setProperty("toString",engine->newFunction(QTime_toString));
  16492. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  16493. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  16494. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  16495. }
  16496. /*:150*//*151:*/
  16497. #line 3525 "./typica.w"
  16498. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  16499. {
  16500. QTime self= getself<QTime> (context);
  16501. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  16502. (self.second()*1000)+self.msec();
  16503. return QScriptValue(retval);
  16504. }
  16505. /*:151*//*152:*/
  16506. #line 3539 "./typica.w"
  16507. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  16508. {
  16509. QTime time;
  16510. QScriptValue retval;
  16511. if(context->argumentCount()==1)
  16512. {
  16513. QTime self= getself<QTime> (context);
  16514. time= self.addMSecs(argument<int> (0,context));
  16515. retval= engine->toScriptValue<QTime> (time);
  16516. setQTimeProperties(retval,engine);
  16517. }
  16518. else
  16519. {
  16520. context->throwError("Incorrect number of arguments passed to "
  16521. "QTime::addMSecs(). This method takes one "
  16522. "integer as an argument.");
  16523. }
  16524. return retval;
  16525. }
  16526. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  16527. {
  16528. QTime time;
  16529. QScriptValue retval;
  16530. if(context->argumentCount()==1)
  16531. {
  16532. QTime self= getself<QTime> (context);
  16533. time= self.addSecs(argument<int> (0,context));
  16534. retval= engine->toScriptValue<QTime> (time);
  16535. setQTimeProperties(retval,engine);
  16536. }
  16537. else
  16538. {
  16539. context->throwError("Incorrect number of arguments passed to "
  16540. "QTime::addSecs(). This method takes one "
  16541. "integer as an argument.");
  16542. }
  16543. return retval;
  16544. }
  16545. /*:152*//*153:*/
  16546. #line 3582 "./typica.w"
  16547. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  16548. {
  16549. QScriptValue retval;
  16550. if(context->argumentCount()==0)
  16551. {
  16552. QTime self= getself<QTime> (context);
  16553. retval= QScriptValue(engine,self.elapsed());
  16554. }
  16555. else
  16556. {
  16557. context->throwError("Incorrect number of arguments passed to "
  16558. "QTime::elapsed(). This method takes no "
  16559. "arguments.");
  16560. }
  16561. return retval;
  16562. }
  16563. /*:153*//*154:*/
  16564. #line 3603 "./typica.w"
  16565. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  16566. {
  16567. QScriptValue retval;
  16568. if(context->argumentCount()==0)
  16569. {
  16570. QTime self= getself<QTime> (context);
  16571. retval= QScriptValue(engine,self.hour());
  16572. }
  16573. else
  16574. {
  16575. context->throwError("Incorrect number of arguments passed to "
  16576. "QTime::hour(). This method takes no "
  16577. "arguments.");
  16578. }
  16579. return retval;
  16580. }
  16581. /*:154*//*155:*/
  16582. #line 3623 "./typica.w"
  16583. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  16584. {
  16585. QScriptValue retval;
  16586. if(context->argumentCount()==0)
  16587. {
  16588. QTime self= getself<QTime> (context);
  16589. retval= QScriptValue(engine,self.minute());
  16590. }
  16591. else
  16592. {
  16593. context->throwError("Incorrect number of arguments passed to "
  16594. "QTime::minute(). This method takes no "
  16595. "arguments.");
  16596. }
  16597. return retval;
  16598. }
  16599. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  16600. {
  16601. QScriptValue retval;
  16602. if(context->argumentCount()==0)
  16603. {
  16604. QTime self= getself<QTime> (context);
  16605. retval= QScriptValue(engine,self.second());
  16606. }
  16607. else
  16608. {
  16609. context->throwError("Incorrect number of arguments passed to "
  16610. "QTime::second(). This method takes no "
  16611. "arguments.");
  16612. }
  16613. return retval;
  16614. }
  16615. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  16616. {
  16617. QScriptValue retval;
  16618. if(context->argumentCount()==0)
  16619. {
  16620. QTime self= getself<QTime> (context);
  16621. retval= QScriptValue(engine,self.msec());
  16622. }
  16623. else
  16624. {
  16625. context->throwError("Incorrect number of arguments passed to "
  16626. "QTime::msec(). This method takes no "
  16627. "arguments.");
  16628. }
  16629. return retval;
  16630. }
  16631. /*:155*//*156:*/
  16632. #line 3679 "./typica.w"
  16633. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  16634. {
  16635. QScriptValue retval;
  16636. if(context->argumentCount()==0)
  16637. {
  16638. QTime self= getself<QTime> (context);
  16639. retval= QScriptValue(engine,self.isNull());
  16640. }
  16641. else
  16642. {
  16643. context->throwError("Incorrect number of arguments passed to "
  16644. "QTime::isNull(). This method takes no "
  16645. "arguments.");
  16646. }
  16647. return retval;
  16648. }
  16649. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  16650. {
  16651. QScriptValue retval;
  16652. if(context->argumentCount()==0)
  16653. {
  16654. QTime self= getself<QTime> (context);
  16655. retval= QScriptValue(engine,self.isValid());
  16656. }
  16657. else
  16658. {
  16659. context->throwError("Incorrect number of arguments passed to "
  16660. "QTime::isValid(). This method takes no "
  16661. "arguments.");
  16662. }
  16663. return retval;
  16664. }
  16665. /*:156*//*157:*/
  16666. #line 3717 "./typica.w"
  16667. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  16668. {
  16669. QScriptValue retval;
  16670. if(context->argumentCount()==1)
  16671. {
  16672. QTime self= getself<QTime> (context);
  16673. QTime arg= argument<QVariant> (0,context).toTime();
  16674. retval= QScriptValue(engine,self.msecsTo(arg));
  16675. }
  16676. else
  16677. {
  16678. context->throwError("Incorrect number of arguments passed to "
  16679. "QTime::msecsTo(). This method takes one QTime.");
  16680. }
  16681. return retval;
  16682. }
  16683. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  16684. {
  16685. QScriptValue retval;
  16686. if(context->argumentCount()==1)
  16687. {
  16688. QTime self= getself<QTime> (context);
  16689. QTime arg= argument<QVariant> (0,context).toTime();
  16690. retval= QScriptValue(engine,self.secsTo(arg));
  16691. }
  16692. else
  16693. {
  16694. context->throwError("Incorrect number of arguments passed to "
  16695. "QTime::secsTo(). This method takes one QTime.");
  16696. }
  16697. return retval;
  16698. }
  16699. /*:157*//*158:*/
  16700. #line 3756 "./typica.w"
  16701. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  16702. {
  16703. QScriptValue retval;
  16704. if(context->argumentCount()==0)
  16705. {
  16706. QTime self= getself<QTime> (context);
  16707. retval= QScriptValue(engine,self.restart());
  16708. }
  16709. else
  16710. {
  16711. context->throwError("Incorrect number of arguments passed to "
  16712. "QTime::restart(). This method takes no "
  16713. "arguments.");
  16714. }
  16715. return retval;
  16716. }
  16717. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  16718. {
  16719. if(context->argumentCount()==0)
  16720. {
  16721. QTime self= getself<QTime> (context);
  16722. self.start();
  16723. }
  16724. else
  16725. {
  16726. context->throwError("Incorrect number of arguments passed to "
  16727. "QTime::start(). This method takes no arguments.");
  16728. }
  16729. return QScriptValue();
  16730. }
  16731. /*:158*//*159:*/
  16732. #line 3792 "./typica.w"
  16733. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  16734. {
  16735. QScriptValue retval;
  16736. if(context->argumentCount()==3||context->argumentCount()==4)
  16737. {
  16738. QTime self= getself<QTime> (context);
  16739. int arg1= 0;
  16740. int arg2= 0;
  16741. int arg3= 0;
  16742. int arg4= 0;
  16743. switch(context->argumentCount())
  16744. {
  16745. case 4:
  16746. arg4= argument<int> (3,context);
  16747. case 3:
  16748. arg3= argument<int> (2,context);
  16749. arg2= argument<int> (1,context);
  16750. arg1= argument<int> (0,context);
  16751. default:
  16752. break;
  16753. }
  16754. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  16755. }
  16756. else
  16757. {
  16758. context->throwError("Incorrect number of arguments passed to "
  16759. "QTime::setHMS(). This method takes three or "
  16760. "four integer arguments.");
  16761. }
  16762. return retval;
  16763. }
  16764. /*:159*//*160:*/
  16765. #line 3828 "./typica.w"
  16766. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  16767. {
  16768. QScriptValue retval;
  16769. if(context->argumentCount()==1)
  16770. {
  16771. QTime self= getself<QTime> (context);
  16772. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  16773. }
  16774. else
  16775. {
  16776. context->throwError("Incorrect number of arguments passed to "
  16777. "QTime::toString(). This method takes one QString "
  16778. "as an argument.");
  16779. }
  16780. return retval;
  16781. }
  16782. /*:160*//*161:*/
  16783. #line 3849 "./typica.w"
  16784. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  16785. {
  16786. QScriptValue object;
  16787. object= engine->toScriptValue<QTime> (QTime::currentTime());
  16788. setQTimeProperties(object,engine);
  16789. return object;
  16790. }
  16791. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  16792. {
  16793. QScriptValue object;
  16794. if(context->argumentCount()==2)
  16795. {
  16796. QString time= argument<QString> (0,context);
  16797. QString format= argument<QString> (1,context);
  16798. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  16799. setQTimeProperties(object,engine);
  16800. }
  16801. else
  16802. {
  16803. context->throwError("Incorrect number of arguments passed to "
  16804. "QTime::fromString(). This method takes two "
  16805. "string arguments.");
  16806. }
  16807. return object;
  16808. }
  16809. /*:161*//*162:*/
  16810. #line 3880 "./typica.w"
  16811. template<> QTime argument(int arg,QScriptContext*context)
  16812. {
  16813. return qscriptvalue_cast<QTime> (context->argument(arg));
  16814. }
  16815. /*:162*//*164:*/
  16816. #line 3898 "./typica.w"
  16817. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  16818. {
  16819. setQFrameProperties(value,engine);
  16820. }
  16821. /*:164*//*166:*/
  16822. #line 3912 "./typica.w"
  16823. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  16824. {
  16825. setQAbstractScrollAreaProperties(value,engine);
  16826. }
  16827. /*:166*//*168:*/
  16828. #line 3926 "./typica.w"
  16829. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  16830. {
  16831. setQAbstractScrollAreaProperties(value,engine);
  16832. }
  16833. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  16834. {
  16835. setQAbstractItemViewProperties(value,engine);
  16836. }
  16837. /*:168*//*171:*/
  16838. #line 3959 "./typica.w"
  16839. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  16840. {
  16841. QScriptValue object= engine->newQObject(new QPushButton());
  16842. setQPushButtonProperties(object,engine);
  16843. return object;
  16844. }
  16845. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  16846. {
  16847. setQAbstractButtonProperties(value,engine);
  16848. }
  16849. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  16850. {
  16851. setQWidgetProperties(value,engine);
  16852. }
  16853. /*:171*//*178:*/
  16854. #line 4071 "./typica.w"
  16855. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  16856. {
  16857. SqlQueryConnection*obj= new SqlQueryConnection();
  16858. QScriptValue object=
  16859. engine->toScriptValue<void*> (obj);
  16860. setQSqlQueryProperties(object,engine);
  16861. return object;
  16862. }
  16863. /*:178*//*179:*/
  16864. #line 4084 "./typica.w"
  16865. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  16866. {
  16867. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  16868. value.setProperty("bindFileData",
  16869. engine->newFunction(QSqlQuery_bindFileData));
  16870. value.setProperty("bindDeviceData",
  16871. engine->newFunction(QSqlQuery_bindDeviceData));
  16872. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  16873. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  16874. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  16875. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  16876. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  16877. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  16878. }
  16879. /*:179*//*180:*/
  16880. #line 4102 "./typica.w"
  16881. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  16882. {
  16883. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  16884. QScriptValue retval;
  16885. if(context->argumentCount()==1)
  16886. {
  16887. retval= QScriptValue(engine,
  16888. q->exec(argument<QString> (0,context)));
  16889. }
  16890. else
  16891. {
  16892. retval= QScriptValue(engine,q->exec());
  16893. }
  16894. if(q->lastError().isValid())
  16895. {
  16896. qDebug()<<q->lastQuery();
  16897. qDebug()<<q->lastError().text();
  16898. }
  16899. return retval;
  16900. }
  16901. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  16902. {
  16903. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16904. return QScriptValue(query->lastQuery());
  16905. }
  16906. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  16907. {
  16908. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16909. return QScriptValue(engine,query->next());
  16910. }
  16911. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  16912. {
  16913. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16914. return QScriptValue(engine,
  16915. query->value(argument<int> (0,context)).toString());
  16916. }
  16917. /*:180*//*181:*/
  16918. #line 4146 "./typica.w"
  16919. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  16920. {
  16921. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16922. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  16923. }
  16924. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  16925. {
  16926. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16927. query->bindValue(argument<QString> (0,context),
  16928. argument<QVariant> (1,context));
  16929. return QScriptValue();
  16930. }
  16931. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  16932. QScriptEngine*)
  16933. {
  16934. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16935. QString placeholder= argument<QString> (0,context);
  16936. QString filename= argument<QString> (1,context);
  16937. QFile file(filename);
  16938. QByteArray data;
  16939. if(file.open(QIODevice::ReadOnly))
  16940. {
  16941. data= file.readAll();
  16942. file.close();
  16943. }
  16944. query->bindValue(placeholder,data);
  16945. return QScriptValue();
  16946. }
  16947. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  16948. QScriptEngine*)
  16949. {
  16950. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16951. QString placeholder= argument<QString> (0,context);
  16952. QIODevice*device= argument<QIODevice*> (1,context);
  16953. device->reset();
  16954. QByteArray data;
  16955. data= device->readAll();
  16956. query->bindValue(placeholder,data);
  16957. return QScriptValue();
  16958. }
  16959. /*:181*//*182:*/
  16960. #line 4198 "./typica.w"
  16961. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16962. {
  16963. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  16964. delete query;
  16965. return QScriptValue::UndefinedValue;
  16966. }
  16967. /*:182*//*185:*/
  16968. #line 4245 "./typica.w"
  16969. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  16970. {
  16971. QFileInfo info(argument<QString> (0,context));
  16972. QScriptValue retval(engine,info.baseName());
  16973. return retval;
  16974. }
  16975. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  16976. {
  16977. QFileInfo info(argument<QString> (0,context));
  16978. QDir dir= info.dir();
  16979. QScriptValue retval(engine,dir.path());
  16980. return retval;
  16981. }
  16982. /*:185*//*186:*/
  16983. #line 4264 "./typica.w"
  16984. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  16985. {
  16986. SqlQueryConnection h;
  16987. QSqlQuery*query= h.operator->();
  16988. QString q= "SELECT file FROM files WHERE id = :file";
  16989. query->prepare(q);
  16990. query->bindValue(":file",argument<int> (0,context));
  16991. query->exec();
  16992. query->next();
  16993. QByteArray array= query->value(0).toByteArray();
  16994. QFile file(argument<QString> (1,context));
  16995. file.open(QIODevice::WriteOnly);
  16996. file.write(array);
  16997. file.close();
  16998. return QScriptValue();
  16999. }
  17000. /*:186*//*187:*/
  17001. #line 4285 "./typica.w"
  17002. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  17003. {
  17004. QString source= argument<QString> (0,context);
  17005. source.remove(0,1);
  17006. source.chop(1);
  17007. QStringList elements= source.split(",");
  17008. QString element;
  17009. QScriptValue dest= engine->newArray(elements.size());
  17010. int i= 0;
  17011. foreach(element,elements)
  17012. {
  17013. if(element.startsWith("\"")&&element.endsWith("\""))
  17014. {
  17015. element.chop(1);
  17016. element= element.remove(0,1);
  17017. }
  17018. dest.setProperty(i,QScriptValue(engine,element));
  17019. i++;
  17020. }
  17021. return dest;
  17022. }
  17023. /*:187*//*188:*/
  17024. #line 4311 "./typica.w"
  17025. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  17026. {
  17027. QString font= argument<QString> (0,context);
  17028. QString classname;
  17029. if(context->argumentCount()> 1)
  17030. {
  17031. classname= argument<QString> (1,context);
  17032. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  17033. }
  17034. else
  17035. {
  17036. QApplication::setFont(QFont(font));
  17037. }
  17038. return QScriptValue();
  17039. }
  17040. /*:188*//*189:*/
  17041. #line 4331 "./typica.w"
  17042. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  17043. {
  17044. SqlQueryConnection h;
  17045. QSqlQuery*query= h.operator->();
  17046. QString q= "SELECT file FROM files WHERE id = :file";
  17047. query->prepare(q);
  17048. query->bindValue(":file",argument<int> (0,context));
  17049. query->exec();
  17050. query->next();
  17051. QByteArray array= query->value(0).toByteArray();
  17052. QBuffer buffer(&array);
  17053. buffer.open(QIODevice::ReadOnly);
  17054. QXmlQuery xquery;
  17055. xquery.bindVariable("profile",&buffer);
  17056. QString xq;
  17057. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  17058. xquery.setQuery(xq);
  17059. QString result;
  17060. xquery.evaluateTo(&result);
  17061. return QScriptValue(result);
  17062. }
  17063. /*:189*//*190:*/
  17064. #line 4358 "./typica.w"
  17065. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  17066. {
  17067. QWidget::setTabOrder(argument<QWidget*> (0,context),
  17068. argument<QWidget*> (1,context));
  17069. return QScriptValue();
  17070. }
  17071. /*:190*//*191:*/
  17072. #line 4369 "./typica.w"
  17073. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  17074. {
  17075. return QScriptValue(QCoreApplication::translate(
  17076. "configuration",
  17077. argument<QString> (1,context).toUtf8().data()));
  17078. }
  17079. /*:191*//*198:*/
  17080. #line 4638 "./typica.w"
  17081. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  17082. {
  17083. QString targetID= argument<QString> (0,context);
  17084. QDomNode element;
  17085. QScriptValue object;
  17086. /*200:*/
  17087. #line 4685 "./typica.w"
  17088. QDomNodeList windows=
  17089. AppInstance->configuration()->documentElement().elementsByTagName("window");
  17090. QDomNode nullNode;
  17091. int i= 0;
  17092. element= nullNode;
  17093. while(i<windows.count())
  17094. {
  17095. element= windows.at(i);
  17096. QDomNamedNodeMap attributes= element.attributes();
  17097. if(attributes.contains("id"))
  17098. {
  17099. if(attributes.namedItem("id").toAttr().value()==targetID)
  17100. {
  17101. break;
  17102. }
  17103. }
  17104. element= nullNode;
  17105. i++;
  17106. }
  17107. /*:200*/
  17108. #line 4644 "./typica.w"
  17109. if(!element.isNull())
  17110. {
  17111. /*201:*/
  17112. #line 4717 "./typica.w"
  17113. ScriptQMainWindow*window= new ScriptQMainWindow;
  17114. window->setObjectName(targetID);
  17115. object= engine->newQObject(window);
  17116. setQMainWindowProperties(object,engine);
  17117. QWidget*central= new(QWidget);
  17118. central->setParent(window);
  17119. central->setObjectName("centralWidget");
  17120. window->setCentralWidget(central);
  17121. if(element.hasChildNodes())
  17122. {
  17123. /*202:*/
  17124. #line 4753 "./typica.w"
  17125. QStack<QWidget*> widgetStack;
  17126. QStack<QLayout*> layoutStack;
  17127. QString windowScript;
  17128. widgetStack.push(central);
  17129. QDomNodeList windowChildren= element.childNodes();
  17130. int i= 0;
  17131. while(i<windowChildren.count())
  17132. {
  17133. QDomNode current;
  17134. QDomElement element;
  17135. current= windowChildren.at(i);
  17136. if(current.isElement())
  17137. {
  17138. element= current.toElement();
  17139. if(element.tagName()=="program")
  17140. {
  17141. windowScript.append(element.text());
  17142. }
  17143. else if(element.tagName()=="layout")
  17144. {
  17145. element.setAttribute("trcontext","configuration");
  17146. addLayoutToWidget(element,&widgetStack,&layoutStack);
  17147. }
  17148. else if(element.tagName()=="menu")
  17149. {
  17150. /*203:*/
  17151. #line 4801 "./typica.w"
  17152. QMenuBar*bar= window->menuBar();
  17153. bar->setParent(window);
  17154. bar->setObjectName("menuBar");
  17155. if(element.hasAttribute("name"))
  17156. {
  17157. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  17158. element.attribute("name").toUtf8().data()));
  17159. menu->setParent(bar);
  17160. if(element.hasAttribute("type"))
  17161. {
  17162. if(element.attribute("type")=="reports")
  17163. {
  17164. if(element.hasAttribute("src"))
  17165. {
  17166. /*663:*/
  17167. #line 14111 "./typica.w"
  17168. QSettings settings;
  17169. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  17170. toString()).
  17171. arg(element.attribute("src"));
  17172. QDir::addSearchPath("reports",reportDirectory);
  17173. QDir directory(reportDirectory);
  17174. directory.setFilter(QDir::Files);
  17175. directory.setSorting(QDir::Name);
  17176. QStringList nameFilter;
  17177. nameFilter<<"*.xml";
  17178. directory.setNameFilters(nameFilter);
  17179. QFileInfoList reportFiles= directory.entryInfoList();
  17180. for(int i= 0;i<reportFiles.size();i++)
  17181. {
  17182. QFileInfo reportFile= reportFiles.at(i);
  17183. /*667:*/
  17184. #line 14191 "./typica.w"
  17185. QString path= reportFile.absoluteFilePath();
  17186. QFile file(path);
  17187. if(file.open(QIODevice::ReadOnly))
  17188. {
  17189. QDomDocument document;
  17190. document.setContent(&file,true);
  17191. QDomElement root= document.documentElement();
  17192. QString translationContext= root.attribute("id");
  17193. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  17194. if(!titleNode.isNull())
  17195. {
  17196. QDomElement titleElement= titleNode.toElement();
  17197. QString title= QCoreApplication::translate("configuration",
  17198. titleElement.text().toUtf8().data());
  17199. if(!title.isEmpty())
  17200. {
  17201. QStringList hierarchy= title.split(":->");
  17202. QMenu*insertionPoint= menu;
  17203. /*668:*/
  17204. #line 14220 "./typica.w"
  17205. for(int j= 0;j<hierarchy.size()-1;j++)
  17206. {
  17207. QObjectList menuList= insertionPoint->children();
  17208. bool menuFound= false;
  17209. for(int k= 0;k<menuList.size();k++)
  17210. {
  17211. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  17212. if(currentItem)
  17213. {
  17214. if(currentItem->title()==hierarchy.at(j))
  17215. {
  17216. menuFound= true;
  17217. insertionPoint= currentItem;
  17218. break;
  17219. }
  17220. }
  17221. }
  17222. if(!menuFound)
  17223. {
  17224. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  17225. }
  17226. }
  17227. /*:668*/
  17228. #line 14210 "./typica.w"
  17229. ReportAction*action= new ReportAction(path,hierarchy.last());
  17230. insertionPoint->addAction(action);
  17231. }
  17232. }
  17233. }
  17234. /*:667*/
  17235. #line 14127 "./typica.w"
  17236. }
  17237. /*:663*/
  17238. #line 4816 "./typica.w"
  17239. }
  17240. }
  17241. }
  17242. if(element.hasChildNodes())
  17243. {
  17244. /*204:*/
  17245. #line 4829 "./typica.w"
  17246. QDomNodeList menuItems= element.childNodes();
  17247. int j= 0;
  17248. while(j<menuItems.count())
  17249. {
  17250. QDomNode item= menuItems.at(j);
  17251. if(item.isElement())
  17252. {
  17253. QDomElement itemElement= item.toElement();
  17254. if(itemElement.tagName()=="item")
  17255. {
  17256. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  17257. itemElement.text().toUtf8().data()),menu);
  17258. if(itemElement.hasAttribute("id"))
  17259. {
  17260. itemAction->setObjectName(itemElement.attribute("id"));
  17261. }
  17262. if(itemElement.hasAttribute("shortcut"))
  17263. {
  17264. itemAction->setShortcut(itemElement.attribute("shortcut"));
  17265. }
  17266. menu->addAction(itemAction);
  17267. }
  17268. else if(itemElement.tagName()=="separator")
  17269. {
  17270. menu->addSeparator();
  17271. }
  17272. else if(itemElement.tagName()=="plugins")
  17273. {
  17274. /*688:*/
  17275. #line 21 "./plugins.w"
  17276. QMenu*pluginMenu= new QMenu(menu);
  17277. if(itemElement.hasAttribute("id"))
  17278. {
  17279. pluginMenu->setObjectName(itemElement.attribute("id"));
  17280. }
  17281. if(itemElement.hasAttribute("title"))
  17282. {
  17283. pluginMenu->setTitle(itemElement.attribute("title"));
  17284. }
  17285. if(itemElement.hasAttribute("src"))
  17286. {
  17287. QSettings settings;
  17288. QString pluginDirectory= QString("%1/%2").
  17289. arg(settings.value("config").toString()).
  17290. arg(itemElement.attribute("src"));
  17291. QDir directory(pluginDirectory);
  17292. directory.setFilter(QDir::Files);
  17293. directory.setSorting(QDir::Name);
  17294. QStringList nameFilter;
  17295. nameFilter<<"*.js";
  17296. directory.setNameFilters(nameFilter);
  17297. QFileInfoList pluginFiles= directory.entryInfoList();
  17298. for(int k= 0;k<pluginFiles.size();k++)
  17299. {
  17300. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  17301. if(itemElement.hasAttribute("preRun"))
  17302. {
  17303. pa->setPreRun(itemElement.attribute("preRun"));
  17304. }
  17305. if(itemElement.hasAttribute("postRun"))
  17306. {
  17307. pa->setPostRun(itemElement.attribute("postRun"));
  17308. }
  17309. pluginMenu->addAction(pa);
  17310. }
  17311. }
  17312. menu->addMenu(pluginMenu);
  17313. /*:688*/
  17314. #line 4858 "./typica.w"
  17315. }
  17316. }
  17317. j++;
  17318. }
  17319. #line 1 "./helpmenu.w"
  17320. /*:204*/
  17321. #line 4822 "./typica.w"
  17322. }
  17323. }
  17324. /*:203*/
  17325. #line 4779 "./typica.w"
  17326. }
  17327. }
  17328. i++;
  17329. }
  17330. QScriptValue oldThis= context->thisObject();
  17331. context->setThisObject(object);
  17332. QScriptValue result= engine->evaluate(windowScript);
  17333. /*195:*/
  17334. #line 4532 "./typica.w"
  17335. if(engine->hasUncaughtException())
  17336. {
  17337. int line= engine->uncaughtExceptionLineNumber();
  17338. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  17339. result.toString();
  17340. QString trace;
  17341. foreach(trace,engine->uncaughtExceptionBacktrace())
  17342. {
  17343. qDebug()<<trace;
  17344. }
  17345. }
  17346. /*:195*/
  17347. #line 4787 "./typica.w"
  17348. context->setThisObject(oldThis);
  17349. /*:202*/
  17350. #line 4728 "./typica.w"
  17351. }
  17352. /*205:*/
  17353. #line 9 "./helpmenu.w"
  17354. HelpMenu*helpMenu= new HelpMenu();
  17355. window->menuBar()->addMenu(helpMenu);
  17356. /*:205*/
  17357. #line 4730 "./typica.w"
  17358. window->show();
  17359. window->setupFinished();
  17360. /*:201*/
  17361. #line 4647 "./typica.w"
  17362. }
  17363. return object;
  17364. }
  17365. /*:198*//*199:*/
  17366. #line 4658 "./typica.w"
  17367. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  17368. {
  17369. QString targetID= argument<QString> (0,context);
  17370. QFile file(QString("reports:%1").arg(targetID));
  17371. QScriptValue object;
  17372. if(file.open(QIODevice::ReadOnly))
  17373. {
  17374. QDomDocument document;
  17375. document.setContent(&file,true);
  17376. QDomElement element= document.documentElement();
  17377. if(!element.isNull())
  17378. {
  17379. /*201:*/
  17380. #line 4717 "./typica.w"
  17381. ScriptQMainWindow*window= new ScriptQMainWindow;
  17382. window->setObjectName(targetID);
  17383. object= engine->newQObject(window);
  17384. setQMainWindowProperties(object,engine);
  17385. QWidget*central= new(QWidget);
  17386. central->setParent(window);
  17387. central->setObjectName("centralWidget");
  17388. window->setCentralWidget(central);
  17389. if(element.hasChildNodes())
  17390. {
  17391. /*202:*/
  17392. #line 4753 "./typica.w"
  17393. QStack<QWidget*> widgetStack;
  17394. QStack<QLayout*> layoutStack;
  17395. QString windowScript;
  17396. widgetStack.push(central);
  17397. QDomNodeList windowChildren= element.childNodes();
  17398. int i= 0;
  17399. while(i<windowChildren.count())
  17400. {
  17401. QDomNode current;
  17402. QDomElement element;
  17403. current= windowChildren.at(i);
  17404. if(current.isElement())
  17405. {
  17406. element= current.toElement();
  17407. if(element.tagName()=="program")
  17408. {
  17409. windowScript.append(element.text());
  17410. }
  17411. else if(element.tagName()=="layout")
  17412. {
  17413. element.setAttribute("trcontext","configuration");
  17414. addLayoutToWidget(element,&widgetStack,&layoutStack);
  17415. }
  17416. else if(element.tagName()=="menu")
  17417. {
  17418. /*203:*/
  17419. #line 4801 "./typica.w"
  17420. QMenuBar*bar= window->menuBar();
  17421. bar->setParent(window);
  17422. bar->setObjectName("menuBar");
  17423. if(element.hasAttribute("name"))
  17424. {
  17425. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  17426. element.attribute("name").toUtf8().data()));
  17427. menu->setParent(bar);
  17428. if(element.hasAttribute("type"))
  17429. {
  17430. if(element.attribute("type")=="reports")
  17431. {
  17432. if(element.hasAttribute("src"))
  17433. {
  17434. /*663:*/
  17435. #line 14111 "./typica.w"
  17436. QSettings settings;
  17437. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  17438. toString()).
  17439. arg(element.attribute("src"));
  17440. QDir::addSearchPath("reports",reportDirectory);
  17441. QDir directory(reportDirectory);
  17442. directory.setFilter(QDir::Files);
  17443. directory.setSorting(QDir::Name);
  17444. QStringList nameFilter;
  17445. nameFilter<<"*.xml";
  17446. directory.setNameFilters(nameFilter);
  17447. QFileInfoList reportFiles= directory.entryInfoList();
  17448. for(int i= 0;i<reportFiles.size();i++)
  17449. {
  17450. QFileInfo reportFile= reportFiles.at(i);
  17451. /*667:*/
  17452. #line 14191 "./typica.w"
  17453. QString path= reportFile.absoluteFilePath();
  17454. QFile file(path);
  17455. if(file.open(QIODevice::ReadOnly))
  17456. {
  17457. QDomDocument document;
  17458. document.setContent(&file,true);
  17459. QDomElement root= document.documentElement();
  17460. QString translationContext= root.attribute("id");
  17461. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  17462. if(!titleNode.isNull())
  17463. {
  17464. QDomElement titleElement= titleNode.toElement();
  17465. QString title= QCoreApplication::translate("configuration",
  17466. titleElement.text().toUtf8().data());
  17467. if(!title.isEmpty())
  17468. {
  17469. QStringList hierarchy= title.split(":->");
  17470. QMenu*insertionPoint= menu;
  17471. /*668:*/
  17472. #line 14220 "./typica.w"
  17473. for(int j= 0;j<hierarchy.size()-1;j++)
  17474. {
  17475. QObjectList menuList= insertionPoint->children();
  17476. bool menuFound= false;
  17477. for(int k= 0;k<menuList.size();k++)
  17478. {
  17479. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  17480. if(currentItem)
  17481. {
  17482. if(currentItem->title()==hierarchy.at(j))
  17483. {
  17484. menuFound= true;
  17485. insertionPoint= currentItem;
  17486. break;
  17487. }
  17488. }
  17489. }
  17490. if(!menuFound)
  17491. {
  17492. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  17493. }
  17494. }
  17495. /*:668*/
  17496. #line 14210 "./typica.w"
  17497. ReportAction*action= new ReportAction(path,hierarchy.last());
  17498. insertionPoint->addAction(action);
  17499. }
  17500. }
  17501. }
  17502. /*:667*/
  17503. #line 14127 "./typica.w"
  17504. }
  17505. /*:663*/
  17506. #line 4816 "./typica.w"
  17507. }
  17508. }
  17509. }
  17510. if(element.hasChildNodes())
  17511. {
  17512. /*204:*/
  17513. #line 4829 "./typica.w"
  17514. QDomNodeList menuItems= element.childNodes();
  17515. int j= 0;
  17516. while(j<menuItems.count())
  17517. {
  17518. QDomNode item= menuItems.at(j);
  17519. if(item.isElement())
  17520. {
  17521. QDomElement itemElement= item.toElement();
  17522. if(itemElement.tagName()=="item")
  17523. {
  17524. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  17525. itemElement.text().toUtf8().data()),menu);
  17526. if(itemElement.hasAttribute("id"))
  17527. {
  17528. itemAction->setObjectName(itemElement.attribute("id"));
  17529. }
  17530. if(itemElement.hasAttribute("shortcut"))
  17531. {
  17532. itemAction->setShortcut(itemElement.attribute("shortcut"));
  17533. }
  17534. menu->addAction(itemAction);
  17535. }
  17536. else if(itemElement.tagName()=="separator")
  17537. {
  17538. menu->addSeparator();
  17539. }
  17540. else if(itemElement.tagName()=="plugins")
  17541. {
  17542. /*688:*/
  17543. #line 21 "./plugins.w"
  17544. QMenu*pluginMenu= new QMenu(menu);
  17545. if(itemElement.hasAttribute("id"))
  17546. {
  17547. pluginMenu->setObjectName(itemElement.attribute("id"));
  17548. }
  17549. if(itemElement.hasAttribute("title"))
  17550. {
  17551. pluginMenu->setTitle(itemElement.attribute("title"));
  17552. }
  17553. if(itemElement.hasAttribute("src"))
  17554. {
  17555. QSettings settings;
  17556. QString pluginDirectory= QString("%1/%2").
  17557. arg(settings.value("config").toString()).
  17558. arg(itemElement.attribute("src"));
  17559. QDir directory(pluginDirectory);
  17560. directory.setFilter(QDir::Files);
  17561. directory.setSorting(QDir::Name);
  17562. QStringList nameFilter;
  17563. nameFilter<<"*.js";
  17564. directory.setNameFilters(nameFilter);
  17565. QFileInfoList pluginFiles= directory.entryInfoList();
  17566. for(int k= 0;k<pluginFiles.size();k++)
  17567. {
  17568. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  17569. if(itemElement.hasAttribute("preRun"))
  17570. {
  17571. pa->setPreRun(itemElement.attribute("preRun"));
  17572. }
  17573. if(itemElement.hasAttribute("postRun"))
  17574. {
  17575. pa->setPostRun(itemElement.attribute("postRun"));
  17576. }
  17577. pluginMenu->addAction(pa);
  17578. }
  17579. }
  17580. menu->addMenu(pluginMenu);
  17581. /*:688*/
  17582. #line 4858 "./typica.w"
  17583. }
  17584. }
  17585. j++;
  17586. }
  17587. #line 1 "./helpmenu.w"
  17588. /*:204*/
  17589. #line 4822 "./typica.w"
  17590. }
  17591. }
  17592. /*:203*/
  17593. #line 4779 "./typica.w"
  17594. }
  17595. }
  17596. i++;
  17597. }
  17598. QScriptValue oldThis= context->thisObject();
  17599. context->setThisObject(object);
  17600. QScriptValue result= engine->evaluate(windowScript);
  17601. /*195:*/
  17602. #line 4532 "./typica.w"
  17603. if(engine->hasUncaughtException())
  17604. {
  17605. int line= engine->uncaughtExceptionLineNumber();
  17606. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  17607. result.toString();
  17608. QString trace;
  17609. foreach(trace,engine->uncaughtExceptionBacktrace())
  17610. {
  17611. qDebug()<<trace;
  17612. }
  17613. }
  17614. /*:195*/
  17615. #line 4787 "./typica.w"
  17616. context->setThisObject(oldThis);
  17617. /*:202*/
  17618. #line 4728 "./typica.w"
  17619. }
  17620. /*205:*/
  17621. #line 9 "./helpmenu.w"
  17622. HelpMenu*helpMenu= new HelpMenu();
  17623. window->menuBar()->addMenu(helpMenu);
  17624. /*:205*/
  17625. #line 4730 "./typica.w"
  17626. window->show();
  17627. window->setupFinished();
  17628. /*:201*/
  17629. #line 4671 "./typica.w"
  17630. }
  17631. file.close();
  17632. }
  17633. return object;
  17634. }
  17635. /*:199*//*217:*/
  17636. #line 4878 "./typica.w"
  17637. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17638. QStack<QLayout*> *layoutStack)
  17639. {
  17640. if(element.hasAttribute("type"))
  17641. {
  17642. /*218:*/
  17643. #line 4899 "./typica.w"
  17644. QLayout*layout;
  17645. QString layoutType= element.attribute("type");
  17646. if(layoutType=="horizontal")
  17647. {
  17648. layout= new QHBoxLayout;
  17649. layoutStack->push(layout);
  17650. populateBoxLayout(element,widgetStack,layoutStack);
  17651. }
  17652. else if(layoutType=="vertical")
  17653. {
  17654. layout= new QVBoxLayout;
  17655. layoutStack->push(layout);
  17656. populateBoxLayout(element,widgetStack,layoutStack);
  17657. }
  17658. else if(layoutType=="grid")
  17659. {
  17660. layout= new QGridLayout;
  17661. layoutStack->push(layout);
  17662. populateGridLayout(element,widgetStack,layoutStack);
  17663. }
  17664. else if(layoutType=="stack")
  17665. {
  17666. layout= new QStackedLayout;
  17667. layoutStack->push(layout);
  17668. populateStackedLayout(element,widgetStack,layoutStack);
  17669. }
  17670. if(element.hasAttribute("id"))
  17671. {
  17672. layout->setObjectName(element.attribute("id"));
  17673. }
  17674. if(element.hasAttribute("spacing"))
  17675. {
  17676. layout->setSpacing(element.attribute("spacing").toInt());
  17677. }
  17678. if(element.hasAttribute("margin"))
  17679. {
  17680. int m= element.attribute("margin").toInt();
  17681. layout->setContentsMargins(m,m,m,m);
  17682. }
  17683. /*:218*/
  17684. #line 4884 "./typica.w"
  17685. QWidget*widget= widgetStack->top();
  17686. if(layout)
  17687. {
  17688. widget->setLayout(layout);
  17689. }
  17690. layoutStack->pop();
  17691. }
  17692. }
  17693. /*:217*//*219:*/
  17694. #line 4946 "./typica.w"
  17695. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17696. QStack<QLayout*> *layoutStack)
  17697. {
  17698. QDomNodeList children= element.childNodes();
  17699. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  17700. for(int i= 0;i<children.count();i++)
  17701. {
  17702. QDomNode current;
  17703. QDomElement currentElement;
  17704. current= children.at(i);
  17705. if(current.isElement())
  17706. {
  17707. currentElement= current.toElement();
  17708. if(currentElement.tagName()=="page")
  17709. {
  17710. QWidget*widget= new QWidget;
  17711. layout->addWidget(widget);
  17712. widgetStack->push(widget);
  17713. currentElement.setAttribute("trcontext","configuration");
  17714. populateWidget(currentElement,widgetStack,layoutStack);
  17715. widgetStack->pop();
  17716. }
  17717. }
  17718. }
  17719. }
  17720. /*:219*//*221:*/
  17721. #line 4985 "./typica.w"
  17722. void addTabBarToLayout(QDomElement element,QStack<QWidget*> *,QStack<QLayout*> *layoutStack)
  17723. {
  17724. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17725. QTabBar*widget= new QTabBar;
  17726. layout->addWidget(widget);
  17727. if(!element.attribute("id").isEmpty())
  17728. {
  17729. widget->setObjectName(element.attribute("id"));
  17730. }
  17731. }
  17732. /*:221*//*223:*/
  17733. #line 5007 "./typica.w"
  17734. QScriptValue constructQTabBar(QScriptContext*,QScriptEngine*engine)
  17735. {
  17736. QScriptValue object= engine->newQObject(new QTabBar);
  17737. setQTabBarProperties(object,engine);
  17738. return object;
  17739. }
  17740. /*:223*//*224:*/
  17741. #line 5018 "./typica.w"
  17742. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine)
  17743. {
  17744. setQWidgetProperties(value,engine);
  17745. value.setProperty("addTab",engine->newFunction(QTabBar_addTab));
  17746. }
  17747. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*)
  17748. {
  17749. QTabBar*self= getself<QTabBar*> (context);
  17750. if(context->argumentCount()> 0)
  17751. {
  17752. self->addTab(argument<QString> (0,context));
  17753. }
  17754. else
  17755. {
  17756. context->throwError("Incorrect number of arguments passed to "
  17757. "QTabBar::addTab().");
  17758. }
  17759. return QScriptValue();
  17760. }
  17761. /*:224*//*226:*/
  17762. #line 5053 "./typica.w"
  17763. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17764. QStack<QLayout*> *layoutStack)
  17765. {
  17766. QDomNodeList children= element.childNodes();
  17767. int row= -1;
  17768. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  17769. for(int i= 0;i<children.count();i++)
  17770. {
  17771. QDomNode current;
  17772. QDomElement currentElement;
  17773. current= children.at(i);
  17774. if(current.isElement())
  17775. {
  17776. currentElement= current.toElement();
  17777. if(currentElement.tagName()=="row")
  17778. {
  17779. row++;
  17780. if(currentElement.hasAttribute("height"))
  17781. {
  17782. layout->setRowMinimumHeight(row,
  17783. currentElement.attribute("height").toInt());
  17784. }
  17785. if(currentElement.hasAttribute("stretch"))
  17786. {
  17787. layout->setRowStretch(row,
  17788. currentElement.attribute("stretch").toInt());
  17789. }
  17790. /*227:*/
  17791. #line 5109 "./typica.w"
  17792. int column= -1;
  17793. QDomNodeList rowChildren= currentElement.childNodes();
  17794. for(int j= 0;j<rowChildren.count();j++)
  17795. {
  17796. QDomNode columnNode;
  17797. QDomElement columnElement;
  17798. columnNode= rowChildren.at(j);
  17799. if(columnNode.isElement())
  17800. {
  17801. columnElement= columnNode.toElement();
  17802. if(columnElement.tagName()=="column")
  17803. {
  17804. column++;
  17805. if(columnElement.hasAttribute("column"))
  17806. {
  17807. column= columnElement.attribute("column").toInt();
  17808. }
  17809. if(columnElement.hasAttribute("width"))
  17810. {
  17811. layout->setColumnMinimumWidth(column,
  17812. columnElement.attribute("width").toInt());
  17813. }
  17814. if(columnElement.hasAttribute("stretch"))
  17815. {
  17816. layout->setColumnStretch(column,
  17817. columnElement.attribute("stretch").toInt());
  17818. }
  17819. int hspan= 1;
  17820. int vspan= 1;
  17821. if(columnElement.hasAttribute("rowspan"))
  17822. {
  17823. vspan= columnElement.attribute("rowspan").toInt();
  17824. }
  17825. if(columnElement.hasAttribute("colspan"))
  17826. {
  17827. hspan= columnElement.attribute("colspan").toInt();
  17828. }
  17829. QHBoxLayout*cell= new QHBoxLayout;
  17830. layout->addLayout(cell,row,column,vspan,hspan);
  17831. layoutStack->push(cell);
  17832. columnElement.setAttribute("trcontext","configuration");
  17833. populateBoxLayout(columnElement,widgetStack,layoutStack);
  17834. layoutStack->pop();
  17835. }
  17836. }
  17837. }
  17838. /*:227*/
  17839. #line 5081 "./typica.w"
  17840. }
  17841. }
  17842. }
  17843. }
  17844. /*:226*//*228:*/
  17845. #line 5160 "./typica.w"
  17846. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17847. QStack<QLayout*> *layoutStack)
  17848. {
  17849. QDomNodeList children= element.childNodes();
  17850. for(int i= 0;i<children.count();i++)
  17851. {
  17852. QDomNode current;
  17853. QDomElement currentElement;
  17854. current= children.at(i);
  17855. if(current.isElement())
  17856. {
  17857. currentElement= current.toElement();
  17858. currentElement.setAttribute("trcontext","configuration");
  17859. if(currentElement.tagName()=="button")
  17860. {
  17861. addButtonToLayout(currentElement,widgetStack,layoutStack);
  17862. }
  17863. else if(currentElement.tagName()=="calendar")
  17864. {
  17865. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  17866. }
  17867. else if(currentElement.tagName()=="timeedit")
  17868. {
  17869. addTimeEditToLayout(currentElement,widgetStack,layoutStack);
  17870. }
  17871. else if(currentElement.tagName()=="decoration")
  17872. {
  17873. addDecorationToLayout(currentElement,widgetStack,
  17874. layoutStack);
  17875. }
  17876. else if(currentElement.tagName()=="layout")
  17877. {
  17878. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  17879. }
  17880. else if(currentElement.tagName()=="splitter")
  17881. {
  17882. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  17883. }
  17884. else if(currentElement.tagName()=="label")
  17885. {
  17886. QBoxLayout*layout=
  17887. qobject_cast<QBoxLayout*> (layoutStack->top());
  17888. QLabel*label= new QLabel(QCoreApplication::translate(
  17889. "configuration",
  17890. currentElement.text().toUtf8().data()));
  17891. layout->addWidget(label);
  17892. }
  17893. else if(currentElement.tagName()=="lcdtemperature")
  17894. {
  17895. addTemperatureDisplayToLayout(currentElement,widgetStack,
  17896. layoutStack);
  17897. }
  17898. else if(currentElement.tagName()=="lcdtimer")
  17899. {
  17900. addTimerDisplayToLayout(currentElement,widgetStack,
  17901. layoutStack);
  17902. }
  17903. else if(currentElement.tagName()=="line")
  17904. {
  17905. addLineToLayout(currentElement,widgetStack,layoutStack);
  17906. }
  17907. else if(currentElement.tagName()=="report")
  17908. {
  17909. addReportToLayout(currentElement,widgetStack,layoutStack);
  17910. }
  17911. else if(currentElement.tagName()=="sqldrop")
  17912. {
  17913. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  17914. }
  17915. else if(currentElement.tagName()=="sqltablearray")
  17916. {
  17917. addSaltToLayout(currentElement,widgetStack,layoutStack);
  17918. }
  17919. else if(currentElement.tagName()=="sqlview")
  17920. {
  17921. addSqlQueryViewToLayout(currentElement,widgetStack,
  17922. layoutStack);
  17923. }
  17924. else if(currentElement.tagName()=="textarea")
  17925. {
  17926. addTextToLayout(currentElement,widgetStack,layoutStack);
  17927. }
  17928. else if(currentElement.tagName()=="spinbox")
  17929. {
  17930. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  17931. }
  17932. else if(currentElement.tagName()=="formarray")
  17933. {
  17934. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  17935. }
  17936. else if(currentElement.tagName()=="hscale")
  17937. {
  17938. addScaleControlToLayout(currentElement,widgetStack,
  17939. layoutStack);
  17940. }
  17941. else if(currentElement.tagName()=="vscale")
  17942. {
  17943. addIntensityControlToLayout(currentElement,widgetStack,
  17944. layoutStack);
  17945. }
  17946. else if(currentElement.tagName()=="webview")
  17947. {
  17948. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  17949. }
  17950. else if(currentElement.tagName()=="stretch")
  17951. {
  17952. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17953. layout->addStretch();
  17954. }
  17955. /*54:*/
  17956. #line 1550 "./typica.w"
  17957. else if(currentElement.tagName()=="svgwidget")
  17958. {
  17959. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  17960. }
  17961. /*:54*//*220:*/
  17962. #line 4977 "./typica.w"
  17963. else if(currentElement.tagName()=="tabbar")
  17964. {
  17965. addTabBarToLayout(currentElement,widgetStack,layoutStack);
  17966. }
  17967. /*:220*//*596:*/
  17968. #line 111 "./printerselector.w"
  17969. else if(currentElement.tagName()=="printerselector")
  17970. {
  17971. addPrinterSelectorToLayout(currentElement,widgetStack,layoutStack);
  17972. }
  17973. #line 12811 "./typica.w"
  17974. /*:596*//*711:*/
  17975. #line 453 "./daterangeselector.w"
  17976. else if(currentElement.tagName()=="daterange")
  17977. {
  17978. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  17979. }
  17980. /*:711*/
  17981. #line 5270 "./typica.w"
  17982. }
  17983. }
  17984. }
  17985. /*:228*//*229:*/
  17986. #line 5278 "./typica.w"
  17987. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17988. QStack<QLayout*> *layoutStack)
  17989. {
  17990. QLayout*targetLayout= layoutStack->pop();
  17991. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  17992. if(element.hasAttribute("type"))
  17993. {
  17994. /*218:*/
  17995. #line 4899 "./typica.w"
  17996. QLayout*layout;
  17997. QString layoutType= element.attribute("type");
  17998. if(layoutType=="horizontal")
  17999. {
  18000. layout= new QHBoxLayout;
  18001. layoutStack->push(layout);
  18002. populateBoxLayout(element,widgetStack,layoutStack);
  18003. }
  18004. else if(layoutType=="vertical")
  18005. {
  18006. layout= new QVBoxLayout;
  18007. layoutStack->push(layout);
  18008. populateBoxLayout(element,widgetStack,layoutStack);
  18009. }
  18010. else if(layoutType=="grid")
  18011. {
  18012. layout= new QGridLayout;
  18013. layoutStack->push(layout);
  18014. populateGridLayout(element,widgetStack,layoutStack);
  18015. }
  18016. else if(layoutType=="stack")
  18017. {
  18018. layout= new QStackedLayout;
  18019. layoutStack->push(layout);
  18020. populateStackedLayout(element,widgetStack,layoutStack);
  18021. }
  18022. if(element.hasAttribute("id"))
  18023. {
  18024. layout->setObjectName(element.attribute("id"));
  18025. }
  18026. if(element.hasAttribute("spacing"))
  18027. {
  18028. layout->setSpacing(element.attribute("spacing").toInt());
  18029. }
  18030. if(element.hasAttribute("margin"))
  18031. {
  18032. int m= element.attribute("margin").toInt();
  18033. layout->setContentsMargins(m,m,m,m);
  18034. }
  18035. /*:218*/
  18036. #line 5286 "./typica.w"
  18037. boxLayout->addLayout(layout);
  18038. layoutStack->pop();
  18039. }
  18040. layoutStack->push(targetLayout);
  18041. }
  18042. /*:229*//*230:*/
  18043. #line 5297 "./typica.w"
  18044. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18045. QStack<QLayout*> *layoutStack)
  18046. {
  18047. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18048. QSplitter*splitter= new(QSplitter);
  18049. layout->addWidget(splitter);
  18050. /*231:*/
  18051. #line 5310 "./typica.w"
  18052. QString orientation= element.attribute("type");
  18053. if(orientation=="horizontal")
  18054. {
  18055. splitter->setOrientation(Qt::Horizontal);
  18056. }
  18057. else if(orientation=="vertical")
  18058. {
  18059. splitter->setOrientation(Qt::Vertical);
  18060. }
  18061. QString id= element.attribute("id");
  18062. if(!id.isEmpty())
  18063. {
  18064. splitter->setObjectName(id);
  18065. }
  18066. if(element.hasChildNodes())
  18067. {
  18068. widgetStack->push(splitter);
  18069. populateSplitter(element,widgetStack,layoutStack);
  18070. widgetStack->pop();
  18071. }
  18072. /*:231*/
  18073. #line 5304 "./typica.w"
  18074. }
  18075. /*:230*//*232:*/
  18076. #line 5336 "./typica.w"
  18077. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18078. QStack<QLayout*> *layoutStack)
  18079. {
  18080. QDomNodeList children= element.childNodes();
  18081. for(int i= 0;i<children.count();i++)
  18082. {
  18083. QDomNode current;
  18084. QDomElement currentElement;
  18085. current= children.at(i);
  18086. if(current.isElement())
  18087. {
  18088. currentElement= current.toElement();
  18089. currentElement.setAttribute("trcontext","configuration");
  18090. if(currentElement.tagName()=="decoration")
  18091. {
  18092. addDecorationToSplitter(currentElement,widgetStack,
  18093. layoutStack);
  18094. }
  18095. else if(currentElement.tagName()=="graph")
  18096. {
  18097. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  18098. }
  18099. else if(currentElement.tagName()=="splitter")
  18100. {
  18101. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  18102. }
  18103. else if(currentElement.tagName()=="lcdtemperature")
  18104. {
  18105. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  18106. layoutStack);
  18107. }
  18108. else if(currentElement.tagName()=="lcdtimer")
  18109. {
  18110. addTimerDisplayToSplitter(currentElement,widgetStack,
  18111. layoutStack);
  18112. }
  18113. else if(currentElement.tagName()=="measurementtable")
  18114. {
  18115. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  18116. }
  18117. else if(currentElement.tagName()=="widget")
  18118. {
  18119. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  18120. }
  18121. }
  18122. }
  18123. }
  18124. /*:232*//*233:*/
  18125. #line 5387 "./typica.w"
  18126. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18127. QStack<QLayout*> *layoutStack)
  18128. {
  18129. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  18130. QSplitter*splitter= new(QSplitter);
  18131. splitter->setParent(parent);
  18132. parent->addWidget(splitter);
  18133. /*231:*/
  18134. #line 5310 "./typica.w"
  18135. QString orientation= element.attribute("type");
  18136. if(orientation=="horizontal")
  18137. {
  18138. splitter->setOrientation(Qt::Horizontal);
  18139. }
  18140. else if(orientation=="vertical")
  18141. {
  18142. splitter->setOrientation(Qt::Vertical);
  18143. }
  18144. QString id= element.attribute("id");
  18145. if(!id.isEmpty())
  18146. {
  18147. splitter->setObjectName(id);
  18148. }
  18149. if(element.hasChildNodes())
  18150. {
  18151. widgetStack->push(splitter);
  18152. populateSplitter(element,widgetStack,layoutStack);
  18153. widgetStack->pop();
  18154. }
  18155. /*:231*/
  18156. #line 5395 "./typica.w"
  18157. }
  18158. /*:233*//*234:*/
  18159. #line 5404 "./typica.w"
  18160. void addTemperatureDisplayToSplitter(QDomElement element,
  18161. QStack<QWidget*> *widgetStack,
  18162. QStack<QLayout*> *)
  18163. {
  18164. TemperatureDisplay*display= new(TemperatureDisplay);
  18165. if(element.hasAttribute("id"))
  18166. {
  18167. display->setObjectName(element.attribute("id"));
  18168. }
  18169. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18170. splitter->addWidget(display);
  18171. }
  18172. void addTemperatureDisplayToLayout(QDomElement element,
  18173. QStack<QWidget*> *,
  18174. QStack<QLayout*> *layoutStack)
  18175. {
  18176. TemperatureDisplay*display= new(TemperatureDisplay);
  18177. if(element.hasAttribute("id"))
  18178. {
  18179. display->setObjectName(element.attribute("id"));
  18180. }
  18181. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18182. layout->addWidget(display);
  18183. }
  18184. /*:234*//*235:*/
  18185. #line 5435 "./typica.w"
  18186. void addTimerDisplayToSplitter(QDomElement element,
  18187. QStack<QWidget*> *widgetStack,
  18188. QStack<QLayout*> *)
  18189. {
  18190. TimerDisplay*display= new(TimerDisplay);
  18191. if(element.hasAttribute("id"))
  18192. {
  18193. display->setObjectName(element.attribute("id"));
  18194. }
  18195. if(element.hasAttribute("format"))
  18196. {
  18197. display->setDisplayFormat(element.attribute("format"));
  18198. }
  18199. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18200. splitter->addWidget(display);
  18201. }
  18202. void addTimerDisplayToLayout(QDomElement element,
  18203. QStack<QWidget*> *,
  18204. QStack<QLayout*> *layoutStack)
  18205. {
  18206. TimerDisplay*display= new(TimerDisplay);
  18207. if(element.hasAttribute("id"))
  18208. {
  18209. display->setObjectName(element.attribute("id"));
  18210. }
  18211. if(element.hasAttribute("format"))
  18212. {
  18213. display->setDisplayFormat(element.attribute("format"));
  18214. }
  18215. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18216. layout->addWidget(display);
  18217. }
  18218. /*:235*//*236:*/
  18219. #line 5473 "./typica.w"
  18220. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  18221. QStack<QLayout*> *layoutStack)
  18222. {
  18223. /*237:*/
  18224. #line 5494 "./typica.w"
  18225. QString labelText=
  18226. QCoreApplication::translate("configuration",
  18227. element.attribute("name").toUtf8().data());
  18228. Qt::Orientations orientation= Qt::Horizontal;
  18229. if(element.hasAttribute("type"))
  18230. {
  18231. if(element.attribute("type")=="horizontal")
  18232. {
  18233. orientation= Qt::Horizontal;
  18234. }
  18235. else if(element.attribute("type")=="vertical")
  18236. {
  18237. orientation= Qt::Vertical;
  18238. }
  18239. }
  18240. /*238:*/
  18241. #line 5521 "./typica.w"
  18242. QWidget*theWidget= NULL;
  18243. QDomNodeList children= element.childNodes();
  18244. for(int i= 0;i<children.count();i++)
  18245. {
  18246. QDomNode item= children.at(i);
  18247. if(item.isElement())
  18248. {
  18249. QDomElement itemElement= item.toElement();
  18250. if(itemElement.tagName()=="lcdtemperature")
  18251. {
  18252. TemperatureDisplay*display= new TemperatureDisplay;
  18253. if(itemElement.hasAttribute("id"))
  18254. {
  18255. display->setObjectName(itemElement.attribute("id"));
  18256. }
  18257. theWidget= display;
  18258. }
  18259. else if(itemElement.tagName()=="lcdtimer")
  18260. {
  18261. TimerDisplay*display= new TimerDisplay;
  18262. if(itemElement.hasAttribute("id"))
  18263. {
  18264. display->setObjectName(itemElement.attribute("id"));
  18265. }
  18266. if(itemElement.hasAttribute("format"))
  18267. {
  18268. display->setDisplayFormat(itemElement.attribute("format"));
  18269. }
  18270. theWidget= display;
  18271. }
  18272. }
  18273. }
  18274. /*:238*/
  18275. #line 5510 "./typica.w"
  18276. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  18277. orientation);
  18278. if(element.hasAttribute("id"))
  18279. {
  18280. decoration->setObjectName(element.attribute("id"));
  18281. }
  18282. /*:237*/
  18283. #line 5477 "./typica.w"
  18284. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18285. layout->addWidget(decoration);
  18286. }
  18287. void addDecorationToSplitter(QDomElement element,
  18288. QStack<QWidget*> *widgetStack,
  18289. QStack<QLayout*> *)
  18290. {
  18291. /*237:*/
  18292. #line 5494 "./typica.w"
  18293. QString labelText=
  18294. QCoreApplication::translate("configuration",
  18295. element.attribute("name").toUtf8().data());
  18296. Qt::Orientations orientation= Qt::Horizontal;
  18297. if(element.hasAttribute("type"))
  18298. {
  18299. if(element.attribute("type")=="horizontal")
  18300. {
  18301. orientation= Qt::Horizontal;
  18302. }
  18303. else if(element.attribute("type")=="vertical")
  18304. {
  18305. orientation= Qt::Vertical;
  18306. }
  18307. }
  18308. /*238:*/
  18309. #line 5521 "./typica.w"
  18310. QWidget*theWidget= NULL;
  18311. QDomNodeList children= element.childNodes();
  18312. for(int i= 0;i<children.count();i++)
  18313. {
  18314. QDomNode item= children.at(i);
  18315. if(item.isElement())
  18316. {
  18317. QDomElement itemElement= item.toElement();
  18318. if(itemElement.tagName()=="lcdtemperature")
  18319. {
  18320. TemperatureDisplay*display= new TemperatureDisplay;
  18321. if(itemElement.hasAttribute("id"))
  18322. {
  18323. display->setObjectName(itemElement.attribute("id"));
  18324. }
  18325. theWidget= display;
  18326. }
  18327. else if(itemElement.tagName()=="lcdtimer")
  18328. {
  18329. TimerDisplay*display= new TimerDisplay;
  18330. if(itemElement.hasAttribute("id"))
  18331. {
  18332. display->setObjectName(itemElement.attribute("id"));
  18333. }
  18334. if(itemElement.hasAttribute("format"))
  18335. {
  18336. display->setDisplayFormat(itemElement.attribute("format"));
  18337. }
  18338. theWidget= display;
  18339. }
  18340. }
  18341. }
  18342. /*:238*/
  18343. #line 5510 "./typica.w"
  18344. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  18345. orientation);
  18346. if(element.hasAttribute("id"))
  18347. {
  18348. decoration->setObjectName(element.attribute("id"));
  18349. }
  18350. /*:237*/
  18351. #line 5486 "./typica.w"
  18352. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18353. splitter->addWidget(decoration);
  18354. }
  18355. /*:236*//*239:*/
  18356. #line 5560 "./typica.w"
  18357. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18358. QStack<QLayout*> *layoutStack)
  18359. {
  18360. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18361. QWidget*widget= new QWidget;
  18362. if(element.hasAttribute("id"))
  18363. {
  18364. widget->setObjectName(element.attribute("id"));
  18365. }
  18366. splitter->addWidget(widget);
  18367. if(element.hasChildNodes())
  18368. {
  18369. widgetStack->push(widget);
  18370. populateWidget(element,widgetStack,layoutStack);
  18371. widgetStack->pop();
  18372. }
  18373. }
  18374. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  18375. QStack<QLayout*> *layoutStack)
  18376. {
  18377. QDomNodeList children= element.childNodes();
  18378. for(int i= 0;i<children.count();i++)
  18379. {
  18380. QDomNode current;
  18381. QDomElement currentElement;
  18382. current= children.at(i);
  18383. if(current.isElement())
  18384. {
  18385. currentElement= current.toElement();
  18386. if(currentElement.tagName()=="layout")
  18387. {
  18388. currentElement.setAttribute("trcontext","configuration");
  18389. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  18390. }
  18391. }
  18392. }
  18393. }
  18394. /*:239*//*240:*/
  18395. #line 5604 "./typica.w"
  18396. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  18397. QStack<QLayout*> *layoutStack)
  18398. {
  18399. QAbstractButton*button= NULL;
  18400. QString text=
  18401. QCoreApplication::translate("configuration",
  18402. element.attribute("name").toUtf8().data());
  18403. if(element.hasAttribute("type"))
  18404. {
  18405. QString type= element.attribute("type");
  18406. if(type=="annotation")
  18407. {
  18408. AnnotationButton*abutton= new AnnotationButton(text);
  18409. if(element.hasAttribute("annotation"))
  18410. {
  18411. abutton->setAnnotation(element.attribute("annotation"));
  18412. }
  18413. if(element.hasAttribute("series"))
  18414. {
  18415. abutton->setTemperatureColumn(element.attribute("series").
  18416. toInt());
  18417. }
  18418. if(element.hasAttribute("column"))
  18419. {
  18420. abutton->setAnnotationColumn(element.attribute("column").
  18421. toInt());
  18422. }
  18423. button= abutton;
  18424. }
  18425. else if(type=="check")
  18426. {
  18427. button= new QCheckBox(text);
  18428. }
  18429. else if(type=="push")
  18430. {
  18431. button= new QPushButton(text);
  18432. }
  18433. }
  18434. if(element.hasAttribute("id"))
  18435. {
  18436. button->setObjectName(element.attribute("id"));
  18437. }
  18438. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18439. layout->addWidget(button);
  18440. }
  18441. /*:240*//*241:*/
  18442. #line 5658 "./typica.w"
  18443. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  18444. QStack<QLayout*> *layoutStack)
  18445. {
  18446. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  18447. if(element.hasAttribute("pretext"))
  18448. {
  18449. box->setPretext(QCoreApplication::translate(
  18450. "configuration",
  18451. element.attribute("pretext").toUtf8().data()));
  18452. }
  18453. if(element.hasAttribute("posttext"))
  18454. {
  18455. box->setPosttext(QCoreApplication::translate(
  18456. "configuration",
  18457. element.attribute("posttext").toUtf8().data()));
  18458. }
  18459. if(element.hasAttribute("series"))
  18460. {
  18461. box->setTemperatureColumn(element.attribute("series").toInt());
  18462. }
  18463. if(element.hasAttribute("column"))
  18464. {
  18465. box->setAnnotationColumn(element.attribute("column").toInt());
  18466. }
  18467. if(element.hasAttribute("min"))
  18468. {
  18469. box->setMinimum(element.attribute("min").toDouble());
  18470. }
  18471. if(element.hasAttribute("max"))
  18472. {
  18473. box->setMaximum(element.attribute("max").toDouble());
  18474. }
  18475. if(element.hasAttribute("decimals"))
  18476. {
  18477. box->setDecimals(element.attribute("decimals").toInt());
  18478. }
  18479. if(element.hasAttribute("step"))
  18480. {
  18481. box->setSingleStep(element.attribute("step").toDouble());
  18482. }
  18483. if(element.hasAttribute("id"))
  18484. {
  18485. box->setObjectName(element.attribute("id"));
  18486. }
  18487. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18488. layout->addWidget(box);
  18489. }
  18490. /*:241*//*242:*/
  18491. #line 5718 "./typica.w"
  18492. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18493. QStack<QLayout*> *)
  18494. {
  18495. ZoomLog*widget= new ZoomLog;
  18496. if(element.hasAttribute("id"))
  18497. {
  18498. widget->setObjectName(element.attribute("id"));
  18499. }
  18500. if(element.hasChildNodes())
  18501. {
  18502. QDomNodeList children= element.childNodes();
  18503. int column= 0;
  18504. for(int i= 0;i<children.count();i++)
  18505. {
  18506. QDomNode current;
  18507. QDomElement currentElement;
  18508. current= children.at(i);
  18509. if(current.isElement())
  18510. {
  18511. currentElement= current.toElement();
  18512. if(currentElement.tagName()=="column")
  18513. {
  18514. QString text=
  18515. QCoreApplication::translate(
  18516. "configuration",
  18517. currentElement.text().toUtf8().data());
  18518. widget->setHeaderData(column,text);
  18519. column++;
  18520. }
  18521. }
  18522. }
  18523. }
  18524. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18525. if(splitter)
  18526. {
  18527. splitter->addWidget(widget);
  18528. }
  18529. else
  18530. {
  18531. qDebug()<<"Splitter not found at top of widget stack!";
  18532. }
  18533. }
  18534. /*:242*//*243:*/
  18535. #line 5765 "./typica.w"
  18536. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18537. QStack<QLayout*> *)
  18538. {
  18539. GraphView*view= new GraphView;
  18540. if(element.hasAttribute("id"))
  18541. {
  18542. view->setObjectName(element.attribute("id"));
  18543. }
  18544. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18545. splitter->addWidget(view);
  18546. }
  18547. /*:243*//*244:*/
  18548. #line 5782 "./typica.w"
  18549. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  18550. QStack<QLayout*> *layoutStack)
  18551. {
  18552. SqlComboBox*box= new SqlComboBox();
  18553. if(element.hasAttribute("data"))
  18554. {
  18555. box->setDataColumn(element.attribute("data").toInt());
  18556. }
  18557. if(element.hasAttribute("display"))
  18558. {
  18559. box->setDisplayColumn(element.attribute("display").toInt());
  18560. }
  18561. if(element.hasAttribute("showdata"))
  18562. {
  18563. if(element.attribute("showdata")=="true")
  18564. {
  18565. box->showData(true);
  18566. }
  18567. }
  18568. if(element.hasAttribute("editable"))
  18569. {
  18570. if(element.attribute("editable")=="true")
  18571. {
  18572. box->setEditable(true);
  18573. }
  18574. }
  18575. if(element.hasChildNodes())
  18576. {
  18577. QDomNodeList children= element.childNodes();
  18578. for(int i= 0;i<children.count();i++)
  18579. {
  18580. QDomNode current;
  18581. QDomElement currentElement;
  18582. current= children.at(i);
  18583. if(current.isElement())
  18584. {
  18585. currentElement= current.toElement();
  18586. if(currentElement.tagName()=="null")
  18587. {
  18588. box->addNullOption();
  18589. }
  18590. else if(currentElement.tagName()=="query")
  18591. {
  18592. box->addSqlOptions(currentElement.text());
  18593. }
  18594. }
  18595. }
  18596. }
  18597. if(element.hasAttribute("id"))
  18598. {
  18599. box->setObjectName(element.attribute("id"));
  18600. }
  18601. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18602. layout->addWidget(box);
  18603. }
  18604. /*:244*//*245:*/
  18605. #line 5861 "./typica.w"
  18606. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  18607. QStack<QLayout*> *layoutStack)
  18608. {
  18609. QTableView*view= new QTableView;
  18610. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  18611. SaltModel*model= new SaltModel(element.childNodes().count());
  18612. if(element.hasAttribute("id"))
  18613. {
  18614. view->setObjectName(element.attribute("id"));
  18615. }
  18616. if(element.hasChildNodes())
  18617. {
  18618. QDomNodeList children= element.childNodes();
  18619. int currentColumn= 0;
  18620. for(int i= 0;i<children.count();i++)
  18621. {
  18622. QDomNode current;
  18623. QDomElement currentElement;
  18624. current= children.at(i);
  18625. if(current.isElement())
  18626. {
  18627. currentElement= current.toElement();
  18628. if(currentElement.tagName()=="column")
  18629. {
  18630. if(currentElement.hasAttribute("name"))
  18631. {
  18632. model->setHeaderData(currentColumn,
  18633. Qt::Horizontal,
  18634. QCoreApplication::translate(
  18635. "configuration",
  18636. currentElement.attribute("name").toUtf8().data()));
  18637. }
  18638. if(currentElement.hasAttribute("delegate"))
  18639. {
  18640. /*246:*/
  18641. #line 5912 "./typica.w"
  18642. if(currentElement.attribute("delegate")=="sql")
  18643. {
  18644. /*247:*/
  18645. #line 5928 "./typica.w"
  18646. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  18647. SqlComboBox*widget= new SqlComboBox();
  18648. if(currentElement.hasAttribute("nulltext"))
  18649. {
  18650. widget->setNullText(currentElement.attribute("nulltext"));
  18651. }
  18652. if(currentElement.hasAttribute("nulldata"))
  18653. {
  18654. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  18655. }
  18656. if(currentElement.hasAttribute("null"))
  18657. {
  18658. if(currentElement.attribute("null")=="true")
  18659. {
  18660. widget->addNullOption();
  18661. }
  18662. }
  18663. if(currentElement.hasAttribute("showdata"))
  18664. {
  18665. if(currentElement.attribute("showdata")=="true")
  18666. {
  18667. widget->showData(true);
  18668. }
  18669. }
  18670. if(currentElement.hasAttribute("data"))
  18671. {
  18672. widget->setDataColumn(currentElement.attribute("data").toInt());
  18673. }
  18674. if(currentElement.hasAttribute("display"))
  18675. {
  18676. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  18677. }
  18678. widget->addSqlOptions(currentElement.text());
  18679. delegate->setWidget(widget);
  18680. view->setItemDelegateForColumn(currentColumn,delegate);
  18681. /*:247*/
  18682. #line 5915 "./typica.w"
  18683. }
  18684. else if(currentElement.attribute("delegate")=="numeric")
  18685. {
  18686. /*248:*/
  18687. #line 5969 "./typica.w"
  18688. NumericDelegate*delegate= new NumericDelegate;
  18689. view->setItemDelegateForColumn(currentColumn,delegate);
  18690. /*:248*/
  18691. #line 5919 "./typica.w"
  18692. }
  18693. /*:246*/
  18694. #line 5896 "./typica.w"
  18695. }
  18696. currentColumn++;
  18697. }
  18698. }
  18699. }
  18700. }
  18701. view->setModel(model);
  18702. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18703. layout->addWidget(view);
  18704. }
  18705. /*:245*//*260:*/
  18706. #line 6142 "./typica.w"
  18707. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  18708. QStack<QLayout*> *layoutStack)
  18709. {
  18710. QLineEdit*widget= new QLineEdit(element.text());
  18711. if(element.hasAttribute("id"))
  18712. {
  18713. widget->setObjectName(element.attribute("id"));
  18714. }
  18715. if(element.hasAttribute("writable"))
  18716. {
  18717. if(element.attribute("writable")=="false")
  18718. {
  18719. widget->setReadOnly(true);
  18720. }
  18721. }
  18722. if(element.hasAttribute("validator"))
  18723. {
  18724. if(element.attribute("validator")=="numeric")
  18725. {
  18726. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  18727. }
  18728. else if(element.attribute("validator")=="integer")
  18729. {
  18730. widget->setValidator(new ScriptValidator(new QIntValidator));
  18731. }
  18732. else if(element.attribute("validator")=="expression"&&
  18733. element.hasAttribute("expression"))
  18734. {
  18735. widget->setValidator(new QRegExpValidator(
  18736. QRegExp(element.attribute("expression")),
  18737. NULL));
  18738. }
  18739. }
  18740. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18741. layout->addWidget(widget);
  18742. }
  18743. /*:260*//*261:*/
  18744. #line 6183 "./typica.w"
  18745. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  18746. QStack<QLayout*> *layoutStack)
  18747. {
  18748. QTextEdit*widget= new QTextEdit;
  18749. if(element.hasAttribute("id"))
  18750. {
  18751. widget->setObjectName(element.attribute("id"));
  18752. }
  18753. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18754. layout->addWidget(widget);
  18755. }
  18756. /*:261*//*262:*/
  18757. #line 6200 "./typica.w"
  18758. void addSqlQueryViewToLayout(QDomElement element,
  18759. QStack<QWidget*> *,
  18760. QStack<QLayout*> *layoutStack)
  18761. {
  18762. SqlQueryView*view= new SqlQueryView;
  18763. if(element.hasAttribute("id"))
  18764. {
  18765. view->setObjectName(element.attribute("id"));
  18766. }
  18767. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18768. layout->addWidget(view);
  18769. }
  18770. /*:262*//*263:*/
  18771. #line 6217 "./typica.w"
  18772. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  18773. QStack<QLayout*> *layoutStack)
  18774. {
  18775. QWidget*widget;
  18776. if(element.hasAttribute("time"))
  18777. {
  18778. if(element.attribute("time")=="true")
  18779. {
  18780. QDateTimeEdit*edit= new QDateTimeEdit;
  18781. edit->setDateTime(QDateTime::currentDateTime());
  18782. edit->setCalendarPopup(true);
  18783. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  18784. widget= qobject_cast<QWidget*> (edit);
  18785. }
  18786. else
  18787. {
  18788. QDateEdit*edit= new QDateEdit;
  18789. edit->setDate(QDate::currentDate());
  18790. edit->setCalendarPopup(true);
  18791. edit->setDisplayFormat("yyyy-MM-dd");
  18792. widget= qobject_cast<QWidget*> (edit);
  18793. }
  18794. }
  18795. else
  18796. {
  18797. QDateEdit*edit= new QDateEdit;
  18798. edit->setDate(QDate::currentDate());
  18799. edit->setCalendarPopup(true);
  18800. edit->setDisplayFormat("yyyy-MM-dd");
  18801. widget= qobject_cast<QWidget*> (edit);
  18802. }
  18803. if(element.hasAttribute("id"))
  18804. {
  18805. widget->setObjectName(element.attribute("id"));
  18806. }
  18807. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18808. layout->addWidget(widget);
  18809. }
  18810. /*:263*//*264:*/
  18811. #line 6260 "./typica.w"
  18812. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  18813. {
  18814. setQDateTimeEditProperties(value,engine);
  18815. }
  18816. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  18817. {
  18818. setQAbstractSpinBoxProperties(value,engine);
  18819. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  18820. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  18821. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  18822. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  18823. value.setProperty("setToCurrentTime",
  18824. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  18825. }
  18826. /*:264*//*265:*/
  18827. #line 6282 "./typica.w"
  18828. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  18829. {
  18830. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18831. if(context->argumentCount()==3)
  18832. {
  18833. self->setDate(QDate(argument<int> (0,context),
  18834. argument<int> (1,context),
  18835. argument<int> (2,context)));
  18836. }
  18837. else
  18838. {
  18839. context->throwError("Incorrect number of arguments passed to "
  18840. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  18841. "specifying the year, month, and day.");
  18842. }
  18843. return QScriptValue();
  18844. }
  18845. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  18846. {
  18847. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18848. return QScriptValue(self->date().day());
  18849. }
  18850. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  18851. {
  18852. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18853. return QScriptValue(self->date().month());
  18854. }
  18855. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  18856. {
  18857. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18858. return QScriptValue(self->date().year());
  18859. }
  18860. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  18861. {
  18862. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  18863. self->setDateTime(QDateTime::currentDateTime());
  18864. return QScriptValue();
  18865. }
  18866. /*:265*//*267:*/
  18867. #line 6342 "./typica.w"
  18868. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *,
  18869. QStack<QLayout*> *layoutStack)
  18870. {
  18871. QTimeEdit*edit= new QTimeEdit;
  18872. if(element.hasAttribute("displayFormat"))
  18873. {
  18874. edit->setDisplayFormat(element.attribute("displayFormat"));
  18875. }
  18876. else
  18877. {
  18878. edit->setDisplayFormat("mm:ss.zzz");
  18879. }
  18880. if(element.hasAttribute("id"))
  18881. {
  18882. edit->setObjectName(element.attribute("id"));
  18883. }
  18884. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18885. layout->addWidget(edit);
  18886. }
  18887. /*:267*//*268:*/
  18888. #line 6365 "./typica.w"
  18889. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  18890. {
  18891. setQDateTimeEditProperties(value,engine);
  18892. }
  18893. /*:268*//*272:*/
  18894. #line 6394 "./typica.w"
  18895. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  18896. {
  18897. QObject*parent= argument<QObject*> (0,context);
  18898. QString name= argument<QString> (1,context);
  18899. QObject*object= parent->findChild<QObject*> (name);
  18900. QScriptValue value;
  18901. if(object)
  18902. {
  18903. value= engine->newQObject(object);
  18904. QString className= object->metaObject()->className();
  18905. /*273:*/
  18906. #line 6412 "./typica.w"
  18907. if(className=="TemperatureDisplay")
  18908. {
  18909. setTemperatureDisplayProperties(value,engine);
  18910. }
  18911. else if(className=="TimerDisplay")
  18912. {
  18913. setTimerDisplayProperties(value,engine);
  18914. }
  18915. else if(className=="QAction")
  18916. {
  18917. setQActionProperties(value,engine);
  18918. }
  18919. else if(className=="QBoxLayout")
  18920. {
  18921. setQBoxLayoutProperties(value,engine);
  18922. }
  18923. else if(className=="QDateEdit")
  18924. {
  18925. setQDateEditProperties(value,engine);
  18926. }
  18927. else if(className=="QDateTimeEdit")
  18928. {
  18929. setQDateTimeEditProperties(value,engine);
  18930. }
  18931. else if(className=="QFrame")
  18932. {
  18933. setQFrameProperties(value,engine);
  18934. }
  18935. else if(className=="QHBoxLayout")
  18936. {
  18937. setQBoxLayoutProperties(value,engine);
  18938. }
  18939. else if(className=="QLCDNumber")
  18940. {
  18941. setQLCDNumberProperties(value,engine);
  18942. }
  18943. else if(className=="QMenu")
  18944. {
  18945. setQMenuProperties(value,engine);
  18946. }
  18947. else if(className=="QMenuBar")
  18948. {
  18949. setQMenuBarProperties(value,engine);
  18950. }
  18951. else if(className=="QPushButton")
  18952. {
  18953. setQPushButtonProperties(value,engine);
  18954. }
  18955. else if(className=="QSplitter")
  18956. {
  18957. setQSplitterProperties(value,engine);
  18958. }
  18959. else if(className=="QTableView")
  18960. {
  18961. if(object->property("tabletype").isValid())
  18962. {
  18963. if(object->property("tabletype").toString()=="SaltTable")
  18964. {
  18965. setSaltTableProperties(value,engine);
  18966. }
  18967. }
  18968. }
  18969. else if(className=="QVBoxLayout")
  18970. {
  18971. setQBoxLayoutProperties(value,engine);
  18972. }
  18973. else if(className=="QWidget")
  18974. {
  18975. setQWidgetProperties(value,engine);
  18976. }
  18977. else if(className=="ScriptQMainWindow")
  18978. {
  18979. setQMainWindowProperties(value,engine);
  18980. }
  18981. else if(className=="SqlComboBox")
  18982. {
  18983. setSqlComboBoxProperties(value,engine);
  18984. }
  18985. else if(className=="SqlQueryView")
  18986. {
  18987. setSqlQueryViewProperties(value,engine);
  18988. }
  18989. else if(className=="ZoomLog")
  18990. {
  18991. setZoomLogProperties(value,engine);
  18992. }
  18993. else if(className=="QTextEdit")
  18994. {
  18995. setQTextEditProperties(value,engine);
  18996. }
  18997. else if(className=="QWebView")
  18998. {
  18999. setQWebViewProperties(value,engine);
  19000. }
  19001. else if(className=="QLineEdit")
  19002. {
  19003. setQLineEditProperties(value,engine);
  19004. }
  19005. else if(className=="QSvgWidget")
  19006. {
  19007. setQSvgWidgetProperties(value,engine);
  19008. }
  19009. else if(className=="QTabBar")
  19010. {
  19011. setQTabBarProperties(value,engine);
  19012. }
  19013. else if(className=="PrinterSelector")
  19014. {
  19015. setQComboBoxProperties(value,engine);
  19016. }
  19017. /*:273*/
  19018. #line 6405 "./typica.w"
  19019. }
  19020. return value;
  19021. }
  19022. /*:272*//*275:*/
  19023. #line 6553 "./typica.w"
  19024. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  19025. {
  19026. QTableView*self= getself<QTableView*> (context);
  19027. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19028. QString datum;
  19029. double total= 0.0;
  19030. int column= argument<int> (0,context);
  19031. int role= argument<int> (1,context);
  19032. for(int i= 0;i<model->rowCount();i++)
  19033. {
  19034. datum= model->data(model->index(i,column),role).toString();
  19035. if(!datum.isEmpty())
  19036. {
  19037. total+= datum.toDouble();
  19038. }
  19039. }
  19040. return QScriptValue(engine,total);
  19041. }
  19042. /*:275*//*276:*/
  19043. #line 6577 "./typica.w"
  19044. QScriptValue SaltTable_columnArray(QScriptContext*context,
  19045. QScriptEngine*engine)
  19046. {
  19047. QTableView*self= getself<QTableView*> (context);
  19048. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19049. int column= argument<int> (0,context);
  19050. int role= argument<int> (1,context);
  19051. QString literal= model->arrayLiteral(column,role);
  19052. return QScriptValue(engine,literal);
  19053. }
  19054. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  19055. QScriptEngine*engine)
  19056. {
  19057. QTableView*self= getself<QTableView*> (context);
  19058. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19059. int column= argument<int> (0,context);
  19060. int role= argument<int> (1,context);
  19061. QString literal= model->quotedArrayLiteral(column,role);
  19062. return QScriptValue(engine,literal);
  19063. }
  19064. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  19065. QScriptEngine*engine)
  19066. {
  19067. QTableView*self= getself<QTableView*> (context);
  19068. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19069. int column= argument<int> (0,context);
  19070. int role= argument<int> (1,context);
  19071. QString literal= model->arrayLiteral(column,role);
  19072. literal.chop(1);
  19073. literal= literal.remove(0,1);
  19074. return QScriptValue(engine,literal);
  19075. }
  19076. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  19077. QScriptEngine*engine)
  19078. {
  19079. QTableView*self= getself<QTableView*> (context);
  19080. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19081. int column= argument<int> (0,context);
  19082. int role= argument<int> (1,context);
  19083. QString literal= model->quotedArrayLiteral(column,role);
  19084. literal.chop(1);
  19085. literal= literal.remove(0,1);
  19086. return QScriptValue(engine,literal);
  19087. }
  19088. /*:276*//*277:*/
  19089. #line 6629 "./typica.w"
  19090. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  19091. {
  19092. QTableView*self= getself<QTableView*> (context);
  19093. QScriptValue value= engine->newQObject(self->model());
  19094. return value;
  19095. }
  19096. /*:277*//*278:*/
  19097. #line 6643 "./typica.w"
  19098. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  19099. {
  19100. QTableView*self= getself<QTableView*> (context);
  19101. int row= argument<int> (0,context);
  19102. int column= argument<int> (1,context);
  19103. QVariant value= argument<QVariant> (2,context);
  19104. int role= argument<int> (3,context);
  19105. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19106. QModelIndex cell= model->index(row,column);
  19107. model->setData(cell,value,role);
  19108. self->update(cell);
  19109. return QScriptValue();
  19110. }
  19111. /*:278*//*279:*/
  19112. #line 6661 "./typica.w"
  19113. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  19114. {
  19115. QTableView*self= getself<QTableView*> (context);
  19116. int row= argument<int> (0,context);
  19117. int column= argument<int> (1,context);
  19118. int role= argument<int> (2,context);
  19119. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19120. QModelIndex cell= model->index(row,column);
  19121. QVariant value= model->data(cell,role);
  19122. QScriptValue retval= engine->newVariant(value);
  19123. retval.setProperty("value",QScriptValue(value.toString()));
  19124. return retval;
  19125. }
  19126. /*:279*//*280:*/
  19127. #line 6681 "./typica.w"
  19128. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  19129. {
  19130. QTableView*self= getself<QTableView*> (context);
  19131. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19132. model->clear();
  19133. return QScriptValue();
  19134. }
  19135. /*:280*//*281:*/
  19136. #line 6693 "./typica.w"
  19137. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  19138. {
  19139. QTableView*self= getself<QTableView*> (context);
  19140. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19141. int row= argument<int> (0,context);
  19142. return engine->newVariant(model->removeRow(row));
  19143. }
  19144. /*:281*//*282:*/
  19145. #line 6706 "./typica.w"
  19146. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  19147. {
  19148. QTableView*self= getself<QTableView*> (context);
  19149. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19150. QVariant value= argument<QVariant> (0,context);
  19151. int column= argument<int> (1,context);
  19152. return engine->newVariant(model->findData(value,column));
  19153. }
  19154. /*:282*//*283:*/
  19155. #line 6719 "./typica.w"
  19156. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  19157. {
  19158. setQWidgetProperties(value,engine);
  19159. value.setProperty("columnArray",
  19160. engine->newFunction(SaltTable_columnArray));
  19161. value.setProperty("quotedColumnArray",
  19162. engine->newFunction(SaltTable_quotedColumnArray));
  19163. value.setProperty("bindableColumnArray",
  19164. engine->newFunction(SaltTable_bindableColumnArray));
  19165. value.setProperty("bindableQuotedColumnArray",
  19166. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  19167. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  19168. value.setProperty("data",engine->newFunction(SaltTable_data));
  19169. value.setProperty("model",engine->newFunction(SaltTable_model));
  19170. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  19171. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  19172. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  19173. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  19174. }
  19175. /*:283*//*285:*/
  19176. #line 6756 "./typica.w"
  19177. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  19178. {
  19179. setQComboBoxProperties(value,engine);
  19180. }
  19181. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  19182. {
  19183. setQWidgetProperties(value,engine);
  19184. value.setProperty("currentData",
  19185. engine->newFunction(QComboBox_currentData));
  19186. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  19187. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  19188. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  19189. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  19190. }
  19191. QScriptValue QComboBox_currentData(QScriptContext*context,
  19192. QScriptEngine*engine)
  19193. {
  19194. QComboBox*self= getself<QComboBox*> (context);
  19195. return QScriptValue(engine,
  19196. self->itemData(self->currentIndex()).toString());
  19197. }
  19198. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  19199. {
  19200. QComboBox*self= getself<QComboBox*> (context);
  19201. self->addItem(argument<QString> (0,context));
  19202. return QScriptValue();
  19203. }
  19204. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  19205. {
  19206. QComboBox*self= getself<QComboBox*> (context);
  19207. self->setModel(argument<QAbstractItemModel*> (0,context));
  19208. return QScriptValue();
  19209. }
  19210. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  19211. {
  19212. QComboBox*self= getself<QComboBox*> (context);
  19213. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  19214. }
  19215. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  19216. {
  19217. QComboBox*self= getself<QComboBox*> (context);
  19218. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  19219. }
  19220. #line 1 "./abouttypica.w"
  19221. /*:285*//*298:*/
  19222. #line 401 "./units.w"
  19223. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  19224. {
  19225. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  19226. argument<Units::Unit> (1,context),
  19227. argument<Units::Unit> (2,context)));
  19228. }
  19229. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  19230. QScriptEngine*)
  19231. {
  19232. return QScriptValue(Units::convertRelativeTemperature(
  19233. argument<double> (0,context),
  19234. argument<Units::Unit> (1,context),
  19235. argument<Units::Unit> (2,context)));
  19236. }
  19237. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  19238. {
  19239. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  19240. }
  19241. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  19242. {
  19243. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  19244. argument<Units::Unit> (1,context),
  19245. argument<Units::Unit> (2,context)));
  19246. }
  19247. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  19248. {
  19249. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  19250. }
  19251. /*:298*//*301:*/
  19252. #line 449 "./units.w"
  19253. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  19254. {
  19255. return engine->newVariant(QVariant(value));
  19256. }
  19257. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  19258. {
  19259. value= sv.toVariant().value<Units::Unit> ();
  19260. }
  19261. /*:301*//*311:*/
  19262. #line 149 "./measurement.w"
  19263. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  19264. {
  19265. QScriptValue object;
  19266. if(context->argumentCount()==2||context->argumentCount()==3)
  19267. {
  19268. double measurement= argument<double> (0,context);
  19269. QTime timestamp= argument<QTime> (1,context);
  19270. Units::Unit unit= Units::Fahrenheit;
  19271. if(context->argumentCount()==3)
  19272. {
  19273. unit= argument<Units::Unit> (2,context);
  19274. }
  19275. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  19276. setMeasurementProperties(object,engine);
  19277. }
  19278. else
  19279. {
  19280. context->throwError("Incorrect number of arguments passed to "
  19281. "Measurement::Measurement(). This method takes two "
  19282. "or three arguments.");
  19283. }
  19284. return object;
  19285. }
  19286. /*:311*//*312:*/
  19287. #line 176 "./measurement.w"
  19288. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  19289. {
  19290. }
  19291. /*:312*//*313:*/
  19292. #line 184 "./measurement.w"
  19293. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  19294. {
  19295. QVariant var;
  19296. var.setValue(measurement);
  19297. return engine->newVariant(var);
  19298. }
  19299. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  19300. {
  19301. measurement= value.toVariant().value<Measurement> ();
  19302. }
  19303. #line 6825 "./typica.w"
  19304. /*:313*//*331:*/
  19305. #line 7403 "./typica.w"
  19306. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  19307. {
  19308. QScriptValue object;
  19309. if(context->argumentCount()==1)
  19310. {
  19311. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  19312. QScriptEngine::ScriptOwnership);
  19313. setDAQProperties(object,engine);
  19314. }
  19315. else if(context->argumentCount()==2)
  19316. {
  19317. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  19318. argument<QString> (1,context)),
  19319. QScriptEngine::ScriptOwnership);
  19320. setDAQProperties(object,engine);
  19321. }
  19322. else
  19323. {
  19324. context->throwError("Incorrect number of arguments passed to DAQ"
  19325. "constructor. The DAQ constructor takes one"
  19326. "string as an argument specifying a device name."
  19327. "Example: Dev1");
  19328. }
  19329. return object;
  19330. }
  19331. /*:331*//*332:*/
  19332. #line 7433 "./typica.w"
  19333. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  19334. {
  19335. setQObjectProperties(value,engine);
  19336. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  19337. }
  19338. /*:332*//*333:*/
  19339. #line 7443 "./typica.w"
  19340. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  19341. {
  19342. DAQ*self= getself<DAQ*> (context);
  19343. QScriptValue object;
  19344. if(self)
  19345. {
  19346. object=
  19347. engine->newQObject(self->newChannel(argument<int> (0,context),
  19348. argument<int> (1,context)));
  19349. setChannelProperties(object,engine);
  19350. }
  19351. return object;
  19352. }
  19353. /*:333*//*340:*/
  19354. #line 7599 "./typica.w"
  19355. QScriptValue constructFakeDAQ(QScriptContext*context,
  19356. QScriptEngine*engine)
  19357. {
  19358. QScriptValue object;
  19359. if(context->argumentCount()==1)
  19360. {
  19361. object=
  19362. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  19363. QScriptEngine::ScriptOwnership);
  19364. setFakeDAQProperties(object,engine);
  19365. }
  19366. else
  19367. {
  19368. context->throwError("Incorrect number of arguments passed to DAQ"
  19369. "constructor. The DAQ constructor takes one"
  19370. "string as an argument specifying a device name."
  19371. "Example: Dev1");
  19372. }
  19373. return object;
  19374. }
  19375. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  19376. {
  19377. setQObjectProperties(value,engine);
  19378. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  19379. }
  19380. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  19381. {
  19382. FakeDAQ*self= getself<FakeDAQ*> (context);
  19383. QScriptValue object;
  19384. if(self)
  19385. {
  19386. object=
  19387. engine->newQObject(self->newChannel(argument<int> (0,context),
  19388. argument<int> (1,context)));
  19389. setChannelProperties(object,engine);
  19390. }
  19391. return object;
  19392. }
  19393. /*:340*//*344:*/
  19394. #line 7690 "./typica.w"
  19395. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  19396. {
  19397. setQObjectProperties(value,engine);
  19398. }
  19399. /*:344*//*351:*/
  19400. #line 7882 "./typica.w"
  19401. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  19402. {
  19403. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  19404. setLinearCalibratorProperties(object,engine);
  19405. return object;
  19406. }
  19407. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  19408. {
  19409. setQObjectProperties(value,engine);
  19410. }
  19411. /*:351*//*356:*/
  19412. #line 8020 "./typica.w"
  19413. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  19414. {
  19415. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  19416. setLinearSplineInterpolatorProperties(object,engine);
  19417. return object;
  19418. }
  19419. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  19420. {
  19421. setQObjectProperties(value,engine);
  19422. }
  19423. /*:356*//*366:*/
  19424. #line 8229 "./typica.w"
  19425. QScriptValue constructTemperatureDisplay(QScriptContext*,
  19426. QScriptEngine*engine)
  19427. {
  19428. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  19429. setTemperatureDisplayProperties(object,engine);
  19430. return object;
  19431. }
  19432. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  19433. {
  19434. setQLCDNumberProperties(value,engine);
  19435. value.setProperty("setDisplayUnits",
  19436. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  19437. }
  19438. /*:366*//*367:*/
  19439. #line 8253 "./typica.w"
  19440. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  19441. {
  19442. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  19443. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  19444. return QScriptValue();
  19445. }
  19446. /*:367*//*374:*/
  19447. #line 8390 "./typica.w"
  19448. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  19449. QScriptEngine*engine)
  19450. {
  19451. QScriptValue object=
  19452. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  19453. setMeasurementTimeOffsetProperties(object,engine);
  19454. return object;
  19455. }
  19456. void setMeasurementTimeOffsetProperties(QScriptValue value,
  19457. QScriptEngine*engine)
  19458. {
  19459. setQObjectProperties(value,engine);
  19460. }
  19461. /*:374*//*379:*/
  19462. #line 8509 "./typica.w"
  19463. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  19464. {
  19465. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  19466. return object;
  19467. }
  19468. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  19469. {
  19470. setQObjectProperties(value,engine);
  19471. }
  19472. /*:379*//*384:*/
  19473. #line 8606 "./typica.w"
  19474. QScriptValue constructZeroEmitter(QScriptContext*context,
  19475. QScriptEngine*engine)
  19476. {
  19477. QScriptValue object=
  19478. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  19479. setZeroEmitterProperties(object,engine);
  19480. return object;
  19481. }
  19482. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  19483. {
  19484. setQObjectProperties(value,engine);
  19485. }
  19486. /*:384*//*389:*/
  19487. #line 8686 "./typica.w"
  19488. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  19489. QScriptEngine*engine)
  19490. {
  19491. QScriptValue object=
  19492. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  19493. setMeasurementAdapterProperties(object,engine);
  19494. return object;
  19495. }
  19496. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  19497. {
  19498. setQObjectProperties(value,engine);
  19499. }
  19500. /*:389*//*406:*/
  19501. #line 9148 "./typica.w"
  19502. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  19503. {
  19504. QScriptValue object= engine->newQObject(new GraphView);
  19505. setGraphViewProperties(object,engine);
  19506. return object;
  19507. }
  19508. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  19509. {
  19510. setQGraphicsViewProperties(value,engine);
  19511. }
  19512. /*:406*//*429:*/
  19513. #line 9798 "./typica.w"
  19514. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  19515. {
  19516. QScriptValue object= engine->newQObject(new ZoomLog);
  19517. setZoomLogProperties(object,engine);
  19518. return object;
  19519. }
  19520. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  19521. {
  19522. setQTableViewProperties(value,engine);
  19523. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  19524. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  19525. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  19526. value.setProperty("restoreState",
  19527. engine->newFunction(ZoomLog_restoreState));
  19528. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  19529. value.setProperty("saveTemporary",
  19530. engine->newFunction(ZoomLog_saveTemporary));
  19531. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  19532. }
  19533. /*:429*//*430:*/
  19534. #line 9825 "./typica.w"
  19535. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  19536. {
  19537. ZoomLog*self= getself<ZoomLog*> (context);
  19538. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  19539. return QScriptValue(engine,retval);
  19540. }
  19541. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  19542. {
  19543. ZoomLog*self= getself<ZoomLog*> (context);
  19544. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  19545. return QScriptValue(engine,retval);
  19546. }
  19547. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  19548. QScriptEngine*engine)
  19549. {
  19550. ZoomLog*self= getself<ZoomLog*> (context);
  19551. QString filename= QDir::tempPath();
  19552. filename.append("/");
  19553. filename.append(QUuid::createUuid().toString());
  19554. filename.append(".xml");
  19555. QFile*file= new QFile(filename);
  19556. self->saveXML(file);
  19557. file->close();
  19558. delete file;
  19559. return QScriptValue(engine,filename);
  19560. }
  19561. /*:430*//*431:*/
  19562. #line 9873 "./typica.w"
  19563. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  19564. {
  19565. ZoomLog*self= getself<ZoomLog*> (context);
  19566. QString key= argument<QString> (0,context);
  19567. int columns= argument<int> (1,context);
  19568. QSettings settings;
  19569. for(int i= 0;i<columns;i++)
  19570. {
  19571. if(self->columnWidth(i))
  19572. {
  19573. settings.beginGroup(key);
  19574. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  19575. settings.endGroup();
  19576. }
  19577. }
  19578. return QScriptValue();
  19579. }
  19580. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  19581. {
  19582. ZoomLog*self= getself<ZoomLog*> (context);
  19583. QString key= argument<QString> (0,context);
  19584. int columns= argument<int> (1,context);
  19585. QSettings settings;
  19586. for(int i= 0;i<columns;i++)
  19587. {
  19588. settings.beginGroup(key);
  19589. self->setColumnWidth(i,
  19590. settings.value(QString("%1").arg(i),80).toInt());
  19591. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  19592. {
  19593. self->setColumnWidth(i,80);
  19594. }
  19595. settings.endGroup();
  19596. }
  19597. return QScriptValue();
  19598. }
  19599. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  19600. {
  19601. ZoomLog*self= getself<ZoomLog*> (context);
  19602. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  19603. }
  19604. /*:431*//*432:*/
  19605. #line 9926 "./typica.w"
  19606. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  19607. {
  19608. ZoomLog*self= getself<ZoomLog*> (context);
  19609. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  19610. return QScriptValue();
  19611. }
  19612. /*:432*//*467:*/
  19613. #line 10746 "./typica.w"
  19614. QScriptValue constructAnnotationButton(QScriptContext*context,
  19615. QScriptEngine*engine)
  19616. {
  19617. QScriptValue object=
  19618. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  19619. setAnnotationButtonProperties(object,engine);
  19620. return object;
  19621. }
  19622. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  19623. {
  19624. setQPushButtonProperties(value,engine);
  19625. }
  19626. /*:467*//*475:*/
  19627. #line 10889 "./typica.w"
  19628. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  19629. QScriptEngine*engine)
  19630. {
  19631. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  19632. argument<QString> (0,context),argument<QString> (1,context)));
  19633. setAnnotationSpinBoxProperties(object,engine);
  19634. return object;
  19635. }
  19636. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19637. {
  19638. setQDoubleSpinBoxProperties(value,engine);
  19639. }
  19640. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19641. {
  19642. setQAbstractSpinBoxProperties(value,engine);
  19643. }
  19644. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  19645. {
  19646. setQWidgetProperties(value,engine);
  19647. }
  19648. /*:475*//*496:*/
  19649. #line 11312 "./typica.w"
  19650. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  19651. {
  19652. QScriptValue object= engine->newQObject(new TimerDisplay);
  19653. setTimerDisplayProperties(object,engine);
  19654. return object;
  19655. }
  19656. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  19657. {
  19658. setQLCDNumberProperties(value,engine);
  19659. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  19660. }
  19661. /*:496*//*497:*/
  19662. #line 11331 "./typica.w"
  19663. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  19664. {
  19665. TimerDisplay*self= getself<TimerDisplay*> (context);
  19666. if(self)
  19667. {
  19668. switch(argument<int> (0,context))
  19669. {
  19670. case 0:
  19671. self->setMode(TimerDisplay::CountUp);
  19672. break;
  19673. case 1:
  19674. self->setMode(TimerDisplay::CountDown);
  19675. break;
  19676. case 2:
  19677. self->setMode(TimerDisplay::Clock);
  19678. break;
  19679. default:
  19680. break;
  19681. }
  19682. }
  19683. return QScriptValue();
  19684. }
  19685. /*:497*//*524:*/
  19686. #line 11837 "./typica.w"
  19687. QScriptValue constructWidgetDecorator(QScriptContext*context,
  19688. QScriptEngine*engine)
  19689. {
  19690. QWidget*widget= argument<QWidget*> (0,context);
  19691. QString text= argument<QString> (1,context);
  19692. Qt::Orientations orientation;
  19693. switch(argument<int> (2,context))
  19694. {
  19695. case 2:
  19696. orientation= Qt::Vertical;
  19697. break;
  19698. default:
  19699. orientation= Qt::Horizontal;
  19700. break;
  19701. }
  19702. QScriptValue object=
  19703. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  19704. setWidgetDecoratorProperties(object,engine);
  19705. return object;
  19706. }
  19707. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  19708. {
  19709. setQWidgetProperties(value,engine);
  19710. }
  19711. /*:524*//*537:*/
  19712. #line 12118 "./typica.w"
  19713. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  19714. {
  19715. QScriptValue object= engine->newQObject(new LogEditWindow);
  19716. return object;
  19717. }
  19718. /*:537*//*556:*/
  19719. #line 12645 "./typica.w"
  19720. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  19721. {
  19722. QIODevice*device= argument<QIODevice*> (0,context);
  19723. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  19724. argument<int> (1,context)));
  19725. object.setProperty("input",engine->newFunction(XMLInput_input));
  19726. return object;
  19727. }
  19728. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  19729. {
  19730. XMLInput*self= getself<XMLInput*> (context);
  19731. self->input();
  19732. return QScriptValue();
  19733. }
  19734. /*:556*//*571:*/
  19735. #line 172 "./webview.w"
  19736. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  19737. {
  19738. QScriptValue object= engine->newQObject(new TypicaWebView);
  19739. setQWebViewProperties(object,engine);
  19740. return object;
  19741. }
  19742. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  19743. {
  19744. setQWidgetProperties(value,engine);
  19745. }
  19746. /*:571*//*572:*/
  19747. #line 189 "./webview.w"
  19748. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  19749. QStack<QLayout*> *layoutStack)
  19750. {
  19751. TypicaWebView*view= new TypicaWebView;
  19752. if(element.hasAttribute("id"))
  19753. {
  19754. view->setObjectName(element.attribute("id"));
  19755. }
  19756. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19757. layout->addWidget(view);
  19758. }
  19759. /*:572*//*577:*/
  19760. #line 240 "./webview.w"
  19761. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  19762. {
  19763. QVariant var;
  19764. var.setValue(element);
  19765. QScriptValue object= engine->newVariant(var);
  19766. return object;
  19767. }
  19768. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  19769. {
  19770. element= value.toVariant().value<QWebElement> ();
  19771. }
  19772. /*:577*//*582:*/
  19773. #line 305 "./webview.w"
  19774. template<> QWebElement argument(int arg,QScriptContext*context)
  19775. {
  19776. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  19777. }
  19778. /*:582*//*583:*/
  19779. #line 314 "./webview.w"
  19780. QScriptValue constructWebElement(QScriptContext*context,
  19781. QScriptEngine*engine)
  19782. {
  19783. QWebElement element= argument<QWebElement> (0,context);
  19784. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  19785. return object;
  19786. }
  19787. /*:583*//*594:*/
  19788. #line 85 "./printerselector.w"
  19789. QScriptValue constructPrinterSelector(QScriptContext*,QScriptEngine*engine)
  19790. {
  19791. QScriptValue object= engine->newQObject(new PrinterSelector);
  19792. setQComboBoxProperties(object,engine);
  19793. return object;
  19794. }
  19795. /*:594*//*595:*/
  19796. #line 96 "./printerselector.w"
  19797. void addPrinterSelectorToLayout(QDomElement element,QStack<QWidget*> *,
  19798. QStack<QLayout*> *layoutStack)
  19799. {
  19800. PrinterSelector*selector= new PrinterSelector;
  19801. if(element.hasAttribute("id"))
  19802. {
  19803. selector->setObjectName(element.attribute("id"));
  19804. }
  19805. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19806. layout->addWidget(selector);
  19807. }
  19808. /*:595*//*661:*/
  19809. #line 14032 "./typica.w"
  19810. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  19811. {
  19812. QScriptValue object= engine->newQObject(new SqlQueryView);
  19813. setSqlQueryViewProperties(object,engine);
  19814. return object;
  19815. }
  19816. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  19817. {
  19818. setQTableViewProperties(value,engine);
  19819. value.setProperty("setHeaderData",
  19820. engine->newFunction(SqlQueryView_setHeaderData));
  19821. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  19822. }
  19823. /*:661*//*662:*/
  19824. #line 14050 "./typica.w"
  19825. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  19826. {
  19827. SqlQueryView*self= getself<SqlQueryView*> (context);
  19828. QString query= argument<QString> (0,context);
  19829. self->setQuery(query);
  19830. self->reset();
  19831. return QScriptValue();
  19832. }
  19833. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  19834. QScriptEngine*)
  19835. {
  19836. SqlQueryView*self= getself<SqlQueryView*> (context);
  19837. int section= argument<int> (0,context);
  19838. QString data= argument<QString> (1,context);
  19839. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  19840. return QScriptValue();
  19841. }
  19842. /*:662*//*670:*/
  19843. #line 14259 "./typica.w"
  19844. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  19845. QStack<QLayout*> *layoutStack)
  19846. {
  19847. QTextEdit*widget= new QTextEdit;
  19848. if(element.hasAttribute("id"))
  19849. {
  19850. widget->setObjectName(element.attribute("id"));
  19851. }
  19852. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19853. layout->addWidget(widget);
  19854. QTextDocument*document= new QTextDocument;
  19855. QFont defaultFont;
  19856. defaultFont.setPointSize(11);
  19857. document->setDefaultFont(defaultFont);
  19858. QTextCursor cursor(document);
  19859. /*671:*/
  19860. #line 14282 "./typica.w"
  19861. QDomNodeList children= element.childNodes();
  19862. for(int i= 0;i<children.count();i++)
  19863. {
  19864. QDomNode current;
  19865. QDomElement currentElement;
  19866. current= children.at(i);
  19867. if(current.isElement())
  19868. {
  19869. currentElement= current.toElement();
  19870. /*672:*/
  19871. #line 14299 "./typica.w"
  19872. if(currentElement.tagName()=="style")
  19873. {
  19874. document->setDefaultStyleSheet(currentElement.text());
  19875. }
  19876. /*:672*//*673:*/
  19877. #line 14310 "./typica.w"
  19878. if(currentElement.tagName()=="html")
  19879. {
  19880. cursor.insertHtml(currentElement.text());
  19881. }
  19882. /*:673*//*674:*/
  19883. #line 14320 "./typica.w"
  19884. if(currentElement.tagName()=="text")
  19885. {
  19886. cursor.insertText(currentElement.text());
  19887. }
  19888. /*:674*//*675:*/
  19889. #line 14330 "./typica.w"
  19890. if(currentElement.tagName()=="table")
  19891. {
  19892. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  19893. ReportTable*table= new ReportTable(frame,currentElement);
  19894. table->setParent(widget);
  19895. if(currentElement.hasAttribute("id"))
  19896. {
  19897. table->setObjectName(currentElement.attribute("id"));
  19898. }
  19899. }
  19900. /*:675*/
  19901. #line 14292 "./typica.w"
  19902. }
  19903. }
  19904. /*:671*/
  19905. #line 14275 "./typica.w"
  19906. widget->setDocument(document);
  19907. }
  19908. /*:670*//*686:*/
  19909. #line 14543 "./typica.w"
  19910. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  19911. {
  19912. QTextEdit*self= getself<QTextEdit*> (context);
  19913. QTextDocument*document= self->document();
  19914. QPrinter printer;
  19915. QPrintDialog printwindow(&printer,self);
  19916. if(printwindow.exec()!=QDialog::Accepted)
  19917. {
  19918. return QScriptValue();
  19919. }
  19920. document->print(&printer);
  19921. return QScriptValue();
  19922. }
  19923. /*:686*//*687:*/
  19924. #line 14561 "./typica.w"
  19925. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  19926. {
  19927. setQAbstractScrollAreaProperties(value,engine);
  19928. value.setProperty("print",engine->newFunction(QTextEdit_print));
  19929. }
  19930. #line 1 "./plugins.w"
  19931. /*:687*//*712:*/
  19932. #line 463 "./daterangeselector.w"
  19933. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  19934. QStack<QLayout*> *layoutStack)
  19935. {
  19936. DateRangeSelector*widget= new DateRangeSelector;
  19937. if(element.hasAttribute("id"))
  19938. {
  19939. widget->setObjectName(element.attribute("id"));
  19940. }
  19941. if(element.hasAttribute("initial"))
  19942. {
  19943. widget->setCurrentIndex(element.attribute("initial").toInt());
  19944. }
  19945. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19946. layout->addWidget(widget);
  19947. }
  19948. /*:712*//*723:*/
  19949. #line 14743 "./typica.w"
  19950. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  19951. QStack<QLayout*> *layoutStack)
  19952. {
  19953. FormArray*widget= new FormArray(element);
  19954. if(element.hasAttribute("id"))
  19955. {
  19956. widget->setObjectName(element.attribute("id"));
  19957. }
  19958. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19959. layout->addWidget(widget);
  19960. }
  19961. /*:723*//*744:*/
  19962. #line 15330 "./typica.w"
  19963. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  19964. QStack<QLayout*> *layoutStack)
  19965. {
  19966. ScaleControl*scale= new ScaleControl;
  19967. if(element.hasAttribute("id"))
  19968. {
  19969. scale->setObjectName(element.attribute("id"));
  19970. }
  19971. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19972. layout->addWidget(scale);
  19973. }
  19974. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  19975. QStack<QLayout*> *layoutStack)
  19976. {
  19977. IntensityControl*scale= new IntensityControl;
  19978. if(element.hasAttribute("id"))
  19979. {
  19980. scale->setObjectName(element.attribute("id"));
  19981. }
  19982. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19983. layout->addWidget(scale);
  19984. }
  19985. /*:744*//*770:*/
  19986. #line 15920 "./typica.w"
  19987. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  19988. {
  19989. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  19990. setDeviceTreeModelProperties(object,engine);
  19991. return object;
  19992. }
  19993. /*:770*//*772:*/
  19994. #line 15943 "./typica.w"
  19995. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  19996. {
  19997. setQAbstractItemModelProperties(value,engine);
  19998. value.setProperty("referenceElement",
  19999. engine->newFunction(DeviceTreeModel_referenceElement));
  20000. }
  20001. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  20002. {
  20003. setQObjectProperties(value,engine);
  20004. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  20005. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  20006. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  20007. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  20008. }
  20009. /*:772*//*773:*/
  20010. #line 15970 "./typica.w"
  20011. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  20012. QScriptEngine*engine)
  20013. {
  20014. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  20015. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  20016. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  20017. QDomElement node;
  20018. QVariantMap retval;
  20019. retval.insert("driver",referenceElement.attribute("driver"));
  20020. for(int i= 0;i<configData.size();i++)
  20021. {
  20022. node= configData.at(i).toElement();
  20023. retval.insert(node.attribute("name"),node.attribute("value"));
  20024. }
  20025. return engine->toScriptValue(retval);
  20026. }
  20027. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  20028. {
  20029. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20030. QModelIndex index= argument<QModelIndex> (0,context);
  20031. int role= argument<int> (1,context);
  20032. return engine->toScriptValue(model->data(index,role));
  20033. }
  20034. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  20035. {
  20036. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20037. int row= 0;
  20038. int column= 0;
  20039. QModelIndex index;
  20040. if(context->argumentCount()> 1)
  20041. {
  20042. row= argument<int> (0,context);
  20043. column= argument<int> (1,context);
  20044. }
  20045. if(context->argumentCount()> 2)
  20046. {
  20047. index= argument<QModelIndex> (2,context);
  20048. }
  20049. QModelIndex retval= model->index(row,column,index);
  20050. return engine->toScriptValue(retval);
  20051. }
  20052. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  20053. QScriptEngine*)
  20054. {
  20055. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20056. QModelIndex index;
  20057. if(context->argumentCount()==1)
  20058. {
  20059. index= argument<QModelIndex> (0,context);
  20060. }
  20061. return QScriptValue(model->rowCount(index));
  20062. }
  20063. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  20064. QScriptEngine*engine)
  20065. {
  20066. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20067. QModelIndex index;
  20068. if(context->argumentCount()==1)
  20069. {
  20070. index= argument<QModelIndex> (0,context);
  20071. }
  20072. return QScriptValue(engine,model->hasChildren(index));
  20073. }
  20074. /*:773*//*776:*/
  20075. #line 16054 "./typica.w"
  20076. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  20077. {
  20078. QVariant var;
  20079. var.setValue(index);
  20080. QScriptValue object= engine->newVariant(var);
  20081. return object;
  20082. }
  20083. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  20084. {
  20085. index= value.toVariant().value<QModelIndex> ();
  20086. }
  20087. /*:776*//*792:*/
  20088. #line 16352 "./typica.w"
  20089. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  20090. QScriptEngine*engine)
  20091. {
  20092. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  20093. return object;
  20094. }
  20095. /*:792*//*863:*/
  20096. #line 47 "./settings.w"
  20097. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  20098. {
  20099. QScriptValue object= engine->newQObject(new SettingsWindow);
  20100. return object;
  20101. }
  20102. /*:863*//*888:*/
  20103. #line 19006 "./typica.w"
  20104. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  20105. {
  20106. QScriptValue object;
  20107. if(context->argumentCount()==2)
  20108. {
  20109. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  20110. argument<QModelIndex> (1,context)),
  20111. QScriptEngine::ScriptOwnership);
  20112. setModbusRTUDeviceProperties(object,engine);
  20113. }
  20114. else
  20115. {
  20116. context->throwError("Incorrect number of arguments passed to "
  20117. "ModbusRTUDevice constructor. This takes the configuration model "
  20118. "and an index.");
  20119. }
  20120. return object;
  20121. }
  20122. /*:888*//*889:*/
  20123. #line 19028 "./typica.w"
  20124. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  20125. {
  20126. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  20127. QScriptValue object;
  20128. if(self)
  20129. {
  20130. if(self->channels.size()> 0)
  20131. {
  20132. object= engine->newQObject(self->channels.at(0));
  20133. setChannelProperties(object,engine);
  20134. }
  20135. }
  20136. return object;
  20137. }
  20138. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  20139. {
  20140. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  20141. QScriptValue object;
  20142. if(self)
  20143. {
  20144. if(self->channels.size()> 1)
  20145. {
  20146. object= engine->newQObject(self->channels.at(1));
  20147. setChannelProperties(object,engine);
  20148. }
  20149. }
  20150. return object;
  20151. }
  20152. /*:889*//*890:*/
  20153. #line 19061 "./typica.w"
  20154. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  20155. {
  20156. setQObjectProperties(value,engine);
  20157. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  20158. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  20159. }
  20160. /*:890*//*906:*/
  20161. #line 713 "./modbus.w"
  20162. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  20163. {
  20164. QScriptValue object;
  20165. if(context->argumentCount()==2)
  20166. {
  20167. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  20168. argument<QModelIndex> (1,context)),
  20169. QScriptEngine::ScriptOwnership);
  20170. setModbusNGProperties(object,engine);
  20171. }
  20172. else
  20173. {
  20174. context->throwError("Incorrect number of arguments passed to "
  20175. "ModbusNG constructor.");
  20176. }
  20177. return object;
  20178. }
  20179. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  20180. {
  20181. setQObjectProperties(value,engine);
  20182. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  20183. }
  20184. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  20185. {
  20186. ModbusNG*self= getself<ModbusNG*> (context);
  20187. QScriptValue object;
  20188. if(self)
  20189. {
  20190. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20191. setChannelProperties(object,engine);
  20192. }
  20193. return object;
  20194. }
  20195. #line 19612 "./typica.w"
  20196. #line 1 "./unsupportedserial.w"
  20197. /*:906*//*920:*/
  20198. #line 357 "./unsupportedserial.w"
  20199. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  20200. {
  20201. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  20202. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  20203. QScriptValue object= engine->newQObject(device);
  20204. setQObjectProperties(object,engine);
  20205. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  20206. return object;
  20207. }
  20208. /*:920*//*925:*/
  20209. #line 430 "./unsupportedserial.w"
  20210. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  20211. {
  20212. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  20213. QScriptValue object;
  20214. if(self)
  20215. {
  20216. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20217. setChannelProperties(object,engine);
  20218. }
  20219. return object;
  20220. }
  20221. /*:925*//*932:*/
  20222. #line 630 "./unsupportedserial.w"
  20223. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  20224. {
  20225. return engine->toScriptValue<QTime> (QTime::currentTime());
  20226. }
  20227. /*:932*//*936:*/
  20228. #line 667 "./unsupportedserial.w"
  20229. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  20230. {
  20231. QScriptValue object= engine->newQObject(new QextSerialPort());
  20232. setSerialPortProperties(object,engine);
  20233. return object;
  20234. }
  20235. /*:936*//*937:*/
  20236. #line 678 "./unsupportedserial.w"
  20237. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  20238. {
  20239. setQIODeviceProperties(value,engine);
  20240. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  20241. }
  20242. /*:937*//*938:*/
  20243. #line 687 "./unsupportedserial.w"
  20244. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  20245. {
  20246. QextSerialPort*self= getself<QextSerialPort*> (context);
  20247. self->flush();
  20248. return QScriptValue();
  20249. }
  20250. #line 19614 "./typica.w"
  20251. #line 1 "./phidgets.w"
  20252. /*:938*//*959:*/
  20253. #line 463 "./phidgets.w"
  20254. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  20255. {
  20256. if(context->argumentCount()!=1)
  20257. {
  20258. context->throwError("Incorrect number of arguments passed to "
  20259. "PhidgetsTemperatureSensor constructor. This takes "
  20260. "a QModelIndex.");
  20261. }
  20262. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  20263. setQObjectProperties(object,engine);
  20264. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  20265. return object;
  20266. }
  20267. /*:959*//*960:*/
  20268. #line 480 "./phidgets.w"
  20269. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  20270. {
  20271. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  20272. QScriptValue object;
  20273. if(self)
  20274. {
  20275. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20276. setChannelProperties(object,engine);
  20277. }
  20278. return object;
  20279. }
  20280. #line 19616 "./typica.w"
  20281. /*:960*//*992:*/
  20282. #line 151 "./rate.w"
  20283. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  20284. {
  20285. int cachetime= 1;
  20286. int scaletime= 1;
  20287. if(context->argumentCount()> 0)
  20288. {
  20289. cachetime= argument<int> (0,context);
  20290. if(context->argumentCount()> 1)
  20291. {
  20292. scaletime= argument<int> (1,context);
  20293. }
  20294. }
  20295. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  20296. setRateOfChangeProperties(object,engine);
  20297. return object;
  20298. }
  20299. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  20300. {
  20301. setQObjectProperties(value,engine);
  20302. }
  20303. /*:992*//*1006:*/
  20304. #line 148 "./mergeseries.w"
  20305. QScriptValue constructDifferenceSeries(QScriptContext*,QScriptEngine*engine)
  20306. {
  20307. QScriptValue object= engine->newQObject(new DifferenceSeries);
  20308. setQObjectProperties(object,engine);
  20309. return object;
  20310. }
  20311. QScriptValue constructMeanSeries(QScriptContext*,QScriptEngine*engine)
  20312. {
  20313. QScriptValue object= engine->newQObject(new MeanSeries);
  20314. setQObjectProperties(object,engine);
  20315. return object;
  20316. }
  20317. /*:1006*//*1031:*/
  20318. #line 614 "./dataqsdk.w"
  20319. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  20320. {
  20321. QScriptValue object;
  20322. if(context->argumentCount()==1)
  20323. {
  20324. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  20325. QScriptEngine::ScriptOwnership);
  20326. setDataqSdkDeviceProperties(object,engine);
  20327. }
  20328. else
  20329. {
  20330. context->throwError("Incorrect number of arguments passed to "
  20331. "DataqSdkDevice. The constructor takes one string "
  20332. "as an argument specifying a device name. "
  20333. "Example: Dev1");
  20334. }
  20335. return object;
  20336. }
  20337. /*:1031*//*1032:*/
  20338. #line 637 "./dataqsdk.w"
  20339. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  20340. {
  20341. setQObjectProperties(value,engine);
  20342. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  20343. }
  20344. /*:1032*//*1033:*/
  20345. #line 647 "./dataqsdk.w"
  20346. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  20347. {
  20348. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  20349. QScriptValue object;
  20350. if(self)
  20351. {
  20352. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  20353. setChannelProperties(object,engine);
  20354. }
  20355. return object;
  20356. }
  20357. /*:1033*//*1058:*/
  20358. #line 80 "./scales.w"
  20359. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  20360. {
  20361. QScriptValue object;
  20362. QString labelText= "";
  20363. if(context->argumentCount()==1)
  20364. {
  20365. labelText= argument<QString> (0,context);
  20366. }
  20367. object= engine->newQObject(new DragLabel(labelText));
  20368. setDragLabelProperties(object,engine);
  20369. return object;
  20370. }
  20371. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  20372. {
  20373. setQLabelProperties(value,engine);
  20374. }
  20375. /*:1058*//*1068:*/
  20376. #line 298 "./scales.w"
  20377. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  20378. {
  20379. return engine->newVariant(QVariant((int)(value)));
  20380. }
  20381. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  20382. {
  20383. value= (BaudRateType)(sv.toVariant().toInt());
  20384. }
  20385. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  20386. {
  20387. return engine->newVariant(QVariant((int)(value)));
  20388. }
  20389. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  20390. {
  20391. value= (DataBitsType)(sv.toVariant().toInt());
  20392. }
  20393. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  20394. {
  20395. return engine->newVariant(QVariant((int)(value)));
  20396. }
  20397. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  20398. {
  20399. value= (ParityType)(sv.toVariant().toInt());
  20400. }
  20401. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  20402. {
  20403. return engine->newVariant(QVariant((int)(value)));
  20404. }
  20405. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  20406. {
  20407. value= (StopBitsType)(sv.toVariant().toInt());
  20408. }
  20409. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  20410. {
  20411. return engine->newVariant(QVariant((int)(value)));
  20412. }
  20413. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  20414. {
  20415. value= (FlowType)(sv.toVariant().toInt());
  20416. }
  20417. /*:1068*//*1071:*/
  20418. #line 367 "./scales.w"
  20419. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  20420. {
  20421. setQIODeviceProperties(value,engine);
  20422. }
  20423. /*:1071*//*1072:*/
  20424. #line 375 "./scales.w"
  20425. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  20426. {
  20427. QScriptValue object;
  20428. if(context->argumentCount()==1)
  20429. {
  20430. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  20431. setSerialScaleProperties(object,engine);
  20432. }
  20433. else
  20434. {
  20435. context->throwError("Incorrect number of arguments passed to "
  20436. "SerialScale. The constructor takes one string "
  20437. "as an argument specifying a port name.");
  20438. }
  20439. return object;
  20440. }
  20441. /*:1072*//*1094:*/
  20442. #line 278 "./valueannotation.w"
  20443. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  20444. {
  20445. QScriptValue object= engine->newQObject(new ValueAnnotation);
  20446. setValueAnnotationProperties(object,engine);
  20447. return object;
  20448. }
  20449. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  20450. {
  20451. setQObjectProperties(value,engine);
  20452. }
  20453. #line 20280 "./typica.w"
  20454. #line 1 "./thresholdannotation.w"
  20455. /*:1094*//*1105:*/
  20456. #line 208 "./thresholdannotation.w"
  20457. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  20458. {
  20459. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  20460. setAnnotatorProperties(object,engine);
  20461. return object;
  20462. }
  20463. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  20464. {
  20465. setQObjectProperties(value,engine);
  20466. }
  20467. #line 20282 "./typica.w"
  20468. #line 1 "./user.w"
  20469. /*:1105*//*1115:*/
  20470. #line 142 "./user.w"
  20471. QScriptValue constructLoginDialog(QScriptContext*,QScriptEngine*engine)
  20472. {
  20473. QScriptValue object= engine->newQObject(new LoginDialog);
  20474. return object;
  20475. }
  20476. /*:1115*//*1125:*/
  20477. #line 330 "./user.w"
  20478. QScriptValue constructNewTypicaUser(QScriptContext*,QScriptEngine*engine)
  20479. {
  20480. QScriptValue object= engine->newQObject(new NewTypicaUser);
  20481. return object;
  20482. }
  20483. /*:1125*/
  20484. #line 530 "./typica.w"
  20485. /*640:*/
  20486. #line 13660 "./typica.w"
  20487. void messageFileOutput(QtMsgType,const char*msg)
  20488. {
  20489. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  20490. output.open(QIODevice::WriteOnly|QIODevice::Append);
  20491. QTextStream outstream(&output);
  20492. outstream<<msg<<"\r\n";
  20493. }
  20494. /*:640*/
  20495. #line 531 "./typica.w"
  20496. /*637:*/
  20497. #line 13621 "./typica.w"
  20498. int main(int argc,char**argv)
  20499. {
  20500. int*c= &argc;
  20501. Application app(*c,argv);
  20502. QSettings settings;
  20503. /*638:*/
  20504. #line 13647 "./typica.w"
  20505. if(settings.value("settings/advanced/logging",false).toBool())
  20506. {
  20507. qInstallMsgHandler(messageFileOutput);
  20508. }
  20509. /*:638*/
  20510. #line 13627 "./typica.w"
  20511. /*641:*/
  20512. #line 13673 "./typica.w"
  20513. QStringList themeSearchPath= QIcon::themeSearchPaths();
  20514. themeSearchPath.append(":/resources/icons/tango");
  20515. QIcon::setThemeSearchPaths(themeSearchPath);
  20516. QIcon::setThemeName(":/resources/icons/tango");
  20517. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  20518. /*:641*/
  20519. #line 13628 "./typica.w"
  20520. /*642:*/
  20521. #line 13693 "./typica.w"
  20522. QFile entypo(":/resources/fonts/entypo.ttf");
  20523. entypo.open(QIODevice::ReadOnly);
  20524. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  20525. entypo.close();
  20526. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  20527. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  20528. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  20529. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  20530. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  20531. /*:642*/
  20532. #line 13629 "./typica.w"
  20533. /*802:*/
  20534. #line 16642 "./typica.w"
  20535. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  20536. /*:802*//*812:*/
  20537. #line 16884 "./typica.w"
  20538. app.registerDeviceConfigurationWidget("nidaqmxbase",
  20539. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  20540. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  20541. NiDaqMxBase9211ConfWidget::staticMetaObject);
  20542. app.registerDeviceConfigurationWidget("ni9211seriestc",
  20543. Ni9211TcConfWidget::staticMetaObject);
  20544. /*:812*//*820:*/
  20545. #line 17115 "./typica.w"
  20546. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  20547. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  20548. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  20549. /*:820*//*844:*/
  20550. #line 18084 "./typica.w"
  20551. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  20552. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  20553. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  20554. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  20555. /*:844*//*849:*/
  20556. #line 18169 "./typica.w"
  20557. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  20558. /*:849*//*852:*/
  20559. #line 18239 "./typica.w"
  20560. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  20561. /*:852*//*855:*/
  20562. #line 18366 "./typica.w"
  20563. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  20564. #line 1 "./freeannotation.w"
  20565. /*:855*//*859:*/
  20566. #line 57 "./freeannotation.w"
  20567. app.registerDeviceConfigurationWidget("freeannotation",
  20568. FreeAnnotationConfWidget::staticMetaObject);
  20569. #line 18370 "./typica.w"
  20570. #line 1 "./settings.w"
  20571. /*:859*//*893:*/
  20572. #line 19602 "./typica.w"
  20573. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  20574. /*:893*//*899:*/
  20575. #line 321 "./modbus.w"
  20576. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  20577. app.registerDeviceConfigurationWidget("modbusnginput",
  20578. ModbusNGInputConfWidget::staticMetaObject);
  20579. /*:899*//*915:*/
  20580. #line 264 "./unsupportedserial.w"
  20581. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  20582. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  20583. app.registerDeviceConfigurationWidget("unsupporteddevice",
  20584. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  20585. /*:915*//*946:*/
  20586. #line 181 "./phidgets.w"
  20587. app.registerDeviceConfigurationWidget("phidgets1048",
  20588. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  20589. app.registerDeviceConfigurationWidget("phidgets1048channel",
  20590. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  20591. /*:946*//*966:*/
  20592. #line 19738 "./typica.w"
  20593. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  20594. /*:966*//*969:*/
  20595. #line 19798 "./typica.w"
  20596. app.registerDeviceConfigurationWidget("coolingtimer",
  20597. CoolingTimerConfWidget::staticMetaObject);
  20598. /*:969*//*974:*/
  20599. #line 20057 "./typica.w"
  20600. app.registerDeviceConfigurationWidget("rangetimer",
  20601. RangeTimerConfWidget::staticMetaObject);
  20602. /*:974*//*979:*/
  20603. #line 20158 "./typica.w"
  20604. app.registerDeviceConfigurationWidget("multirangetimer",
  20605. MultiRangeTimerConfWidget::staticMetaObject);
  20606. /*:979*//*984:*/
  20607. #line 20268 "./typica.w"
  20608. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  20609. #line 1 "./rate.w"
  20610. /*:984*//*996:*/
  20611. #line 253 "./rate.w"
  20612. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  20613. /*:996*//*1010:*/
  20614. #line 266 "./mergeseries.w"
  20615. app.registerDeviceConfigurationWidget("mergeseries",
  20616. MergeSeriesConfWidget::staticMetaObject);
  20617. /*:1010*//*1051:*/
  20618. #line 1233 "./dataqsdk.w"
  20619. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  20620. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  20621. DataqSdkChannelConfWidget::staticMetaObject);
  20622. /*:1051*//*1076:*/
  20623. #line 552 "./scales.w"
  20624. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  20625. /*:1076*//*1084:*/
  20626. #line 138 "./valueannotation.w"
  20627. app.registerDeviceConfigurationWidget("valueannotation",
  20628. ValueAnnotationConfWidget::staticMetaObject);
  20629. /*:1084*//*1098:*/
  20630. #line 109 "./thresholdannotation.w"
  20631. app.registerDeviceConfigurationWidget("thresholdannotation",
  20632. ThresholdAnnotationConfWidget::staticMetaObject);
  20633. /*:1098*/
  20634. #line 13631 "./typica.w"
  20635. /*643:*/
  20636. #line 13710 "./typica.w"
  20637. if(settings.value("database/exists","false").toString()=="true")
  20638. {
  20639. /*648:*/
  20640. #line 13845 "./typica.w"
  20641. QSqlDatabase database=
  20642. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  20643. database.setConnectOptions("application_name=Typica");
  20644. database.setHostName(settings.value("database/hostname").toString());
  20645. database.setPort(settings.value("database/portnumber",5432).toInt());
  20646. database.setDatabaseName(settings.value("database/dbname").toString());
  20647. database.setUserName(settings.value("database/user").toString());
  20648. database.setPassword(settings.value("database/password").toString());
  20649. if(!database.open())
  20650. {
  20651. settings.setValue("database/exists","false");
  20652. }
  20653. else
  20654. {
  20655. database.close();
  20656. AppInstance->setDatabaseConnected(true);
  20657. }
  20658. /*:648*/
  20659. #line 13713 "./typica.w"
  20660. }
  20661. if(settings.value("database/exists","false").toString()=="false")
  20662. {
  20663. /*647:*/
  20664. #line 13836 "./typica.w"
  20665. SqlConnectionSetup dialog;
  20666. dialog.exec();
  20667. /*:647*/
  20668. #line 13717 "./typica.w"
  20669. }
  20670. /*:643*/
  20671. #line 13632 "./typica.w"
  20672. /*192:*/
  20673. #line 4406 "./typica.w"
  20674. QStringList arguments= QCoreApplication::arguments();
  20675. int position= arguments.indexOf("-c");
  20676. QString filename= QString();
  20677. if(position!=-1)
  20678. {
  20679. if(arguments.size()>=position+1)
  20680. {
  20681. filename= arguments.at(position+1);
  20682. }
  20683. }else{
  20684. QDir checkPath(QCoreApplication::applicationDirPath()+"/../config/");
  20685. if(checkPath.exists("config.xml")){
  20686. filename= checkPath.filePath("config.xml");
  20687. }else{
  20688. checkPath= QDir(QCoreApplication::applicationDirPath()+"/config/");
  20689. if(checkPath.exists("config.xml")){
  20690. filename= checkPath.filePath("config.xml");
  20691. }
  20692. }
  20693. }
  20694. if(filename.isEmpty())
  20695. {
  20696. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  20697. settings.value("config","").toString());
  20698. }
  20699. QDir directory;
  20700. if(!filename.isEmpty())
  20701. {
  20702. QFile file(filename);
  20703. QFileInfo info(filename);
  20704. directory= info.dir();
  20705. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  20706. QTranslator*configtr= new QTranslator;
  20707. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  20708. QString("%1/Translations").arg(directory.canonicalPath())))
  20709. {
  20710. QCoreApplication::installTranslator(configtr);
  20711. }
  20712. settings.setValue("config",directory.path());
  20713. if(file.open(QIODevice::ReadOnly))
  20714. {
  20715. app.configuration()->setContent(&file,true);
  20716. }
  20717. }else{
  20718. return 1;
  20719. }
  20720. /*193:*/
  20721. #line 4459 "./typica.w"
  20722. QDomElement root= app.configuration()->documentElement();
  20723. QDomNodeList children= root.childNodes();
  20724. QString replacementDoc;
  20725. QDomDocument includedDoc;
  20726. QDomDocumentFragment fragment;
  20727. for(int i= 0;i<children.size();i++)
  20728. {
  20729. QDomNode currentNode= children.at(i);
  20730. QDomElement currentElement;
  20731. if(currentNode.nodeName()=="include")
  20732. {
  20733. currentElement= currentNode.toElement();
  20734. if(currentElement.hasAttribute("src"))
  20735. {
  20736. replacementDoc= directory.path();
  20737. replacementDoc.append('/');
  20738. replacementDoc.append(currentElement.attribute("src"));
  20739. QFile doc(replacementDoc);
  20740. if(doc.open(QIODevice::ReadOnly))
  20741. {
  20742. includedDoc.setContent(&doc,true);
  20743. fragment= includedDoc.createDocumentFragment();
  20744. fragment.appendChild(includedDoc.documentElement());
  20745. root.replaceChild(fragment,currentNode);
  20746. doc.close();
  20747. }
  20748. }
  20749. }
  20750. }
  20751. /*:193*/
  20752. #line 4453 "./typica.w"
  20753. /*:192*/
  20754. #line 13633 "./typica.w"
  20755. /*7:*/
  20756. #line 663 "./typica.w"
  20757. QScriptEngine*engine= new QScriptEngine;
  20758. QScriptValue constructor;
  20759. QScriptValue value;
  20760. /*:7*//*17:*/
  20761. #line 866 "./typica.w"
  20762. constructor= engine->newFunction(constructQTimer);
  20763. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  20764. engine->globalObject().setProperty("Timer",value);
  20765. /*:17*//*20:*/
  20766. #line 905 "./typica.w"
  20767. constructor= engine->newFunction(constructQWidget);
  20768. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  20769. engine->globalObject().setProperty("QWidget",value);
  20770. /*:20*//*24:*/
  20771. #line 992 "./typica.w"
  20772. constructor= engine->newFunction(displayWarning);
  20773. engine->globalObject().setProperty("displayWarning",constructor);
  20774. constructor= engine->newFunction(displayError);
  20775. engine->globalObject().setProperty("displayError",constructor);
  20776. /*:24*//*34:*/
  20777. #line 1221 "./typica.w"
  20778. constructor= engine->newFunction(constructQMainWindow);
  20779. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  20780. constructor);
  20781. engine->globalObject().setProperty("QMainWindow",value);
  20782. /*:34*//*45:*/
  20783. #line 1426 "./typica.w"
  20784. constructor= engine->newFunction(constructQFrame);
  20785. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  20786. engine->globalObject().setProperty("QFrame",value);
  20787. /*:45*//*48:*/
  20788. #line 1459 "./typica.w"
  20789. constructor= engine->newFunction(constructQLabel);
  20790. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  20791. engine->globalObject().setProperty("QLabel",value);
  20792. /*:48*//*51:*/
  20793. #line 1502 "./typica.w"
  20794. constructor= engine->newFunction(constructQSvgWidget);
  20795. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  20796. engine->globalObject().setProperty("QSvgWidget",value);
  20797. /*:51*//*57:*/
  20798. #line 1584 "./typica.w"
  20799. constructor= engine->newFunction(constructQLineEdit);
  20800. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  20801. engine->globalObject().setProperty("QLineEdit",value);
  20802. /*:57*//*61:*/
  20803. #line 1631 "./typica.w"
  20804. constructor= engine->newFunction(constructQSplitter);
  20805. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  20806. engine->globalObject().setProperty("QSplitter",value);
  20807. /*:61*//*69:*/
  20808. #line 1820 "./typica.w"
  20809. constructor= engine->newFunction(constructQBoxLayout);
  20810. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  20811. engine->globalObject().setProperty("QBoxLayout",value);
  20812. /*:69*//*73:*/
  20813. #line 1932 "./typica.w"
  20814. constructor= engine->newFunction(constructQAction);
  20815. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  20816. engine->globalObject().setProperty("QAction",value);
  20817. /*:73*//*76:*/
  20818. #line 1991 "./typica.w"
  20819. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  20820. value.setProperty("getOpenFileName",
  20821. engine->newFunction(QFileDialog_getOpenFileName));
  20822. value.setProperty("getSaveFileName",
  20823. engine->newFunction(QFileDialog_getSaveFileName));
  20824. engine->globalObject().setProperty("QFileDialog",value);
  20825. /*:76*//*81:*/
  20826. #line 2109 "./typica.w"
  20827. constructor= engine->newFunction(constructQFile);
  20828. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  20829. engine->globalObject().setProperty("QFile",value);
  20830. /*:81*//*92:*/
  20831. #line 2327 "./typica.w"
  20832. constructor= engine->newFunction(constructQProcess);
  20833. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  20834. engine->globalObject().setProperty("QProcess",value);
  20835. /*:92*//*101:*/
  20836. #line 2476 "./typica.w"
  20837. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  20838. constructor= engine->newFunction(constructQByteArray);
  20839. engine->globalObject().setProperty("QByteArray",constructor);
  20840. /*:101*//*113:*/
  20841. #line 2718 "./typica.w"
  20842. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  20843. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  20844. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  20845. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  20846. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  20847. /*:113*//*116:*/
  20848. #line 2821 "./typica.w"
  20849. constructor= engine->newFunction(constructQBuffer);
  20850. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  20851. engine->globalObject().setProperty("QBuffer",value);
  20852. /*:116*//*119:*/
  20853. #line 2870 "./typica.w"
  20854. constructor= engine->newFunction(constructXQuery);
  20855. engine->globalObject().setProperty("XQuery",constructor);
  20856. /*:119*//*125:*/
  20857. #line 2972 "./typica.w"
  20858. constructor= engine->newFunction(constructXmlWriter);
  20859. engine->globalObject().setProperty("XmlWriter",constructor);
  20860. /*:125*//*134:*/
  20861. #line 3178 "./typica.w"
  20862. constructor= engine->newFunction(constructXmlReader);
  20863. engine->globalObject().setProperty("XmlReader",constructor);
  20864. /*:134*//*141:*/
  20865. #line 3302 "./typica.w"
  20866. value= engine->newQObject(&settings);
  20867. setQSettingsProperties(value,engine);
  20868. engine->globalObject().setProperty("QSettings",value);
  20869. /*:141*//*145:*/
  20870. #line 3383 "./typica.w"
  20871. constructor= engine->newFunction(constructQLCDNumber);
  20872. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  20873. engine->globalObject().setProperty("QLCDNumber",value);
  20874. /*:145*//*148:*/
  20875. #line 3439 "./typica.w"
  20876. constructor= engine->newFunction(constructQTime);
  20877. engine->globalObject().setProperty("QTime",constructor);
  20878. /*:148*//*170:*/
  20879. #line 3952 "./typica.w"
  20880. constructor= engine->newFunction(constructQPushButton);
  20881. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  20882. engine->globalObject().setProperty("QPushButton",value);
  20883. /*:170*//*177:*/
  20884. #line 4063 "./typica.w"
  20885. constructor= engine->newFunction(constructQSqlQuery);
  20886. engine->globalObject().setProperty("QSqlQuery",constructor);
  20887. /*:177*//*184:*/
  20888. #line 4227 "./typica.w"
  20889. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  20890. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  20891. engine->globalObject().setProperty("sqlToArray",
  20892. engine->newFunction(sqlToArray));
  20893. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  20894. engine->globalObject().setProperty("annotationFromRecord",
  20895. engine->newFunction(annotationFromRecord));
  20896. engine->globalObject().setProperty("setTabOrder",
  20897. engine->newFunction(setTabOrder));
  20898. engine->globalObject().setProperty("saveFileFromDatabase",
  20899. engine->newFunction(saveFileFromDatabase));
  20900. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  20901. /*:184*//*197:*/
  20902. #line 4628 "./typica.w"
  20903. engine->globalObject().setProperty("createWindow",
  20904. engine->newFunction(createWindow));
  20905. engine->globalObject().setProperty("createReport",
  20906. engine->newFunction(createReport));
  20907. /*:197*//*222:*/
  20908. #line 5000 "./typica.w"
  20909. constructor= engine->newFunction(constructQTabBar);
  20910. value= engine->newQMetaObject(&QTabBar::staticMetaObject,constructor);
  20911. engine->globalObject().setProperty("QTabBar",value);
  20912. /*:222*//*271:*/
  20913. #line 6386 "./typica.w"
  20914. engine->globalObject().setProperty("findChildObject",
  20915. engine->newFunction(findChildObject));
  20916. /*:271*//*297:*/
  20917. #line 389 "./units.w"
  20918. value= engine->newQMetaObject(&Units::staticMetaObject);
  20919. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  20920. value.setProperty("convertRelativeTemperature",
  20921. engine->newFunction(Units_convertRelativeTemperature));
  20922. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  20923. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  20924. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  20925. engine->globalObject().setProperty("Units",value);
  20926. /*:297*//*302:*/
  20927. #line 462 "./units.w"
  20928. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  20929. #line 6818 "./typica.w"
  20930. /*:302*//*310:*/
  20931. #line 141 "./measurement.w"
  20932. constructor= engine->newFunction(constructMeasurement);
  20933. engine->globalObject().setProperty("Measurement",constructor);
  20934. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  20935. /*:310*//*330:*/
  20936. #line 7389 "./typica.w"
  20937. constructor= engine->newFunction(constructDAQ);
  20938. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  20939. value.setProperty("Fahrenheit",Units::Fahrenheit);
  20940. value.setProperty("Celsius",Units::Celsius);
  20941. value.setProperty("Kelvin",Units::Kelvin);
  20942. value.setProperty("Rankine",Units::Rankine);
  20943. engine->globalObject().setProperty("DAQ",value);
  20944. /*:330*//*339:*/
  20945. #line 7591 "./typica.w"
  20946. constructor= engine->newFunction(constructFakeDAQ);
  20947. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  20948. engine->globalObject().setProperty("FakeDAQ",value);
  20949. /*:339*//*350:*/
  20950. #line 7874 "./typica.w"
  20951. constructor= engine->newFunction(constructLinearCalibrator);
  20952. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  20953. constructor);
  20954. engine->globalObject().setProperty("LinearCalibrator",value);
  20955. /*:350*//*355:*/
  20956. #line 8013 "./typica.w"
  20957. constructor= engine->newFunction(constructLinearSplineInterpolator);
  20958. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  20959. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  20960. /*:355*//*365:*/
  20961. #line 8221 "./typica.w"
  20962. constructor= engine->newFunction(constructTemperatureDisplay);
  20963. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  20964. constructor);
  20965. engine->globalObject().setProperty("TemperatureDisplay",value);
  20966. /*:365*//*373:*/
  20967. #line 8379 "./typica.w"
  20968. constructor= engine->newFunction(constructMeasurementTimeOffset);
  20969. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  20970. constructor);
  20971. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  20972. /*:373*//*378:*/
  20973. #line 8500 "./typica.w"
  20974. constructor= engine->newFunction(constructThresholdDetector);
  20975. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  20976. engine->globalObject().setProperty("ThresholdDetector",value);
  20977. /*:378*//*383:*/
  20978. #line 8599 "./typica.w"
  20979. constructor= engine->newFunction(constructZeroEmitter);
  20980. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  20981. engine->globalObject().setProperty("ZeroEmitter",value);
  20982. /*:383*//*388:*/
  20983. #line 8678 "./typica.w"
  20984. constructor= engine->newFunction(constructMeasurementAdapter);
  20985. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  20986. constructor);
  20987. engine->globalObject().setProperty("MeasurementAdapter",value);
  20988. /*:388*//*405:*/
  20989. #line 9141 "./typica.w"
  20990. constructor= engine->newFunction(constructGraphView);
  20991. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  20992. engine->globalObject().setProperty("GraphView",value);
  20993. /*:405*//*428:*/
  20994. #line 9790 "./typica.w"
  20995. constructor= engine->newFunction(constructZoomLog);
  20996. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  20997. engine->globalObject().setProperty("ZoomLog",value);
  20998. /*:428*//*466:*/
  20999. #line 10738 "./typica.w"
  21000. constructor= engine->newFunction(constructAnnotationButton);
  21001. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  21002. constructor);
  21003. engine->globalObject().setProperty("AnnotationButton",value);
  21004. /*:466*//*474:*/
  21005. #line 10880 "./typica.w"
  21006. constructor= engine->newFunction(constructAnnotationSpinBox);
  21007. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  21008. constructor);
  21009. engine->globalObject().setProperty("AnnotationSpinBox",value);
  21010. /*:474*//*495:*/
  21011. #line 11305 "./typica.w"
  21012. constructor= engine->newFunction(constructTimerDisplay);
  21013. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  21014. engine->globalObject().setProperty("TimerDisplay",value);
  21015. /*:495*//*523:*/
  21016. #line 11829 "./typica.w"
  21017. constructor= engine->newFunction(constructWidgetDecorator);
  21018. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  21019. engine->globalObject().setProperty("WidgetDecorator",value);
  21020. /*:523*//*536:*/
  21021. #line 12111 "./typica.w"
  21022. constructor= engine->newFunction(constructLogEditWindow);
  21023. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  21024. engine->globalObject().setProperty("LogEditWindow",value);
  21025. /*:536*//*555:*/
  21026. #line 12638 "./typica.w"
  21027. constructor= engine->newFunction(constructXMLInput);
  21028. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  21029. engine->globalObject().setProperty("XMLInput",value);
  21030. /*:555*//*570:*/
  21031. #line 164 "./webview.w"
  21032. constructor= engine->newFunction(constructWebView);
  21033. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  21034. engine->globalObject().setProperty("WebView",value);
  21035. /*:570*//*578:*/
  21036. #line 256 "./webview.w"
  21037. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  21038. /*:578*//*581:*/
  21039. #line 298 "./webview.w"
  21040. constructor= engine->newFunction(constructWebElement);
  21041. engine->globalObject().setProperty("WebElement",constructor);
  21042. /*:581*//*593:*/
  21043. #line 76 "./printerselector.w"
  21044. constructor= engine->newFunction(constructPrinterSelector);
  21045. engine->globalObject().setProperty("PrinterSelector",constructor);
  21046. /*:593*//*601:*/
  21047. #line 12894 "./typica.w"
  21048. value= engine->newQObject(AppInstance);
  21049. engine->globalObject().setProperty("Application",value);
  21050. /*:601*//*660:*/
  21051. #line 14024 "./typica.w"
  21052. constructor= engine->newFunction(constructSqlQueryView);
  21053. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  21054. engine->globalObject().setProperty("SqlQueryView",value);
  21055. /*:660*//*771:*/
  21056. #line 15930 "./typica.w"
  21057. constructor= engine->newFunction(constructDeviceTreeModel);
  21058. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  21059. constructor);
  21060. engine->globalObject().setProperty("DeviceTreeModel",value);
  21061. /*:771*//*777:*/
  21062. #line 16070 "./typica.w"
  21063. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  21064. /*:777*//*793:*/
  21065. #line 16362 "./typica.w"
  21066. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  21067. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  21068. constructor);
  21069. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  21070. /*:793*//*864:*/
  21071. #line 56 "./settings.w"
  21072. constructor= engine->newFunction(constructSettingsWindow);
  21073. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  21074. engine->globalObject().setProperty("SettingsWindow",value);
  21075. #line 1 "./graphsettings.w"
  21076. /*:864*//*887:*/
  21077. #line 18997 "./typica.w"
  21078. constructor= engine->newFunction(constructModbusRTUDevice);
  21079. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  21080. engine->globalObject().setProperty("ModbusRTUDevice",value);
  21081. /*:887*//*905:*/
  21082. #line 705 "./modbus.w"
  21083. constructor= engine->newFunction(constructModbusNG);
  21084. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  21085. engine->globalObject().setProperty("ModbusNG",value);
  21086. /*:905*//*919:*/
  21087. #line 350 "./unsupportedserial.w"
  21088. engine->globalObject().setProperty("createDevice",
  21089. engine->newFunction(createDevice));
  21090. /*:919*//*931:*/
  21091. #line 622 "./unsupportedserial.w"
  21092. engine->globalObject().setProperty("getMeasurementTimestamp",
  21093. engine->newFunction(getMeasurementTimestamp));
  21094. /*:931*//*935:*/
  21095. #line 658 "./unsupportedserial.w"
  21096. constructor= engine->newFunction(constructSerialPort);
  21097. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  21098. engine->globalObject().setProperty("SerialPort",value);
  21099. /*:935*//*957:*/
  21100. #line 450 "./phidgets.w"
  21101. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  21102. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  21103. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  21104. /*:957*//*991:*/
  21105. #line 144 "./rate.w"
  21106. constructor= engine->newFunction(constructRateOfChange);
  21107. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  21108. engine->globalObject().setProperty("RateOfChange",value);
  21109. /*:991*//*1005:*/
  21110. #line 137 "./mergeseries.w"
  21111. constructor= engine->newFunction(constructDifferenceSeries);
  21112. value= engine->newQMetaObject(&DifferenceSeries::staticMetaObject,
  21113. constructor);
  21114. engine->globalObject().setProperty("DifferenceSeries",value);
  21115. constructor= engine->newFunction(constructMeanSeries);
  21116. value= engine->newQMetaObject(&MeanSeries::staticMetaObject,constructor);
  21117. engine->globalObject().setProperty("MeanSeries",value);
  21118. /*:1005*//*1030:*/
  21119. #line 604 "./dataqsdk.w"
  21120. constructor= engine->newFunction(constructDataqSdkDevice);
  21121. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  21122. engine->globalObject().setProperty("DataqSdkDevice",value);
  21123. /*:1030*//*1057:*/
  21124. #line 73 "./scales.w"
  21125. constructor= engine->newFunction(constructDragLabel);
  21126. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  21127. engine->globalObject().setProperty("DragLabel",value);
  21128. /*:1057*//*1065:*/
  21129. #line 265 "./scales.w"
  21130. constructor= engine->newFunction(constructSerialScale);
  21131. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  21132. engine->globalObject().setProperty("SerialScale",value);
  21133. /*:1065*//*1069:*/
  21134. #line 351 "./scales.w"
  21135. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  21136. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  21137. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  21138. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  21139. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  21140. /*:1069*//*1093:*/
  21141. #line 271 "./valueannotation.w"
  21142. constructor= engine->newFunction(constructValueAnnotation);
  21143. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  21144. engine->globalObject().setProperty("ValueAnnotation",value);
  21145. /*:1093*//*1104:*/
  21146. #line 201 "./thresholdannotation.w"
  21147. constructor= engine->newFunction(constructAnnotator);
  21148. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  21149. engine->globalObject().setProperty("Annotator",value);
  21150. /*:1104*//*1114:*/
  21151. #line 135 "./user.w"
  21152. constructor= engine->newFunction(constructLoginDialog);
  21153. value= engine->newQMetaObject(&LoginDialog::staticMetaObject,constructor);
  21154. engine->globalObject().setProperty("LoginDialog",value);
  21155. /*:1114*//*1124:*/
  21156. #line 323 "./user.w"
  21157. constructor= engine->newFunction(constructNewTypicaUser);
  21158. value= engine->newQMetaObject(&NewTypicaUser::staticMetaObject,constructor);
  21159. engine->globalObject().setProperty("NewTypicaUser",value);
  21160. /*:1124*/
  21161. #line 13634 "./typica.w"
  21162. app.engine= engine;
  21163. /*194:*/
  21164. #line 4507 "./typica.w"
  21165. QString styleText;
  21166. QString programText;
  21167. QDomElement currentElement;
  21168. for(int i= 0;i<children.size();i++)
  21169. {
  21170. QDomNode currentNode= children.at(i);
  21171. if(currentNode.nodeName()=="style")
  21172. {
  21173. currentElement= currentNode.toElement();
  21174. styleText.append(currentElement.text());
  21175. }
  21176. else if(currentNode.nodeName()=="program")
  21177. {
  21178. currentElement= currentNode.toElement();
  21179. programText.append(currentElement.text());
  21180. }
  21181. }
  21182. app.setStyleSheet(styleText);
  21183. QScriptValue result= engine->evaluate(programText);
  21184. /*195:*/
  21185. #line 4532 "./typica.w"
  21186. if(engine->hasUncaughtException())
  21187. {
  21188. int line= engine->uncaughtExceptionLineNumber();
  21189. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  21190. result.toString();
  21191. QString trace;
  21192. foreach(trace,engine->uncaughtExceptionBacktrace())
  21193. {
  21194. qDebug()<<trace;
  21195. }
  21196. }
  21197. /*:195*/
  21198. #line 4527 "./typica.w"
  21199. /*:194*/
  21200. #line 13636 "./typica.w"
  21201. int retval= app.exec();
  21202. delete engine;
  21203. return retval;
  21204. }
  21205. /*:637*/
  21206. #line 532 "./typica.w"
  21207. #include "moc_typica.cpp"
  21208. /*:3*/