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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 616 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. /*:5*//*6:*/
  17. #line 632 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*291:*/
  20. #line 6604 "./typica.w"
  21. #include "units.h"
  22. #line 1 "./measurement.w"
  23. /*:291*//*561:*/
  24. #line 197 "./webview.w"
  25. #include "webview.h"
  26. /*:561*//*574:*/
  27. #line 375 "./webview.w"
  28. #include "webelement.h"
  29. #line 12570 "./typica.w"
  30. /*:574*//*685:*/
  31. #line 487 "./daterangeselector.w"
  32. #include "daterangeselector.h"
  33. #line 14296 "./typica.w"
  34. /*:685*//*793:*/
  35. #line 16867 "./typica.w"
  36. #include "qextserialport.h"
  37. #include "qextserialenumerator.h"
  38. /*:793*//*964:*/
  39. #line 124 "./dataqsdk.w"
  40. #ifdef Q_OS_WIN32
  41. #include <windef.h>
  42. #else
  43. #define PASCAL
  44. #endif
  45. /*:964*//*988:*/
  46. #line 862 "./dataqsdk.w"
  47. #include <limits>
  48. /*:988*//*1003:*/
  49. #line 62 "./scales.w"
  50. #include "draglabel.h"
  51. /*:1003*//*1018:*/
  52. #line 335 "./scales.w"
  53. #include "scale.h"
  54. /*:1018*/
  55. #line 525 "./typica.w"
  56. /*23:*/
  57. #line 994 "./typica.w"
  58. class ScriptQMainWindow:public QMainWindow
  59. {
  60. Q_OBJECT
  61. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  62. public:
  63. ScriptQMainWindow();
  64. QString closePrompt();
  65. public slots:
  66. void show();
  67. void saveSizeAndPosition(const QString&key);
  68. void restoreSizeAndPosition(const QString&key);
  69. void displayStatus(const QString&message= QString());
  70. void setClosePrompt(QString prompt);
  71. protected:
  72. void closeEvent(QCloseEvent*event);
  73. void showEvent(QShowEvent*event);
  74. signals:
  75. void aboutToClose(void);
  76. private:
  77. QString cprompt;
  78. };
  79. /*:23*//*169:*/
  80. #line 3918 "./typica.w"
  81. class SqlQueryConnection:public QSqlQuery
  82. {
  83. public:
  84. SqlQueryConnection(const QString&query= QString());
  85. ~SqlQueryConnection();
  86. QSqlQuery*operator->()const;
  87. private:
  88. QString connection;
  89. QSqlQuery*q;
  90. };
  91. /*:169*//*240:*/
  92. #line 5806 "./typica.w"
  93. class NumericDelegate:public QItemDelegate
  94. {
  95. Q_OBJECT
  96. public:
  97. NumericDelegate(QObject*parent= NULL);
  98. QWidget*createEditor(QWidget*parent,
  99. const QStyleOptionViewItem&option,
  100. const QModelIndex&index)const;
  101. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  102. void setModelData(QWidget*editor,QAbstractItemModel*model,
  103. const QModelIndex&index)const;
  104. void updateEditorGeometry(QWidget*editor,
  105. const QStyleOptionViewItem&option,
  106. const QModelIndex&index)const;
  107. };
  108. /*:240*//*246:*/
  109. #line 5899 "./typica.w"
  110. class ScriptValidator:public QValidator
  111. {
  112. Q_OBJECT
  113. public:
  114. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  115. void fixup(QString&input)const;
  116. QValidator::State validate(QString&input,int&pos)const;
  117. private:
  118. QValidator*v;
  119. };
  120. /*:246*//*287:*/
  121. #line 438 "./units.w"
  122. Q_DECLARE_METATYPE(Units::Unit)
  123. /*:287*//*292:*/
  124. #line 19 "./measurement.w"
  125. class Measurement:public QVariantMap
  126. {
  127. public:
  128. Measurement(double temperature= 0,QTime time= QTime(),
  129. Units::Unit sc= Units::Fahrenheit);
  130. Measurement(double temperature);
  131. double temperature()const;
  132. QTime time()const;
  133. void setTemperature(double temperature);
  134. void setTime(QTime time);
  135. void setUnit(Units::Unit scale);
  136. Units::Unit scale()const;
  137. Measurement toFahrenheit();
  138. Measurement toCelsius();
  139. Measurement toKelvin();
  140. Measurement toRankine();
  141. };
  142. /*:292*//*296:*/
  143. #line 128 "./measurement.w"
  144. Q_DECLARE_METATYPE(Measurement)
  145. /*:296*//*303:*/
  146. #line 6668 "./typica.w"
  147. class Channel;
  148. class DAQImplementation;
  149. class DAQ:public QObject
  150. {
  151. Q_OBJECT
  152. Q_ENUMS(ThermocoupleType)
  153. DAQImplementation*imp;
  154. private slots:
  155. void threadFinished();
  156. public:
  157. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  158. ~DAQ();
  159. Channel*newChannel(int units,int thermocouple);
  160. Q_INVOKABLE void setClockRate(double Hz);
  161. Q_INVOKABLE void start();
  162. Q_INVOKABLE void stop();
  163. enum ThermocoupleType
  164. {
  165. TypeJ= 10072,
  166. TypeK= 10073,
  167. TypeN= 10077,
  168. TypeR= 10082,
  169. TypeS= 10085,
  170. TypeT= 10086,
  171. TypeB= 10047,
  172. TypeE= 10055
  173. };
  174. };
  175. /*:303*//*304:*/
  176. #line 6706 "./typica.w"
  177. class DAQImplementation:public QThread
  178. {
  179. Q_OBJECT
  180. public:
  181. DAQImplementation(const QString&driverinfo);
  182. ~DAQImplementation();
  183. void run();
  184. void measure();
  185. /*305:*/
  186. #line 6726 "./typica.w"
  187. typedef int(*daqfp)(...);
  188. daqfp read;
  189. daqfp errorInfo;
  190. daqfp startTask;
  191. daqfp createTask;
  192. daqfp createChannel;
  193. daqfp setClock;
  194. daqfp stopTask;
  195. daqfp clearTask;
  196. daqfp resetDevice;
  197. daqfp waitForMeasurement;
  198. /*:305*/
  199. #line 6715 "./typica.w"
  200. /*306:*/
  201. #line 6742 "./typica.w"
  202. bool useBase;
  203. QString device;
  204. QVector<Channel*> channelMap;
  205. unsigned int handle;
  206. int error;
  207. int channels;
  208. bool ready;
  209. QLibrary driver;
  210. QVector<Units::Unit> unitMap;
  211. /*:306*/
  212. #line 6716 "./typica.w"
  213. };
  214. /*:304*//*322:*/
  215. #line 7247 "./typica.w"
  216. class FakeDAQImplementation:public QThread
  217. {
  218. Q_OBJECT
  219. public:
  220. FakeDAQImplementation();
  221. ~FakeDAQImplementation();
  222. void run();
  223. void measure();
  224. QVector<Channel*> channelMap;
  225. int channels;
  226. bool ready;
  227. double clockRate;
  228. };
  229. class FakeDAQ:public QObject
  230. {
  231. Q_OBJECT
  232. FakeDAQImplementation*imp;
  233. public:
  234. FakeDAQ(QString device);
  235. ~FakeDAQ();
  236. Channel*newChannel(int units,int thermocouple);
  237. Q_INVOKABLE void setClockRate(double Hz);
  238. Q_INVOKABLE void start();
  239. };
  240. /*:322*//*329:*/
  241. #line 7434 "./typica.w"
  242. class Channel:public QObject
  243. {
  244. Q_OBJECT
  245. public:
  246. Channel();
  247. ~Channel();
  248. public slots:
  249. void input(Measurement measurement);
  250. signals:
  251. void newData(Measurement);
  252. };
  253. /*:329*//*333:*/
  254. #line 7501 "./typica.w"
  255. class LinearCalibrator:public QObject
  256. {
  257. Q_OBJECT
  258. Q_PROPERTY(double measuredLower READ measuredLower
  259. WRITE setMeasuredLower)
  260. Q_PROPERTY(double measuredUpper READ measuredUpper
  261. WRITE setMeasuredUpper)
  262. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  263. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  264. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  265. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  266. public:
  267. LinearCalibrator(QObject*parent= NULL);
  268. double measuredLower();
  269. double measuredUpper();
  270. double mappedLower();
  271. double mappedUpper();
  272. bool isClosedRange();
  273. double sensitivity();
  274. public slots:
  275. void setMeasuredLower(double lower);
  276. void setMeasuredUpper(double upper);
  277. void setMappedLower(double lower);
  278. void setMappedUpper(double upper);
  279. void setClosedRange(bool closed);
  280. void setSensitivity(double sensitivity);
  281. Measurement newMeasurement(Measurement measure);
  282. signals:
  283. void measurement(Measurement measure);
  284. void newData(Measurement measure);
  285. private:
  286. double Lo1;
  287. double Lo2;
  288. double Up1;
  289. double Up2;
  290. double sensitivitySetting;
  291. bool clamp;
  292. };
  293. /*:333*//*340:*/
  294. #line 7697 "./typica.w"
  295. class LinearSplineInterpolator:public QObject
  296. {
  297. Q_OBJECT
  298. public:
  299. LinearSplineInterpolator(QObject*parent= NULL);
  300. Q_INVOKABLE void add_pair(double source,double destination);
  301. public slots:
  302. Measurement newMeasurement(Measurement measure);
  303. signals:
  304. void newData(Measurement measure);
  305. private:
  306. void make_interpolators();
  307. QMap<double,double> *pairs;
  308. QList<LinearCalibrator*> *interpolators;
  309. };
  310. /*:340*//*345:*/
  311. #line 7833 "./typica.w"
  312. class TemperatureDisplay:public QLCDNumber
  313. {
  314. Q_OBJECT
  315. int unit;
  316. bool r;
  317. public:
  318. TemperatureDisplay(QWidget*parent= NULL);
  319. ~TemperatureDisplay();
  320. public slots:
  321. void setValue(Measurement temperature);
  322. void invalidate();
  323. void setDisplayUnits(Units::Unit scale);
  324. void setRelativeMode(bool relative);
  325. };
  326. /*:345*//*356:*/
  327. #line 8052 "./typica.w"
  328. class MeasurementTimeOffset:public QObject
  329. {
  330. Q_OBJECT
  331. QTime epoch;
  332. QTime previous;
  333. bool hasPrevious;
  334. public:
  335. MeasurementTimeOffset(QTime zero);
  336. QTime zeroTime();
  337. public slots:
  338. void newMeasurement(Measurement measure);
  339. void setZeroTime(QTime zero);
  340. signals:
  341. void measurement(Measurement measure);
  342. };
  343. /*:356*//*363:*/
  344. #line 8204 "./typica.w"
  345. class ThresholdDetector:public QObject
  346. {
  347. Q_OBJECT
  348. Q_ENUMS(EdgeDirection)
  349. public:
  350. enum EdgeDirection{
  351. Ascending,Descending
  352. };
  353. ThresholdDetector(double value);
  354. public slots:
  355. void newMeasurement(Measurement measure);
  356. void setThreshold(double value);
  357. void setEdgeDirection(EdgeDirection direction);
  358. signals:
  359. void timeForValue(double);
  360. private:
  361. double previousValue;
  362. double threshold;
  363. EdgeDirection currentDirection;
  364. };
  365. /*:363*//*368:*/
  366. #line 8310 "./typica.w"
  367. class ZeroEmitter:public QObject
  368. {
  369. Q_OBJECT
  370. Q_PROPERTY(int column READ column WRITE setColumn)
  371. Measurement cache;
  372. int col;
  373. public:
  374. ZeroEmitter(int tempcolumn= 1);
  375. int column();
  376. double lastTemperature();
  377. public slots:
  378. void newMeasurement(Measurement measure);
  379. void setColumn(int column);
  380. void emitZero();
  381. signals:
  382. void measurement(Measurement measure,int tempcolumn);
  383. };
  384. /*:368*//*373:*/
  385. #line 8404 "./typica.w"
  386. class MeasurementAdapter:public QObject
  387. {
  388. Q_OBJECT
  389. int col;
  390. public:
  391. MeasurementAdapter(int tempcolumn);
  392. int column();
  393. public slots:
  394. void newMeasurement(Measurement measure);
  395. void setColumn(int column);
  396. signals:
  397. void measurement(Measurement measure,int tempcolumn);
  398. };
  399. /*:373*//*378:*/
  400. #line 8493 "./typica.w"
  401. class GraphView:public QGraphicsView
  402. {
  403. Q_OBJECT
  404. QGraphicsScene*theScene;
  405. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  406. QMap<int,QPointF> *prevPoints;
  407. QMap<int,double> *translations;
  408. QList<QGraphicsItem*> *gridLinesF;
  409. QList<QGraphicsItem*> *gridLinesC;
  410. QList<QGraphicsItem*> *relativeGridLines;
  411. bool relativeEnabled;
  412. bool timeIndicatorEnabled;
  413. QGraphicsLineItem*timeLine;
  414. LinearSplineInterpolator*relativeAdjuster;
  415. public:
  416. GraphView(QWidget*parent= NULL);
  417. void removeSeries(int column);
  418. protected:
  419. void resizeEvent(QResizeEvent*event);
  420. public slots:
  421. void newMeasurement(Measurement measure,int tempcolumn);
  422. void setSeriesTranslation(int column,double offset);
  423. void setTimeIndicatorEnabled(bool enabled);
  424. void clear();
  425. void showF();
  426. void showC();
  427. };
  428. /*:378*//*395:*/
  429. #line 8958 "./typica.w"
  430. class MeasurementModel;
  431. class ZoomLog:public QTableView
  432. {
  433. Q_OBJECT
  434. /*396:*/
  435. #line 9007 "./typica.w"
  436. MeasurementModel*model_ms;
  437. MeasurementModel*model_1s;
  438. MeasurementModel*model_5s;
  439. MeasurementModel*model_10s;
  440. MeasurementModel*model_15s;
  441. MeasurementModel*model_30s;
  442. MeasurementModel*model_1m;
  443. QList<MeasurementModel*> modelSet;
  444. QHash<int,Measurement> lastMeasurement;
  445. MeasurementModel*currentModel;
  446. QList<int> saveTempCols;
  447. QList<int> saveControlCols;
  448. QList<int> saveNoteCols;
  449. QList<int> currentColumnSet;
  450. /*:396*/
  451. #line 8963 "./typica.w"
  452. void switchLOD(MeasurementModel*m);
  453. private slots:
  454. void centerOn(int row);
  455. void persistColumnResize(int column,int oldsize,int newsize);
  456. void restoreColumnWidths();
  457. public:
  458. ZoomLog();
  459. QVariant data(int row,int column)const;
  460. int rowCount();
  461. bool saveXML(QIODevice*device);
  462. bool saveCSV(QIODevice*device);
  463. QString lastTime(int series);
  464. Q_INVOKABLE Units::Unit displayUnits();
  465. public slots:
  466. void setVisible(bool visibility);
  467. void setHeaderData(int section,QString text);
  468. void LOD_ms();
  469. void LOD_1s();
  470. void LOD_5s();
  471. void LOD_10s();
  472. void LOD_15s();
  473. void LOD_30s();
  474. void LOD_1m();
  475. void newMeasurement(Measurement measure,int tempcolumn);
  476. void newAnnotation(QString annotation,int tempcolumn,
  477. int annotationcolumn);
  478. void clear();
  479. void addOutputTemperatureColumn(int column);
  480. void addOutputControlColumn(int column);
  481. void addOutputAnnotationColumn(int column);
  482. void clearOutputColumns();
  483. void setDisplayUnits(Units::Unit scale);
  484. void addToCurrentColumnSet(int column);
  485. void clearCurrentColumnSet();
  486. protected:
  487. virtual void showEvent(QShowEvent*event);
  488. };
  489. /*:395*//*421:*/
  490. #line 9703 "./typica.w"
  491. class MeasurementList;
  492. class MeasurementModel:public QAbstractItemModel
  493. {
  494. Q_OBJECT
  495. Units::Unit unit;
  496. QList<MeasurementList*> *entries;
  497. QStringList*hData;
  498. int colcount;
  499. QHash<int,int> *lastTemperature;
  500. QList<MeasurementList*> ::iterator lastInsertion;
  501. QHash<int,bool> *controlColumns;
  502. public:
  503. MeasurementModel(QObject*parent= NULL);
  504. ~MeasurementModel();
  505. int rowCount(const QModelIndex&parent= QModelIndex())const;
  506. int columnCount(const QModelIndex&parent= QModelIndex())const;
  507. bool setHeaderData(int section,Qt::Orientation orientation,
  508. const QVariant&value,int role= Qt::DisplayRole);
  509. QVariant data(const QModelIndex&index,int role)const;
  510. bool setData(const QModelIndex&index,const QVariant&value,
  511. int role= Qt::EditRole);
  512. Qt::ItemFlags flags(const QModelIndex&index)const;
  513. QVariant headerData(int section,Qt::Orientation orientation,
  514. int role= Qt::DisplayRole)const;
  515. QModelIndex index(int row,int column,
  516. const QModelIndex&parent= QModelIndex())const;
  517. QModelIndex parent(const QModelIndex&index)const;
  518. Units::Unit displayUnits();
  519. public slots:
  520. void newMeasurement(Measurement measure,int tempcolumn);
  521. void newAnnotation(QString annotation,int tempcolumn,
  522. int annotationColumn);
  523. void clear();
  524. void setDisplayUnits(Units::Unit scale);
  525. signals:
  526. void rowChanged(int);
  527. };
  528. /*:421*//*422:*/
  529. #line 9747 "./typica.w"
  530. class MeasurementList:public QVariantList
  531. {
  532. public:
  533. bool operator<(const MeasurementList&other)const;
  534. bool operator==(const MeasurementList&other)const;
  535. };
  536. /*:422*//*448:*/
  537. #line 10405 "./typica.w"
  538. class AnnotationButton:public QPushButton
  539. {
  540. Q_OBJECT
  541. QString note;
  542. int tc;
  543. int ac;
  544. int count;
  545. public:
  546. AnnotationButton(const QString&text,QWidget*parent= NULL);
  547. public slots:
  548. void setAnnotation(const QString&annotation);
  549. void setTemperatureColumn(int tempcolumn);
  550. void setAnnotationColumn(int annotationcolumn);
  551. void annotate();
  552. void resetCount();
  553. signals:
  554. void annotation(QString annotation,int tempcolumn,
  555. int notecolumn);
  556. };
  557. /*:448*//*456:*/
  558. #line 10530 "./typica.w"
  559. class AnnotationSpinBox:public QDoubleSpinBox
  560. {
  561. Q_OBJECT
  562. QString pretext;
  563. QString posttext;
  564. int tc;
  565. int ac;
  566. bool change;
  567. public:
  568. AnnotationSpinBox(const QString&pret,const QString&postt,
  569. QWidget*parent= NULL);
  570. public slots:
  571. void setPretext(const QString&pret);
  572. void setPosttext(const QString&postt);
  573. void setTemperatureColumn(int tempcolumn);
  574. void setAnnotationColumn(int annotationcolumn);
  575. void annotate();
  576. void resetChange();
  577. signals:
  578. void annotation(QString annotation,int tempcolumn,
  579. int notecolumn);
  580. };
  581. /*:456*//*464:*/
  582. #line 10689 "./typica.w"
  583. class TimerDisplay:public QLCDNumber
  584. {
  585. Q_OBJECT
  586. /*465:*/
  587. #line 10739 "./typica.w"
  588. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  589. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  590. Q_PROPERTY(bool running READ isRunning)
  591. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  592. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  593. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  594. Q_PROPERTY(QString value READ value)
  595. /*:465*/
  596. #line 10693 "./typica.w"
  597. private slots:
  598. void updateTime();
  599. void setCountUpMode();
  600. void setCountDownMode();
  601. void setClockMode();
  602. public:
  603. TimerDisplay(QWidget*parent= NULL);
  604. ~TimerDisplay();
  605. enum TimerMode
  606. {
  607. CountUp,
  608. CountDown,
  609. Clock
  610. };
  611. QString value();
  612. QTime seconds();
  613. TimerMode mode();
  614. bool isRunning();
  615. QTime resetValue();
  616. QString displayFormat();
  617. bool autoReset();
  618. public slots:
  619. void setTimer(QTime value= QTime(0,0,0));
  620. void setMode(TimerMode mode);
  621. void startTimer();
  622. void stopTimer();
  623. void copyTimer();
  624. void setResetValue(QTime value= QTime(0,0,0));
  625. void reset();
  626. void setDisplayFormat(QString format);
  627. void setAutoReset(bool reset);
  628. void updateDisplay();
  629. signals:
  630. void valueChanged(QTime);
  631. void runStateChanged(bool);
  632. private:
  633. /*466:*/
  634. #line 10750 "./typica.w"
  635. QTime s;
  636. QTime r;
  637. QTimer clock;
  638. TimerDisplay::TimerMode m;
  639. bool running;
  640. bool ar;
  641. QAction*startAction;
  642. QAction*stopAction;
  643. QAction*resetAction;
  644. QString f;
  645. QTime relative;
  646. QTime base;
  647. /*:466*/
  648. #line 10730 "./typica.w"
  649. };
  650. /*:464*//*487:*/
  651. #line 11142 "./typica.w"
  652. class PackLayout:public QLayout
  653. {
  654. int doLayout(const QRect&rect,bool testOnly)const;
  655. QList<QLayoutItem*> itemList;
  656. Qt::Orientations orientation;
  657. public:
  658. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  659. PackLayout(int spacing= -1);
  660. ~PackLayout();
  661. void addItem(QLayoutItem*item);
  662. Qt::Orientations expandingDirections()const;
  663. bool hasHeightForWidth()const;
  664. int heightForWidth(int width)const;
  665. int count()const;
  666. QLayoutItem*itemAt(int index)const;
  667. QSize minimumSize()const;
  668. void setGeometry(const QRect&rect);
  669. void setOrientation(Qt::Orientations direction);
  670. QSize sizeHint()const;
  671. QLayoutItem*takeAt(int index);
  672. };
  673. /*:487*//*500:*/
  674. #line 11420 "./typica.w"
  675. class SceneButton:public QGraphicsScene
  676. {
  677. Q_OBJECT
  678. public:
  679. SceneButton();
  680. ~SceneButton();
  681. protected:
  682. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  683. signals:
  684. void clicked(QPoint pos);
  685. };
  686. /*:500*//*502:*/
  687. #line 11462 "./typica.w"
  688. class WidgetDecorator:public QWidget
  689. {
  690. Q_OBJECT
  691. PackLayout*layout;
  692. QGraphicsView*label;
  693. QGraphicsTextItem*text;
  694. SceneButton*scene;
  695. public:
  696. WidgetDecorator(QWidget*widget,const QString&labeltext,
  697. Qt::Orientations orientation= Qt::Horizontal,
  698. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  699. ~WidgetDecorator();
  700. void setBackgroundBrush(QBrush background);
  701. void setTextColor(QColor color);
  702. };
  703. /*:502*//*513:*/
  704. #line 11637 "./typica.w"
  705. class LogEditWindow:public QMainWindow
  706. {
  707. Q_OBJECT
  708. QWidget*centralWidget;
  709. PackLayout*mainLayout;
  710. QHBoxLayout*addRowsLayout;
  711. QLabel*startTimeLabel;
  712. QTimeEdit*startTime;
  713. QLabel*endTimeLabel;
  714. QTimeEdit*endTime;
  715. QLabel*intervalLabel;
  716. QSpinBox*interval;
  717. QPushButton*addRows;
  718. QAction*saveXml;
  719. QAction*saveCsv;
  720. QAction*openXml;
  721. MeasurementModel*model;
  722. QTableView*log;
  723. private slots:
  724. void addTheRows();
  725. void saveXML();
  726. void saveCSV();
  727. void openXML();
  728. protected:
  729. void closeEvent(QCloseEvent*event);
  730. public:
  731. LogEditWindow();
  732. };
  733. /*:513*//*527:*/
  734. #line 11945 "./typica.w"
  735. class XMLOutput:public QObject
  736. {
  737. Q_OBJECT
  738. MeasurementModel*data;
  739. QIODevice*out;
  740. int time;
  741. QMap<int,QString> temperatureColumns;
  742. QMap<int,QString> controlColumns;
  743. QMap<int,QString> annotationColumns;
  744. public:
  745. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  746. void addTemperatureColumn(const QString&series,int column);
  747. void addControlColumn(const QString&series,int column);
  748. void addAnnotationColumn(const QString&series,int column);
  749. void setModel(MeasurementModel*model);
  750. void setTimeColumn(int column);
  751. void setDevice(QIODevice*device);
  752. bool output();
  753. };
  754. /*:527*//*534:*/
  755. #line 12181 "./typica.w"
  756. class XMLInput:public QObject
  757. {
  758. Q_OBJECT
  759. int firstc;
  760. QIODevice*in;
  761. public:
  762. XMLInput(QIODevice*input,int c);
  763. void setFirstColumn(int column);
  764. void setDevice(QIODevice*device);
  765. bool input();
  766. signals:
  767. void measure(Measurement,int);
  768. void annotation(QString,int,int);
  769. void newTemperatureColumn(int,QString);
  770. void newAnnotationColumn(int,QString);
  771. void lastColumn(int);
  772. };
  773. /*:534*//*545:*/
  774. #line 12435 "./typica.w"
  775. class CSVOutput
  776. {
  777. MeasurementModel*data;
  778. QIODevice*out;
  779. int time;
  780. QMap<int,QString> temperatureColumns;
  781. QMap<int,QString> controlColumns;
  782. QMap<int,QString> annotationColumns;
  783. public:
  784. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  785. void addTemperatureColumn(const QString&series,int column);
  786. void addControlColumn(const QString&series,int column);
  787. void addAnnotationColumn(const QString&series,int column);
  788. void setModel(MeasurementModel*model);
  789. void setTimeColumn(int column);
  790. void setDevice(QIODevice*device);
  791. bool output();
  792. };
  793. /*:545*//*575:*/
  794. #line 12578 "./typica.w"
  795. #define AppInstance (qobject_cast<Application *> (qApp))
  796. class NodeInserter;
  797. class DeviceTreeModel;
  798. class Application:public QApplication
  799. {
  800. Q_OBJECT
  801. public:
  802. Application(int&argc,char**argv);
  803. QDomDocument*configuration();
  804. /*717:*/
  805. #line 15142 "./typica.w"
  806. QDomDocument deviceConfiguration();
  807. /*:717*//*750:*/
  808. #line 15815 "./typica.w"
  809. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  810. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  811. const QModelIndex&index);
  812. /*:750*//*755:*/
  813. #line 15919 "./typica.w"
  814. QList<NodeInserter*> topLevelNodeInserters;
  815. /*:755*/
  816. #line 12589 "./typica.w"
  817. QSqlDatabase database();
  818. QScriptEngine*engine;
  819. public slots:
  820. /*718:*/
  821. #line 15149 "./typica.w"
  822. void saveDeviceConfiguration();
  823. /*:718*/
  824. #line 12593 "./typica.w"
  825. private:
  826. /*716:*/
  827. #line 15133 "./typica.w"
  828. QDomDocument deviceConfigurationDocument;
  829. /*:716*//*749:*/
  830. #line 15809 "./typica.w"
  831. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  832. /*:749*/
  833. #line 12595 "./typica.w"
  834. QDomDocument conf;
  835. };
  836. /*:575*//*583:*/
  837. #line 12720 "./typica.w"
  838. class SaltModel:public QAbstractItemModel
  839. {
  840. Q_OBJECT
  841. QList<QList<QMap<int,QVariant> > > modelData;
  842. QStringList hData;
  843. int colcount;
  844. public:
  845. SaltModel(int columns);
  846. ~SaltModel();
  847. int rowCount(const QModelIndex&parent= QModelIndex())const;
  848. int columnCount(const QModelIndex&parent= QModelIndex())const;
  849. bool setHeaderData(int section,Qt::Orientation orientation,
  850. const QVariant&value,int role= Qt::DisplayRole);
  851. QVariant data(const QModelIndex&index,int role)const;
  852. bool setData(const QModelIndex&index,const QVariant&value,
  853. int role= Qt::EditRole);
  854. Qt::ItemFlags flags(const QModelIndex&index)const;
  855. QVariant headerData(int section,Qt::Orientation orientation,
  856. int role= Qt::DisplayRole)const;
  857. QModelIndex index(int row,int column,
  858. const QModelIndex&parent= QModelIndex())const;
  859. QModelIndex parent(const QModelIndex&index)const;
  860. QString arrayLiteral(int column,int role)const;
  861. QString quotedArrayLiteral(int column,int role)const;
  862. void clear();
  863. bool removeRows(int row,int count,
  864. const QModelIndex&parent= QModelIndex());
  865. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  866. };
  867. /*:583*//*599:*/
  868. #line 13105 "./typica.w"
  869. class SqlComboBox:public QComboBox
  870. {
  871. Q_OBJECT
  872. int dataColumn;
  873. int displayColumn;
  874. bool dataColumnShown;
  875. QString specialNullText;
  876. QVariant specialNullData;
  877. public:
  878. SqlComboBox();
  879. ~SqlComboBox();
  880. SqlComboBox*clone(QWidget*parent);
  881. public slots:
  882. void addNullOption();
  883. void addSqlOptions(QString query);
  884. void setDataColumn(int column);
  885. void setDisplayColumn(int column);
  886. void showData(bool show);
  887. void setNullText(QString nullText);
  888. void setNullData(QVariant nullData);
  889. };
  890. /*:599*//*606:*/
  891. #line 13252 "./typica.w"
  892. class SqlComboBoxDelegate:public QItemDelegate
  893. {
  894. Q_OBJECT
  895. SqlComboBox*delegate;
  896. public:
  897. SqlComboBoxDelegate(QObject*parent= NULL);
  898. QWidget*createEditor(QWidget*parent,
  899. const QStyleOptionViewItem&option,
  900. const QModelIndex&index)const;
  901. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  902. void setModelData(QWidget*editor,QAbstractItemModel*model,
  903. const QModelIndex&index)const;
  904. void setWidget(SqlComboBox*widget);
  905. virtual QSize sizeHint()const;
  906. void updateEditorGeometry(QWidget*editor,
  907. const QStyleOptionViewItem&option,
  908. const QModelIndex&index)const;
  909. };
  910. /*:606*//*621:*/
  911. #line 13463 "./typica.w"
  912. class SqlConnectionSetup:public QDialog
  913. {
  914. Q_OBJECT
  915. public:
  916. SqlConnectionSetup();
  917. ~SqlConnectionSetup();
  918. public slots:
  919. void testConnection();
  920. private:
  921. QFormLayout*formLayout;
  922. QComboBox*driver;
  923. QLineEdit*hostname;
  924. QLineEdit*portnumber;
  925. QLineEdit*dbname;
  926. QLineEdit*user;
  927. QLineEdit*password;
  928. QVBoxLayout*layout;
  929. QHBoxLayout*buttons;
  930. QPushButton*cancelButton;
  931. QPushButton*connectButton;
  932. };
  933. /*:621*//*626:*/
  934. #line 13606 "./typica.w"
  935. class SqlQueryView:public QTableView
  936. {
  937. Q_OBJECT
  938. public:
  939. SqlQueryView(QWidget*parent= NULL);
  940. void setQuery(const QString&query);
  941. bool setHeaderData(int section,Qt::Orientation orientation,
  942. const QVariant&value,int role);
  943. Q_INVOKABLE QVariant data(int row,int column,
  944. int role= Qt::DisplayRole);
  945. signals:
  946. void openEntry(QString key);
  947. void openEntryRow(int row);
  948. protected:
  949. virtual void showEvent(QShowEvent*event);
  950. private slots:
  951. void openRow(const QModelIndex&index);
  952. void persistColumnResize(int column,int oldsize,int newsize);
  953. };
  954. /*:626*//*641:*/
  955. #line 13861 "./typica.w"
  956. class ReportAction:public QAction
  957. {
  958. Q_OBJECT
  959. public:
  960. ReportAction(const QString&fileName,const QString&reportName,
  961. QObject*parent= NULL);
  962. private slots:
  963. void createReport();
  964. private:
  965. QString reportFile;
  966. };
  967. /*:641*//*653:*/
  968. #line 14072 "./typica.w"
  969. class ReportTable:public QObject
  970. {
  971. Q_OBJECT
  972. QTextFrame*area;
  973. QDomElement configuration;
  974. QMap<QString,QVariant> bindings;
  975. public:
  976. ReportTable(QTextFrame*frame,QDomElement description);
  977. ~ReportTable();
  978. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  979. public slots:
  980. void refresh();
  981. };
  982. /*:653*//*686:*/
  983. #line 14311 "./typica.w"
  984. class FormArray:public QScrollArea
  985. {
  986. Q_OBJECT
  987. QDomElement configuration;
  988. QWidget itemContainer;
  989. QVBoxLayout itemLayout;
  990. int maxwidth;
  991. int maxheight;
  992. public:
  993. FormArray(QDomElement description);
  994. Q_INVOKABLE QWidget*elementAt(int index);
  995. Q_INVOKABLE int elements();
  996. public slots:
  997. void addElements(int copies= 1);
  998. void removeAllElements();
  999. void setMaximumElementWidth(int width);
  1000. void setMaximumElementHeight(int height);
  1001. };
  1002. /*:686*//*696:*/
  1003. #line 14527 "./typica.w"
  1004. class ScaleControl:public QGraphicsView
  1005. {
  1006. Q_OBJECT
  1007. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1008. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1009. /*697:*/
  1010. #line 14553 "./typica.w"
  1011. QGraphicsScene scene;
  1012. QGraphicsPolygonItem initialDecrement;
  1013. QGraphicsPolygonItem initialIncrement;
  1014. QGraphicsPolygonItem finalDecrement;
  1015. QGraphicsPolygonItem finalIncrement;
  1016. QGraphicsPolygonItem initialIndicator;
  1017. QGraphicsPolygonItem finalIndicator;
  1018. QGraphicsPathItem scaleLine;
  1019. QPolygonF left;
  1020. QPolygonF right;
  1021. QPolygonF down;
  1022. QPolygonF up;
  1023. QPainterPath scalePath;
  1024. QBrush initialBrush;
  1025. QBrush finalBrush;
  1026. double nonScoredValue;
  1027. double scoredValue;
  1028. bool initialSet;
  1029. bool finalSet;
  1030. bool scaleDown;
  1031. /*:697*/
  1032. #line 14533 "./typica.w"
  1033. public:
  1034. ScaleControl();
  1035. double initialValue(void);
  1036. double finalValue(void);
  1037. virtual QSize sizeHint()const;
  1038. public slots:
  1039. void setInitialValue(double value);
  1040. void setFinalValue(double value);
  1041. signals:
  1042. void initialChanged(double);
  1043. void finalChanged(double);
  1044. protected:
  1045. virtual void mousePressEvent(QMouseEvent*event);
  1046. virtual void mouseReleaseEvent(QMouseEvent*event);
  1047. };
  1048. /*:696*//*708:*/
  1049. #line 14850 "./typica.w"
  1050. class IntensityControl:public QGraphicsView
  1051. {
  1052. Q_OBJECT
  1053. Q_PROPERTY(double value READ value WRITE setValue)
  1054. QGraphicsScene scene;
  1055. QGraphicsPolygonItem decrement;
  1056. QGraphicsPolygonItem increment;
  1057. QGraphicsPolygonItem indicator;
  1058. QGraphicsPathItem scaleLine;
  1059. QPolygonF left;
  1060. QPolygonF up;
  1061. QPolygonF down;
  1062. QPainterPath scalePath;
  1063. QBrush theBrush;
  1064. double theValue;
  1065. bool valueSet;
  1066. bool scaleDown;
  1067. public:
  1068. IntensityControl();
  1069. double value();
  1070. virtual QSize sizeHint()const;
  1071. public slots:
  1072. void setValue(double val);
  1073. signals:
  1074. void valueChanged(double);
  1075. protected:
  1076. virtual void mousePressEvent(QMouseEvent*event);
  1077. virtual void mouseReleaseEvent(QMouseEvent*event);
  1078. };
  1079. /*:708*//*724:*/
  1080. #line 15238 "./typica.w"
  1081. class DeviceTreeModelNode
  1082. {
  1083. public:
  1084. DeviceTreeModelNode(QDomNode&node,int row,
  1085. DeviceTreeModelNode*parent= NULL);
  1086. ~DeviceTreeModelNode();
  1087. DeviceTreeModelNode*child(int index);
  1088. DeviceTreeModelNode*parent();
  1089. QDomNode node()const;
  1090. int row();
  1091. private:
  1092. QDomNode domNode;
  1093. QHash<int,DeviceTreeModelNode*> children;
  1094. int rowNumber;
  1095. DeviceTreeModelNode*parentItem;
  1096. };
  1097. /*:724*//*726:*/
  1098. #line 15313 "./typica.w"
  1099. class DeviceTreeModel:public QAbstractItemModel
  1100. {
  1101. Q_OBJECT
  1102. public:
  1103. DeviceTreeModel(QObject*parent= NULL);
  1104. ~DeviceTreeModel();
  1105. QVariant data(const QModelIndex&index,int role)const;
  1106. Qt::ItemFlags flags(const QModelIndex&index)const;
  1107. QVariant headerData(int section,Qt::Orientation orientation,
  1108. int role= Qt::DisplayRole)const;
  1109. QModelIndex index(int row,int column,
  1110. const QModelIndex&parent= QModelIndex())const;
  1111. QModelIndex parent(const QModelIndex&child)const;
  1112. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1113. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1114. bool setData(const QModelIndex&index,const QVariant&value,
  1115. int role);
  1116. bool removeRows(int row,int count,const QModelIndex&parent);
  1117. QDomElement referenceElement(const QString&id);
  1118. public slots:
  1119. void newNode(const QString&name,const QString&driver,
  1120. const QModelIndex&parent);
  1121. private:
  1122. QDomDocument document;
  1123. DeviceTreeModelNode*root;
  1124. QDomNode referenceSection;
  1125. QDomNode treeRoot;
  1126. };
  1127. /*:726*//*745:*/
  1128. #line 15767 "./typica.w"
  1129. Q_DECLARE_METATYPE(QModelIndex)
  1130. /*:745*//*753:*/
  1131. #line 15874 "./typica.w"
  1132. class NodeInserter:public QAction
  1133. {
  1134. Q_OBJECT
  1135. public:
  1136. NodeInserter(const QString&title,const QString&name,
  1137. const QString&driver,QObject*parent= NULL);
  1138. signals:
  1139. void triggered(QString name,QString driver);
  1140. private slots:
  1141. void onTriggered();
  1142. private:
  1143. QString defaultNodeName;
  1144. QString driverString;
  1145. };
  1146. /*:753*//*756:*/
  1147. #line 15929 "./typica.w"
  1148. class DeviceConfigurationWindow:public QWidget
  1149. {
  1150. Q_OBJECT
  1151. public:
  1152. DeviceConfigurationWindow();
  1153. public slots:
  1154. void addDevice();
  1155. void removeNode();
  1156. void newSelection(const QModelIndex&index);
  1157. private slots:
  1158. void resizeColumn();
  1159. private:
  1160. QDomDocument document;
  1161. DeviceTreeModel*model;
  1162. QTreeView*view;
  1163. QScrollArea*configArea;
  1164. };
  1165. /*:756*//*765:*/
  1166. #line 16099 "./typica.w"
  1167. class BasicDeviceConfigurationWidget:public QWidget
  1168. {
  1169. Q_OBJECT
  1170. public:
  1171. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1172. const QModelIndex&index);
  1173. public slots:
  1174. void insertChildNode(const QString&name,const QString&driver);
  1175. void updateAttribute(const QString&name,const QString&value);
  1176. protected:
  1177. DeviceTreeModel*deviceModel;
  1178. QModelIndex currentNode;
  1179. };
  1180. /*:765*//*769:*/
  1181. #line 16184 "./typica.w"
  1182. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1183. {
  1184. Q_OBJECT
  1185. public:
  1186. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1187. const QModelIndex&index);
  1188. private slots:
  1189. void updateRoasterId(int id);
  1190. void updateCapacityCheck(int value);
  1191. void updateCapacity(const QString&value);
  1192. void updateCapacityUnit(const QString&value);
  1193. };
  1194. /*:769*//*774:*/
  1195. #line 16389 "./typica.w"
  1196. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1197. {
  1198. Q_OBJECT
  1199. public:
  1200. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1201. const QModelIndex&index);
  1202. };
  1203. /*:774*//*776:*/
  1204. #line 16435 "./typica.w"
  1205. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1206. {
  1207. Q_OBJECT
  1208. public:
  1209. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1210. const QModelIndex&index);
  1211. private slots:
  1212. void addChannel();
  1213. void updateDeviceId(const QString&newId);
  1214. };
  1215. /*:776*//*780:*/
  1216. #line 16521 "./typica.w"
  1217. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1218. {
  1219. Q_OBJECT
  1220. public:
  1221. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1222. const QModelIndex&index);
  1223. private slots:
  1224. void updateThermocoupleType(const QString&type);
  1225. void updateColumnName(const QString&name);
  1226. void updateHidden(bool hidden);
  1227. };
  1228. /*:780*//*785:*/
  1229. #line 16637 "./typica.w"
  1230. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1231. {
  1232. Q_OBJECT
  1233. public:
  1234. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1235. const QModelIndex&index);
  1236. };
  1237. /*:785*//*787:*/
  1238. #line 16678 "./typica.w"
  1239. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1240. {
  1241. Q_OBJECT
  1242. public:
  1243. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1244. const QModelIndex&index);
  1245. private slots:
  1246. void addChannel();
  1247. void updateDeviceId(const QString&newId);
  1248. };
  1249. /*:787*//*789:*/
  1250. #line 16747 "./typica.w"
  1251. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1252. {
  1253. Q_OBJECT
  1254. public:
  1255. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1256. const QModelIndex&index);
  1257. private slots:
  1258. void updateDeviceId(const QString&newId);
  1259. void updateThermocoupleType(const QString&type);
  1260. void updateColumnName(const QString&name);
  1261. void updateHidden(bool hidden);
  1262. };
  1263. /*:789*//*794:*/
  1264. #line 16878 "./typica.w"
  1265. class PortSelector:public QComboBox
  1266. {
  1267. Q_OBJECT
  1268. public:
  1269. PortSelector(QWidget*parent= NULL);
  1270. private slots:
  1271. void addDevice(QextPortInfo port);
  1272. private:
  1273. QextSerialEnumerator*lister;
  1274. };
  1275. /*:794*//*796:*/
  1276. #line 16926 "./typica.w"
  1277. class BaudSelector:public QComboBox
  1278. {
  1279. Q_OBJECT
  1280. Q_ENUMS(BaudRateType)
  1281. public:
  1282. BaudSelector(QWidget*parent= NULL);
  1283. enum BaudRateType
  1284. {
  1285. #if defined(Q_OS_UNIX) || defined(qdoc)
  1286. BAUD50= 50,
  1287. BAUD75= 75,
  1288. BAUD134= 134,
  1289. BAUD150= 150,
  1290. BAUD200= 200,
  1291. BAUD1800= 1800,
  1292. #if defined(B76800) || defined(qdoc)
  1293. BAUD76800= 76800,
  1294. #endif
  1295. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1296. BAUD230400= 230400,
  1297. BAUD460800= 460800,
  1298. BAUD500000= 500000,
  1299. BAUD576000= 576000,
  1300. BAUD921600= 921600,
  1301. BAUD1000000= 1000000,
  1302. BAUD1152000= 1152000,
  1303. BAUD1500000= 1500000,
  1304. BAUD2000000= 2000000,
  1305. BAUD2500000= 2500000,
  1306. BAUD3000000= 3000000,
  1307. BAUD3500000= 3500000,
  1308. BAUD4000000= 4000000,
  1309. #endif
  1310. #endif
  1311. #if defined(Q_OS_WIN) || defined(qdoc)
  1312. BAUD14400= 14400,
  1313. BAUD56000= 56000,
  1314. BAUD128000= 128000,
  1315. BAUD256000= 256000,
  1316. #endif
  1317. BAUD110= 110,
  1318. BAUD300= 300,
  1319. BAUD600= 600,
  1320. BAUD1200= 1200,
  1321. BAUD2400= 2400,
  1322. BAUD4800= 4800,
  1323. BAUD9600= 9600,
  1324. BAUD19200= 19200,
  1325. BAUD38400= 38400,
  1326. BAUD57600= 57600,
  1327. BAUD115200= 115200
  1328. };
  1329. };
  1330. /*:796*//*798:*/
  1331. #line 16997 "./typica.w"
  1332. class ParitySelector:public QComboBox
  1333. {
  1334. Q_OBJECT
  1335. Q_ENUMS(ParityType)
  1336. public:
  1337. ParitySelector(QWidget*parent= NULL);
  1338. enum ParityType
  1339. {
  1340. PAR_NONE,
  1341. PAR_ODD,
  1342. PAR_EVEN,
  1343. #if defined(Q_OS_WIN) || defined(qdoc)
  1344. PAR_MARK,
  1345. #endif
  1346. PAR_SPACE
  1347. };
  1348. };
  1349. /*:798*//*800:*/
  1350. #line 17035 "./typica.w"
  1351. class FlowSelector:public QComboBox
  1352. {
  1353. Q_OBJECT
  1354. Q_ENUMS(FlowType)
  1355. public:
  1356. FlowSelector(QWidget*parent= NULL);
  1357. enum FlowType
  1358. {
  1359. FLOW_OFF,
  1360. FLOW_HARDWARE,
  1361. FLOW_XONXOFF
  1362. };
  1363. };
  1364. /*:800*//*802:*/
  1365. #line 17068 "./typica.w"
  1366. class StopSelector:public QComboBox
  1367. {
  1368. Q_OBJECT
  1369. Q_ENUMS(StopBitsType)
  1370. public:
  1371. StopSelector(QWidget*parent= NULL);
  1372. enum StopBitsType
  1373. {
  1374. STOP_1,
  1375. #if defined(Q_OS_WIN) || defined(qdoc)
  1376. STOP_1_5,
  1377. #endif
  1378. STOP_2
  1379. };
  1380. };
  1381. /*:802*//*805:*/
  1382. #line 17121 "./typica.w"
  1383. class ShortHexSpinBox:public QSpinBox
  1384. {
  1385. Q_OBJECT
  1386. public:
  1387. ShortHexSpinBox(QWidget*parent= NULL);
  1388. virtual QValidator::State validate(QString&input,int&pos)const;
  1389. protected:
  1390. virtual int valueFromText(const QString&text)const;
  1391. virtual QString textFromValue(int value)const;
  1392. };
  1393. /*:805*//*807:*/
  1394. #line 17183 "./typica.w"
  1395. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1396. {
  1397. Q_OBJECT
  1398. public:
  1399. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1400. const QModelIndex&index);
  1401. private slots:
  1402. void updatePort(const QString&newPort);
  1403. void updateBaudRate(const QString&newRate);
  1404. void updateParity(const QString&newParity);
  1405. void updateFlowControl(const QString&newFlow);
  1406. void updateStopBits(const QString&newStopBits);
  1407. };
  1408. /*:807*//*809:*/
  1409. #line 17334 "./typica.w"
  1410. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1411. {
  1412. Q_OBJECT
  1413. public:
  1414. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1415. const QModelIndex&index);
  1416. private slots:
  1417. void updateStationNumber(int newStation);
  1418. void updateFixedUnit(bool newFixed);
  1419. void updateFixedDecimal(bool newFixed);
  1420. void updateUnit(const QString&newUnit);
  1421. void updateUnitAddress(int newAddress);
  1422. void updateValueF(int newValue);
  1423. void updateValueC(int newValue);
  1424. void updatePrecisionAddress(int newAddress);
  1425. void updatePrecisionValue(int newValue);
  1426. private:
  1427. QStackedLayout*unitSpecificationLayout;
  1428. QStackedLayout*decimalSpecificationLayout;
  1429. };
  1430. /*:809*//*811:*/
  1431. #line 17593 "./typica.w"
  1432. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1433. {
  1434. Q_OBJECT
  1435. public:
  1436. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1437. const QModelIndex&index);
  1438. private slots:
  1439. void updateAddress(int newAddress);
  1440. };
  1441. /*:811*//*813:*/
  1442. #line 17639 "./typica.w"
  1443. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1444. {
  1445. Q_OBJECT
  1446. public:
  1447. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1448. const QModelIndex&index);
  1449. private slots:
  1450. void updateReadAddress(int newAddress);
  1451. void updateWriteAddress(int newAddress);
  1452. void updateFixedRange(bool fixed);
  1453. void updateLower(const QString&lower);
  1454. void updateUpper(const QString&upper);
  1455. void updateLowerAddress(int newAddress);
  1456. void updateUpperAddress(int newAddress);
  1457. private:
  1458. QStackedLayout*boundsLayout;
  1459. };
  1460. /*:813*//*817:*/
  1461. #line 17833 "./typica.w"
  1462. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1463. {
  1464. Q_OBJECT
  1465. public:
  1466. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1467. private slots:
  1468. void updateButtonText(const QString&text);
  1469. void updateAnnotationText(const QString&text);
  1470. };
  1471. /*:817*//*821:*/
  1472. #line 17901 "./typica.w"
  1473. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1474. {
  1475. Q_OBJECT
  1476. public:
  1477. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1478. private slots:
  1479. void updateButtonText(const QString&text);
  1480. void updateAnnotationText(const QString&text);
  1481. };
  1482. /*:821*//*824:*/
  1483. #line 17975 "./typica.w"
  1484. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1485. {
  1486. Q_OBJECT
  1487. public:
  1488. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1489. private slots:
  1490. void updateLabel(const QString&text);
  1491. void updateMinimum(const QString&minimum);
  1492. void updateMaximum(const QString&maximum);
  1493. void updatePrecision(int precision);
  1494. void updatePretext(const QString&text);
  1495. void updatePosttext(const QString&text);
  1496. };
  1497. /*:824*//*827:*/
  1498. #line 12 "./freeannotation.w"
  1499. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1500. {
  1501. Q_OBJECT
  1502. public:
  1503. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1504. private slots:
  1505. void updateLabel(const QString&text);
  1506. };
  1507. /*:827*//*831:*/
  1508. #line 11 "./settings.w"
  1509. class SettingsWindow:public QMainWindow
  1510. {
  1511. Q_OBJECT
  1512. public:
  1513. SettingsWindow();
  1514. };
  1515. /*:831*//*836:*/
  1516. #line 8 "./graphsettings.w"
  1517. class GraphSettingsWidget:public QWidget
  1518. {
  1519. Q_OBJECT
  1520. public:
  1521. GraphSettingsWidget();
  1522. };
  1523. /*:836*//*838:*/
  1524. #line 46 "./graphsettings.w"
  1525. class GraphSettingsRelativeTab:public QWidget
  1526. {
  1527. Q_OBJECT
  1528. public:
  1529. GraphSettingsRelativeTab();
  1530. public slots:
  1531. void updateEnableSetting(bool enable);
  1532. void updateColorSetting(const QString&color);
  1533. void updateAxisSetting(const QString&gridList);
  1534. void updateUnit(int unit);
  1535. void showColorPicker();
  1536. private:
  1537. QLineEdit*colorEdit;
  1538. };
  1539. /*:838*//*842:*/
  1540. #line 7 "./advancedsettings.w"
  1541. class AdvancedSettingsWidget:public QWidget
  1542. {
  1543. Q_OBJECT
  1544. public:
  1545. AdvancedSettingsWidget();
  1546. public slots:
  1547. void enableDiagnosticLogging(bool enabled);
  1548. };
  1549. /*:842*//*846:*/
  1550. #line 18100 "./typica.w"
  1551. class ModbusRTUDevice:public QObject
  1552. {
  1553. Q_OBJECT
  1554. public:
  1555. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1556. ~ModbusRTUDevice();
  1557. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1558. Q_INVOKABLE double SVLower();
  1559. Q_INVOKABLE double SVUpper();
  1560. Q_INVOKABLE int decimals();
  1561. QList<Channel*> channels;
  1562. public slots:
  1563. void outputSV(double sv);
  1564. signals:
  1565. void SVLowerChanged(double);
  1566. void SVUpperChanged(double);
  1567. void SVDecimalChanged(int);
  1568. void queueEmpty();
  1569. private slots:
  1570. void dataAvailable();
  1571. void sendNextMessage();
  1572. void decimalResponse(QByteArray response);
  1573. void unitResponse(QByteArray response);
  1574. void svlResponse(QByteArray response);
  1575. void svuResponse(QByteArray response);
  1576. void requestMeasurement();
  1577. void mResponse(QByteArray response);
  1578. void ignore(QByteArray response);
  1579. void timeout();
  1580. private:
  1581. QextSerialPort*port;
  1582. QByteArray responseBuffer;
  1583. QList<QByteArray> messageQueue;
  1584. QList<QObject*> retObjQueue;
  1585. QList<char*> callbackQueue;
  1586. quint16 calculateCRC(QByteArray data);
  1587. QTimer*messageDelayTimer;
  1588. QTimer*commTimeout;
  1589. int delayTime;
  1590. char station;
  1591. int decimalPosition;
  1592. int valueF;
  1593. int valueC;
  1594. bool unitIsF;
  1595. double outputSVLower;
  1596. double outputSVUpper;
  1597. QByteArray outputSVStub;
  1598. QByteArray pvStub;
  1599. QByteArray svStub;
  1600. QByteArray mStub;
  1601. quint16 pvaddress;
  1602. quint16 svaddress;
  1603. bool svenabled;
  1604. bool readingsv;
  1605. double savedpv;
  1606. bool waiting;
  1607. };
  1608. /*:846*//*862:*/
  1609. #line 18803 "./typica.w"
  1610. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1611. {
  1612. Q_OBJECT
  1613. public:
  1614. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1615. private slots:
  1616. void updatePort(const QString&newPort);
  1617. void updateBaudRate(const QString&newRate);
  1618. void updateParity(const QString&newParity);
  1619. void updateFlowControl(const QString&newFlow);
  1620. void updateStopBits(const QString&newStopBits);
  1621. void updateStation(int station);
  1622. void updateFixedDecimal(bool fixed);
  1623. void updateDecimalAddress(int address);
  1624. void updateDecimalPosition(int position);
  1625. void updateFixedUnit(bool fixed);
  1626. void updateUnitAddress(int address);
  1627. void updateValueForF(int value);
  1628. void updateValueForC(int value);
  1629. void updateUnit(const QString&newUnit);
  1630. void updatePVAddress(int address);
  1631. void updateSVEnabled(bool enabled);
  1632. void updateSVReadAddress(int address);
  1633. void updateDeviceLimit(bool query);
  1634. void updateSVLowerAddress(int address);
  1635. void updateSVUpperAddress(int address);
  1636. void updateSVLower(double value);
  1637. void updateSVUpper(double value);
  1638. void updateSVWritable(bool canWriteSV);
  1639. void updateSVWriteAddress(int address);
  1640. void updatePVColumnName(const QString&name);
  1641. void updateSVColumnName(const QString&name);
  1642. void updatePVHidden(bool hidden);
  1643. void updateSVHidden(bool hidden);
  1644. private:
  1645. PortSelector*port;
  1646. BaudSelector*baud;
  1647. ParitySelector*parity;
  1648. FlowSelector*flow;
  1649. StopSelector*stop;
  1650. QSpinBox*station;
  1651. QCheckBox*decimalQuery;
  1652. ShortHexSpinBox*decimalAddress;
  1653. QSpinBox*decimalPosition;
  1654. QCheckBox*unitQuery;
  1655. ShortHexSpinBox*unitAddress;
  1656. QSpinBox*valueF;
  1657. QSpinBox*valueC;
  1658. QComboBox*fixedUnit;
  1659. ShortHexSpinBox*pVAddress;
  1660. QCheckBox*sVEnabled;
  1661. ShortHexSpinBox*sVReadAddress;
  1662. QCheckBox*deviceLimit;
  1663. ShortHexSpinBox*sVLowerAddr;
  1664. ShortHexSpinBox*sVUpperAddr;
  1665. QDoubleSpinBox*sVLower;
  1666. QDoubleSpinBox*sVUpper;
  1667. QCheckBox*sVWritable;
  1668. ShortHexSpinBox*sVOutputAddr;
  1669. QLineEdit*pVColumnName;
  1670. QLineEdit*sVColumnName;
  1671. };
  1672. /*:862*//*866:*/
  1673. #line 36 "./unsupportedserial.w"
  1674. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1675. {
  1676. Q_OBJECT
  1677. public:
  1678. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1679. const QModelIndex&index);
  1680. private slots:
  1681. void updateConfiguration();
  1682. void saveScript();
  1683. void addChannel();
  1684. private:
  1685. SaltModel*deviceSettingsModel;
  1686. QTextEdit*scriptEditor;
  1687. };
  1688. /*:866*//*871:*/
  1689. #line 166 "./unsupportedserial.w"
  1690. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1691. {
  1692. Q_OBJECT
  1693. public:
  1694. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1695. const QModelIndex&index);
  1696. private slots:
  1697. void updateColumnName(const QString&value);
  1698. void updateHidden(bool hidden);
  1699. void updateConfiguration();
  1700. private:
  1701. SaltModel*channelSettingsModel;
  1702. };
  1703. /*:871*//*876:*/
  1704. #line 298 "./unsupportedserial.w"
  1705. class JavaScriptDevice:public QObject
  1706. {
  1707. Q_OBJECT
  1708. public:
  1709. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1710. QScriptEngine*engine);
  1711. Q_INVOKABLE int channelCount();
  1712. Channel*getChannel(int channel);
  1713. Q_INVOKABLE bool isChannelHidden(int channel);
  1714. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1715. Q_INVOKABLE QString channelColumnName(int channel);
  1716. Q_INVOKABLE QString channelIndicatorText(int channel);
  1717. public slots:
  1718. void setTemperatureColumn(int tcol);
  1719. void setAnnotationColumn(int ncol);
  1720. void start();
  1721. void stop();
  1722. signals:
  1723. void annotation(QString note,int tcol,int ncol);
  1724. void triggerStartBatch();
  1725. void triggerStopBatch();
  1726. void deviceStopRequested();
  1727. private:
  1728. QVariantMap deviceSettings;
  1729. QString deviceScript;
  1730. QList<Channel*> channelList;
  1731. QList<bool> hiddenState;
  1732. QList<Units::Unit> channelUnits;
  1733. QList<QString> columnNames;
  1734. QList<QString> indicatorTexts;
  1735. QList<QVariantMap> channelSettings;
  1736. int annotationTemperatureColumn;
  1737. int annotationNoteColumn;
  1738. QScriptEngine*scriptengine;
  1739. };
  1740. /*:876*//*901:*/
  1741. #line 11 "./phidgets.w"
  1742. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1743. {
  1744. Q_OBJECT
  1745. public:
  1746. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1747. const QModelIndex&index);
  1748. private slots:
  1749. void addChannel();
  1750. void updateRate(int ms);
  1751. };
  1752. /*:901*//*905:*/
  1753. #line 82 "./phidgets.w"
  1754. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1755. {
  1756. Q_OBJECT
  1757. public:
  1758. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1759. const QModelIndex&index);
  1760. private slots:
  1761. void updateColumnName(const QString&value);
  1762. void updateHidden(bool hidden);
  1763. void updateTC(int index);
  1764. void updateChannel(int channel);
  1765. private:
  1766. QComboBox*tcType;
  1767. };
  1768. /*:905*//*910:*/
  1769. #line 213 "./phidgets.w"
  1770. class PhidgetsTemperatureSensor:public QObject
  1771. {
  1772. Q_OBJECT
  1773. public:
  1774. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1775. Q_INVOKABLE int channelCount();
  1776. Channel*getChannel(int channel);
  1777. Q_INVOKABLE bool isChannelHidden(int channel);
  1778. Q_INVOKABLE QString channelColumnName(int channel);
  1779. Q_INVOKABLE QString channelIndicatorText(int channel);
  1780. public slots:
  1781. void start();
  1782. void stop();
  1783. private slots:
  1784. void getMeasurements();
  1785. private:
  1786. QList<int> channelIndices;
  1787. QList<int> tctypes;
  1788. QList<Channel*> channelList;
  1789. QMap<int,Channel*> channelMap;
  1790. QList<bool> hiddenState;
  1791. QList<QString> columnNames;
  1792. QList<QString> indicatorTexts;
  1793. QLibrary driver;
  1794. QTimer sampleTimer;
  1795. void*device;
  1796. /*914:*/
  1797. #line 349 "./phidgets.w"
  1798. #ifdef _WIN32
  1799. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1800. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1801. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1802. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1803. #else
  1804. typedef int(*PhidgetHandleOnly)(void*);
  1805. typedef int(*PhidgetHandleInt)(void*,int);
  1806. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1807. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1808. #endif
  1809. PhidgetHandleOnly createDevice;
  1810. PhidgetHandleInt openDevice;
  1811. PhidgetHandleInt waitForOpen;
  1812. PhidgetHandleIntInt setTCType;
  1813. PhidgetHandleIntDoubleOut getTemperature;
  1814. PhidgetHandleOnly closeDevice;
  1815. PhidgetHandleOnly deleteDevice;
  1816. /*:914*/
  1817. #line 240 "./phidgets.w"
  1818. };
  1819. /*:910*//*923:*/
  1820. #line 19341 "./typica.w"
  1821. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1822. {
  1823. Q_OBJECT
  1824. public:
  1825. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1826. const QModelIndex&index);
  1827. private slots:
  1828. void updateSourceColumn(const QString&source);
  1829. void updateDestinationColumn(const QString&dest);
  1830. void updateKnots();
  1831. private:
  1832. SaltModel*tablemodel;
  1833. };
  1834. /*:923*//*929:*/
  1835. #line 19471 "./typica.w"
  1836. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1837. {
  1838. Q_OBJECT
  1839. public:
  1840. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1841. const QModelIndex&index);
  1842. private slots:
  1843. void updateResetTime(QTime time);
  1844. };
  1845. /*:929*//*933:*/
  1846. #line 19537 "./typica.w"
  1847. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1848. {
  1849. Q_OBJECT
  1850. public:
  1851. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1852. private slots:
  1853. void updateStartButtonText(const QString&text);
  1854. void updateStopButtonText(const QString&text);
  1855. void updateStartColumnName(const QString&text);
  1856. void updateStopColumnName(const QString&text);
  1857. void updateStartValue(const QString&text);
  1858. void updateStopValue(const QString&text);
  1859. void updateStartTrigger(int option);
  1860. void updateStopTrigger(int option);
  1861. };
  1862. /*:933*//*938:*/
  1863. #line 19789 "./typica.w"
  1864. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1865. {
  1866. Q_OBJECT
  1867. public:
  1868. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1869. const QModelIndex&index);
  1870. private slots:
  1871. void updateColumnName(const QString&text);
  1872. void updateRangeData();
  1873. private:
  1874. SaltModel*tablemodel;
  1875. };
  1876. /*:938*//*943:*/
  1877. #line 19891 "./typica.w"
  1878. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1879. {
  1880. Q_OBJECT
  1881. public:
  1882. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1883. private slots:
  1884. void updateMatchingColumn(const QString&column);
  1885. void updateTemperature();
  1886. private:
  1887. QDoubleSpinBox*temperatureValue;
  1888. QComboBox*unitSelector;
  1889. };
  1890. /*:943*//*947:*/
  1891. #line 16 "./rate.w"
  1892. class RateOfChange:public QObject
  1893. {
  1894. Q_OBJECT
  1895. public:
  1896. RateOfChange(int cachetime= 1,int scaletime= 1);
  1897. public slots:
  1898. void newMeasurement(Measurement measure);
  1899. void setCacheTime(int seconds);
  1900. void setScaleTime(int seconds);
  1901. signals:
  1902. void newData(Measurement measure);
  1903. private:
  1904. int ct;
  1905. int st;
  1906. QList<Measurement> cache;
  1907. };
  1908. /*:947*//*955:*/
  1909. #line 177 "./rate.w"
  1910. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1911. {
  1912. Q_OBJECT
  1913. public:
  1914. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1915. private slots:
  1916. void updateColumn(const QString&column);
  1917. void updateCacheTime(const QString&seconds);
  1918. void updateScaleTime(const QString&seconds);
  1919. };
  1920. /*:955*//*961:*/
  1921. #line 19 "./dataqsdk.w"
  1922. class DataqSdkDeviceImplementation;
  1923. class DataqSdkDevice:public QObject
  1924. {
  1925. Q_OBJECT
  1926. DataqSdkDeviceImplementation*imp;
  1927. private slots:
  1928. void threadFinished();
  1929. public:
  1930. DataqSdkDevice(QString device);
  1931. ~DataqSdkDevice();
  1932. Channel*newChannel(Units::Unit scale);
  1933. Q_INVOKABLE void setClockRate(double Hz);
  1934. Q_INVOKABLE void start();
  1935. static QStringList detectPorts();
  1936. static QStringList detectHardware();
  1937. };
  1938. /*:961*//*962:*/
  1939. #line 49 "./dataqsdk.w"
  1940. class DataqSdkDeviceImplementation:public QThread
  1941. {
  1942. Q_OBJECT
  1943. public:
  1944. DataqSdkDeviceImplementation();
  1945. ~DataqSdkDeviceImplementation();
  1946. void run();
  1947. /*963:*/
  1948. #line 70 "./dataqsdk.w"
  1949. typedef struct di_inlist_struct{
  1950. unsigned short chan;
  1951. unsigned short diff;
  1952. unsigned short gain;
  1953. unsigned short unipolar;
  1954. unsigned short dig_out_enable;
  1955. unsigned short dig_out;
  1956. unsigned short ave;
  1957. unsigned short counter;
  1958. }DI_INLIST_STRUCT;
  1959. typedef int(PASCAL*FPDIOPEN)(unsigned);
  1960. typedef int(PASCAL*FPDICLOSE)(void);
  1961. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  1962. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  1963. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  1964. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  1965. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  1966. typedef int(PASCAL*FPDISTARTSCAN)(void);
  1967. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  1968. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  1969. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  1970. typedef int(PASCAL*FPDISTOPSCAN)(void);
  1971. FPDIOPEN di_open;
  1972. FPDICLOSE di_close;
  1973. FPDISAMPLERATE di_sample_rate;
  1974. FPDIMAXIMUMRATE di_maximum_rate;
  1975. FPDILISTLENGTH di_list_length;
  1976. FPDIINLIST di_inlist;
  1977. FPDIBUFFERALLOC di_buffer_alloc;
  1978. FPDISTARTSCAN di_start_scan;
  1979. FPDISTATUSREAD di_status_read;
  1980. FPDIBUFFERSTATUS di_buffer_status;
  1981. FPDIBURSTRATE di_burst_rate;
  1982. FPDISTOPSCAN di_stop_scan;
  1983. /*:963*/
  1984. #line 57 "./dataqsdk.w"
  1985. /*965:*/
  1986. #line 134 "./dataqsdk.w"
  1987. bool isOpen;
  1988. double sampleRate;
  1989. long oversample;
  1990. long burstDivisor;
  1991. QString device;
  1992. unsigned deviceNumber;
  1993. QVector<Channel*> channelMap;
  1994. int error;
  1995. int channels;
  1996. bool ready;
  1997. QLibrary*driver;
  1998. QVector<Units::Unit> unitMap;
  1999. int*input_buffer;
  2000. QTimer*eventClock;
  2001. QMultiMap<int,double> smoother;
  2002. /*:965*/
  2003. #line 58 "./dataqsdk.w"
  2004. public slots:
  2005. void measure();
  2006. private:
  2007. qint16*buffer;
  2008. };
  2009. /*:962*//*982:*/
  2010. #line 663 "./dataqsdk.w"
  2011. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2012. {
  2013. Q_OBJECT
  2014. public:
  2015. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2016. const QModelIndex&index);
  2017. private slots:
  2018. void updateAutoSelect(bool automatic);
  2019. void updateDeviceNumber(int deviceNumber);
  2020. void updatePort(QString portId);
  2021. void addChannel();
  2022. private:
  2023. QStackedWidget*deviceIdStack;
  2024. };
  2025. /*:982*//*987:*/
  2026. #line 808 "./dataqsdk.w"
  2027. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2028. {
  2029. Q_OBJECT
  2030. public:
  2031. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2032. const QModelIndex&index);
  2033. private slots:
  2034. void updateUnits(const QString&unit);
  2035. void updateColumnName(const QString&value);
  2036. void updateMeasuredLower(const QString&value);
  2037. void updateMeasuredUpper(const QString&value);
  2038. void updateMappedLower(const QString&value);
  2039. void updateMappedUpper(const QString&value);
  2040. void updateClosedInterval(bool closed);
  2041. void updateSmoothingEnabled(bool enabled);
  2042. void updateSensitivity(const QString&value);
  2043. void startCalibration();
  2044. void stopCalibration();
  2045. void resetCalibration();
  2046. void updateInput(Measurement measure);
  2047. void updateOutput(Measurement measure);
  2048. void updateHidden(bool hidden);
  2049. private:
  2050. QPushButton*startButton;
  2051. QPushButton*resetButton;
  2052. QPushButton*stopButton;
  2053. /*992:*/
  2054. #line 1098 "./dataqsdk.w"
  2055. bool autoSelect;
  2056. QString deviceID;
  2057. unsigned int channelOfInterest;
  2058. /*:992*/
  2059. #line 835 "./dataqsdk.w"
  2060. DataqSdkDevice*calibrationDevice;
  2061. LinearCalibrator*calibrator;
  2062. QLineEdit*currentMeasurement;
  2063. QLineEdit*minimumMeasurement;
  2064. QLineEdit*maximumMeasurement;
  2065. QLineEdit*averageMeasurement;
  2066. QLineEdit*currentMapped;
  2067. QLineEdit*minimumMapped;
  2068. QLineEdit*maximumMapped;
  2069. QLineEdit*averageMapped;
  2070. int rmCount;
  2071. int cmCount;
  2072. double rmin;
  2073. double rmax;
  2074. double rmean;
  2075. double cmin;
  2076. double cmax;
  2077. double cmean;
  2078. };
  2079. /*:987*//*1014:*/
  2080. #line 247 "./scales.w"
  2081. Q_DECLARE_METATYPE(BaudRateType)
  2082. Q_DECLARE_METATYPE(DataBitsType)
  2083. Q_DECLARE_METATYPE(ParityType)
  2084. Q_DECLARE_METATYPE(StopBitsType)
  2085. Q_DECLARE_METATYPE(FlowType)
  2086. /*:1014*//*1021:*/
  2087. #line 370 "./scales.w"
  2088. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2089. {
  2090. Q_OBJECT
  2091. public:
  2092. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2093. const QModelIndex&index);
  2094. private slots:
  2095. void updatePort(const QString&newPort);
  2096. void updateBaudRate(const QString&rate);
  2097. void updateParity(int index);
  2098. void updateFlowControl(int index);
  2099. void updateStopBits(int index);
  2100. private:
  2101. PortSelector*port;
  2102. BaudSelector*baud;
  2103. ParitySelector*parity;
  2104. FlowSelector*flow;
  2105. StopSelector*stop;
  2106. };
  2107. /*:1021*//*1026:*/
  2108. #line 14 "./valueannotation.w"
  2109. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2110. {
  2111. Q_OBJECT
  2112. public:
  2113. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2114. const QModelIndex&index);
  2115. private slots:
  2116. void updateSourceColumn(const QString&source);
  2117. void updateAnnotations();
  2118. void updateStart(bool noteOnStart);
  2119. private:
  2120. SaltModel*tablemodel;
  2121. };
  2122. /*:1026*//*1034:*/
  2123. #line 165 "./valueannotation.w"
  2124. class ValueAnnotation:public QObject
  2125. {
  2126. Q_OBJECT
  2127. public:
  2128. ValueAnnotation();
  2129. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2130. public slots:
  2131. void newMeasurement(Measurement measure);
  2132. void annotate();
  2133. void setAnnotationColumn(int column);
  2134. void setTemperatureColumn(int column);
  2135. void setTolerance(double epsilon);
  2136. signals:
  2137. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2138. private:
  2139. int lastIndex;
  2140. int annotationColumn;
  2141. int measurementColumn;
  2142. QList<double> values;
  2143. QStringList annotations;
  2144. double tolerance;
  2145. };
  2146. /*:1034*/
  2147. #line 526 "./typica.w"
  2148. /*12:*/
  2149. #line 808 "./typica.w"
  2150. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2151. /*:12*//*14:*/
  2152. #line 823 "./typica.w"
  2153. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2154. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2155. /*:14*//*16:*/
  2156. #line 848 "./typica.w"
  2157. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2158. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2159. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2160. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2161. QScriptEngine*engine);
  2162. /*:16*//*20:*/
  2163. #line 938 "./typica.w"
  2164. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2165. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2166. /*:20*//*30:*/
  2167. #line 1139 "./typica.w"
  2168. QScriptValue constructQMainWindow(QScriptContext*context,
  2169. QScriptEngine*engine);
  2170. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2171. QScriptEngine*engine);
  2172. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2173. QScriptEngine*engine);
  2174. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2175. /*:30*//*35:*/
  2176. #line 1238 "./typica.w"
  2177. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2178. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2179. /*:35*//*38:*/
  2180. #line 1283 "./typica.w"
  2181. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2182. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2183. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2184. /*:38*//*41:*/
  2185. #line 1349 "./typica.w"
  2186. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2187. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2188. /*:41*//*44:*/
  2189. #line 1382 "./typica.w"
  2190. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2191. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2192. /*:44*//*47:*/
  2193. #line 1420 "./typica.w"
  2194. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2195. QScriptValue constructQSvgWidget(QScriptContext*context,
  2196. QScriptEngine*engine);
  2197. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2198. QScriptEngine*engine);
  2199. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2200. QStack<QLayout*> *layoutStack);
  2201. /*:47*//*53:*/
  2202. #line 1507 "./typica.w"
  2203. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2204. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2205. /*:53*//*57:*/
  2206. #line 1546 "./typica.w"
  2207. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2208. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2209. QScriptEngine*engine);
  2210. QScriptValue QSplitter_saveState(QScriptContext*context,
  2211. QScriptEngine*engine);
  2212. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2213. QScriptEngine*engine);
  2214. QScriptValue QSplitter_count(QScriptContext*context,
  2215. QScriptEngine*engine);
  2216. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2217. /*:57*//*63:*/
  2218. #line 1685 "./typica.w"
  2219. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2220. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2221. /*:63*//*65:*/
  2222. #line 1740 "./typica.w"
  2223. QScriptValue constructQBoxLayout(QScriptContext*context,
  2224. QScriptEngine*engine);
  2225. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2226. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2227. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2228. /*:65*//*69:*/
  2229. #line 1853 "./typica.w"
  2230. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2231. QScriptValue QAction_setShortcut(QScriptContext*context,
  2232. QScriptEngine*engine);
  2233. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2234. /*:69*//*72:*/
  2235. #line 1909 "./typica.w"
  2236. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2237. QScriptEngine*engine);
  2238. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2239. QScriptEngine*engine);
  2240. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2241. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2242. /*:72*//*77:*/
  2243. #line 2020 "./typica.w"
  2244. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2245. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2246. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2247. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2248. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2249. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2250. QScriptValue QIODevice_readToString(QScriptContext*context,
  2251. QScriptEngine*engine);
  2252. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2253. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2254. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2255. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2256. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2257. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2258. /*:77*//*88:*/
  2259. #line 2246 "./typica.w"
  2260. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2261. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2262. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2263. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2264. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2265. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2266. /*:88*//*96:*/
  2267. #line 2364 "./typica.w"
  2268. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2269. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2270. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2271. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2272. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2273. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2274. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2275. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2276. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2277. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2278. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2279. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2280. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2281. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2282. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2283. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2284. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2285. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2286. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2287. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2288. /*:96*//*109:*/
  2289. #line 2638 "./typica.w"
  2290. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2291. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2292. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2293. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2294. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2295. /*:109*//*112:*/
  2296. #line 2743 "./typica.w"
  2297. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2298. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2299. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2300. /*:112*//*115:*/
  2301. #line 2788 "./typica.w"
  2302. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2303. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2304. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2305. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2306. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2307. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2308. /*:115*//*121:*/
  2309. #line 2870 "./typica.w"
  2310. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2311. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2312. QScriptEngine*engine);
  2313. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2314. QScriptEngine*engine);
  2315. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2316. QScriptEngine*engine);
  2317. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2318. QScriptEngine*engine);
  2319. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2320. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2321. QScriptEngine*engine);
  2322. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2323. QScriptEngine*engine);
  2324. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2325. QScriptEngine*engine);
  2326. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2327. QScriptEngine*engine);
  2328. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2329. QScriptEngine*engine);
  2330. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2331. QScriptEngine*engine);
  2332. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2333. QScriptEngine*engine);
  2334. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2335. QScriptEngine*engine);
  2336. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2337. /*:121*//*130:*/
  2338. #line 3088 "./typica.w"
  2339. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2340. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2341. QScriptValue XmlReader_attribute(QScriptContext*context,
  2342. QScriptEngine*engine);
  2343. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2344. QScriptEngine*engine);
  2345. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2346. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2347. QScriptEngine*engine);
  2348. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2349. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2350. QScriptEngine*engine);
  2351. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2352. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2353. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2354. /*:130*//*137:*/
  2355. #line 3223 "./typica.w"
  2356. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2357. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2358. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2359. /*:137*//*141:*/
  2360. #line 3305 "./typica.w"
  2361. QScriptValue constructQLCDNumber(QScriptContext*context,
  2362. QScriptEngine*engine);
  2363. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2364. /*:141*//*144:*/
  2365. #line 3343 "./typica.w"
  2366. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2367. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2368. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2369. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2370. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2371. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2372. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2373. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2374. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2375. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2376. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2377. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2378. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2379. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2380. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2381. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2382. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2383. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2384. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2385. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2386. /*:144*//*160:*/
  2387. #line 3821 "./typica.w"
  2388. void setQAbstractScrollAreaProperties(QScriptValue value,
  2389. QScriptEngine*engine);
  2390. /*:160*//*162:*/
  2391. #line 3836 "./typica.w"
  2392. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2393. /*:162*//*164:*/
  2394. #line 3849 "./typica.w"
  2395. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2396. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2397. /*:164*//*166:*/
  2398. #line 3873 "./typica.w"
  2399. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2400. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2401. QScriptValue constructQPushButton(QScriptContext*context,
  2402. QScriptEngine*engine);
  2403. /*:166*//*173:*/
  2404. #line 3972 "./typica.w"
  2405. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2406. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2407. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2408. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2409. QScriptEngine*engine);
  2410. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2411. QScriptEngine*engine);
  2412. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2413. QScriptEngine*engine);
  2414. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2415. QScriptEngine*engine);
  2416. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2417. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2418. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2419. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2420. /*:173*//*180:*/
  2421. #line 4143 "./typica.w"
  2422. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2423. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2424. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2425. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2426. QScriptValue annotationFromRecord(QScriptContext*context,
  2427. QScriptEngine*engine);
  2428. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2429. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2430. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2431. /*:180*//*193:*/
  2432. #line 4474 "./typica.w"
  2433. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2434. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2435. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2436. QStack<QLayout*> *layoutStack);
  2437. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2438. QStack<QLayout*> *layoutStack);
  2439. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2440. QStack<QLayout*> *layoutStack);
  2441. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2442. QStack<QLayout*> *layoutStack);
  2443. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2444. QStack<QLayout*> *layoutStack);
  2445. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2446. QStack<QLayout*> *layoutStack);
  2447. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2448. QStack<QLayout*> *layoutStack);
  2449. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2450. QStack<QLayout*> *layoutStack);
  2451. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2452. QStack<QLayout*> *layoutStack);
  2453. void addTemperatureDisplayToSplitter(QDomElement element,
  2454. QStack<QWidget*> *widgetStack,
  2455. QStack<QLayout*> *layoutStack);
  2456. void addTemperatureDisplayToLayout(QDomElement element,
  2457. QStack<QWidget*> *widgetStack,
  2458. QStack<QLayout*> *layoutStack);
  2459. void addTimerDisplayToSplitter(QDomElement element,
  2460. QStack<QWidget*> *widgetStack,
  2461. QStack<QLayout*> *layoutStack);
  2462. void addTimerDisplayToLayout(QDomElement element,
  2463. QStack<QWidget*> *widgetStack,
  2464. QStack<QLayout*> *layoutStack);
  2465. void addDecorationToSplitter(QDomElement element,
  2466. QStack<QWidget*> *widgetStack,
  2467. QStack<QLayout*> *layoutStack);
  2468. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2469. QStack<QLayout*> *layoutStack);
  2470. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2471. QStack<QLayout*> *layoutStack);
  2472. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2473. QStack<QLayout*> *layoutStack);
  2474. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2475. QStack<QLayout*> *layoutStack);
  2476. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2477. QStack<QLayout*> *layoutStack);
  2478. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2479. QStack<QLayout*> *layoutStack);
  2480. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2481. QStack<QLayout*> *layoutStack);
  2482. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2483. QStack<QLayout*> *layoutStack);
  2484. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2485. QStack<QLayout*> *layoutStack);
  2486. void addSqlQueryViewToLayout(QDomElement element,
  2487. QStack<QWidget*> *widgetStack,
  2488. QStack<QLayout*> *layoutStack);
  2489. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2490. QStack<QLayout*> *layoutStack);
  2491. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2492. QStack<QLayout*> *layoutStack);
  2493. /*:193*//*257:*/
  2494. #line 6156 "./typica.w"
  2495. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2496. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2497. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2498. QScriptEngine*engine);
  2499. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2500. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2501. QScriptEngine*engine);
  2502. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2503. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2504. /*:257*//*258:*/
  2505. #line 6172 "./typica.w"
  2506. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2507. /*:258*//*262:*/
  2508. #line 6311 "./typica.w"
  2509. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2510. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2511. QScriptEngine*engine);
  2512. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2513. QScriptEngine*engine);
  2514. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2515. QScriptEngine*engine);
  2516. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2517. QScriptEngine*engine);
  2518. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2519. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2520. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2521. QScriptEngine*engine);
  2522. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2523. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2524. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2525. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2526. /*:262*//*272:*/
  2527. #line 6527 "./typica.w"
  2528. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2529. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2530. QScriptValue QComboBox_currentData(QScriptContext*context,
  2531. QScriptEngine*engine);
  2532. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2533. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2534. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2535. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2536. /*:272*//*284:*/
  2537. #line 379 "./units.w"
  2538. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2539. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2540. QScriptEngine*engine);
  2541. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2542. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2544. /*:284*//*288:*/
  2545. #line 443 "./units.w"
  2546. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2547. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2548. /*:288*//*297:*/
  2549. #line 133 "./measurement.w"
  2550. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2551. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2552. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2553. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2554. /*:297*//*317:*/
  2555. #line 7162 "./typica.w"
  2556. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2557. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2558. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2559. /*:317*//*326:*/
  2560. #line 7367 "./typica.w"
  2561. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2562. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2563. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2564. /*:326*//*331:*/
  2565. #line 7468 "./typica.w"
  2566. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2567. /*:331*//*337:*/
  2568. #line 7650 "./typica.w"
  2569. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2570. QScriptEngine*engine);
  2571. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2572. /*:337*//*342:*/
  2573. #line 7790 "./typica.w"
  2574. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2575. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2576. /*:342*//*352:*/
  2577. #line 7995 "./typica.w"
  2578. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2579. QScriptEngine*engine);
  2580. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2581. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2582. QScriptEngine*engine);
  2583. /*:352*//*360:*/
  2584. #line 8154 "./typica.w"
  2585. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2586. QScriptEngine*engine);
  2587. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2588. QScriptEngine*engine);
  2589. /*:360*//*365:*/
  2590. #line 8267 "./typica.w"
  2591. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2592. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2593. /*:365*//*370:*/
  2594. #line 8365 "./typica.w"
  2595. QScriptValue constructZeroEmitter(QScriptContext*context,
  2596. QScriptEngine*engine);
  2597. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2598. /*:370*//*375:*/
  2599. #line 8444 "./typica.w"
  2600. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2601. QScriptEngine*engine);
  2602. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2603. /*:375*//*392:*/
  2604. #line 8908 "./typica.w"
  2605. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2606. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2607. /*:392*//*415:*/
  2608. #line 9535 "./typica.w"
  2609. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2610. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2611. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2612. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2613. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2614. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2615. QScriptEngine*engine);
  2616. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2617. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2618. QScriptEngine*engnie);
  2619. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2620. QScriptEngine*engine);
  2621. /*:415*//*453:*/
  2622. #line 10492 "./typica.w"
  2623. QScriptValue constructAnnotationButton(QScriptContext*context,
  2624. QScriptEngine*engine);
  2625. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2626. /*:453*//*461:*/
  2627. #line 10632 "./typica.w"
  2628. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2629. QScriptEngine*engine);
  2630. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2631. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2632. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2633. /*:461*//*482:*/
  2634. #line 11058 "./typica.w"
  2635. QScriptValue constructTimerDisplay(QScriptContext*context,
  2636. QScriptEngine*engine);
  2637. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2638. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2639. /*:482*//*510:*/
  2640. #line 11583 "./typica.w"
  2641. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2642. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2643. QScriptEngine*engine);
  2644. /*:510*//*523:*/
  2645. #line 11866 "./typica.w"
  2646. QScriptValue constructLogEditWindow(QScriptContext*context,
  2647. QScriptEngine*engine);
  2648. /*:523*//*542:*/
  2649. #line 12393 "./typica.w"
  2650. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2651. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2652. /*:542*//*560:*/
  2653. #line 189 "./webview.w"
  2654. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2655. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2656. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2657. QStack<QLayout*> *layoutStack);
  2658. /*:560*//*563:*/
  2659. #line 219 "./webview.w"
  2660. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2661. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2662. /*:563*//*567:*/
  2663. #line 277 "./webview.w"
  2664. QScriptValue constructWebElement(QScriptContext*context,
  2665. QScriptEngine*engine);
  2666. /*:567*//*636:*/
  2667. #line 13740 "./typica.w"
  2668. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2669. QScriptValue constructSqlQueryView(QScriptContext*context,
  2670. QScriptEngine*engine);
  2671. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2672. QScriptEngine*engine);
  2673. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2674. QScriptEngine*engine);
  2675. /*:636*//*646:*/
  2676. #line 13979 "./typica.w"
  2677. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2678. QStack<QLayout*> *layoutStack);
  2679. /*:646*//*662:*/
  2680. #line 14264 "./typica.w"
  2681. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2682. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2683. /*:662*//*684:*/
  2684. #line 480 "./daterangeselector.w"
  2685. void addDateRangeToLayout(QDomElement element,
  2686. QStack<QWidget*> *widgetStack,
  2687. QStack<QLayout*> *layoutStack);
  2688. /*:684*//*693:*/
  2689. #line 14461 "./typica.w"
  2690. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2691. QStack<QLayout*> *layoutStack);
  2692. /*:693*//*714:*/
  2693. #line 15045 "./typica.w"
  2694. void addScaleControlToLayout(QDomElement element,
  2695. QStack<QWidget*> *widgetStack,
  2696. QStack<QLayout*> *layoutStack);
  2697. void addIntensityControlToLayout(QDomElement element,
  2698. QStack<QWidget*> *widgetStack,
  2699. QStack<QLayout*> *layoutStack);
  2700. /*:714*//*740:*/
  2701. #line 15631 "./typica.w"
  2702. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2703. QScriptEngine*engine);
  2704. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2705. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2706. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2707. QScriptEngine*engine);
  2708. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2709. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2710. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2711. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2712. /*:740*//*746:*/
  2713. #line 15773 "./typica.w"
  2714. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2715. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2716. /*:746*//*762:*/
  2717. #line 16071 "./typica.w"
  2718. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2719. QScriptEngine*engine);
  2720. /*:762*//*833:*/
  2721. #line 42 "./settings.w"
  2722. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2723. /*:833*//*857:*/
  2724. #line 18710 "./typica.w"
  2725. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2726. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2727. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2728. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2729. /*:857*//*877:*/
  2730. #line 345 "./unsupportedserial.w"
  2731. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2732. /*:877*//*883:*/
  2733. #line 425 "./unsupportedserial.w"
  2734. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2735. /*:883*//*889:*/
  2736. #line 617 "./unsupportedserial.w"
  2737. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2738. /*:889*//*893:*/
  2739. #line 651 "./unsupportedserial.w"
  2740. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2741. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2742. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2743. /*:893*//*920:*/
  2744. #line 457 "./phidgets.w"
  2745. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2746. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2747. /*:920*//*952:*/
  2748. #line 138 "./rate.w"
  2749. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2750. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2751. /*:952*//*977:*/
  2752. #line 597 "./dataqsdk.w"
  2753. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2754. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2755. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2756. /*:977*//*1004:*/
  2757. #line 67 "./scales.w"
  2758. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2759. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2760. /*:1004*//*1012:*/
  2761. #line 233 "./scales.w"
  2762. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2763. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2764. /*:1012*//*1015:*/
  2765. #line 258 "./scales.w"
  2766. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2767. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2768. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2769. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2770. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2771. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2772. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2773. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2774. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2775. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2776. /*:1015*//*1040:*/
  2777. #line 265 "./valueannotation.w"
  2778. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2779. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2780. /*:1040*/
  2781. #line 527 "./typica.w"
  2782. /*616:*/
  2783. #line 13389 "./typica.w"
  2784. void messageFileOutput(QtMsgType type,const char*msg);
  2785. /*:616*/
  2786. #line 528 "./typica.w"
  2787. /*4:*/
  2788. #line 537 "./typica.w"
  2789. /*754:*/
  2790. #line 15894 "./typica.w"
  2791. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2792. const QString&driver,QObject*parent):
  2793. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2794. {
  2795. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2796. }
  2797. void NodeInserter::onTriggered()
  2798. {
  2799. emit triggered(defaultNodeName,driverString);
  2800. }
  2801. /*:754*/
  2802. #line 538 "./typica.w"
  2803. /*293:*/
  2804. #line 40 "./measurement.w"
  2805. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2806. {
  2807. insert("measurement",temperature);
  2808. insert("time",time);
  2809. insert("unit",sc);
  2810. }
  2811. Measurement::Measurement(double temperature)
  2812. {
  2813. insert("measurement",temperature);
  2814. insert("time",QTime::currentTime());
  2815. insert("unit",Units::Fahrenheit);
  2816. }
  2817. void Measurement::setTemperature(double temperature)
  2818. {
  2819. insert("measurement",temperature);
  2820. }
  2821. void Measurement::setTime(QTime time)
  2822. {
  2823. insert("time",time);
  2824. }
  2825. void Measurement::setUnit(Units::Unit scale)
  2826. {
  2827. insert("unit",scale);
  2828. }
  2829. double Measurement::temperature()const
  2830. {
  2831. return value("measurement").toDouble();
  2832. }
  2833. QTime Measurement::time()const
  2834. {
  2835. return value("time").toTime();
  2836. }
  2837. Units::Unit Measurement::scale()const
  2838. {
  2839. return(Units::Unit)(value("unit").toInt());
  2840. }
  2841. /*:293*//*294:*/
  2842. #line 88 "./measurement.w"
  2843. Measurement Measurement::toFahrenheit()
  2844. {
  2845. return Measurement(Units::convertTemperature(this->temperature(),
  2846. this->scale(),Units::Fahrenheit),
  2847. this->time(),Units::Fahrenheit);
  2848. }
  2849. Measurement Measurement::toCelsius()
  2850. {
  2851. return Measurement(Units::convertTemperature(this->temperature(),
  2852. this->scale(),Units::Celsius),
  2853. this->time(),Units::Celsius);
  2854. }
  2855. Measurement Measurement::toKelvin()
  2856. {
  2857. return Measurement(Units::convertTemperature(this->temperature(),
  2858. this->scale(),Units::Kelvin),
  2859. this->time(),Units::Kelvin);
  2860. }
  2861. Measurement Measurement::toRankine()
  2862. {
  2863. return Measurement(Units::convertTemperature(this->temperature(),
  2864. this->scale(),Units::Rankine),
  2865. this->time(),Units::Rankine);
  2866. }
  2867. /*:294*/
  2868. #line 539 "./typica.w"
  2869. /*307:*/
  2870. #line 6767 "./typica.w"
  2871. void DAQImplementation::measure()
  2872. {
  2873. int samplesRead= 0;
  2874. double buffer[channels];
  2875. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2876. (unsigned long)(0),buffer,(unsigned long)(channels),
  2877. &samplesRead,(signed long)(0));
  2878. if(error)
  2879. {
  2880. ready= false;
  2881. }
  2882. else
  2883. {
  2884. if(samplesRead)
  2885. {
  2886. QTime time= QTime::currentTime();
  2887. for(int i= 0;i<samplesRead;i++)
  2888. {
  2889. for(int j= 0;j<channels;j++)
  2890. {
  2891. double measuredValue= buffer[j+(i*channels)];
  2892. Measurement measure(measuredValue,time,
  2893. unitMap[j]);
  2894. channelMap[j]->input(measure);
  2895. }
  2896. }
  2897. }
  2898. }
  2899. }
  2900. /*:307*//*308:*/
  2901. #line 6810 "./typica.w"
  2902. void DAQImplementation::run()
  2903. {
  2904. setPriority(QThread::TimeCriticalPriority);
  2905. while(ready)
  2906. {
  2907. measure();
  2908. }
  2909. }
  2910. /*:308*//*309:*/
  2911. #line 6826 "./typica.w"
  2912. void DAQ::threadFinished()
  2913. {
  2914. if(imp->error)
  2915. {
  2916. /*310:*/
  2917. #line 6877 "./typica.w"
  2918. imp->ready= false;
  2919. QMessageBox warning;
  2920. warning.setStandardButtons(QMessageBox::Cancel);
  2921. warning.setIcon(QMessageBox::Warning);
  2922. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2923. unsigned long bytes= imp->errorInfo(NULL,0);
  2924. char string[bytes];
  2925. imp->errorInfo(string,bytes);
  2926. warning.setInformativeText(QString(string));
  2927. warning.setWindowTitle(QString(PROGRAM_NAME));
  2928. warning.exec();
  2929. /*:310*/
  2930. #line 6831 "./typica.w"
  2931. }
  2932. }
  2933. /*:309*//*311:*/
  2934. #line 6902 "./typica.w"
  2935. void DAQ::start()
  2936. {
  2937. if(imp->ready)
  2938. {
  2939. imp->error= imp->startTask(imp->handle);
  2940. if(imp->error)
  2941. {
  2942. /*310:*/
  2943. #line 6877 "./typica.w"
  2944. imp->ready= false;
  2945. QMessageBox warning;
  2946. warning.setStandardButtons(QMessageBox::Cancel);
  2947. warning.setIcon(QMessageBox::Warning);
  2948. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2949. unsigned long bytes= imp->errorInfo(NULL,0);
  2950. char string[bytes];
  2951. imp->errorInfo(string,bytes);
  2952. warning.setInformativeText(QString(string));
  2953. warning.setWindowTitle(QString(PROGRAM_NAME));
  2954. warning.exec();
  2955. /*:310*/
  2956. #line 6910 "./typica.w"
  2957. }
  2958. else
  2959. {
  2960. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2961. imp->start();
  2962. }
  2963. }
  2964. }
  2965. void DAQ::stop()
  2966. {
  2967. if(imp->useBase)
  2968. {
  2969. imp->ready= false;
  2970. imp->wait(ULONG_MAX);
  2971. imp->stopTask(imp->handle);
  2972. }
  2973. else
  2974. {
  2975. imp->ready= false;
  2976. imp->error= imp->stopTask(imp->handle);
  2977. if(imp->error)
  2978. {
  2979. /*310:*/
  2980. #line 6877 "./typica.w"
  2981. imp->ready= false;
  2982. QMessageBox warning;
  2983. warning.setStandardButtons(QMessageBox::Cancel);
  2984. warning.setIcon(QMessageBox::Warning);
  2985. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2986. unsigned long bytes= imp->errorInfo(NULL,0);
  2987. char string[bytes];
  2988. imp->errorInfo(string,bytes);
  2989. warning.setInformativeText(QString(string));
  2990. warning.setWindowTitle(QString(PROGRAM_NAME));
  2991. warning.exec();
  2992. /*:310*/
  2993. #line 6934 "./typica.w"
  2994. }
  2995. imp->error= imp->clearTask(imp->handle);
  2996. if(imp->error)
  2997. {
  2998. /*310:*/
  2999. #line 6877 "./typica.w"
  3000. imp->ready= false;
  3001. QMessageBox warning;
  3002. warning.setStandardButtons(QMessageBox::Cancel);
  3003. warning.setIcon(QMessageBox::Warning);
  3004. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3005. unsigned long bytes= imp->errorInfo(NULL,0);
  3006. char string[bytes];
  3007. imp->errorInfo(string,bytes);
  3008. warning.setInformativeText(QString(string));
  3009. warning.setWindowTitle(QString(PROGRAM_NAME));
  3010. warning.exec();
  3011. /*:310*/
  3012. #line 6939 "./typica.w"
  3013. }
  3014. }
  3015. }
  3016. /*:311*//*312:*/
  3017. #line 6949 "./typica.w"
  3018. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3019. {
  3020. imp->device= device;
  3021. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3022. if(imp->error)
  3023. {
  3024. /*310:*/
  3025. #line 6877 "./typica.w"
  3026. imp->ready= false;
  3027. QMessageBox warning;
  3028. warning.setStandardButtons(QMessageBox::Cancel);
  3029. warning.setIcon(QMessageBox::Warning);
  3030. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3031. unsigned long bytes= imp->errorInfo(NULL,0);
  3032. char string[bytes];
  3033. imp->errorInfo(string,bytes);
  3034. warning.setInformativeText(QString(string));
  3035. warning.setWindowTitle(QString(PROGRAM_NAME));
  3036. warning.exec();
  3037. /*:310*/
  3038. #line 6956 "./typica.w"
  3039. }
  3040. else
  3041. {
  3042. imp->ready= true;
  3043. }
  3044. }
  3045. /*:312*//*313:*/
  3046. #line 6970 "./typica.w"
  3047. Channel*DAQ::newChannel(int units,int thermocouple)
  3048. {
  3049. Channel*retval= new Channel();
  3050. imp->channelMap[imp->channels]= retval;
  3051. imp->unitMap[imp->channels]= (Units::Unit)units;
  3052. imp->channels++;
  3053. if(imp->ready)
  3054. {
  3055. if(imp->useBase)
  3056. {
  3057. imp->error= imp->createChannel(imp->handle,
  3058. QString("%1/ai%2").arg(imp->device).
  3059. arg(imp->channels-1).
  3060. toAscii().data(),
  3061. "",(double)(-1.0),(double)(100.0),
  3062. (signed long)(units),
  3063. (signed long)(thermocouple),
  3064. (signed long)(10200),(double)(0),
  3065. "");
  3066. }
  3067. else
  3068. {
  3069. imp->error= imp->createChannel(imp->handle,
  3070. QString("%1/ai%2").arg(imp->device).
  3071. arg(imp->channels-1).
  3072. toAscii().data(),
  3073. "",(double)(50.0),(double)(500.0),
  3074. (signed long)(units),
  3075. (signed long)(thermocouple),
  3076. (signed long)(10200),(double)(0),
  3077. "");
  3078. }
  3079. if(imp->error)
  3080. {
  3081. /*310:*/
  3082. #line 6877 "./typica.w"
  3083. imp->ready= false;
  3084. QMessageBox warning;
  3085. warning.setStandardButtons(QMessageBox::Cancel);
  3086. warning.setIcon(QMessageBox::Warning);
  3087. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3088. unsigned long bytes= imp->errorInfo(NULL,0);
  3089. char string[bytes];
  3090. imp->errorInfo(string,bytes);
  3091. warning.setInformativeText(QString(string));
  3092. warning.setWindowTitle(QString(PROGRAM_NAME));
  3093. warning.exec();
  3094. /*:310*/
  3095. #line 7005 "./typica.w"
  3096. }
  3097. }
  3098. return retval;
  3099. }
  3100. /*:313*//*314:*/
  3101. #line 7019 "./typica.w"
  3102. void DAQ::setClockRate(double Hz)
  3103. {
  3104. if(imp->ready)
  3105. {
  3106. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3107. (signed long)(10280),(signed long)(10123),
  3108. (unsigned long long)(1));
  3109. if(imp->error)
  3110. {
  3111. /*310:*/
  3112. #line 6877 "./typica.w"
  3113. imp->ready= false;
  3114. QMessageBox warning;
  3115. warning.setStandardButtons(QMessageBox::Cancel);
  3116. warning.setIcon(QMessageBox::Warning);
  3117. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3118. unsigned long bytes= imp->errorInfo(NULL,0);
  3119. char string[bytes];
  3120. imp->errorInfo(string,bytes);
  3121. warning.setInformativeText(QString(string));
  3122. warning.setWindowTitle(QString(PROGRAM_NAME));
  3123. warning.exec();
  3124. /*:310*/
  3125. #line 7029 "./typica.w"
  3126. }
  3127. }
  3128. }
  3129. /*:314*//*315:*/
  3130. #line 7039 "./typica.w"
  3131. DAQ::~DAQ()
  3132. {
  3133. if(imp->useBase)
  3134. {
  3135. imp->resetDevice(imp->device.toAscii().data());
  3136. imp->clearTask(imp->handle);
  3137. }
  3138. else
  3139. {
  3140. if(imp->ready)
  3141. {
  3142. imp->ready= false;
  3143. imp->wait(ULONG_MAX);
  3144. imp->stopTask(imp->handle);
  3145. imp->resetDevice(imp->device.toAscii().data());
  3146. imp->clearTask(imp->handle);
  3147. }
  3148. }
  3149. delete imp;
  3150. }
  3151. /*:315*//*316:*/
  3152. #line 7070 "./typica.w"
  3153. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3154. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3155. unitMap(4)
  3156. {
  3157. if(driverinfo=="nidaqmxbase")
  3158. {
  3159. useBase= true;
  3160. }
  3161. else
  3162. {
  3163. useBase= false;
  3164. }
  3165. if(useBase)
  3166. {
  3167. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3168. if(!driver.load())
  3169. {
  3170. driver.setFileName("nidaqmxbase");
  3171. if(!driver.load())
  3172. {
  3173. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3174. tr("Failed to find nidaqmxbase. Please install it."));
  3175. QApplication::quit();
  3176. }
  3177. }
  3178. }
  3179. else
  3180. {
  3181. driver.setFileName("nicaiu");
  3182. if(!driver.load())
  3183. {
  3184. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3185. tr("Failed to find nidaqmx. Please install it."));
  3186. QApplication::quit();
  3187. }
  3188. }
  3189. if(useBase)
  3190. {
  3191. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3192. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3193. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3194. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3195. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3196. ==0||
  3197. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3198. 0||
  3199. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3200. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3201. 0||
  3202. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3203. {
  3204. waitForMeasurement= NULL;
  3205. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3206. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3207. QApplication::quit();
  3208. }
  3209. }
  3210. else
  3211. {
  3212. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3213. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3214. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3215. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3216. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3217. ==0||
  3218. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3219. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3220. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3221. 0||
  3222. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3223. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3224. {
  3225. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3226. tr("Failed to link a required symbol in NI-DAQmx."));
  3227. QApplication::quit();
  3228. }
  3229. }
  3230. }
  3231. DAQImplementation::~DAQImplementation()
  3232. {
  3233. driver.unload();
  3234. }
  3235. /*:316*/
  3236. #line 540 "./typica.w"
  3237. /*966:*/
  3238. #line 197 "./dataqsdk.w"
  3239. void DataqSdkDeviceImplementation::measure()
  3240. {
  3241. unsigned count= channels*40;
  3242. di_status_read(buffer,count);
  3243. QTime time= QTime::currentTime();
  3244. for(unsigned int i= 0;i<count;i++)
  3245. {
  3246. buffer[i]= buffer[i]&0xFFFC;
  3247. }
  3248. QList<int> countList;
  3249. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3250. {
  3251. QList<double> channelBuffer;
  3252. for(unsigned int j= 0;j<40;j++)
  3253. {
  3254. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3255. if(i==0)
  3256. {
  3257. countList<<buffer[i+(channels*j)];
  3258. }
  3259. }
  3260. double value= 0.0;
  3261. for(unsigned int j= 0;j<40;j++)
  3262. {
  3263. value+= channelBuffer[j];
  3264. }
  3265. value/= 40.0;
  3266. if(i==0)
  3267. {
  3268. QList<double> smoothingList;
  3269. smoothingList<<value;
  3270. QList<int> smoothingKeys= smoother.uniqueKeys();
  3271. for(int j= 0;j<smoothingKeys.size();j++)
  3272. {
  3273. if(countList.contains(smoothingKeys[j]))
  3274. {
  3275. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3276. for(int k= 0;k<keyValues.size();k++)
  3277. {
  3278. smoothingList<<keyValues[k];
  3279. }
  3280. }
  3281. else
  3282. {
  3283. smoother.remove(smoothingKeys[j]);
  3284. }
  3285. }
  3286. qSort(countList);
  3287. int lastCount= 0;
  3288. for(int j= 0;j<countList.size();j++)
  3289. {
  3290. if(j==0||countList[j]!=lastCount)
  3291. {
  3292. smoother.insert(countList[j],value);
  3293. lastCount= countList[j];
  3294. }
  3295. }
  3296. value= 0.0;
  3297. for(int j= 0;j<smoothingList.size();j++)
  3298. {
  3299. value+= smoothingList[j];
  3300. }
  3301. value/= smoothingList.size();
  3302. }
  3303. Measurement measure(value,time,unitMap[i]);
  3304. channelMap[i]->input(measure);
  3305. }
  3306. }
  3307. /*:966*//*967:*/
  3308. #line 290 "./dataqsdk.w"
  3309. void DataqSdkDeviceImplementation::run()
  3310. {
  3311. if(!ready)
  3312. {
  3313. error= 9;
  3314. return;
  3315. }
  3316. driver= new QLibrary(device);
  3317. if(!driver->load())
  3318. {
  3319. error= 1;
  3320. qDebug()<<"Failed to load driver: "<<device;
  3321. return;
  3322. }
  3323. di_open= (FPDIOPEN)driver->resolve("di_open");
  3324. di_close= (FPDICLOSE)driver->resolve("di_close");
  3325. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3326. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3327. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3328. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3329. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3330. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3331. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3332. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3333. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3334. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3335. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3336. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3337. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3338. (!di_burst_rate)||(!di_stop_scan))
  3339. {
  3340. error= 2;
  3341. return;
  3342. }
  3343. error= di_open(deviceNumber);
  3344. if(error)
  3345. {
  3346. di_close();
  3347. error= di_open(deviceNumber);
  3348. if(error)
  3349. {
  3350. error= 3;
  3351. di_close();
  3352. return;
  3353. }
  3354. }
  3355. isOpen= true;
  3356. di_maximum_rate(240.0);
  3357. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3358. &burstDivisor);
  3359. buffer= new qint16[(int)sampleRate];
  3360. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3361. for(unsigned short i= 0;i<channels;i++)
  3362. {
  3363. inlist[i].chan= i;
  3364. inlist[i].gain= 0;
  3365. inlist[i].ave= 1;
  3366. inlist[i].counter= (oversample-1);
  3367. }
  3368. error= di_list_length(channels,0);
  3369. if(error)
  3370. {
  3371. error= 4;
  3372. return;
  3373. }
  3374. error= di_inlist(inlist);
  3375. if(error)
  3376. {
  3377. error= 5;
  3378. return;
  3379. }
  3380. input_buffer= di_buffer_alloc(0,4096);
  3381. if(input_buffer==NULL)
  3382. {
  3383. error= 6;
  3384. return;
  3385. }
  3386. error= di_start_scan();
  3387. if(error)
  3388. {
  3389. error= 7;
  3390. return;
  3391. }
  3392. while(ready)
  3393. {
  3394. measure();
  3395. }
  3396. }
  3397. /*:967*//*968:*/
  3398. #line 386 "./dataqsdk.w"
  3399. void DataqSdkDevice::threadFinished()
  3400. {
  3401. if(imp->error)
  3402. {
  3403. /*969:*/
  3404. #line 400 "./dataqsdk.w"
  3405. imp->ready= false;
  3406. QMessageBox warning;
  3407. warning.setStandardButtons(QMessageBox::Cancel);
  3408. warning.setIcon(QMessageBox::Warning);
  3409. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3410. warning.setInformativeText(tr("An error occurred"));
  3411. warning.setWindowTitle(QString(PROGRAM_NAME));
  3412. warning.exec();
  3413. /*:969*/
  3414. #line 391 "./dataqsdk.w"
  3415. }
  3416. }
  3417. /*:968*//*970:*/
  3418. #line 417 "./dataqsdk.w"
  3419. void DataqSdkDevice::start()
  3420. {
  3421. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3422. imp->start();
  3423. }
  3424. /*:970*//*971:*/
  3425. #line 428 "./dataqsdk.w"
  3426. QStringList DataqSdkDevice::detectHardware()
  3427. {
  3428. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3429. QSettings::NativeFormat);
  3430. QStringList keys= deviceLookup.childKeys();
  3431. QStringList devices;
  3432. for(int i= 0;i<keys.size();i++)
  3433. {
  3434. QString value= deviceLookup.value(keys.at(i)).toString();
  3435. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3436. {
  3437. devices.append(value.split("\\").at(2));
  3438. }
  3439. }
  3440. QStringList portList;
  3441. foreach(QString device,devices)
  3442. {
  3443. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3444. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3445. portList.append(deviceEntry.value("FriendlyName").toString());
  3446. }
  3447. return portList;
  3448. }
  3449. QStringList DataqSdkDevice::detectPorts()
  3450. {
  3451. QStringList friendlyNames= detectHardware();
  3452. QStringList portList;
  3453. foreach(QString name,friendlyNames)
  3454. {
  3455. name.remove(0,name.indexOf("COM"));
  3456. name.chop(1);
  3457. portList.append(name);
  3458. }
  3459. return portList;
  3460. }
  3461. /*:971*//*972:*/
  3462. #line 473 "./dataqsdk.w"
  3463. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3464. {
  3465. bool usesAuto= false;
  3466. int autoIndex= device.toInt(&usesAuto);
  3467. QString finalizedPort;
  3468. if(usesAuto)
  3469. {
  3470. QStringList portList= detectPorts();
  3471. if(autoIndex> 0&&autoIndex<=portList.size())
  3472. {
  3473. finalizedPort= portList.at(autoIndex-1);
  3474. }
  3475. else
  3476. {
  3477. imp->error= 8;
  3478. qDebug()<<"Failed to detect port.";
  3479. }
  3480. }
  3481. else
  3482. {
  3483. finalizedPort= device;
  3484. }
  3485. int rstart= finalizedPort.indexOf("COM");
  3486. finalizedPort.remove(0,rstart+3);
  3487. bool chopFinished= false;
  3488. int finalizedPortNumber= 0;
  3489. while(finalizedPort.size()> 0&&!chopFinished)
  3490. {
  3491. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3492. if(!chopFinished)
  3493. {
  3494. finalizedPort.chop(1);
  3495. }
  3496. }
  3497. if(finalizedPortNumber<10)
  3498. {
  3499. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3500. }
  3501. else
  3502. {
  3503. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3504. }
  3505. imp->deviceNumber= 0x12C02D00;
  3506. imp->deviceNumber+= finalizedPortNumber;
  3507. imp->ready= true;
  3508. }
  3509. /*:972*//*973:*/
  3510. #line 523 "./dataqsdk.w"
  3511. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3512. {
  3513. Channel*retval= NULL;
  3514. if(imp->ready)
  3515. {
  3516. retval= new Channel();
  3517. imp->channelMap[imp->channels]= retval;
  3518. imp->unitMap[imp->channels]= scale;
  3519. imp->channels++;
  3520. }
  3521. return retval;
  3522. }
  3523. /*:973*//*974:*/
  3524. #line 547 "./dataqsdk.w"
  3525. void DataqSdkDevice::setClockRate(double Hz)
  3526. {
  3527. imp->sampleRate= Hz;
  3528. }
  3529. /*:974*//*975:*/
  3530. #line 557 "./dataqsdk.w"
  3531. DataqSdkDevice::~DataqSdkDevice()
  3532. {
  3533. if(imp->ready)
  3534. {
  3535. imp->ready= false;
  3536. }
  3537. imp->wait(ULONG_MAX);
  3538. delete imp;
  3539. }
  3540. /*:975*//*976:*/
  3541. #line 575 "./dataqsdk.w"
  3542. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3543. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3544. {
  3545. }
  3546. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3547. {
  3548. if(isOpen)
  3549. {
  3550. di_stop_scan();
  3551. di_close();
  3552. }
  3553. if(driver->isLoaded())
  3554. {
  3555. driver->unload();
  3556. }
  3557. }
  3558. /*:976*/
  3559. #line 541 "./typica.w"
  3560. /*323:*/
  3561. #line 7279 "./typica.w"
  3562. void FakeDAQImplementation::measure()
  3563. {
  3564. msleep((int)(1000/clockRate));
  3565. QTime time= QTime::currentTime();
  3566. for(int i= 0;i<channels;i++)
  3567. {
  3568. Measurement measure(qrand()%500,time);
  3569. channelMap[i]->input(measure);
  3570. }
  3571. }
  3572. /*:323*//*324:*/
  3573. #line 7293 "./typica.w"
  3574. void FakeDAQImplementation::run()
  3575. {
  3576. setPriority(QThread::TimeCriticalPriority);
  3577. while(ready)
  3578. {
  3579. measure();
  3580. }
  3581. }
  3582. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3583. channels(0),ready(false),clockRate(1)
  3584. {
  3585. }
  3586. FakeDAQImplementation::~FakeDAQImplementation()
  3587. {
  3588. }
  3589. /*:324*//*325:*/
  3590. #line 7318 "./typica.w"
  3591. void FakeDAQ::start()
  3592. {
  3593. if(imp->ready)
  3594. {
  3595. imp->start();
  3596. }
  3597. }
  3598. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3599. {
  3600. imp->ready= true;
  3601. }
  3602. Channel*FakeDAQ::newChannel(int,int)
  3603. {
  3604. Channel*retval;
  3605. if(imp->ready)
  3606. {
  3607. retval= new Channel();
  3608. imp->channelMap[imp->channels]= retval;
  3609. imp->channels++;
  3610. }
  3611. else
  3612. {
  3613. return NULL;
  3614. }
  3615. return retval;
  3616. }
  3617. void FakeDAQ::setClockRate(double Hz)
  3618. {
  3619. if(imp->ready)
  3620. {
  3621. imp->clockRate= Hz;
  3622. }
  3623. }
  3624. FakeDAQ::~FakeDAQ()
  3625. {
  3626. imp->ready= false;
  3627. imp->wait(ULONG_MAX);
  3628. delete imp;
  3629. }
  3630. /*:325*/
  3631. #line 542 "./typica.w"
  3632. /*330:*/
  3633. #line 7449 "./typica.w"
  3634. Channel::Channel():QObject(NULL)
  3635. {
  3636. }
  3637. Channel::~Channel()
  3638. {
  3639. }
  3640. void Channel::input(Measurement measurement)
  3641. {
  3642. emit newData(measurement);
  3643. }
  3644. /*:330*/
  3645. #line 543 "./typica.w"
  3646. /*346:*/
  3647. #line 7854 "./typica.w"
  3648. void TemperatureDisplay::setRelativeMode(bool relative)
  3649. {
  3650. r= relative;
  3651. }
  3652. /*:346*//*347:*/
  3653. #line 7871 "./typica.w"
  3654. void TemperatureDisplay::setValue(Measurement temperature)
  3655. {
  3656. QString number;
  3657. switch(unit)
  3658. {
  3659. case Units::Fahrenheit:
  3660. display(QString("%1'F").
  3661. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3662. 2)));
  3663. break;
  3664. case Units::Celsius:
  3665. if(!r){
  3666. display(QString("%1'C").
  3667. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3668. 2)));
  3669. }else{
  3670. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3671. display(QString("%1'C").arg(number));
  3672. }
  3673. break;
  3674. case Units::Kelvin:
  3675. if(!r){
  3676. display(QString("%1").
  3677. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3678. 2)));
  3679. }else{
  3680. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3681. display(QString("%1").arg(number));
  3682. }
  3683. break;
  3684. case Units::Rankine:
  3685. display(QString("%1'r").
  3686. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3687. 2)));
  3688. break;
  3689. case Units::Unitless:
  3690. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3691. break;
  3692. default:
  3693. switch(temperature.scale())
  3694. {
  3695. case Units::Fahrenheit:
  3696. display(QString("%1'F").
  3697. arg(number.setNum(temperature.temperature(),'f',2)));
  3698. break;
  3699. case Units::Celsius:
  3700. display(QString("%1'C").
  3701. arg(number.setNum(temperature.temperature(),'f',2)));
  3702. break;
  3703. case Units::Kelvin:
  3704. display(QString("%1").
  3705. arg(number.setNum(temperature.temperature(),'f',2)));
  3706. break;
  3707. case Units::Rankine:
  3708. display(QString("%1'r").
  3709. arg(number.setNum(temperature.temperature(),'f',2)));
  3710. break;
  3711. case Units::Unitless:
  3712. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3713. break;
  3714. default:
  3715. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  3716. break;
  3717. }
  3718. break;
  3719. }
  3720. }
  3721. /*:347*//*348:*/
  3722. #line 7950 "./typica.w"
  3723. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3724. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3725. {
  3726. setSegmentStyle(Filled);
  3727. display("---.--'F");
  3728. }
  3729. /*:348*//*349:*/
  3730. #line 7966 "./typica.w"
  3731. void TemperatureDisplay::invalidate()
  3732. {
  3733. display("---.--'F");
  3734. }
  3735. /*:349*//*350:*/
  3736. #line 7978 "./typica.w"
  3737. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3738. {
  3739. unit= scale;
  3740. }
  3741. /*:350*//*351:*/
  3742. #line 7986 "./typica.w"
  3743. TemperatureDisplay::~TemperatureDisplay()
  3744. {
  3745. }
  3746. /*:351*/
  3747. #line 544 "./typica.w"
  3748. /*357:*/
  3749. #line 8086 "./typica.w"
  3750. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3751. {
  3752. if(measure.time()<epoch)
  3753. {
  3754. if(hasPrevious)
  3755. {
  3756. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3757. epoch.msec());
  3758. QTime jitComp(epoch.hour(),measure.time().minute(),
  3759. measure.time().second(),measure.time().msec());
  3760. int relTime= jitBase.msecsTo(jitComp);
  3761. /*358:*/
  3762. #line 8120 "./typica.w"
  3763. QTime newTime(0,0,0,0);
  3764. newTime= newTime.addMSecs(relTime);
  3765. if(newTime.hour()> 0)
  3766. {
  3767. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3768. }
  3769. Measurement rel= measure;
  3770. rel.setTime(newTime);
  3771. emit measurement(rel);
  3772. /*:358*/
  3773. #line 8098 "./typica.w"
  3774. }
  3775. else
  3776. {
  3777. Measurement rel= measure;
  3778. rel.setTime(QTime(0,0,0,0));
  3779. emit measurement(rel);
  3780. }
  3781. }
  3782. else
  3783. {
  3784. int relTime= epoch.msecsTo(measure.time());
  3785. /*358:*/
  3786. #line 8120 "./typica.w"
  3787. QTime newTime(0,0,0,0);
  3788. newTime= newTime.addMSecs(relTime);
  3789. if(newTime.hour()> 0)
  3790. {
  3791. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3792. }
  3793. Measurement rel= measure;
  3794. rel.setTime(newTime);
  3795. emit measurement(rel);
  3796. /*:358*/
  3797. #line 8110 "./typica.w"
  3798. }
  3799. hasPrevious= true;
  3800. previous= measure.time();
  3801. }
  3802. /*:357*//*359:*/
  3803. #line 8133 "./typica.w"
  3804. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3805. previous(0,0,0,0),hasPrevious(false)
  3806. {
  3807. }
  3808. QTime MeasurementTimeOffset::zeroTime()
  3809. {
  3810. return epoch;
  3811. }
  3812. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3813. {
  3814. epoch= zero;
  3815. hasPrevious= false;
  3816. }
  3817. /*:359*/
  3818. #line 545 "./typica.w"
  3819. /*369:*/
  3820. #line 8331 "./typica.w"
  3821. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3822. {
  3823. }
  3824. int ZeroEmitter::column()
  3825. {
  3826. return col;
  3827. }
  3828. double ZeroEmitter::lastTemperature()
  3829. {
  3830. return cache.temperature();
  3831. }
  3832. void ZeroEmitter::newMeasurement(Measurement measure)
  3833. {
  3834. cache= measure;
  3835. }
  3836. void ZeroEmitter::setColumn(int column)
  3837. {
  3838. col= column;
  3839. }
  3840. void ZeroEmitter::emitZero()
  3841. {
  3842. cache.setTime(QTime(0,0,0,0));
  3843. emit measurement(cache,col);
  3844. }
  3845. /*:369*/
  3846. #line 546 "./typica.w"
  3847. /*374:*/
  3848. #line 8421 "./typica.w"
  3849. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3850. {
  3851. }
  3852. int MeasurementAdapter::column()
  3853. {
  3854. return col;
  3855. }
  3856. void MeasurementAdapter::newMeasurement(Measurement measure)
  3857. {
  3858. emit measurement(measure,col);
  3859. }
  3860. void MeasurementAdapter::setColumn(int column)
  3861. {
  3862. col= column;
  3863. }
  3864. /*:374*/
  3865. #line 547 "./typica.w"
  3866. /*379:*/
  3867. #line 8543 "./typica.w"
  3868. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3869. theScene(new QGraphicsScene),
  3870. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3871. prevPoints(new QMap<int,QPointF> ),
  3872. translations(new QMap<int,double> ),
  3873. gridLinesF(new QList<QGraphicsItem*> ),
  3874. gridLinesC(new QList<QGraphicsItem*> ),
  3875. relativeGridLines(new QList<QGraphicsItem*> ),
  3876. relativeEnabled(false),
  3877. timeIndicatorEnabled(false),
  3878. timeLine(new QGraphicsLineItem),
  3879. relativeAdjuster(new LinearSplineInterpolator)
  3880. {
  3881. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3882. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3883. setScene(theScene);
  3884. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3885. QPen timePen;
  3886. timePen.setColor(QColor(160,160,164,127));
  3887. timeLine->setPen(timePen);
  3888. timeLine->setLine(0,0,0,-500);
  3889. timeLine->hide();
  3890. theScene->addItem(timeLine);
  3891. /*380:*/
  3892. #line 8583 "./typica.w"
  3893. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3894. tempaxis->setLine(-10,-500,-10,0);
  3895. theScene->addItem(tempaxis);
  3896. QGraphicsLineItem*gridLine;
  3897. QGraphicsTextItem*label;
  3898. for(int y= -100;y> -600;y-= 100)
  3899. {
  3900. gridLine= new QGraphicsLineItem;
  3901. gridLine->setLine(0,y,1200,y);
  3902. theScene->addItem(gridLine);
  3903. label= new QGraphicsTextItem;
  3904. label->setHtml(QString("%1&deg;F").arg(-y));
  3905. label->setPos(-55,y-(label->boundingRect().height()/2));
  3906. theScene->addItem(label);
  3907. gridLinesF->append(gridLine);
  3908. gridLinesF->append(label);
  3909. }
  3910. for(int degC= 50;degC<=250;degC+= 50)
  3911. {
  3912. gridLine= new QGraphicsLineItem;
  3913. int y= -(degC*(9.0/5.0)+32);
  3914. gridLine->setLine(0,y,1200,y);
  3915. gridLine->hide();
  3916. theScene->addItem(gridLine);
  3917. gridLinesC->append(gridLine);
  3918. label= new QGraphicsTextItem;
  3919. label->setHtml(QString("%1&deg;C").arg(degC));
  3920. label->setPos(-55,y-(label->boundingRect().height()/2));
  3921. label->hide();
  3922. theScene->addItem(label);
  3923. gridLinesC->append(label);
  3924. }
  3925. /*:380*/
  3926. #line 8567 "./typica.w"
  3927. ;
  3928. /*381:*/
  3929. #line 8624 "./typica.w"
  3930. QSettings settings;
  3931. if(settings.contains("settings/graph/relative/enable"))
  3932. {
  3933. if(settings.value("settings/graph/relative/enable").toBool())
  3934. {
  3935. relativeEnabled= true;
  3936. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  3937. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  3938. QMap<double,QString> relativeAxisPairs;
  3939. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  3940. foreach(QString item,relativeAxisLabels)
  3941. {
  3942. relativeAxisPairs.insert(item.toDouble(),item);
  3943. }
  3944. if(relativeAxisPairs.size()> 1)
  3945. {
  3946. double skip= 500.0/(relativeAxisPairs.size()-1);
  3947. double y= 0;
  3948. foreach(double key,relativeAxisPairs.keys())
  3949. {
  3950. gridLine= new QGraphicsLineItem;
  3951. gridLine->setLine(0,y,1205,y);
  3952. gridLine->setPen(QPen(relativeColor));
  3953. theScene->addItem(gridLine);
  3954. relativeGridLines->append(gridLine);
  3955. label= new QGraphicsTextItem;
  3956. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  3957. label->setPos(1210,y-(label->boundingRect().height()/2));
  3958. theScene->addItem(label);
  3959. relativeGridLines->append(label);
  3960. if(unit=="F")
  3961. {
  3962. relativeAdjuster->add_pair(key,-y);
  3963. }
  3964. else
  3965. {
  3966. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  3967. }
  3968. y-= skip;
  3969. }
  3970. }
  3971. }
  3972. }
  3973. /*:381*/
  3974. #line 8568 "./typica.w"
  3975. /*383:*/
  3976. #line 8701 "./typica.w"
  3977. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  3978. timeaxis->setLine(0,10,1200,10);
  3979. theScene->addItem(timeaxis);
  3980. for(int x= 0;x<1201;x+= 120)
  3981. {
  3982. QGraphicsLineItem*tick= new QGraphicsLineItem;
  3983. tick->setLine(x,0,x,20);
  3984. theScene->addItem(tick);
  3985. QGraphicsTextItem*label= new QGraphicsTextItem;
  3986. label->setPlainText(QString("%1").arg(x/60));
  3987. label->setPos(x-(label->boundingRect().width()/2),20);
  3988. theScene->addItem(label);
  3989. }
  3990. /*:383*/
  3991. #line 8569 "./typica.w"
  3992. ;
  3993. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3994. }
  3995. /*:379*//*382:*/
  3996. #line 8671 "./typica.w"
  3997. void GraphView::showF()
  3998. {
  3999. for(int i= 0;i<gridLinesF->size();i++)
  4000. {
  4001. gridLinesF->at(i)->show();
  4002. }
  4003. for(int i= 0;i<gridLinesC->size();i++)
  4004. {
  4005. gridLinesC->at(i)->hide();
  4006. }
  4007. }
  4008. void GraphView::showC()
  4009. {
  4010. for(int i= 0;i<gridLinesF->size();i++)
  4011. {
  4012. gridLinesF->at(i)->hide();
  4013. }
  4014. for(int i= 0;i<gridLinesC->size();i++)
  4015. {
  4016. gridLinesC->at(i)->show();
  4017. }
  4018. }
  4019. /*:382*//*384:*/
  4020. #line 8720 "./typica.w"
  4021. void GraphView::resizeEvent(QResizeEvent*)
  4022. {
  4023. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4024. }
  4025. /*:384*//*385:*/
  4026. #line 8734 "./typica.w"
  4027. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4028. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4029. {
  4030. double offset= 0;
  4031. if(measure.contains("relative"))
  4032. {
  4033. if(measure.value("relative").toBool())
  4034. {
  4035. if(relativeEnabled)
  4036. {
  4037. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4038. }
  4039. else
  4040. {
  4041. return;
  4042. }
  4043. }
  4044. }
  4045. if(translations->contains(tempcolumn))
  4046. {
  4047. offset= translations->value(tempcolumn);
  4048. }
  4049. if(prevPoints->contains(tempcolumn))
  4050. {
  4051. /*387:*/
  4052. #line 8811 "./typica.w"
  4053. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4054. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4055. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4056. -(prevPoints->value(tempcolumn).y()),
  4057. nextPoint.x()+offset,-(nextPoint.y()));
  4058. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4059. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4060. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4061. Qt::darkYellow};
  4062. segment->setPen(p[tempcolumn%12]);
  4063. theScene->addItem(segment);
  4064. prevPoints->insert(tempcolumn,nextPoint);
  4065. if(timeIndicatorEnabled)
  4066. {
  4067. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4068. }
  4069. /*:387*/
  4070. #line 8760 "./typica.w"
  4071. if(graphLines->contains(tempcolumn))
  4072. {
  4073. graphLines->value(tempcolumn)->append(segment);
  4074. }
  4075. else
  4076. {
  4077. QList<QGraphicsLineItem*> *newLine=
  4078. new QList<QGraphicsLineItem*> ;
  4079. newLine->append(segment);
  4080. graphLines->insert(tempcolumn,newLine);
  4081. }
  4082. }
  4083. else
  4084. {
  4085. /*386:*/
  4086. #line 8796 "./typica.w"
  4087. int x= FULLTIMETOINT(measure.time())/1000;
  4088. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4089. if(timeIndicatorEnabled)
  4090. {
  4091. timeLine->setLine(x,0,x,-500);
  4092. }
  4093. /*:386*/
  4094. #line 8777 "./typica.w"
  4095. }
  4096. }
  4097. /*:385*//*388:*/
  4098. #line 8832 "./typica.w"
  4099. void GraphView::clear()
  4100. {
  4101. int i;
  4102. foreach(i,prevPoints->keys())
  4103. {
  4104. removeSeries(i);
  4105. }
  4106. translations->clear();
  4107. }
  4108. /*:388*//*389:*/
  4109. #line 8846 "./typica.w"
  4110. void GraphView::removeSeries(int column)
  4111. {
  4112. if(graphLines->contains(column))
  4113. {
  4114. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4115. QGraphicsLineItem*segment;
  4116. foreach(segment,*series)
  4117. {
  4118. theScene->removeItem(segment);
  4119. }
  4120. qDeleteAll(*series);
  4121. }
  4122. graphLines->remove(column);
  4123. prevPoints->remove(column);
  4124. }
  4125. /*:389*//*390:*/
  4126. #line 8865 "./typica.w"
  4127. void GraphView::setSeriesTranslation(int column,double offset)
  4128. {
  4129. if(graphLines->contains(column))
  4130. {
  4131. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4132. QGraphicsLineItem*segment;
  4133. foreach(segment,*series)
  4134. {
  4135. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4136. }
  4137. }
  4138. if(translations->contains(column))
  4139. {
  4140. translations->insert(column,offset+translations->value(column));
  4141. }
  4142. else
  4143. {
  4144. translations->insert(column,offset);
  4145. }
  4146. }
  4147. /*:390*//*391:*/
  4148. #line 8892 "./typica.w"
  4149. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4150. {
  4151. timeIndicatorEnabled= enabled;
  4152. if(enabled)
  4153. {
  4154. timeLine->show();
  4155. }
  4156. else
  4157. {
  4158. timeLine->hide();
  4159. }
  4160. }
  4161. /*:391*/
  4162. #line 548 "./typica.w"
  4163. /*397:*/
  4164. #line 9036 "./typica.w"
  4165. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4166. {
  4167. if(measure.time()!=QTime(0,0,0,0))
  4168. {
  4169. /*399:*/
  4170. #line 9110 "./typica.w"
  4171. if(lastMeasurement.contains(tempcolumn))
  4172. {
  4173. if(lastMeasurement[tempcolumn].time()<measure.time())
  4174. {
  4175. QList<QTime> timelist;
  4176. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4177. {
  4178. timelist.append(i);
  4179. }
  4180. for(int i= 0;i<timelist.size();i++)
  4181. {
  4182. Measurement synthesized= measure;
  4183. synthesized.setTime(timelist[i]);
  4184. newMeasurement(synthesized,tempcolumn);
  4185. }
  4186. }
  4187. }
  4188. /*:399*/
  4189. #line 9041 "./typica.w"
  4190. }
  4191. model_ms->newMeasurement(measure,tempcolumn);
  4192. if(lastMeasurement.contains(tempcolumn))
  4193. {
  4194. if(measure.time().second()!=
  4195. lastMeasurement.value(tempcolumn).time().second())
  4196. {
  4197. Measurement adjusted= measure;
  4198. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4199. adjusted.setTime(adjtime);
  4200. model_1s->newMeasurement(adjusted,tempcolumn);
  4201. if(adjusted.time().second()%5==0)
  4202. {
  4203. model_5s->newMeasurement(adjusted,tempcolumn);
  4204. if(adjusted.time().second()%10==0)
  4205. {
  4206. model_10s->newMeasurement(adjusted,tempcolumn);
  4207. }
  4208. if(adjusted.time().second()%15==0)
  4209. {
  4210. model_15s->newMeasurement(adjusted,tempcolumn);
  4211. if(adjusted.time().second()%30==0)
  4212. {
  4213. model_30s->newMeasurement(adjusted,tempcolumn);
  4214. if(adjusted.time().second()==0)
  4215. {
  4216. model_1m->newMeasurement(adjusted,tempcolumn);
  4217. }
  4218. }
  4219. }
  4220. }
  4221. }
  4222. /*401:*/
  4223. #line 9154 "./typica.w"
  4224. if(currentColumnSet.contains(tempcolumn))
  4225. {
  4226. int replicationcolumn;
  4227. foreach(replicationcolumn,currentColumnSet)
  4228. {
  4229. if(replicationcolumn!=tempcolumn)
  4230. {
  4231. if(lastMeasurement.contains(replicationcolumn))
  4232. {
  4233. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4234. {
  4235. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4236. synthetic.setTime(measure.time());
  4237. model_ms->newMeasurement(synthetic,replicationcolumn);
  4238. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4239. {
  4240. Measurement adjusted= synthetic;
  4241. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4242. model_1s->newMeasurement(adjusted,replicationcolumn);
  4243. if(adjusted.time().second()%5==0)
  4244. {
  4245. model_5s->newMeasurement(adjusted,replicationcolumn);
  4246. if(adjusted.time().second()%10==0)
  4247. {
  4248. model_10s->newMeasurement(adjusted,replicationcolumn);
  4249. }
  4250. if(adjusted.time().second()%15==0)
  4251. {
  4252. model_15s->newMeasurement(adjusted,replicationcolumn);
  4253. if(adjusted.time().second()%30==0)
  4254. {
  4255. model_30s->newMeasurement(adjusted,replicationcolumn);
  4256. if(adjusted.time().second()==0)
  4257. {
  4258. model_1m->newMeasurement(adjusted,replicationcolumn);
  4259. }
  4260. }
  4261. }
  4262. }
  4263. }
  4264. lastMeasurement[replicationcolumn]= synthetic;
  4265. }
  4266. }
  4267. }
  4268. }
  4269. }
  4270. /*:401*/
  4271. #line 9074 "./typica.w"
  4272. }
  4273. else
  4274. {
  4275. /*398:*/
  4276. #line 9086 "./typica.w"
  4277. MeasurementModel*m;
  4278. foreach(m,modelSet)
  4279. {
  4280. m->newMeasurement(measure,tempcolumn);
  4281. }
  4282. /*:398*/
  4283. #line 9078 "./typica.w"
  4284. }
  4285. lastMeasurement.insert(tempcolumn,measure);
  4286. }
  4287. /*:397*//*400:*/
  4288. #line 9140 "./typica.w"
  4289. void ZoomLog::addToCurrentColumnSet(int column)
  4290. {
  4291. currentColumnSet.append(column);
  4292. }
  4293. void ZoomLog::clearCurrentColumnSet()
  4294. {
  4295. currentColumnSet.clear();
  4296. }
  4297. /*:400*//*402:*/
  4298. #line 9224 "./typica.w"
  4299. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4300. int annotationcolumn)
  4301. {
  4302. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4303. MeasurementModel*m;
  4304. if(lastMeasurement.contains(tempcolumn))
  4305. {
  4306. foreach(m,modelSet)
  4307. {
  4308. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4309. }
  4310. }
  4311. foreach(m,modelSet)
  4312. {
  4313. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4314. }
  4315. }
  4316. /*:402*//*403:*/
  4317. #line 9248 "./typica.w"
  4318. void ZoomLog::centerOn(int row)
  4319. {
  4320. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4321. }
  4322. /*:403*//*404:*/
  4323. #line 9258 "./typica.w"
  4324. void ZoomLog::clear()
  4325. {
  4326. MeasurementModel*m;
  4327. foreach(m,modelSet)
  4328. {
  4329. m->clear();
  4330. }
  4331. lastMeasurement.clear();
  4332. saveTempCols.clear();
  4333. saveControlCols.clear();
  4334. saveNoteCols.clear();
  4335. }
  4336. /*:404*//*405:*/
  4337. #line 9276 "./typica.w"
  4338. QVariant ZoomLog::data(int row,int column)const
  4339. {
  4340. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4341. Qt::DisplayRole);
  4342. }
  4343. int ZoomLog::rowCount()
  4344. {
  4345. return model_ms->rowCount();
  4346. }
  4347. /*:405*//*406:*/
  4348. #line 9299 "./typica.w"
  4349. bool ZoomLog::saveXML(QIODevice*device)
  4350. {
  4351. Units::Unit prevUnits= model_ms->displayUnits();
  4352. if(prevUnits!=Units::Fahrenheit)
  4353. {
  4354. model_ms->setDisplayUnits(Units::Fahrenheit);
  4355. }
  4356. XMLOutput writer(model_ms,device,0);
  4357. int c;
  4358. foreach(c,saveTempCols)
  4359. {
  4360. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4361. toString(),c);
  4362. }
  4363. foreach(c,saveControlCols)
  4364. {
  4365. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4366. toString(),c);
  4367. }
  4368. foreach(c,saveNoteCols)
  4369. {
  4370. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4371. toString(),c);
  4372. }
  4373. bool retval= writer.output();
  4374. if(prevUnits!=Units::Fahrenheit)
  4375. {
  4376. model_ms->setDisplayUnits(prevUnits);
  4377. }
  4378. return retval;
  4379. }
  4380. /*:406*//*407:*/
  4381. #line 9335 "./typica.w"
  4382. bool ZoomLog::saveCSV(QIODevice*device)
  4383. {
  4384. CSVOutput writer(currentModel,device,0);
  4385. int c;
  4386. foreach(c,saveTempCols)
  4387. {
  4388. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4389. toString(),c);
  4390. }
  4391. foreach(c,saveControlCols)
  4392. {
  4393. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4394. toString(),c);
  4395. }
  4396. foreach(c,saveNoteCols)
  4397. {
  4398. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4399. toString(),c);
  4400. }
  4401. return writer.output();
  4402. }
  4403. /*:407*//*408:*/
  4404. #line 9364 "./typica.w"
  4405. void ZoomLog::switchLOD(MeasurementModel*m)
  4406. {
  4407. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4408. setModel(m);
  4409. currentModel= m;
  4410. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4411. }
  4412. void ZoomLog::LOD_ms()
  4413. {
  4414. switchLOD(model_ms);
  4415. }
  4416. void ZoomLog::LOD_1s()
  4417. {
  4418. switchLOD(model_1s);
  4419. }
  4420. void ZoomLog::LOD_5s()
  4421. {
  4422. switchLOD(model_5s);
  4423. }
  4424. void ZoomLog::LOD_10s()
  4425. {
  4426. switchLOD(model_10s);
  4427. }
  4428. void ZoomLog::LOD_15s()
  4429. {
  4430. switchLOD(model_15s);
  4431. }
  4432. void ZoomLog::LOD_30s()
  4433. {
  4434. switchLOD(model_30s);
  4435. }
  4436. void ZoomLog::LOD_1m()
  4437. {
  4438. switchLOD(model_1m);
  4439. }
  4440. /*:408*//*409:*/
  4441. #line 9412 "./typica.w"
  4442. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4443. {
  4444. model_ms->setDisplayUnits(scale);
  4445. model_1s->setDisplayUnits(scale);
  4446. model_5s->setDisplayUnits(scale);
  4447. model_10s->setDisplayUnits(scale);
  4448. model_15s->setDisplayUnits(scale);
  4449. model_30s->setDisplayUnits(scale);
  4450. model_1m->setDisplayUnits(scale);
  4451. }
  4452. Units::Unit ZoomLog::displayUnits()
  4453. {
  4454. return model_ms->displayUnits();
  4455. }
  4456. /*:409*//*410:*/
  4457. #line 9432 "./typica.w"
  4458. QString ZoomLog::lastTime(int series)
  4459. {
  4460. Measurement measure= lastMeasurement.value(series);
  4461. QTime time= measure.time();
  4462. return time.toString("h:mm:ss.zzz");
  4463. }
  4464. /*:410*//*411:*/
  4465. #line 9442 "./typica.w"
  4466. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4467. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4468. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4469. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4470. {
  4471. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4472. setSelectionMode(QAbstractItemView::NoSelection);
  4473. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4474. model_30s<<model_1m;
  4475. currentModel= model_30s;
  4476. setModel(currentModel);
  4477. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4478. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4479. this,SLOT(persistColumnResize(int,int,int)));
  4480. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4481. this,SLOT(restoreColumnWidths()));
  4482. }
  4483. /*:411*//*412:*/
  4484. #line 9465 "./typica.w"
  4485. void ZoomLog::setHeaderData(int section,QString text)
  4486. {
  4487. MeasurementModel*m;
  4488. foreach(m,modelSet)
  4489. {
  4490. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4491. }
  4492. }
  4493. /*:412*//*413:*/
  4494. #line 9483 "./typica.w"
  4495. void ZoomLog::addOutputTemperatureColumn(int column)
  4496. {
  4497. saveTempCols.append(column);
  4498. }
  4499. void ZoomLog::addOutputControlColumn(int column)
  4500. {
  4501. saveControlCols.append(column);
  4502. }
  4503. void ZoomLog::addOutputAnnotationColumn(int column)
  4504. {
  4505. saveNoteCols.append(column);
  4506. }
  4507. void ZoomLog::clearOutputColumns()
  4508. {
  4509. saveTempCols.clear();
  4510. saveControlCols.clear();
  4511. saveNoteCols.clear();
  4512. }
  4513. /*:413*//*414:*/
  4514. #line 9509 "./typica.w"
  4515. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4516. {
  4517. /*629:*/
  4518. #line 13655 "./typica.w"
  4519. QSettings settings;
  4520. /*630:*/
  4521. #line 13668 "./typica.w"
  4522. QWidget*topLevelWidget= this;
  4523. while(topLevelWidget->parentWidget())
  4524. {
  4525. topLevelWidget= topLevelWidget->parentWidget();
  4526. }
  4527. /*:630*/
  4528. #line 13657 "./typica.w"
  4529. settings.setValue(QString("columnWidths/%1/%2/%3").
  4530. arg(topLevelWidget->objectName()).
  4531. arg(objectName()).arg(column),
  4532. QVariant(newsize));
  4533. /*:629*/
  4534. #line 9512 "./typica.w"
  4535. }
  4536. void ZoomLog::restoreColumnWidths()
  4537. {
  4538. /*632:*/
  4539. #line 13688 "./typica.w"
  4540. QSettings settings;
  4541. /*630:*/
  4542. #line 13668 "./typica.w"
  4543. QWidget*topLevelWidget= this;
  4544. while(topLevelWidget->parentWidget())
  4545. {
  4546. topLevelWidget= topLevelWidget->parentWidget();
  4547. }
  4548. /*:630*/
  4549. #line 13690 "./typica.w"
  4550. QString baseKey=
  4551. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4552. arg(objectName());
  4553. for(int i= 0;i<model()->columnCount();i++)
  4554. {
  4555. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4556. if(settings.contains(key))
  4557. {
  4558. setColumnWidth(i,settings.value(key).toInt());
  4559. }
  4560. }
  4561. /*:632*/
  4562. #line 9517 "./typica.w"
  4563. }
  4564. void ZoomLog::setVisible(bool visibility)
  4565. {
  4566. QTableView::setVisible(visibility);
  4567. }
  4568. void ZoomLog::showEvent(QShowEvent*)
  4569. {
  4570. /*632:*/
  4571. #line 13688 "./typica.w"
  4572. QSettings settings;
  4573. /*630:*/
  4574. #line 13668 "./typica.w"
  4575. QWidget*topLevelWidget= this;
  4576. while(topLevelWidget->parentWidget())
  4577. {
  4578. topLevelWidget= topLevelWidget->parentWidget();
  4579. }
  4580. /*:630*/
  4581. #line 13690 "./typica.w"
  4582. QString baseKey=
  4583. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4584. arg(objectName());
  4585. for(int i= 0;i<model()->columnCount();i++)
  4586. {
  4587. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4588. if(settings.contains(key))
  4589. {
  4590. setColumnWidth(i,settings.value(key).toInt());
  4591. }
  4592. }
  4593. /*:632*/
  4594. #line 9527 "./typica.w"
  4595. }
  4596. /*:414*/
  4597. #line 549 "./typica.w"
  4598. /*423:*/
  4599. #line 9760 "./typica.w"
  4600. bool MeasurementList::operator<(const MeasurementList&other)const
  4601. {
  4602. return this->first().toTime()<other.first().toTime();
  4603. }
  4604. bool MeasurementList::operator==(const MeasurementList&other)const
  4605. {
  4606. return this->first().toTime()==other.first().toTime();
  4607. }
  4608. /*:423*//*424:*/
  4609. #line 9776 "./typica.w"
  4610. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4611. {
  4612. return QModelIndex();
  4613. }
  4614. /*:424*//*425:*/
  4615. #line 9786 "./typica.w"
  4616. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4617. {
  4618. if(measure.scale()==Units::Unitless)
  4619. {
  4620. controlColumns->insert(tempcolumn,true);
  4621. }
  4622. else
  4623. {
  4624. controlColumns->insert(tempcolumn,false);
  4625. }
  4626. MeasurementList*temp;
  4627. temp= new MeasurementList;
  4628. temp->append(QVariant(measure.time()));
  4629. /*426:*/
  4630. #line 9845 "./typica.w"
  4631. /*427:*/
  4632. #line 9890 "./typica.w"
  4633. QList<MeasurementList*> ::iterator i= lastInsertion;
  4634. bool quickscan= false;
  4635. if(entries->size()> 5)
  4636. {
  4637. if(**i<*temp)
  4638. {
  4639. i+= 1;
  4640. for(int j= 10;j> 0;j--)
  4641. {
  4642. if(i!=entries->end())
  4643. {
  4644. if(**i<*temp)
  4645. {
  4646. i+= 1;
  4647. }
  4648. else
  4649. {
  4650. quickscan= true;
  4651. break;
  4652. }
  4653. }
  4654. else
  4655. {
  4656. quickscan= true;
  4657. break;
  4658. }
  4659. }
  4660. }
  4661. else
  4662. {
  4663. if(**i==*temp)
  4664. {
  4665. quickscan= true;
  4666. }
  4667. }
  4668. }
  4669. /*:427*/
  4670. #line 9846 "./typica.w"
  4671. if(quickscan==false)
  4672. {
  4673. i= entries->begin();
  4674. QList<MeasurementList*> ::iterator u= entries->end();
  4675. QList<MeasurementList*> ::iterator midpoint;
  4676. int n= u-i;
  4677. int rA;
  4678. while(n> 0)
  4679. {
  4680. rA= n>>1;
  4681. midpoint= i+rA;
  4682. if(**midpoint<*temp)
  4683. {
  4684. i= midpoint+1;
  4685. n-= rA+1;
  4686. }
  4687. else
  4688. {
  4689. n= rA;
  4690. }
  4691. }
  4692. }
  4693. /*:426*/
  4694. #line 9800 "./typica.w"
  4695. MeasurementList*newEntry;
  4696. int insertion;
  4697. if(i!=entries->end())
  4698. {
  4699. insertion= entries->indexOf(*i);
  4700. if((*i)->first().toTime()==measure.time())
  4701. {
  4702. /*428:*/
  4703. #line 9932 "./typica.w"
  4704. if((*i)->size()<tempcolumn+1)
  4705. {
  4706. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4707. {
  4708. (*i)->append(QVariant());
  4709. }
  4710. }
  4711. (*i)->replace(tempcolumn,measure);
  4712. lastInsertion= i;
  4713. emit dataChanged(createIndex(insertion,tempcolumn),
  4714. createIndex(insertion,tempcolumn));
  4715. lastTemperature->insert(tempcolumn,insertion);
  4716. /*:428*/
  4717. #line 9808 "./typica.w"
  4718. }
  4719. else
  4720. {
  4721. /*429:*/
  4722. #line 9950 "./typica.w"
  4723. beginInsertRows(QModelIndex(),insertion,insertion);
  4724. newEntry= new MeasurementList;
  4725. newEntry->append(QVariant(measure.time()));
  4726. for(int j= 0;j<tempcolumn+1;j++)
  4727. {
  4728. newEntry->append(QVariant());
  4729. }
  4730. newEntry->replace(tempcolumn,measure);
  4731. lastInsertion= entries->insert(i,newEntry);
  4732. endInsertRows();
  4733. lastTemperature->insert(tempcolumn,insertion);
  4734. /*:429*/
  4735. #line 9812 "./typica.w"
  4736. }
  4737. }
  4738. else
  4739. {
  4740. /*430:*/
  4741. #line 9968 "./typica.w"
  4742. insertion= entries->size();
  4743. /*429:*/
  4744. #line 9950 "./typica.w"
  4745. beginInsertRows(QModelIndex(),insertion,insertion);
  4746. newEntry= new MeasurementList;
  4747. newEntry->append(QVariant(measure.time()));
  4748. for(int j= 0;j<tempcolumn+1;j++)
  4749. {
  4750. newEntry->append(QVariant());
  4751. }
  4752. newEntry->replace(tempcolumn,measure);
  4753. lastInsertion= entries->insert(i,newEntry);
  4754. endInsertRows();
  4755. lastTemperature->insert(tempcolumn,insertion);
  4756. /*:429*/
  4757. #line 9970 "./typica.w"
  4758. /*:430*/
  4759. #line 9817 "./typica.w"
  4760. }
  4761. if(tempcolumn>=colcount)
  4762. {
  4763. colcount= tempcolumn+1;
  4764. }
  4765. emit rowChanged(insertion);
  4766. delete temp;
  4767. }
  4768. /*:425*//*431:*/
  4769. #line 9980 "./typica.w"
  4770. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4771. int annotationColumn)
  4772. {
  4773. int r;
  4774. if(lastTemperature->contains(tempcolumn))
  4775. {
  4776. r= lastTemperature->value(tempcolumn);
  4777. }
  4778. else
  4779. {
  4780. r= 0;
  4781. }
  4782. if(r==0&&entries->size()==0)
  4783. {
  4784. /*432:*/
  4785. #line 10018 "./typica.w"
  4786. beginInsertRows(QModelIndex(),0,0);
  4787. MeasurementList*newEntry= new MeasurementList;
  4788. newEntry->append(QVariant(QTime(0,0,0,0)));
  4789. entries->append(newEntry);
  4790. endInsertRows();
  4791. /*:432*/
  4792. #line 9995 "./typica.w"
  4793. }
  4794. MeasurementList*row= entries->at(r);
  4795. if(row->size()<=annotationColumn)
  4796. {
  4797. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4798. {
  4799. row->append(QVariant());
  4800. }
  4801. }
  4802. row->replace(annotationColumn,annotation);
  4803. emit dataChanged(createIndex(r,annotationColumn),
  4804. createIndex(r,annotationColumn));
  4805. emit rowChanged(r);
  4806. if(annotationColumn> colcount-1)
  4807. {
  4808. colcount= annotationColumn+1;
  4809. }
  4810. }
  4811. /*:431*//*433:*/
  4812. #line 10029 "./typica.w"
  4813. void MeasurementModel::clear()
  4814. {
  4815. beginRemoveRows(QModelIndex(),0,entries->size());
  4816. while(entries->size()!=0)
  4817. {
  4818. MeasurementList*row= entries->takeFirst();
  4819. delete row;
  4820. }
  4821. endRemoveRows();
  4822. colcount= hData->size();
  4823. lastTemperature->clear();
  4824. reset();
  4825. }
  4826. /*:433*//*434:*/
  4827. #line 10062 "./typica.w"
  4828. bool MeasurementModel::setData(const QModelIndex&index,
  4829. const QVariant&value,int role)
  4830. {
  4831. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4832. {
  4833. return false;
  4834. }
  4835. /*435:*/
  4836. #line 10094 "./typica.w"
  4837. bool valid= false;
  4838. if(index.isValid())
  4839. {
  4840. if(index.row()<entries->size())
  4841. {
  4842. if(index.column()<colcount)
  4843. {
  4844. valid= true;
  4845. }
  4846. }
  4847. }
  4848. /*:435*/
  4849. #line 10070 "./typica.w"
  4850. if(!valid)
  4851. {
  4852. return false;
  4853. }
  4854. MeasurementList*row= entries->at(index.row());
  4855. if(index.column()>=row->size())
  4856. {
  4857. /*436:*/
  4858. #line 10111 "./typica.w"
  4859. for(int i= row->size()-1;i<index.column();i++)
  4860. {
  4861. row->append(QVariant());
  4862. }
  4863. /*:436*/
  4864. #line 10078 "./typica.w"
  4865. }
  4866. if(index.column()==0)
  4867. {
  4868. /*437:*/
  4869. #line 10126 "./typica.w"
  4870. QTime time;
  4871. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4872. {
  4873. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4874. {
  4875. return false;
  4876. }
  4877. }
  4878. row= entries->takeAt(index.row());
  4879. row->replace(index.column(),QVariant(time));
  4880. MeasurementList*temp= row;
  4881. /*426:*/
  4882. #line 9845 "./typica.w"
  4883. /*427:*/
  4884. #line 9890 "./typica.w"
  4885. QList<MeasurementList*> ::iterator i= lastInsertion;
  4886. bool quickscan= false;
  4887. if(entries->size()> 5)
  4888. {
  4889. if(**i<*temp)
  4890. {
  4891. i+= 1;
  4892. for(int j= 10;j> 0;j--)
  4893. {
  4894. if(i!=entries->end())
  4895. {
  4896. if(**i<*temp)
  4897. {
  4898. i+= 1;
  4899. }
  4900. else
  4901. {
  4902. quickscan= true;
  4903. break;
  4904. }
  4905. }
  4906. else
  4907. {
  4908. quickscan= true;
  4909. break;
  4910. }
  4911. }
  4912. }
  4913. else
  4914. {
  4915. if(**i==*temp)
  4916. {
  4917. quickscan= true;
  4918. }
  4919. }
  4920. }
  4921. /*:427*/
  4922. #line 9846 "./typica.w"
  4923. if(quickscan==false)
  4924. {
  4925. i= entries->begin();
  4926. QList<MeasurementList*> ::iterator u= entries->end();
  4927. QList<MeasurementList*> ::iterator midpoint;
  4928. int n= u-i;
  4929. int rA;
  4930. while(n> 0)
  4931. {
  4932. rA= n>>1;
  4933. midpoint= i+rA;
  4934. if(**midpoint<*temp)
  4935. {
  4936. i= midpoint+1;
  4937. n-= rA+1;
  4938. }
  4939. else
  4940. {
  4941. n= rA;
  4942. }
  4943. }
  4944. }
  4945. /*:426*/
  4946. #line 10138 "./typica.w"
  4947. entries->insert(i,row);
  4948. int newRow= entries->indexOf(*i);
  4949. if(newRow<index.row())
  4950. {
  4951. emit dataChanged(createIndex(newRow,index.column()),index);
  4952. }
  4953. else
  4954. {
  4955. emit dataChanged(index,createIndex(newRow,index.column()));
  4956. }
  4957. /*:437*/
  4958. #line 10082 "./typica.w"
  4959. }
  4960. else
  4961. {
  4962. /*438:*/
  4963. #line 10152 "./typica.w"
  4964. row->replace(index.column(),value);
  4965. emit dataChanged(index,index);
  4966. /*:438*/
  4967. #line 10086 "./typica.w"
  4968. }
  4969. return true;
  4970. }
  4971. /*:434*//*439:*/
  4972. #line 10160 "./typica.w"
  4973. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  4974. unit(Units::Fahrenheit),hData(new QStringList),
  4975. lastTemperature(new QHash<int,int> ),
  4976. controlColumns(new QHash<int,bool> )
  4977. {
  4978. colcount= 1;
  4979. entries= new QList<MeasurementList*> ;
  4980. lastInsertion= entries->begin();
  4981. hData->append(tr("Time"));
  4982. }
  4983. /*:439*//*440:*/
  4984. #line 10174 "./typica.w"
  4985. MeasurementModel::~MeasurementModel()
  4986. {
  4987. clear();
  4988. delete entries;
  4989. delete hData;
  4990. }
  4991. /*:440*//*441:*/
  4992. #line 10186 "./typica.w"
  4993. int MeasurementModel::rowCount(const QModelIndex&parent)const
  4994. {
  4995. if(parent==QModelIndex())
  4996. {
  4997. return entries->size();
  4998. }
  4999. return 0;
  5000. }
  5001. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5002. {
  5003. if(parent==QModelIndex())
  5004. {
  5005. return colcount;
  5006. }
  5007. return 0;
  5008. }
  5009. /*:441*//*442:*/
  5010. #line 10213 "./typica.w"
  5011. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5012. const QVariant&value,int)
  5013. {
  5014. if(orientation==Qt::Horizontal)
  5015. {
  5016. if(hData->size()<section+1)
  5017. {
  5018. for(int i= hData->size();i<section+1;i++)
  5019. {
  5020. if(colcount<i)
  5021. {
  5022. beginInsertColumns(QModelIndex(),i,i);
  5023. }
  5024. hData->append(QString());
  5025. if(colcount<i)
  5026. {
  5027. endInsertColumns();
  5028. }
  5029. }
  5030. }
  5031. hData->replace(section,value.toString());
  5032. emit headerDataChanged(orientation,section,section);
  5033. if(colcount<section+1)
  5034. {
  5035. colcount= section+1;
  5036. }
  5037. return true;
  5038. }
  5039. return false;
  5040. }
  5041. /*:442*//*443:*/
  5042. #line 10253 "./typica.w"
  5043. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5044. {
  5045. beginResetModel();
  5046. unit= scale;
  5047. endResetModel();
  5048. }
  5049. Units::Unit MeasurementModel::displayUnits()
  5050. {
  5051. return unit;
  5052. }
  5053. /*:443*//*444:*/
  5054. #line 10279 "./typica.w"
  5055. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5056. {
  5057. /*435:*/
  5058. #line 10094 "./typica.w"
  5059. bool valid= false;
  5060. if(index.isValid())
  5061. {
  5062. if(index.row()<entries->size())
  5063. {
  5064. if(index.column()<colcount)
  5065. {
  5066. valid= true;
  5067. }
  5068. }
  5069. }
  5070. /*:435*/
  5071. #line 10282 "./typica.w"
  5072. if(!valid)
  5073. {
  5074. return QVariant();
  5075. }
  5076. MeasurementList*row= entries->at(index.row());
  5077. if(role==Qt::UserRole)
  5078. {
  5079. return QVariant(row->at(index.column()));
  5080. }
  5081. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5082. {
  5083. if(index.column()> row->size())
  5084. {
  5085. return QVariant();
  5086. }
  5087. else
  5088. {
  5089. if(index.column()==0)
  5090. {
  5091. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5092. }
  5093. else if(lastTemperature->contains(index.column()))
  5094. {
  5095. QVariantMap v= row->at(index.column()).toMap();
  5096. if(!v.contains("measurement"))
  5097. {
  5098. return QVariant();
  5099. }
  5100. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5101. {
  5102. return v.value("measurement");
  5103. }
  5104. else
  5105. {
  5106. if(v.contains("relative"))
  5107. {
  5108. if(v.value("relative").toBool())
  5109. {
  5110. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5111. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5112. }
  5113. }
  5114. return QVariant(QString("%1").
  5115. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5116. (Units::Unit)(v.value("unit").toInt()),unit)));
  5117. }
  5118. }
  5119. return QVariant(row->at(index.column()).toString());
  5120. }
  5121. }
  5122. return QVariant();
  5123. }
  5124. /*:444*//*445:*/
  5125. #line 10338 "./typica.w"
  5126. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5127. int role)const
  5128. {
  5129. if(orientation==Qt::Horizontal)
  5130. {
  5131. if(role==Qt::DisplayRole)
  5132. {
  5133. if(section<hData->size())
  5134. {
  5135. return QVariant(hData->at(section));
  5136. }
  5137. }
  5138. }
  5139. return QVariant();
  5140. }
  5141. /*:445*//*446:*/
  5142. #line 10365 "./typica.w"
  5143. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5144. {
  5145. /*435:*/
  5146. #line 10094 "./typica.w"
  5147. bool valid= false;
  5148. if(index.isValid())
  5149. {
  5150. if(index.row()<entries->size())
  5151. {
  5152. if(index.column()<colcount)
  5153. {
  5154. valid= true;
  5155. }
  5156. }
  5157. }
  5158. /*:435*/
  5159. #line 10368 "./typica.w"
  5160. if(valid)
  5161. {
  5162. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5163. }
  5164. return 0;
  5165. }
  5166. /*:446*//*447:*/
  5167. #line 10380 "./typica.w"
  5168. QModelIndex MeasurementModel::index(int row,int column,
  5169. const QModelIndex&parent)const
  5170. {
  5171. if(parent==QModelIndex())
  5172. {
  5173. if(row<entries->size()&&entries->isEmpty()==false)
  5174. {
  5175. if(column<entries->at(row)->size())
  5176. {
  5177. return createIndex(row,column);
  5178. }
  5179. }
  5180. }
  5181. return QModelIndex();
  5182. }
  5183. /*:447*/
  5184. #line 550 "./typica.w"
  5185. /*449:*/
  5186. #line 10431 "./typica.w"
  5187. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5188. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5189. {
  5190. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5191. }
  5192. /*:449*//*450:*/
  5193. #line 10446 "./typica.w"
  5194. void AnnotationButton::annotate()
  5195. {
  5196. if(note.contains("%1"))
  5197. {
  5198. count++;
  5199. emit annotation(note.arg(count),tc,ac);
  5200. }
  5201. else
  5202. {
  5203. emit annotation(note,tc,ac);
  5204. }
  5205. }
  5206. /*:450*//*451:*/
  5207. #line 10464 "./typica.w"
  5208. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5209. {
  5210. tc= tempcolumn;
  5211. }
  5212. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5213. {
  5214. ac= annotationcolumn;
  5215. }
  5216. void AnnotationButton::setAnnotation(const QString&annotation)
  5217. {
  5218. note= annotation;
  5219. }
  5220. /*:451*//*452:*/
  5221. #line 10483 "./typica.w"
  5222. void AnnotationButton::resetCount()
  5223. {
  5224. count= 0;
  5225. }
  5226. /*:452*/
  5227. #line 551 "./typica.w"
  5228. /*457:*/
  5229. #line 10566 "./typica.w"
  5230. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5231. const QString&postt,
  5232. QWidget*parent)
  5233. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5234. {
  5235. resetChange();
  5236. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5237. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5238. }
  5239. /*:457*//*458:*/
  5240. #line 10583 "./typica.w"
  5241. void AnnotationSpinBox::resetChange()
  5242. {
  5243. change= true;
  5244. }
  5245. /*:458*//*459:*/
  5246. #line 10594 "./typica.w"
  5247. void AnnotationSpinBox::annotate()
  5248. {
  5249. if(change)
  5250. {
  5251. change= false;
  5252. emit annotation(QString("%1%2%3").arg(pretext).
  5253. arg(value()).arg(posttext),tc,ac);
  5254. }
  5255. }
  5256. /*:459*//*460:*/
  5257. #line 10607 "./typica.w"
  5258. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5259. {
  5260. tc= tempcolumn;
  5261. }
  5262. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5263. {
  5264. ac= annotationcolumn;
  5265. }
  5266. void AnnotationSpinBox::setPretext(const QString&pret)
  5267. {
  5268. pretext= pret;
  5269. }
  5270. void AnnotationSpinBox::setPosttext(const QString&postt)
  5271. {
  5272. posttext= postt;
  5273. }
  5274. /*:460*/
  5275. #line 552 "./typica.w"
  5276. /*467:*/
  5277. #line 10776 "./typica.w"
  5278. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5279. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5280. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5281. stopAction(new QAction(tr("Stop"),NULL)),
  5282. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5283. relative(QTime::currentTime()),base(QTime(0,0,0))
  5284. {
  5285. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5286. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5287. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5288. clock.setInterval(500);
  5289. clock.setSingleShot(false);
  5290. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5291. setSegmentStyle(Filled);
  5292. updateDisplay();
  5293. }
  5294. /*:467*//*468:*/
  5295. #line 10797 "./typica.w"
  5296. void TimerDisplay::updateTime()
  5297. {
  5298. QTime time;
  5299. int cseconds= 0;
  5300. int oseconds= 0;
  5301. int r= 0;
  5302. QTime nt= QTime(0,0,0);
  5303. int n= 0;
  5304. int bseconds= 0;
  5305. switch(m)
  5306. {
  5307. case TimerDisplay::CountUp:
  5308. /*469:*/
  5309. #line 10829 "./typica.w"
  5310. /*470:*/
  5311. #line 10842 "./typica.w"
  5312. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5313. time= QTime::currentTime();
  5314. cseconds= TIMETOINT(time);
  5315. oseconds= TIMETOINT(relative);
  5316. r= cseconds-oseconds;
  5317. /*:470*/
  5318. #line 10830 "./typica.w"
  5319. nt= nt.addSecs(r);
  5320. if(nt!=s)
  5321. {
  5322. s= nt;
  5323. emit valueChanged(s);
  5324. }
  5325. /*:469*/
  5326. #line 10810 "./typica.w"
  5327. ;
  5328. break;
  5329. case TimerDisplay::CountDown:
  5330. /*471:*/
  5331. #line 10854 "./typica.w"
  5332. if(s> QTime(0,0,0))
  5333. {
  5334. /*470:*/
  5335. #line 10842 "./typica.w"
  5336. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5337. time= QTime::currentTime();
  5338. cseconds= TIMETOINT(time);
  5339. oseconds= TIMETOINT(relative);
  5340. r= cseconds-oseconds;
  5341. /*:470*/
  5342. #line 10857 "./typica.w"
  5343. bseconds= TIMETOINT(base);
  5344. n= bseconds-r;
  5345. nt= nt.addSecs(n);
  5346. if(nt!=s)
  5347. {
  5348. s= nt;
  5349. emit valueChanged(s);
  5350. }
  5351. }else{
  5352. stopTimer();
  5353. }
  5354. /*:471*/
  5355. #line 10813 "./typica.w"
  5356. ;
  5357. break;
  5358. case TimerDisplay::Clock:
  5359. /*472:*/
  5360. #line 10873 "./typica.w"
  5361. time= QTime::currentTime();
  5362. if(time!=s)
  5363. {
  5364. s= time;
  5365. emit valueChanged(s);
  5366. }
  5367. /*:472*/
  5368. #line 10816 "./typica.w"
  5369. ;
  5370. break;
  5371. default:
  5372. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5373. break;
  5374. }
  5375. updateDisplay();
  5376. }
  5377. /*:468*//*473:*/
  5378. #line 10885 "./typica.w"
  5379. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5380. void TimerDisplay::startTimer()
  5381. {
  5382. if(!running)
  5383. {
  5384. relative= QTime::currentTime();
  5385. if(ar)
  5386. {
  5387. reset();
  5388. }
  5389. else
  5390. {
  5391. relative= TIMESUBTRACT(relative,s);
  5392. }
  5393. if(m==Clock)
  5394. {
  5395. updateTime();
  5396. }
  5397. base= s;
  5398. clock.start();
  5399. running= true;
  5400. emit runStateChanged(true);
  5401. }
  5402. }
  5403. /*:473*//*474:*/
  5404. #line 10915 "./typica.w"
  5405. void TimerDisplay::stopTimer()
  5406. {
  5407. if(running)
  5408. {
  5409. clock.stop();
  5410. running= false;
  5411. emit runStateChanged(false);
  5412. }
  5413. }
  5414. /*:474*//*475:*/
  5415. #line 10928 "./typica.w"
  5416. TimerDisplay::~TimerDisplay()
  5417. {
  5418. clock.stop();
  5419. }
  5420. /*:475*//*476:*/
  5421. #line 10937 "./typica.w"
  5422. void TimerDisplay::setCountUpMode()
  5423. {
  5424. m= TimerDisplay::CountUp;
  5425. }
  5426. void TimerDisplay::setCountDownMode()
  5427. {
  5428. m= TimerDisplay::CountDown;
  5429. }
  5430. void TimerDisplay::setClockMode()
  5431. {
  5432. m= TimerDisplay::Clock;
  5433. }
  5434. /*:476*//*477:*/
  5435. #line 10955 "./typica.w"
  5436. QString TimerDisplay::value()
  5437. {
  5438. return s.toString(f);
  5439. }
  5440. QTime TimerDisplay::seconds()
  5441. {
  5442. return s;
  5443. }
  5444. TimerDisplay::TimerMode TimerDisplay::mode()
  5445. {
  5446. return m;
  5447. }
  5448. bool TimerDisplay::isRunning()
  5449. {
  5450. return running;
  5451. }
  5452. QTime TimerDisplay::resetValue()
  5453. {
  5454. return r;
  5455. }
  5456. QString TimerDisplay::displayFormat()
  5457. {
  5458. return f;
  5459. }
  5460. bool TimerDisplay::autoReset()
  5461. {
  5462. return ar;
  5463. }
  5464. /*:477*//*478:*/
  5465. #line 10993 "./typica.w"
  5466. void TimerDisplay::setTimer(QTime value)
  5467. {
  5468. if(value.isValid())
  5469. {
  5470. s= value;
  5471. updateDisplay();
  5472. emit valueChanged(value);
  5473. }
  5474. }
  5475. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5476. {
  5477. m= mode;
  5478. }
  5479. void TimerDisplay::setResetValue(QTime value)
  5480. {
  5481. r= value;
  5482. }
  5483. void TimerDisplay::setDisplayFormat(QString format)
  5484. {
  5485. f= format;
  5486. setNumDigits(format.length());
  5487. }
  5488. void TimerDisplay::setAutoReset(bool reset)
  5489. {
  5490. ar= reset;
  5491. }
  5492. /*:478*//*479:*/
  5493. #line 11028 "./typica.w"
  5494. void TimerDisplay::copyTimer()
  5495. {
  5496. QApplication::clipboard()->setText(value());
  5497. }
  5498. /*:479*//*480:*/
  5499. #line 11037 "./typica.w"
  5500. void TimerDisplay::reset()
  5501. {
  5502. if(!running)
  5503. {
  5504. s= r;
  5505. updateDisplay();
  5506. }
  5507. }
  5508. /*:480*//*481:*/
  5509. #line 11050 "./typica.w"
  5510. void TimerDisplay::updateDisplay()
  5511. {
  5512. display(value());
  5513. }
  5514. /*:481*/
  5515. #line 553 "./typica.w"
  5516. /*488:*/
  5517. #line 11175 "./typica.w"
  5518. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5519. {
  5520. int x= rect.x();
  5521. int y= rect.y();
  5522. QLayoutItem*item;
  5523. if(orientation==Qt::Horizontal)
  5524. {
  5525. /*489:*/
  5526. #line 11199 "./typica.w"
  5527. foreach(item,itemList)
  5528. {
  5529. int nextX= x+item->sizeHint().width()+spacing();
  5530. int right= x+item->sizeHint().width();
  5531. if(item==itemList.last())
  5532. {
  5533. right= rect.right();
  5534. }
  5535. int bottom= rect.bottom();
  5536. if(!testOnly)
  5537. {
  5538. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5539. }
  5540. x= nextX;
  5541. }
  5542. /*:489*/
  5543. #line 11183 "./typica.w"
  5544. }
  5545. else
  5546. {
  5547. /*490:*/
  5548. #line 11218 "./typica.w"
  5549. foreach(item,itemList)
  5550. {
  5551. int nextY= y+item->sizeHint().height()+spacing();
  5552. int bottom= y+item->sizeHint().height();
  5553. if(item==itemList.last())
  5554. {
  5555. bottom= rect.bottom();
  5556. }
  5557. int right= rect.right();
  5558. if(!testOnly)
  5559. {
  5560. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5561. }
  5562. y= nextY;
  5563. }
  5564. /*:490*/
  5565. #line 11187 "./typica.w"
  5566. }
  5567. return y;
  5568. }
  5569. /*:488*//*491:*/
  5570. #line 11242 "./typica.w"
  5571. QSize PackLayout::minimumSize()const
  5572. {
  5573. QSize size;
  5574. QLayoutItem*item;
  5575. foreach(item,itemList)
  5576. {
  5577. if(orientation==Qt::Horizontal)
  5578. {
  5579. size+= QSize(item->minimumSize().width(),0);
  5580. if(size.height()<item->minimumSize().height())
  5581. {
  5582. size.setHeight(item->minimumSize().height());
  5583. }
  5584. }
  5585. else
  5586. {
  5587. size+= QSize(0,item->minimumSize().height());
  5588. if(size.width()<item->minimumSize().width())
  5589. {
  5590. size.setWidth(item->minimumSize().width());
  5591. }
  5592. }
  5593. }
  5594. size+= QSize(2*margin(),2*margin());
  5595. return size;
  5596. }
  5597. /*:491*//*492:*/
  5598. #line 11274 "./typica.w"
  5599. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5600. QLayout(parent)
  5601. {
  5602. setMargin(margin);
  5603. setSpacing(spacing);
  5604. setOrientation(Qt::Horizontal);
  5605. }
  5606. PackLayout::PackLayout(int spacing)
  5607. {
  5608. setSpacing(spacing);
  5609. setOrientation(Qt::Horizontal);
  5610. }
  5611. /*:492*//*493:*/
  5612. #line 11292 "./typica.w"
  5613. PackLayout::~PackLayout()
  5614. {
  5615. QLayoutItem*item;
  5616. while((item= takeAt(0)))
  5617. {
  5618. delete item;
  5619. }
  5620. }
  5621. /*:493*//*494:*/
  5622. #line 11306 "./typica.w"
  5623. QLayoutItem*PackLayout::takeAt(int index)
  5624. {
  5625. if(index>=0&&index<itemList.size())
  5626. {
  5627. return itemList.takeAt(index);
  5628. }
  5629. else
  5630. {
  5631. return NULL;
  5632. }
  5633. }
  5634. /*:494*//*495:*/
  5635. #line 11322 "./typica.w"
  5636. QLayoutItem*PackLayout::itemAt(int index)const
  5637. {
  5638. if(index>=0&&index<itemList.size())
  5639. {
  5640. return itemList.at(index);
  5641. }
  5642. else
  5643. {
  5644. return NULL;
  5645. }
  5646. }
  5647. /*:495*//*496:*/
  5648. #line 11345 "./typica.w"
  5649. void PackLayout::addItem(QLayoutItem*item)
  5650. {
  5651. itemList.append(item);
  5652. }
  5653. /*:496*//*497:*/
  5654. #line 11353 "./typica.w"
  5655. int PackLayout::count()const
  5656. {
  5657. return itemList.size();
  5658. }
  5659. /*:497*//*498:*/
  5660. #line 11365 "./typica.w"
  5661. Qt::Orientations PackLayout::expandingDirections()const
  5662. {
  5663. return Qt::Vertical|Qt::Horizontal;
  5664. }
  5665. bool PackLayout::hasHeightForWidth()const
  5666. {
  5667. return false;
  5668. }
  5669. int PackLayout::heightForWidth(int width)const
  5670. {
  5671. return doLayout(QRect(0,0,width,0),true);
  5672. }
  5673. void PackLayout::setGeometry(const QRect&rect)
  5674. {
  5675. QLayout::setGeometry(rect);
  5676. doLayout(rect,false);
  5677. }
  5678. QSize PackLayout::sizeHint()const
  5679. {
  5680. return minimumSize();
  5681. }
  5682. /*:498*//*499:*/
  5683. #line 11396 "./typica.w"
  5684. void PackLayout::setOrientation(Qt::Orientations direction)
  5685. {
  5686. orientation= direction;
  5687. doLayout(geometry(),false);
  5688. }
  5689. /*:499*/
  5690. #line 554 "./typica.w"
  5691. /*501:*/
  5692. #line 11435 "./typica.w"
  5693. SceneButton::SceneButton():QGraphicsScene()
  5694. {
  5695. }
  5696. SceneButton::~SceneButton()
  5697. {
  5698. }
  5699. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5700. {
  5701. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5702. }
  5703. /*:501*/
  5704. #line 555 "./typica.w"
  5705. /*503:*/
  5706. #line 11481 "./typica.w"
  5707. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5708. Qt::Orientations orientation,
  5709. QWidget*parent,Qt::WindowFlags f):
  5710. QWidget(parent,f),label(new QGraphicsView()),
  5711. scene(new SceneButton())
  5712. {
  5713. layout= new PackLayout(this);
  5714. layout->setOrientation(orientation);
  5715. /*504:*/
  5716. #line 11501 "./typica.w"
  5717. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5718. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5719. label->setFrameShape(QFrame::NoFrame);
  5720. label->setInteractive(true);
  5721. /*:504*/
  5722. #line 11490 "./typica.w"
  5723. /*505:*/
  5724. #line 11512 "./typica.w"
  5725. scene->setBackgroundBrush(Qt::cyan);
  5726. text= scene->addText(labeltext);
  5727. if(orientation==Qt::Horizontal)
  5728. {
  5729. text->rotate(270.0);
  5730. }
  5731. label->setScene(scene);
  5732. /*:505*/
  5733. #line 11491 "./typica.w"
  5734. /*506:*/
  5735. #line 11530 "./typica.w"
  5736. if(orientation==Qt::Horizontal)
  5737. {
  5738. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5739. }
  5740. else
  5741. {
  5742. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5743. }
  5744. label->centerOn(text);
  5745. /*:506*/
  5746. #line 11492 "./typica.w"
  5747. /*507:*/
  5748. #line 11545 "./typica.w"
  5749. layout->addWidget(label);
  5750. layout->addWidget(widget);
  5751. if(orientation==Qt::Horizontal)
  5752. {
  5753. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5754. widget->sizeHint().height());
  5755. }
  5756. else
  5757. {
  5758. setMinimumSize(widget->sizeHint().width(),
  5759. widget->sizeHint().height()+label->sizeHint().height());
  5760. }
  5761. /*:507*/
  5762. #line 11493 "./typica.w"
  5763. }
  5764. /*:503*//*508:*/
  5765. #line 11562 "./typica.w"
  5766. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5767. {
  5768. scene->setBackgroundBrush(background);
  5769. }
  5770. void WidgetDecorator::setTextColor(QColor color)
  5771. {
  5772. text->setDefaultTextColor(color);
  5773. }
  5774. /*:508*//*509:*/
  5775. #line 11575 "./typica.w"
  5776. WidgetDecorator::~WidgetDecorator()
  5777. {
  5778. }
  5779. /*:509*/
  5780. #line 556 "./typica.w"
  5781. /*514:*/
  5782. #line 11674 "./typica.w"
  5783. void LogEditWindow::addTheRows()
  5784. {
  5785. QTime s= startTime->time();
  5786. while(s<endTime->time())
  5787. {
  5788. model->newMeasurement(Measurement(0,s),1);
  5789. s= s.addSecs(interval->value());
  5790. }
  5791. model->newMeasurement(Measurement(0,endTime->time()),1);
  5792. }
  5793. /*:514*//*515:*/
  5794. #line 11688 "./typica.w"
  5795. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5796. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5797. addRowsLayout(new QHBoxLayout(NULL)),
  5798. startTimeLabel(new QLabel("Start Time")),
  5799. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5800. endTimeLabel(new QLabel("End Time")),
  5801. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5802. intervalLabel(new QLabel("Interval (seconds)")),
  5803. interval(new QSpinBox()),
  5804. addRows(new QPushButton("Add Rows")),
  5805. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5806. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5807. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5808. model(new MeasurementModel()),
  5809. log(new QTableView())
  5810. {
  5811. /*516:*/
  5812. #line 11725 "./typica.w"
  5813. QSettings settings;
  5814. resize(settings.value("logSize",QSize(620,400)).toSize());
  5815. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5816. /*:516*/
  5817. #line 11705 "./typica.w"
  5818. /*517:*/
  5819. #line 11738 "./typica.w"
  5820. mainLayout->setOrientation(Qt::Vertical);
  5821. addRowsLayout->addSpacing(10);
  5822. addRowsLayout->addWidget(startTimeLabel);
  5823. addRowsLayout->addWidget(startTime);
  5824. addRowsLayout->addSpacing(10);
  5825. startTime->setDisplayFormat("mm:ss");
  5826. addRowsLayout->addWidget(endTimeLabel);
  5827. addRowsLayout->addWidget(endTime);
  5828. addRowsLayout->addSpacing(10);
  5829. endTime->setDisplayFormat("mm:ss");
  5830. addRowsLayout->addWidget(intervalLabel);
  5831. addRowsLayout->addWidget(interval);
  5832. addRowsLayout->addSpacing(10);
  5833. interval->setRange(0,60);
  5834. interval->setValue(30);
  5835. addRowsLayout->addWidget(addRows);
  5836. addRowsLayout->addSpacing(10);
  5837. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5838. /*:517*/
  5839. #line 11706 "./typica.w"
  5840. /*518:*/
  5841. #line 11761 "./typica.w"
  5842. model->setHeaderData(0,Qt::Horizontal,"Time");
  5843. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5844. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5845. model->clear();
  5846. /*:518*/
  5847. #line 11707 "./typica.w"
  5848. /*519:*/
  5849. #line 11770 "./typica.w"
  5850. log->setModel(model);
  5851. log->setColumnWidth(0,100);
  5852. log->setColumnWidth(1,100);
  5853. log->setColumnWidth(2,100);
  5854. /*:519*/
  5855. #line 11708 "./typica.w"
  5856. mainLayout->addItem(addRowsLayout);
  5857. mainLayout->addWidget(log);
  5858. centralWidget->setLayout(mainLayout);
  5859. setCentralWidget(centralWidget);
  5860. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5861. fileMenu->addAction(openXml);
  5862. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5863. fileMenu->addAction(saveXml);
  5864. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5865. fileMenu->addAction(saveCsv);
  5866. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5867. }
  5868. /*:515*//*520:*/
  5869. #line 11781 "./typica.w"
  5870. void LogEditWindow::saveXML()
  5871. {
  5872. QSettings settings;
  5873. QString lastDir= settings.value("lastDirectory").toString();
  5874. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5875. lastDir,"",0);
  5876. QFile file(filename);
  5877. XMLOutput writer(model,&file,0);
  5878. writer.addTemperatureColumn("Temperature",1);
  5879. writer.addAnnotationColumn("Annotation",2);
  5880. if(writer.output())
  5881. {
  5882. QFileInfo info(filename);
  5883. QDir directory= info.dir();
  5884. lastDir= directory.path();
  5885. settings.setValue("lastDirectory",lastDir);
  5886. }
  5887. }
  5888. void LogEditWindow::saveCSV()
  5889. {
  5890. QSettings settings;
  5891. QString lastDir= settings.value("lastDirectory").toString();
  5892. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5893. lastDir,"",0);
  5894. QFile file(filename);
  5895. CSVOutput writer(model,&file,0);
  5896. writer.addTemperatureColumn("Temperature",1);
  5897. writer.addAnnotationColumn("Annotation",2);
  5898. if(writer.output())
  5899. {
  5900. QFileInfo info(filename);
  5901. QDir directory= info.dir();
  5902. lastDir= directory.path();
  5903. settings.setValue("lastDirectory",lastDir);
  5904. }
  5905. }
  5906. /*:520*//*521:*/
  5907. #line 11824 "./typica.w"
  5908. void LogEditWindow::openXML()
  5909. {
  5910. QSettings settings;
  5911. QString lastDir= settings.value("lastDirectory").toString();
  5912. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  5913. lastDir,"",0);
  5914. if(filename.isNull())
  5915. {
  5916. return;
  5917. }
  5918. QFile file(filename);
  5919. XMLInput reader(&file,1);
  5920. connect(&reader,SIGNAL(measure(Measurement,int)),
  5921. model,SLOT(newMeasurement(Measurement,int)));
  5922. connect(&reader,SIGNAL(annotation(QString,int,int)),
  5923. model,SLOT(newAnnotation(QString,int,int)));
  5924. if(reader.input())
  5925. {
  5926. QFileInfo info(filename);
  5927. setWindowTitle(QString(tr("%1 - %2")).
  5928. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  5929. QDir directory= info.dir();
  5930. lastDir= directory.path();
  5931. settings.setValue("lastDirectory",lastDir);
  5932. }
  5933. }
  5934. /*:521*//*522:*/
  5935. #line 11855 "./typica.w"
  5936. void LogEditWindow::closeEvent(QCloseEvent*event)
  5937. {
  5938. QSettings settings;
  5939. settings.setValue("logSize",size());
  5940. settings.setValue("logPos",pos());
  5941. event->accept();
  5942. }
  5943. /*:522*/
  5944. #line 557 "./typica.w"
  5945. /*528:*/
  5946. #line 11970 "./typica.w"
  5947. bool XMLOutput::output()
  5948. {
  5949. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5950. {
  5951. return false;
  5952. }
  5953. QXmlStreamWriter xmlout(out);
  5954. xmlout.writeStartDocument("1.0");
  5955. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  5956. xmlout.writeStartElement("roastlog");
  5957. /*529:*/
  5958. #line 12003 "./typica.w"
  5959. foreach(int c,temperatureColumns.keys())
  5960. {
  5961. xmlout.writeStartElement("tempseries");
  5962. xmlout.writeAttribute("name",temperatureColumns.value(c));
  5963. xmlout.writeEndElement();
  5964. }
  5965. foreach(int c,controlColumns.keys())
  5966. {
  5967. xmlout.writeStartElement("controlseries");
  5968. xmlout.writeAttribute("name",controlColumns.value(c));
  5969. xmlout.writeEndElement();
  5970. }
  5971. foreach(int c,annotationColumns.keys())
  5972. {
  5973. xmlout.writeStartElement("noteseries");
  5974. xmlout.writeAttribute("name",annotationColumns.value(c));
  5975. xmlout.writeEndElement();
  5976. }
  5977. /*:529*/
  5978. #line 11981 "./typica.w"
  5979. xmlout.writeStartElement("roast");
  5980. bool oresult;
  5981. for(int i= 0;i<data->rowCount();i++)
  5982. {
  5983. /*530:*/
  5984. #line 12028 "./typica.w"
  5985. oresult= false;
  5986. foreach(int c,temperatureColumns.keys())
  5987. {
  5988. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5989. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5990. {
  5991. oresult= true;
  5992. break;
  5993. }
  5994. }
  5995. foreach(int c,controlColumns.keys())
  5996. {
  5997. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5998. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5999. {
  6000. oresult= true;
  6001. break;
  6002. }
  6003. }
  6004. if(oresult==false)
  6005. {
  6006. foreach(int c,annotationColumns.keys())
  6007. {
  6008. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6009. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6010. isEmpty()))
  6011. {
  6012. oresult= true;
  6013. break;
  6014. }
  6015. }
  6016. }
  6017. /*:530*/
  6018. #line 11986 "./typica.w"
  6019. if(oresult)
  6020. {
  6021. /*531:*/
  6022. #line 12067 "./typica.w"
  6023. xmlout.writeStartElement("tuple");
  6024. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6025. Qt::DisplayRole).toString());
  6026. foreach(int c,temperatureColumns.keys())
  6027. {
  6028. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6029. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6030. {
  6031. xmlout.writeStartElement("temperature");
  6032. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6033. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6034. {
  6035. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6036. {
  6037. xmlout.writeAttribute("relative","true");
  6038. }
  6039. }
  6040. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6041. toString());
  6042. xmlout.writeEndElement();
  6043. }
  6044. }
  6045. foreach(int c,controlColumns.keys())
  6046. {
  6047. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6048. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6049. {
  6050. xmlout.writeStartElement("control");
  6051. xmlout.writeAttribute("series",controlColumns.value(c));
  6052. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6053. xmlout.writeEndElement();
  6054. }
  6055. }
  6056. foreach(int c,annotationColumns.keys())
  6057. {
  6058. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6059. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6060. {
  6061. xmlout.writeStartElement("annotation");
  6062. xmlout.writeAttribute("series",annotationColumns.value(c));
  6063. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6064. toString());
  6065. xmlout.writeEndElement();
  6066. }
  6067. }
  6068. xmlout.writeEndElement();
  6069. /*:531*/
  6070. #line 11989 "./typica.w"
  6071. }
  6072. }
  6073. xmlout.writeEndElement();
  6074. xmlout.writeEndElement();
  6075. xmlout.writeEndDocument();
  6076. out->close();
  6077. return true;
  6078. }
  6079. /*:528*//*532:*/
  6080. #line 12117 "./typica.w"
  6081. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6082. :QObject(NULL),data(model),out(device),time(timec)
  6083. {
  6084. }
  6085. void XMLOutput::setModel(MeasurementModel*model)
  6086. {
  6087. data= model;
  6088. }
  6089. void XMLOutput::setTimeColumn(int column)
  6090. {
  6091. time= column;
  6092. }
  6093. void XMLOutput::setDevice(QIODevice*device)
  6094. {
  6095. out= device;
  6096. }
  6097. /*:532*//*533:*/
  6098. #line 12146 "./typica.w"
  6099. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6100. {
  6101. temperatureColumns.insert(column,series);
  6102. }
  6103. void XMLOutput::addControlColumn(const QString&series,int column)
  6104. {
  6105. controlColumns.insert(column,series);
  6106. }
  6107. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6108. {
  6109. annotationColumns.insert(column,series);
  6110. }
  6111. /*:533*/
  6112. #line 558 "./typica.w"
  6113. /*535:*/
  6114. #line 12203 "./typica.w"
  6115. bool XMLInput::input()
  6116. {
  6117. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6118. {
  6119. return false;
  6120. }
  6121. QXmlStreamReader xmlin(in);
  6122. QMap<QString,int> temperatureColumns;
  6123. QMap<QString,int> annotationColumns;
  6124. int nextColumn= firstc;
  6125. /*536:*/
  6126. #line 12234 "./typica.w"
  6127. while(!xmlin.isDTD())
  6128. {
  6129. xmlin.readNext();
  6130. }
  6131. if(xmlin.isDTD())
  6132. {
  6133. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6134. {
  6135. /*537:*/
  6136. #line 12256 "./typica.w"
  6137. emit newTemperatureColumn(firstc,"Bean");
  6138. emit newAnnotationColumn(firstc+1,"Note");
  6139. emit lastColumn(firstc+1);
  6140. /*:537*/
  6141. #line 12243 "./typica.w"
  6142. }
  6143. else
  6144. {
  6145. xmlin.readNext();
  6146. /*538:*/
  6147. #line 12265 "./typica.w"
  6148. while(xmlin.name()!="roast")
  6149. {
  6150. if(xmlin.isStartElement())
  6151. {
  6152. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6153. {
  6154. temperatureColumns.insert(xmlin.attributes().value("name").
  6155. toString(),
  6156. nextColumn);
  6157. emit newTemperatureColumn(nextColumn,
  6158. xmlin.attributes().value("name").
  6159. toString());
  6160. nextColumn++;
  6161. }
  6162. else if(xmlin.name()=="noteseries")
  6163. {
  6164. annotationColumns.insert(xmlin.attributes().value("name").
  6165. toString(),nextColumn);
  6166. emit newAnnotationColumn(nextColumn,
  6167. xmlin.attributes().value("name").
  6168. toString());
  6169. nextColumn++;
  6170. }
  6171. }
  6172. xmlin.readNext();
  6173. }
  6174. emit lastColumn(nextColumn-1);
  6175. /*:538*/
  6176. #line 12248 "./typica.w"
  6177. }
  6178. }
  6179. /*:536*/
  6180. #line 12214 "./typica.w"
  6181. QTime timeval= QTime();
  6182. double tempval= 0;
  6183. QString noteval= QString();
  6184. int column;
  6185. int counter= 0;
  6186. while(!xmlin.atEnd())
  6187. {
  6188. /*539:*/
  6189. #line 12306 "./typica.w"
  6190. xmlin.readNext();
  6191. if(xmlin.isStartElement())
  6192. {
  6193. /*540:*/
  6194. #line 12332 "./typica.w"
  6195. if(xmlin.name()=="time")
  6196. {
  6197. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6198. }
  6199. else if(xmlin.name()=="temperature")
  6200. {
  6201. column= xmlin.attributes().hasAttribute("series")?
  6202. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6203. bool relative= (xmlin.attributes().value("relative")=="true");
  6204. tempval= xmlin.readElementText().toDouble();
  6205. Measurement measurement(tempval,timeval);
  6206. if(relative)
  6207. {
  6208. measurement.insert("relative",true);
  6209. }
  6210. emit measure(measurement,column);
  6211. }
  6212. else if(xmlin.name()=="control")
  6213. {
  6214. column= xmlin.attributes().value("series").toString().isEmpty()?
  6215. firstc:temperatureColumns.value(xmlin.attributes().
  6216. value("series").toString());
  6217. tempval= xmlin.readElementText().toDouble();
  6218. Measurement measurement(tempval,timeval,Units::Unitless);
  6219. emit measure(measurement,column);
  6220. }
  6221. else if(xmlin.name()=="annotation")
  6222. {
  6223. column= xmlin.attributes().value("series").toString().isEmpty()?
  6224. firstc+1:annotationColumns.value(xmlin.attributes().
  6225. value("series").toString());
  6226. noteval= xmlin.readElementText();
  6227. if(!noteval.isEmpty())
  6228. {
  6229. emit annotation(noteval,firstc,column);
  6230. }
  6231. }
  6232. /*:540*/
  6233. #line 12310 "./typica.w"
  6234. }
  6235. counter++;
  6236. if(counter%100==0)
  6237. {
  6238. QCoreApplication::processEvents();
  6239. }
  6240. /*:539*/
  6241. #line 12222 "./typica.w"
  6242. }
  6243. return true;
  6244. }
  6245. /*:535*//*541:*/
  6246. #line 12373 "./typica.w"
  6247. XMLInput::XMLInput(QIODevice*input,int c):
  6248. firstc(c),in(input)
  6249. {
  6250. }
  6251. void XMLInput::setFirstColumn(int column)
  6252. {
  6253. firstc= column;
  6254. }
  6255. void XMLInput::setDevice(QIODevice*device)
  6256. {
  6257. in= device;
  6258. }
  6259. /*:541*/
  6260. #line 559 "./typica.w"
  6261. /*546:*/
  6262. #line 12464 "./typica.w"
  6263. bool CSVOutput::output()
  6264. {
  6265. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6266. {
  6267. return false;
  6268. }
  6269. QTextStream output(out);
  6270. /*547:*/
  6271. #line 12488 "./typica.w"
  6272. output<<"Time";
  6273. foreach(int c,temperatureColumns.keys())
  6274. {
  6275. output<<','<<temperatureColumns.value(c);
  6276. }
  6277. foreach(int c,controlColumns.keys())
  6278. {
  6279. output<<','<<controlColumns.value(c);
  6280. }
  6281. foreach(int c,annotationColumns.keys())
  6282. {
  6283. output<<','<<annotationColumns.value(c);
  6284. }
  6285. output<<'\n';
  6286. /*:547*/
  6287. #line 12472 "./typica.w"
  6288. bool oresult;
  6289. for(int i= 0;i<data->rowCount();i++)
  6290. {
  6291. /*530:*/
  6292. #line 12028 "./typica.w"
  6293. oresult= false;
  6294. foreach(int c,temperatureColumns.keys())
  6295. {
  6296. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6297. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6298. {
  6299. oresult= true;
  6300. break;
  6301. }
  6302. }
  6303. foreach(int c,controlColumns.keys())
  6304. {
  6305. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6306. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6307. {
  6308. oresult= true;
  6309. break;
  6310. }
  6311. }
  6312. if(oresult==false)
  6313. {
  6314. foreach(int c,annotationColumns.keys())
  6315. {
  6316. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6317. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6318. isEmpty()))
  6319. {
  6320. oresult= true;
  6321. break;
  6322. }
  6323. }
  6324. }
  6325. /*:530*/
  6326. #line 12476 "./typica.w"
  6327. if(oresult)
  6328. {
  6329. /*548:*/
  6330. #line 12513 "./typica.w"
  6331. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6332. foreach(int c,temperatureColumns.keys())
  6333. {
  6334. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6335. }
  6336. foreach(int c,controlColumns.keys())
  6337. {
  6338. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6339. }
  6340. foreach(int c,annotationColumns.keys())
  6341. {
  6342. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6343. }
  6344. output<<'\n';
  6345. /*:548*/
  6346. #line 12479 "./typica.w"
  6347. }
  6348. }
  6349. out->close();
  6350. return true;
  6351. }
  6352. /*:546*//*549:*/
  6353. #line 12532 "./typica.w"
  6354. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6355. data(model),out(device),time(timec)
  6356. {
  6357. }
  6358. void CSVOutput::setModel(MeasurementModel*model)
  6359. {
  6360. data= model;
  6361. }
  6362. void CSVOutput::setTimeColumn(int column)
  6363. {
  6364. time= column;
  6365. }
  6366. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6367. {
  6368. temperatureColumns.insert(column,series);
  6369. }
  6370. void CSVOutput::addControlColumn(const QString&series,int column)
  6371. {
  6372. controlColumns.insert(column,series);
  6373. }
  6374. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6375. {
  6376. annotationColumns.insert(column,series);
  6377. }
  6378. void CSVOutput::setDevice(QIODevice*device)
  6379. {
  6380. out= device;
  6381. }
  6382. #line 1 "./webview.w"
  6383. /*:549*/
  6384. #line 560 "./typica.w"
  6385. /*584:*/
  6386. #line 12793 "./typica.w"
  6387. QString SaltModel::arrayLiteral(int column,int role)const
  6388. {
  6389. QString literal= "'{";
  6390. for(int i= 0;i<rowCount();i++)
  6391. {
  6392. QString datum= data(index(i,column),role).toString();
  6393. if(!datum.isEmpty())
  6394. {
  6395. literal.append(datum);
  6396. literal.append(", ");
  6397. }
  6398. }
  6399. if(literal.size()> 2)
  6400. {
  6401. literal.chop(2);
  6402. }
  6403. literal.append("}'");
  6404. return literal;
  6405. }
  6406. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6407. {
  6408. QString literal= "'{";
  6409. for(int i= 0;i<rowCount();i++)
  6410. {
  6411. QString datum= data(index(i,column),role).toString();
  6412. if(!datum.isEmpty())
  6413. {
  6414. literal.append("\"");
  6415. literal.append(datum);
  6416. literal.append("\", ");
  6417. }
  6418. }
  6419. if(literal.size()> 2)
  6420. {
  6421. literal.chop(2);
  6422. }
  6423. literal.append("}'");
  6424. return literal;
  6425. }
  6426. /*:584*//*585:*/
  6427. #line 12837 "./typica.w"
  6428. QModelIndex SaltModel::parent(const QModelIndex&)const
  6429. {
  6430. return QModelIndex();
  6431. }
  6432. /*:585*//*586:*/
  6433. #line 12856 "./typica.w"
  6434. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6435. int role)
  6436. {
  6437. /*587:*/
  6438. #line 12887 "./typica.w"
  6439. bool valid= false;
  6440. if(index.isValid())
  6441. {
  6442. if(index.row()<modelData.size())
  6443. {
  6444. if(index.column()<colcount)
  6445. {
  6446. valid= true;
  6447. }
  6448. }
  6449. }
  6450. /*:587*/
  6451. #line 12860 "./typica.w"
  6452. if(!valid)
  6453. {
  6454. return false;
  6455. }
  6456. if(index.row()==modelData.size()-1)
  6457. {
  6458. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6459. /*588:*/
  6460. #line 12903 "./typica.w"
  6461. QList<QMap<int,QVariant> > newRow;
  6462. QMap<int,QVariant> defaults;
  6463. for(int i= 0;i<colcount;i++)
  6464. {
  6465. newRow.append(defaults);
  6466. }
  6467. modelData.append(newRow);
  6468. /*:588*/
  6469. #line 12868 "./typica.w"
  6470. endInsertRows();
  6471. }
  6472. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6473. QMap<int,QVariant> cell= row.at(index.column());
  6474. cell.insert(role,value);
  6475. if(role==Qt::EditRole)
  6476. {
  6477. cell.insert(Qt::DisplayRole,value);
  6478. }
  6479. row.replace(index.column(),cell);
  6480. modelData.replace(index.row(),row);
  6481. emit dataChanged(index,index);
  6482. return true;
  6483. }
  6484. /*:586*//*589:*/
  6485. #line 12914 "./typica.w"
  6486. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6487. {
  6488. for(int i= 0;i<columns;i++)
  6489. {
  6490. hData<<"";
  6491. }
  6492. /*588:*/
  6493. #line 12903 "./typica.w"
  6494. QList<QMap<int,QVariant> > newRow;
  6495. QMap<int,QVariant> defaults;
  6496. for(int i= 0;i<colcount;i++)
  6497. {
  6498. newRow.append(defaults);
  6499. }
  6500. modelData.append(newRow);
  6501. /*:588*/
  6502. #line 12921 "./typica.w"
  6503. }
  6504. /*:589*//*590:*/
  6505. #line 12926 "./typica.w"
  6506. SaltModel::~SaltModel()
  6507. {
  6508. }
  6509. /*:590*//*591:*/
  6510. #line 12936 "./typica.w"
  6511. int SaltModel::rowCount(const QModelIndex&parent)const
  6512. {
  6513. return(parent==QModelIndex()?modelData.size():0);
  6514. }
  6515. int SaltModel::columnCount(const QModelIndex&parent)const
  6516. {
  6517. return(parent==QModelIndex()?colcount:0);
  6518. }
  6519. /*:591*//*592:*/
  6520. #line 12949 "./typica.w"
  6521. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6522. const QVariant&value,int)
  6523. {
  6524. if(orientation==Qt::Horizontal&&section<colcount)
  6525. {
  6526. hData.replace(section,value.toString());
  6527. emit headerDataChanged(orientation,section,section);
  6528. return true;
  6529. }
  6530. return false;
  6531. }
  6532. /*:592*//*593:*/
  6533. #line 12964 "./typica.w"
  6534. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6535. {
  6536. /*587:*/
  6537. #line 12887 "./typica.w"
  6538. bool valid= false;
  6539. if(index.isValid())
  6540. {
  6541. if(index.row()<modelData.size())
  6542. {
  6543. if(index.column()<colcount)
  6544. {
  6545. valid= true;
  6546. }
  6547. }
  6548. }
  6549. /*:587*/
  6550. #line 12967 "./typica.w"
  6551. if(!valid)
  6552. {
  6553. return QVariant();
  6554. }
  6555. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6556. QMap<int,QVariant> cell= row.at(index.column());
  6557. return cell.value(role,QVariant());
  6558. }
  6559. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6560. int role)const
  6561. {
  6562. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6563. section<colcount)
  6564. {
  6565. return QVariant(hData.at(section));
  6566. }
  6567. return QVariant();
  6568. }
  6569. /*:593*//*594:*/
  6570. #line 12991 "./typica.w"
  6571. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6572. {
  6573. /*587:*/
  6574. #line 12887 "./typica.w"
  6575. bool valid= false;
  6576. if(index.isValid())
  6577. {
  6578. if(index.row()<modelData.size())
  6579. {
  6580. if(index.column()<colcount)
  6581. {
  6582. valid= true;
  6583. }
  6584. }
  6585. }
  6586. /*:587*/
  6587. #line 12994 "./typica.w"
  6588. if(valid)
  6589. {
  6590. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6591. }
  6592. return 0;
  6593. }
  6594. /*:594*//*595:*/
  6595. #line 13005 "./typica.w"
  6596. QModelIndex SaltModel::index(int row,int column,
  6597. const QModelIndex&parent)const
  6598. {
  6599. if(parent==QModelIndex())
  6600. {
  6601. if(row<modelData.size()&&column<colcount)
  6602. {
  6603. return createIndex(row,column);
  6604. }
  6605. }
  6606. return QModelIndex();
  6607. }
  6608. /*:595*//*596:*/
  6609. #line 13023 "./typica.w"
  6610. void SaltModel::clear()
  6611. {
  6612. beginResetModel();
  6613. modelData.clear();
  6614. /*588:*/
  6615. #line 12903 "./typica.w"
  6616. QList<QMap<int,QVariant> > newRow;
  6617. QMap<int,QVariant> defaults;
  6618. for(int i= 0;i<colcount;i++)
  6619. {
  6620. newRow.append(defaults);
  6621. }
  6622. modelData.append(newRow);
  6623. /*:588*/
  6624. #line 13028 "./typica.w"
  6625. endResetModel();
  6626. }
  6627. /*:596*//*597:*/
  6628. #line 13037 "./typica.w"
  6629. bool SaltModel::removeRows(int row,int count,
  6630. const QModelIndex&parent)
  6631. {
  6632. if(parent==QModelIndex())
  6633. {
  6634. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6635. {
  6636. beginRemoveRows(parent,row,row+count-1);
  6637. for(int i= 0;i<count;i++)
  6638. {
  6639. modelData.removeAt(row);
  6640. }
  6641. endRemoveRows();
  6642. if(modelData.size()==0)
  6643. {
  6644. beginInsertRows(parent,0,0);
  6645. /*588:*/
  6646. #line 12903 "./typica.w"
  6647. QList<QMap<int,QVariant> > newRow;
  6648. QMap<int,QVariant> defaults;
  6649. for(int i= 0;i<colcount;i++)
  6650. {
  6651. newRow.append(defaults);
  6652. }
  6653. modelData.append(newRow);
  6654. /*:588*/
  6655. #line 13054 "./typica.w"
  6656. endInsertRows();
  6657. }
  6658. return true;
  6659. }
  6660. }
  6661. return false;
  6662. }
  6663. /*:597*//*598:*/
  6664. #line 13068 "./typica.w"
  6665. int SaltModel::findData(const QVariant&value,int column,int role)
  6666. {
  6667. for(int i= 0;i<modelData.size();i++)
  6668. {
  6669. if(modelData.at(i).size()> column)
  6670. {
  6671. if(modelData.at(i).at(column).contains(role))
  6672. {
  6673. if(modelData.at(i).at(column).value(role)==value)
  6674. {
  6675. return i;
  6676. }
  6677. }
  6678. }
  6679. }
  6680. return-1;
  6681. }
  6682. /*:598*/
  6683. #line 561 "./typica.w"
  6684. /*600:*/
  6685. #line 13132 "./typica.w"
  6686. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6687. {
  6688. SqlComboBox*widget= new SqlComboBox();
  6689. widget->setParent(parent);
  6690. for(int i= 0;i<count();i++)
  6691. {
  6692. widget->addItem(itemText(i),itemData(i));
  6693. }
  6694. return widget;
  6695. }
  6696. /*:600*//*601:*/
  6697. #line 13149 "./typica.w"
  6698. void SqlComboBox::showData(bool show)
  6699. {
  6700. dataColumnShown= show;
  6701. }
  6702. /*:601*//*602:*/
  6703. #line 13163 "./typica.w"
  6704. void SqlComboBox::addNullOption()
  6705. {
  6706. addItem(specialNullText,specialNullData);
  6707. }
  6708. void SqlComboBox::setNullText(QString nullText)
  6709. {
  6710. specialNullText= nullText;
  6711. }
  6712. void SqlComboBox::setNullData(QVariant nullData)
  6713. {
  6714. specialNullData= nullData;
  6715. }
  6716. /*:602*//*603:*/
  6717. #line 13186 "./typica.w"
  6718. void SqlComboBox::setDataColumn(int column)
  6719. {
  6720. dataColumn= column;
  6721. }
  6722. void SqlComboBox::setDisplayColumn(int column)
  6723. {
  6724. displayColumn= column;
  6725. }
  6726. /*:603*//*604:*/
  6727. #line 13200 "./typica.w"
  6728. void SqlComboBox::addSqlOptions(QString query)
  6729. {
  6730. SqlQueryConnection h;
  6731. QSqlQuery*dbquery= h.operator->();
  6732. if(!dbquery->exec(query))
  6733. {
  6734. QSqlError error= dbquery->lastError();
  6735. qDebug()<<error.databaseText();
  6736. qDebug()<<error.driverText();
  6737. qDebug()<<error.text();
  6738. qDebug()<<dbquery->lastQuery();
  6739. }
  6740. while(dbquery->next())
  6741. {
  6742. QString displayValue(dbquery->value(displayColumn).toString());
  6743. QString dataValue(dbquery->value(dataColumn).toString());
  6744. if(dataColumnShown)
  6745. {
  6746. displayValue.append(QString(" (%1)").arg(dataValue));
  6747. }
  6748. addItem(displayValue,dataValue);
  6749. }
  6750. }
  6751. /*:604*//*605:*/
  6752. #line 13236 "./typica.w"
  6753. SqlComboBox::SqlComboBox():
  6754. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6755. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6756. {
  6757. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6758. }
  6759. SqlComboBox::~SqlComboBox()
  6760. {
  6761. }
  6762. /*:605*/
  6763. #line 562 "./typica.w"
  6764. /*607:*/
  6765. #line 13275 "./typica.w"
  6766. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6767. {
  6768. delegate= widget;
  6769. }
  6770. /*:607*//*608:*/
  6771. #line 13284 "./typica.w"
  6772. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6773. const QStyleOptionViewItem&,
  6774. const QModelIndex&)const
  6775. {
  6776. return delegate->clone(parent);
  6777. }
  6778. /*:608*//*609:*/
  6779. #line 13295 "./typica.w"
  6780. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6781. const QModelIndex&index)const
  6782. {
  6783. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6784. self->setCurrentIndex(self->findData(
  6785. index.model()->data(index,
  6786. Qt::UserRole).toString()));
  6787. }
  6788. /*:609*//*610:*/
  6789. #line 13308 "./typica.w"
  6790. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6791. QAbstractItemModel*model,
  6792. const QModelIndex&index)const
  6793. {
  6794. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6795. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6796. Qt::UserRole);
  6797. model->setData(index,self->currentText(),Qt::DisplayRole);
  6798. }
  6799. /*:610*//*611:*/
  6800. #line 13321 "./typica.w"
  6801. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6802. const QStyleOptionViewItem&option,
  6803. const QModelIndex&)const
  6804. {
  6805. editor->setGeometry(option.rect);
  6806. }
  6807. /*:611*//*612:*/
  6808. #line 13332 "./typica.w"
  6809. QSize SqlComboBoxDelegate::sizeHint()const
  6810. {
  6811. return delegate->sizeHint();
  6812. }
  6813. /*:612*//*613:*/
  6814. #line 13340 "./typica.w"
  6815. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6816. :QItemDelegate(parent)
  6817. {
  6818. }
  6819. /*:613*/
  6820. #line 563 "./typica.w"
  6821. /*576:*/
  6822. #line 12602 "./typica.w"
  6823. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6824. {
  6825. /*577:*/
  6826. #line 12617 "./typica.w"
  6827. setOrganizationName("Wilson's Coffee & Tea");
  6828. setOrganizationDomain("wilsonscoffee.com");
  6829. setApplicationName(PROGRAM_NAME);
  6830. /*:577*/
  6831. #line 12605 "./typica.w"
  6832. /*578:*/
  6833. #line 12626 "./typica.w"
  6834. QTranslator*base= new QTranslator;
  6835. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6836. {
  6837. installTranslator(base);
  6838. }
  6839. QTranslator*app= new QTranslator;
  6840. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6841. {
  6842. installTranslator(app);
  6843. }
  6844. /*:578*/
  6845. #line 12606 "./typica.w"
  6846. /*295:*/
  6847. #line 123 "./measurement.w"
  6848. qRegisterMetaType<Measurement> ("Measurement");
  6849. /*:295*/
  6850. #line 12607 "./typica.w"
  6851. /*784:*/
  6852. #line 16621 "./typica.w"
  6853. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6854. tr("NI DAQmx Base"),
  6855. "nidaqmxbase",NULL);
  6856. topLevelNodeInserters.append(inserter);
  6857. /*:784*//*792:*/
  6858. #line 16852 "./typica.w"
  6859. #ifdef Q_OS_WIN32
  6860. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6861. topLevelNodeInserters.append(inserter);
  6862. #endif
  6863. /*:792*//*816:*/
  6864. #line 17815 "./typica.w"
  6865. #if 0
  6866. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6867. topLevelNodeInserters.append(inserter);
  6868. #endif
  6869. /*:816*//*865:*/
  6870. #line 19328 "./typica.w"
  6871. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6872. topLevelNodeInserters.append(inserter);
  6873. #line 1 "./unsupportedserial.w"
  6874. /*:865*//*875:*/
  6875. #line 272 "./unsupportedserial.w"
  6876. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  6877. "unsupporteddevice",NULL);
  6878. topLevelNodeInserters.append(inserter);
  6879. /*:875*//*909:*/
  6880. #line 190 "./phidgets.w"
  6881. QLibrary phidgetsCheck("phidget21");
  6882. if(phidgetsCheck.load())
  6883. {
  6884. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6885. "phidgets1048",NULL);
  6886. topLevelNodeInserters.append(inserter);
  6887. phidgetsCheck.unload();
  6888. }
  6889. else
  6890. {
  6891. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  6892. if(phidgetsCheck.load())
  6893. {
  6894. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6895. "phidgets1048",NULL);
  6896. topLevelNodeInserters.append(inserter);
  6897. phidgetsCheck.unload();
  6898. }
  6899. }
  6900. /*:909*//*1000:*/
  6901. #line 1241 "./dataqsdk.w"
  6902. #ifdef Q_OS_WIN32
  6903. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  6904. "dataqsdk",NULL);
  6905. topLevelNodeInserters.append(inserter);
  6906. #endif
  6907. #line 19978 "./typica.w"
  6908. #line 1 "./scales.w"
  6909. /*:1000*//*1025:*/
  6910. #line 495 "./scales.w"
  6911. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  6912. topLevelNodeInserters.append(inserter);
  6913. #line 19980 "./typica.w"
  6914. #line 1 "./valueannotation.w"
  6915. /*:1025*/
  6916. #line 12608 "./typica.w"
  6917. }
  6918. /*:576*//*580:*/
  6919. #line 12649 "./typica.w"
  6920. QDomDocument*Application::configuration()
  6921. {
  6922. return&conf;
  6923. }
  6924. /*:580*//*581:*/
  6925. #line 12658 "./typica.w"
  6926. QSqlDatabase Application::database()
  6927. {
  6928. QString connectionName;
  6929. QSqlDatabase connection=
  6930. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  6931. do
  6932. {
  6933. connectionName= QUuid::createUuid().toString();
  6934. }while(QSqlDatabase::connectionNames().contains(connectionName));
  6935. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  6936. }
  6937. /*:581*//*719:*/
  6938. #line 15154 "./typica.w"
  6939. void Application::saveDeviceConfiguration()
  6940. {
  6941. QSettings settings;
  6942. settings.setValue("DeviceConfiguration",
  6943. QVariant(deviceConfigurationDocument.toByteArray()));
  6944. }
  6945. /*:719*//*720:*/
  6946. #line 15166 "./typica.w"
  6947. QDomDocument Application::deviceConfiguration()
  6948. {
  6949. if(deviceConfigurationDocument.isNull())
  6950. {
  6951. /*721:*/
  6952. #line 15180 "./typica.w"
  6953. QSettings settings;
  6954. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  6955. QString etext;
  6956. int eline;
  6957. int ecol;
  6958. if(document.length()==0)
  6959. {
  6960. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  6961. /*722:*/
  6962. #line 15204 "./typica.w"
  6963. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6964. emptyDocument.open(QIODevice::ReadOnly);
  6965. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6966. &etext,&eline,&ecol))
  6967. {
  6968. /*723:*/
  6969. #line 15221 "./typica.w"
  6970. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6971. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6972. qDebug()<<etext;
  6973. /*:723*/
  6974. #line 15210 "./typica.w"
  6975. }
  6976. else
  6977. {
  6978. saveDeviceConfiguration();
  6979. }
  6980. /*:722*/
  6981. #line 15189 "./typica.w"
  6982. }
  6983. else
  6984. {
  6985. if(!deviceConfigurationDocument.setContent(document,false,
  6986. &etext,&eline,&ecol))
  6987. {
  6988. /*723:*/
  6989. #line 15221 "./typica.w"
  6990. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6991. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6992. qDebug()<<etext;
  6993. /*:723*/
  6994. #line 15196 "./typica.w"
  6995. /*722:*/
  6996. #line 15204 "./typica.w"
  6997. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6998. emptyDocument.open(QIODevice::ReadOnly);
  6999. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7000. &etext,&eline,&ecol))
  7001. {
  7002. /*723:*/
  7003. #line 15221 "./typica.w"
  7004. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7005. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7006. qDebug()<<etext;
  7007. /*:723*/
  7008. #line 15210 "./typica.w"
  7009. }
  7010. else
  7011. {
  7012. saveDeviceConfiguration();
  7013. }
  7014. /*:722*/
  7015. #line 15197 "./typica.w"
  7016. }
  7017. }
  7018. /*:721*/
  7019. #line 15171 "./typica.w"
  7020. }
  7021. return deviceConfigurationDocument;
  7022. }
  7023. /*:720*//*751:*/
  7024. #line 15822 "./typica.w"
  7025. void Application::registerDeviceConfigurationWidget(QString driver,
  7026. QMetaObject widget)
  7027. {
  7028. deviceConfigurationWidgets.insert(driver,widget);
  7029. }
  7030. /*:751*//*752:*/
  7031. #line 15838 "./typica.w"
  7032. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7033. const QModelIndex&index)
  7034. {
  7035. QVariant nodeReference= index.data(Qt::UserRole);
  7036. QDomElement referenceElement= model->referenceElement(
  7037. model->data(index,Qt::UserRole).toString());
  7038. QMetaObject metaObject=
  7039. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7040. QWidget::staticMetaObject);
  7041. QWidget*editor;
  7042. if(metaObject.className()==QWidget::staticMetaObject.className())
  7043. {
  7044. editor= NULL;
  7045. }
  7046. else
  7047. {
  7048. editor= qobject_cast<QWidget*> (
  7049. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7050. Q_ARG(QModelIndex,index)));
  7051. }
  7052. return editor;
  7053. }
  7054. /*:752*/
  7055. #line 564 "./typica.w"
  7056. /*622:*/
  7057. #line 13488 "./typica.w"
  7058. SqlConnectionSetup::SqlConnectionSetup():
  7059. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7060. portnumber(new QLineEdit),
  7061. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7062. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7063. cancelButton(new QPushButton(tr("Cancel"))),
  7064. connectButton(new QPushButton(tr("Connect")))
  7065. {
  7066. driver->addItem("PostgreSQL","QPSQL");
  7067. formLayout->addRow(tr("Database driver:"),driver);
  7068. formLayout->addRow(tr("Host name:"),hostname);
  7069. formLayout->addRow(tr("Port number:"),portnumber);
  7070. portnumber->setText("5432");
  7071. formLayout->addRow(tr("Database name:"),dbname);
  7072. formLayout->addRow(tr("User name:"),user);
  7073. password->setEchoMode(QLineEdit::Password);
  7074. formLayout->addRow(tr("Password:"),password);
  7075. layout->addLayout(formLayout);
  7076. buttons->addStretch(1);
  7077. buttons->addWidget(cancelButton);
  7078. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7079. buttons->addWidget(connectButton);
  7080. layout->addLayout(buttons);
  7081. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7082. connectButton->setDefault(true);
  7083. setLayout(layout);
  7084. setModal(true);
  7085. }
  7086. SqlConnectionSetup::~SqlConnectionSetup()
  7087. {
  7088. }
  7089. /*:622*//*623:*/
  7090. #line 13526 "./typica.w"
  7091. void SqlConnectionSetup::testConnection()
  7092. {
  7093. QSqlDatabase database=
  7094. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7095. toString());
  7096. database.setConnectOptions("application_name=Typica");
  7097. database.setHostName(hostname->text());
  7098. database.setPort(portnumber->text().toInt());
  7099. database.setDatabaseName(dbname->text());
  7100. database.setUserName(user->text());
  7101. database.setPassword(password->text());
  7102. if(database.open())
  7103. {
  7104. QSettings settings;
  7105. settings.setValue("database/exists","true");
  7106. settings.setValue("database/driver",
  7107. driver->itemData(driver->currentIndex()).toString());
  7108. settings.setValue("database/hostname",hostname->text());
  7109. settings.setValue("database/portnumber",portnumber->text());
  7110. settings.setValue("database/dbname",dbname->text());
  7111. settings.setValue("database/user",user->text());
  7112. settings.setValue("database/password",password->text());
  7113. database.close();
  7114. accept();
  7115. }
  7116. else
  7117. {
  7118. QMessageBox::information(this,tr("Database connection failed"),
  7119. tr("Failed to connect to database."));
  7120. }
  7121. }
  7122. /*:623*/
  7123. #line 565 "./typica.w"
  7124. /*627:*/
  7125. #line 13631 "./typica.w"
  7126. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7127. {
  7128. setModel(new QSqlQueryModel);
  7129. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7130. this,SLOT(openRow(QModelIndex)));
  7131. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7132. this,SLOT(persistColumnResize(int,int,int)));
  7133. }
  7134. /*:627*//*628:*/
  7135. #line 13646 "./typica.w"
  7136. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7137. {
  7138. /*629:*/
  7139. #line 13655 "./typica.w"
  7140. QSettings settings;
  7141. /*630:*/
  7142. #line 13668 "./typica.w"
  7143. QWidget*topLevelWidget= this;
  7144. while(topLevelWidget->parentWidget())
  7145. {
  7146. topLevelWidget= topLevelWidget->parentWidget();
  7147. }
  7148. /*:630*/
  7149. #line 13657 "./typica.w"
  7150. settings.setValue(QString("columnWidths/%1/%2/%3").
  7151. arg(topLevelWidget->objectName()).
  7152. arg(objectName()).arg(column),
  7153. QVariant(newsize));
  7154. /*:629*/
  7155. #line 13649 "./typica.w"
  7156. }
  7157. /*:628*//*631:*/
  7158. #line 13678 "./typica.w"
  7159. void SqlQueryView::showEvent(QShowEvent*event)
  7160. {
  7161. /*632:*/
  7162. #line 13688 "./typica.w"
  7163. QSettings settings;
  7164. /*630:*/
  7165. #line 13668 "./typica.w"
  7166. QWidget*topLevelWidget= this;
  7167. while(topLevelWidget->parentWidget())
  7168. {
  7169. topLevelWidget= topLevelWidget->parentWidget();
  7170. }
  7171. /*:630*/
  7172. #line 13690 "./typica.w"
  7173. QString baseKey=
  7174. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7175. arg(objectName());
  7176. for(int i= 0;i<model()->columnCount();i++)
  7177. {
  7178. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7179. if(settings.contains(key))
  7180. {
  7181. setColumnWidth(i,settings.value(key).toInt());
  7182. }
  7183. }
  7184. /*:632*/
  7185. #line 13681 "./typica.w"
  7186. event->accept();
  7187. }
  7188. /*:631*//*633:*/
  7189. #line 13705 "./typica.w"
  7190. void SqlQueryView::openRow(const QModelIndex&index)
  7191. {
  7192. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7193. emit openEntryRow(index.row());
  7194. }
  7195. /*:633*//*634:*/
  7196. #line 13714 "./typica.w"
  7197. void SqlQueryView::setQuery(const QString&query)
  7198. {
  7199. QSqlDatabase database= AppInstance->database();
  7200. database.open();
  7201. QSqlQuery q(query,database);
  7202. ((QSqlQueryModel*)model())->setQuery(q);
  7203. database.close();
  7204. }
  7205. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7206. const QVariant&value,int role)
  7207. {
  7208. return model()->setHeaderData(section,orientation,value,role);
  7209. }
  7210. /*:634*//*635:*/
  7211. #line 13732 "./typica.w"
  7212. QVariant SqlQueryView::data(int row,int column,int role)
  7213. {
  7214. return model()->data(model()->index(row,column),role);
  7215. }
  7216. /*:635*/
  7217. #line 566 "./typica.w"
  7218. /*170:*/
  7219. #line 3936 "./typica.w"
  7220. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7221. {
  7222. QSqlDatabase database= AppInstance->database();
  7223. database.open();
  7224. q= new QSqlQuery(query,database);
  7225. connection= database.connectionName();
  7226. }
  7227. /*:170*//*171:*/
  7228. #line 3949 "./typica.w"
  7229. SqlQueryConnection::~SqlQueryConnection()
  7230. {
  7231. delete q;
  7232. {
  7233. QSqlDatabase database= QSqlDatabase::database(connection);
  7234. database.close();
  7235. }
  7236. QSqlDatabase::removeDatabase(connection);
  7237. }
  7238. /*:171*//*172:*/
  7239. #line 3963 "./typica.w"
  7240. QSqlQuery*SqlQueryConnection::operator->()const
  7241. {
  7242. return q;
  7243. }
  7244. /*:172*/
  7245. #line 567 "./typica.w"
  7246. /*654:*/
  7247. #line 14091 "./typica.w"
  7248. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7249. area(frame),configuration(description)
  7250. {
  7251. refresh();
  7252. }
  7253. ReportTable::~ReportTable()
  7254. {
  7255. }
  7256. /*:654*//*655:*/
  7257. #line 14107 "./typica.w"
  7258. void ReportTable::bind(QString placeholder,QVariant value)
  7259. {
  7260. bindings.insert(placeholder,value);
  7261. }
  7262. /*:655*//*656:*/
  7263. #line 14117 "./typica.w"
  7264. void ReportTable::refresh()
  7265. {
  7266. /*657:*/
  7267. #line 14138 "./typica.w"
  7268. QTextCursor cursor= area->firstCursorPosition();
  7269. while(cursor<area->lastCursorPosition())
  7270. {
  7271. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7272. }
  7273. cursor.removeSelectedText();
  7274. /*:657*/
  7275. #line 14120 "./typica.w"
  7276. int rows= 1;
  7277. int columns= 1;
  7278. int currentRow= 0;
  7279. QTextTable*table= cursor.insertTable(rows,columns);
  7280. /*658:*/
  7281. #line 14151 "./typica.w"
  7282. QTextTableFormat format= table->format();
  7283. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7284. if(configuration.hasAttribute("align"))
  7285. {
  7286. if(configuration.attribute("align")=="center")
  7287. {
  7288. format.setAlignment(Qt::AlignHCenter);
  7289. }
  7290. }
  7291. table->setFormat(format);
  7292. /*:658*/
  7293. #line 14125 "./typica.w"
  7294. /*659:*/
  7295. #line 14165 "./typica.w"
  7296. QDomNodeList children= configuration.childNodes();
  7297. for(int i= 0;i<children.count();i++)
  7298. {
  7299. QDomNode current;
  7300. QDomElement currentElement;
  7301. current= children.at(i);
  7302. if(current.isElement())
  7303. {
  7304. currentElement= current.toElement();
  7305. if(currentElement.tagName()=="query")
  7306. {
  7307. /*660:*/
  7308. #line 14192 "./typica.w"
  7309. SqlQueryConnection h;
  7310. QSqlQuery*query= h.operator->();
  7311. query->prepare(currentElement.text());
  7312. foreach(QString key,bindings.uniqueKeys())
  7313. {
  7314. if(currentElement.text().contains(key))
  7315. {
  7316. query->bindValue(key,bindings.value(key));
  7317. }
  7318. }
  7319. query->exec();
  7320. if(!query->next())
  7321. {
  7322. continue;
  7323. }
  7324. if(query->record().count()> columns)
  7325. {
  7326. table->appendColumns(query->record().count()-columns);
  7327. }
  7328. do
  7329. {
  7330. table->appendRows(1);
  7331. rows++;
  7332. currentRow++;
  7333. for(int j= 0;j<query->record().count();j++)
  7334. {
  7335. QTextTableCell cell= table->cellAt(currentRow,j);
  7336. cursor= cell.firstCursorPosition();
  7337. cursor.insertText(query->value(j).toString());
  7338. }
  7339. }while(query->next());
  7340. /*:660*/
  7341. #line 14177 "./typica.w"
  7342. }
  7343. else if(currentElement.tagName()=="row")
  7344. {
  7345. /*661:*/
  7346. #line 14232 "./typica.w"
  7347. table->appendRows(1);
  7348. currentRow++;
  7349. rows++;
  7350. QDomNodeList rowChildren= currentElement.childNodes();
  7351. int currentColumn= 0;
  7352. for(int j= 0;j<rowChildren.count();j++)
  7353. {
  7354. QDomNode node;
  7355. QDomElement nodeElement;
  7356. node= rowChildren.at(j);
  7357. if(node.isElement())
  7358. {
  7359. nodeElement= node.toElement();
  7360. if(nodeElement.tagName()=="cell")
  7361. {
  7362. if(currentColumn==columns)
  7363. {
  7364. table->appendColumns(1);
  7365. columns++;
  7366. }
  7367. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7368. cursor= cell.firstCursorPosition();
  7369. cursor.insertText(nodeElement.text());
  7370. currentColumn++;
  7371. }
  7372. }
  7373. }
  7374. /*:661*/
  7375. #line 14181 "./typica.w"
  7376. }
  7377. }
  7378. }
  7379. /*:659*/
  7380. #line 14126 "./typica.w"
  7381. if(rows> 1)
  7382. {
  7383. table->removeRows(0,1);
  7384. }
  7385. }
  7386. /*:656*/
  7387. #line 568 "./typica.w"
  7388. /*687:*/
  7389. #line 14336 "./typica.w"
  7390. FormArray::FormArray(QDomElement description):configuration(description),
  7391. maxwidth(-1),maxheight(-1)
  7392. {
  7393. setWidget(&itemContainer);
  7394. itemContainer.setLayout(&itemLayout);
  7395. }
  7396. /*:687*//*688:*/
  7397. #line 14353 "./typica.w"
  7398. void FormArray::addElements(int copies)
  7399. {
  7400. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7401. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7402. QWidget*widget;
  7403. for(int i= 0;i<copies;i++)
  7404. {
  7405. widget= new QWidget;
  7406. if(maxwidth> -1)
  7407. {
  7408. widget->setMaximumWidth(maxwidth);
  7409. }
  7410. if(maxheight> -1)
  7411. {
  7412. widget->setMaximumHeight(maxheight);
  7413. }
  7414. if(configuration.hasChildNodes())
  7415. {
  7416. widgetStack->push(widget);
  7417. populateWidget(configuration,widgetStack,layoutStack);
  7418. widgetStack->pop();
  7419. widget->setMinimumHeight(widget->sizeHint().height());
  7420. itemLayout.addWidget(widget);
  7421. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7422. {
  7423. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7424. }
  7425. else
  7426. {
  7427. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7428. +widget->sizeHint().height());
  7429. }
  7430. if(maxwidth> -1)
  7431. {
  7432. itemContainer.setMinimumWidth(maxwidth+50);
  7433. }
  7434. else
  7435. {
  7436. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7437. }
  7438. }
  7439. }
  7440. }
  7441. /*:688*//*689:*/
  7442. #line 14403 "./typica.w"
  7443. QWidget*FormArray::elementAt(int index)
  7444. {
  7445. if(index<itemLayout.count())
  7446. {
  7447. QLayoutItem*item= itemLayout.itemAt(index);
  7448. return item->widget();
  7449. }
  7450. else
  7451. {
  7452. return NULL;
  7453. }
  7454. }
  7455. /*:689*//*690:*/
  7456. #line 14420 "./typica.w"
  7457. void FormArray::removeAllElements()
  7458. {
  7459. while(itemLayout.count()> 0)
  7460. {
  7461. QLayoutItem*item;
  7462. item= itemLayout.itemAt(0);
  7463. item->widget()->hide();
  7464. itemLayout.removeWidget(item->widget());
  7465. }
  7466. itemContainer.setMinimumHeight(0);
  7467. }
  7468. /*:690*//*691:*/
  7469. #line 14436 "./typica.w"
  7470. int FormArray::elements()
  7471. {
  7472. return itemLayout.count();
  7473. }
  7474. /*:691*//*692:*/
  7475. #line 14447 "./typica.w"
  7476. void FormArray::setMaximumElementWidth(int width)
  7477. {
  7478. maxwidth= width;
  7479. }
  7480. void FormArray::setMaximumElementHeight(int height)
  7481. {
  7482. maxheight= height;
  7483. }
  7484. /*:692*/
  7485. #line 569 "./typica.w"
  7486. /*698:*/
  7487. #line 14578 "./typica.w"
  7488. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7489. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7490. {
  7491. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7492. QPointF(0,5);
  7493. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7494. QPointF(10,5);
  7495. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7496. QPointF(0,0);
  7497. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7498. initialBrush.setColor(QColor(170,170,255));
  7499. initialBrush.setStyle(Qt::SolidPattern);
  7500. finalBrush.setColor(Qt::blue);
  7501. finalBrush.setStyle(Qt::SolidPattern);
  7502. initialDecrement.setPolygon(left);
  7503. initialDecrement.setBrush(initialBrush);
  7504. initialDecrement.setPos(0,0);
  7505. scene.addItem(&initialDecrement);
  7506. initialIncrement.setPolygon(right);
  7507. initialIncrement.setBrush(initialBrush);
  7508. initialIncrement.setPos(122,0);
  7509. scene.addItem(&initialIncrement);
  7510. finalDecrement.setPolygon(left);
  7511. finalDecrement.setBrush(finalBrush);
  7512. finalDecrement.setPos(0,12);
  7513. scene.addItem(&finalDecrement);
  7514. finalIncrement.setPolygon(right);
  7515. finalIncrement.setBrush(finalBrush);
  7516. finalIncrement.setPos(122,12);
  7517. scene.addItem(&finalIncrement);
  7518. scalePath.moveTo(0,10);
  7519. scalePath.lineTo(100,10);
  7520. scalePath.moveTo(0,0);
  7521. scalePath.lineTo(0,20);
  7522. scalePath.moveTo(10,5);
  7523. scalePath.lineTo(10,15);
  7524. scalePath.moveTo(20,5);
  7525. scalePath.lineTo(20,15);
  7526. scalePath.moveTo(30,5);
  7527. scalePath.lineTo(30,15);
  7528. scalePath.moveTo(40,5);
  7529. scalePath.lineTo(40,15);
  7530. scalePath.moveTo(50,0);
  7531. scalePath.lineTo(50,20);
  7532. scalePath.moveTo(60,5);
  7533. scalePath.lineTo(60,15);
  7534. scalePath.moveTo(70,5);
  7535. scalePath.lineTo(70,15);
  7536. scalePath.moveTo(80,5);
  7537. scalePath.lineTo(80,15);
  7538. scalePath.moveTo(90,5);
  7539. scalePath.lineTo(90,15);
  7540. scalePath.moveTo(100,0);
  7541. scalePath.lineTo(100,20);
  7542. scaleLine.setPath(scalePath);
  7543. scaleLine.setPos(16,1);
  7544. scene.addItem(&scaleLine);
  7545. setScene(&scene);
  7546. initialIndicator.setPolygon(down);
  7547. initialIndicator.setBrush(initialBrush);
  7548. finalIndicator.setPolygon(up);
  7549. finalIndicator.setBrush(finalBrush);
  7550. setMinimumSize(sizeHint());
  7551. setMaximumSize(sizeHint());
  7552. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7553. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7554. setMinimumSize(sizeHint());
  7555. }
  7556. /*:698*//*699:*/
  7557. #line 14651 "./typica.w"
  7558. QSize ScaleControl::sizeHint()const
  7559. {
  7560. return QSize(140,30);
  7561. }
  7562. /*:699*//*700:*/
  7563. #line 14660 "./typica.w"
  7564. void ScaleControl::setInitialValue(double value)
  7565. {
  7566. if(value>=0&&value<=10)
  7567. {
  7568. nonScoredValue= value;
  7569. if(!initialSet)
  7570. {
  7571. scene.addItem(&initialIndicator);
  7572. }
  7573. initialSet= true;
  7574. initialIndicator.setPos(value*10+16,10);
  7575. emit initialChanged(value);
  7576. if(!finalSet)
  7577. {
  7578. setFinalValue(value);
  7579. }
  7580. }
  7581. }
  7582. void ScaleControl::setFinalValue(double value)
  7583. {
  7584. if(value>=0&&value<=10)
  7585. {
  7586. scoredValue= value;
  7587. if(!finalSet)
  7588. {
  7589. scene.addItem(&finalIndicator);
  7590. }
  7591. finalSet= true;
  7592. finalIndicator.setPos(value*10+16,11);
  7593. emit finalChanged(value);
  7594. }
  7595. }
  7596. /*:700*//*701:*/
  7597. #line 14697 "./typica.w"
  7598. double ScaleControl::initialValue(void)
  7599. {
  7600. return nonScoredValue;
  7601. }
  7602. double ScaleControl::finalValue(void)
  7603. {
  7604. return scoredValue;
  7605. }
  7606. /*:701*//*702:*/
  7607. #line 14718 "./typica.w"
  7608. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7609. {
  7610. /*703:*/
  7611. #line 14730 "./typica.w"
  7612. if(event->button()!=Qt::LeftButton)
  7613. {
  7614. event->ignore();
  7615. return;
  7616. }
  7617. /*:703*/
  7618. #line 14721 "./typica.w"
  7619. scaleDown= true;
  7620. event->accept();
  7621. }
  7622. /*:702*//*704:*/
  7623. #line 14741 "./typica.w"
  7624. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7625. {
  7626. /*703:*/
  7627. #line 14730 "./typica.w"
  7628. if(event->button()!=Qt::LeftButton)
  7629. {
  7630. event->ignore();
  7631. return;
  7632. }
  7633. /*:703*/
  7634. #line 14744 "./typica.w"
  7635. if(!scaleDown)
  7636. {
  7637. event->ignore();
  7638. return;
  7639. }
  7640. scaleDown= false;
  7641. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7642. /*705:*/
  7643. #line 14766 "./typica.w"
  7644. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7645. {
  7646. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7647. {
  7648. if(initialSet)
  7649. {
  7650. setInitialValue(nonScoredValue-0.05);
  7651. }
  7652. event->accept();
  7653. return;
  7654. }
  7655. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7656. {
  7657. if(finalSet)
  7658. {
  7659. setFinalValue(scoredValue-0.05);
  7660. event->accept();
  7661. return;
  7662. }
  7663. }
  7664. }
  7665. /*:705*/
  7666. #line 14752 "./typica.w"
  7667. /*706:*/
  7668. #line 14792 "./typica.w"
  7669. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7670. {
  7671. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7672. {
  7673. if(initialSet)
  7674. {
  7675. setInitialValue(nonScoredValue+0.05);
  7676. event->accept();
  7677. return;
  7678. }
  7679. }
  7680. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7681. {
  7682. if(finalSet)
  7683. {
  7684. setFinalValue(scoredValue+0.05);
  7685. event->accept();
  7686. return;
  7687. }
  7688. }
  7689. }
  7690. /*:706*/
  7691. #line 14753 "./typica.w"
  7692. /*707:*/
  7693. #line 14818 "./typica.w"
  7694. double relativeX= sceneCoordinate.x()-16;
  7695. if(initialSet)
  7696. {
  7697. if(relativeX>=0&&relativeX<=100)
  7698. {
  7699. setFinalValue(relativeX/10.0);
  7700. event->accept();
  7701. return;
  7702. }
  7703. }
  7704. else
  7705. {
  7706. if(relativeX>=0&&relativeX<=100)
  7707. {
  7708. setInitialValue(relativeX/10.0);
  7709. event->accept();
  7710. return;
  7711. }
  7712. }
  7713. /*:707*/
  7714. #line 14754 "./typica.w"
  7715. event->ignore();
  7716. return;
  7717. }
  7718. /*:704*/
  7719. #line 570 "./typica.w"
  7720. /*709:*/
  7721. #line 14884 "./typica.w"
  7722. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7723. valueSet(false),scaleDown(false)
  7724. {
  7725. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7726. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7727. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7728. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7729. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7730. theBrush.setColor(Qt::blue);
  7731. theBrush.setStyle(Qt::SolidPattern);
  7732. increment.setPolygon(up);
  7733. increment.setBrush(theBrush);
  7734. increment.setPos(0,0);
  7735. scene.addItem(&increment);
  7736. decrement.setPolygon(down);
  7737. decrement.setBrush(theBrush);
  7738. decrement.setPos(0,122);
  7739. scene.addItem(&decrement);
  7740. scalePath.moveTo(5,0);
  7741. scalePath.lineTo(5,100);
  7742. scalePath.moveTo(0,0);
  7743. scalePath.lineTo(10,0);
  7744. scalePath.moveTo(0,10);
  7745. scalePath.lineTo(10,10);
  7746. scalePath.moveTo(0,20);
  7747. scalePath.lineTo(10,20);
  7748. scalePath.moveTo(0,30);
  7749. scalePath.lineTo(10,30);
  7750. scalePath.moveTo(0,40);
  7751. scalePath.lineTo(10,40);
  7752. scalePath.moveTo(0,50);
  7753. scalePath.lineTo(10,50);
  7754. scalePath.moveTo(0,60);
  7755. scalePath.lineTo(10,60);
  7756. scalePath.moveTo(0,70);
  7757. scalePath.lineTo(10,70);
  7758. scalePath.moveTo(0,80);
  7759. scalePath.lineTo(10,80);
  7760. scalePath.moveTo(0,90);
  7761. scalePath.lineTo(10,90);
  7762. scalePath.moveTo(0,100);
  7763. scalePath.lineTo(10,100);
  7764. scaleLine.setPath(scalePath);
  7765. scaleLine.setPos(0,16);
  7766. scene.addItem(&scaleLine);
  7767. setScene(&scene);
  7768. indicator.setPolygon(left);
  7769. indicator.setBrush(theBrush);
  7770. setMinimumSize(sizeHint());
  7771. setMaximumSize(sizeHint());
  7772. }
  7773. /*:709*//*710:*/
  7774. #line 14939 "./typica.w"
  7775. QSize IntensityControl::sizeHint()const
  7776. {
  7777. return QSize(25,160);
  7778. }
  7779. /*:710*//*711:*/
  7780. #line 14954 "./typica.w"
  7781. void IntensityControl::setValue(double val)
  7782. {
  7783. if(val>=0&&val<=10)
  7784. {
  7785. theValue= val;
  7786. if(!valueSet)
  7787. {
  7788. scene.addItem(&indicator);
  7789. }
  7790. valueSet= true;
  7791. indicator.setPos(6,(100-(val*10))+16);
  7792. emit(valueChanged(val));
  7793. }
  7794. else if(val<1)
  7795. {
  7796. setValue(0);
  7797. }
  7798. else
  7799. {
  7800. setValue(10);
  7801. }
  7802. }
  7803. double IntensityControl::value()
  7804. {
  7805. return theValue;
  7806. }
  7807. /*:711*//*712:*/
  7808. #line 14986 "./typica.w"
  7809. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7810. {
  7811. /*703:*/
  7812. #line 14730 "./typica.w"
  7813. if(event->button()!=Qt::LeftButton)
  7814. {
  7815. event->ignore();
  7816. return;
  7817. }
  7818. /*:703*/
  7819. #line 14989 "./typica.w"
  7820. scaleDown= true;
  7821. event->accept();
  7822. }
  7823. /*:712*//*713:*/
  7824. #line 15000 "./typica.w"
  7825. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7826. {
  7827. /*703:*/
  7828. #line 14730 "./typica.w"
  7829. if(event->button()!=Qt::LeftButton)
  7830. {
  7831. event->ignore();
  7832. return;
  7833. }
  7834. /*:703*/
  7835. #line 15003 "./typica.w"
  7836. if(!scaleDown)
  7837. {
  7838. event->ignore();
  7839. return;
  7840. }
  7841. scaleDown= false;
  7842. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7843. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7844. {
  7845. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7846. {
  7847. if(valueSet)
  7848. {
  7849. setValue(theValue+0.05);
  7850. }
  7851. event->accept();
  7852. return;
  7853. }
  7854. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7855. {
  7856. if(valueSet)
  7857. {
  7858. setValue(theValue-0.05);
  7859. }
  7860. event->accept();
  7861. return;
  7862. }
  7863. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7864. {
  7865. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7866. event->accept();
  7867. return;
  7868. }
  7869. }
  7870. }
  7871. /*:713*/
  7872. #line 571 "./typica.w"
  7873. /*364:*/
  7874. #line 8229 "./typica.w"
  7875. void ThresholdDetector::newMeasurement(Measurement measure)
  7876. {
  7877. if((currentDirection==Ascending&&previousValue<threshold&&
  7878. previousValue>=0)||(currentDirection==Descending&&
  7879. previousValue> threshold&&previousValue>=0))
  7880. {
  7881. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7882. (currentDirection==Descending&&measure.temperature()<=threshold))
  7883. {
  7884. double offset= measure.time().hour()*60*60;
  7885. offset+= measure.time().minute()*60;
  7886. offset+= measure.time().second();
  7887. offset+= measure.time().msec()/1000;
  7888. emit timeForValue(offset);
  7889. }
  7890. }
  7891. previousValue= measure.temperature();
  7892. }
  7893. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7894. previousValue(-1),threshold(value),currentDirection(Ascending)
  7895. {
  7896. }
  7897. void ThresholdDetector::setThreshold(double value)
  7898. {
  7899. threshold= value;
  7900. }
  7901. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7902. {
  7903. currentDirection= direction;
  7904. }
  7905. /*:364*/
  7906. #line 572 "./typica.w"
  7907. /*795:*/
  7908. #line 16892 "./typica.w"
  7909. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  7910. lister(new QextSerialEnumerator)
  7911. {
  7912. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  7913. QextPortInfo port;
  7914. foreach(port,ports)
  7915. {
  7916. #ifdef Q_OS_WIN32
  7917. addItem(port.portName);
  7918. #else
  7919. addItem(port.physName);
  7920. #endif
  7921. }
  7922. lister->setUpNotifications();
  7923. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  7924. this,SLOT(addDevice(QextPortInfo)));
  7925. setEditable(true);
  7926. }
  7927. void PortSelector::addDevice(QextPortInfo port)
  7928. {
  7929. addItem(port.portName);
  7930. }
  7931. /*:795*/
  7932. #line 573 "./typica.w"
  7933. /*797:*/
  7934. #line 16984 "./typica.w"
  7935. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  7936. {
  7937. QMetaObject meta= BaudSelector::staticMetaObject;
  7938. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  7939. for(int i= 0;i<type.keyCount();i++)
  7940. {
  7941. addItem(QString("%1").arg(type.value(i)));
  7942. }
  7943. }
  7944. /*:797*/
  7945. #line 574 "./typica.w"
  7946. /*799:*/
  7947. #line 17022 "./typica.w"
  7948. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  7949. {
  7950. QMetaObject meta= ParitySelector::staticMetaObject;
  7951. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  7952. for(int i= 0;i<type.keyCount();i++)
  7953. {
  7954. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7955. }
  7956. }
  7957. /*:799*/
  7958. #line 575 "./typica.w"
  7959. /*801:*/
  7960. #line 17052 "./typica.w"
  7961. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  7962. {
  7963. QMetaObject meta= FlowSelector::staticMetaObject;
  7964. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  7965. for(int i= 0;i<type.keyCount();i++)
  7966. {
  7967. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7968. }
  7969. }
  7970. /*:801*/
  7971. #line 576 "./typica.w"
  7972. /*803:*/
  7973. #line 17087 "./typica.w"
  7974. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  7975. {
  7976. QMetaObject meta= StopSelector::staticMetaObject;
  7977. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  7978. for(int i= 0;i<type.keyCount();i++)
  7979. {
  7980. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7981. }
  7982. }
  7983. /*:803*/
  7984. #line 577 "./typica.w"
  7985. /*863:*/
  7986. #line 18869 "./typica.w"
  7987. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  7988. :BasicDeviceConfigurationWidget(model,index),
  7989. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  7990. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  7991. decimalQuery(new QCheckBox(tr("Enable"))),
  7992. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  7993. unitQuery(new QCheckBox(tr("Enable"))),
  7994. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  7995. valueC(new QSpinBox),fixedUnit(new QComboBox),
  7996. pVAddress(new ShortHexSpinBox),
  7997. sVEnabled(new QCheckBox(tr("Enable"))),
  7998. sVReadAddress(new ShortHexSpinBox),
  7999. deviceLimit(new QCheckBox(tr("Enable"))),
  8000. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8001. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8002. sVWritable(new QCheckBox(tr("Enable"))),
  8003. sVOutputAddr(new ShortHexSpinBox),
  8004. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8005. {
  8006. QHBoxLayout*layout= new QHBoxLayout;
  8007. QWidget*form= new QWidget;
  8008. QHBoxLayout*masterLayout= new QHBoxLayout;
  8009. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8010. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8011. QFormLayout*serialSection= new QFormLayout;
  8012. serialSection->addRow(QString(tr("Port:")),port);
  8013. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8014. serialSection->addRow(QString(tr("Parity:")),parity);
  8015. serialSection->addRow(QString(tr("Flow control:")),flow);
  8016. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8017. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8018. serialSectionBox->setLayout(serialSection);
  8019. portAndDeviceLayout->addWidget(serialSectionBox);
  8020. QFormLayout*deviceSection= new QFormLayout;
  8021. station->setMinimum(1);
  8022. station->setMaximum(255);
  8023. decimalPosition->setMinimum(0);
  8024. decimalPosition->setMaximum(9);
  8025. valueF->setMinimum(0);
  8026. valueF->setMaximum(0xFFFF);
  8027. valueC->setMinimum(0);
  8028. valueC->setMaximum(0xFFFF);
  8029. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8030. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8031. deviceSection->addRow(tr("Station:"),station);
  8032. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8033. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8034. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8035. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8036. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8037. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8038. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8039. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8040. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8041. deviceSectionBox->setLayout(deviceSection);
  8042. portAndDeviceLayout->addWidget(deviceSectionBox);
  8043. QFormLayout*pVSection= new QFormLayout;
  8044. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8045. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8046. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8047. pVSection->addRow(pVHideBox);
  8048. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8049. processValueBox->setLayout(pVSection);
  8050. seriesLayout->addWidget(processValueBox);
  8051. QFormLayout*sVSection= new QFormLayout;
  8052. sVLower->setDecimals(1);
  8053. sVLower->setMinimum(0.0);
  8054. sVLower->setMaximum(999.9);
  8055. sVUpper->setDecimals(1);
  8056. sVUpper->setMinimum(0.0);
  8057. sVUpper->setMaximum(999.9);
  8058. sVSection->addRow(tr("Set value:"),sVEnabled);
  8059. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8060. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8061. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8062. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8063. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8064. sVSection->addRow(tr("Lower limit:"),sVLower);
  8065. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8066. sVSection->addRow(tr("Output set value:"),sVWritable);
  8067. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8068. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8069. sVSection->addRow(sVHideBox);
  8070. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8071. setValueBox->setLayout(sVSection);
  8072. seriesLayout->addWidget(setValueBox);
  8073. masterLayout->addLayout(portAndDeviceLayout);
  8074. masterLayout->addLayout(seriesLayout);
  8075. form->setLayout(masterLayout);
  8076. /*771:*/
  8077. #line 16333 "./typica.w"
  8078. QDomElement referenceElement=
  8079. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8080. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8081. QDomElement node;
  8082. /*:771*/
  8083. #line 18959 "./typica.w"
  8084. for(int i= 0;i<configData.size();i++)
  8085. {
  8086. node= configData.at(i).toElement();
  8087. if(node.attribute("name")=="port")
  8088. {
  8089. QString portname= node.attribute("value");
  8090. int idx= port->findText(portname);
  8091. if(idx>=0)
  8092. {
  8093. port->setCurrentIndex(idx);
  8094. }
  8095. else
  8096. {
  8097. port->addItem(portname);
  8098. }
  8099. }
  8100. else if(node.attribute("name")=="baud")
  8101. {
  8102. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8103. }
  8104. else if(node.attribute("name")=="parity")
  8105. {
  8106. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8107. }
  8108. else if(node.attribute("name")=="flow")
  8109. {
  8110. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8111. }
  8112. else if(node.attribute("name")=="stop")
  8113. {
  8114. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8115. }
  8116. else if(node.attribute("name")=="station")
  8117. {
  8118. station->setValue(node.attribute("value").toInt());
  8119. }
  8120. else if(node.attribute("name")=="decimalQuery")
  8121. {
  8122. if(node.attribute("value")=="true")
  8123. {
  8124. decimalQuery->setChecked(true);
  8125. }
  8126. else
  8127. {
  8128. decimalQuery->setChecked(false);
  8129. }
  8130. }
  8131. else if(node.attribute("name")=="decimalAddress")
  8132. {
  8133. decimalAddress->setValue(node.attribute("value").toInt());
  8134. }
  8135. else if(node.attribute("name")=="decimalPosition")
  8136. {
  8137. decimalPosition->setValue(node.attribute("value").toInt());
  8138. }
  8139. else if(node.attribute("name")=="unitQuery")
  8140. {
  8141. if(node.attribute("value")=="true")
  8142. {
  8143. unitQuery->setChecked(true);
  8144. }
  8145. else
  8146. {
  8147. unitQuery->setChecked(false);
  8148. }
  8149. }
  8150. else if(node.attribute("name")=="unitAddress")
  8151. {
  8152. unitAddress->setValue(node.attribute("value").toInt());
  8153. }
  8154. else if(node.attribute("name")=="valueF")
  8155. {
  8156. valueF->setValue(node.attribute("value").toInt());
  8157. }
  8158. else if(node.attribute("name")=="valueC")
  8159. {
  8160. valueC->setValue(node.attribute("value").toInt());
  8161. }
  8162. else if(node.attribute("name")=="fixedUnit")
  8163. {
  8164. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8165. }
  8166. else if(node.attribute("name")=="pVAddress")
  8167. {
  8168. pVAddress->setValue(node.attribute("value").toInt());
  8169. }
  8170. else if(node.attribute("name")=="sVEnabled")
  8171. {
  8172. if(node.attribute("value")=="true")
  8173. {
  8174. sVEnabled->setChecked(true);
  8175. }
  8176. else
  8177. {
  8178. sVEnabled->setChecked(false);
  8179. }
  8180. }
  8181. else if(node.attribute("name")=="sVReadAddress")
  8182. {
  8183. sVReadAddress->setValue(node.attribute("value").toInt());
  8184. }
  8185. else if(node.attribute("name")=="deviceLimit")
  8186. {
  8187. if(node.attribute("value")=="true")
  8188. {
  8189. deviceLimit->setChecked(true);
  8190. }
  8191. else
  8192. {
  8193. deviceLimit->setChecked(false);
  8194. }
  8195. }
  8196. else if(node.attribute("name")=="sVLowerAddr")
  8197. {
  8198. sVLowerAddr->setValue(node.attribute("value").toInt());
  8199. }
  8200. else if(node.attribute("name")=="sVUpperAddr")
  8201. {
  8202. sVUpperAddr->setValue(node.attribute("value").toInt());
  8203. }
  8204. else if(node.attribute("name")=="sVLower")
  8205. {
  8206. sVLower->setValue(node.attribute("value").toDouble());
  8207. }
  8208. else if(node.attribute("name")=="sVUpper")
  8209. {
  8210. sVUpper->setValue(node.attribute("value").toDouble());
  8211. }
  8212. else if(node.attribute("name")=="sVWritable")
  8213. {
  8214. if(node.attribute("value")=="true")
  8215. {
  8216. sVWritable->setChecked(true);
  8217. }
  8218. else
  8219. {
  8220. sVWritable->setChecked(false);
  8221. }
  8222. }
  8223. else if(node.attribute("name")=="sVOutputAddr")
  8224. {
  8225. sVOutputAddr->setValue(node.attribute("value").toInt());
  8226. }
  8227. else if(node.attribute("name")=="pvcolname")
  8228. {
  8229. pVColumnName->setText(node.attribute("value"));
  8230. }
  8231. else if(node.attribute("name")=="svcolname")
  8232. {
  8233. sVColumnName->setText(node.attribute("value"));
  8234. }
  8235. else if(node.attribute("name")=="pvhidden")
  8236. {
  8237. pVHideBox->setChecked(node.attribute("value")=="true");
  8238. }
  8239. else if(node.attribute("name")=="svhidden")
  8240. {
  8241. sVHideBox->setChecked(node.attribute("value")=="true");
  8242. }
  8243. }
  8244. updatePort(port->currentText());
  8245. updateBaudRate(baud->currentText());
  8246. updateParity(parity->itemData(parity->currentIndex()).toString());
  8247. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8248. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8249. updateStation(station->value());
  8250. updateFixedDecimal(decimalQuery->isChecked());
  8251. updateDecimalAddress(decimalAddress->value());
  8252. updateDecimalPosition(decimalPosition->value());
  8253. updateFixedUnit(unitQuery->isChecked());
  8254. updateUnitAddress(unitAddress->value());
  8255. updateValueForF(valueF->value());
  8256. updateValueForC(valueC->value());
  8257. updateUnit(fixedUnit->currentText());
  8258. updatePVAddress(pVAddress->value());
  8259. updateSVEnabled(sVEnabled->isChecked());
  8260. updateSVReadAddress(sVReadAddress->value());
  8261. updateDeviceLimit(deviceLimit->isChecked());
  8262. updateSVLowerAddress(sVLowerAddr->value());
  8263. updateSVUpperAddress(sVUpperAddr->value());
  8264. updateSVLower(sVLower->value());
  8265. updateSVUpper(sVUpper->value());
  8266. updateSVWritable(sVWritable->isChecked());
  8267. updateSVWriteAddress(sVOutputAddr->value());
  8268. updatePVColumnName(pVColumnName->text());
  8269. updateSVColumnName(sVColumnName->text());
  8270. updatePVHidden(pVHideBox->isChecked());
  8271. updateSVHidden(sVHideBox->isChecked());
  8272. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8273. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8274. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8275. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8276. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8277. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8278. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8279. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8280. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8281. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8282. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8283. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8284. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8285. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8286. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8287. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8288. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8289. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8290. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8291. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8292. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8293. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8294. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8295. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8296. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8297. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8298. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8299. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8300. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8301. layout->addWidget(form);
  8302. setLayout(layout);
  8303. }
  8304. void ModbusConfigurator::updatePort(const QString&newPort)
  8305. {
  8306. updateAttribute("port",newPort);
  8307. }
  8308. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8309. {
  8310. updateAttribute("baud",newRate);
  8311. }
  8312. void ModbusConfigurator::updateParity(const QString&)
  8313. {
  8314. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8315. }
  8316. void ModbusConfigurator::updateFlowControl(const QString&)
  8317. {
  8318. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8319. }
  8320. void ModbusConfigurator::updateStopBits(const QString&)
  8321. {
  8322. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8323. }
  8324. void ModbusConfigurator::updateStation(int station)
  8325. {
  8326. updateAttribute("station",QString("%1").arg(station));
  8327. }
  8328. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8329. {
  8330. updateAttribute("decimalQuery",fixed?"true":"false");
  8331. }
  8332. void ModbusConfigurator::updateDecimalAddress(int address)
  8333. {
  8334. updateAttribute("decimalAddress",QString("%1").arg(address));
  8335. }
  8336. void ModbusConfigurator::updateDecimalPosition(int position)
  8337. {
  8338. updateAttribute("decimalPosition",QString("%1").arg(position));
  8339. }
  8340. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8341. {
  8342. updateAttribute("unitQuery",fixed?"true":"false");
  8343. }
  8344. void ModbusConfigurator::updateUnitAddress(int address)
  8345. {
  8346. updateAttribute("unitAddress",QString("%1").arg(address));
  8347. }
  8348. void ModbusConfigurator::updateValueForF(int value)
  8349. {
  8350. updateAttribute("valueF",QString("%1").arg(value));
  8351. }
  8352. void ModbusConfigurator::updateValueForC(int value)
  8353. {
  8354. updateAttribute("valueC",QString("%1").arg(value));
  8355. }
  8356. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8357. {
  8358. updateAttribute("fixedUnit",newUnit);
  8359. }
  8360. void ModbusConfigurator::updatePVAddress(int address)
  8361. {
  8362. updateAttribute("pVAddress",QString("%1").arg(address));
  8363. }
  8364. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8365. {
  8366. updateAttribute("sVEnabled",enabled?"true":"false");
  8367. }
  8368. void ModbusConfigurator::updateSVReadAddress(int address)
  8369. {
  8370. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8371. }
  8372. void ModbusConfigurator::updateDeviceLimit(bool query)
  8373. {
  8374. updateAttribute("deviceLimit",query?"true":"false");
  8375. }
  8376. void ModbusConfigurator::updateSVLowerAddress(int address)
  8377. {
  8378. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8379. }
  8380. void ModbusConfigurator::updateSVUpperAddress(int address)
  8381. {
  8382. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8383. }
  8384. void ModbusConfigurator::updateSVLower(double value)
  8385. {
  8386. updateAttribute("sVLower",QString("%1").arg(value));
  8387. }
  8388. void ModbusConfigurator::updateSVUpper(double value)
  8389. {
  8390. updateAttribute("sVUpper",QString("%1").arg(value));
  8391. }
  8392. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8393. {
  8394. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8395. }
  8396. void ModbusConfigurator::updateSVWriteAddress(int address)
  8397. {
  8398. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8399. }
  8400. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8401. {
  8402. updateAttribute("pvcolname",name);
  8403. }
  8404. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8405. {
  8406. updateAttribute("svcolname",name);
  8407. }
  8408. void ModbusConfigurator::updatePVHidden(bool hidden)
  8409. {
  8410. updateAttribute("pvhidden",hidden?"true":"false");
  8411. }
  8412. void ModbusConfigurator::updateSVHidden(bool hidden)
  8413. {
  8414. updateAttribute("svhidden",hidden?"true":"false");
  8415. }
  8416. /*:863*/
  8417. #line 578 "./typica.w"
  8418. /*806:*/
  8419. #line 17136 "./typica.w"
  8420. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8421. {
  8422. setMinimum(0);
  8423. setMaximum(0xFFFF);
  8424. setPrefix("0x");
  8425. setMinimumWidth(65);
  8426. }
  8427. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8428. {
  8429. if(input.size()==2)
  8430. {
  8431. return QValidator::Intermediate;
  8432. }
  8433. bool okay;
  8434. input.toInt(&okay,16);
  8435. if(okay)
  8436. {
  8437. return QValidator::Acceptable;
  8438. }
  8439. return QValidator::Invalid;
  8440. }
  8441. int ShortHexSpinBox::valueFromText(const QString&text)const
  8442. {
  8443. return text.toInt(NULL,16);
  8444. }
  8445. QString ShortHexSpinBox::textFromValue(int value)const
  8446. {
  8447. QString retval;
  8448. retval.setNum(value,16);
  8449. while(retval.size()<4)
  8450. {
  8451. retval.prepend("0");
  8452. }
  8453. return retval.toUpper();
  8454. }
  8455. /*:806*/
  8456. #line 579 "./typica.w"
  8457. /*847:*/
  8458. #line 18168 "./typica.w"
  8459. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8460. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8461. waiting(false)
  8462. {
  8463. qDebug()<<"Initializing Modbus RTU Device";
  8464. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8465. Qt::UserRole).toString());
  8466. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8467. QDomElement node;
  8468. QVariantMap attributes;
  8469. for(int i= 0;i<portConfigData.size();i++)
  8470. {
  8471. node= portConfigData.at(i).toElement();
  8472. attributes.insert(node.attribute("name"),node.attribute("value"));
  8473. }
  8474. port= new QextSerialPort(attributes.value("port").toString(),
  8475. QextSerialPort::EventDriven);
  8476. int baudRate= attributes.value("baud").toInt();
  8477. port->setBaudRate((BaudRateType)baudRate);
  8478. double temp= ((double)(1)/(double)(baudRate))*48;
  8479. delayTime= (int)(temp*3000);
  8480. messageDelayTimer->setSingleShot(true);
  8481. commTimeout->setSingleShot(true);
  8482. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8483. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8484. port->setDataBits(DATA_8);
  8485. port->setParity((ParityType)attributes.value("parity").toInt());
  8486. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8487. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8488. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8489. port->open(QIODevice::ReadWrite);
  8490. station= (char)attributes.value("station").toInt();
  8491. if(attributes.value("decimalQuery")=="true")
  8492. {
  8493. decimalPosition= 0;
  8494. QByteArray message;
  8495. message.append(station);
  8496. message.append((char)0x03);
  8497. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8498. char*addressBytes= (char*)&address;
  8499. message.append(addressBytes[1]);
  8500. message.append(addressBytes[0]);
  8501. message.append((char)0x00);
  8502. message.append((char)0x01);
  8503. queueMessage(message,this,"decimalResponse(QByteArray)");
  8504. }
  8505. else
  8506. {
  8507. decimalPosition= attributes.value("decimalPosition").toInt();
  8508. }
  8509. valueF= attributes.value("valueF").toInt();
  8510. valueC= attributes.value("valueC").toInt();
  8511. if(attributes.value("unitQuery")=="true")
  8512. {
  8513. QByteArray message;
  8514. message.append(station);
  8515. message.append((char)0x03);
  8516. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8517. char*addressBytes= (char*)&address;
  8518. message.append(addressBytes[1]);
  8519. message.append(addressBytes[0]);
  8520. message.append((char)0x00);
  8521. message.append((char)0x01);
  8522. queueMessage(message,this,"unitResponse(QByteArray)");
  8523. }
  8524. else
  8525. {
  8526. if(attributes.value("fixedUnit")=="Celsius")
  8527. {
  8528. unitIsF= false;
  8529. }
  8530. }
  8531. if(attributes.value("sVWritable")=="true")
  8532. {
  8533. if(attributes.value("deviceLimit")=="true")
  8534. {
  8535. QByteArray lmessage;
  8536. lmessage.append(station);
  8537. lmessage.append((char)0x03);
  8538. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8539. char*addressBytes= (char*)&laddress;
  8540. lmessage.append(addressBytes[1]);
  8541. lmessage.append(addressBytes[0]);
  8542. lmessage.append((char)0x00);
  8543. lmessage.append((char)0x01);
  8544. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8545. QByteArray umessage;
  8546. umessage.append(station);
  8547. umessage.append((char)0x03);
  8548. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8549. addressBytes= (char*)&uaddress;
  8550. umessage.append(addressBytes[1]);
  8551. umessage.append(addressBytes[0]);
  8552. umessage.append((char)0x00);
  8553. umessage.append((char)0x01);
  8554. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8555. }
  8556. else
  8557. {
  8558. outputSVLower= attributes.value("sVLower").toDouble();
  8559. outputSVUpper= attributes.value("sVUpper").toDouble();
  8560. }
  8561. outputSVStub.append(station);
  8562. outputSVStub.append((char)0x06);
  8563. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8564. char*addressBytes= (char*)&address;
  8565. outputSVStub.append(addressBytes[1]);
  8566. outputSVStub.append(addressBytes[0]);
  8567. }
  8568. Channel*pv= new Channel;
  8569. channels.append(pv);
  8570. pvStub.append(station);
  8571. pvStub.append((char)0x04);
  8572. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8573. char*pvac= (char*)&pvaddress;
  8574. pvStub.append(pvac[1]);
  8575. pvStub.append(pvac[0]);
  8576. pvStub.append((char)0x00);
  8577. pvStub.append((char)0x01);
  8578. svenabled= attributes.value("sVEnabled").toBool();
  8579. if(svenabled)
  8580. {
  8581. Channel*sv= new Channel;
  8582. channels.append(sv);
  8583. svStub.append(station);
  8584. svStub.append((char)0x04);
  8585. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8586. char*svac= (char*)&svaddress;
  8587. svStub.append(svac[1]);
  8588. svStub.append(svac[0]);
  8589. svStub.append((char)0x00);
  8590. svStub.append((char)0x01);
  8591. if(svaddress-pvaddress==1)
  8592. {
  8593. mStub.append(station);
  8594. mStub.append((char)0x04);
  8595. mStub.append(pvac[1]);
  8596. mStub.append(pvac[0]);
  8597. mStub.append((char)0x00);
  8598. mStub.append((char)0x02);
  8599. }
  8600. }
  8601. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8602. requestMeasurement();
  8603. }
  8604. double ModbusRTUDevice::SVLower()
  8605. {
  8606. return outputSVLower;
  8607. }
  8608. double ModbusRTUDevice::SVUpper()
  8609. {
  8610. return outputSVUpper;
  8611. }
  8612. int ModbusRTUDevice::decimals()
  8613. {
  8614. return decimalPosition;
  8615. }
  8616. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8617. {
  8618. quint16 temp;
  8619. char*tchar= (char*)&temp;
  8620. tchar[1]= response.at(3);
  8621. tchar[0]= response.at(4);
  8622. decimalPosition= temp;
  8623. emit SVDecimalChanged(decimalPosition);
  8624. qDebug()<<"Received decimal response";
  8625. }
  8626. void ModbusRTUDevice::unitResponse(QByteArray response)
  8627. {
  8628. quint16 temp;
  8629. char*tchar= (char*)&temp;
  8630. tchar[1]= response.at(3);
  8631. tchar[0]= response.at(4);
  8632. int value= temp;
  8633. if(value==valueF)
  8634. {
  8635. unitIsF= true;
  8636. }
  8637. else
  8638. {
  8639. unitIsF= false;
  8640. }
  8641. qDebug()<<"Received unit response";
  8642. }
  8643. void ModbusRTUDevice::svlResponse(QByteArray response)
  8644. {
  8645. quint16 temp;
  8646. char*tchar= (char*)&temp;
  8647. tchar[1]= response.at(3);
  8648. tchar[0]= response.at(4);
  8649. outputSVLower= (double)temp;
  8650. for(int i= 0;i<decimalPosition;i++)
  8651. {
  8652. outputSVLower/= 10;
  8653. }
  8654. emit SVLowerChanged(outputSVLower);
  8655. qDebug()<<"Received set value lower bound response";
  8656. }
  8657. void ModbusRTUDevice::svuResponse(QByteArray response)
  8658. {
  8659. quint16 temp;
  8660. char*tchar= (char*)&temp;
  8661. tchar[1]= response.at(3);
  8662. tchar[0]= response.at(4);
  8663. outputSVUpper= (double)temp;
  8664. for(int i= 0;i<decimalPosition;i++)
  8665. {
  8666. outputSVUpper/= 10;
  8667. }
  8668. emit SVUpperChanged(outputSVUpper);
  8669. qDebug()<<"Received set value upper bound response";
  8670. }
  8671. void ModbusRTUDevice::requestMeasurement()
  8672. {
  8673. if(mStub.length()> 0)
  8674. {
  8675. queueMessage(mStub,this,"mResponse(QByteArray)");
  8676. }
  8677. else
  8678. {
  8679. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8680. if(svenabled)
  8681. {
  8682. queueMessage(svStub,this,"mResponse(QByteArray)");
  8683. }
  8684. }
  8685. }
  8686. void ModbusRTUDevice::mResponse(QByteArray response)
  8687. {
  8688. QTime time= QTime::currentTime();
  8689. if(response.at(2)==0x04)
  8690. {
  8691. /*848:*/
  8692. #line 18423 "./typica.w"
  8693. quint16 pv;
  8694. quint16 sv;
  8695. char*pvBytes= (char*)&pv;
  8696. char*svBytes= (char*)&sv;
  8697. pvBytes[1]= response.at(3);
  8698. pvBytes[0]= response.at(4);
  8699. svBytes[1]= response.at(5);
  8700. svBytes[0]= response.at(6);
  8701. double pvOut= (double)pv;
  8702. double svOut= (double)sv;
  8703. for(int i= 0;i<decimalPosition;i++)
  8704. {
  8705. pvOut/= 10;
  8706. svOut/= 10;
  8707. }
  8708. if(!unitIsF)
  8709. {
  8710. pvOut= pvOut*9/5+32;
  8711. svOut= svOut*9/5+32;
  8712. }
  8713. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8714. Measurement svm(svOut,time,Units::Fahrenheit);
  8715. channels.at(0)->input(pvm);
  8716. channels.at(1)->input(svm);
  8717. /*:848*/
  8718. #line 18410 "./typica.w"
  8719. }
  8720. else
  8721. {
  8722. /*849:*/
  8723. #line 18453 "./typica.w"
  8724. quint16 value;
  8725. char*valueBytes= (char*)&value;
  8726. valueBytes[1]= response.at(3);
  8727. valueBytes[0]= response.at(4);
  8728. double valueOut= (double)value;
  8729. for(int i= 0;i<decimalPosition;i++)
  8730. {
  8731. valueOut/= 10;
  8732. }
  8733. if(!unitIsF)
  8734. {
  8735. valueOut= valueOut*9/5+32;
  8736. }
  8737. if(!svenabled)
  8738. {
  8739. Measurement vm(valueOut,time,Units::Fahrenheit);
  8740. channels.at(0)->input(vm);
  8741. }
  8742. else
  8743. {
  8744. if(readingsv)
  8745. {
  8746. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8747. Measurement svm(valueOut,time,Units::Fahrenheit);
  8748. channels.at(0)->input(pvm);
  8749. channels.at(1)->input(svm);
  8750. readingsv= false;
  8751. }
  8752. else
  8753. {
  8754. savedpv= valueOut;
  8755. readingsv= true;
  8756. }
  8757. }
  8758. /*:849*/
  8759. #line 18414 "./typica.w"
  8760. }
  8761. }
  8762. /*:847*//*850:*/
  8763. #line 18491 "./typica.w"
  8764. ModbusRTUDevice::~ModbusRTUDevice()
  8765. {
  8766. commTimeout->stop();
  8767. messageDelayTimer->stop();
  8768. port->close();
  8769. }
  8770. /*:850*//*851:*/
  8771. #line 18518 "./typica.w"
  8772. void ModbusRTUDevice::dataAvailable()
  8773. {
  8774. if(messageDelayTimer->isActive())
  8775. {
  8776. messageDelayTimer->stop();
  8777. }
  8778. responseBuffer.append(port->readAll());
  8779. /*852:*/
  8780. #line 18564 "./typica.w"
  8781. if(responseBuffer.size()<5)
  8782. {
  8783. return;
  8784. }
  8785. switch(responseBuffer.at(1))
  8786. {
  8787. case 0x01:
  8788. case 0x02:
  8789. if(responseBuffer.size()<6)
  8790. {
  8791. return;
  8792. }
  8793. responseBuffer= responseBuffer.left(6);
  8794. break;
  8795. case 0x03:
  8796. case 0x04:
  8797. if(responseBuffer.size()<5+responseBuffer.at(2))
  8798. {
  8799. return;
  8800. }
  8801. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8802. break;
  8803. case 0x05:
  8804. case 0x06:
  8805. case 0x10:
  8806. if(responseBuffer.size()<8)
  8807. {
  8808. return;
  8809. }
  8810. responseBuffer= responseBuffer.left(8);
  8811. break;
  8812. }
  8813. /*:852*/
  8814. #line 18526 "./typica.w"
  8815. commTimeout->stop();
  8816. if(calculateCRC(responseBuffer)==0)
  8817. {
  8818. QObject*object= retObjQueue.at(0);
  8819. char*method= callbackQueue.at(0);
  8820. QMetaMethod metamethod= object->metaObject()->
  8821. method(object->metaObject()->
  8822. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8823. metamethod.invoke(object,Qt::QueuedConnection,
  8824. Q_ARG(QByteArray,responseBuffer));
  8825. messageQueue.removeAt(0);
  8826. retObjQueue.removeAt(0);
  8827. callbackQueue.removeAt(0);
  8828. }
  8829. else
  8830. {
  8831. qDebug()<<"CRC failed";
  8832. }
  8833. messageDelayTimer->start(delayTime);
  8834. waiting= false;
  8835. responseBuffer.clear();
  8836. }
  8837. /*:851*//*853:*/
  8838. #line 18606 "./typica.w"
  8839. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8840. {
  8841. quint16 retval= 0xFFFF;
  8842. int i= 0;
  8843. while(i<data.size())
  8844. {
  8845. retval^= 0x00FF&(quint16)data.at(i);
  8846. for(int j= 0;j<8;j++)
  8847. {
  8848. if(retval&1)
  8849. {
  8850. retval= (retval>>1)^0xA001;
  8851. }
  8852. else
  8853. {
  8854. retval>>= 1;
  8855. }
  8856. }
  8857. i++;
  8858. }
  8859. return retval;
  8860. }
  8861. /*:853*//*854:*/
  8862. #line 18637 "./typica.w"
  8863. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8864. const char*callback)
  8865. {
  8866. messageQueue.append(request);
  8867. retObjQueue.append(object);
  8868. callbackQueue.append(const_cast<char*> (callback));
  8869. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8870. {
  8871. sendNextMessage();
  8872. }
  8873. }
  8874. void ModbusRTUDevice::sendNextMessage()
  8875. {
  8876. if(messageQueue.size()> 0&&!waiting)
  8877. {
  8878. QByteArray message= messageQueue.at(0);
  8879. quint16 crc= calculateCRC(message);
  8880. char*check= (char*)&crc;
  8881. message.append(check[0]);
  8882. message.append(check[1]);
  8883. port->write(message);
  8884. commTimeout->start(2000);
  8885. messageDelayTimer->start(delayTime);
  8886. waiting= true;
  8887. }
  8888. else
  8889. {
  8890. emit queueEmpty();
  8891. }
  8892. }
  8893. void ModbusRTUDevice::outputSV(double value)
  8894. {
  8895. for(int i= 0;i<decimalPosition;i++)
  8896. {
  8897. value*= 10;
  8898. }
  8899. quint16 outval= (quint16)value;
  8900. QByteArray message(outputSVStub);
  8901. char*valBytes= (char*)&outval;
  8902. message.append(valBytes[1]);
  8903. message.append(valBytes[0]);
  8904. queueMessage(message,this,"ignore(QByteArray)");
  8905. }
  8906. /*:854*//*855:*/
  8907. #line 18686 "./typica.w"
  8908. void ModbusRTUDevice::ignore(QByteArray)
  8909. {
  8910. return;
  8911. }
  8912. /*:855*//*856:*/
  8913. #line 18699 "./typica.w"
  8914. void ModbusRTUDevice::timeout()
  8915. {
  8916. qDebug()<<"Communications timeout.";
  8917. responseBuffer.clear();
  8918. waiting= false;
  8919. messageDelayTimer->start();
  8920. }
  8921. /*:856*/
  8922. #line 580 "./typica.w"
  8923. /*725:*/
  8924. #line 15258 "./typica.w"
  8925. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  8926. DeviceTreeModelNode*parent)
  8927. :domNode(node),rowNumber(row),parentItem(parent)
  8928. {
  8929. }
  8930. DeviceTreeModelNode::~DeviceTreeModelNode()
  8931. {
  8932. QHash<int,DeviceTreeModelNode*> ::iterator i;
  8933. for(i= children.begin();i!=children.end();i++)
  8934. {
  8935. delete i.value();
  8936. }
  8937. }
  8938. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  8939. {
  8940. return parentItem;
  8941. }
  8942. int DeviceTreeModelNode::row()
  8943. {
  8944. return rowNumber;
  8945. }
  8946. QDomNode DeviceTreeModelNode::node()const
  8947. {
  8948. return domNode;
  8949. }
  8950. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  8951. {
  8952. if(children.contains(index))
  8953. {
  8954. return children[index];
  8955. }
  8956. if(index>=0&&index<domNode.childNodes().count())
  8957. {
  8958. QDomNode childNode= domNode.childNodes().item(index);
  8959. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  8960. index,this);
  8961. children[index]= childItem;
  8962. return childItem;
  8963. }
  8964. return NULL;
  8965. }
  8966. /*:725*/
  8967. #line 581 "./typica.w"
  8968. /*727:*/
  8969. #line 15347 "./typica.w"
  8970. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  8971. :QAbstractItemModel(parent)
  8972. {
  8973. document= AppInstance->deviceConfiguration();
  8974. QDomNodeList elements= document.elementsByTagName("devices");
  8975. if(elements.size()!=1)
  8976. {
  8977. qDebug()<<"Unexpected result when loading device map.";
  8978. }
  8979. treeRoot= elements.at(0);
  8980. root= new DeviceTreeModelNode(treeRoot,0);
  8981. elements= document.elementsByTagName("references");
  8982. if(elements.size()!=1)
  8983. {
  8984. qDebug()<<"No references section. Creating.";
  8985. referenceSection= document.createElement("references");
  8986. document.appendChild(referenceSection);
  8987. }
  8988. else
  8989. {
  8990. referenceSection= elements.at(0);
  8991. }
  8992. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  8993. AppInstance,SLOT(saveDeviceConfiguration()));
  8994. connect(this,SIGNAL(modelReset()),
  8995. AppInstance,SLOT(saveDeviceConfiguration()));
  8996. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8997. AppInstance,SLOT(saveDeviceConfiguration()));
  8998. }
  8999. /*:727*//*728:*/
  9000. #line 15382 "./typica.w"
  9001. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9002. {
  9003. return 1;
  9004. }
  9005. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9006. {
  9007. if(parent.column()> 0)
  9008. {
  9009. return 0;
  9010. }
  9011. /*729:*/
  9012. #line 15401 "./typica.w"
  9013. DeviceTreeModelNode*parentItem;
  9014. if(!parent.isValid())
  9015. {
  9016. parentItem= root;
  9017. }
  9018. else
  9019. {
  9020. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9021. }
  9022. /*:729*/
  9023. #line 15394 "./typica.w"
  9024. return parentItem->node().childNodes().count();
  9025. }
  9026. /*:728*//*730:*/
  9027. #line 15415 "./typica.w"
  9028. QModelIndex DeviceTreeModel::index(int row,int column,
  9029. const QModelIndex&parent)const
  9030. {
  9031. if(!hasIndex(row,column,parent))
  9032. {
  9033. return QModelIndex();
  9034. }
  9035. /*729:*/
  9036. #line 15401 "./typica.w"
  9037. DeviceTreeModelNode*parentItem;
  9038. if(!parent.isValid())
  9039. {
  9040. parentItem= root;
  9041. }
  9042. else
  9043. {
  9044. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9045. }
  9046. /*:729*/
  9047. #line 15423 "./typica.w"
  9048. DeviceTreeModelNode*childItem= parentItem->child(row);
  9049. if(childItem)
  9050. {
  9051. return createIndex(row,column,childItem);
  9052. }
  9053. return QModelIndex();
  9054. }
  9055. /*:730*//*731:*/
  9056. #line 15434 "./typica.w"
  9057. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9058. {
  9059. if(!child.isValid())
  9060. {
  9061. return QModelIndex();
  9062. }
  9063. DeviceTreeModelNode*childItem=
  9064. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9065. DeviceTreeModelNode*parentItem= childItem->parent();
  9066. if(!parentItem||parentItem==root)
  9067. {
  9068. return QModelIndex();
  9069. }
  9070. return createIndex(parentItem->row(),0,parentItem);
  9071. }
  9072. /*:731*//*732:*/
  9073. #line 15453 "./typica.w"
  9074. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9075. {
  9076. if(!index.isValid())
  9077. {
  9078. return 0;
  9079. }
  9080. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9081. }
  9082. /*:732*//*733:*/
  9083. #line 15468 "./typica.w"
  9084. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9085. {
  9086. if(!index.isValid())
  9087. {
  9088. return QVariant();
  9089. }
  9090. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9091. {
  9092. return QVariant();
  9093. }
  9094. DeviceTreeModelNode*item=
  9095. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9096. QDomNode node= item->node();
  9097. QDomElement element= node.toElement();
  9098. switch(role)
  9099. {
  9100. case Qt::DisplayRole:
  9101. case Qt::EditRole:
  9102. return QVariant(element.attribute("name"));
  9103. case Qt::UserRole:
  9104. return QVariant(element.attribute("reference"));
  9105. default:
  9106. return QVariant();
  9107. }
  9108. return QVariant();
  9109. }
  9110. /*:733*//*734:*/
  9111. #line 15500 "./typica.w"
  9112. bool DeviceTreeModel::setData(const QModelIndex&index,
  9113. const QVariant&value,int)
  9114. {
  9115. if(!index.isValid())
  9116. {
  9117. return false;
  9118. }
  9119. DeviceTreeModelNode*item=
  9120. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9121. QDomNode node= item->node();
  9122. QDomElement element= node.toElement();
  9123. element.setAttribute("name",value.toString());
  9124. emit dataChanged(index,index);
  9125. return true;
  9126. }
  9127. /*:734*//*735:*/
  9128. #line 15523 "./typica.w"
  9129. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9130. const QModelIndex&parent)
  9131. {
  9132. QString referenceID= QUuid::createUuid().toString();
  9133. /*729:*/
  9134. #line 15401 "./typica.w"
  9135. DeviceTreeModelNode*parentItem;
  9136. if(!parent.isValid())
  9137. {
  9138. parentItem= root;
  9139. }
  9140. else
  9141. {
  9142. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9143. }
  9144. /*:729*/
  9145. #line 15528 "./typica.w"
  9146. QDomNode parentNode= parentItem->node();
  9147. int newRowNumber= rowCount(parent);
  9148. beginInsertRows(parent,newRowNumber,newRowNumber);
  9149. QDomElement deviceElement= document.createElement("node");
  9150. deviceElement.setAttribute("name",name);
  9151. deviceElement.setAttribute("reference",referenceID);
  9152. parentNode.appendChild(deviceElement);
  9153. QDomElement referenceElement= document.createElement("reference");
  9154. referenceElement.setAttribute("id",referenceID);
  9155. referenceElement.setAttribute("driver",driver);
  9156. referenceSection.appendChild(referenceElement);
  9157. endInsertRows();
  9158. }
  9159. /*:735*//*736:*/
  9160. #line 15546 "./typica.w"
  9161. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9162. {
  9163. /*729:*/
  9164. #line 15401 "./typica.w"
  9165. DeviceTreeModelNode*parentItem;
  9166. if(!parent.isValid())
  9167. {
  9168. parentItem= root;
  9169. }
  9170. else
  9171. {
  9172. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9173. }
  9174. /*:729*/
  9175. #line 15549 "./typica.w"
  9176. QDomNode parentNode= parentItem->node();
  9177. QDomNodeList childNodes= parentNode.childNodes();
  9178. if(childNodes.size()<row+count)
  9179. {
  9180. return false;
  9181. }
  9182. beginRemoveRows(parent,row,row+count-1);
  9183. QList<QDomElement> removalList;
  9184. for(int i= row;i<row+count;i++)
  9185. {
  9186. removalList.append(childNodes.at(i).toElement());
  9187. }
  9188. QDomElement element;
  9189. QDomElement reference;
  9190. for(int i= 0;i<count;i++)
  9191. {
  9192. element= removalList.at(i);
  9193. if(element.hasAttribute("reference"))
  9194. {
  9195. reference= referenceElement(element.attribute("reference"));
  9196. if(!reference.isNull())
  9197. {
  9198. referenceSection.removeChild(reference);
  9199. }
  9200. }
  9201. parentNode.removeChild(element);
  9202. }
  9203. endRemoveRows();
  9204. beginResetModel();
  9205. delete root;
  9206. root= new DeviceTreeModelNode(treeRoot,0);
  9207. endResetModel();
  9208. return true;
  9209. }
  9210. /*:736*//*737:*/
  9211. #line 15588 "./typica.w"
  9212. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9213. {
  9214. QDomNodeList childNodes= referenceSection.childNodes();
  9215. QDomElement element;
  9216. for(int i= 0;i<childNodes.size();i++)
  9217. {
  9218. element= childNodes.at(i).toElement();
  9219. if(element.hasAttribute("id"))
  9220. {
  9221. if(element.attribute("id")==id)
  9222. {
  9223. return element;
  9224. }
  9225. }
  9226. }
  9227. return QDomElement();
  9228. }
  9229. /*:737*//*738:*/
  9230. #line 15609 "./typica.w"
  9231. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9232. {
  9233. return QVariant();
  9234. }
  9235. /*:738*//*739:*/
  9236. #line 15618 "./typica.w"
  9237. DeviceTreeModel::~DeviceTreeModel()
  9238. {
  9239. delete root;
  9240. }
  9241. /*:739*/
  9242. #line 582 "./typica.w"
  9243. /*766:*/
  9244. #line 16118 "./typica.w"
  9245. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9246. DeviceTreeModel*model,const QModelIndex&index)
  9247. :QWidget(NULL),deviceModel(model),currentNode(index)
  9248. {
  9249. }
  9250. /*:766*//*767:*/
  9251. #line 16130 "./typica.w"
  9252. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9253. const QString&value)
  9254. {
  9255. QDomElement referenceElement= deviceModel->referenceElement(
  9256. deviceModel->data(currentNode,Qt::UserRole).toString());
  9257. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9258. QDomElement node;
  9259. bool found= false;
  9260. for(int i= 0;i<configData.size();i++)
  9261. {
  9262. node= configData.at(i).toElement();
  9263. if(node.attribute("name")==name)
  9264. {
  9265. node.setAttribute("value",value);
  9266. found= true;
  9267. break;
  9268. }
  9269. }
  9270. if(!found)
  9271. {
  9272. node= AppInstance->deviceConfiguration().createElement("attribute");
  9273. node.setAttribute("name",name);
  9274. node.setAttribute("value",value);
  9275. referenceElement.appendChild(node);
  9276. }
  9277. AppInstance->saveDeviceConfiguration();
  9278. }
  9279. /*:767*//*768:*/
  9280. #line 16164 "./typica.w"
  9281. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9282. const QString&driver)
  9283. {
  9284. deviceModel->newNode(name,driver,currentNode);
  9285. }
  9286. /*:768*/
  9287. #line 583 "./typica.w"
  9288. /*757:*/
  9289. #line 15962 "./typica.w"
  9290. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9291. view(new QTreeView),configArea(new QScrollArea)
  9292. {
  9293. QSplitter*splitter= new QSplitter;
  9294. QWidget*leftWidget= new QWidget;
  9295. leftWidget->setMinimumWidth(200);
  9296. QVBoxLayout*left= new QVBoxLayout;
  9297. view->setAnimated(true);
  9298. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9299. document= AppInstance->deviceConfiguration();
  9300. model= new DeviceTreeModel;
  9301. view->setModel(model);
  9302. view->setTextElideMode(Qt::ElideNone);
  9303. view->expandAll();
  9304. view->resizeColumnToContents(0);
  9305. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9306. QHBoxLayout*treeButtons= new QHBoxLayout;
  9307. QToolButton*addDeviceButton= new QToolButton;
  9308. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9309. addDeviceButton->setToolTip(tr("New Roaster"));
  9310. connect(addDeviceButton,SIGNAL(clicked()),
  9311. this,SLOT(addDevice()));
  9312. QToolButton*removeNodeButton= new QToolButton;
  9313. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9314. removeNodeButton->setToolTip(tr("Delete Selection"));
  9315. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9316. treeButtons->addWidget(addDeviceButton);
  9317. treeButtons->addWidget(removeNodeButton);
  9318. left->addWidget(view);
  9319. left->addLayout(treeButtons);
  9320. leftWidget->setLayout(left);
  9321. splitter->addWidget(leftWidget);
  9322. configArea->setMinimumWidth(580);
  9323. configArea->setMinimumHeight(460);
  9324. configArea->setWidgetResizable(true);
  9325. splitter->addWidget(configArea);
  9326. QVBoxLayout*centralLayout= new QVBoxLayout;
  9327. centralLayout->addWidget(splitter);
  9328. setLayout(centralLayout);
  9329. connect(view,SIGNAL(activated(QModelIndex)),
  9330. this,SLOT(newSelection(QModelIndex)));
  9331. connect(view,SIGNAL(clicked(QModelIndex)),
  9332. this,SLOT(newSelection(QModelIndex)));
  9333. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9334. view,SLOT(expand(QModelIndex)));
  9335. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9336. this,SLOT(resizeColumn()));
  9337. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9338. this,SLOT(resizeColumn()));
  9339. }
  9340. /*:757*//*758:*/
  9341. #line 16017 "./typica.w"
  9342. void DeviceConfigurationWindow::addDevice()
  9343. {
  9344. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9345. }
  9346. /*:758*//*759:*/
  9347. #line 16025 "./typica.w"
  9348. void DeviceConfigurationWindow::removeNode()
  9349. {
  9350. QModelIndex index= view->currentIndex();
  9351. if(index.isValid())
  9352. {
  9353. int row= index.row();
  9354. QModelIndex parent= index.parent();
  9355. model->removeRow(row,parent);
  9356. }
  9357. }
  9358. /*:759*//*760:*/
  9359. #line 16041 "./typica.w"
  9360. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9361. {
  9362. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9363. if(editor)
  9364. {
  9365. configArea->setWidget(editor);
  9366. editor->show();
  9367. }
  9368. }
  9369. /*:760*//*761:*/
  9370. #line 16058 "./typica.w"
  9371. void DeviceConfigurationWindow::resizeColumn()
  9372. {
  9373. view->resizeColumnToContents(0);
  9374. }
  9375. /*:761*/
  9376. #line 584 "./typica.w"
  9377. /*781:*/
  9378. #line 16539 "./typica.w"
  9379. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9380. const QModelIndex&index):
  9381. BasicDeviceConfigurationWidget(model,index)
  9382. {
  9383. QFormLayout*layout= new QFormLayout;
  9384. QLineEdit*columnName= new QLineEdit;
  9385. layout->addRow(tr("Column Name:"),columnName);
  9386. QComboBox*typeSelector= new QComboBox;
  9387. typeSelector->addItem("J");
  9388. typeSelector->addItem("K");
  9389. typeSelector->addItem("T");
  9390. typeSelector->addItem("B");
  9391. typeSelector->addItem("E");
  9392. typeSelector->addItem("N");
  9393. typeSelector->addItem("R");
  9394. typeSelector->addItem("S");
  9395. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9396. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9397. layout->addRow(hideSeries);
  9398. setLayout(layout);
  9399. /*771:*/
  9400. #line 16333 "./typica.w"
  9401. QDomElement referenceElement=
  9402. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9403. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9404. QDomElement node;
  9405. /*:771*/
  9406. #line 16560 "./typica.w"
  9407. for(int i= 0;i<configData.size();i++)
  9408. {
  9409. node= configData.at(i).toElement();
  9410. if(node.attribute("name")=="type")
  9411. {
  9412. typeSelector->setCurrentIndex(
  9413. typeSelector->findText(node.attribute("value")));
  9414. }
  9415. else if(node.attribute("name")=="columnname")
  9416. {
  9417. columnName->setText(node.attribute("value"));
  9418. }
  9419. else if(node.attribute("name")=="hidden")
  9420. {
  9421. hideSeries->setChecked(node.attribute("value")=="true");
  9422. }
  9423. }
  9424. updateThermocoupleType(typeSelector->currentText());
  9425. updateColumnName(columnName->text());
  9426. updateHidden(hideSeries->isChecked());
  9427. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9428. this,SLOT(updateThermocoupleType(QString)));
  9429. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9430. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9431. }
  9432. /*:781*//*782:*/
  9433. #line 16590 "./typica.w"
  9434. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9435. {
  9436. updateAttribute("type",type);
  9437. }
  9438. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9439. {
  9440. updateAttribute("columnname",name);
  9441. }
  9442. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9443. {
  9444. updateAttribute("hidden",hidden?"true":"false");
  9445. }
  9446. /*:782*/
  9447. #line 585 "./typica.w"
  9448. /*777:*/
  9449. #line 16453 "./typica.w"
  9450. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9451. const QModelIndex&index)
  9452. :BasicDeviceConfigurationWidget(model,index)
  9453. {
  9454. QVBoxLayout*layout= new QVBoxLayout;
  9455. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9456. QLabel*label= new QLabel(tr("Device ID:"));
  9457. QLineEdit*deviceId= new QLineEdit;
  9458. deviceIdLayout->addWidget(label);
  9459. deviceIdLayout->addWidget(deviceId);
  9460. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9461. layout->addLayout(deviceIdLayout);
  9462. layout->addWidget(addChannelButton);
  9463. /*771:*/
  9464. #line 16333 "./typica.w"
  9465. QDomElement referenceElement=
  9466. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9467. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9468. QDomElement node;
  9469. /*:771*/
  9470. #line 16467 "./typica.w"
  9471. for(int i= 0;i<configData.size();i++)
  9472. {
  9473. node= configData.at(i).toElement();
  9474. if(node.attribute("name")=="deviceID")
  9475. {
  9476. deviceId->setText(node.attribute("value","Dev1"));
  9477. break;
  9478. }
  9479. }
  9480. updateDeviceId(deviceId->text());
  9481. connect(addChannelButton,SIGNAL(clicked()),
  9482. this,SLOT(addChannel()));
  9483. connect(deviceId,SIGNAL(textEdited(QString)),
  9484. this,SLOT(updateDeviceId(QString)));
  9485. setLayout(layout);
  9486. }
  9487. /*:777*//*778:*/
  9488. #line 16489 "./typica.w"
  9489. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9490. {
  9491. updateAttribute("deviceID",newId);
  9492. }
  9493. /*:778*//*779:*/
  9494. #line 16497 "./typica.w"
  9495. void NiDaqMxBase9211ConfWidget::addChannel()
  9496. {
  9497. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9498. }
  9499. /*:779*/
  9500. #line 586 "./typica.w"
  9501. /*775:*/
  9502. #line 16404 "./typica.w"
  9503. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9504. DeviceTreeModel*model,const QModelIndex&index):
  9505. BasicDeviceConfigurationWidget(model,index)
  9506. {
  9507. QHBoxLayout*layout= new QHBoxLayout;
  9508. QToolButton*addDeviceButton= new QToolButton;
  9509. addDeviceButton->setText(tr("Add Device"));
  9510. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9511. "nidaqmxbase9211series");
  9512. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9513. "nidaqmxbase9211series");
  9514. connect(add9211,SIGNAL(triggered(QString,QString)),
  9515. this,SLOT(insertChildNode(QString,QString)));
  9516. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9517. this,SLOT(insertChildNode(QString,QString)));
  9518. QMenu*deviceMenu= new QMenu;
  9519. deviceMenu->addAction(add9211);
  9520. deviceMenu->addAction(add9211a);
  9521. addDeviceButton->setMenu(deviceMenu);
  9522. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9523. layout->addWidget(addDeviceButton);
  9524. setLayout(layout);
  9525. }
  9526. /*:775*/
  9527. #line 587 "./typica.w"
  9528. /*642:*/
  9529. #line 13878 "./typica.w"
  9530. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9531. QObject*parent):
  9532. QAction(reportName,parent),reportFile(fileName)
  9533. {
  9534. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9535. }
  9536. /*:642*//*643:*/
  9537. #line 13894 "./typica.w"
  9538. void ReportAction::createReport()
  9539. {
  9540. QFile file(reportFile);
  9541. QDomDocument document;
  9542. if(file.open(QIODevice::ReadOnly))
  9543. {
  9544. document.setContent(&file,true);
  9545. QDomElement element= document.documentElement();
  9546. QScriptEngine*engine= AppInstance->engine;
  9547. QScriptContext*context= engine->pushContext();
  9548. QScriptValue object;
  9549. QString targetID= reportFile;
  9550. /*198:*/
  9551. #line 4628 "./typica.w"
  9552. ScriptQMainWindow*window= new ScriptQMainWindow;
  9553. window->setObjectName(targetID);
  9554. object= engine->newQObject(window);
  9555. setQMainWindowProperties(object,engine);
  9556. QWidget*central= new(QWidget);
  9557. central->setParent(window);
  9558. central->setObjectName("centralWidget");
  9559. window->setCentralWidget(central);
  9560. if(element.hasChildNodes())
  9561. {
  9562. /*199:*/
  9563. #line 4663 "./typica.w"
  9564. QStack<QWidget*> widgetStack;
  9565. QStack<QLayout*> layoutStack;
  9566. QString windowScript;
  9567. widgetStack.push(central);
  9568. QDomNodeList windowChildren= element.childNodes();
  9569. int i= 0;
  9570. while(i<windowChildren.count())
  9571. {
  9572. QDomNode current;
  9573. QDomElement element;
  9574. current= windowChildren.at(i);
  9575. if(current.isElement())
  9576. {
  9577. element= current.toElement();
  9578. if(element.tagName()=="program")
  9579. {
  9580. windowScript.append(element.text());
  9581. }
  9582. else if(element.tagName()=="layout")
  9583. {
  9584. element.setAttribute("trcontext","configuration");
  9585. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9586. }
  9587. else if(element.tagName()=="menu")
  9588. {
  9589. /*200:*/
  9590. #line 4711 "./typica.w"
  9591. QMenuBar*bar= window->menuBar();
  9592. bar->setParent(window);
  9593. bar->setObjectName("menuBar");
  9594. if(element.hasAttribute("name"))
  9595. {
  9596. QMenu*menu= bar->addMenu(QCoreApplication::translate(targetID.toAscii().data(),
  9597. element.attribute("name").toUtf8().data()));
  9598. menu->setParent(bar);
  9599. if(element.hasAttribute("type"))
  9600. {
  9601. if(element.attribute("type")=="reports")
  9602. {
  9603. if(element.hasAttribute("src"))
  9604. {
  9605. /*640:*/
  9606. #line 13838 "./typica.w"
  9607. QSettings settings;
  9608. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9609. toString()).
  9610. arg(element.attribute("src"));
  9611. QDir::addSearchPath("reports",reportDirectory);
  9612. QDir directory(reportDirectory);
  9613. directory.setFilter(QDir::Files);
  9614. directory.setSorting(QDir::Name);
  9615. QStringList nameFilter;
  9616. nameFilter<<"*.xml";
  9617. directory.setNameFilters(nameFilter);
  9618. QFileInfoList reportFiles= directory.entryInfoList();
  9619. for(int i= 0;i<reportFiles.size();i++)
  9620. {
  9621. QFileInfo reportFile= reportFiles.at(i);
  9622. /*644:*/
  9623. #line 13918 "./typica.w"
  9624. QString path= reportFile.absoluteFilePath();
  9625. QFile file(path);
  9626. if(file.open(QIODevice::ReadOnly))
  9627. {
  9628. QDomDocument document;
  9629. document.setContent(&file,true);
  9630. QDomElement root= document.documentElement();
  9631. QString translationContext= root.attribute("id");
  9632. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9633. if(!titleNode.isNull())
  9634. {
  9635. QDomElement titleElement= titleNode.toElement();
  9636. QString title= QCoreApplication::translate(translationContext.toAscii().data(),
  9637. titleElement.text().toUtf8().data());
  9638. if(!title.isEmpty())
  9639. {
  9640. QStringList hierarchy= title.split(":->");
  9641. QMenu*insertionPoint= menu;
  9642. /*645:*/
  9643. #line 13947 "./typica.w"
  9644. for(int j= 0;j<hierarchy.size()-1;j++)
  9645. {
  9646. QObjectList menuList= insertionPoint->children();
  9647. bool menuFound= false;
  9648. for(int k= 0;k<menuList.size();k++)
  9649. {
  9650. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9651. if(currentItem)
  9652. {
  9653. if(currentItem->title()==hierarchy.at(j))
  9654. {
  9655. menuFound= true;
  9656. insertionPoint= currentItem;
  9657. break;
  9658. }
  9659. }
  9660. }
  9661. if(!menuFound)
  9662. {
  9663. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9664. }
  9665. }
  9666. /*:645*/
  9667. #line 13937 "./typica.w"
  9668. ReportAction*action= new ReportAction(path,hierarchy.last());
  9669. insertionPoint->addAction(action);
  9670. }
  9671. }
  9672. }
  9673. /*:644*/
  9674. #line 13854 "./typica.w"
  9675. }
  9676. /*:640*/
  9677. #line 4726 "./typica.w"
  9678. }
  9679. }
  9680. }
  9681. if(element.hasChildNodes())
  9682. {
  9683. /*201:*/
  9684. #line 4739 "./typica.w"
  9685. QDomNodeList menuItems= element.childNodes();
  9686. int j= 0;
  9687. while(j<menuItems.count())
  9688. {
  9689. QDomNode item= menuItems.at(j);
  9690. if(item.isElement())
  9691. {
  9692. QDomElement itemElement= item.toElement();
  9693. if(itemElement.tagName()=="item")
  9694. {
  9695. QAction*itemAction= new QAction(QCoreApplication::translate(targetID.toAscii().data(),
  9696. itemElement.text().toUtf8().data()),menu);
  9697. if(itemElement.hasAttribute("id"))
  9698. {
  9699. itemAction->setObjectName(itemElement.attribute("id"));
  9700. }
  9701. if(itemElement.hasAttribute("shortcut"))
  9702. {
  9703. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9704. }
  9705. menu->addAction(itemAction);
  9706. }
  9707. else if(itemElement.tagName()=="separator")
  9708. {
  9709. menu->addSeparator();
  9710. }
  9711. }
  9712. j++;
  9713. }
  9714. #line 1 "./helpmenu.w"
  9715. /*:201*/
  9716. #line 4732 "./typica.w"
  9717. }
  9718. }
  9719. /*:200*/
  9720. #line 4689 "./typica.w"
  9721. }
  9722. }
  9723. i++;
  9724. }
  9725. QScriptValue oldThis= context->thisObject();
  9726. context->setThisObject(object);
  9727. QScriptValue result= engine->evaluate(windowScript);
  9728. /*192:*/
  9729. #line 4445 "./typica.w"
  9730. if(engine->hasUncaughtException())
  9731. {
  9732. int line= engine->uncaughtExceptionLineNumber();
  9733. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9734. result.toString();
  9735. QString trace;
  9736. foreach(trace,engine->uncaughtExceptionBacktrace())
  9737. {
  9738. qDebug()<<trace;
  9739. }
  9740. }
  9741. /*:192*/
  9742. #line 4697 "./typica.w"
  9743. context->setThisObject(oldThis);
  9744. /*:199*/
  9745. #line 4639 "./typica.w"
  9746. }
  9747. /*202:*/
  9748. #line 9 "./helpmenu.w"
  9749. HelpMenu*helpMenu= new HelpMenu();
  9750. window->menuBar()->addMenu(helpMenu);
  9751. /*:202*/
  9752. #line 4641 "./typica.w"
  9753. window->show();
  9754. /*:198*/
  9755. #line 13907 "./typica.w"
  9756. file.close();
  9757. engine->popContext();
  9758. }
  9759. }
  9760. /*:643*/
  9761. #line 588 "./typica.w"
  9762. /*241:*/
  9763. #line 5825 "./typica.w"
  9764. NumericDelegate::NumericDelegate(QObject*parent):
  9765. QItemDelegate(parent)
  9766. {
  9767. }
  9768. /*:241*//*242:*/
  9769. #line 5837 "./typica.w"
  9770. void NumericDelegate::setEditorData(QWidget*editor,
  9771. const QModelIndex&index)const
  9772. {
  9773. QString value= index.model()->data(index,Qt::EditRole).toString();
  9774. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9775. line->setText(value);
  9776. }
  9777. /*:242*//*243:*/
  9778. #line 5852 "./typica.w"
  9779. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9780. const QModelIndex&index)const
  9781. {
  9782. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9783. model->setData(index,line->text(),Qt::EditRole);
  9784. QScriptEngine*engine= AppInstance->engine;
  9785. engine->pushContext();
  9786. QString script= QString("Number(%1)").arg(line->text());
  9787. QScriptValue result= engine->evaluate(line->text());
  9788. if(result.isNumber())
  9789. {
  9790. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9791. }
  9792. else
  9793. {
  9794. model->setData(index,QVariant(),Qt::DisplayRole);
  9795. }
  9796. engine->popContext();
  9797. }
  9798. /*:243*//*244:*/
  9799. #line 5875 "./typica.w"
  9800. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9801. const QStyleOptionViewItem&,
  9802. const QModelIndex&)const
  9803. {
  9804. return(new QLineEdit(parent));
  9805. }
  9806. /*:244*//*245:*/
  9807. #line 5886 "./typica.w"
  9808. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9809. const QStyleOptionViewItem&option,
  9810. const QModelIndex&)const
  9811. {
  9812. editor->setGeometry(option.rect);
  9813. }
  9814. /*:245*/
  9815. #line 589 "./typica.w"
  9816. /*786:*/
  9817. #line 16649 "./typica.w"
  9818. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9819. const QModelIndex&index)
  9820. :BasicDeviceConfigurationWidget(model,index)
  9821. {
  9822. QHBoxLayout*layout= new QHBoxLayout;
  9823. QToolButton*addDeviceButton= new QToolButton;
  9824. addDeviceButton->setText(tr("Add Device"));
  9825. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9826. "nidaqmx9211series");
  9827. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9828. "nidaqmxtc01");
  9829. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9830. this,SLOT(insertChildNode(QString,QString)));
  9831. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9832. this,SLOT(insertChildNode(QString,QString)));
  9833. QMenu*deviceMenu= new QMenu;
  9834. deviceMenu->addAction(add9211a);
  9835. deviceMenu->addAction(addtc01);
  9836. addDeviceButton->setMenu(deviceMenu);
  9837. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9838. layout->addWidget(addDeviceButton);
  9839. setLayout(layout);
  9840. }
  9841. /*:786*/
  9842. #line 590 "./typica.w"
  9843. /*788:*/
  9844. #line 16698 "./typica.w"
  9845. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9846. const QModelIndex&index)
  9847. :BasicDeviceConfigurationWidget(model,index)
  9848. {
  9849. QVBoxLayout*layout= new QVBoxLayout;
  9850. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9851. QLabel*label= new QLabel(tr("Device ID:"));
  9852. QLineEdit*deviceId= new QLineEdit;
  9853. deviceIdLayout->addWidget(label);
  9854. deviceIdLayout->addWidget(deviceId);
  9855. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9856. layout->addLayout(deviceIdLayout);
  9857. layout->addWidget(addChannelButton);
  9858. /*771:*/
  9859. #line 16333 "./typica.w"
  9860. QDomElement referenceElement=
  9861. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9862. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9863. QDomElement node;
  9864. /*:771*/
  9865. #line 16712 "./typica.w"
  9866. for(int i= 0;i<configData.size();i++)
  9867. {
  9868. node= configData.at(i).toElement();
  9869. if(node.attribute("name")=="deviceID")
  9870. {
  9871. deviceId->setText(node.attribute("value","Dev1"));
  9872. break;
  9873. }
  9874. }
  9875. updateDeviceId(deviceId->text());
  9876. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9877. connect(deviceId,SIGNAL(textEdited(QString)),
  9878. this,SLOT(updateDeviceId(QString)));
  9879. setLayout(layout);
  9880. }
  9881. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9882. {
  9883. updateAttribute("deviceID",newId);
  9884. }
  9885. void NiDaqMx9211ConfWidget::addChannel()
  9886. {
  9887. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9888. }
  9889. /*:788*/
  9890. #line 591 "./typica.w"
  9891. /*790:*/
  9892. #line 16763 "./typica.w"
  9893. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9894. const QModelIndex&index)
  9895. :BasicDeviceConfigurationWidget(model,index)
  9896. {
  9897. QFormLayout*layout= new QFormLayout;
  9898. QLineEdit*deviceId= new QLineEdit;
  9899. layout->addRow(tr("Device ID:"),deviceId);
  9900. QLineEdit*columnName= new QLineEdit;
  9901. layout->addRow(tr("Column Name:"),columnName);
  9902. QComboBox*typeSelector= new QComboBox;
  9903. typeSelector->addItem("J");
  9904. typeSelector->addItem("K");
  9905. typeSelector->addItem("T");
  9906. typeSelector->addItem("B");
  9907. typeSelector->addItem("E");
  9908. typeSelector->addItem("N");
  9909. typeSelector->addItem("R");
  9910. typeSelector->addItem("S");
  9911. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9912. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  9913. layout->addRow(hideSeries);
  9914. /*771:*/
  9915. #line 16333 "./typica.w"
  9916. QDomElement referenceElement=
  9917. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9918. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9919. QDomElement node;
  9920. /*:771*/
  9921. #line 16785 "./typica.w"
  9922. for(int i= 0;i<configData.size();i++)
  9923. {
  9924. node= configData.at(i).toElement();
  9925. if(node.attribute("name")=="deviceID")
  9926. {
  9927. deviceId->setText(node.attribute("value"));
  9928. }
  9929. else if(node.attribute("name")=="type")
  9930. {
  9931. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  9932. }
  9933. else if(node.attribute("name")=="columnname")
  9934. {
  9935. columnName->setText(node.attribute("value"));
  9936. }
  9937. else if(node.attribute("name")=="hidden")
  9938. {
  9939. hideSeries->setChecked(node.attribute("value")=="true");
  9940. }
  9941. }
  9942. updateDeviceId(deviceId->text());
  9943. updateThermocoupleType(typeSelector->currentText());
  9944. updateColumnName(columnName->text());
  9945. updateHidden(hideSeries->isChecked());
  9946. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  9947. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  9948. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9949. setLayout(layout);
  9950. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9951. }
  9952. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  9953. {
  9954. updateAttribute("deviceID",newId);
  9955. }
  9956. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  9957. {
  9958. updateAttribute("type",type);
  9959. }
  9960. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  9961. {
  9962. updateAttribute("columnname",name);
  9963. }
  9964. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  9965. {
  9966. updateAttribute("hidden",hidden?"true":"false");
  9967. }
  9968. /*:790*/
  9969. #line 592 "./typica.w"
  9970. /*808:*/
  9971. #line 17201 "./typica.w"
  9972. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  9973. const QModelIndex&index)
  9974. :BasicDeviceConfigurationWidget(model,index)
  9975. {
  9976. QFormLayout*layout= new QFormLayout;
  9977. QToolButton*addDeviceButton= new QToolButton;
  9978. addDeviceButton->setText(tr("Add Device"));
  9979. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  9980. "Modbus RTU Device",
  9981. "modbusrtudevice");
  9982. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  9983. this,SLOT(insertChildNode(QString,QString)));
  9984. QMenu*deviceMenu= new QMenu;
  9985. deviceMenu->addAction(addModbusRtuDevice);
  9986. addDeviceButton->setMenu(deviceMenu);
  9987. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9988. layout->addRow(QString(),addDeviceButton);
  9989. PortSelector*port= new PortSelector;
  9990. layout->addRow(tr("Port:"),port);
  9991. connect(port,SIGNAL(currentIndexChanged(QString)),
  9992. this,SLOT(updatePort(QString)));
  9993. connect(port,SIGNAL(editTextChanged(QString)),
  9994. this,SLOT(updatePort(QString)));
  9995. BaudSelector*rate= new BaudSelector;
  9996. layout->addRow(tr("Baud:"),rate);
  9997. connect(rate,SIGNAL(currentIndexChanged(QString)),
  9998. this,SLOT(updateBaudRate(QString)));
  9999. ParitySelector*parity= new ParitySelector;
  10000. layout->addRow(tr("Parity:"),parity);
  10001. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10002. this,SLOT(updateParity(QString)));
  10003. FlowSelector*flow= new FlowSelector;
  10004. layout->addRow(tr("Flow Control:"),flow);
  10005. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10006. this,SLOT(updateFlowControl(QString)));
  10007. StopSelector*stop= new StopSelector;
  10008. layout->addRow(tr("Stop Bits:"),stop);
  10009. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10010. this,SLOT(updateStopBits(QString)));
  10011. /*771:*/
  10012. #line 16333 "./typica.w"
  10013. QDomElement referenceElement=
  10014. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10015. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10016. QDomElement node;
  10017. /*:771*/
  10018. #line 17241 "./typica.w"
  10019. for(int i= 0;i<configData.size();i++)
  10020. {
  10021. node= configData.at(i).toElement();
  10022. if(node.attribute("name")=="port")
  10023. {
  10024. int j= port->findText(node.attribute("value"));
  10025. if(j>=0)
  10026. {
  10027. port->setCurrentIndex(j);
  10028. }
  10029. else
  10030. {
  10031. port->insertItem(0,node.attribute("value"));
  10032. port->setCurrentIndex(0);
  10033. }
  10034. }
  10035. else if(node.attribute("name")=="baudrate")
  10036. {
  10037. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10038. }
  10039. else if(node.attribute("name")=="parity")
  10040. {
  10041. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10042. }
  10043. else if(node.attribute("name")=="flowcontrol")
  10044. {
  10045. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10046. }
  10047. else if(node.attribute("name")=="stopbits")
  10048. {
  10049. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10050. }
  10051. }
  10052. updatePort(port->currentText());
  10053. updateBaudRate(rate->currentText());
  10054. updateParity(parity->currentText());
  10055. updateFlowControl(flow->currentText());
  10056. updateStopBits(stop->currentText());
  10057. setLayout(layout);
  10058. }
  10059. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10060. {
  10061. updateAttribute("port",newPort);
  10062. }
  10063. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10064. {
  10065. updateAttribute("baudrate",newRate);
  10066. }
  10067. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10068. {
  10069. updateAttribute("parity",newParity);
  10070. }
  10071. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10072. {
  10073. updateAttribute("flowcontrol",newFlow);
  10074. }
  10075. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10076. {
  10077. updateAttribute("stopbits",newStopBits);
  10078. }
  10079. /*:808*/
  10080. #line 593 "./typica.w"
  10081. /*810:*/
  10082. #line 17364 "./typica.w"
  10083. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10084. const QModelIndex&index)
  10085. :BasicDeviceConfigurationWidget(model,index),
  10086. unitSpecificationLayout(new QStackedLayout),
  10087. decimalSpecificationLayout(new QStackedLayout)
  10088. {
  10089. QVBoxLayout*layout= new QVBoxLayout;
  10090. QToolButton*addChannelButton= new QToolButton;
  10091. addChannelButton->setText(tr("Add Channel"));
  10092. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10093. "Temperature Process Value",
  10094. "modbustemperaturepv");
  10095. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10096. "Temperature Set Value",
  10097. "modbustemperaturesv");
  10098. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10099. this,SLOT(insertChildNode(QString,QString)));
  10100. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10101. this,SLOT(insertChildNode(QString,QString)));
  10102. QMenu*channelMenu= new QMenu;
  10103. channelMenu->addAction(addTemperaturePV);
  10104. channelMenu->addAction(addTemperatureSV);
  10105. addChannelButton->setMenu(channelMenu);
  10106. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10107. layout->addWidget(addChannelButton);
  10108. QHBoxLayout*stationLayout= new QHBoxLayout;
  10109. QLabel*stationLabel= new QLabel(tr("Station:"));
  10110. QSpinBox*stationNumber= new QSpinBox;
  10111. stationNumber->setMinimum(0);
  10112. stationNumber->setMaximum(255);
  10113. stationLayout->addWidget(stationLabel);
  10114. stationLayout->addWidget(stationNumber);
  10115. layout->addLayout(stationLayout);
  10116. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10117. layout->addWidget(fixedUnit);
  10118. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10119. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10120. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10121. QComboBox*fixedUnitSelector= new QComboBox;
  10122. fixedUnitSelector->addItem("Fahrenheit");
  10123. fixedUnitSelector->addItem("Celsius");
  10124. fixedUnitLayout->addWidget(fixedUnitLabel);
  10125. fixedUnitLayout->addWidget(fixedUnitSelector);
  10126. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10127. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10128. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10129. QFormLayout*queriedUnitLayout= new QFormLayout;
  10130. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10131. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10132. QSpinBox*valueF= new QSpinBox;
  10133. valueF->setMinimum(0);
  10134. valueF->setMaximum(65535);
  10135. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10136. QSpinBox*valueC= new QSpinBox;
  10137. valueC->setMinimum(0);
  10138. valueC->setMaximum(65535);
  10139. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10140. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10141. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10142. layout->addLayout(unitSpecificationLayout);
  10143. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10144. layout->addWidget(fixedPrecision);
  10145. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10146. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10147. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10148. fixedPrecisionValue->setMinimum(0);
  10149. fixedPrecisionValue->setMaximum(9);
  10150. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10151. fixedPrecisionValue);
  10152. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10153. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10154. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10155. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10156. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10157. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10158. precisionAddress);
  10159. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10160. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10161. layout->addLayout(decimalSpecificationLayout);
  10162. /*771:*/
  10163. #line 16333 "./typica.w"
  10164. QDomElement referenceElement=
  10165. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10166. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10167. QDomElement node;
  10168. /*:771*/
  10169. #line 17444 "./typica.w"
  10170. for(int i= 0;i<configData.size();i++)
  10171. {
  10172. node= configData.at(i).toElement();
  10173. if(node.attribute("name")=="station")
  10174. {
  10175. stationNumber->setValue(node.attribute("value").toInt());
  10176. }
  10177. else if(node.attribute("name")=="fixedunit")
  10178. {
  10179. if(node.attribute("value")=="true")
  10180. {
  10181. fixedUnit->setCheckState(Qt::Checked);
  10182. }
  10183. else if(node.attribute("value")=="false")
  10184. {
  10185. fixedUnit->setCheckState(Qt::Unchecked);
  10186. }
  10187. }
  10188. else if(node.attribute("name")=="fixedprecision")
  10189. {
  10190. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10191. }
  10192. else if(node.attribute("name")=="unit")
  10193. {
  10194. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10195. }
  10196. else if(node.attribute("name")=="unitaddress")
  10197. {
  10198. unitAddress->setValue(node.attribute("value").toInt());
  10199. }
  10200. else if(node.attribute("name")=="fvalue")
  10201. {
  10202. valueF->setValue(node.attribute("value").toInt());
  10203. }
  10204. else if(node.attribute("name")=="cvalue")
  10205. {
  10206. valueC->setValue(node.attribute("value").toInt());
  10207. }
  10208. else if(node.attribute("name")=="precisionaddress")
  10209. {
  10210. precisionAddress->setValue(node.attribute("value").toInt());
  10211. }
  10212. else if(node.attribute("name")=="precision")
  10213. {
  10214. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10215. }
  10216. }
  10217. updateStationNumber(stationNumber->value());
  10218. updateFixedUnit(fixedUnit->isChecked());
  10219. updateFixedDecimal(fixedPrecision->isChecked());
  10220. updateUnit(fixedUnitSelector->currentText());
  10221. updateUnitAddress(unitAddress->value());
  10222. updateValueF(valueF->value());
  10223. updateValueC(valueC->value());
  10224. updatePrecisionAddress(precisionAddress->value());
  10225. updatePrecisionValue(fixedPrecisionValue->value());
  10226. connect(stationNumber,SIGNAL(valueChanged(int)),
  10227. this,SLOT(updateStationNumber(int)));
  10228. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10229. this,SLOT(updateUnit(QString)));
  10230. connect(unitAddress,SIGNAL(valueChanged(int)),
  10231. this,SLOT(updateUnitAddress(int)));
  10232. connect(valueF,SIGNAL(valueChanged(int)),
  10233. this,SLOT(updateValueF(int)));
  10234. connect(valueC,SIGNAL(valueChanged(int)),
  10235. this,SLOT(updateValueC(int)));
  10236. connect(fixedUnit,SIGNAL(toggled(bool)),
  10237. this,SLOT(updateFixedUnit(bool)));
  10238. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10239. this,SLOT(updateFixedDecimal(bool)));
  10240. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10241. this,SLOT(updatePrecisionValue(int)));
  10242. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10243. this,SLOT(updatePrecisionAddress(int)));
  10244. setLayout(layout);
  10245. }
  10246. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10247. {
  10248. updateAttribute("station",QString("%1").arg(newStation));
  10249. }
  10250. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10251. {
  10252. if(newFixed)
  10253. {
  10254. unitSpecificationLayout->setCurrentIndex(0);
  10255. updateAttribute("fixedunit","true");
  10256. }
  10257. else
  10258. {
  10259. unitSpecificationLayout->setCurrentIndex(1);
  10260. updateAttribute("fixedunit","false");
  10261. }
  10262. }
  10263. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10264. {
  10265. if(newFixed)
  10266. {
  10267. decimalSpecificationLayout->setCurrentIndex(0);
  10268. updateAttribute("fixedprecision","true");
  10269. }
  10270. else
  10271. {
  10272. decimalSpecificationLayout->setCurrentIndex(1);
  10273. updateAttribute("fixedprecision","false");
  10274. }
  10275. }
  10276. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10277. {
  10278. updateAttribute("unit",newUnit);
  10279. }
  10280. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10281. {
  10282. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10283. }
  10284. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10285. {
  10286. updateAttribute("fvalue",QString("%1").arg(newValue));
  10287. }
  10288. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10289. {
  10290. updateAttribute("cvalue",QString("%1").arg(newValue));
  10291. }
  10292. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10293. {
  10294. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10295. }
  10296. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10297. {
  10298. updateAttribute("precision",QString("%1").arg(newValue));
  10299. }
  10300. /*:810*/
  10301. #line 594 "./typica.w"
  10302. /*812:*/
  10303. #line 17607 "./typica.w"
  10304. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10305. const QModelIndex&index)
  10306. :BasicDeviceConfigurationWidget(model,index)
  10307. {
  10308. QFormLayout*layout= new QFormLayout;
  10309. ShortHexSpinBox*address= new ShortHexSpinBox;
  10310. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10311. /*771:*/
  10312. #line 16333 "./typica.w"
  10313. QDomElement referenceElement=
  10314. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10315. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10316. QDomElement node;
  10317. /*:771*/
  10318. #line 17615 "./typica.w"
  10319. for(int i= 0;i<configData.size();i++)
  10320. {
  10321. node= configData.at(i).toElement();
  10322. if(node.attribute("name")=="address")
  10323. {
  10324. address->setValue(node.attribute("value").toInt());
  10325. break;
  10326. }
  10327. }
  10328. updateAddress(address->value());
  10329. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10330. setLayout(layout);
  10331. }
  10332. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10333. {
  10334. updateAttribute("address",QString("%1").arg(newAddress));
  10335. }
  10336. /*:812*/
  10337. #line 595 "./typica.w"
  10338. /*814:*/
  10339. #line 17663 "./typica.w"
  10340. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10341. const QModelIndex&index)
  10342. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10343. {
  10344. QVBoxLayout*layout= new QVBoxLayout;
  10345. QFormLayout*addressLayout= new QFormLayout;
  10346. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10347. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10348. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10349. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10350. layout->addLayout(addressLayout);
  10351. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10352. layout->addWidget(fixedRange);
  10353. QWidget*queriedRangePlaceholder= new QWidget(this);
  10354. QFormLayout*queriedRangeLayout= new QFormLayout;
  10355. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10356. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10357. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10358. lowerAddress);
  10359. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10360. upperAddress);
  10361. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10362. boundsLayout->addWidget(queriedRangePlaceholder);
  10363. QWidget*fixedRangePlaceholder= new QWidget(this);
  10364. QFormLayout*fixedRangeLayout= new QFormLayout;
  10365. QLineEdit*fixedLower= new QLineEdit;
  10366. QLineEdit*fixedUpper= new QLineEdit;
  10367. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10368. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10369. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10370. boundsLayout->addWidget(fixedRangePlaceholder);
  10371. layout->addLayout(boundsLayout);
  10372. /*771:*/
  10373. #line 16333 "./typica.w"
  10374. QDomElement referenceElement=
  10375. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10376. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10377. QDomElement node;
  10378. /*:771*/
  10379. #line 17696 "./typica.w"
  10380. for(int i= 0;i<configData.size();i++)
  10381. {
  10382. node= configData.at(i).toElement();
  10383. if(node.attribute("name")=="readaddress")
  10384. {
  10385. readAddress->setValue(node.attribute("value").toInt());
  10386. }
  10387. else if(node.attribute("name")=="writeaddress")
  10388. {
  10389. writeAddress->setValue(node.attribute("value").toInt());
  10390. }
  10391. else if(node.attribute("name")=="fixedrange")
  10392. {
  10393. if(node.attribute("value")=="true")
  10394. {
  10395. fixedRange->setCheckState(Qt::Checked);
  10396. }
  10397. else if(node.attribute("value")=="false")
  10398. {
  10399. fixedRange->setCheckState(Qt::Unchecked);
  10400. }
  10401. }
  10402. else if(node.attribute("name")=="fixedlower")
  10403. {
  10404. fixedLower->setText(node.attribute("value"));
  10405. }
  10406. else if(node.attribute("name")=="fixedupper")
  10407. {
  10408. fixedUpper->setText(node.attribute("value"));
  10409. }
  10410. else if(node.attribute("name")=="loweraddress")
  10411. {
  10412. lowerAddress->setValue(node.attribute("value").toInt());
  10413. }
  10414. else if(node.attribute("name")=="upperaddress")
  10415. {
  10416. upperAddress->setValue(node.attribute("value").toInt());
  10417. }
  10418. }
  10419. updateReadAddress(readAddress->value());
  10420. updateWriteAddress(writeAddress->value());
  10421. updateFixedRange(fixedRange->isChecked());
  10422. updateLower(fixedLower->text());
  10423. updateUpper(fixedUpper->text());
  10424. updateLowerAddress(lowerAddress->value());
  10425. updateUpperAddress(upperAddress->value());
  10426. connect(readAddress,SIGNAL(valueChanged(int)),
  10427. this,SLOT(updateReadAddress(int)));
  10428. connect(writeAddress,SIGNAL(valueChanged(int)),
  10429. this,SLOT(updateWriteAddress(int)));
  10430. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10431. connect(fixedLower,SIGNAL(textChanged(QString)),
  10432. this,SLOT(updateLower(QString)));
  10433. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10434. this,SLOT(updateUpper(QString)));
  10435. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10436. this,SLOT(updateLowerAddress(int)));
  10437. connect(upperAddress,SIGNAL(valueChanged(int)),
  10438. this,SLOT(updateUpperAddress(int)));
  10439. setLayout(layout);
  10440. }
  10441. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10442. {
  10443. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10444. }
  10445. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10446. {
  10447. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10448. }
  10449. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10450. {
  10451. if(fixed)
  10452. {
  10453. updateAttribute("fixedrange","true");
  10454. boundsLayout->setCurrentIndex(1);
  10455. }
  10456. else
  10457. {
  10458. updateAttribute("fixedrange","false");
  10459. boundsLayout->setCurrentIndex(0);
  10460. }
  10461. }
  10462. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10463. {
  10464. updateAttribute("fixedlower",lower);
  10465. }
  10466. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10467. {
  10468. updateAttribute("fixedupper",upper);
  10469. }
  10470. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10471. {
  10472. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10473. }
  10474. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10475. {
  10476. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10477. }
  10478. /*:814*/
  10479. #line 596 "./typica.w"
  10480. /*770:*/
  10481. #line 16203 "./typica.w"
  10482. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10483. :BasicDeviceConfigurationWidget(model,index)
  10484. {
  10485. QVBoxLayout*layout= new QVBoxLayout;
  10486. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10487. QMenu*deviceMenu= new QMenu;
  10488. NodeInserter*insertAction;
  10489. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10490. {
  10491. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10492. this,SLOT(insertChildNode(QString,QString)));
  10493. deviceMenu->addAction(insertAction);
  10494. }
  10495. addDeviceButton->setMenu(deviceMenu);
  10496. layout->addWidget(addDeviceButton);
  10497. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10498. QMenu*annotationMenu= new QMenu;
  10499. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10500. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10501. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10502. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10503. tr("Free Text"),
  10504. "freeannotation");
  10505. annotationMenu->addAction(basicButtonInserter);
  10506. annotationMenu->addAction(countingButtonInserter);
  10507. annotationMenu->addAction(spinBoxInserter);
  10508. annotationMenu->addAction(freeAnnotationInserter);
  10509. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10510. this,SLOT(insertChildNode(QString,QString)));
  10511. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10512. this,SLOT(insertChildNode(QString,QString)));
  10513. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10514. this,SLOT(insertChildNode(QString,QString)));
  10515. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10516. this,SLOT(insertChildNode(QString,QString)));
  10517. /*1033:*/
  10518. #line 144 "./valueannotation.w"
  10519. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10520. tr("Value Annotation"),
  10521. "valueannotation");
  10522. annotationMenu->addAction(valueAnnotationInserter);
  10523. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10524. this,SLOT(insertChildNode(QString,QString)));
  10525. /*:1033*/
  10526. #line 16239 "./typica.w"
  10527. addAnnotationControlButton->setMenu(annotationMenu);
  10528. layout->addWidget(addAnnotationControlButton);
  10529. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10530. QMenu*timersMenu= new QMenu;
  10531. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10532. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10533. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10534. timersMenu->addAction(coolingTimerInserter);
  10535. timersMenu->addAction(rangeTimerInserter);
  10536. timersMenu->addAction(multirangeTimerInserter);
  10537. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10538. this,SLOT(insertChildNode(QString,QString)));
  10539. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10540. this,SLOT(insertChildNode(QString,QString)));
  10541. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10542. this,SLOT(insertChildNode(QString,QString)));
  10543. timersButton->setMenu(timersMenu);
  10544. layout->addWidget(timersButton);
  10545. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10546. QMenu*advancedMenu= new QMenu;
  10547. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10548. advancedMenu->addAction(linearsplineinserter);
  10549. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10550. advancedMenu->addAction(translationinserter);
  10551. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10552. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10553. /*959:*/
  10554. #line 258 "./rate.w"
  10555. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10556. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10557. advancedMenu->addAction(rateOfChangeInserter);
  10558. /*:959*/
  10559. #line 16268 "./typica.w"
  10560. advancedButton->setMenu(advancedMenu);
  10561. layout->addWidget(advancedButton);
  10562. QHBoxLayout*idLayout= new QHBoxLayout;
  10563. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10564. idLayout->addWidget(idLabel);
  10565. QSpinBox*id= new QSpinBox;
  10566. idLayout->addWidget(id);
  10567. idLayout->addStretch();
  10568. layout->addLayout(idLayout);
  10569. QHBoxLayout*capacityLayout= new QHBoxLayout;
  10570. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  10571. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  10572. capacity->setMinimum(0.0);
  10573. capacity->setDecimals(3);
  10574. capacity->setMaximum(999999.999);
  10575. QComboBox*capacityUnit= new QComboBox;
  10576. capacityUnit->addItem("g");
  10577. capacityUnit->addItem("Kg");
  10578. capacityUnit->addItem("oz");
  10579. capacityUnit->addItem("Lb");
  10580. capacityUnit->setCurrentIndex(3);
  10581. capacityLayout->addWidget(capacityCheckEnabled);
  10582. capacityLayout->addWidget(capacity);
  10583. capacityLayout->addWidget(capacityUnit);
  10584. capacityLayout->addStretch();
  10585. layout->addLayout(capacityLayout);
  10586. layout->addStretch();
  10587. /*771:*/
  10588. #line 16333 "./typica.w"
  10589. QDomElement referenceElement=
  10590. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10591. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10592. QDomElement node;
  10593. /*:771*/
  10594. #line 16297 "./typica.w"
  10595. for(int i= 0;i<configData.size();i++)
  10596. {
  10597. node= configData.at(i).toElement();
  10598. if(node.attribute("name")=="databaseid")
  10599. {
  10600. id->setValue(node.attribute("value").toInt());
  10601. }
  10602. else if(node.attribute("name")=="checkcapacity")
  10603. {
  10604. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  10605. }
  10606. else if(node.attribute("name")=="capacity")
  10607. {
  10608. capacity->setValue(node.attribute("value").toDouble());
  10609. }
  10610. else if(node.attribute("name")=="capacityunit")
  10611. {
  10612. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  10613. }
  10614. }
  10615. updateRoasterId(id->value());
  10616. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10617. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  10618. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  10619. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  10620. setLayout(layout);
  10621. }
  10622. /*:770*//*772:*/
  10623. #line 16343 "./typica.w"
  10624. void RoasterConfWidget::updateRoasterId(int id)
  10625. {
  10626. updateAttribute("databaseid",QString("%1").arg(id));
  10627. }
  10628. void RoasterConfWidget::updateCapacityCheck(int value)
  10629. {
  10630. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  10631. }
  10632. void RoasterConfWidget::updateCapacity(const QString&value)
  10633. {
  10634. updateAttribute("capacity",value);
  10635. }
  10636. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  10637. {
  10638. updateAttribute("capacityunit",value);
  10639. }
  10640. /*:772*/
  10641. #line 597 "./typica.w"
  10642. /*818:*/
  10643. #line 17846 "./typica.w"
  10644. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10645. :BasicDeviceConfigurationWidget(model,index)
  10646. {
  10647. QFormLayout*layout= new QFormLayout;
  10648. QLineEdit*buttonTextEdit= new QLineEdit;
  10649. QLineEdit*annotationTextEdit= new QLineEdit;
  10650. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10651. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10652. /*771:*/
  10653. #line 16333 "./typica.w"
  10654. QDomElement referenceElement=
  10655. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10656. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10657. QDomElement node;
  10658. /*:771*/
  10659. #line 17855 "./typica.w"
  10660. for(int i= 0;i<configData.size();i++)
  10661. {
  10662. node= configData.at(i).toElement();
  10663. if(node.attribute("name")=="buttontext")
  10664. {
  10665. buttonTextEdit->setText(node.attribute("value"));
  10666. }
  10667. else if(node.attribute("name")=="annotationtext")
  10668. {
  10669. annotationTextEdit->setText(node.attribute("value"));
  10670. }
  10671. }
  10672. updateButtonText(buttonTextEdit->text());
  10673. updateAnnotationText(annotationTextEdit->text());
  10674. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10675. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10676. setLayout(layout);
  10677. }
  10678. /*:818*//*819:*/
  10679. #line 17877 "./typica.w"
  10680. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10681. {
  10682. updateAttribute("buttontext",text);
  10683. }
  10684. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10685. {
  10686. updateAttribute("annotationtext",text);
  10687. }
  10688. /*:819*//*822:*/
  10689. #line 17915 "./typica.w"
  10690. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10691. :BasicDeviceConfigurationWidget(model,index)
  10692. {
  10693. QFormLayout*layout= new QFormLayout;
  10694. QLineEdit*buttonTextEdit= new QLineEdit;
  10695. QLineEdit*annotationTextEdit= new QLineEdit;
  10696. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10697. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10698. /*771:*/
  10699. #line 16333 "./typica.w"
  10700. QDomElement referenceElement=
  10701. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10702. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10703. QDomElement node;
  10704. /*:771*/
  10705. #line 17924 "./typica.w"
  10706. for(int i= 0;i<configData.size();i++)
  10707. {
  10708. node= configData.at(i).toElement();
  10709. if(node.attribute("name")=="buttontext")
  10710. {
  10711. buttonTextEdit->setText(node.attribute("value"));
  10712. }
  10713. else if(node.attribute("name")=="annotationtext")
  10714. {
  10715. annotationTextEdit->setText(node.attribute("value"));
  10716. }
  10717. }
  10718. updateButtonText(buttonTextEdit->text());
  10719. updateAnnotationText(annotationTextEdit->text());
  10720. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10721. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10722. QTextEdit*documentation= new QTextEdit;
  10723. 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."));
  10724. documentation->setReadOnly(true);
  10725. layout->addRow("",documentation);
  10726. setLayout(layout);
  10727. }
  10728. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10729. {
  10730. updateAttribute("buttontext",text);
  10731. }
  10732. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10733. {
  10734. updateAttribute("annotationtext",text);
  10735. }
  10736. /*:822*/
  10737. #line 598 "./typica.w"
  10738. /*825:*/
  10739. #line 17992 "./typica.w"
  10740. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10741. :BasicDeviceConfigurationWidget(model,index)
  10742. {
  10743. QFormLayout*layout= new QFormLayout;
  10744. QLineEdit*labelEdit= new QLineEdit;
  10745. layout->addRow(tr("Control Label: "),labelEdit);
  10746. QLineEdit*minimumEdit= new QLineEdit;
  10747. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10748. QLineEdit*maximumEdit= new QLineEdit;
  10749. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10750. QSpinBox*precisionEdit= new QSpinBox;
  10751. precisionEdit->setMinimum(0);
  10752. precisionEdit->setMaximum(9);
  10753. layout->addRow(tr("Precision"),precisionEdit);
  10754. QLineEdit*pretext= new QLineEdit;
  10755. layout->addRow(tr("Prefix text"),pretext);
  10756. QLineEdit*posttext= new QLineEdit;
  10757. layout->addRow(tr("Suffix text"),posttext);
  10758. /*771:*/
  10759. #line 16333 "./typica.w"
  10760. QDomElement referenceElement=
  10761. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10762. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10763. QDomElement node;
  10764. /*:771*/
  10765. #line 18011 "./typica.w"
  10766. for(int i= 0;i<configData.size();i++)
  10767. {
  10768. node= configData.at(i).toElement();
  10769. if(node.attribute("name")=="label")
  10770. {
  10771. labelEdit->setText(node.attribute("value"));
  10772. }
  10773. else if(node.attribute("name")=="minimum")
  10774. {
  10775. minimumEdit->setText(node.attribute("value"));
  10776. }
  10777. else if(node.attribute("name")=="maximum")
  10778. {
  10779. maximumEdit->setText(node.attribute("value"));
  10780. }
  10781. else if(node.attribute("name")=="precision")
  10782. {
  10783. precisionEdit->setValue(node.attribute("value").toInt());
  10784. }
  10785. else if(node.attribute("name")=="pretext")
  10786. {
  10787. pretext->setText(node.attribute("value"));
  10788. }
  10789. else if(node.attribute("name")=="posttext")
  10790. {
  10791. posttext->setText(node.attribute("value"));
  10792. }
  10793. }
  10794. updateLabel(labelEdit->text());
  10795. updateMinimum(minimumEdit->text());
  10796. updateMaximum(maximumEdit->text());
  10797. updatePrecision(precisionEdit->value());
  10798. updatePretext(pretext->text());
  10799. updatePosttext(posttext->text());
  10800. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10801. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10802. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10803. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10804. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10805. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10806. setLayout(layout);
  10807. }
  10808. void NoteSpinConfWidget::updateLabel(const QString&text)
  10809. {
  10810. updateAttribute("label",text);
  10811. }
  10812. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10813. {
  10814. updateAttribute("minimum",minimum);
  10815. }
  10816. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10817. {
  10818. updateAttribute("maximum",maximum);
  10819. }
  10820. void NoteSpinConfWidget::updatePrecision(int precision)
  10821. {
  10822. updateAttribute("precision",QString("%1").arg(precision));
  10823. }
  10824. void NoteSpinConfWidget::updatePretext(const QString&text)
  10825. {
  10826. updateAttribute("pretext",text);
  10827. }
  10828. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10829. {
  10830. updateAttribute("posttext",text);
  10831. }
  10832. /*:825*/
  10833. #line 599 "./typica.w"
  10834. /*334:*/
  10835. #line 7545 "./typica.w"
  10836. LinearCalibrator::LinearCalibrator(QObject*parent):
  10837. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10838. {
  10839. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10840. }
  10841. /*:334*//*335:*/
  10842. #line 7559 "./typica.w"
  10843. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10844. {
  10845. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10846. if(clamp)
  10847. {
  10848. if(outval<Lo1)
  10849. {
  10850. outval= Lo1;
  10851. }
  10852. else if(outval> Up1)
  10853. {
  10854. outval= Up1;
  10855. }
  10856. }
  10857. if(sensitivitySetting>=0.05)
  10858. {
  10859. int temp= qRound(outval/sensitivitySetting);
  10860. outval= temp*sensitivitySetting;
  10861. }
  10862. Measurement adjusted(outval,measure.time(),measure.scale());
  10863. emit measurement(adjusted);
  10864. return adjusted;
  10865. }
  10866. /*:335*//*336:*/
  10867. #line 7586 "./typica.w"
  10868. double LinearCalibrator::measuredLower()
  10869. {
  10870. return Lo2;
  10871. }
  10872. double LinearCalibrator::measuredUpper()
  10873. {
  10874. return Up2;
  10875. }
  10876. double LinearCalibrator::mappedLower()
  10877. {
  10878. return Lo1;
  10879. }
  10880. double LinearCalibrator::mappedUpper()
  10881. {
  10882. return Up1;
  10883. }
  10884. bool LinearCalibrator::isClosedRange()
  10885. {
  10886. return clamp;
  10887. }
  10888. void LinearCalibrator::setMeasuredLower(double lower)
  10889. {
  10890. Lo2= lower;
  10891. }
  10892. void LinearCalibrator::setMeasuredUpper(double upper)
  10893. {
  10894. Up2= upper;
  10895. }
  10896. void LinearCalibrator::setMappedLower(double lower)
  10897. {
  10898. Lo1= lower;
  10899. }
  10900. void LinearCalibrator::setMappedUpper(double upper)
  10901. {
  10902. Up1= upper;
  10903. }
  10904. void LinearCalibrator::setClosedRange(bool closed)
  10905. {
  10906. clamp= closed;
  10907. }
  10908. void LinearCalibrator::setSensitivity(double sensitivity)
  10909. {
  10910. sensitivitySetting= sensitivity;
  10911. }
  10912. double LinearCalibrator::sensitivity()
  10913. {
  10914. return sensitivitySetting;
  10915. }
  10916. /*:336*/
  10917. #line 600 "./typica.w"
  10918. /*341:*/
  10919. #line 7719 "./typica.w"
  10920. void LinearSplineInterpolator::add_pair(double source,double destination)
  10921. {
  10922. pairs->insert(source,destination);
  10923. make_interpolators();
  10924. }
  10925. void LinearSplineInterpolator::make_interpolators()
  10926. {
  10927. if(pairs->size()> 1)
  10928. {
  10929. while(interpolators->size()> 0)
  10930. {
  10931. LinearCalibrator*removed= interpolators->takeFirst();
  10932. removed->deleteLater();
  10933. }
  10934. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10935. QMap<double,double> ::const_iterator j= i+1;
  10936. while(j!=pairs->constEnd())
  10937. {
  10938. LinearCalibrator*segment= new LinearCalibrator();
  10939. segment->setMeasuredLower(i.key());
  10940. segment->setMappedLower(i.value());
  10941. segment->setMeasuredUpper(j.key());
  10942. segment->setMappedUpper(j.value());
  10943. segment->setClosedRange(false);
  10944. interpolators->append(segment);
  10945. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10946. i++;
  10947. j++;
  10948. }
  10949. }
  10950. }
  10951. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  10952. QObject(parent),pairs(new QMap<double,double> ),
  10953. interpolators(new QList<LinearCalibrator*> )
  10954. {
  10955. }
  10956. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  10957. {
  10958. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10959. int index= -1;
  10960. while(i!=pairs->constEnd())
  10961. {
  10962. if(measure.temperature()<=i.key())
  10963. {
  10964. break;
  10965. }
  10966. i++;
  10967. index++;
  10968. }
  10969. if(index<0)
  10970. {
  10971. index= 0;
  10972. }
  10973. if(index>=interpolators->size())
  10974. {
  10975. index= interpolators->size()-1;
  10976. }
  10977. if(interpolators->at(index)!=NULL)
  10978. {
  10979. return interpolators->at(index)->newMeasurement(measure);
  10980. }
  10981. return Measurement();
  10982. }
  10983. /*:341*/
  10984. #line 601 "./typica.w"
  10985. /*924:*/
  10986. #line 19360 "./typica.w"
  10987. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10988. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  10989. {
  10990. QFormLayout*layout= new QFormLayout;
  10991. QLineEdit*source= new QLineEdit;
  10992. layout->addRow(tr("Source column name:"),source);
  10993. QLineEdit*destination= new QLineEdit;
  10994. layout->addRow(tr("Destination column name:"),destination);
  10995. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  10996. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  10997. QTableView*mappingTable= new QTableView;
  10998. mappingTable->setModel(tablemodel);
  10999. NumericDelegate*delegate= new NumericDelegate;
  11000. mappingTable->setItemDelegate(delegate);
  11001. layout->addRow(tr("Mapping data:"),mappingTable);
  11002. /*771:*/
  11003. #line 16333 "./typica.w"
  11004. QDomElement referenceElement=
  11005. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11006. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11007. QDomElement node;
  11008. /*:771*/
  11009. #line 19376 "./typica.w"
  11010. for(int i= 0;i<configData.size();i++)
  11011. {
  11012. node= configData.at(i).toElement();
  11013. if(node.attribute("name")=="source")
  11014. {
  11015. source->setText(node.attribute("value"));
  11016. }
  11017. else if(node.attribute("name")=="destination")
  11018. {
  11019. destination->setText(node.attribute("value"));
  11020. }
  11021. else if(node.attribute("name")=="sourcevalues")
  11022. {
  11023. /*925:*/
  11024. #line 19415 "./typica.w"
  11025. QString data= node.attribute("value");
  11026. if(data.length()> 3)
  11027. {
  11028. data.chop(2);
  11029. data= data.remove(0,2);
  11030. }
  11031. QStringList itemList= data.split(",");
  11032. /*:925*/
  11033. #line 19390 "./typica.w"
  11034. int column= 0;
  11035. /*926:*/
  11036. #line 19427 "./typica.w"
  11037. for(int j= 0;j<itemList.size();j++)
  11038. {
  11039. tablemodel->setData(tablemodel->index(j,column),
  11040. QVariant(itemList.at(j).toDouble()),
  11041. Qt::DisplayRole);
  11042. }
  11043. /*:926*/
  11044. #line 19392 "./typica.w"
  11045. }
  11046. else if(node.attribute("name")=="destinationvalues")
  11047. {
  11048. /*925:*/
  11049. #line 19415 "./typica.w"
  11050. QString data= node.attribute("value");
  11051. if(data.length()> 3)
  11052. {
  11053. data.chop(2);
  11054. data= data.remove(0,2);
  11055. }
  11056. QStringList itemList= data.split(",");
  11057. /*:925*/
  11058. #line 19397 "./typica.w"
  11059. int column= 1;
  11060. /*926:*/
  11061. #line 19427 "./typica.w"
  11062. for(int j= 0;j<itemList.size();j++)
  11063. {
  11064. tablemodel->setData(tablemodel->index(j,column),
  11065. QVariant(itemList.at(j).toDouble()),
  11066. Qt::DisplayRole);
  11067. }
  11068. /*:926*/
  11069. #line 19399 "./typica.w"
  11070. }
  11071. }
  11072. updateSourceColumn(source->text());
  11073. updateDestinationColumn(destination->text());
  11074. updateKnots();
  11075. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11076. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11077. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11078. setLayout(layout);
  11079. }
  11080. /*:924*//*927:*/
  11081. #line 19438 "./typica.w"
  11082. void LinearSplineInterpolationConfWidget::updateKnots()
  11083. {
  11084. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11085. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11086. }
  11087. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11088. {
  11089. updateAttribute("source",source);
  11090. }
  11091. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11092. {
  11093. updateAttribute("destination",dest);
  11094. }
  11095. /*:927*/
  11096. #line 602 "./typica.w"
  11097. /*944:*/
  11098. #line 19907 "./typica.w"
  11099. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11100. :BasicDeviceConfigurationWidget(model,index),
  11101. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  11102. {
  11103. unitSelector->addItem("Fahrenheit");
  11104. unitSelector->addItem("Celsius");
  11105. temperatureValue->setMinimum(0);
  11106. temperatureValue->setMaximum(1000);
  11107. QFormLayout*layout= new QFormLayout;
  11108. QLineEdit*column= new QLineEdit;
  11109. layout->addRow(tr("Column to match:"),column);
  11110. layout->addRow(tr("Unit:"),unitSelector);
  11111. layout->addRow(tr("Value:"),temperatureValue);
  11112. /*771:*/
  11113. #line 16333 "./typica.w"
  11114. QDomElement referenceElement=
  11115. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11116. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11117. QDomElement node;
  11118. /*:771*/
  11119. #line 19921 "./typica.w"
  11120. for(int i= 0;i<configData.size();i++)
  11121. {
  11122. node= configData.at(i).toElement();
  11123. if(node.attribute("name")=="column")
  11124. {
  11125. column->setText(node.attribute("value"));
  11126. }
  11127. else if(node.attribute("name")=="unit")
  11128. {
  11129. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11130. }
  11131. else if(node.attribute("name")=="value")
  11132. {
  11133. temperatureValue->setValue(node.attribute("value").toDouble());
  11134. }
  11135. }
  11136. updateMatchingColumn(column->text());
  11137. updateTemperature();
  11138. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11139. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11140. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11141. setLayout(layout);
  11142. }
  11143. /*:944*//*945:*/
  11144. #line 19950 "./typica.w"
  11145. void TranslationConfWidget::updateTemperature()
  11146. {
  11147. updateAttribute("unit",unitSelector->currentText());
  11148. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11149. if(unitSelector->currentText()=="Fahrenheit")
  11150. {
  11151. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11152. }
  11153. else
  11154. {
  11155. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11156. }
  11157. }
  11158. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11159. {
  11160. updateAttribute("column",column);
  11161. }
  11162. /*:945*/
  11163. #line 603 "./typica.w"
  11164. /*828:*/
  11165. #line 24 "./freeannotation.w"
  11166. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11167. const QModelIndex&index)
  11168. :BasicDeviceConfigurationWidget(model,index)
  11169. {
  11170. QFormLayout*layout= new QFormLayout;
  11171. QLineEdit*labelEdit= new QLineEdit;
  11172. layout->addRow(tr("Label Text:"),labelEdit);
  11173. /*771:*/
  11174. #line 16333 "./typica.w"
  11175. QDomElement referenceElement=
  11176. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11177. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11178. QDomElement node;
  11179. /*:771*/
  11180. #line 32 "./freeannotation.w"
  11181. for(int i= 0;i<configData.size();i++)
  11182. {
  11183. node= configData.at(i).toElement();
  11184. if(node.attribute("name")=="labeltext")
  11185. {
  11186. labelEdit->setText(node.attribute("value"));
  11187. }
  11188. }
  11189. updateLabel(labelEdit->text());
  11190. connect(labelEdit,SIGNAL(textEdited(QString)),
  11191. this,SLOT(updateLabel(QString)));
  11192. setLayout(layout);
  11193. }
  11194. /*:828*//*829:*/
  11195. #line 49 "./freeannotation.w"
  11196. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11197. {
  11198. updateAttribute("labeltext",text);
  11199. }
  11200. /*:829*/
  11201. #line 604 "./typica.w"
  11202. /*948:*/
  11203. #line 39 "./rate.w"
  11204. void RateOfChange::newMeasurement(Measurement measure)
  11205. {
  11206. cache.append(measure);
  11207. /*949:*/
  11208. #line 64 "./rate.w"
  11209. if(cache.size()> 2)
  11210. {
  11211. bool done= false;
  11212. while(!done)
  11213. {
  11214. if(cache.front().time().secsTo(cache.back().time())> ct)
  11215. {
  11216. cache.removeFirst();
  11217. }
  11218. else if(cache.back().time()<cache.front().time())
  11219. {
  11220. cache.removeFirst();
  11221. done= true;
  11222. }
  11223. else
  11224. {
  11225. done= true;
  11226. }
  11227. if(cache.size()<3)
  11228. {
  11229. done= true;
  11230. }
  11231. }
  11232. }
  11233. /*:949*/
  11234. #line 43 "./rate.w"
  11235. if(cache.size()>=2)
  11236. {
  11237. /*950:*/
  11238. #line 96 "./rate.w"
  11239. int N= cache.size();
  11240. double SXY= 0;
  11241. double SX= 0;
  11242. double SXX= 0;
  11243. double SY= 0;
  11244. double y;
  11245. double x;
  11246. for(int i= 0;i<N;i++)
  11247. {
  11248. y= cache.at(i).temperature();
  11249. SY+= y;
  11250. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11251. SX+= x;
  11252. SXX+= (x*x);
  11253. SXY+= (x*y);
  11254. }
  11255. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11256. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11257. value.insert("relative",true);
  11258. emit newData(value);
  11259. /*:950*/
  11260. #line 46 "./rate.w"
  11261. }
  11262. }
  11263. /*:948*//*951:*/
  11264. #line 120 "./rate.w"
  11265. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11266. {
  11267. setScaleTime(scaletime);
  11268. }
  11269. void RateOfChange::setCacheTime(int seconds)
  11270. {
  11271. ct= seconds;
  11272. }
  11273. void RateOfChange::setScaleTime(int seconds)
  11274. {
  11275. st= (seconds> 0?seconds:1);
  11276. }
  11277. /*:951*/
  11278. #line 605 "./typica.w"
  11279. /*832:*/
  11280. #line 26 "./settings.w"
  11281. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11282. {
  11283. QTabWidget*settingsTab= new QTabWidget;
  11284. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11285. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11286. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11287. settingsTab->addTab(graphSettings,tr("Graph"));
  11288. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11289. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11290. setCentralWidget(settingsTab);
  11291. }
  11292. /*:832*/
  11293. #line 606 "./typica.w"
  11294. /*837:*/
  11295. #line 27 "./graphsettings.w"
  11296. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11297. {
  11298. QTabWidget*graphCategories= new QTabWidget;
  11299. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11300. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11301. QVBoxLayout*layout= new QVBoxLayout;
  11302. layout->addWidget(graphCategories);
  11303. setLayout(layout);
  11304. }
  11305. /*:837*//*839:*/
  11306. #line 65 "./graphsettings.w"
  11307. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11308. colorEdit(new QLineEdit)
  11309. {
  11310. QSettings settings;
  11311. QVBoxLayout*layout= new QVBoxLayout;
  11312. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11313. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11314. updateEnableSetting(enable->isChecked());
  11315. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11316. layout->addWidget(enable);
  11317. QHBoxLayout*colorLayout= new QHBoxLayout;
  11318. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11319. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11320. updateColorSetting(colorEdit->text());
  11321. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11322. QToolButton*colorPickerButton= new QToolButton();
  11323. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11324. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11325. colorLayout->addWidget(colorLabel);
  11326. colorLayout->addWidget(colorEdit);
  11327. colorLayout->addWidget(colorPickerButton);
  11328. colorLayout->addStretch();
  11329. layout->addLayout(colorLayout);
  11330. QHBoxLayout*unitLayout= new QHBoxLayout;
  11331. QLabel*unitLabel= new QLabel(tr("Unit"));
  11332. QComboBox*unitSelector= new QComboBox;
  11333. unitSelector->addItem(tr("Fahrenheit"));
  11334. unitSelector->addItem(tr("Celsius"));
  11335. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11336. updateUnit(unitSelector->currentIndex());
  11337. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11338. unitLayout->addWidget(unitLabel);
  11339. unitLayout->addWidget(unitSelector);
  11340. unitLayout->addStretch();
  11341. layout->addLayout(unitLayout);
  11342. QHBoxLayout*axisLayout= new QHBoxLayout;
  11343. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11344. QLineEdit*axisEdit= new QLineEdit;
  11345. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11346. updateAxisSetting(axisEdit->text());
  11347. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11348. axisLayout->addWidget(axisLabel);
  11349. axisLayout->addWidget(axisEdit);
  11350. layout->addLayout(axisLayout);
  11351. layout->addStretch();
  11352. setLayout(layout);
  11353. }
  11354. /*:839*//*840:*/
  11355. #line 116 "./graphsettings.w"
  11356. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11357. {
  11358. QSettings settings;
  11359. settings.setValue("settings/graph/relative/enable",enabled);
  11360. }
  11361. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11362. {
  11363. QSettings settings;
  11364. settings.setValue("settings/graph/relative/color",color);
  11365. }
  11366. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11367. {
  11368. QSettings settings;
  11369. QString settingValue;
  11370. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11371. QStringList numbers;
  11372. foreach(QString text,points)
  11373. {
  11374. bool okay= false;
  11375. text.toDouble(&okay);
  11376. if(okay)
  11377. {
  11378. numbers.append(text);
  11379. }
  11380. }
  11381. numbers.removeDuplicates();
  11382. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11383. }
  11384. void GraphSettingsRelativeTab::updateUnit(int unit)
  11385. {
  11386. QSettings settings;
  11387. settings.setValue("settings/graph/relative/unit",unit);
  11388. }
  11389. /*:840*//*841:*/
  11390. #line 159 "./graphsettings.w"
  11391. void GraphSettingsRelativeTab::showColorPicker()
  11392. {
  11393. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11394. colorEdit->setText(color.name());
  11395. }
  11396. #line 62 "./settings.w"
  11397. #line 1 "./advancedsettings.w"
  11398. /*:841*/
  11399. #line 607 "./typica.w"
  11400. /*983:*/
  11401. #line 682 "./dataqsdk.w"
  11402. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11403. const QModelIndex&index)
  11404. :BasicDeviceConfigurationWidget(model,index),
  11405. deviceIdStack(new QStackedWidget)
  11406. {
  11407. QVBoxLayout*layout= new QVBoxLayout;
  11408. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11409. layout->addWidget(autoDetect);
  11410. QWidget*autoLayerWidget= new QWidget;
  11411. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11412. QLabel*autoLabel= new QLabel(tr("Device number"));
  11413. QSpinBox*autoNumber= new QSpinBox;
  11414. autoNumber->setMinimum(1);
  11415. autoNumber->setMaximum(99);
  11416. autoLayerLayout->addWidget(autoLabel);
  11417. autoLayerLayout->addWidget(autoNumber);
  11418. autoLayerWidget->setLayout(autoLayerLayout);
  11419. QWidget*fixedLayerWidget= new QWidget;
  11420. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11421. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11422. QComboBox*portSelection= new QComboBox;
  11423. portSelection->setEditable(true);
  11424. portSelection->addItems(DataqSdkDevice::detectHardware());
  11425. fixedLayerLayout->addWidget(fixedLabel);
  11426. fixedLayerLayout->addWidget(portSelection);
  11427. fixedLayerWidget->setLayout(fixedLayerLayout);
  11428. deviceIdStack->addWidget(autoLayerWidget);
  11429. deviceIdStack->addWidget(fixedLayerWidget);
  11430. layout->addWidget(deviceIdStack);
  11431. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11432. layout->addWidget(addChannelButton);
  11433. /*771:*/
  11434. #line 16333 "./typica.w"
  11435. QDomElement referenceElement=
  11436. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11437. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11438. QDomElement node;
  11439. /*:771*/
  11440. #line 714 "./dataqsdk.w"
  11441. for(int i= 0;i<configData.size();i++)
  11442. {
  11443. node= configData.at(i).toElement();
  11444. if(node.attribute("name")=="autoSelect")
  11445. {
  11446. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11447. }
  11448. else if(node.attribute("name")=="deviceNumber")
  11449. {
  11450. autoNumber->setValue(node.attribute("value").toInt());
  11451. }
  11452. else if(node.attribute("name")=="port")
  11453. {
  11454. int index= portSelection->findText(node.attribute("value"));
  11455. if(index> -1)
  11456. {
  11457. portSelection->setCurrentIndex(index);
  11458. }
  11459. else
  11460. {
  11461. portSelection->setEditText(node.attribute("value"));
  11462. }
  11463. }
  11464. }
  11465. updateAutoSelect(autoDetect->isChecked());
  11466. updateDeviceNumber(autoNumber->value());
  11467. updatePort(portSelection->currentText());
  11468. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11469. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11470. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11471. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11472. setLayout(layout);
  11473. }
  11474. /*:983*//*984:*/
  11475. #line 758 "./dataqsdk.w"
  11476. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11477. {
  11478. if(automatic)
  11479. {
  11480. updateAttribute("autoSelect","true");
  11481. deviceIdStack->setCurrentIndex(0);
  11482. }
  11483. else
  11484. {
  11485. updateAttribute("autoSelect","false");
  11486. deviceIdStack->setCurrentIndex(1);
  11487. }
  11488. }
  11489. /*:984*//*985:*/
  11490. #line 775 "./dataqsdk.w"
  11491. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11492. {
  11493. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11494. }
  11495. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11496. {
  11497. updateAttribute("port",portId);
  11498. }
  11499. /*:985*//*986:*/
  11500. #line 788 "./dataqsdk.w"
  11501. void DataqSdkDeviceConfWidget::addChannel()
  11502. {
  11503. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11504. }
  11505. /*:986*//*989:*/
  11506. #line 868 "./dataqsdk.w"
  11507. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11508. const QModelIndex&index)
  11509. :BasicDeviceConfigurationWidget(model,index),
  11510. startButton(new QPushButton(tr("Start"))),
  11511. resetButton(new QPushButton(tr("Reset"))),
  11512. stopButton(new QPushButton(tr("Stop"))),
  11513. calibrator(new LinearCalibrator),
  11514. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11515. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11516. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11517. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11518. rmCount(0),cmCount(0),
  11519. rmin(std::numeric_limits<double> ::max()),
  11520. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11521. cmin(std::numeric_limits<double> ::max()),
  11522. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11523. {
  11524. /*993:*/
  11525. #line 1107 "./dataqsdk.w"
  11526. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11527. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11528. QDomElement deviceNode;
  11529. QString configPort;
  11530. QString configAuto;
  11531. for(int i= 0;i<deviceConfigData.size();i++)
  11532. {
  11533. deviceNode= deviceConfigData.at(i).toElement();
  11534. if(deviceNode.attribute("name")=="autoSelect")
  11535. {
  11536. autoSelect= (deviceNode.attribute("value")=="true");
  11537. }
  11538. else if(deviceNode.attribute("name")=="deviceNumber")
  11539. {
  11540. configAuto= deviceNode.attribute("value");
  11541. }
  11542. else if(deviceNode.attribute("name")=="port")
  11543. {
  11544. configPort= deviceNode.attribute("value");
  11545. }
  11546. }
  11547. deviceID= autoSelect?configAuto:configPort;
  11548. channelOfInterest= index.row();
  11549. /*:993*/
  11550. #line 886 "./dataqsdk.w"
  11551. resetButton->setEnabled(false);
  11552. stopButton->setEnabled(false);
  11553. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11554. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11555. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11556. QVBoxLayout*layout= new QVBoxLayout;
  11557. QFormLayout*topLayout= new QFormLayout;
  11558. QLineEdit*columnEdit= new QLineEdit;
  11559. topLayout->addRow(tr("Column name"),columnEdit);
  11560. QComboBox*unitSelector= new QComboBox;
  11561. unitSelector->addItem(tr("Temperature"));
  11562. unitSelector->addItem(tr("Control"));
  11563. topLayout->addRow(tr("Measurement type"),unitSelector);
  11564. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11565. topLayout->addRow(smoothingBox);
  11566. layout->addLayout(topLayout);
  11567. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11568. topLayout->addRow(hideSeries);
  11569. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11570. layout->addWidget(calibrationLabel);
  11571. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11572. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11573. QLineEdit*measuredLowerEdit= new QLineEdit;
  11574. measuredLowerEdit->setText("0");
  11575. QLineEdit*measuredUpperEdit= new QLineEdit;
  11576. measuredUpperEdit->setText("10");
  11577. QLineEdit*mappedLowerEdit= new QLineEdit;
  11578. mappedLowerEdit->setText("0");
  11579. QLineEdit*mappedUpperEdit= new QLineEdit;
  11580. mappedUpperEdit->setText("10");
  11581. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11582. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11583. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11584. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11585. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11586. calibrationControlsLayout->addRow(closedBox);
  11587. QLineEdit*sensitivityEdit= new QLineEdit;
  11588. sensitivityEdit->setText("0");
  11589. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11590. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11591. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11592. deviceControlLayout->addWidget(startButton);
  11593. deviceControlLayout->addWidget(resetButton);
  11594. deviceControlLayout->addWidget(stopButton);
  11595. QFormLayout*indicatorLayout= new QFormLayout;
  11596. currentMeasurement->setReadOnly(true);
  11597. minimumMeasurement->setReadOnly(true);
  11598. maximumMeasurement->setReadOnly(true);
  11599. averageMeasurement->setReadOnly(true);
  11600. currentMapped->setReadOnly(true);
  11601. minimumMapped->setReadOnly(true);
  11602. maximumMapped->setReadOnly(true);
  11603. averageMapped->setReadOnly(true);
  11604. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11605. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11606. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11607. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11608. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11609. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11610. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11611. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11612. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11613. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11614. calibrationTestLayout->addLayout(deviceControlLayout);
  11615. calibrationTestLayout->addLayout(indicatorLayout);
  11616. calibrationLayout->addLayout(calibrationControlsLayout);
  11617. calibrationLayout->addLayout(calibrationTestLayout);
  11618. layout->addLayout(calibrationLayout);
  11619. /*771:*/
  11620. #line 16333 "./typica.w"
  11621. QDomElement referenceElement=
  11622. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11623. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11624. QDomElement node;
  11625. /*:771*/
  11626. #line 955 "./dataqsdk.w"
  11627. for(int i= 0;i<configData.size();i++)
  11628. {
  11629. node= configData.at(i).toElement();
  11630. if(node.attribute("name")=="column")
  11631. {
  11632. columnEdit->setText(node.attribute("value"));
  11633. }
  11634. else if(node.attribute("name")=="type")
  11635. {
  11636. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11637. }
  11638. else if(node.attribute("name")=="smoothing")
  11639. {
  11640. smoothingBox->setChecked(node.attribute("value")=="true");
  11641. }
  11642. else if(node.attribute("name")=="calibrationMeasuredLower")
  11643. {
  11644. measuredLowerEdit->setText(node.attribute("value"));
  11645. }
  11646. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11647. {
  11648. measuredUpperEdit->setText(node.attribute("value"));
  11649. }
  11650. else if(node.attribute("name")=="calibrationMappedLower")
  11651. {
  11652. mappedLowerEdit->setText(node.attribute("value"));
  11653. }
  11654. else if(node.attribute("name")=="calibrationMappedUpper")
  11655. {
  11656. mappedUpperEdit->setText(node.attribute("value"));
  11657. }
  11658. else if(node.attribute("name")=="calibrationClosedInterval")
  11659. {
  11660. closedBox->setChecked(node.attribute("value")=="true");
  11661. }
  11662. else if(node.attribute("name")=="calibrationSensitivity")
  11663. {
  11664. sensitivityEdit->setText(node.attribute("value"));
  11665. }
  11666. else if(node.attribute("name")=="hidden")
  11667. {
  11668. hideSeries->setChecked(node.attribute("value")=="true");
  11669. }
  11670. }
  11671. updateColumnName(columnEdit->text());
  11672. updateUnits(unitSelector->currentText());
  11673. updateSmoothingEnabled(smoothingBox->isChecked());
  11674. updateMeasuredLower(measuredLowerEdit->text());
  11675. updateMeasuredUpper(measuredUpperEdit->text());
  11676. updateMappedLower(mappedLowerEdit->text());
  11677. updateMappedUpper(mappedUpperEdit->text());
  11678. updateClosedInterval(closedBox->isChecked());
  11679. updateSensitivity(sensitivityEdit->text());
  11680. updateHidden(hideSeries->isChecked());
  11681. connect(columnEdit,SIGNAL(textChanged(QString)),
  11682. this,SLOT(updateColumnName(QString)));
  11683. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11684. this,SLOT(updateUnits(QString)));
  11685. connect(smoothingBox,SIGNAL(toggled(bool)),
  11686. this,SLOT(updateSmoothingEnabled(bool)));
  11687. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11688. this,SLOT(updateMeasuredLower(QString)));
  11689. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11690. this,SLOT(updateMappedLower(QString)));
  11691. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11692. this,SLOT(updateMeasuredUpper(QString)));
  11693. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11694. this,SLOT(updateMappedUpper(QString)));
  11695. connect(closedBox,SIGNAL(toggled(bool)),
  11696. this,SLOT(updateClosedInterval(bool)));
  11697. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11698. this,SLOT(updateSensitivity(QString)));
  11699. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11700. setLayout(layout);
  11701. }
  11702. /*:989*//*990:*/
  11703. #line 1038 "./dataqsdk.w"
  11704. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11705. {
  11706. updateAttribute("type",unit);
  11707. }
  11708. /*:990*//*991:*/
  11709. #line 1047 "./dataqsdk.w"
  11710. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11711. {
  11712. updateAttribute("calibrationMeasuredLower",value);
  11713. calibrator->setMeasuredLower(value.toDouble());
  11714. }
  11715. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11716. {
  11717. updateAttribute("calibrationMeasuredUpper",value);
  11718. calibrator->setMeasuredUpper(value.toDouble());
  11719. }
  11720. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11721. {
  11722. updateAttribute("calibrationMappedLower",value);
  11723. calibrator->setMappedLower(value.toDouble());
  11724. }
  11725. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11726. {
  11727. updateAttribute("calibrationMappedUpper",value);
  11728. calibrator->setMappedUpper(value.toDouble());
  11729. }
  11730. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11731. {
  11732. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11733. calibrator->setClosedRange(closed);
  11734. }
  11735. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11736. {
  11737. updateAttribute("smoothing",enabled?"true":"false");
  11738. }
  11739. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11740. {
  11741. updateAttribute("calibrationSensitivity",value);
  11742. calibrator->setSensitivity(value.toDouble());
  11743. }
  11744. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11745. {
  11746. updateAttribute("hidden",hidden?"true":"false");
  11747. }
  11748. /*:991*//*994:*/
  11749. #line 1136 "./dataqsdk.w"
  11750. void DataqSdkChannelConfWidget::startCalibration()
  11751. {
  11752. startButton->setEnabled(false);
  11753. stopButton->setEnabled(true);
  11754. resetButton->setEnabled(true);
  11755. calibrationDevice= new DataqSdkDevice(deviceID);
  11756. Channel*channel;
  11757. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11758. {
  11759. channel= calibrationDevice->newChannel(Units::Unitless);
  11760. }
  11761. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11762. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11763. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11764. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11765. calibrationDevice->start();
  11766. }
  11767. void DataqSdkChannelConfWidget::stopCalibration()
  11768. {
  11769. startButton->setEnabled(true);
  11770. stopButton->setEnabled(false);
  11771. resetButton->setEnabled(false);
  11772. calibrationDevice->deleteLater();
  11773. /*996:*/
  11774. #line 1181 "./dataqsdk.w"
  11775. rmCount= 0;
  11776. cmCount= 0;
  11777. rmin= std::numeric_limits<double> ::max();
  11778. rmax= std::numeric_limits<double> ::min();
  11779. rmean= 0;
  11780. cmin= std::numeric_limits<double> ::max();
  11781. cmax= std::numeric_limits<double> ::min();
  11782. cmean= 0;
  11783. /*:996*/
  11784. #line 1161 "./dataqsdk.w"
  11785. }
  11786. /*:994*//*995:*/
  11787. #line 1172 "./dataqsdk.w"
  11788. void DataqSdkChannelConfWidget::resetCalibration()
  11789. {
  11790. /*996:*/
  11791. #line 1181 "./dataqsdk.w"
  11792. rmCount= 0;
  11793. cmCount= 0;
  11794. rmin= std::numeric_limits<double> ::max();
  11795. rmax= std::numeric_limits<double> ::min();
  11796. rmean= 0;
  11797. cmin= std::numeric_limits<double> ::max();
  11798. cmax= std::numeric_limits<double> ::min();
  11799. cmean= 0;
  11800. /*:996*/
  11801. #line 1175 "./dataqsdk.w"
  11802. }
  11803. /*:995*//*997:*/
  11804. #line 1195 "./dataqsdk.w"
  11805. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11806. {
  11807. double nv= measure.temperature();
  11808. currentMeasurement->setText(QString("%1").arg(nv));
  11809. rmin= qMin(nv,rmin);
  11810. minimumMeasurement->setText(QString("%1").arg(rmin));
  11811. rmax= qMax(nv,rmax);
  11812. maximumMeasurement->setText(QString("%1").arg(rmax));
  11813. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11814. rmCount++;
  11815. averageMeasurement->setText(QString("%1").arg(rmean));
  11816. }
  11817. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11818. {
  11819. double nv= measure.temperature();
  11820. currentMapped->setText(QString("%1").arg(nv));
  11821. cmin= qMin(nv,cmin);
  11822. minimumMapped->setText(QString("%1").arg(cmin));
  11823. cmax= qMax(nv,cmax);
  11824. maximumMapped->setText(QString("%1").arg(cmax));
  11825. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11826. cmCount++;
  11827. averageMapped->setText(QString("%1").arg(cmean));
  11828. }
  11829. /*:997*//*998:*/
  11830. #line 1224 "./dataqsdk.w"
  11831. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11832. {
  11833. updateAttribute("column",value);
  11834. }
  11835. /*:998*/
  11836. #line 608 "./typica.w"
  11837. /*1022:*/
  11838. #line 393 "./scales.w"
  11839. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11840. const QModelIndex&index)
  11841. :BasicDeviceConfigurationWidget(model,index),
  11842. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11843. flow(new FlowSelector),stop(new StopSelector)
  11844. {
  11845. QFormLayout*layout= new QFormLayout;
  11846. layout->addRow(tr("Port:"),port);
  11847. connect(port,SIGNAL(currentIndexChanged(QString)),
  11848. this,SLOT(updatePort(QString)));
  11849. connect(port,SIGNAL(editTextChanged(QString)),
  11850. this,SLOT(updatePort(QString)));
  11851. layout->addRow(tr("Baud:"),baud);
  11852. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11853. this,SLOT(updateBaudRate(QString)));
  11854. layout->addRow(tr("Parity:"),parity);
  11855. connect(parity,SIGNAL(currentIndexChanged(int)),
  11856. this,SLOT(updateParity(int)));
  11857. layout->addRow(tr("Flow Control:"),flow);
  11858. connect(flow,SIGNAL(currentIndexChanged(int)),
  11859. this,SLOT(updateFlowControl(int)));
  11860. layout->addRow(tr("Stop Bits:"),stop);
  11861. connect(stop,SIGNAL(currentIndexChanged(int)),
  11862. this,SLOT(updateStopBits(int)));
  11863. /*771:*/
  11864. #line 16333 "./typica.w"
  11865. QDomElement referenceElement=
  11866. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11867. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11868. QDomElement node;
  11869. /*:771*/
  11870. #line 418 "./scales.w"
  11871. for(int i= 0;i<configData.size();i++)
  11872. {
  11873. node= configData.at(i).toElement();
  11874. if(node.attribute("name")=="port")
  11875. {
  11876. int j= port->findText(node.attribute("value"));
  11877. if(j>=0)
  11878. {
  11879. port->setCurrentIndex(j);
  11880. }
  11881. else
  11882. {
  11883. port->insertItem(0,node.attribute("value"));
  11884. port->setCurrentIndex(0);
  11885. }
  11886. }
  11887. else if(node.attribute("name")=="baudrate")
  11888. {
  11889. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11890. }
  11891. else if(node.attribute("name")=="parity")
  11892. {
  11893. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11894. }
  11895. else if(node.attribute("name")=="flowcontrol")
  11896. {
  11897. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  11898. }
  11899. else if(node.attribute("name")=="stopbits")
  11900. {
  11901. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  11902. }
  11903. }
  11904. updatePort(port->currentText());
  11905. updateBaudRate(baud->currentText());
  11906. updateParity(parity->currentIndex());
  11907. updateFlowControl(flow->currentIndex());
  11908. updateStopBits(stop->currentIndex());
  11909. setLayout(layout);
  11910. }
  11911. /*:1022*//*1023:*/
  11912. #line 462 "./scales.w"
  11913. void SerialScaleConfWidget::updatePort(const QString&newPort)
  11914. {
  11915. updateAttribute("port",newPort);
  11916. }
  11917. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  11918. {
  11919. updateAttribute("baudrate",rate);
  11920. }
  11921. void SerialScaleConfWidget::updateParity(int index)
  11922. {
  11923. updateAttribute("parity",parity->itemData(index).toString());
  11924. }
  11925. void SerialScaleConfWidget::updateFlowControl(int index)
  11926. {
  11927. updateAttribute("flowcontrol",flow->itemData(index).toString());
  11928. }
  11929. void SerialScaleConfWidget::updateStopBits(int index)
  11930. {
  11931. updateAttribute("stopbits",stop->itemData(index).toString());
  11932. }
  11933. /*:1023*/
  11934. #line 609 "./typica.w"
  11935. /*1035:*/
  11936. #line 195 "./valueannotation.w"
  11937. void ValueAnnotation::newMeasurement(Measurement measure)
  11938. {
  11939. for(int i= 0;i<values.size();i++)
  11940. {
  11941. if(measure.temperature()> values.at(i)-tolerance&&
  11942. measure.temperature()<values.at(i)+tolerance)
  11943. {
  11944. if(i!=lastIndex)
  11945. {
  11946. lastIndex= i;
  11947. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  11948. }
  11949. }
  11950. }
  11951. }
  11952. /*:1035*//*1036:*/
  11953. #line 216 "./valueannotation.w"
  11954. void ValueAnnotation::annotate()
  11955. {
  11956. if(lastIndex> -1)
  11957. {
  11958. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  11959. }
  11960. }
  11961. /*:1036*//*1037:*/
  11962. #line 228 "./valueannotation.w"
  11963. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  11964. {
  11965. values.append(value);
  11966. annotations.append(annotation);
  11967. }
  11968. /*:1037*//*1038:*/
  11969. #line 237 "./valueannotation.w"
  11970. void ValueAnnotation::setAnnotationColumn(int column)
  11971. {
  11972. annotationColumn= column;
  11973. }
  11974. void ValueAnnotation::setTemperatureColumn(int column)
  11975. {
  11976. measurementColumn= column;
  11977. }
  11978. void ValueAnnotation::setTolerance(double epsilon)
  11979. {
  11980. tolerance= epsilon;
  11981. }
  11982. /*:1038*//*1039:*/
  11983. #line 255 "./valueannotation.w"
  11984. ValueAnnotation::ValueAnnotation():QObject(),
  11985. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  11986. {
  11987. }
  11988. /*:1039*/
  11989. #line 610 "./typica.w"
  11990. /*1027:*/
  11991. #line 33 "./valueannotation.w"
  11992. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  11993. const QModelIndex&index)
  11994. :BasicDeviceConfigurationWidget(model,index),
  11995. tablemodel(new SaltModel(2))
  11996. {
  11997. QFormLayout*layout= new QFormLayout;
  11998. QLineEdit*source= new QLineEdit;
  11999. layout->addRow(tr("Source column name:"),source);
  12000. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12001. noteOnStart->setChecked(true);
  12002. layout->addRow(noteOnStart);
  12003. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12004. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12005. QTableView*annotationTable= new QTableView;
  12006. annotationTable->setModel(tablemodel);
  12007. NumericDelegate*delegate= new NumericDelegate;
  12008. annotationTable->setItemDelegateForColumn(0,delegate);
  12009. layout->addRow(tr("Annotations for values:"),annotationTable);
  12010. /*771:*/
  12011. #line 16333 "./typica.w"
  12012. QDomElement referenceElement=
  12013. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12014. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12015. QDomElement node;
  12016. /*:771*/
  12017. #line 52 "./valueannotation.w"
  12018. for(int i= 0;i<configData.size();i++)
  12019. {
  12020. node= configData.at(i).toElement();
  12021. if(node.attribute("name")=="source")
  12022. {
  12023. source->setText(node.attribute("value"));
  12024. }
  12025. else if(node.attribute("name")=="emitOnStart")
  12026. {
  12027. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12028. }
  12029. else if(node.attribute("name")=="measuredValues")
  12030. {
  12031. /*925:*/
  12032. #line 19415 "./typica.w"
  12033. QString data= node.attribute("value");
  12034. if(data.length()> 3)
  12035. {
  12036. data.chop(2);
  12037. data= data.remove(0,2);
  12038. }
  12039. QStringList itemList= data.split(",");
  12040. /*:925*/
  12041. #line 66 "./valueannotation.w"
  12042. int column= 0;
  12043. /*926:*/
  12044. #line 19427 "./typica.w"
  12045. for(int j= 0;j<itemList.size();j++)
  12046. {
  12047. tablemodel->setData(tablemodel->index(j,column),
  12048. QVariant(itemList.at(j).toDouble()),
  12049. Qt::DisplayRole);
  12050. }
  12051. /*:926*/
  12052. #line 68 "./valueannotation.w"
  12053. }
  12054. else if(node.attribute("name")=="annotations")
  12055. {
  12056. /*1028:*/
  12057. #line 89 "./valueannotation.w"
  12058. QString data= node.attribute("value");
  12059. if(data.length()> 3)
  12060. {
  12061. data.chop(2);
  12062. data= data.remove(0,2);
  12063. }
  12064. QStringList itemList= data.split(",");
  12065. for(int i= 0;i<itemList.size();i++)
  12066. {
  12067. itemList[i]= itemList[i].simplified();
  12068. }
  12069. /*:1028*/
  12070. #line 72 "./valueannotation.w"
  12071. int column= 1;
  12072. /*1029:*/
  12073. #line 104 "./valueannotation.w"
  12074. for(int i= 0;i<itemList.size();i++)
  12075. {
  12076. tablemodel->setData(tablemodel->index(i,column),
  12077. QVariant(itemList.at(i)),
  12078. Qt::DisplayRole);
  12079. }
  12080. /*:1029*/
  12081. #line 74 "./valueannotation.w"
  12082. }
  12083. }
  12084. updateSourceColumn(source->text());
  12085. updateStart(noteOnStart->isChecked());
  12086. updateAnnotations();
  12087. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12088. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12089. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12090. setLayout(layout);
  12091. }
  12092. /*:1027*//*1030:*/
  12093. #line 115 "./valueannotation.w"
  12094. void ValueAnnotationConfWidget::updateAnnotations()
  12095. {
  12096. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12097. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12098. }
  12099. /*:1030*//*1031:*/
  12100. #line 125 "./valueannotation.w"
  12101. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12102. {
  12103. updateAttribute("source",source);
  12104. }
  12105. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12106. {
  12107. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12108. }
  12109. /*:1031*/
  12110. #line 611 "./typica.w"
  12111. /*:4*//*250:*/
  12112. #line 5951 "./typica.w"
  12113. /*247:*/
  12114. #line 5914 "./typica.w"
  12115. void ScriptValidator::fixup(QString&input)const
  12116. {
  12117. QScriptEngine*engine= AppInstance->engine;
  12118. engine->pushContext();
  12119. input= engine->evaluate(input).toString();
  12120. engine->popContext();
  12121. }
  12122. /*:247*//*248:*/
  12123. #line 5927 "./typica.w"
  12124. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  12125. {
  12126. if(v)
  12127. {
  12128. if(v->validate(input,pos)==QValidator::Acceptable)
  12129. {
  12130. return QValidator::Acceptable;
  12131. }
  12132. }
  12133. return QValidator::Intermediate;
  12134. }
  12135. /*:248*//*249:*/
  12136. #line 5942 "./typica.w"
  12137. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  12138. :QValidator(parent),v(validator)
  12139. {
  12140. }
  12141. /*:249*/
  12142. #line 5952 "./typica.w"
  12143. /*:250*//*845:*/
  12144. #line 60 "./advancedsettings.w"
  12145. /*843:*/
  12146. #line 26 "./advancedsettings.w"
  12147. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  12148. {
  12149. QSettings settings;
  12150. QFormLayout*layout= new QFormLayout;
  12151. QCheckBox*logDiagnostics= new QCheckBox;
  12152. logDiagnostics->setCheckState(
  12153. settings.value("settings/advanced/logging",false).toBool()?
  12154. Qt::Checked:Qt::Unchecked);
  12155. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  12156. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  12157. setLayout(layout);
  12158. }
  12159. /*:843*//*844:*/
  12160. #line 43 "./advancedsettings.w"
  12161. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  12162. {
  12163. QSettings settings;
  12164. settings.setValue("settings/advanced/logging",enabled);
  12165. if(enabled)
  12166. {
  12167. qInstallMsgHandler(messageFileOutput);
  12168. }
  12169. else
  12170. {
  12171. qInstallMsgHandler(0);
  12172. }
  12173. }
  12174. /*:844*/
  12175. #line 61 "./advancedsettings.w"
  12176. #line 18093 "./typica.w"
  12177. /*:845*//*892:*/
  12178. #line 639 "./unsupportedserial.w"
  12179. /*867:*/
  12180. #line 58 "./unsupportedserial.w"
  12181. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  12182. const QModelIndex&index)
  12183. :BasicDeviceConfigurationWidget(model,index),
  12184. deviceSettingsModel(new SaltModel(2)),
  12185. scriptEditor(new QTextEdit)
  12186. {
  12187. scriptEditor->setTabStopWidth(20);
  12188. QVBoxLayout*dummyLayout= new QVBoxLayout;
  12189. QTabWidget*central= new QTabWidget;
  12190. QWidget*deviceConfigurationWidget= new QWidget;
  12191. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  12192. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12193. deviceConfigurationLayout->addWidget(addChannelButton);
  12194. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12195. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  12196. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  12197. QTableView*deviceSettingsView= new QTableView;
  12198. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  12199. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  12200. deviceSettingsView->setModel(deviceSettingsModel);
  12201. deviceConfigurationLayout->addWidget(deviceSettingsView);
  12202. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  12203. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  12204. central->addTab(scriptEditor,tr("Script"));
  12205. dummyLayout->addWidget(central);
  12206. /*771:*/
  12207. #line 16333 "./typica.w"
  12208. QDomElement referenceElement=
  12209. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12210. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12211. QDomElement node;
  12212. /*:771*/
  12213. #line 86 "./unsupportedserial.w"
  12214. for(int i= 0;i<configData.size();i++)
  12215. {
  12216. node= configData.at(i).toElement();
  12217. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12218. {
  12219. int column= 0;
  12220. if(node.attribute("name")=="values")
  12221. {
  12222. column= 1;
  12223. }
  12224. QString data= node.attribute("value");
  12225. if(data.length()> 3)
  12226. {
  12227. data.chop(2);
  12228. data= data.remove(0,2);
  12229. }
  12230. QStringList keyList= data.split(", ");
  12231. for(int j= 0;j<keyList.size();j++)
  12232. {
  12233. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12234. QVariant(keyList.at(j)),
  12235. Qt::EditRole);
  12236. }
  12237. }
  12238. else if(node.attribute("name")=="script")
  12239. {
  12240. scriptEditor->setPlainText(node.attribute("value"));
  12241. }
  12242. }
  12243. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12244. this,SLOT(updateConfiguration()));
  12245. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  12246. setLayout(dummyLayout);
  12247. }
  12248. /*:867*//*868:*/
  12249. #line 131 "./unsupportedserial.w"
  12250. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  12251. {
  12252. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12253. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12254. }
  12255. /*:868*//*869:*/
  12256. #line 144 "./unsupportedserial.w"
  12257. void UnsupportedSerialDeviceConfWidget::saveScript()
  12258. {
  12259. updateAttribute("script",scriptEditor->toPlainText());
  12260. }
  12261. /*:869*//*870:*/
  12262. #line 155 "./unsupportedserial.w"
  12263. void UnsupportedSerialDeviceConfWidget::addChannel()
  12264. {
  12265. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  12266. }
  12267. /*:870*//*872:*/
  12268. #line 183 "./unsupportedserial.w"
  12269. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  12270. const QModelIndex&index)
  12271. :BasicDeviceConfigurationWidget(model,index),
  12272. channelSettingsModel(new SaltModel(2))
  12273. {
  12274. QFormLayout*layout= new QFormLayout;
  12275. QLineEdit*columnName= new QLineEdit;
  12276. layout->addRow(tr("Column Name:"),columnName);
  12277. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12278. layout->addRow(hideSeries);
  12279. QTableView*channelSettings= new QTableView;
  12280. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  12281. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  12282. channelSettings->setModel(channelSettingsModel);
  12283. layout->addRow(channelSettings);
  12284. setLayout(layout);
  12285. /*771:*/
  12286. #line 16333 "./typica.w"
  12287. QDomElement referenceElement=
  12288. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12289. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12290. QDomElement node;
  12291. /*:771*/
  12292. #line 200 "./unsupportedserial.w"
  12293. for(int i= 0;i<configData.size();i++)
  12294. {
  12295. node= configData.at(i).toElement();
  12296. if(node.attribute("name")=="columnname")
  12297. {
  12298. columnName->setText(node.attribute("value"));
  12299. }
  12300. else if(node.attribute("name")=="hidden")
  12301. {
  12302. hideSeries->setChecked(node.attribute("value")=="true");
  12303. }
  12304. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12305. {
  12306. int column= 0;
  12307. if(node.attribute("name")=="values")
  12308. {
  12309. column= 1;
  12310. }
  12311. QString data= node.attribute("value");
  12312. if(data.length()> 3)
  12313. {
  12314. data.chop(2);
  12315. data= data.remove(0,2);
  12316. }
  12317. QStringList keyList= data.split(", ");
  12318. for(int j= 0;j<keyList.size();j++)
  12319. {
  12320. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  12321. QVariant(keyList.at(j)),
  12322. Qt::EditRole);
  12323. }
  12324. }
  12325. }
  12326. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12327. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12328. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12329. this,SLOT(updateConfiguration()));
  12330. }
  12331. /*:872*//*873:*/
  12332. #line 244 "./unsupportedserial.w"
  12333. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  12334. {
  12335. updateAttribute("columnname",value);
  12336. }
  12337. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  12338. {
  12339. updateAttribute("hidden",hidden?"true":"false");
  12340. }
  12341. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  12342. {
  12343. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12344. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12345. }
  12346. /*:873*/
  12347. #line 640 "./unsupportedserial.w"
  12348. /*880:*/
  12349. #line 371 "./unsupportedserial.w"
  12350. void JavaScriptDevice::start()
  12351. {
  12352. QScriptValue object= scriptengine->newQObject(this);
  12353. /*881:*/
  12354. #line 390 "./unsupportedserial.w"
  12355. QScriptValue settingsObject= scriptengine->newObject();
  12356. QVariantMap::const_iterator i= deviceSettings.constBegin();
  12357. while(i!=deviceSettings.constEnd())
  12358. {
  12359. settingsObject.setProperty(i.key(),i.value().toString());
  12360. i++;
  12361. }
  12362. object.setProperty("settings",settingsObject);
  12363. /*:881*/
  12364. #line 375 "./unsupportedserial.w"
  12365. /*882:*/
  12366. #line 405 "./unsupportedserial.w"
  12367. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  12368. for(int i= 0;i<channelCount();i++)
  12369. {
  12370. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  12371. QScriptValue channelSettingsObject= scriptengine->newObject();
  12372. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  12373. while(j!=channelSettings.at(i).constEnd())
  12374. {
  12375. channelSettingsObject.setProperty(j.key(),j.value().toString());
  12376. j++;
  12377. }
  12378. channelObject.setProperty("settings",channelSettingsObject);
  12379. channelsArray.setProperty(i,channelObject);
  12380. }
  12381. object.setProperty("channels",channelsArray);
  12382. /*:882*/
  12383. #line 376 "./unsupportedserial.w"
  12384. QScriptContext*context= scriptengine->currentContext();
  12385. QScriptValue oldThis= context->thisObject();
  12386. context->setThisObject(object);
  12387. QScriptValue result= scriptengine->evaluate(deviceScript);
  12388. QScriptEngine*engine= scriptengine;
  12389. /*192:*/
  12390. #line 4445 "./typica.w"
  12391. if(engine->hasUncaughtException())
  12392. {
  12393. int line= engine->uncaughtExceptionLineNumber();
  12394. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  12395. result.toString();
  12396. QString trace;
  12397. foreach(trace,engine->uncaughtExceptionBacktrace())
  12398. {
  12399. qDebug()<<trace;
  12400. }
  12401. }
  12402. /*:192*/
  12403. #line 382 "./unsupportedserial.w"
  12404. context->setThisObject(oldThis);
  12405. }
  12406. /*:880*//*885:*/
  12407. #line 446 "./unsupportedserial.w"
  12408. void JavaScriptDevice::stop()
  12409. {
  12410. emit deviceStopRequested();
  12411. }
  12412. /*:885*//*886:*/
  12413. #line 459 "./unsupportedserial.w"
  12414. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  12415. QScriptEngine*engine):
  12416. QObject(NULL),scriptengine(engine)
  12417. {
  12418. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12419. QDomElement deviceReferenceElement=
  12420. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12421. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12422. QDomElement node;
  12423. QStringList deviceKeys;
  12424. QStringList deviceValues;
  12425. for(int i= 0;i<deviceConfigData.size();i++)
  12426. {
  12427. node= deviceConfigData.at(i).toElement();
  12428. if(node.attribute("name")=="keys")
  12429. {
  12430. QString data= node.attribute("value");
  12431. if(data.length()> 3)
  12432. {
  12433. data.chop(2);
  12434. data= data.remove(0,2);
  12435. }
  12436. deviceKeys= data.split(", ");
  12437. }
  12438. else if(node.attribute("name")=="values")
  12439. {
  12440. QString data= node.attribute("value");
  12441. if(data.length()> 3)
  12442. {
  12443. data.chop(2);
  12444. data= data.remove(0,2);
  12445. }
  12446. deviceValues= data.split(", ");
  12447. }
  12448. else if(node.attribute("name")=="script")
  12449. {
  12450. deviceScript= node.attribute("value");
  12451. }
  12452. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  12453. }
  12454. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  12455. {
  12456. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  12457. }
  12458. if(model->hasChildren(index))
  12459. {
  12460. for(int i= 0;i<model->rowCount(index);i++)
  12461. {
  12462. QModelIndex channelIndex= model->index(i,0,index);
  12463. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12464. channelList.append(new Channel);
  12465. QDomElement channelReferenceElement=
  12466. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12467. QDomNodeList channelConfigData=
  12468. channelReferenceElement.elementsByTagName("attribute");
  12469. QStringList channelKeys;
  12470. QStringList channelValues;
  12471. for(int j= 0;j<channelConfigData.size();j++)
  12472. {
  12473. node= channelConfigData.at(j).toElement();
  12474. if(node.attribute("name")=="keys")
  12475. {
  12476. QString data= node.attribute("value");
  12477. if(data.length()> 3)
  12478. {
  12479. data.chop(2);
  12480. data= data.remove(0,2);
  12481. }
  12482. channelKeys= data.split(", ");
  12483. }
  12484. else if(node.attribute("name")=="values")
  12485. {
  12486. QString data= node.attribute("value");
  12487. if(data.length()> 3)
  12488. {
  12489. data.chop(2);
  12490. data= data.remove(0,2);
  12491. }
  12492. channelValues= data.split(", ");
  12493. }
  12494. else if(node.attribute("name")=="hidden")
  12495. {
  12496. hiddenState.append(node.attribute("value")=="true");
  12497. }
  12498. else if(node.attribute("name")=="columnname")
  12499. {
  12500. columnNames.append(node.attribute("value"));
  12501. }
  12502. }
  12503. QVariantMap cs;
  12504. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  12505. {
  12506. cs.insert(channelKeys[j],channelValues[j]);
  12507. }
  12508. channelSettings.append(cs);
  12509. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12510. channelUnits.append(Units::Fahrenheit);
  12511. }
  12512. }
  12513. }
  12514. /*:886*//*887:*/
  12515. #line 564 "./unsupportedserial.w"
  12516. int JavaScriptDevice::channelCount()
  12517. {
  12518. return channelList.length();
  12519. }
  12520. Channel*JavaScriptDevice::getChannel(int channel)
  12521. {
  12522. return channelList.at(channel);
  12523. }
  12524. bool JavaScriptDevice::isChannelHidden(int channel)
  12525. {
  12526. return hiddenState.at(channel);
  12527. }
  12528. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  12529. {
  12530. return channelUnits.at(channel);
  12531. }
  12532. QString JavaScriptDevice::channelColumnName(int channel)
  12533. {
  12534. if(channel>=0&&channel<columnNames.length())
  12535. {
  12536. return columnNames.at(channel);
  12537. }
  12538. return QString();
  12539. }
  12540. QString JavaScriptDevice::channelIndicatorText(int channel)
  12541. {
  12542. return indicatorTexts.at(channel);
  12543. }
  12544. /*:887*//*888:*/
  12545. #line 601 "./unsupportedserial.w"
  12546. void JavaScriptDevice::setTemperatureColumn(int tcol)
  12547. {
  12548. annotationTemperatureColumn= tcol;
  12549. }
  12550. void JavaScriptDevice::setAnnotationColumn(int ncol)
  12551. {
  12552. annotationNoteColumn= ncol;
  12553. }
  12554. /*:888*/
  12555. #line 641 "./unsupportedserial.w"
  12556. /*:892*//*918:*/
  12557. #line 444 "./phidgets.w"
  12558. /*902:*/
  12559. #line 31 "./phidgets.w"
  12560. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  12561. const QModelIndex&index)
  12562. :BasicDeviceConfigurationWidget(model,index)
  12563. {
  12564. QFormLayout*layout= new QFormLayout;
  12565. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12566. QSpinBox*sampleRate= new QSpinBox;
  12567. sampleRate->setMinimum(40);
  12568. sampleRate->setMaximum(600);
  12569. sampleRate->setSingleStep(40);
  12570. sampleRate->setValue(360);
  12571. /*771:*/
  12572. #line 16333 "./typica.w"
  12573. QDomElement referenceElement=
  12574. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12575. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12576. QDomElement node;
  12577. /*:771*/
  12578. #line 44 "./phidgets.w"
  12579. for(int i= 0;i<configData.size();i++)
  12580. {
  12581. node= configData.at(i).toElement();
  12582. if(node.attribute("name")=="sampleRate")
  12583. {
  12584. sampleRate->setValue(node.attribute("value").toInt());
  12585. }
  12586. }
  12587. updateRate(sampleRate->value());
  12588. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  12589. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12590. layout->addRow(addChannelButton);
  12591. layout->addRow(tr("Sample rate:"),sampleRate);
  12592. setLayout(layout);
  12593. }
  12594. /*:902*//*903:*/
  12595. #line 66 "./phidgets.w"
  12596. void PhidgetsTemperatureSensorConfWidget::addChannel()
  12597. {
  12598. insertChildNode(tr("Channel"),"phidgets1048channel");
  12599. }
  12600. /*:903*//*904:*/
  12601. #line 74 "./phidgets.w"
  12602. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  12603. {
  12604. updateAttribute("sampleRate",QString("%1").arg(ms));
  12605. }
  12606. /*:904*//*906:*/
  12607. #line 103 "./phidgets.w"
  12608. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  12609. DeviceTreeModel*model,const QModelIndex&index)
  12610. :BasicDeviceConfigurationWidget(model,index),
  12611. tcType(new QComboBox)
  12612. {
  12613. QFormLayout*layout= new QFormLayout;
  12614. QLineEdit*columnName= new QLineEdit;
  12615. layout->addRow(tr("Column Name:"),columnName);
  12616. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12617. layout->addRow(hideSeries);
  12618. layout->addRow(tr("Thermocouple Type:"),tcType);
  12619. tcType->addItem("Type K","1");
  12620. tcType->addItem("Type J","2");
  12621. tcType->addItem("Type E","3");
  12622. tcType->addItem("Type T","4");
  12623. QSpinBox*channel= new QSpinBox;
  12624. layout->addRow(tr("Channel:"),channel);
  12625. channel->setMinimum(0);
  12626. channel->setMaximum(3);
  12627. setLayout(layout);
  12628. /*771:*/
  12629. #line 16333 "./typica.w"
  12630. QDomElement referenceElement=
  12631. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12632. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12633. QDomElement node;
  12634. /*:771*/
  12635. #line 124 "./phidgets.w"
  12636. for(int i= 0;i<configData.size();i++)
  12637. {
  12638. node= configData.at(i).toElement();
  12639. if(node.attribute("name")=="columnname")
  12640. {
  12641. columnName->setText(node.attribute("value"));
  12642. }
  12643. else if(node.attribute("name")=="hidden")
  12644. {
  12645. hideSeries->setChecked(node.attribute("value")=="true");
  12646. }
  12647. else if(node.attribute("name")=="tctype")
  12648. {
  12649. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  12650. }
  12651. else if(node.attribute("name")=="channel")
  12652. {
  12653. channel->setValue(node.attribute("value").toInt());
  12654. }
  12655. }
  12656. updateColumnName(columnName->text());
  12657. updateHidden(hideSeries->isChecked());
  12658. updateTC(tcType->currentIndex());
  12659. updateChannel(channel->value());
  12660. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12661. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12662. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  12663. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  12664. }
  12665. /*:906*//*907:*/
  12666. #line 157 "./phidgets.w"
  12667. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  12668. {
  12669. updateAttribute("columnname",value);
  12670. }
  12671. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  12672. {
  12673. updateAttribute("hidden",hidden?"true":"false");
  12674. }
  12675. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  12676. {
  12677. updateAttribute("tctype",tcType->itemData(index).toString());
  12678. }
  12679. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  12680. {
  12681. updateAttribute("channel",QString("%1").arg(channel));
  12682. }
  12683. /*:907*//*911:*/
  12684. #line 246 "./phidgets.w"
  12685. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  12686. :QObject(NULL),driver("phidget21"),device(NULL)
  12687. {
  12688. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12689. QDomElement deviceReferenceElement=
  12690. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12691. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12692. QDomElement node;
  12693. for(int i= 0;i<deviceConfigData.size();i++)
  12694. {
  12695. node= deviceConfigData.at(i).toElement();
  12696. if(node.attribute("name")=="sampleRate")
  12697. {
  12698. sampleTimer.setInterval(node.attribute("value").toInt());
  12699. }
  12700. }
  12701. if(model->hasChildren(index))
  12702. {
  12703. for(int i= 0;i<model->rowCount(index);i++)
  12704. {
  12705. QModelIndex channelIndex= model->index(i,0,index);
  12706. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12707. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12708. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  12709. for(int j= 0;j<channelConfigData.size();j++)
  12710. {
  12711. node= channelConfigData.at(j).toElement();
  12712. if(node.attribute("name")=="channel")
  12713. {
  12714. int channelID= node.attribute("value").toInt();
  12715. channelIndices.append(channelID);
  12716. Channel*channel= new Channel;
  12717. channelList.append(channel);
  12718. channelMap.insert(channelID,channel);
  12719. }
  12720. else if(node.attribute("name")=="hidden")
  12721. {
  12722. hiddenState.append(node.attribute("value")=="true");
  12723. }
  12724. else if(node.attribute("name")=="columnname")
  12725. {
  12726. columnNames.append(node.attribute("value"));
  12727. }
  12728. else if(node.attribute("name")=="tctype")
  12729. {
  12730. tctypes.append(node.attribute("value").toInt());
  12731. }
  12732. }
  12733. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12734. }
  12735. }
  12736. }
  12737. /*:911*//*912:*/
  12738. #line 306 "./phidgets.w"
  12739. int PhidgetsTemperatureSensor::channelCount()
  12740. {
  12741. return channelList.length();
  12742. }
  12743. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  12744. {
  12745. return channelList.at(channel);
  12746. }
  12747. /*:912*//*913:*/
  12748. #line 319 "./phidgets.w"
  12749. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  12750. {
  12751. return hiddenState.at(channel);
  12752. }
  12753. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  12754. {
  12755. if(channel>=0&&channel<columnNames.length())
  12756. {
  12757. return columnNames.at(channel);
  12758. }
  12759. return QString();
  12760. }
  12761. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  12762. {
  12763. if(channel>=0&&channel<indicatorTexts.length())
  12764. {
  12765. return indicatorTexts.at(channel);
  12766. }
  12767. return QString();
  12768. }
  12769. /*:913*//*915:*/
  12770. #line 371 "./phidgets.w"
  12771. void PhidgetsTemperatureSensor::start()
  12772. {
  12773. if(!driver.load())
  12774. {
  12775. driver.setFileName("Phidget21.framework/Phidget21");
  12776. if(!driver.load())
  12777. {
  12778. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  12779. tr("Failed to find phidget21. Please install it."));
  12780. return;
  12781. }
  12782. }
  12783. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  12784. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  12785. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  12786. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  12787. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  12788. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  12789. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  12790. {
  12791. QMessageBox::critical(NULL,tr("Typica: Link error"),
  12792. tr("Failed to link a required symbol in phidget21."));
  12793. return;
  12794. }
  12795. createDevice(&device);
  12796. openDevice(device,-1);
  12797. int error;
  12798. if((error= waitForOpen(device,10000)))
  12799. {
  12800. closeDevice(device);
  12801. deleteDevice(device);
  12802. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  12803. tr("CPhidget_waitForAttachment returns error %n",0,error));
  12804. return;
  12805. }
  12806. for(int i= 0;i<channelIndices.length();i++)
  12807. {
  12808. setTCType(device,channelIndices.at(i),tctypes.at(i));
  12809. }
  12810. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  12811. sampleTimer.start();
  12812. }
  12813. /*:915*//*916:*/
  12814. #line 418 "./phidgets.w"
  12815. void PhidgetsTemperatureSensor::getMeasurements()
  12816. {
  12817. double value= 0.0;
  12818. QTime time= QTime::currentTime();
  12819. foreach(int i,channelIndices)
  12820. {
  12821. getTemperature(device,i,&value);
  12822. Measurement measure(value*9.0/5.0+32.0,time);
  12823. channelMap[i]->input(measure);
  12824. }
  12825. }
  12826. /*:916*//*917:*/
  12827. #line 433 "./phidgets.w"
  12828. void PhidgetsTemperatureSensor::stop()
  12829. {
  12830. sampleTimer.stop();
  12831. closeDevice(device);
  12832. deleteDevice(device);
  12833. driver.unload();
  12834. }
  12835. /*:917*/
  12836. #line 445 "./phidgets.w"
  12837. /*:918*//*932:*/
  12838. #line 19523 "./typica.w"
  12839. /*930:*/
  12840. #line 19485 "./typica.w"
  12841. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  12842. const QModelIndex&index)
  12843. :BasicDeviceConfigurationWidget(model,index)
  12844. {
  12845. QHBoxLayout*layout= new QHBoxLayout;
  12846. QLabel*label= new QLabel(tr("Cooling Time: "));
  12847. QTimeEdit*editor= new QTimeEdit;
  12848. editor->setDisplayFormat("mm:ss");
  12849. /*771:*/
  12850. #line 16333 "./typica.w"
  12851. QDomElement referenceElement=
  12852. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12853. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12854. QDomElement node;
  12855. /*:771*/
  12856. #line 19494 "./typica.w"
  12857. for(int i= 0;i<configData.size();i++)
  12858. {
  12859. node= configData.at(i).toElement();
  12860. if(node.attribute("name")=="reset")
  12861. {
  12862. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  12863. }
  12864. }
  12865. updateResetTime(editor->time());
  12866. connect(editor,SIGNAL(timeChanged(QTime)),
  12867. this,SLOT(updateResetTime(QTime)));
  12868. layout->addWidget(label);
  12869. layout->addWidget(editor);
  12870. setLayout(layout);
  12871. }
  12872. void CoolingTimerConfWidget::updateResetTime(QTime time)
  12873. {
  12874. updateAttribute("reset",time.toString("mm:ss"));
  12875. }
  12876. /*:930*/
  12877. #line 19524 "./typica.w"
  12878. /*:932*//*937:*/
  12879. #line 19782 "./typica.w"
  12880. /*934:*/
  12881. #line 19556 "./typica.w"
  12882. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  12883. :BasicDeviceConfigurationWidget(model,index)
  12884. {
  12885. QVBoxLayout*layout= new QVBoxLayout;
  12886. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  12887. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  12888. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  12889. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  12890. QButtonGroup*startOptionGroup= new QButtonGroup;
  12891. startOptionGroup->addButton(startBatchOption,1);
  12892. startOptionGroup->addButton(buttonOption,2);
  12893. startOptionGroup->addButton(thresholdOption,3);
  12894. startBatchOption->setChecked(true);
  12895. QGridLayout*startOptions= new QGridLayout;
  12896. startOptions->addWidget(startBatchOption,0,0);
  12897. startOptions->addWidget(buttonOption,1,0);
  12898. startOptions->addWidget(thresholdOption,2,0);
  12899. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  12900. QLineEdit*buttonTextEdit= new QLineEdit;
  12901. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  12902. buttonTextOptions->addWidget(buttonTextLabel);
  12903. buttonTextOptions->addWidget(buttonTextEdit);
  12904. startOptions->addLayout(buttonTextOptions,1,1);
  12905. QFormLayout*thresholdOptions= new QFormLayout;
  12906. QLineEdit*startColumnName= new QLineEdit;
  12907. QLineEdit*startValue= new QLineEdit;
  12908. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  12909. thresholdOptions->addRow(tr("Value: "),startValue);
  12910. startOptions->addLayout(thresholdOptions,2,1);
  12911. startConfigurationGroup->setLayout(startOptions);
  12912. layout->addWidget(startConfigurationGroup);
  12913. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  12914. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  12915. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  12916. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  12917. QButtonGroup*stopOptionGroup= new QButtonGroup;
  12918. stopOptionGroup->addButton(stopBatchOption,1);
  12919. stopOptionGroup->addButton(stopButtonOption,2);
  12920. stopOptionGroup->addButton(stopThresholdOption,3);
  12921. stopBatchOption->setChecked(true);
  12922. QGridLayout*stopOptions= new QGridLayout;
  12923. stopOptions->addWidget(stopBatchOption,0,0);
  12924. stopOptions->addWidget(stopButtonOption,1,0);
  12925. stopOptions->addWidget(stopThresholdOption,2,0);
  12926. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  12927. QLineEdit*stopButtonEdit= new QLineEdit;
  12928. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  12929. stopButtonTextOptions->addWidget(stopButtonLabel);
  12930. stopButtonTextOptions->addWidget(stopButtonEdit);
  12931. stopOptions->addLayout(stopButtonTextOptions,1,1);
  12932. QLineEdit*stopColumnName= new QLineEdit;
  12933. QLineEdit*stopValue= new QLineEdit;
  12934. QFormLayout*stopThresholdOptions= new QFormLayout;
  12935. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  12936. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  12937. stopOptions->addLayout(stopThresholdOptions,2,1);
  12938. stopConfigurationGroup->setLayout(stopOptions);
  12939. layout->addWidget(stopConfigurationGroup);
  12940. /*771:*/
  12941. #line 16333 "./typica.w"
  12942. QDomElement referenceElement=
  12943. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12944. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12945. QDomElement node;
  12946. /*:771*/
  12947. #line 19618 "./typica.w"
  12948. for(int i= 0;i<configData.size();i++)
  12949. {
  12950. node= configData.at(i).toElement();
  12951. if(node.attribute("name")=="startbuttontext")
  12952. {
  12953. buttonTextEdit->setText(node.attribute("value"));
  12954. }
  12955. else if(node.attribute("name")=="stopbuttontext")
  12956. {
  12957. stopButtonEdit->setText(node.attribute("value"));
  12958. }
  12959. else if(node.attribute("name")=="startcolumnname")
  12960. {
  12961. startColumnName->setText(node.attribute("value"));
  12962. }
  12963. else if(node.attribute("name")=="stopcolumnname")
  12964. {
  12965. stopColumnName->setText(node.attribute("value"));
  12966. }
  12967. else if(node.attribute("name")=="startvalue")
  12968. {
  12969. startValue->setText(node.attribute("value"));
  12970. }
  12971. else if(node.attribute("name")=="stopvalue")
  12972. {
  12973. stopValue->setText(node.attribute("value"));
  12974. }
  12975. else if(node.attribute("name")=="starttrigger")
  12976. {
  12977. if(node.attribute("value")=="batch")
  12978. {
  12979. startBatchOption->setChecked(true);
  12980. }
  12981. else if(node.attribute("value")=="manual")
  12982. {
  12983. buttonOption->setChecked(true);
  12984. }
  12985. else if(node.attribute("value")=="value")
  12986. {
  12987. thresholdOption->setChecked(true);
  12988. }
  12989. }
  12990. else if(node.attribute("name")=="stoptrigger")
  12991. {
  12992. if(node.attribute("value")=="batch")
  12993. {
  12994. stopBatchOption->setChecked(true);
  12995. }
  12996. else if(node.attribute("value")=="manual")
  12997. {
  12998. stopButtonOption->setChecked(true);
  12999. }
  13000. else if(node.attribute("value")=="value")
  13001. {
  13002. stopThresholdOption->setChecked(true);
  13003. }
  13004. }
  13005. }
  13006. updateStartButtonText(buttonTextEdit->text());
  13007. updateStopButtonText(stopButtonEdit->text());
  13008. updateStartColumnName(startColumnName->text());
  13009. updateStopColumnName(stopColumnName->text());
  13010. updateStartValue(startValue->text());
  13011. updateStopValue(stopValue->text());
  13012. updateStartTrigger(startOptionGroup->checkedId());
  13013. updateStopTrigger(stopOptionGroup->checkedId());
  13014. setLayout(layout);
  13015. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  13016. this,SLOT(updateStartButtonText(QString)));
  13017. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  13018. this,SLOT(updateStopButtonText(QString)));
  13019. connect(startColumnName,SIGNAL(textChanged(QString)),
  13020. this,SLOT(updateStartColumnName(QString)));
  13021. connect(stopColumnName,SIGNAL(textChanged(QString)),
  13022. this,SLOT(updateStopColumnName(QString)));
  13023. connect(startValue,SIGNAL(textChanged(QString)),
  13024. this,SLOT(updateStartValue(QString)));
  13025. connect(stopValue,SIGNAL(textChanged(QString)),
  13026. this,SLOT(updateStopValue(QString)));
  13027. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  13028. this,SLOT(updateStartTrigger(int)));
  13029. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  13030. this,SLOT(updateStopTrigger(int)));
  13031. }
  13032. /*:934*//*935:*/
  13033. #line 19708 "./typica.w"
  13034. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  13035. {
  13036. updateAttribute("startbuttontext",text);
  13037. }
  13038. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  13039. {
  13040. updateAttribute("stopbuttontext",text);
  13041. }
  13042. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  13043. {
  13044. updateAttribute("startcolumnname",text);
  13045. }
  13046. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  13047. {
  13048. updateAttribute("stopcolumnname",text);
  13049. }
  13050. void RangeTimerConfWidget::updateStartValue(const QString&text)
  13051. {
  13052. updateAttribute("startvalue",text);
  13053. }
  13054. void RangeTimerConfWidget::updateStopValue(const QString&text)
  13055. {
  13056. updateAttribute("stopvalue",text);
  13057. }
  13058. void RangeTimerConfWidget::updateStartTrigger(int option)
  13059. {
  13060. switch(option)
  13061. {
  13062. case 1:
  13063. updateAttribute("starttrigger","batch");
  13064. break;
  13065. case 2:
  13066. updateAttribute("starttrigger","manual");
  13067. break;
  13068. case 3:
  13069. updateAttribute("starttrigger","value");
  13070. break;
  13071. default:
  13072. break;
  13073. }
  13074. }
  13075. void RangeTimerConfWidget::updateStopTrigger(int option)
  13076. {
  13077. switch(option)
  13078. {
  13079. case 1:
  13080. updateAttribute("stoptrigger","batch");
  13081. break;
  13082. case 2:
  13083. updateAttribute("stoptrigger","manual");
  13084. break;
  13085. case 3:
  13086. updateAttribute("stoptrigger","value");
  13087. break;
  13088. default:
  13089. break;
  13090. }
  13091. }
  13092. /*:935*/
  13093. #line 19783 "./typica.w"
  13094. /*:937*//*942:*/
  13095. #line 19883 "./typica.w"
  13096. /*939:*/
  13097. #line 19807 "./typica.w"
  13098. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  13099. const QModelIndex&index)
  13100. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  13101. {
  13102. QFormLayout*layout= new QFormLayout;
  13103. QLineEdit*trigger= new QLineEdit;
  13104. layout->addRow(tr("Trigger column name:"),trigger);
  13105. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  13106. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  13107. QTableView*rangeTable= new QTableView;
  13108. rangeTable->setModel(tablemodel);
  13109. layout->addRow(tr("Range data:"),rangeTable);
  13110. /*771:*/
  13111. #line 16333 "./typica.w"
  13112. QDomElement referenceElement=
  13113. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13114. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13115. QDomElement node;
  13116. /*:771*/
  13117. #line 19820 "./typica.w"
  13118. for(int i= 0;i<configData.size();i++)
  13119. {
  13120. node= configData.at(i).toElement();
  13121. if(node.attribute("name")=="trigger")
  13122. {
  13123. trigger->setText(node.attribute("value"));
  13124. }
  13125. else if(node.attribute("name")=="rangenames")
  13126. {
  13127. QString data= node.attribute("value");
  13128. if(data.length()> 3)
  13129. {
  13130. data.chop(2);
  13131. data= data.remove(0,2);
  13132. }
  13133. QStringList itemList= data.split(", ");
  13134. for(int j= 0;j<itemList.size();j++)
  13135. {
  13136. QString item= itemList.at(j);
  13137. item.chop(1);
  13138. item= item.remove(0,1);
  13139. tablemodel->setData(tablemodel->index(j,0),
  13140. QVariant(item),Qt::DisplayRole);
  13141. }
  13142. }
  13143. else if(node.attribute("name")=="endtemps")
  13144. {
  13145. /*925:*/
  13146. #line 19415 "./typica.w"
  13147. QString data= node.attribute("value");
  13148. if(data.length()> 3)
  13149. {
  13150. data.chop(2);
  13151. data= data.remove(0,2);
  13152. }
  13153. QStringList itemList= data.split(",");
  13154. /*:925*/
  13155. #line 19848 "./typica.w"
  13156. int column= 1;
  13157. /*926:*/
  13158. #line 19427 "./typica.w"
  13159. for(int j= 0;j<itemList.size();j++)
  13160. {
  13161. tablemodel->setData(tablemodel->index(j,column),
  13162. QVariant(itemList.at(j).toDouble()),
  13163. Qt::DisplayRole);
  13164. }
  13165. /*:926*/
  13166. #line 19850 "./typica.w"
  13167. }
  13168. }
  13169. updateColumnName(trigger->text());
  13170. updateRangeData();
  13171. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13172. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  13173. setLayout(layout);
  13174. }
  13175. /*:939*//*940:*/
  13176. #line 19864 "./typica.w"
  13177. void MultiRangeTimerConfWidget::updateRangeData()
  13178. {
  13179. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  13180. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  13181. }
  13182. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  13183. {
  13184. updateAttribute("trigger",text);
  13185. }
  13186. /*:940*/
  13187. #line 19884 "./typica.w"
  13188. /*:942*//*960:*/
  13189. #line 265 "./rate.w"
  13190. /*956:*/
  13191. #line 191 "./rate.w"
  13192. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13193. :BasicDeviceConfigurationWidget(model,index)
  13194. {
  13195. QFormLayout*layout= new QFormLayout;
  13196. QLineEdit*column= new QLineEdit;
  13197. layout->addRow(tr("Primary series column name:"),column);
  13198. QSpinBox*cacheTime= new QSpinBox;
  13199. cacheTime->setMinimum(0);
  13200. cacheTime->setMaximum(300);
  13201. layout->addRow(tr("Cache time:"),cacheTime);
  13202. QSpinBox*scaleTime= new QSpinBox;
  13203. scaleTime->setMinimum(1);
  13204. scaleTime->setMaximum(300);
  13205. layout->addRow(tr("Scale time:"),scaleTime);
  13206. /*771:*/
  13207. #line 16333 "./typica.w"
  13208. QDomElement referenceElement=
  13209. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13210. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13211. QDomElement node;
  13212. /*:771*/
  13213. #line 206 "./rate.w"
  13214. for(int i= 0;i<configData.size();i++)
  13215. {
  13216. node= configData.at(i).toElement();
  13217. if(node.attribute("name")=="column")
  13218. {
  13219. column->setText(node.attribute("value"));
  13220. }
  13221. else if(node.attribute("name")=="cache")
  13222. {
  13223. cacheTime->setValue(node.attribute("value").toInt());
  13224. }
  13225. else if(node.attribute("name")=="scale")
  13226. {
  13227. scaleTime->setValue(node.attribute("value").toInt());
  13228. }
  13229. }
  13230. updateColumn(column->text());
  13231. updateCacheTime(cacheTime->text());
  13232. updateScaleTime(scaleTime->text());
  13233. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  13234. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  13235. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  13236. setLayout(layout);
  13237. }
  13238. /*:956*//*957:*/
  13239. #line 235 "./rate.w"
  13240. void RateOfChangeConfWidget::updateColumn(const QString&column)
  13241. {
  13242. updateAttribute("column",column);
  13243. }
  13244. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  13245. {
  13246. updateAttribute("cache",seconds);
  13247. }
  13248. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  13249. {
  13250. updateAttribute("scale",seconds);
  13251. }
  13252. /*:957*/
  13253. #line 266 "./rate.w"
  13254. #line 19976 "./typica.w"
  13255. #line 1 "./dataqsdk.w"
  13256. /*:960*/
  13257. #line 529 "./typica.w"
  13258. /*8:*/
  13259. #line 672 "./typica.w"
  13260. template<class TYPE> TYPE getself(QScriptContext*context)
  13261. {
  13262. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  13263. return self;
  13264. }
  13265. template<> QTime getself(QScriptContext*context)
  13266. {
  13267. QTime self= context->thisObject().toVariant().toTime();
  13268. return self;
  13269. }
  13270. template<> QByteArray getself(QScriptContext*context)
  13271. {
  13272. QByteArray self= context->thisObject().toVariant().toByteArray();
  13273. return self;
  13274. }
  13275. template<> SqlQueryConnection*getself(QScriptContext*context)
  13276. {
  13277. SqlQueryConnection*self=
  13278. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  13279. return self;
  13280. }
  13281. template<> QXmlQuery*getself(QScriptContext*context)
  13282. {
  13283. QXmlQuery*self=
  13284. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  13285. return self;
  13286. }
  13287. template<> QXmlStreamWriter*getself(QScriptContext*context)
  13288. {
  13289. QXmlStreamWriter*self=
  13290. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  13291. return self;
  13292. }
  13293. template<> QXmlStreamReader*getself(QScriptContext*context)
  13294. {
  13295. QXmlStreamReader*self=
  13296. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  13297. return self;
  13298. }
  13299. /*:8*//*9:*/
  13300. #line 723 "./typica.w"
  13301. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  13302. {
  13303. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  13304. return argument;
  13305. }
  13306. template<> QString argument(int arg,QScriptContext*context)
  13307. {
  13308. return context->argument(arg).toString();
  13309. }
  13310. template<> QVariant argument(int arg,QScriptContext*context)
  13311. {
  13312. return context->argument(arg).toVariant();
  13313. }
  13314. template<> int argument(int arg,QScriptContext*context)
  13315. {
  13316. return context->argument(arg).toInt32();
  13317. }
  13318. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  13319. {
  13320. return(SqlQueryConnection*)
  13321. qscriptvalue_cast<void*> (context->argument(arg));
  13322. }
  13323. template<> QModelIndex argument(int arg,QScriptContext*context)
  13324. {
  13325. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  13326. }
  13327. template<> double argument(int arg,QScriptContext*context)
  13328. {
  13329. return(double)(context->argument(arg).toNumber());
  13330. }
  13331. template<> Units::Unit argument(int arg,QScriptContext*context)
  13332. {
  13333. return(Units::Unit)(context->argument(arg).toInt32());
  13334. }
  13335. template<> QByteArray argument(int arg,QScriptContext*context)
  13336. {
  13337. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  13338. }
  13339. /*:9*//*13:*/
  13340. #line 815 "./typica.w"
  13341. void setQObjectProperties(QScriptValue,QScriptEngine*)
  13342. {
  13343. }
  13344. /*:13*//*15:*/
  13345. #line 829 "./typica.w"
  13346. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  13347. {
  13348. }
  13349. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  13350. {
  13351. }
  13352. /*:15*//*18:*/
  13353. #line 868 "./typica.w"
  13354. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  13355. {
  13356. QScriptValue object= engine->newQObject(new QWidget);
  13357. setQWidgetProperties(object,engine);
  13358. return object;
  13359. }
  13360. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  13361. {
  13362. setQObjectProperties(value,engine);
  13363. setQPaintDeviceProperties(value,engine);
  13364. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  13365. value.setProperty("activateWindow",
  13366. engine->newFunction(QWidget_activateWindow));
  13367. }
  13368. /*:18*//*19:*/
  13369. #line 890 "./typica.w"
  13370. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  13371. {
  13372. if(context->argumentCount()==1)
  13373. {
  13374. QWidget*self= getself<QWidget*> (context);
  13375. QLayout*layout= argument<QLayout*> (0,context);
  13376. if(layout)
  13377. {
  13378. self->setLayout(layout);
  13379. }
  13380. else
  13381. {
  13382. context->throwError("Incorrect argument type passed to "
  13383. "QWidget::setLayout(). This method requires "
  13384. "a QLayout.");
  13385. }
  13386. }
  13387. else
  13388. {
  13389. context->throwError("Incorrect number of arguments passed to "
  13390. "QWidget::setLayout(). This method takes one "
  13391. "QLayout as an argument.");
  13392. }
  13393. return QScriptValue();
  13394. }
  13395. QScriptValue QWidget_activateWindow(QScriptContext*context,
  13396. QScriptEngine*)
  13397. {
  13398. QWidget*self= getself<QWidget*> (context);
  13399. self->activateWindow();
  13400. return QScriptValue();
  13401. }
  13402. /*:19*//*22:*/
  13403. #line 952 "./typica.w"
  13404. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  13405. {
  13406. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  13407. argument<QString> (0,context),
  13408. argument<QString> (1,context),
  13409. QMessageBox::Ok|QMessageBox::Cancel);
  13410. if(selection==QMessageBox::Ok){
  13411. return QScriptValue(true);
  13412. }
  13413. return QScriptValue(false);
  13414. }
  13415. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  13416. {
  13417. QMessageBox::critical(NULL,argument<QString> (0,context),
  13418. argument<QString> (1,context));
  13419. return QScriptValue();
  13420. }
  13421. /*:22*//*24:*/
  13422. #line 1019 "./typica.w"
  13423. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  13424. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  13425. {
  13426. }
  13427. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  13428. {
  13429. QSettings settings;
  13430. settings.beginGroup(key);
  13431. settings.setValue("pos",pos());
  13432. settings.setValue("size",size());
  13433. settings.endGroup();
  13434. }
  13435. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  13436. {
  13437. QSettings settings;
  13438. settings.beginGroup(key);
  13439. if(settings.contains("size"))
  13440. {
  13441. resize(settings.value("size").toSize());
  13442. }
  13443. if(settings.contains("pos"))
  13444. {
  13445. move(settings.value("pos").toPoint());
  13446. }
  13447. settings.endGroup();
  13448. }
  13449. void ScriptQMainWindow::displayStatus(const QString&message)
  13450. {
  13451. statusBar()->showMessage(message);
  13452. }
  13453. void ScriptQMainWindow::showEvent(QShowEvent*event)
  13454. {
  13455. if(!event->spontaneous())
  13456. {
  13457. /*29:*/
  13458. #line 1131 "./typica.w"
  13459. QSettings settings;
  13460. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  13461. toByteArray());
  13462. /*:29*/
  13463. #line 1059 "./typica.w"
  13464. event->accept();
  13465. }
  13466. else
  13467. {
  13468. event->ignore();
  13469. }
  13470. }
  13471. void ScriptQMainWindow::show()
  13472. {
  13473. QMainWindow::show();
  13474. }
  13475. /*:24*//*25:*/
  13476. #line 1080 "./typica.w"
  13477. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  13478. {
  13479. if(isWindowModified()){
  13480. /*26:*/
  13481. #line 1094 "./typica.w"
  13482. QMessageBox::StandardButton result;
  13483. result= QMessageBox::warning(this,"Typica",closePrompt(),
  13484. QMessageBox::Ok|QMessageBox::Cancel);
  13485. if(result==QMessageBox::Cancel)
  13486. {
  13487. event->ignore();
  13488. return;
  13489. }
  13490. /*:26*/
  13491. #line 1084 "./typica.w"
  13492. }
  13493. emit aboutToClose();
  13494. /*28:*/
  13495. #line 1125 "./typica.w"
  13496. QSettings settings;
  13497. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  13498. /*:28*/
  13499. #line 1087 "./typica.w"
  13500. event->accept();
  13501. }
  13502. /*:25*//*27:*/
  13503. #line 1106 "./typica.w"
  13504. QString ScriptQMainWindow::closePrompt()
  13505. {
  13506. return cprompt;
  13507. }
  13508. void ScriptQMainWindow::setClosePrompt(QString prompt)
  13509. {
  13510. cprompt= prompt;
  13511. }
  13512. /*:27*//*32:*/
  13513. #line 1159 "./typica.w"
  13514. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  13515. {
  13516. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  13517. setQMainWindowProperties(object,engine);
  13518. return object;
  13519. }
  13520. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  13521. {
  13522. setQWidgetProperties(value,engine);
  13523. value.setProperty("setCentralWidget",
  13524. engine->newFunction(QMainWindow_setCentralWidget));
  13525. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  13526. }
  13527. /*:32*//*33:*/
  13528. #line 1181 "./typica.w"
  13529. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  13530. QScriptEngine*)
  13531. {
  13532. if(context->argumentCount()==1)
  13533. {
  13534. QMainWindow*self= getself<QMainWindow*> (context);
  13535. QWidget*widget= argument<QWidget*> (0,context);
  13536. if(widget)
  13537. {
  13538. self->setCentralWidget(widget);
  13539. }
  13540. else
  13541. {
  13542. context->throwError("Incorrect argument type passed to "
  13543. "QMainWindow::setCentralWidget(). This "
  13544. "method requires a QWidget.");
  13545. }
  13546. }
  13547. else
  13548. {
  13549. context->throwError("Incorrect number of arguments passed to "
  13550. "QMainWindow::setCentralWidget(). This method "
  13551. "takes one QWidget as an argument.");
  13552. }
  13553. return QScriptValue();
  13554. }
  13555. /*:33*//*34:*/
  13556. #line 1215 "./typica.w"
  13557. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  13558. {
  13559. QScriptValue object;
  13560. if(context->argumentCount()==0)
  13561. {
  13562. QMainWindow*self= getself<QMainWindow*> (context);
  13563. QMenuBar*bar= self->menuBar();
  13564. object= engine->newQObject(bar);
  13565. setQMenuBarProperties(object,engine);
  13566. }
  13567. else
  13568. {
  13569. context->throwError("Incorrect number of arguments passed to "
  13570. "QMainWindow::menuBar(). This method takes no "
  13571. "arguments.");
  13572. }
  13573. return object;
  13574. }
  13575. /*:34*//*36:*/
  13576. #line 1245 "./typica.w"
  13577. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  13578. {
  13579. setQWidgetProperties(value,engine);
  13580. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  13581. }
  13582. /*:36*//*37:*/
  13583. #line 1260 "./typica.w"
  13584. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  13585. {
  13586. QScriptValue object;
  13587. if(context->argumentCount()==1)
  13588. {
  13589. QMenuBar*self= getself<QMenuBar*> (context);
  13590. QString title= argument<QString> (0,context);
  13591. object= engine->newQObject(self->addMenu(title));
  13592. setQMenuProperties(object,engine);
  13593. }
  13594. else
  13595. {
  13596. context->throwError("Incorrect number of arguments passed to "
  13597. "QMenuBar::addMenu(). This method takes one "
  13598. "string as an argument.");
  13599. }
  13600. return object;
  13601. }
  13602. /*:37*//*39:*/
  13603. #line 1290 "./typica.w"
  13604. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  13605. {
  13606. setQWidgetProperties(value,engine);
  13607. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  13608. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  13609. }
  13610. /*:39*//*40:*/
  13611. #line 1300 "./typica.w"
  13612. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  13613. {
  13614. if(context->argumentCount()==1)
  13615. {
  13616. QMenu*self= getself<QMenu*> (context);
  13617. QAction*action= argument<QAction*> (0,context);
  13618. if(action)
  13619. {
  13620. self->addAction(action);
  13621. }
  13622. else
  13623. {
  13624. context->throwError("Incorrect argument type passed to "
  13625. "QMenu::addAction(). This method requires a "
  13626. "QAction.");
  13627. }
  13628. }
  13629. else
  13630. {
  13631. context->throwError("Incorrect number of arguments passed to "
  13632. "QMenu::addAction(). This method takes one "
  13633. "QAction as an argument.");
  13634. }
  13635. return QScriptValue();
  13636. }
  13637. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  13638. {
  13639. if(context->argumentCount()==0)
  13640. {
  13641. QMenu*self= getself<QMenu*> (context);
  13642. self->addSeparator();
  13643. }
  13644. else
  13645. {
  13646. context->throwError("Incorrect number of arguments passed to "
  13647. "QMenu::addSeparator(). This method takes no "
  13648. "arguments.");
  13649. }
  13650. return QScriptValue();
  13651. }
  13652. /*:40*//*43:*/
  13653. #line 1362 "./typica.w"
  13654. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  13655. {
  13656. QScriptValue object= engine->newQObject(new QFrame);
  13657. setQFrameProperties(object,engine);
  13658. return object;
  13659. }
  13660. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  13661. {
  13662. setQWidgetProperties(value,engine);
  13663. }
  13664. /*:43*//*46:*/
  13665. #line 1396 "./typica.w"
  13666. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  13667. {
  13668. QString text;
  13669. if(context->argumentCount()==1)
  13670. {
  13671. text= argument<QString> (0,context);
  13672. }
  13673. QScriptValue object= engine->newQObject(new QLabel(text));
  13674. setQLabelProperties(object,engine);
  13675. return object;
  13676. }
  13677. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  13678. {
  13679. setQFrameProperties(value,engine);
  13680. }
  13681. /*:46*//*49:*/
  13682. #line 1438 "./typica.w"
  13683. QScriptValue constructQSvgWidget(QScriptContext*,
  13684. QScriptEngine*engine)
  13685. {
  13686. QScriptValue object= engine->newQObject(new QSvgWidget);
  13687. setQSvgWidgetProperties(object,engine);
  13688. return object;
  13689. }
  13690. /*:49*//*50:*/
  13691. #line 1449 "./typica.w"
  13692. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  13693. {
  13694. setQWidgetProperties(value,engine);
  13695. value.setProperty("loadDevice",
  13696. engine->newFunction(QSvgWidget_loadDevice));
  13697. }
  13698. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  13699. {
  13700. if(context->argumentCount()==1)
  13701. {
  13702. QSvgWidget*self= getself<QSvgWidget*> (context);
  13703. QIODevice*device= argument<QIODevice*> (0,context);
  13704. device->reset();
  13705. QByteArray data= device->readAll();
  13706. self->load(data);
  13707. }
  13708. else
  13709. {
  13710. context->throwError("Incorrect number of arguments passed to "
  13711. "QSvgWidget::loadData(). This method takes one "
  13712. "QIODevice as an argument.");
  13713. }
  13714. return QScriptValue();
  13715. }
  13716. /*:50*//*52:*/
  13717. #line 1487 "./typica.w"
  13718. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  13719. QStack<QLayout*> *layoutStack)
  13720. {
  13721. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13722. QSvgWidget*widget= new QSvgWidget;
  13723. layout->addWidget(widget);
  13724. QString id= element.attribute("id");
  13725. if(!id.isEmpty())
  13726. {
  13727. widget->setObjectName(id);
  13728. }
  13729. }
  13730. /*:52*//*55:*/
  13731. #line 1520 "./typica.w"
  13732. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  13733. {
  13734. QScriptValue object= engine->newQObject(new QLineEdit());
  13735. setQLineEditProperties(object,engine);
  13736. return object;
  13737. }
  13738. /*:55*//*56:*/
  13739. #line 1531 "./typica.w"
  13740. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  13741. {
  13742. setQWidgetProperties(value,engine);
  13743. }
  13744. /*:56*//*59:*/
  13745. #line 1567 "./typica.w"
  13746. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  13747. {
  13748. QScriptValue object= engine->newQObject(new QSplitter);
  13749. setQSplitterProperties(object,engine);
  13750. return object;
  13751. }
  13752. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  13753. {
  13754. setQFrameProperties(value,engine);
  13755. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  13756. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  13757. value.setProperty("restoreState",
  13758. engine->newFunction(QSplitter_restoreState));
  13759. value.setProperty("count",engine->newFunction(QSplitter_count));
  13760. }
  13761. /*:59*//*60:*/
  13762. #line 1588 "./typica.w"
  13763. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  13764. {
  13765. if(context->argumentCount()==1)
  13766. {
  13767. QSplitter*self= getself<QSplitter*> (context);
  13768. QWidget*widget= argument<QWidget*> (0,context);
  13769. if(widget)
  13770. {
  13771. self->addWidget(widget);
  13772. }
  13773. else
  13774. {
  13775. context->throwError("Incorrect argument type passed to "
  13776. "QSplitter::addWidget(). This method "
  13777. "requires a QWidget.");
  13778. }
  13779. }
  13780. else
  13781. {
  13782. context->throwError("Incorrect number of arguments passed to "
  13783. "QSplitter::addWidget(). This method takes one "
  13784. "QWidget as an argument.");
  13785. }
  13786. return QScriptValue();
  13787. }
  13788. /*:60*//*61:*/
  13789. #line 1625 "./typica.w"
  13790. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  13791. {
  13792. QSplitter*self= getself<QSplitter*> (context);
  13793. return QScriptValue(self->count());
  13794. }
  13795. /*:61*//*62:*/
  13796. #line 1638 "./typica.w"
  13797. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  13798. {
  13799. if(context->argumentCount()==1)
  13800. {
  13801. QSplitter*self= getself<QSplitter*> (context);
  13802. QString key= argument<QString> (0,context);
  13803. QSettings settings;
  13804. settings.setValue(key,self->saveState());
  13805. }
  13806. else
  13807. {
  13808. context->throwError("Incorrect number of arguments passed to "
  13809. "QSplitter::saveState(). This method takes one "
  13810. "string as an argument.");
  13811. }
  13812. return QScriptValue();
  13813. }
  13814. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  13815. {
  13816. if(context->argumentCount()==1)
  13817. {
  13818. QSplitter*self= getself<QSplitter*> (context);
  13819. QString key= argument<QString> (0,context);
  13820. QSettings settings;
  13821. self->restoreState(settings.value(key).toByteArray());
  13822. }
  13823. else
  13824. {
  13825. context->throwError("Incorrect number of arguments passed to "
  13826. "QSplitter::restoreState(). This method takes "
  13827. "one string as an argument.");
  13828. }
  13829. return QScriptValue();
  13830. }
  13831. /*:62*//*64:*/
  13832. #line 1691 "./typica.w"
  13833. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13834. {
  13835. setQLayoutItemProperties(value,engine);
  13836. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  13837. }
  13838. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13839. {
  13840. if(context->argumentCount()==1)
  13841. {
  13842. QLayout*self= getself<QLayout*> (context);
  13843. QWidget*widget= argument<QWidget*> (0,context);
  13844. if(widget)
  13845. {
  13846. self->addWidget(widget);
  13847. }
  13848. else
  13849. {
  13850. context->throwError("Incorrect argument type passed to "
  13851. "QLayout::addWidget(). This method requires "
  13852. "a QWidget.");
  13853. }
  13854. }
  13855. else
  13856. {
  13857. context->throwError("Incorrect number of arguments passed to "
  13858. "QLayout::addWidget(). This method takes one "
  13859. "QWidget as an argument.");
  13860. }
  13861. return QScriptValue();
  13862. }
  13863. /*:64*//*67:*/
  13864. #line 1758 "./typica.w"
  13865. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  13866. {
  13867. QScriptValue object=
  13868. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  13869. setQBoxLayoutProperties(object,engine);
  13870. return object;
  13871. }
  13872. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  13873. {
  13874. setQLayoutProperties(value,engine);
  13875. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  13876. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  13877. }
  13878. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  13879. {
  13880. if(context->argumentCount()> 0&&context->argumentCount()<3)
  13881. {
  13882. QBoxLayout*self= getself<QBoxLayout*> (context);
  13883. QLayout*layout= argument<QLayout*> (0,context);
  13884. int stretch= 0;
  13885. if(context->argumentCount()==2)
  13886. {
  13887. stretch= argument<int> (1,context);
  13888. }
  13889. if(layout)
  13890. {
  13891. self->addLayout(layout,stretch);
  13892. }
  13893. else
  13894. {
  13895. context->throwError("Incorrect argument type passed to "
  13896. "QLayout::addLayout(). This method requires "
  13897. "a QLayout.");
  13898. }
  13899. }
  13900. else
  13901. {
  13902. context->throwError("Incorrect number of arguments passed to "
  13903. "QLayout::addLayout(). This method takes one "
  13904. "QLayout as an argument and optionally one integer.");
  13905. }
  13906. return QScriptValue();
  13907. }
  13908. /*:67*//*68:*/
  13909. #line 1809 "./typica.w"
  13910. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  13911. {
  13912. if(context->argumentCount()> 0&&context->argumentCount()<4)
  13913. {
  13914. QBoxLayout*self= getself<QBoxLayout*> (context);
  13915. QWidget*widget= argument<QWidget*> (0,context);
  13916. int stretch= 0;
  13917. Qt::Alignment alignment= 0;
  13918. if(context->argumentCount()> 1)
  13919. {
  13920. stretch= argument<int> (1,context);
  13921. }
  13922. if(context->argumentCount()> 2)
  13923. {
  13924. alignment= (Qt::Alignment)(argument<int> (2,context));
  13925. }
  13926. if(widget)
  13927. {
  13928. self->addWidget(widget,stretch,alignment);
  13929. }
  13930. else
  13931. {
  13932. context->throwError("Incorrect argument type passed to "
  13933. "QBoxLayout::addWidget(). This method requires "
  13934. "a QWidget.");
  13935. }
  13936. }
  13937. else
  13938. {
  13939. context->throwError("Incorrect number of arguments passed to "
  13940. "QBoxLayout::addWidget(). This method takes one "
  13941. "QWidget and optionally up to two integers as "
  13942. "arguments.");
  13943. }
  13944. return QScriptValue();
  13945. }
  13946. /*:68*//*71:*/
  13947. #line 1873 "./typica.w"
  13948. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  13949. {
  13950. QScriptValue object= engine->newQObject(new QAction(NULL));
  13951. setQActionProperties(object,engine);
  13952. return object;
  13953. }
  13954. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  13955. {
  13956. setQObjectProperties(value,engine);
  13957. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  13958. }
  13959. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  13960. {
  13961. if(context->argumentCount()==1)
  13962. {
  13963. QAction*self= getself<QAction*> (context);
  13964. self->setShortcut(argument<QString> (0,context));
  13965. }
  13966. else
  13967. {
  13968. context->throwError("Incorrect number of arguments passed to "
  13969. "QAction::setShortcut(). This method takes one "
  13970. "string as an argument.");
  13971. }
  13972. return QScriptValue();
  13973. }
  13974. /*:71*//*74:*/
  13975. #line 1931 "./typica.w"
  13976. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  13977. QScriptEngine*engine)
  13978. {
  13979. QScriptValue retval;
  13980. if(context->argumentCount()==3)
  13981. {
  13982. QWidget*widget= argument<QWidget*> (0,context);
  13983. if(widget)
  13984. {
  13985. QString caption= argument<QString> (1,context);
  13986. QString dir= argument<QString> (2,context);
  13987. retval= QScriptValue(engine,
  13988. QFileDialog::getOpenFileName(widget,caption,
  13989. dir,"",0,0));
  13990. setQFileDialogProperties(retval,engine);
  13991. }
  13992. else
  13993. {
  13994. context->throwError("Incorrect argument type passed to "
  13995. "QFileDialog::getOpenFileName(). The first "
  13996. "argument to this method must be a QWidget.");
  13997. }
  13998. }
  13999. else
  14000. {
  14001. context->throwError("Incorrect number of arguments passed to "
  14002. "QFileDialog::getOpenFileName(). This method "
  14003. "takes one QWidget followed by two strings for a "
  14004. "total of three arguments.");
  14005. }
  14006. return retval;
  14007. }
  14008. /*:74*//*75:*/
  14009. #line 1967 "./typica.w"
  14010. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  14011. QScriptEngine*engine)
  14012. {
  14013. QScriptValue retval;
  14014. if(context->argumentCount()==3)
  14015. {
  14016. QWidget*widget= argument<QWidget*> (0,context);
  14017. if(widget)
  14018. {
  14019. QString caption= argument<QString> (1,context);
  14020. QString dir= argument<QString> (2,context);
  14021. retval= QScriptValue(engine,
  14022. QFileDialog::getSaveFileName(widget,caption,
  14023. dir,"",0,0));
  14024. setQFileDialogProperties(retval,engine);
  14025. }
  14026. else
  14027. {
  14028. context->throwError("Incorrect argument type passed to "
  14029. "QFileDialog::getSaveFileName(). The first "
  14030. "argument to this method must be a QWidget.");
  14031. }
  14032. }
  14033. else
  14034. {
  14035. context->throwError("Incorrect number of arguments passed to "
  14036. "QFileDialog::getSaveFileName(). This method "
  14037. "takes one QWidget followed by two strings for a "
  14038. "total of three arguments.");
  14039. }
  14040. return retval;
  14041. }
  14042. /*:75*//*76:*/
  14043. #line 2004 "./typica.w"
  14044. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  14045. {
  14046. setQDialogProperties(value,engine);
  14047. }
  14048. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  14049. {
  14050. setQWidgetProperties(value,engine);
  14051. }
  14052. /*:76*//*79:*/
  14053. #line 2045 "./typica.w"
  14054. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  14055. {
  14056. QScriptValue object=
  14057. engine->newQObject(new QFile(argument<QString> (0,context)));
  14058. setQFileProperties(object,engine);
  14059. return object;
  14060. }
  14061. /*:79*//*80:*/
  14062. #line 2056 "./typica.w"
  14063. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  14064. {
  14065. setQIODeviceProperties(value,engine);
  14066. value.setProperty("remove",engine->newFunction(QFile_remove));
  14067. }
  14068. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  14069. {
  14070. QFile*self= getself<QFile*> (context);
  14071. bool retval= self->remove();
  14072. return QScriptValue(engine,retval);
  14073. }
  14074. /*:80*//*81:*/
  14075. #line 2078 "./typica.w"
  14076. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  14077. {
  14078. setQObjectProperties(value,engine);
  14079. value.setProperty("open",engine->newFunction(QIODevice_open));
  14080. value.setProperty("close",engine->newFunction(QIODevice_close));
  14081. value.setProperty("readToString",
  14082. engine->newFunction(QIODevice_readToString));
  14083. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  14084. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  14085. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  14086. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  14087. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  14088. value.setProperty("read",engine->newFunction(QIODevice_read));
  14089. }
  14090. /*:81*//*82:*/
  14091. #line 2099 "./typica.w"
  14092. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  14093. {
  14094. QIODevice*self= getself<QIODevice*> (context);
  14095. bool retval= false;
  14096. if(context->argumentCount()==1)
  14097. {
  14098. switch(argument<int> (0,context))
  14099. {
  14100. case 1:
  14101. retval= self->open(QIODevice::ReadOnly);
  14102. break;
  14103. case 2:
  14104. retval= self->open(QIODevice::WriteOnly);
  14105. break;
  14106. case 3:
  14107. retval= self->open(QIODevice::ReadWrite);
  14108. break;
  14109. default:
  14110. break;
  14111. }
  14112. }
  14113. else
  14114. {
  14115. retval= self->open(QIODevice::ReadWrite);
  14116. }
  14117. return QScriptValue(retval);
  14118. }
  14119. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  14120. {
  14121. QIODevice*self= getself<QIODevice*> (context);
  14122. self->close();
  14123. return QScriptValue();
  14124. }
  14125. /*:82*//*83:*/
  14126. #line 2139 "./typica.w"
  14127. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  14128. {
  14129. QIODevice*self= getself<QIODevice*> (context);
  14130. self->reset();
  14131. return QScriptValue(QString(self->readAll()));
  14132. }
  14133. /*:83*//*84:*/
  14134. #line 2155 "./typica.w"
  14135. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  14136. {
  14137. QIODevice*self= getself<QIODevice*> (context);
  14138. if(context->argumentCount()==1)
  14139. {
  14140. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  14141. }
  14142. context->throwError("Incorrect number of arguments passed to "
  14143. "QIODevice::putChar()");
  14144. return QScriptValue();
  14145. }
  14146. /*:84*//*85:*/
  14147. #line 2173 "./typica.w"
  14148. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  14149. {
  14150. QIODevice*self= getself<QIODevice*> (context);
  14151. if(context->argumentCount()==1)
  14152. {
  14153. self->write(argument<QString> (0,context).toUtf8());
  14154. }
  14155. else
  14156. {
  14157. context->throwError("Incorrect number of arguments passed to "
  14158. "QIODevice::writeString()");
  14159. }
  14160. return QScriptValue();
  14161. }
  14162. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  14163. {
  14164. QIODevice*self= getself<QIODevice*> (context);
  14165. if(context->argumentCount()==1)
  14166. {
  14167. self->write(argument<QByteArray> (0,context));
  14168. }
  14169. else
  14170. {
  14171. context->throwError("Incorrect number of arguments passed to "
  14172. "QIODevice::writeBytes()");
  14173. }
  14174. return QScriptValue();
  14175. }
  14176. /*:85*//*86:*/
  14177. #line 2207 "./typica.w"
  14178. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  14179. {
  14180. QIODevice*self= getself<QIODevice*> (context);
  14181. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  14182. setQByteArrayProperties(value,engine);
  14183. return value;
  14184. }
  14185. /*:86*//*87:*/
  14186. #line 2218 "./typica.w"
  14187. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  14188. {
  14189. QIODevice*self= getself<QIODevice*> (context);
  14190. QScriptValue value= engine->toScriptValue<QByteArray> (
  14191. self->peek(argument<int> (0,context)));
  14192. setQByteArrayProperties(value,engine);
  14193. return value;
  14194. }
  14195. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  14196. {
  14197. QIODevice*self= getself<QIODevice*> (context);
  14198. QScriptValue value= engine->toScriptValue<QByteArray> (
  14199. self->read(argument<int> (0,context)));
  14200. setQByteArrayProperties(value,engine);
  14201. return value;
  14202. }
  14203. /*:87*//*90:*/
  14204. #line 2263 "./typica.w"
  14205. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  14206. {
  14207. QScriptValue object= engine->newQObject(new QProcess);
  14208. setQProcessProperties(object,engine);
  14209. return object;
  14210. }
  14211. /*:90*//*91:*/
  14212. #line 2274 "./typica.w"
  14213. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  14214. {
  14215. setQIODeviceProperties(value,engine);
  14216. value.setProperty("execute",engine->newFunction(QProcess_execute));
  14217. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  14218. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  14219. value.setProperty("start",engine->newFunction(QProcess_start));
  14220. }
  14221. /*:91*//*92:*/
  14222. #line 2288 "./typica.w"
  14223. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  14224. {
  14225. QProcess*self= getself<QProcess*> (context);
  14226. QString program= argument<QString> (0,context);
  14227. QStringList arguments= QStringList();
  14228. if(context->argumentCount()> 1){
  14229. arguments= argument<QVariant> (1,context).toStringList();
  14230. }
  14231. int retval= self->execute(program,arguments);
  14232. return QScriptValue(retval);
  14233. }
  14234. /*:92*//*93:*/
  14235. #line 2303 "./typica.w"
  14236. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  14237. {
  14238. QProcess*self= getself<QProcess*> (context);
  14239. QString program= argument<QString> (0,context);
  14240. QStringList arguments= QStringList();
  14241. if(context->argumentCount()> 1){
  14242. arguments= argument<QVariant> (1,context).toStringList();
  14243. }
  14244. QString workingDirectory= "";
  14245. if(context->argumentCount()> 2){
  14246. workingDirectory= argument<QString> (2,context);
  14247. }
  14248. bool retval;
  14249. switch(context->argumentCount())
  14250. {
  14251. case 1:
  14252. retval= self->startDetached(program);
  14253. break;
  14254. case 2:
  14255. retval= self->startDetached(program,arguments);
  14256. break;
  14257. case 3:
  14258. retval= self->startDetached(program,arguments,workingDirectory);
  14259. break;
  14260. default:
  14261. retval= false;
  14262. }
  14263. return QScriptValue(retval);
  14264. }
  14265. /*:93*//*94:*/
  14266. #line 2336 "./typica.w"
  14267. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  14268. {
  14269. QProcess*self= getself<QProcess*> (context);
  14270. QString directory= argument<QString> (0,context);
  14271. self->setWorkingDirectory(directory);
  14272. return QScriptValue();
  14273. }
  14274. /*:94*//*95:*/
  14275. #line 2348 "./typica.w"
  14276. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  14277. {
  14278. QProcess*self= getself<QProcess*> (context);
  14279. QString program= argument<QString> (0,context);
  14280. QStringList arguments= QStringList();
  14281. if(context->argumentCount()> 1){
  14282. arguments= argument<QVariant> (1,context).toStringList();
  14283. }
  14284. self->start(program,arguments);
  14285. return QScriptValue();
  14286. }
  14287. /*:95*//*97:*/
  14288. #line 2389 "./typica.w"
  14289. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  14290. {
  14291. QScriptValue object= engine->newVariant(QVariant(bytes));
  14292. setQByteArrayProperties(object,engine);
  14293. return object;
  14294. }
  14295. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  14296. {
  14297. bytes= value.toVariant().toByteArray();
  14298. }
  14299. /*:97*//*99:*/
  14300. #line 2412 "./typica.w"
  14301. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  14302. {
  14303. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  14304. setQByteArrayProperties(object,engine);
  14305. return object;
  14306. }
  14307. /*:99*//*100:*/
  14308. #line 2423 "./typica.w"
  14309. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  14310. {
  14311. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  14312. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  14313. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  14314. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  14315. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  14316. value.setProperty("size",engine->newFunction(QByteArray_size));
  14317. value.setProperty("left",engine->newFunction(QByteArray_left));
  14318. value.setProperty("right",engine->newFunction(QByteArray_right));
  14319. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  14320. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  14321. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  14322. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  14323. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  14324. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  14325. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  14326. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  14327. }
  14328. /*:100*//*101:*/
  14329. #line 2447 "./typica.w"
  14330. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  14331. {
  14332. QByteArray self= getself<QByteArray> (context);
  14333. QByteArray retval;
  14334. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  14335. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  14336. setQByteArrayProperties(value,engine);
  14337. return value;
  14338. }
  14339. /*:101*//*102:*/
  14340. #line 2461 "./typica.w"
  14341. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  14342. {
  14343. QByteArray self= getself<QByteArray> (context);
  14344. return QScriptValue((int)(self.at(argument<int> (0,context))));
  14345. }
  14346. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  14347. {
  14348. QByteArray self= getself<QByteArray> (context);
  14349. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  14350. return QScriptValue();
  14351. }
  14352. /*:102*//*103:*/
  14353. #line 2479 "./typica.w"
  14354. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  14355. {
  14356. QByteArray self= getself<QByteArray> (context);
  14357. QScriptValue value=
  14358. engine->toScriptValue<QByteArray> (
  14359. self.append(argument<QByteArray> (0,context)));
  14360. setQByteArrayProperties(value,engine);
  14361. return value;
  14362. }
  14363. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  14364. {
  14365. QByteArray self= getself<QByteArray> (context);
  14366. QScriptValue value= engine->toScriptValue<QByteArray> (
  14367. self.append(argument<QString> (0,context)));
  14368. setQByteArrayProperties(value,engine);
  14369. return value;
  14370. }
  14371. /*:103*//*104:*/
  14372. #line 2501 "./typica.w"
  14373. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  14374. {
  14375. QByteArray self= getself<QByteArray> (context);
  14376. return QScriptValue(self.size());
  14377. }
  14378. /*:104*//*105:*/
  14379. #line 2511 "./typica.w"
  14380. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  14381. {
  14382. QByteArray self= getself<QByteArray> (context);
  14383. QScriptValue value= engine->toScriptValue<QByteArray> (
  14384. self.left(argument<int> (0,context)));
  14385. setQByteArrayProperties(value,engine);
  14386. return value;
  14387. }
  14388. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  14389. {
  14390. QByteArray self= getself<QByteArray> (context);
  14391. QScriptValue value= engine->toScriptValue<QByteArray> (
  14392. self.right(argument<int> (0,context)));
  14393. setQByteArrayProperties(value,engine);
  14394. return value;
  14395. }
  14396. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  14397. {
  14398. QByteArray self= getself<QByteArray> (context);
  14399. int length= -1;
  14400. if(context->argumentCount()> 1)
  14401. {
  14402. length= argument<int> (1,context);
  14403. }
  14404. QScriptValue value= engine->toScriptValue<QByteArray> (
  14405. self.mid(argument<int> (0,context),length));
  14406. setQByteArrayProperties(value,engine);
  14407. return value;
  14408. }
  14409. /*:105*//*106:*/
  14410. #line 2546 "./typica.w"
  14411. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  14412. {
  14413. QByteArray self= getself<QByteArray> (context);
  14414. self.chop(argument<int> (0,context));
  14415. return QScriptValue();
  14416. }
  14417. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  14418. {
  14419. QByteArray self= getself<QByteArray> (context);
  14420. QScriptValue value= engine->toScriptValue<QByteArray> (
  14421. self.remove(argument<int> (0,context),argument<int> (1,context)));
  14422. setQByteArrayProperties(value,engine);
  14423. return value;
  14424. }
  14425. /*:106*//*107:*/
  14426. #line 2569 "./typica.w"
  14427. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  14428. {
  14429. QByteArray self= getself<QByteArray> (context);
  14430. int value= 0;
  14431. char*bytes= (char*)&value;
  14432. bytes[0]= self[0];
  14433. return QScriptValue(value);
  14434. }
  14435. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  14436. {
  14437. QByteArray self= getself<QByteArray> (context);
  14438. int value= 0;
  14439. char*bytes= (char*)&value;
  14440. bytes[0]= self[0];
  14441. bytes[1]= self[1];
  14442. return QScriptValue(value);
  14443. }
  14444. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  14445. {
  14446. QByteArray self= getself<QByteArray> (context);
  14447. int value= 0;
  14448. char*bytes= (char*)&value;
  14449. bytes[0]= self[0];
  14450. bytes[1]= self[1];
  14451. bytes[2]= self[2];
  14452. bytes[3]= self[3];
  14453. return QScriptValue(value);
  14454. }
  14455. /*:107*//*108:*/
  14456. #line 2605 "./typica.w"
  14457. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  14458. {
  14459. QByteArray self= getself<QByteArray> (context);
  14460. float value= 0.0;
  14461. char*bytes= (char*)&value;
  14462. bytes[0]= self[0];
  14463. bytes[1]= self[1];
  14464. bytes[2]= self[2];
  14465. bytes[3]= self[3];
  14466. return QScriptValue(value);
  14467. }
  14468. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  14469. {
  14470. QByteArray self= getself<QByteArray> (context);
  14471. double value= 0.0;
  14472. char*bytes= (char*)&value;
  14473. bytes[0]= self[0];
  14474. bytes[1]= self[1];
  14475. bytes[2]= self[2];
  14476. bytes[3]= self[3];
  14477. bytes[4]= self[4];
  14478. bytes[5]= self[5];
  14479. bytes[6]= self[6];
  14480. bytes[7]= self[7];
  14481. return QScriptValue(value);
  14482. }
  14483. /*:108*//*111:*/
  14484. #line 2660 "./typica.w"
  14485. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  14486. {
  14487. qint8 value= (qint8)(argument<int> (0,context));
  14488. char*bytes= (char*)&value;
  14489. QByteArray retval;
  14490. retval.resize(1);
  14491. retval[0]= bytes[0];
  14492. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  14493. setQByteArrayProperties(v,engine);
  14494. return v;
  14495. }
  14496. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  14497. {
  14498. qint16 value= (qint16)(argument<int> (0,context));
  14499. char*bytes= (char*)&value;
  14500. QByteArray retval;
  14501. retval.resize(2);
  14502. retval[0]= bytes[0];
  14503. retval[1]= bytes[1];
  14504. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  14505. setQByteArrayProperties(v,engine);
  14506. return v;
  14507. }
  14508. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  14509. {
  14510. qint32 value= (qint32)(argument<int> (0,context));
  14511. char*bytes= (char*)&value;
  14512. QByteArray retval;
  14513. retval.resize(4);
  14514. retval[0]= bytes[0];
  14515. retval[1]= bytes[1];
  14516. retval[2]= bytes[2];
  14517. retval[3]= bytes[3];
  14518. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  14519. setQByteArrayProperties(v,engine);
  14520. return v;
  14521. }
  14522. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  14523. {
  14524. float value= (float)(argument<double> (0,context));
  14525. char*bytes= (char*)&value;
  14526. QByteArray retval;
  14527. retval.resize(4);
  14528. retval[0]= bytes[0];
  14529. retval[1]= bytes[1];
  14530. retval[2]= bytes[2];
  14531. retval[3]= bytes[3];
  14532. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  14533. setQByteArrayProperties(v,engine);
  14534. return v;
  14535. }
  14536. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  14537. {
  14538. double value= (double)(argument<double> (0,context));
  14539. char*bytes= (char*)&value;
  14540. QByteArray retval;
  14541. retval.resize(8);
  14542. retval[0]= bytes[0];
  14543. retval[1]= bytes[1];
  14544. retval[2]= bytes[2];
  14545. retval[3]= bytes[3];
  14546. retval[4]= bytes[4];
  14547. retval[5]= bytes[5];
  14548. retval[6]= bytes[6];
  14549. retval[7]= bytes[7];
  14550. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  14551. setQByteArrayProperties(v,engine);
  14552. return v;
  14553. }
  14554. /*:111*//*114:*/
  14555. #line 2757 "./typica.w"
  14556. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  14557. {
  14558. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  14559. QScriptValue object= engine->newQObject(new QBuffer(array));
  14560. setQBufferProperties(object,engine);
  14561. return object;
  14562. }
  14563. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  14564. {
  14565. setQIODeviceProperties(value,engine);
  14566. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  14567. }
  14568. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  14569. {
  14570. QBuffer*self= getself<QBuffer*> (context);
  14571. self->setData(argument<QString> (0,context).toAscii());
  14572. return QScriptValue();
  14573. }
  14574. /*:114*//*117:*/
  14575. #line 2806 "./typica.w"
  14576. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  14577. {
  14578. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  14579. setXQueryProperties(object,engine);
  14580. return object;
  14581. }
  14582. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  14583. {
  14584. QXmlQuery*self= getself<QXmlQuery*> (context);
  14585. delete self;
  14586. return QScriptValue();
  14587. }
  14588. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  14589. {
  14590. value.setProperty("bind",engine->newFunction(XQuery_bind));
  14591. value.setProperty("exec",engine->newFunction(XQuery_exec));
  14592. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  14593. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  14594. }
  14595. /*:117*//*118:*/
  14596. #line 2832 "./typica.w"
  14597. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  14598. {
  14599. QXmlQuery*self= getself<QXmlQuery*> (context);
  14600. QIODevice*buffer= argument<QIODevice*> (1,context);
  14601. self->bindVariable(argument<QString> (0,context),buffer);
  14602. return QScriptValue();
  14603. }
  14604. /*:118*//*119:*/
  14605. #line 2843 "./typica.w"
  14606. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  14607. {
  14608. QXmlQuery*self= getself<QXmlQuery*> (context);
  14609. self->setQuery(argument<QString> (0,context));
  14610. return QScriptValue();
  14611. }
  14612. /*:119*//*120:*/
  14613. #line 2853 "./typica.w"
  14614. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  14615. {
  14616. QXmlQuery*self= getself<QXmlQuery*> (context);
  14617. QString result;
  14618. self->evaluateTo(&result);
  14619. return QScriptValue(result);
  14620. }
  14621. /*:120*//*123:*/
  14622. #line 2908 "./typica.w"
  14623. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  14624. {
  14625. QXmlStreamWriter*retval;
  14626. if(context->argumentCount()==1)
  14627. {
  14628. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  14629. }
  14630. else
  14631. {
  14632. retval= new QXmlStreamWriter;
  14633. }
  14634. QScriptValue object= engine->toScriptValue<void*> (retval);
  14635. setXmlWriterProperties(object,engine);
  14636. return object;
  14637. }
  14638. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  14639. {
  14640. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  14641. value.setProperty("writeAttribute",
  14642. engine->newFunction(XmlWriter_writeAttribute));
  14643. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  14644. value.setProperty("writeCharacters",
  14645. engine->newFunction(XmlWriter_writeCharacters));
  14646. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  14647. value.setProperty("writeEmptyElement",
  14648. engine->newFunction(XmlWriter_writeEmptyElement));
  14649. value.setProperty("writeEndDocument",
  14650. engine->newFunction(XmlWriter_writeEndDocument));
  14651. value.setProperty("writeEndElement",
  14652. engine->newFunction(XmlWriter_writeEndElement));
  14653. value.setProperty("writeEntityReference",
  14654. engine->newFunction(XmlWriter_writeEntityReference));
  14655. value.setProperty("writeProcessingInstruction",
  14656. engine->newFunction(XmlWriter_writeProcessingInstruction));
  14657. value.setProperty("writeStartDocument",
  14658. engine->newFunction(XmlWriter_writeStartDocument));
  14659. value.setProperty("writeStartElement",
  14660. engine->newFunction(XmlWriter_writeStartElement));
  14661. value.setProperty("writeTextElement",
  14662. engine->newFunction(XmlWriter_writeTextElement));
  14663. }
  14664. /*:123*//*124:*/
  14665. #line 2955 "./typica.w"
  14666. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  14667. {
  14668. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14669. QIODevice*device= argument<QIODevice*> (0,context);
  14670. self->setDevice(device);
  14671. return QScriptValue();
  14672. }
  14673. /*:124*//*125:*/
  14674. #line 2969 "./typica.w"
  14675. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  14676. QScriptEngine*)
  14677. {
  14678. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14679. self->writeStartDocument(argument<QString> (0,context));
  14680. return QScriptValue();
  14681. }
  14682. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  14683. QScriptEngine*)
  14684. {
  14685. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14686. self->writeEndDocument();
  14687. return QScriptValue();
  14688. }
  14689. /*:125*//*126:*/
  14690. #line 2988 "./typica.w"
  14691. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  14692. {
  14693. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14694. self->writeDTD(argument<QString> (0,context));
  14695. return QScriptValue();
  14696. }
  14697. /*:126*//*127:*/
  14698. #line 2999 "./typica.w"
  14699. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  14700. QScriptEngine*)
  14701. {
  14702. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14703. self->writeStartElement(argument<QString> (0,context));
  14704. return QScriptValue();
  14705. }
  14706. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  14707. {
  14708. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14709. self->writeAttribute(argument<QString> (0,context),
  14710. argument<QString> (1,context));
  14711. return QScriptValue();
  14712. }
  14713. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  14714. {
  14715. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14716. self->writeCharacters(argument<QString> (0,context));
  14717. return QScriptValue();
  14718. }
  14719. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  14720. {
  14721. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14722. self->writeEndElement();
  14723. return QScriptValue();
  14724. }
  14725. /*:127*//*128:*/
  14726. #line 3035 "./typica.w"
  14727. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  14728. QScriptEngine*)
  14729. {
  14730. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14731. self->writeEmptyElement(argument<QString> (0,context));
  14732. return QScriptValue();
  14733. }
  14734. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  14735. QScriptEngine*)
  14736. {
  14737. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14738. self->writeTextElement(argument<QString> (0,context),
  14739. argument<QString> (1,context));
  14740. return QScriptValue();
  14741. }
  14742. /*:128*//*129:*/
  14743. #line 3056 "./typica.w"
  14744. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  14745. {
  14746. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14747. self->writeCDATA(argument<QString> (0,context));
  14748. return QScriptValue();
  14749. }
  14750. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  14751. QScriptEngine*)
  14752. {
  14753. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14754. self->writeEntityReference(argument<QString> (0,context));
  14755. return QScriptValue();
  14756. }
  14757. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  14758. QScriptEngine*)
  14759. {
  14760. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  14761. self->writeProcessingInstruction(argument<QString> (0,context),
  14762. argument<QString> (1,context));
  14763. return QScriptValue();
  14764. }
  14765. /*:129*//*132:*/
  14766. #line 3115 "./typica.w"
  14767. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  14768. {
  14769. QXmlStreamReader*retval=
  14770. new QXmlStreamReader(argument<QIODevice*> (0,context));
  14771. QScriptValue object= engine->toScriptValue<void*> (retval);
  14772. setXmlReaderProperties(object,engine);
  14773. return object;
  14774. }
  14775. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  14776. {
  14777. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  14778. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  14779. value.setProperty("hasAttribute",
  14780. engine->newFunction(XmlReader_hasAttribute));
  14781. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  14782. value.setProperty("isStartElement",
  14783. engine->newFunction(XmlReader_isStartElement));
  14784. value.setProperty("name",engine->newFunction(XmlReader_name));
  14785. value.setProperty("readElementText",
  14786. engine->newFunction(XmlReader_readElementText));
  14787. value.setProperty("readNext",
  14788. engine->newFunction(XmlReader_readNext));
  14789. value.setProperty("text",engine->newFunction(XmlReader_text));
  14790. }
  14791. /*:132*//*133:*/
  14792. #line 3145 "./typica.w"
  14793. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  14794. {
  14795. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14796. QString retval=
  14797. self->attributes().value(argument<QString> (0,context)).toString();
  14798. return QScriptValue(retval);
  14799. }
  14800. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  14801. {
  14802. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14803. bool retval=
  14804. self->attributes().hasAttribute(argument<QString> (0,context));
  14805. return QScriptValue(retval);
  14806. }
  14807. /*:133*//*134:*/
  14808. #line 3165 "./typica.w"
  14809. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  14810. {
  14811. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14812. return QScriptValue(self->atEnd());
  14813. }
  14814. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  14815. {
  14816. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14817. return QScriptValue(self->isDTD());
  14818. }
  14819. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  14820. {
  14821. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14822. return QScriptValue(self->isStartElement());
  14823. }
  14824. /*:134*//*135:*/
  14825. #line 3186 "./typica.w"
  14826. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  14827. {
  14828. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14829. self->readNext();
  14830. return QScriptValue();
  14831. }
  14832. /*:135*//*136:*/
  14833. #line 3196 "./typica.w"
  14834. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  14835. {
  14836. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14837. return QScriptValue(self->name().toString());
  14838. }
  14839. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  14840. {
  14841. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14842. return QScriptValue(self->readElementText());
  14843. }
  14844. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  14845. {
  14846. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  14847. return QScriptValue(self->text().toString());
  14848. }
  14849. /*:136*//*139:*/
  14850. #line 3238 "./typica.w"
  14851. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  14852. {
  14853. setQObjectProperties(value,engine);
  14854. value.setProperty("value",engine->newFunction(QSettings_value));
  14855. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  14856. }
  14857. /*:139*//*140:*/
  14858. #line 3250 "./typica.w"
  14859. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  14860. {
  14861. QScriptValue object;
  14862. if(context->argumentCount()==1||context->argumentCount()==2)
  14863. {
  14864. QSettings settings;
  14865. QString key= argument<QString> (0,context);
  14866. QVariant value;
  14867. QVariant retval;
  14868. if(context->argumentCount()> 1)
  14869. {
  14870. value= argument<QVariant> (1,context);
  14871. retval= settings.value(key,value);
  14872. }
  14873. else
  14874. {
  14875. retval= settings.value(key);
  14876. }
  14877. object= engine->newVariant(retval);
  14878. }
  14879. else
  14880. {
  14881. context->throwError("Incorrect number of arguments passed to "
  14882. "QSettings::value(). This method takes one "
  14883. "string and one optional variant type.");
  14884. }
  14885. return object;
  14886. }
  14887. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  14888. {
  14889. if(context->argumentCount()==2)
  14890. {
  14891. QSettings settings;
  14892. QString key= argument<QString> (0,context);
  14893. QVariant value= argument<QVariant> (1,context);
  14894. settings.setValue(key,value);
  14895. }
  14896. else
  14897. {
  14898. context->throwError("Incorrect number of arguments passed to "
  14899. "QSettings::setValue(). This method takes one "
  14900. "string and one variant type for a total of two "
  14901. "arguments.");
  14902. }
  14903. return QScriptValue();
  14904. }
  14905. /*:140*//*143:*/
  14906. #line 3319 "./typica.w"
  14907. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  14908. {
  14909. QScriptValue object= engine->newQObject(new QLCDNumber());
  14910. setQLCDNumberProperties(object,engine);
  14911. return object;
  14912. }
  14913. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  14914. {
  14915. setQFrameProperties(value,engine);
  14916. }
  14917. /*:143*//*146:*/
  14918. #line 3377 "./typica.w"
  14919. QScriptValue constructQTime(QScriptContext*context,
  14920. QScriptEngine*engine)
  14921. {
  14922. QScriptValue object;
  14923. if(context->argumentCount()==0||
  14924. (context->argumentCount()>=2&&context->argumentCount()<=4))
  14925. {
  14926. int arg1= 0;
  14927. int arg2= 0;
  14928. int arg3= 0;
  14929. int arg4= 0;
  14930. switch(context->argumentCount())
  14931. {
  14932. case 4:
  14933. arg4= argument<int> (3,context);
  14934. case 3:
  14935. arg3= argument<int> (2,context);
  14936. case 2:
  14937. arg2= argument<int> (1,context);
  14938. arg1= argument<int> (0,context);
  14939. default:
  14940. break;
  14941. }
  14942. if(context->argumentCount())
  14943. {
  14944. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  14945. arg4));
  14946. }
  14947. else
  14948. {
  14949. object= engine->toScriptValue<QTime> (QTime());
  14950. }
  14951. setQTimeProperties(object,engine);
  14952. }
  14953. else
  14954. {
  14955. context->throwError("Incorrect number of arguments passed to "
  14956. "QTime::QTime(). This method takes zero, two, "
  14957. "three, or four integer arguments.");
  14958. }
  14959. return object;
  14960. }
  14961. /*:146*//*147:*/
  14962. #line 3425 "./typica.w"
  14963. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  14964. {
  14965. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  14966. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  14967. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  14968. value.setProperty("hour",engine->newFunction(QTime_hour));
  14969. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  14970. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  14971. value.setProperty("minute",engine->newFunction(QTime_minute));
  14972. value.setProperty("msec",engine->newFunction(QTime_msec));
  14973. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  14974. value.setProperty("restart",engine->newFunction(QTime_restart));
  14975. value.setProperty("second",engine->newFunction(QTime_second));
  14976. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  14977. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  14978. value.setProperty("start",engine->newFunction(QTime_start));
  14979. value.setProperty("toString",engine->newFunction(QTime_toString));
  14980. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  14981. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  14982. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  14983. }
  14984. /*:147*//*148:*/
  14985. #line 3454 "./typica.w"
  14986. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  14987. {
  14988. QTime self= getself<QTime> (context);
  14989. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  14990. (self.second()*1000)+self.msec();
  14991. return QScriptValue(retval);
  14992. }
  14993. /*:148*//*149:*/
  14994. #line 3468 "./typica.w"
  14995. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  14996. {
  14997. QTime time;
  14998. QScriptValue retval;
  14999. if(context->argumentCount()==1)
  15000. {
  15001. QTime self= getself<QTime> (context);
  15002. time= self.addMSecs(argument<int> (0,context));
  15003. retval= engine->toScriptValue<QTime> (time);
  15004. setQTimeProperties(retval,engine);
  15005. }
  15006. else
  15007. {
  15008. context->throwError("Incorrect number of arguments passed to "
  15009. "QTime::addMSecs(). This method takes one "
  15010. "integer as an argument.");
  15011. }
  15012. return retval;
  15013. }
  15014. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  15015. {
  15016. QTime time;
  15017. QScriptValue retval;
  15018. if(context->argumentCount()==1)
  15019. {
  15020. QTime self= getself<QTime> (context);
  15021. time= self.addSecs(argument<int> (0,context));
  15022. retval= engine->toScriptValue<QTime> (time);
  15023. setQTimeProperties(retval,engine);
  15024. }
  15025. else
  15026. {
  15027. context->throwError("Incorrect number of arguments passed to "
  15028. "QTime::addSecs(). This method takes one "
  15029. "integer as an argument.");
  15030. }
  15031. return retval;
  15032. }
  15033. /*:149*//*150:*/
  15034. #line 3511 "./typica.w"
  15035. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  15036. {
  15037. QScriptValue retval;
  15038. if(context->argumentCount()==0)
  15039. {
  15040. QTime self= getself<QTime> (context);
  15041. retval= QScriptValue(engine,self.elapsed());
  15042. }
  15043. else
  15044. {
  15045. context->throwError("Incorrect number of arguments passed to "
  15046. "QTime::elapsed(). This method takes no "
  15047. "arguments.");
  15048. }
  15049. return retval;
  15050. }
  15051. /*:150*//*151:*/
  15052. #line 3532 "./typica.w"
  15053. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  15054. {
  15055. QScriptValue retval;
  15056. if(context->argumentCount()==0)
  15057. {
  15058. QTime self= getself<QTime> (context);
  15059. retval= QScriptValue(engine,self.hour());
  15060. }
  15061. else
  15062. {
  15063. context->throwError("Incorrect number of arguments passed to "
  15064. "QTime::hour(). This method takes no "
  15065. "arguments.");
  15066. }
  15067. return retval;
  15068. }
  15069. /*:151*//*152:*/
  15070. #line 3552 "./typica.w"
  15071. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  15072. {
  15073. QScriptValue retval;
  15074. if(context->argumentCount()==0)
  15075. {
  15076. QTime self= getself<QTime> (context);
  15077. retval= QScriptValue(engine,self.minute());
  15078. }
  15079. else
  15080. {
  15081. context->throwError("Incorrect number of arguments passed to "
  15082. "QTime::minute(). This method takes no "
  15083. "arguments.");
  15084. }
  15085. return retval;
  15086. }
  15087. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  15088. {
  15089. QScriptValue retval;
  15090. if(context->argumentCount()==0)
  15091. {
  15092. QTime self= getself<QTime> (context);
  15093. retval= QScriptValue(engine,self.second());
  15094. }
  15095. else
  15096. {
  15097. context->throwError("Incorrect number of arguments passed to "
  15098. "QTime::second(). This method takes no "
  15099. "arguments.");
  15100. }
  15101. return retval;
  15102. }
  15103. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  15104. {
  15105. QScriptValue retval;
  15106. if(context->argumentCount()==0)
  15107. {
  15108. QTime self= getself<QTime> (context);
  15109. retval= QScriptValue(engine,self.msec());
  15110. }
  15111. else
  15112. {
  15113. context->throwError("Incorrect number of arguments passed to "
  15114. "QTime::msec(). This method takes no "
  15115. "arguments.");
  15116. }
  15117. return retval;
  15118. }
  15119. /*:152*//*153:*/
  15120. #line 3608 "./typica.w"
  15121. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  15122. {
  15123. QScriptValue retval;
  15124. if(context->argumentCount()==0)
  15125. {
  15126. QTime self= getself<QTime> (context);
  15127. retval= QScriptValue(engine,self.isNull());
  15128. }
  15129. else
  15130. {
  15131. context->throwError("Incorrect number of arguments passed to "
  15132. "QTime::isNull(). This method takes no "
  15133. "arguments.");
  15134. }
  15135. return retval;
  15136. }
  15137. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  15138. {
  15139. QScriptValue retval;
  15140. if(context->argumentCount()==0)
  15141. {
  15142. QTime self= getself<QTime> (context);
  15143. retval= QScriptValue(engine,self.isValid());
  15144. }
  15145. else
  15146. {
  15147. context->throwError("Incorrect number of arguments passed to "
  15148. "QTime::isValid(). This method takes no "
  15149. "arguments.");
  15150. }
  15151. return retval;
  15152. }
  15153. /*:153*//*154:*/
  15154. #line 3646 "./typica.w"
  15155. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  15156. {
  15157. QScriptValue retval;
  15158. if(context->argumentCount()==1)
  15159. {
  15160. QTime self= getself<QTime> (context);
  15161. QTime arg= argument<QVariant> (0,context).toTime();
  15162. retval= QScriptValue(engine,self.msecsTo(arg));
  15163. }
  15164. else
  15165. {
  15166. context->throwError("Incorrect number of arguments passed to "
  15167. "QTime::msecsTo(). This method takes one QTime.");
  15168. }
  15169. return retval;
  15170. }
  15171. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  15172. {
  15173. QScriptValue retval;
  15174. if(context->argumentCount()==1)
  15175. {
  15176. QTime self= getself<QTime> (context);
  15177. QTime arg= argument<QVariant> (0,context).toTime();
  15178. retval= QScriptValue(engine,self.secsTo(arg));
  15179. }
  15180. else
  15181. {
  15182. context->throwError("Incorrect number of arguments passed to "
  15183. "QTime::secsTo(). This method takes one QTime.");
  15184. }
  15185. return retval;
  15186. }
  15187. /*:154*//*155:*/
  15188. #line 3685 "./typica.w"
  15189. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  15190. {
  15191. QScriptValue retval;
  15192. if(context->argumentCount()==0)
  15193. {
  15194. QTime self= getself<QTime> (context);
  15195. retval= QScriptValue(engine,self.restart());
  15196. }
  15197. else
  15198. {
  15199. context->throwError("Incorrect number of arguments passed to "
  15200. "QTime::restart(). This method takes no "
  15201. "arguments.");
  15202. }
  15203. return retval;
  15204. }
  15205. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  15206. {
  15207. if(context->argumentCount()==0)
  15208. {
  15209. QTime self= getself<QTime> (context);
  15210. self.start();
  15211. }
  15212. else
  15213. {
  15214. context->throwError("Incorrect number of arguments passed to "
  15215. "QTime::start(). This method takes no arguments.");
  15216. }
  15217. return QScriptValue();
  15218. }
  15219. /*:155*//*156:*/
  15220. #line 3721 "./typica.w"
  15221. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  15222. {
  15223. QScriptValue retval;
  15224. if(context->argumentCount()==3||context->argumentCount()==4)
  15225. {
  15226. QTime self= getself<QTime> (context);
  15227. int arg1= 0;
  15228. int arg2= 0;
  15229. int arg3= 0;
  15230. int arg4= 0;
  15231. switch(context->argumentCount())
  15232. {
  15233. case 4:
  15234. arg4= argument<int> (3,context);
  15235. case 3:
  15236. arg3= argument<int> (2,context);
  15237. arg2= argument<int> (1,context);
  15238. arg1= argument<int> (0,context);
  15239. default:
  15240. break;
  15241. }
  15242. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  15243. }
  15244. else
  15245. {
  15246. context->throwError("Incorrect number of arguments passed to "
  15247. "QTime::setHMS(). This method takes three or "
  15248. "four integer arguments.");
  15249. }
  15250. return retval;
  15251. }
  15252. /*:156*//*157:*/
  15253. #line 3757 "./typica.w"
  15254. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  15255. {
  15256. QScriptValue retval;
  15257. if(context->argumentCount()==1)
  15258. {
  15259. QTime self= getself<QTime> (context);
  15260. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  15261. }
  15262. else
  15263. {
  15264. context->throwError("Incorrect number of arguments passed to "
  15265. "QTime::toString(). This method takes one QString "
  15266. "as an argument.");
  15267. }
  15268. return retval;
  15269. }
  15270. /*:157*//*158:*/
  15271. #line 3778 "./typica.w"
  15272. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  15273. {
  15274. QScriptValue object;
  15275. object= engine->toScriptValue<QTime> (QTime::currentTime());
  15276. setQTimeProperties(object,engine);
  15277. return object;
  15278. }
  15279. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  15280. {
  15281. QScriptValue object;
  15282. if(context->argumentCount()==2)
  15283. {
  15284. QString time= argument<QString> (0,context);
  15285. QString format= argument<QString> (1,context);
  15286. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  15287. setQTimeProperties(object,engine);
  15288. }
  15289. else
  15290. {
  15291. context->throwError("Incorrect number of arguments passed to "
  15292. "QTime::fromString(). This method takes two "
  15293. "string arguments.");
  15294. }
  15295. return object;
  15296. }
  15297. /*:158*//*159:*/
  15298. #line 3809 "./typica.w"
  15299. template<> QTime argument(int arg,QScriptContext*context)
  15300. {
  15301. return qscriptvalue_cast<QTime> (context->argument(arg));
  15302. }
  15303. /*:159*//*161:*/
  15304. #line 3827 "./typica.w"
  15305. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  15306. {
  15307. setQFrameProperties(value,engine);
  15308. }
  15309. /*:161*//*163:*/
  15310. #line 3841 "./typica.w"
  15311. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  15312. {
  15313. setQAbstractScrollAreaProperties(value,engine);
  15314. }
  15315. /*:163*//*165:*/
  15316. #line 3855 "./typica.w"
  15317. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  15318. {
  15319. setQAbstractScrollAreaProperties(value,engine);
  15320. }
  15321. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  15322. {
  15323. setQAbstractItemViewProperties(value,engine);
  15324. }
  15325. /*:165*//*168:*/
  15326. #line 3888 "./typica.w"
  15327. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  15328. {
  15329. QScriptValue object= engine->newQObject(new QPushButton());
  15330. setQPushButtonProperties(object,engine);
  15331. return object;
  15332. }
  15333. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  15334. {
  15335. setQAbstractButtonProperties(value,engine);
  15336. }
  15337. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  15338. {
  15339. setQWidgetProperties(value,engine);
  15340. }
  15341. /*:168*//*175:*/
  15342. #line 4000 "./typica.w"
  15343. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  15344. {
  15345. SqlQueryConnection*obj= new SqlQueryConnection();
  15346. QScriptValue object=
  15347. engine->toScriptValue<void*> (obj);
  15348. setQSqlQueryProperties(object,engine);
  15349. return object;
  15350. }
  15351. /*:175*//*176:*/
  15352. #line 4013 "./typica.w"
  15353. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  15354. {
  15355. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  15356. value.setProperty("bindFileData",
  15357. engine->newFunction(QSqlQuery_bindFileData));
  15358. value.setProperty("bindDeviceData",
  15359. engine->newFunction(QSqlQuery_bindDeviceData));
  15360. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  15361. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  15362. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  15363. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  15364. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  15365. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  15366. }
  15367. /*:176*//*177:*/
  15368. #line 4031 "./typica.w"
  15369. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  15370. {
  15371. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  15372. QScriptValue retval;
  15373. if(context->argumentCount()==1)
  15374. {
  15375. retval= QScriptValue(engine,
  15376. q->exec(argument<QString> (0,context)));
  15377. }
  15378. else
  15379. {
  15380. retval= QScriptValue(engine,q->exec());
  15381. }
  15382. if(q->lastError().isValid())
  15383. {
  15384. qDebug()<<q->lastQuery();
  15385. qDebug()<<q->lastError().text();
  15386. }
  15387. return retval;
  15388. }
  15389. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  15390. {
  15391. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15392. return QScriptValue(query->lastQuery());
  15393. }
  15394. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  15395. {
  15396. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15397. return QScriptValue(engine,query->next());
  15398. }
  15399. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  15400. {
  15401. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15402. return QScriptValue(engine,
  15403. query->value(argument<int> (0,context)).toString());
  15404. }
  15405. /*:177*//*178:*/
  15406. #line 4075 "./typica.w"
  15407. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  15408. {
  15409. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15410. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  15411. }
  15412. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  15413. {
  15414. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15415. query->bindValue(argument<QString> (0,context),
  15416. argument<QVariant> (1,context));
  15417. return QScriptValue();
  15418. }
  15419. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  15420. QScriptEngine*)
  15421. {
  15422. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15423. QString placeholder= argument<QString> (0,context);
  15424. QString filename= argument<QString> (1,context);
  15425. QFile file(filename);
  15426. QByteArray data;
  15427. if(file.open(QIODevice::ReadOnly))
  15428. {
  15429. data= file.readAll();
  15430. file.close();
  15431. }
  15432. query->bindValue(placeholder,data);
  15433. return QScriptValue();
  15434. }
  15435. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  15436. QScriptEngine*)
  15437. {
  15438. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15439. QString placeholder= argument<QString> (0,context);
  15440. QIODevice*device= argument<QIODevice*> (1,context);
  15441. device->reset();
  15442. QByteArray data;
  15443. data= device->readAll();
  15444. query->bindValue(placeholder,data);
  15445. return QScriptValue();
  15446. }
  15447. /*:178*//*179:*/
  15448. #line 4127 "./typica.w"
  15449. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  15450. {
  15451. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  15452. delete query;
  15453. return QScriptValue::UndefinedValue;
  15454. }
  15455. /*:179*//*182:*/
  15456. #line 4174 "./typica.w"
  15457. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  15458. {
  15459. QFileInfo info(argument<QString> (0,context));
  15460. QScriptValue retval(engine,info.baseName());
  15461. return retval;
  15462. }
  15463. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  15464. {
  15465. QFileInfo info(argument<QString> (0,context));
  15466. QDir dir= info.dir();
  15467. QScriptValue retval(engine,dir.path());
  15468. return retval;
  15469. }
  15470. /*:182*//*183:*/
  15471. #line 4193 "./typica.w"
  15472. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  15473. {
  15474. SqlQueryConnection h;
  15475. QSqlQuery*query= h.operator->();
  15476. QString q= "SELECT file FROM files WHERE id = :file";
  15477. query->prepare(q);
  15478. query->bindValue(":file",argument<int> (0,context));
  15479. query->exec();
  15480. query->next();
  15481. QByteArray array= query->value(0).toByteArray();
  15482. QFile file(argument<QString> (1,context));
  15483. file.open(QIODevice::WriteOnly);
  15484. file.write(array);
  15485. file.close();
  15486. return QScriptValue();
  15487. }
  15488. /*:183*//*184:*/
  15489. #line 4214 "./typica.w"
  15490. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  15491. {
  15492. QString source= argument<QString> (0,context);
  15493. source.remove(0,1);
  15494. source.chop(1);
  15495. QStringList elements= source.split(",");
  15496. QString element;
  15497. QScriptValue dest= engine->newArray(elements.size());
  15498. int i= 0;
  15499. foreach(element,elements)
  15500. {
  15501. if(element.startsWith("\"")&&element.endsWith("\""))
  15502. {
  15503. element.chop(1);
  15504. element= element.remove(0,1);
  15505. }
  15506. dest.setProperty(i,QScriptValue(engine,element));
  15507. i++;
  15508. }
  15509. return dest;
  15510. }
  15511. /*:184*//*185:*/
  15512. #line 4240 "./typica.w"
  15513. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  15514. {
  15515. QString font= argument<QString> (0,context);
  15516. QString classname;
  15517. if(context->argumentCount()> 1)
  15518. {
  15519. classname= argument<QString> (1,context);
  15520. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  15521. }
  15522. else
  15523. {
  15524. QApplication::setFont(QFont(font));
  15525. }
  15526. return QScriptValue();
  15527. }
  15528. /*:185*//*186:*/
  15529. #line 4260 "./typica.w"
  15530. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  15531. {
  15532. SqlQueryConnection h;
  15533. QSqlQuery*query= h.operator->();
  15534. QString q= "SELECT file FROM files WHERE id = :file";
  15535. query->prepare(q);
  15536. query->bindValue(":file",argument<int> (0,context));
  15537. query->exec();
  15538. query->next();
  15539. QByteArray array= query->value(0).toByteArray();
  15540. QBuffer buffer(&array);
  15541. buffer.open(QIODevice::ReadOnly);
  15542. QXmlQuery xquery;
  15543. xquery.bindVariable("profile",&buffer);
  15544. QString xq;
  15545. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  15546. xquery.setQuery(xq);
  15547. QString result;
  15548. xquery.evaluateTo(&result);
  15549. return QScriptValue(result);
  15550. }
  15551. /*:186*//*187:*/
  15552. #line 4287 "./typica.w"
  15553. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  15554. {
  15555. QWidget::setTabOrder(argument<QWidget*> (0,context),
  15556. argument<QWidget*> (1,context));
  15557. return QScriptValue();
  15558. }
  15559. /*:187*//*188:*/
  15560. #line 4298 "./typica.w"
  15561. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  15562. {
  15563. return QScriptValue(QCoreApplication::translate(
  15564. argument<QString> (0,context).toAscii().data(),
  15565. argument<QString> (1,context).toUtf8().data()));
  15566. }
  15567. /*:188*//*195:*/
  15568. #line 4549 "./typica.w"
  15569. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  15570. {
  15571. QString targetID= argument<QString> (0,context);
  15572. QDomNode element;
  15573. QScriptValue object;
  15574. /*197:*/
  15575. #line 4596 "./typica.w"
  15576. QDomNodeList windows=
  15577. AppInstance->configuration()->documentElement().elementsByTagName("window");
  15578. QDomNode nullNode;
  15579. int i= 0;
  15580. element= nullNode;
  15581. while(i<windows.count())
  15582. {
  15583. element= windows.at(i);
  15584. QDomNamedNodeMap attributes= element.attributes();
  15585. if(attributes.contains("id"))
  15586. {
  15587. if(attributes.namedItem("id").toAttr().value()==targetID)
  15588. {
  15589. break;
  15590. }
  15591. }
  15592. element= nullNode;
  15593. i++;
  15594. }
  15595. /*:197*/
  15596. #line 4555 "./typica.w"
  15597. if(!element.isNull())
  15598. {
  15599. /*198:*/
  15600. #line 4628 "./typica.w"
  15601. ScriptQMainWindow*window= new ScriptQMainWindow;
  15602. window->setObjectName(targetID);
  15603. object= engine->newQObject(window);
  15604. setQMainWindowProperties(object,engine);
  15605. QWidget*central= new(QWidget);
  15606. central->setParent(window);
  15607. central->setObjectName("centralWidget");
  15608. window->setCentralWidget(central);
  15609. if(element.hasChildNodes())
  15610. {
  15611. /*199:*/
  15612. #line 4663 "./typica.w"
  15613. QStack<QWidget*> widgetStack;
  15614. QStack<QLayout*> layoutStack;
  15615. QString windowScript;
  15616. widgetStack.push(central);
  15617. QDomNodeList windowChildren= element.childNodes();
  15618. int i= 0;
  15619. while(i<windowChildren.count())
  15620. {
  15621. QDomNode current;
  15622. QDomElement element;
  15623. current= windowChildren.at(i);
  15624. if(current.isElement())
  15625. {
  15626. element= current.toElement();
  15627. if(element.tagName()=="program")
  15628. {
  15629. windowScript.append(element.text());
  15630. }
  15631. else if(element.tagName()=="layout")
  15632. {
  15633. element.setAttribute("trcontext","configuration");
  15634. addLayoutToWidget(element,&widgetStack,&layoutStack);
  15635. }
  15636. else if(element.tagName()=="menu")
  15637. {
  15638. /*200:*/
  15639. #line 4711 "./typica.w"
  15640. QMenuBar*bar= window->menuBar();
  15641. bar->setParent(window);
  15642. bar->setObjectName("menuBar");
  15643. if(element.hasAttribute("name"))
  15644. {
  15645. QMenu*menu= bar->addMenu(QCoreApplication::translate(targetID.toAscii().data(),
  15646. element.attribute("name").toUtf8().data()));
  15647. menu->setParent(bar);
  15648. if(element.hasAttribute("type"))
  15649. {
  15650. if(element.attribute("type")=="reports")
  15651. {
  15652. if(element.hasAttribute("src"))
  15653. {
  15654. /*640:*/
  15655. #line 13838 "./typica.w"
  15656. QSettings settings;
  15657. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  15658. toString()).
  15659. arg(element.attribute("src"));
  15660. QDir::addSearchPath("reports",reportDirectory);
  15661. QDir directory(reportDirectory);
  15662. directory.setFilter(QDir::Files);
  15663. directory.setSorting(QDir::Name);
  15664. QStringList nameFilter;
  15665. nameFilter<<"*.xml";
  15666. directory.setNameFilters(nameFilter);
  15667. QFileInfoList reportFiles= directory.entryInfoList();
  15668. for(int i= 0;i<reportFiles.size();i++)
  15669. {
  15670. QFileInfo reportFile= reportFiles.at(i);
  15671. /*644:*/
  15672. #line 13918 "./typica.w"
  15673. QString path= reportFile.absoluteFilePath();
  15674. QFile file(path);
  15675. if(file.open(QIODevice::ReadOnly))
  15676. {
  15677. QDomDocument document;
  15678. document.setContent(&file,true);
  15679. QDomElement root= document.documentElement();
  15680. QString translationContext= root.attribute("id");
  15681. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  15682. if(!titleNode.isNull())
  15683. {
  15684. QDomElement titleElement= titleNode.toElement();
  15685. QString title= QCoreApplication::translate(translationContext.toAscii().data(),
  15686. titleElement.text().toUtf8().data());
  15687. if(!title.isEmpty())
  15688. {
  15689. QStringList hierarchy= title.split(":->");
  15690. QMenu*insertionPoint= menu;
  15691. /*645:*/
  15692. #line 13947 "./typica.w"
  15693. for(int j= 0;j<hierarchy.size()-1;j++)
  15694. {
  15695. QObjectList menuList= insertionPoint->children();
  15696. bool menuFound= false;
  15697. for(int k= 0;k<menuList.size();k++)
  15698. {
  15699. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  15700. if(currentItem)
  15701. {
  15702. if(currentItem->title()==hierarchy.at(j))
  15703. {
  15704. menuFound= true;
  15705. insertionPoint= currentItem;
  15706. break;
  15707. }
  15708. }
  15709. }
  15710. if(!menuFound)
  15711. {
  15712. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  15713. }
  15714. }
  15715. /*:645*/
  15716. #line 13937 "./typica.w"
  15717. ReportAction*action= new ReportAction(path,hierarchy.last());
  15718. insertionPoint->addAction(action);
  15719. }
  15720. }
  15721. }
  15722. /*:644*/
  15723. #line 13854 "./typica.w"
  15724. }
  15725. /*:640*/
  15726. #line 4726 "./typica.w"
  15727. }
  15728. }
  15729. }
  15730. if(element.hasChildNodes())
  15731. {
  15732. /*201:*/
  15733. #line 4739 "./typica.w"
  15734. QDomNodeList menuItems= element.childNodes();
  15735. int j= 0;
  15736. while(j<menuItems.count())
  15737. {
  15738. QDomNode item= menuItems.at(j);
  15739. if(item.isElement())
  15740. {
  15741. QDomElement itemElement= item.toElement();
  15742. if(itemElement.tagName()=="item")
  15743. {
  15744. QAction*itemAction= new QAction(QCoreApplication::translate(targetID.toAscii().data(),
  15745. itemElement.text().toUtf8().data()),menu);
  15746. if(itemElement.hasAttribute("id"))
  15747. {
  15748. itemAction->setObjectName(itemElement.attribute("id"));
  15749. }
  15750. if(itemElement.hasAttribute("shortcut"))
  15751. {
  15752. itemAction->setShortcut(itemElement.attribute("shortcut"));
  15753. }
  15754. menu->addAction(itemAction);
  15755. }
  15756. else if(itemElement.tagName()=="separator")
  15757. {
  15758. menu->addSeparator();
  15759. }
  15760. }
  15761. j++;
  15762. }
  15763. #line 1 "./helpmenu.w"
  15764. /*:201*/
  15765. #line 4732 "./typica.w"
  15766. }
  15767. }
  15768. /*:200*/
  15769. #line 4689 "./typica.w"
  15770. }
  15771. }
  15772. i++;
  15773. }
  15774. QScriptValue oldThis= context->thisObject();
  15775. context->setThisObject(object);
  15776. QScriptValue result= engine->evaluate(windowScript);
  15777. /*192:*/
  15778. #line 4445 "./typica.w"
  15779. if(engine->hasUncaughtException())
  15780. {
  15781. int line= engine->uncaughtExceptionLineNumber();
  15782. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  15783. result.toString();
  15784. QString trace;
  15785. foreach(trace,engine->uncaughtExceptionBacktrace())
  15786. {
  15787. qDebug()<<trace;
  15788. }
  15789. }
  15790. /*:192*/
  15791. #line 4697 "./typica.w"
  15792. context->setThisObject(oldThis);
  15793. /*:199*/
  15794. #line 4639 "./typica.w"
  15795. }
  15796. /*202:*/
  15797. #line 9 "./helpmenu.w"
  15798. HelpMenu*helpMenu= new HelpMenu();
  15799. window->menuBar()->addMenu(helpMenu);
  15800. /*:202*/
  15801. #line 4641 "./typica.w"
  15802. window->show();
  15803. /*:198*/
  15804. #line 4558 "./typica.w"
  15805. }
  15806. return object;
  15807. }
  15808. /*:195*//*196:*/
  15809. #line 4569 "./typica.w"
  15810. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  15811. {
  15812. QString targetID= argument<QString> (0,context);
  15813. QFile file(QString("reports:%1").arg(targetID));
  15814. QScriptValue object;
  15815. if(file.open(QIODevice::ReadOnly))
  15816. {
  15817. QDomDocument document;
  15818. document.setContent(&file,true);
  15819. QDomElement element= document.documentElement();
  15820. if(!element.isNull())
  15821. {
  15822. /*198:*/
  15823. #line 4628 "./typica.w"
  15824. ScriptQMainWindow*window= new ScriptQMainWindow;
  15825. window->setObjectName(targetID);
  15826. object= engine->newQObject(window);
  15827. setQMainWindowProperties(object,engine);
  15828. QWidget*central= new(QWidget);
  15829. central->setParent(window);
  15830. central->setObjectName("centralWidget");
  15831. window->setCentralWidget(central);
  15832. if(element.hasChildNodes())
  15833. {
  15834. /*199:*/
  15835. #line 4663 "./typica.w"
  15836. QStack<QWidget*> widgetStack;
  15837. QStack<QLayout*> layoutStack;
  15838. QString windowScript;
  15839. widgetStack.push(central);
  15840. QDomNodeList windowChildren= element.childNodes();
  15841. int i= 0;
  15842. while(i<windowChildren.count())
  15843. {
  15844. QDomNode current;
  15845. QDomElement element;
  15846. current= windowChildren.at(i);
  15847. if(current.isElement())
  15848. {
  15849. element= current.toElement();
  15850. if(element.tagName()=="program")
  15851. {
  15852. windowScript.append(element.text());
  15853. }
  15854. else if(element.tagName()=="layout")
  15855. {
  15856. element.setAttribute("trcontext","configuration");
  15857. addLayoutToWidget(element,&widgetStack,&layoutStack);
  15858. }
  15859. else if(element.tagName()=="menu")
  15860. {
  15861. /*200:*/
  15862. #line 4711 "./typica.w"
  15863. QMenuBar*bar= window->menuBar();
  15864. bar->setParent(window);
  15865. bar->setObjectName("menuBar");
  15866. if(element.hasAttribute("name"))
  15867. {
  15868. QMenu*menu= bar->addMenu(QCoreApplication::translate(targetID.toAscii().data(),
  15869. element.attribute("name").toUtf8().data()));
  15870. menu->setParent(bar);
  15871. if(element.hasAttribute("type"))
  15872. {
  15873. if(element.attribute("type")=="reports")
  15874. {
  15875. if(element.hasAttribute("src"))
  15876. {
  15877. /*640:*/
  15878. #line 13838 "./typica.w"
  15879. QSettings settings;
  15880. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  15881. toString()).
  15882. arg(element.attribute("src"));
  15883. QDir::addSearchPath("reports",reportDirectory);
  15884. QDir directory(reportDirectory);
  15885. directory.setFilter(QDir::Files);
  15886. directory.setSorting(QDir::Name);
  15887. QStringList nameFilter;
  15888. nameFilter<<"*.xml";
  15889. directory.setNameFilters(nameFilter);
  15890. QFileInfoList reportFiles= directory.entryInfoList();
  15891. for(int i= 0;i<reportFiles.size();i++)
  15892. {
  15893. QFileInfo reportFile= reportFiles.at(i);
  15894. /*644:*/
  15895. #line 13918 "./typica.w"
  15896. QString path= reportFile.absoluteFilePath();
  15897. QFile file(path);
  15898. if(file.open(QIODevice::ReadOnly))
  15899. {
  15900. QDomDocument document;
  15901. document.setContent(&file,true);
  15902. QDomElement root= document.documentElement();
  15903. QString translationContext= root.attribute("id");
  15904. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  15905. if(!titleNode.isNull())
  15906. {
  15907. QDomElement titleElement= titleNode.toElement();
  15908. QString title= QCoreApplication::translate(translationContext.toAscii().data(),
  15909. titleElement.text().toUtf8().data());
  15910. if(!title.isEmpty())
  15911. {
  15912. QStringList hierarchy= title.split(":->");
  15913. QMenu*insertionPoint= menu;
  15914. /*645:*/
  15915. #line 13947 "./typica.w"
  15916. for(int j= 0;j<hierarchy.size()-1;j++)
  15917. {
  15918. QObjectList menuList= insertionPoint->children();
  15919. bool menuFound= false;
  15920. for(int k= 0;k<menuList.size();k++)
  15921. {
  15922. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  15923. if(currentItem)
  15924. {
  15925. if(currentItem->title()==hierarchy.at(j))
  15926. {
  15927. menuFound= true;
  15928. insertionPoint= currentItem;
  15929. break;
  15930. }
  15931. }
  15932. }
  15933. if(!menuFound)
  15934. {
  15935. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  15936. }
  15937. }
  15938. /*:645*/
  15939. #line 13937 "./typica.w"
  15940. ReportAction*action= new ReportAction(path,hierarchy.last());
  15941. insertionPoint->addAction(action);
  15942. }
  15943. }
  15944. }
  15945. /*:644*/
  15946. #line 13854 "./typica.w"
  15947. }
  15948. /*:640*/
  15949. #line 4726 "./typica.w"
  15950. }
  15951. }
  15952. }
  15953. if(element.hasChildNodes())
  15954. {
  15955. /*201:*/
  15956. #line 4739 "./typica.w"
  15957. QDomNodeList menuItems= element.childNodes();
  15958. int j= 0;
  15959. while(j<menuItems.count())
  15960. {
  15961. QDomNode item= menuItems.at(j);
  15962. if(item.isElement())
  15963. {
  15964. QDomElement itemElement= item.toElement();
  15965. if(itemElement.tagName()=="item")
  15966. {
  15967. QAction*itemAction= new QAction(QCoreApplication::translate(targetID.toAscii().data(),
  15968. itemElement.text().toUtf8().data()),menu);
  15969. if(itemElement.hasAttribute("id"))
  15970. {
  15971. itemAction->setObjectName(itemElement.attribute("id"));
  15972. }
  15973. if(itemElement.hasAttribute("shortcut"))
  15974. {
  15975. itemAction->setShortcut(itemElement.attribute("shortcut"));
  15976. }
  15977. menu->addAction(itemAction);
  15978. }
  15979. else if(itemElement.tagName()=="separator")
  15980. {
  15981. menu->addSeparator();
  15982. }
  15983. }
  15984. j++;
  15985. }
  15986. #line 1 "./helpmenu.w"
  15987. /*:201*/
  15988. #line 4732 "./typica.w"
  15989. }
  15990. }
  15991. /*:200*/
  15992. #line 4689 "./typica.w"
  15993. }
  15994. }
  15995. i++;
  15996. }
  15997. QScriptValue oldThis= context->thisObject();
  15998. context->setThisObject(object);
  15999. QScriptValue result= engine->evaluate(windowScript);
  16000. /*192:*/
  16001. #line 4445 "./typica.w"
  16002. if(engine->hasUncaughtException())
  16003. {
  16004. int line= engine->uncaughtExceptionLineNumber();
  16005. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16006. result.toString();
  16007. QString trace;
  16008. foreach(trace,engine->uncaughtExceptionBacktrace())
  16009. {
  16010. qDebug()<<trace;
  16011. }
  16012. }
  16013. /*:192*/
  16014. #line 4697 "./typica.w"
  16015. context->setThisObject(oldThis);
  16016. /*:199*/
  16017. #line 4639 "./typica.w"
  16018. }
  16019. /*202:*/
  16020. #line 9 "./helpmenu.w"
  16021. HelpMenu*helpMenu= new HelpMenu();
  16022. window->menuBar()->addMenu(helpMenu);
  16023. /*:202*/
  16024. #line 4641 "./typica.w"
  16025. window->show();
  16026. /*:198*/
  16027. #line 4582 "./typica.w"
  16028. }
  16029. file.close();
  16030. }
  16031. return object;
  16032. }
  16033. /*:196*//*214:*/
  16034. #line 4784 "./typica.w"
  16035. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16036. QStack<QLayout*> *layoutStack)
  16037. {
  16038. if(element.hasAttribute("type"))
  16039. {
  16040. /*215:*/
  16041. #line 4805 "./typica.w"
  16042. QLayout*layout;
  16043. QString layoutType= element.attribute("type");
  16044. if(layoutType=="horizontal")
  16045. {
  16046. layout= new QHBoxLayout;
  16047. layoutStack->push(layout);
  16048. populateBoxLayout(element,widgetStack,layoutStack);
  16049. }
  16050. else if(layoutType=="vertical")
  16051. {
  16052. layout= new QVBoxLayout;
  16053. layoutStack->push(layout);
  16054. populateBoxLayout(element,widgetStack,layoutStack);
  16055. }
  16056. else if(layoutType=="grid")
  16057. {
  16058. layout= new QGridLayout;
  16059. layoutStack->push(layout);
  16060. populateGridLayout(element,widgetStack,layoutStack);
  16061. }
  16062. else if(layoutType=="stack")
  16063. {
  16064. layout= new QStackedLayout;
  16065. layoutStack->push(layout);
  16066. populateStackedLayout(element,widgetStack,layoutStack);
  16067. }
  16068. if(element.hasAttribute("id"))
  16069. {
  16070. layout->setObjectName(element.attribute("id"));
  16071. }
  16072. if(element.hasAttribute("spacing"))
  16073. {
  16074. layout->setSpacing(element.attribute("spacing").toInt());
  16075. }
  16076. if(element.hasAttribute("margin"))
  16077. {
  16078. int m= element.attribute("margin").toInt();
  16079. layout->setContentsMargins(m,m,m,m);
  16080. }
  16081. /*:215*/
  16082. #line 4790 "./typica.w"
  16083. QWidget*widget= widgetStack->top();
  16084. if(layout)
  16085. {
  16086. widget->setLayout(layout);
  16087. }
  16088. layoutStack->pop();
  16089. }
  16090. }
  16091. /*:214*//*216:*/
  16092. #line 4852 "./typica.w"
  16093. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16094. QStack<QLayout*> *layoutStack)
  16095. {
  16096. QDomNodeList children= element.childNodes();
  16097. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  16098. for(int i= 0;i<children.count();i++)
  16099. {
  16100. QDomNode current;
  16101. QDomElement currentElement;
  16102. current= children.at(i);
  16103. if(current.isElement())
  16104. {
  16105. currentElement= current.toElement();
  16106. if(currentElement.tagName()=="page")
  16107. {
  16108. QWidget*widget= new QWidget;
  16109. layout->addWidget(widget);
  16110. widgetStack->push(widget);
  16111. currentElement.setAttribute("trcontext","configuration");
  16112. populateWidget(currentElement,widgetStack,layoutStack);
  16113. widgetStack->pop();
  16114. }
  16115. }
  16116. }
  16117. }
  16118. /*:216*//*217:*/
  16119. #line 4885 "./typica.w"
  16120. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16121. QStack<QLayout*> *layoutStack)
  16122. {
  16123. QDomNodeList children= element.childNodes();
  16124. int row= -1;
  16125. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  16126. for(int i= 0;i<children.count();i++)
  16127. {
  16128. QDomNode current;
  16129. QDomElement currentElement;
  16130. current= children.at(i);
  16131. if(current.isElement())
  16132. {
  16133. currentElement= current.toElement();
  16134. if(currentElement.tagName()=="row")
  16135. {
  16136. row++;
  16137. if(currentElement.hasAttribute("height"))
  16138. {
  16139. layout->setRowMinimumHeight(row,
  16140. currentElement.attribute("height").toInt());
  16141. }
  16142. if(currentElement.hasAttribute("stretch"))
  16143. {
  16144. layout->setRowStretch(row,
  16145. currentElement.attribute("stretch").toInt());
  16146. }
  16147. /*218:*/
  16148. #line 4941 "./typica.w"
  16149. int column= -1;
  16150. QDomNodeList rowChildren= currentElement.childNodes();
  16151. for(int j= 0;j<rowChildren.count();j++)
  16152. {
  16153. QDomNode columnNode;
  16154. QDomElement columnElement;
  16155. columnNode= rowChildren.at(j);
  16156. if(columnNode.isElement())
  16157. {
  16158. columnElement= columnNode.toElement();
  16159. if(columnElement.tagName()=="column")
  16160. {
  16161. column++;
  16162. if(columnElement.hasAttribute("column"))
  16163. {
  16164. column= columnElement.attribute("column").toInt();
  16165. }
  16166. if(columnElement.hasAttribute("width"))
  16167. {
  16168. layout->setColumnMinimumWidth(column,
  16169. columnElement.attribute("width").toInt());
  16170. }
  16171. if(columnElement.hasAttribute("stretch"))
  16172. {
  16173. layout->setColumnStretch(column,
  16174. columnElement.attribute("stretch").toInt());
  16175. }
  16176. int hspan= 1;
  16177. int vspan= 1;
  16178. if(columnElement.hasAttribute("rowspan"))
  16179. {
  16180. vspan= columnElement.attribute("rowspan").toInt();
  16181. }
  16182. if(columnElement.hasAttribute("colspan"))
  16183. {
  16184. hspan= columnElement.attribute("colspan").toInt();
  16185. }
  16186. QHBoxLayout*cell= new QHBoxLayout;
  16187. layout->addLayout(cell,row,column,vspan,hspan);
  16188. layoutStack->push(cell);
  16189. columnElement.setAttribute("trcontext","configuration");
  16190. populateBoxLayout(columnElement,widgetStack,layoutStack);
  16191. layoutStack->pop();
  16192. }
  16193. }
  16194. }
  16195. /*:218*/
  16196. #line 4913 "./typica.w"
  16197. }
  16198. }
  16199. }
  16200. }
  16201. /*:217*//*219:*/
  16202. #line 4992 "./typica.w"
  16203. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16204. QStack<QLayout*> *layoutStack)
  16205. {
  16206. QDomNodeList children= element.childNodes();
  16207. for(int i= 0;i<children.count();i++)
  16208. {
  16209. QDomNode current;
  16210. QDomElement currentElement;
  16211. current= children.at(i);
  16212. if(current.isElement())
  16213. {
  16214. currentElement= current.toElement();
  16215. currentElement.setAttribute("trcontext","configuration");
  16216. if(currentElement.tagName()=="button")
  16217. {
  16218. addButtonToLayout(currentElement,widgetStack,layoutStack);
  16219. }
  16220. else if(currentElement.tagName()=="calendar")
  16221. {
  16222. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  16223. }
  16224. else if(currentElement.tagName()=="decoration")
  16225. {
  16226. addDecorationToLayout(currentElement,widgetStack,
  16227. layoutStack);
  16228. }
  16229. else if(currentElement.tagName()=="layout")
  16230. {
  16231. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  16232. }
  16233. else if(currentElement.tagName()=="splitter")
  16234. {
  16235. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  16236. }
  16237. else if(currentElement.tagName()=="label")
  16238. {
  16239. QBoxLayout*layout=
  16240. qobject_cast<QBoxLayout*> (layoutStack->top());
  16241. QLabel*label= new QLabel(QCoreApplication::translate(
  16242. "configuration",
  16243. currentElement.text().toUtf8().data()));
  16244. layout->addWidget(label);
  16245. }
  16246. else if(currentElement.tagName()=="lcdtemperature")
  16247. {
  16248. addTemperatureDisplayToLayout(currentElement,widgetStack,
  16249. layoutStack);
  16250. }
  16251. else if(currentElement.tagName()=="lcdtimer")
  16252. {
  16253. addTimerDisplayToLayout(currentElement,widgetStack,
  16254. layoutStack);
  16255. }
  16256. else if(currentElement.tagName()=="line")
  16257. {
  16258. addLineToLayout(currentElement,widgetStack,layoutStack);
  16259. }
  16260. else if(currentElement.tagName()=="report")
  16261. {
  16262. addReportToLayout(currentElement,widgetStack,layoutStack);
  16263. }
  16264. else if(currentElement.tagName()=="sqldrop")
  16265. {
  16266. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  16267. }
  16268. else if(currentElement.tagName()=="sqltablearray")
  16269. {
  16270. addSaltToLayout(currentElement,widgetStack,layoutStack);
  16271. }
  16272. else if(currentElement.tagName()=="sqlview")
  16273. {
  16274. addSqlQueryViewToLayout(currentElement,widgetStack,
  16275. layoutStack);
  16276. }
  16277. else if(currentElement.tagName()=="textarea")
  16278. {
  16279. addTextToLayout(currentElement,widgetStack,layoutStack);
  16280. }
  16281. else if(currentElement.tagName()=="spinbox")
  16282. {
  16283. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  16284. }
  16285. else if(currentElement.tagName()=="formarray")
  16286. {
  16287. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  16288. }
  16289. else if(currentElement.tagName()=="hscale")
  16290. {
  16291. addScaleControlToLayout(currentElement,widgetStack,
  16292. layoutStack);
  16293. }
  16294. else if(currentElement.tagName()=="vscale")
  16295. {
  16296. addIntensityControlToLayout(currentElement,widgetStack,
  16297. layoutStack);
  16298. }
  16299. else if(currentElement.tagName()=="webview")
  16300. {
  16301. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  16302. }
  16303. else if(currentElement.tagName()=="stretch")
  16304. {
  16305. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16306. layout->addStretch();
  16307. }
  16308. /*51:*/
  16309. #line 1479 "./typica.w"
  16310. else if(currentElement.tagName()=="svgwidget")
  16311. {
  16312. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  16313. }
  16314. /*:51*//*682:*/
  16315. #line 451 "./daterangeselector.w"
  16316. else if(currentElement.tagName()=="daterange")
  16317. {
  16318. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  16319. }
  16320. /*:682*/
  16321. #line 5098 "./typica.w"
  16322. }
  16323. }
  16324. }
  16325. /*:219*//*220:*/
  16326. #line 5106 "./typica.w"
  16327. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16328. QStack<QLayout*> *layoutStack)
  16329. {
  16330. QLayout*targetLayout= layoutStack->pop();
  16331. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  16332. if(element.hasAttribute("type"))
  16333. {
  16334. /*215:*/
  16335. #line 4805 "./typica.w"
  16336. QLayout*layout;
  16337. QString layoutType= element.attribute("type");
  16338. if(layoutType=="horizontal")
  16339. {
  16340. layout= new QHBoxLayout;
  16341. layoutStack->push(layout);
  16342. populateBoxLayout(element,widgetStack,layoutStack);
  16343. }
  16344. else if(layoutType=="vertical")
  16345. {
  16346. layout= new QVBoxLayout;
  16347. layoutStack->push(layout);
  16348. populateBoxLayout(element,widgetStack,layoutStack);
  16349. }
  16350. else if(layoutType=="grid")
  16351. {
  16352. layout= new QGridLayout;
  16353. layoutStack->push(layout);
  16354. populateGridLayout(element,widgetStack,layoutStack);
  16355. }
  16356. else if(layoutType=="stack")
  16357. {
  16358. layout= new QStackedLayout;
  16359. layoutStack->push(layout);
  16360. populateStackedLayout(element,widgetStack,layoutStack);
  16361. }
  16362. if(element.hasAttribute("id"))
  16363. {
  16364. layout->setObjectName(element.attribute("id"));
  16365. }
  16366. if(element.hasAttribute("spacing"))
  16367. {
  16368. layout->setSpacing(element.attribute("spacing").toInt());
  16369. }
  16370. if(element.hasAttribute("margin"))
  16371. {
  16372. int m= element.attribute("margin").toInt();
  16373. layout->setContentsMargins(m,m,m,m);
  16374. }
  16375. /*:215*/
  16376. #line 5114 "./typica.w"
  16377. boxLayout->addLayout(layout);
  16378. layoutStack->pop();
  16379. }
  16380. layoutStack->push(targetLayout);
  16381. }
  16382. /*:220*//*221:*/
  16383. #line 5125 "./typica.w"
  16384. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16385. QStack<QLayout*> *layoutStack)
  16386. {
  16387. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16388. QSplitter*splitter= new(QSplitter);
  16389. layout->addWidget(splitter);
  16390. /*222:*/
  16391. #line 5138 "./typica.w"
  16392. QString orientation= element.attribute("type");
  16393. if(orientation=="horizontal")
  16394. {
  16395. splitter->setOrientation(Qt::Horizontal);
  16396. }
  16397. else if(orientation=="vertical")
  16398. {
  16399. splitter->setOrientation(Qt::Vertical);
  16400. }
  16401. QString id= element.attribute("id");
  16402. if(!id.isEmpty())
  16403. {
  16404. splitter->setObjectName(id);
  16405. }
  16406. if(element.hasChildNodes())
  16407. {
  16408. widgetStack->push(splitter);
  16409. populateSplitter(element,widgetStack,layoutStack);
  16410. widgetStack->pop();
  16411. }
  16412. /*:222*/
  16413. #line 5132 "./typica.w"
  16414. }
  16415. /*:221*//*223:*/
  16416. #line 5164 "./typica.w"
  16417. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16418. QStack<QLayout*> *layoutStack)
  16419. {
  16420. QDomNodeList children= element.childNodes();
  16421. for(int i= 0;i<children.count();i++)
  16422. {
  16423. QDomNode current;
  16424. QDomElement currentElement;
  16425. current= children.at(i);
  16426. if(current.isElement())
  16427. {
  16428. currentElement= current.toElement();
  16429. currentElement.setAttribute("trcontext","configuration");
  16430. if(currentElement.tagName()=="decoration")
  16431. {
  16432. addDecorationToSplitter(currentElement,widgetStack,
  16433. layoutStack);
  16434. }
  16435. else if(currentElement.tagName()=="graph")
  16436. {
  16437. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  16438. }
  16439. else if(currentElement.tagName()=="splitter")
  16440. {
  16441. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  16442. }
  16443. else if(currentElement.tagName()=="lcdtemperature")
  16444. {
  16445. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  16446. layoutStack);
  16447. }
  16448. else if(currentElement.tagName()=="lcdtimer")
  16449. {
  16450. addTimerDisplayToSplitter(currentElement,widgetStack,
  16451. layoutStack);
  16452. }
  16453. else if(currentElement.tagName()=="measurementtable")
  16454. {
  16455. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  16456. }
  16457. else if(currentElement.tagName()=="widget")
  16458. {
  16459. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  16460. }
  16461. }
  16462. }
  16463. }
  16464. /*:223*//*224:*/
  16465. #line 5215 "./typica.w"
  16466. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16467. QStack<QLayout*> *layoutStack)
  16468. {
  16469. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  16470. QSplitter*splitter= new(QSplitter);
  16471. splitter->setParent(parent);
  16472. parent->addWidget(splitter);
  16473. /*222:*/
  16474. #line 5138 "./typica.w"
  16475. QString orientation= element.attribute("type");
  16476. if(orientation=="horizontal")
  16477. {
  16478. splitter->setOrientation(Qt::Horizontal);
  16479. }
  16480. else if(orientation=="vertical")
  16481. {
  16482. splitter->setOrientation(Qt::Vertical);
  16483. }
  16484. QString id= element.attribute("id");
  16485. if(!id.isEmpty())
  16486. {
  16487. splitter->setObjectName(id);
  16488. }
  16489. if(element.hasChildNodes())
  16490. {
  16491. widgetStack->push(splitter);
  16492. populateSplitter(element,widgetStack,layoutStack);
  16493. widgetStack->pop();
  16494. }
  16495. /*:222*/
  16496. #line 5223 "./typica.w"
  16497. }
  16498. /*:224*//*225:*/
  16499. #line 5232 "./typica.w"
  16500. void addTemperatureDisplayToSplitter(QDomElement element,
  16501. QStack<QWidget*> *widgetStack,
  16502. QStack<QLayout*> *)
  16503. {
  16504. TemperatureDisplay*display= new(TemperatureDisplay);
  16505. if(element.hasAttribute("id"))
  16506. {
  16507. display->setObjectName(element.attribute("id"));
  16508. }
  16509. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16510. splitter->addWidget(display);
  16511. }
  16512. void addTemperatureDisplayToLayout(QDomElement element,
  16513. QStack<QWidget*> *,
  16514. QStack<QLayout*> *layoutStack)
  16515. {
  16516. TemperatureDisplay*display= new(TemperatureDisplay);
  16517. if(element.hasAttribute("id"))
  16518. {
  16519. display->setObjectName(element.attribute("id"));
  16520. }
  16521. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16522. layout->addWidget(display);
  16523. }
  16524. /*:225*//*226:*/
  16525. #line 5263 "./typica.w"
  16526. void addTimerDisplayToSplitter(QDomElement element,
  16527. QStack<QWidget*> *widgetStack,
  16528. QStack<QLayout*> *)
  16529. {
  16530. TimerDisplay*display= new(TimerDisplay);
  16531. if(element.hasAttribute("id"))
  16532. {
  16533. display->setObjectName(element.attribute("id"));
  16534. }
  16535. if(element.hasAttribute("format"))
  16536. {
  16537. display->setDisplayFormat(element.attribute("format"));
  16538. }
  16539. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16540. splitter->addWidget(display);
  16541. }
  16542. void addTimerDisplayToLayout(QDomElement element,
  16543. QStack<QWidget*> *,
  16544. QStack<QLayout*> *layoutStack)
  16545. {
  16546. TimerDisplay*display= new(TimerDisplay);
  16547. if(element.hasAttribute("id"))
  16548. {
  16549. display->setObjectName(element.attribute("id"));
  16550. }
  16551. if(element.hasAttribute("format"))
  16552. {
  16553. display->setDisplayFormat(element.attribute("format"));
  16554. }
  16555. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16556. layout->addWidget(display);
  16557. }
  16558. /*:226*//*227:*/
  16559. #line 5301 "./typica.w"
  16560. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  16561. QStack<QLayout*> *layoutStack)
  16562. {
  16563. /*228:*/
  16564. #line 5322 "./typica.w"
  16565. QString labelText=
  16566. QCoreApplication::translate("configuration",
  16567. element.attribute("name").toUtf8().data());
  16568. Qt::Orientations orientation= Qt::Horizontal;
  16569. if(element.hasAttribute("type"))
  16570. {
  16571. if(element.attribute("type")=="horizontal")
  16572. {
  16573. orientation= Qt::Horizontal;
  16574. }
  16575. else if(element.attribute("type")=="vertical")
  16576. {
  16577. orientation= Qt::Vertical;
  16578. }
  16579. }
  16580. /*229:*/
  16581. #line 5349 "./typica.w"
  16582. QWidget*theWidget= NULL;
  16583. QDomNodeList children= element.childNodes();
  16584. for(int i= 0;i<children.count();i++)
  16585. {
  16586. QDomNode item= children.at(i);
  16587. if(item.isElement())
  16588. {
  16589. QDomElement itemElement= item.toElement();
  16590. if(itemElement.tagName()=="lcdtemperature")
  16591. {
  16592. TemperatureDisplay*display= new TemperatureDisplay;
  16593. if(itemElement.hasAttribute("id"))
  16594. {
  16595. display->setObjectName(itemElement.attribute("id"));
  16596. }
  16597. theWidget= display;
  16598. }
  16599. else if(itemElement.tagName()=="lcdtimer")
  16600. {
  16601. TimerDisplay*display= new TimerDisplay;
  16602. if(itemElement.hasAttribute("id"))
  16603. {
  16604. display->setObjectName(itemElement.attribute("id"));
  16605. }
  16606. if(itemElement.hasAttribute("format"))
  16607. {
  16608. display->setDisplayFormat(itemElement.attribute("format"));
  16609. }
  16610. theWidget= display;
  16611. }
  16612. }
  16613. }
  16614. /*:229*/
  16615. #line 5338 "./typica.w"
  16616. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  16617. orientation);
  16618. if(element.hasAttribute("id"))
  16619. {
  16620. decoration->setObjectName(element.attribute("id"));
  16621. }
  16622. /*:228*/
  16623. #line 5305 "./typica.w"
  16624. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16625. layout->addWidget(decoration);
  16626. }
  16627. void addDecorationToSplitter(QDomElement element,
  16628. QStack<QWidget*> *widgetStack,
  16629. QStack<QLayout*> *)
  16630. {
  16631. /*228:*/
  16632. #line 5322 "./typica.w"
  16633. QString labelText=
  16634. QCoreApplication::translate("configuration",
  16635. element.attribute("name").toUtf8().data());
  16636. Qt::Orientations orientation= Qt::Horizontal;
  16637. if(element.hasAttribute("type"))
  16638. {
  16639. if(element.attribute("type")=="horizontal")
  16640. {
  16641. orientation= Qt::Horizontal;
  16642. }
  16643. else if(element.attribute("type")=="vertical")
  16644. {
  16645. orientation= Qt::Vertical;
  16646. }
  16647. }
  16648. /*229:*/
  16649. #line 5349 "./typica.w"
  16650. QWidget*theWidget= NULL;
  16651. QDomNodeList children= element.childNodes();
  16652. for(int i= 0;i<children.count();i++)
  16653. {
  16654. QDomNode item= children.at(i);
  16655. if(item.isElement())
  16656. {
  16657. QDomElement itemElement= item.toElement();
  16658. if(itemElement.tagName()=="lcdtemperature")
  16659. {
  16660. TemperatureDisplay*display= new TemperatureDisplay;
  16661. if(itemElement.hasAttribute("id"))
  16662. {
  16663. display->setObjectName(itemElement.attribute("id"));
  16664. }
  16665. theWidget= display;
  16666. }
  16667. else if(itemElement.tagName()=="lcdtimer")
  16668. {
  16669. TimerDisplay*display= new TimerDisplay;
  16670. if(itemElement.hasAttribute("id"))
  16671. {
  16672. display->setObjectName(itemElement.attribute("id"));
  16673. }
  16674. if(itemElement.hasAttribute("format"))
  16675. {
  16676. display->setDisplayFormat(itemElement.attribute("format"));
  16677. }
  16678. theWidget= display;
  16679. }
  16680. }
  16681. }
  16682. /*:229*/
  16683. #line 5338 "./typica.w"
  16684. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  16685. orientation);
  16686. if(element.hasAttribute("id"))
  16687. {
  16688. decoration->setObjectName(element.attribute("id"));
  16689. }
  16690. /*:228*/
  16691. #line 5314 "./typica.w"
  16692. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16693. splitter->addWidget(decoration);
  16694. }
  16695. /*:227*//*230:*/
  16696. #line 5388 "./typica.w"
  16697. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16698. QStack<QLayout*> *layoutStack)
  16699. {
  16700. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16701. QWidget*widget= new QWidget;
  16702. if(element.hasAttribute("id"))
  16703. {
  16704. widget->setObjectName(element.attribute("id"));
  16705. }
  16706. splitter->addWidget(widget);
  16707. if(element.hasChildNodes())
  16708. {
  16709. widgetStack->push(widget);
  16710. populateWidget(element,widgetStack,layoutStack);
  16711. widgetStack->pop();
  16712. }
  16713. }
  16714. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16715. QStack<QLayout*> *layoutStack)
  16716. {
  16717. QDomNodeList children= element.childNodes();
  16718. for(int i= 0;i<children.count();i++)
  16719. {
  16720. QDomNode current;
  16721. QDomElement currentElement;
  16722. current= children.at(i);
  16723. if(current.isElement())
  16724. {
  16725. currentElement= current.toElement();
  16726. if(currentElement.tagName()=="layout")
  16727. {
  16728. currentElement.setAttribute("trcontext","configuration");
  16729. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  16730. }
  16731. }
  16732. }
  16733. }
  16734. /*:230*//*231:*/
  16735. #line 5432 "./typica.w"
  16736. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  16737. QStack<QLayout*> *layoutStack)
  16738. {
  16739. QAbstractButton*button= NULL;
  16740. QString text=
  16741. QCoreApplication::translate("configuration",
  16742. element.attribute("name").toUtf8().data());
  16743. if(element.hasAttribute("type"))
  16744. {
  16745. QString type= element.attribute("type");
  16746. if(type=="annotation")
  16747. {
  16748. AnnotationButton*abutton= new AnnotationButton(text);
  16749. if(element.hasAttribute("annotation"))
  16750. {
  16751. abutton->setAnnotation(element.attribute("annotation"));
  16752. }
  16753. if(element.hasAttribute("series"))
  16754. {
  16755. abutton->setTemperatureColumn(element.attribute("series").
  16756. toInt());
  16757. }
  16758. if(element.hasAttribute("column"))
  16759. {
  16760. abutton->setAnnotationColumn(element.attribute("column").
  16761. toInt());
  16762. }
  16763. button= abutton;
  16764. }
  16765. else if(type=="check")
  16766. {
  16767. button= new QCheckBox(text);
  16768. }
  16769. else if(type=="push")
  16770. {
  16771. button= new QPushButton(text);
  16772. }
  16773. }
  16774. if(element.hasAttribute("id"))
  16775. {
  16776. button->setObjectName(element.attribute("id"));
  16777. }
  16778. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16779. layout->addWidget(button);
  16780. }
  16781. /*:231*//*232:*/
  16782. #line 5486 "./typica.w"
  16783. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  16784. QStack<QLayout*> *layoutStack)
  16785. {
  16786. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  16787. if(element.hasAttribute("pretext"))
  16788. {
  16789. box->setPretext(QCoreApplication::translate(
  16790. "configuration",
  16791. element.attribute("pretext").toUtf8().data()));
  16792. }
  16793. if(element.hasAttribute("posttext"))
  16794. {
  16795. box->setPosttext(QCoreApplication::translate(
  16796. "configuration",
  16797. element.attribute("posttext").toUtf8().data()));
  16798. }
  16799. if(element.hasAttribute("series"))
  16800. {
  16801. box->setTemperatureColumn(element.attribute("series").toInt());
  16802. }
  16803. if(element.hasAttribute("column"))
  16804. {
  16805. box->setAnnotationColumn(element.attribute("column").toInt());
  16806. }
  16807. if(element.hasAttribute("min"))
  16808. {
  16809. box->setMinimum(element.attribute("min").toDouble());
  16810. }
  16811. if(element.hasAttribute("max"))
  16812. {
  16813. box->setMaximum(element.attribute("max").toDouble());
  16814. }
  16815. if(element.hasAttribute("decimals"))
  16816. {
  16817. box->setDecimals(element.attribute("decimals").toInt());
  16818. }
  16819. if(element.hasAttribute("step"))
  16820. {
  16821. box->setSingleStep(element.attribute("step").toDouble());
  16822. }
  16823. if(element.hasAttribute("id"))
  16824. {
  16825. box->setObjectName(element.attribute("id"));
  16826. }
  16827. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16828. layout->addWidget(box);
  16829. }
  16830. /*:232*//*233:*/
  16831. #line 5546 "./typica.w"
  16832. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16833. QStack<QLayout*> *)
  16834. {
  16835. ZoomLog*widget= new ZoomLog;
  16836. if(element.hasAttribute("id"))
  16837. {
  16838. widget->setObjectName(element.attribute("id"));
  16839. }
  16840. if(element.hasChildNodes())
  16841. {
  16842. QDomNodeList children= element.childNodes();
  16843. int column= 0;
  16844. for(int i= 0;i<children.count();i++)
  16845. {
  16846. QDomNode current;
  16847. QDomElement currentElement;
  16848. current= children.at(i);
  16849. if(current.isElement())
  16850. {
  16851. currentElement= current.toElement();
  16852. if(currentElement.tagName()=="column")
  16853. {
  16854. QString text=
  16855. QCoreApplication::translate(
  16856. "configuration",
  16857. currentElement.text().toUtf8().data());
  16858. widget->setHeaderData(column,text);
  16859. column++;
  16860. }
  16861. }
  16862. }
  16863. }
  16864. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16865. if(splitter)
  16866. {
  16867. splitter->addWidget(widget);
  16868. }
  16869. else
  16870. {
  16871. qDebug()<<"Splitter not found at top of widget stack!";
  16872. }
  16873. }
  16874. /*:233*//*234:*/
  16875. #line 5593 "./typica.w"
  16876. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  16877. QStack<QLayout*> *)
  16878. {
  16879. GraphView*view= new GraphView;
  16880. if(element.hasAttribute("id"))
  16881. {
  16882. view->setObjectName(element.attribute("id"));
  16883. }
  16884. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  16885. splitter->addWidget(view);
  16886. }
  16887. /*:234*//*235:*/
  16888. #line 5610 "./typica.w"
  16889. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  16890. QStack<QLayout*> *layoutStack)
  16891. {
  16892. SqlComboBox*box= new SqlComboBox();
  16893. if(element.hasAttribute("data"))
  16894. {
  16895. box->setDataColumn(element.attribute("data").toInt());
  16896. }
  16897. if(element.hasAttribute("display"))
  16898. {
  16899. box->setDisplayColumn(element.attribute("display").toInt());
  16900. }
  16901. if(element.hasAttribute("showdata"))
  16902. {
  16903. if(element.attribute("showdata")=="true")
  16904. {
  16905. box->showData(true);
  16906. }
  16907. }
  16908. if(element.hasAttribute("editable"))
  16909. {
  16910. if(element.attribute("editable")=="true")
  16911. {
  16912. box->setEditable(true);
  16913. }
  16914. }
  16915. if(element.hasChildNodes())
  16916. {
  16917. QDomNodeList children= element.childNodes();
  16918. for(int i= 0;i<children.count();i++)
  16919. {
  16920. QDomNode current;
  16921. QDomElement currentElement;
  16922. current= children.at(i);
  16923. if(current.isElement())
  16924. {
  16925. currentElement= current.toElement();
  16926. if(currentElement.tagName()=="null")
  16927. {
  16928. box->addNullOption();
  16929. }
  16930. else if(currentElement.tagName()=="query")
  16931. {
  16932. box->addSqlOptions(currentElement.text());
  16933. }
  16934. }
  16935. }
  16936. }
  16937. if(element.hasAttribute("id"))
  16938. {
  16939. box->setObjectName(element.attribute("id"));
  16940. }
  16941. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16942. layout->addWidget(box);
  16943. }
  16944. /*:235*//*236:*/
  16945. #line 5689 "./typica.w"
  16946. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  16947. QStack<QLayout*> *layoutStack)
  16948. {
  16949. QTableView*view= new QTableView;
  16950. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  16951. SaltModel*model= new SaltModel(element.childNodes().count());
  16952. if(element.hasAttribute("id"))
  16953. {
  16954. view->setObjectName(element.attribute("id"));
  16955. }
  16956. if(element.hasChildNodes())
  16957. {
  16958. QDomNodeList children= element.childNodes();
  16959. int currentColumn= 0;
  16960. for(int i= 0;i<children.count();i++)
  16961. {
  16962. QDomNode current;
  16963. QDomElement currentElement;
  16964. current= children.at(i);
  16965. if(current.isElement())
  16966. {
  16967. currentElement= current.toElement();
  16968. if(currentElement.tagName()=="column")
  16969. {
  16970. if(currentElement.hasAttribute("name"))
  16971. {
  16972. model->setHeaderData(currentColumn,
  16973. Qt::Horizontal,
  16974. QCoreApplication::translate(
  16975. "configuration",
  16976. currentElement.attribute("name").toUtf8().data()));
  16977. }
  16978. if(currentElement.hasAttribute("delegate"))
  16979. {
  16980. /*237:*/
  16981. #line 5740 "./typica.w"
  16982. if(currentElement.attribute("delegate")=="sql")
  16983. {
  16984. /*238:*/
  16985. #line 5756 "./typica.w"
  16986. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  16987. SqlComboBox*widget= new SqlComboBox();
  16988. if(currentElement.hasAttribute("nulltext"))
  16989. {
  16990. widget->setNullText(currentElement.attribute("nulltext"));
  16991. }
  16992. if(currentElement.hasAttribute("nulldata"))
  16993. {
  16994. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  16995. }
  16996. if(currentElement.hasAttribute("null"))
  16997. {
  16998. if(currentElement.attribute("null")=="true")
  16999. {
  17000. widget->addNullOption();
  17001. }
  17002. }
  17003. if(currentElement.hasAttribute("showdata"))
  17004. {
  17005. if(currentElement.attribute("showdata")=="true")
  17006. {
  17007. widget->showData(true);
  17008. }
  17009. }
  17010. if(currentElement.hasAttribute("data"))
  17011. {
  17012. widget->setDataColumn(currentElement.attribute("data").toInt());
  17013. }
  17014. if(currentElement.hasAttribute("display"))
  17015. {
  17016. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  17017. }
  17018. widget->addSqlOptions(currentElement.text());
  17019. delegate->setWidget(widget);
  17020. view->setItemDelegateForColumn(currentColumn,delegate);
  17021. /*:238*/
  17022. #line 5743 "./typica.w"
  17023. }
  17024. else if(currentElement.attribute("delegate")=="numeric")
  17025. {
  17026. /*239:*/
  17027. #line 5797 "./typica.w"
  17028. NumericDelegate*delegate= new NumericDelegate;
  17029. view->setItemDelegateForColumn(currentColumn,delegate);
  17030. /*:239*/
  17031. #line 5747 "./typica.w"
  17032. }
  17033. /*:237*/
  17034. #line 5724 "./typica.w"
  17035. }
  17036. currentColumn++;
  17037. }
  17038. }
  17039. }
  17040. }
  17041. view->setModel(model);
  17042. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17043. layout->addWidget(view);
  17044. }
  17045. /*:236*//*251:*/
  17046. #line 5970 "./typica.w"
  17047. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  17048. QStack<QLayout*> *layoutStack)
  17049. {
  17050. QLineEdit*widget= new QLineEdit(element.text());
  17051. if(element.hasAttribute("id"))
  17052. {
  17053. widget->setObjectName(element.attribute("id"));
  17054. }
  17055. if(element.hasAttribute("writable"))
  17056. {
  17057. if(element.attribute("writable")=="false")
  17058. {
  17059. widget->setReadOnly(true);
  17060. }
  17061. }
  17062. if(element.hasAttribute("validator"))
  17063. {
  17064. if(element.attribute("validator")=="numeric")
  17065. {
  17066. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  17067. }
  17068. else if(element.attribute("validator")=="integer")
  17069. {
  17070. widget->setValidator(new ScriptValidator(new QIntValidator));
  17071. }
  17072. else if(element.attribute("validator")=="expression"&&
  17073. element.hasAttribute("expression"))
  17074. {
  17075. widget->setValidator(new QRegExpValidator(
  17076. QRegExp(element.attribute("expression")),
  17077. NULL));
  17078. }
  17079. }
  17080. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17081. layout->addWidget(widget);
  17082. }
  17083. /*:251*//*252:*/
  17084. #line 6011 "./typica.w"
  17085. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  17086. QStack<QLayout*> *layoutStack)
  17087. {
  17088. QTextEdit*widget= new QTextEdit;
  17089. if(element.hasAttribute("id"))
  17090. {
  17091. widget->setObjectName(element.attribute("id"));
  17092. }
  17093. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17094. layout->addWidget(widget);
  17095. }
  17096. /*:252*//*253:*/
  17097. #line 6028 "./typica.w"
  17098. void addSqlQueryViewToLayout(QDomElement element,
  17099. QStack<QWidget*> *,
  17100. QStack<QLayout*> *layoutStack)
  17101. {
  17102. SqlQueryView*view= new SqlQueryView;
  17103. if(element.hasAttribute("id"))
  17104. {
  17105. view->setObjectName(element.attribute("id"));
  17106. }
  17107. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17108. layout->addWidget(view);
  17109. }
  17110. /*:253*//*254:*/
  17111. #line 6045 "./typica.w"
  17112. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  17113. QStack<QLayout*> *layoutStack)
  17114. {
  17115. QWidget*widget;
  17116. if(element.hasAttribute("time"))
  17117. {
  17118. if(element.attribute("time")=="true")
  17119. {
  17120. QDateTimeEdit*edit= new QDateTimeEdit;
  17121. edit->setDateTime(QDateTime::currentDateTime());
  17122. edit->setCalendarPopup(true);
  17123. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  17124. widget= qobject_cast<QWidget*> (edit);
  17125. }
  17126. else
  17127. {
  17128. QDateEdit*edit= new QDateEdit;
  17129. edit->setDate(QDate::currentDate());
  17130. edit->setCalendarPopup(true);
  17131. edit->setDisplayFormat("yyyy-MM-dd");
  17132. widget= qobject_cast<QWidget*> (edit);
  17133. }
  17134. }
  17135. else
  17136. {
  17137. QDateEdit*edit= new QDateEdit;
  17138. edit->setDate(QDate::currentDate());
  17139. edit->setCalendarPopup(true);
  17140. edit->setDisplayFormat("yyyy-MM-dd");
  17141. widget= qobject_cast<QWidget*> (edit);
  17142. }
  17143. if(element.hasAttribute("id"))
  17144. {
  17145. widget->setObjectName(element.attribute("id"));
  17146. }
  17147. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17148. layout->addWidget(widget);
  17149. }
  17150. /*:254*//*255:*/
  17151. #line 6088 "./typica.w"
  17152. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  17153. {
  17154. setQDateTimeEditProperties(value,engine);
  17155. }
  17156. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  17157. {
  17158. setQAbstractSpinBoxProperties(value,engine);
  17159. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  17160. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  17161. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  17162. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  17163. value.setProperty("setToCurrentTime",
  17164. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  17165. }
  17166. /*:255*//*256:*/
  17167. #line 6110 "./typica.w"
  17168. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  17169. {
  17170. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17171. if(context->argumentCount()==3)
  17172. {
  17173. self->setDate(QDate(argument<int> (0,context),
  17174. argument<int> (1,context),
  17175. argument<int> (2,context)));
  17176. }
  17177. else
  17178. {
  17179. context->throwError("Incorrect number of arguments passed to "
  17180. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  17181. "specifying the year, month, and day.");
  17182. }
  17183. return QScriptValue();
  17184. }
  17185. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  17186. {
  17187. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17188. return QScriptValue(self->date().day());
  17189. }
  17190. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  17191. {
  17192. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17193. return QScriptValue(self->date().month());
  17194. }
  17195. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  17196. {
  17197. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17198. return QScriptValue(self->date().year());
  17199. }
  17200. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  17201. {
  17202. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17203. self->setDateTime(QDateTime::currentDateTime());
  17204. return QScriptValue();
  17205. }
  17206. /*:256*//*260:*/
  17207. #line 6185 "./typica.w"
  17208. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  17209. {
  17210. QObject*parent= argument<QObject*> (0,context);
  17211. QString name= argument<QString> (1,context);
  17212. QObject*object= parent->findChild<QObject*> (name);
  17213. QScriptValue value;
  17214. if(object)
  17215. {
  17216. value= engine->newQObject(object);
  17217. QString className= object->metaObject()->className();
  17218. /*261:*/
  17219. #line 6203 "./typica.w"
  17220. if(className=="TemperatureDisplay")
  17221. {
  17222. setTemperatureDisplayProperties(value,engine);
  17223. }
  17224. else if(className=="TimerDisplay")
  17225. {
  17226. setTimerDisplayProperties(value,engine);
  17227. }
  17228. else if(className=="QAction")
  17229. {
  17230. setQActionProperties(value,engine);
  17231. }
  17232. else if(className=="QBoxLayout")
  17233. {
  17234. setQBoxLayoutProperties(value,engine);
  17235. }
  17236. else if(className=="QDateEdit")
  17237. {
  17238. setQDateEditProperties(value,engine);
  17239. }
  17240. else if(className=="QDateTimeEdit")
  17241. {
  17242. setQDateTimeEditProperties(value,engine);
  17243. }
  17244. else if(className=="QFrame")
  17245. {
  17246. setQFrameProperties(value,engine);
  17247. }
  17248. else if(className=="QHBoxLayout")
  17249. {
  17250. setQBoxLayoutProperties(value,engine);
  17251. }
  17252. else if(className=="QLCDNumber")
  17253. {
  17254. setQLCDNumberProperties(value,engine);
  17255. }
  17256. else if(className=="QMenu")
  17257. {
  17258. setQMenuProperties(value,engine);
  17259. }
  17260. else if(className=="QMenuBar")
  17261. {
  17262. setQMenuBarProperties(value,engine);
  17263. }
  17264. else if(className=="QPushButton")
  17265. {
  17266. setQPushButtonProperties(value,engine);
  17267. }
  17268. else if(className=="QSplitter")
  17269. {
  17270. setQSplitterProperties(value,engine);
  17271. }
  17272. else if(className=="QTableView")
  17273. {
  17274. if(object->property("tabletype").isValid())
  17275. {
  17276. if(object->property("tabletype").toString()=="SaltTable")
  17277. {
  17278. setSaltTableProperties(value,engine);
  17279. }
  17280. }
  17281. }
  17282. else if(className=="QVBoxLayout")
  17283. {
  17284. setQBoxLayoutProperties(value,engine);
  17285. }
  17286. else if(className=="QWidget")
  17287. {
  17288. setQWidgetProperties(value,engine);
  17289. }
  17290. else if(className=="ScriptQMainWindow")
  17291. {
  17292. setQMainWindowProperties(value,engine);
  17293. }
  17294. else if(className=="SqlComboBox")
  17295. {
  17296. setSqlComboBoxProperties(value,engine);
  17297. }
  17298. else if(className=="SqlQueryView")
  17299. {
  17300. setSqlQueryViewProperties(value,engine);
  17301. }
  17302. else if(className=="ZoomLog")
  17303. {
  17304. setZoomLogProperties(value,engine);
  17305. }
  17306. else if(className=="QTextEdit")
  17307. {
  17308. setQTextEditProperties(value,engine);
  17309. }
  17310. else if(className=="QWebView")
  17311. {
  17312. setQWebViewProperties(value,engine);
  17313. }
  17314. else if(className=="QLineEdit")
  17315. {
  17316. setQLineEditProperties(value,engine);
  17317. }
  17318. else if(className=="QSvgWidget")
  17319. {
  17320. setQSvgWidgetProperties(value,engine);
  17321. }
  17322. /*:261*/
  17323. #line 6196 "./typica.w"
  17324. }
  17325. return value;
  17326. }
  17327. /*:260*//*263:*/
  17328. #line 6336 "./typica.w"
  17329. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  17330. {
  17331. QTableView*self= getself<QTableView*> (context);
  17332. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17333. QString datum;
  17334. double total= 0.0;
  17335. int column= argument<int> (0,context);
  17336. int role= argument<int> (1,context);
  17337. for(int i= 0;i<model->rowCount();i++)
  17338. {
  17339. datum= model->data(model->index(i,column),role).toString();
  17340. if(!datum.isEmpty())
  17341. {
  17342. total+= datum.toDouble();
  17343. }
  17344. }
  17345. return QScriptValue(engine,total);
  17346. }
  17347. /*:263*//*264:*/
  17348. #line 6360 "./typica.w"
  17349. QScriptValue SaltTable_columnArray(QScriptContext*context,
  17350. QScriptEngine*engine)
  17351. {
  17352. QTableView*self= getself<QTableView*> (context);
  17353. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17354. int column= argument<int> (0,context);
  17355. int role= argument<int> (1,context);
  17356. QString literal= model->arrayLiteral(column,role);
  17357. return QScriptValue(engine,literal);
  17358. }
  17359. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  17360. QScriptEngine*engine)
  17361. {
  17362. QTableView*self= getself<QTableView*> (context);
  17363. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17364. int column= argument<int> (0,context);
  17365. int role= argument<int> (1,context);
  17366. QString literal= model->quotedArrayLiteral(column,role);
  17367. return QScriptValue(engine,literal);
  17368. }
  17369. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  17370. QScriptEngine*engine)
  17371. {
  17372. QTableView*self= getself<QTableView*> (context);
  17373. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17374. int column= argument<int> (0,context);
  17375. int role= argument<int> (1,context);
  17376. QString literal= model->arrayLiteral(column,role);
  17377. literal.chop(1);
  17378. literal= literal.remove(0,1);
  17379. return QScriptValue(engine,literal);
  17380. }
  17381. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  17382. QScriptEngine*engine)
  17383. {
  17384. QTableView*self= getself<QTableView*> (context);
  17385. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17386. int column= argument<int> (0,context);
  17387. int role= argument<int> (1,context);
  17388. QString literal= model->quotedArrayLiteral(column,role);
  17389. literal.chop(1);
  17390. literal= literal.remove(0,1);
  17391. return QScriptValue(engine,literal);
  17392. }
  17393. /*:264*//*265:*/
  17394. #line 6412 "./typica.w"
  17395. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  17396. {
  17397. QTableView*self= getself<QTableView*> (context);
  17398. QScriptValue value= engine->newQObject(self->model());
  17399. return value;
  17400. }
  17401. /*:265*//*266:*/
  17402. #line 6426 "./typica.w"
  17403. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  17404. {
  17405. QTableView*self= getself<QTableView*> (context);
  17406. int row= argument<int> (0,context);
  17407. int column= argument<int> (1,context);
  17408. QVariant value= argument<QVariant> (2,context);
  17409. int role= argument<int> (3,context);
  17410. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17411. QModelIndex cell= model->index(row,column);
  17412. model->setData(cell,value,role);
  17413. self->update(cell);
  17414. return QScriptValue();
  17415. }
  17416. /*:266*//*267:*/
  17417. #line 6444 "./typica.w"
  17418. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  17419. {
  17420. QTableView*self= getself<QTableView*> (context);
  17421. int row= argument<int> (0,context);
  17422. int column= argument<int> (1,context);
  17423. int role= argument<int> (2,context);
  17424. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17425. QModelIndex cell= model->index(row,column);
  17426. QVariant value= model->data(cell,role);
  17427. QScriptValue retval= engine->newVariant(value);
  17428. retval.setProperty("value",QScriptValue(value.toString()));
  17429. return retval;
  17430. }
  17431. /*:267*//*268:*/
  17432. #line 6464 "./typica.w"
  17433. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  17434. {
  17435. QTableView*self= getself<QTableView*> (context);
  17436. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17437. model->clear();
  17438. return QScriptValue();
  17439. }
  17440. /*:268*//*269:*/
  17441. #line 6476 "./typica.w"
  17442. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  17443. {
  17444. QTableView*self= getself<QTableView*> (context);
  17445. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17446. int row= argument<int> (0,context);
  17447. return engine->newVariant(model->removeRow(row));
  17448. }
  17449. /*:269*//*270:*/
  17450. #line 6489 "./typica.w"
  17451. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  17452. {
  17453. QTableView*self= getself<QTableView*> (context);
  17454. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17455. QVariant value= argument<QVariant> (0,context);
  17456. int column= argument<int> (1,context);
  17457. return engine->newVariant(model->findData(value,column));
  17458. }
  17459. /*:270*//*271:*/
  17460. #line 6502 "./typica.w"
  17461. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  17462. {
  17463. setQWidgetProperties(value,engine);
  17464. value.setProperty("columnArray",
  17465. engine->newFunction(SaltTable_columnArray));
  17466. value.setProperty("quotedColumnArray",
  17467. engine->newFunction(SaltTable_quotedColumnArray));
  17468. value.setProperty("bindableColumnArray",
  17469. engine->newFunction(SaltTable_bindableColumnArray));
  17470. value.setProperty("bindableQuotedColumnArray",
  17471. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  17472. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  17473. value.setProperty("data",engine->newFunction(SaltTable_data));
  17474. value.setProperty("model",engine->newFunction(SaltTable_model));
  17475. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  17476. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  17477. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  17478. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  17479. }
  17480. /*:271*//*273:*/
  17481. #line 6539 "./typica.w"
  17482. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  17483. {
  17484. setQComboBoxProperties(value,engine);
  17485. }
  17486. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  17487. {
  17488. setQWidgetProperties(value,engine);
  17489. value.setProperty("currentData",
  17490. engine->newFunction(QComboBox_currentData));
  17491. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  17492. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  17493. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  17494. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  17495. }
  17496. QScriptValue QComboBox_currentData(QScriptContext*context,
  17497. QScriptEngine*engine)
  17498. {
  17499. QComboBox*self= getself<QComboBox*> (context);
  17500. return QScriptValue(engine,
  17501. self->itemData(self->currentIndex()).toString());
  17502. }
  17503. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  17504. {
  17505. QComboBox*self= getself<QComboBox*> (context);
  17506. self->addItem(argument<QString> (0,context));
  17507. return QScriptValue();
  17508. }
  17509. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  17510. {
  17511. QComboBox*self= getself<QComboBox*> (context);
  17512. self->setModel(argument<QAbstractItemModel*> (0,context));
  17513. return QScriptValue();
  17514. }
  17515. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  17516. {
  17517. QComboBox*self= getself<QComboBox*> (context);
  17518. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  17519. }
  17520. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  17521. {
  17522. QComboBox*self= getself<QComboBox*> (context);
  17523. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  17524. }
  17525. #line 1 "./abouttypica.w"
  17526. /*:273*//*286:*/
  17527. #line 401 "./units.w"
  17528. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  17529. {
  17530. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  17531. argument<Units::Unit> (1,context),
  17532. argument<Units::Unit> (2,context)));
  17533. }
  17534. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  17535. QScriptEngine*)
  17536. {
  17537. return QScriptValue(Units::convertRelativeTemperature(
  17538. argument<double> (0,context),
  17539. argument<Units::Unit> (1,context),
  17540. argument<Units::Unit> (2,context)));
  17541. }
  17542. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  17543. {
  17544. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  17545. }
  17546. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  17547. {
  17548. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  17549. argument<Units::Unit> (1,context),
  17550. argument<Units::Unit> (2,context)));
  17551. }
  17552. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  17553. {
  17554. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  17555. }
  17556. /*:286*//*289:*/
  17557. #line 449 "./units.w"
  17558. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  17559. {
  17560. return engine->newVariant(QVariant(value));
  17561. }
  17562. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  17563. {
  17564. value= sv.toVariant().value<Units::Unit> ();
  17565. }
  17566. /*:289*//*299:*/
  17567. #line 149 "./measurement.w"
  17568. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  17569. {
  17570. QScriptValue object;
  17571. if(context->argumentCount()==2||context->argumentCount()==3)
  17572. {
  17573. double measurement= argument<double> (0,context);
  17574. QTime timestamp= argument<QTime> (1,context);
  17575. Units::Unit unit= Units::Fahrenheit;
  17576. if(context->argumentCount()==3)
  17577. {
  17578. unit= argument<Units::Unit> (2,context);
  17579. }
  17580. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  17581. setMeasurementProperties(object,engine);
  17582. }
  17583. else
  17584. {
  17585. context->throwError("Incorrect number of arguments passed to "
  17586. "Measurement::Measurement(). This method takes two "
  17587. "or three arguments.");
  17588. }
  17589. return object;
  17590. }
  17591. /*:299*//*300:*/
  17592. #line 176 "./measurement.w"
  17593. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  17594. {
  17595. }
  17596. /*:300*//*301:*/
  17597. #line 184 "./measurement.w"
  17598. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  17599. {
  17600. QVariant var;
  17601. var.setValue(measurement);
  17602. return engine->newVariant(var);
  17603. }
  17604. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  17605. {
  17606. measurement= value.toVariant().value<Measurement> ();
  17607. }
  17608. #line 6608 "./typica.w"
  17609. /*:301*//*319:*/
  17610. #line 7186 "./typica.w"
  17611. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  17612. {
  17613. QScriptValue object;
  17614. if(context->argumentCount()==1)
  17615. {
  17616. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  17617. QScriptEngine::ScriptOwnership);
  17618. setDAQProperties(object,engine);
  17619. }
  17620. else if(context->argumentCount()==2)
  17621. {
  17622. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  17623. argument<QString> (1,context)),
  17624. QScriptEngine::ScriptOwnership);
  17625. setDAQProperties(object,engine);
  17626. }
  17627. else
  17628. {
  17629. context->throwError("Incorrect number of arguments passed to DAQ"
  17630. "constructor. The DAQ constructor takes one"
  17631. "string as an argument specifying a device name."
  17632. "Example: Dev1");
  17633. }
  17634. return object;
  17635. }
  17636. /*:319*//*320:*/
  17637. #line 7216 "./typica.w"
  17638. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  17639. {
  17640. setQObjectProperties(value,engine);
  17641. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  17642. }
  17643. /*:320*//*321:*/
  17644. #line 7226 "./typica.w"
  17645. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  17646. {
  17647. DAQ*self= getself<DAQ*> (context);
  17648. QScriptValue object;
  17649. if(self)
  17650. {
  17651. object=
  17652. engine->newQObject(self->newChannel(argument<int> (0,context),
  17653. argument<int> (1,context)));
  17654. setChannelProperties(object,engine);
  17655. }
  17656. return object;
  17657. }
  17658. /*:321*//*328:*/
  17659. #line 7382 "./typica.w"
  17660. QScriptValue constructFakeDAQ(QScriptContext*context,
  17661. QScriptEngine*engine)
  17662. {
  17663. QScriptValue object;
  17664. if(context->argumentCount()==1)
  17665. {
  17666. object=
  17667. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  17668. QScriptEngine::ScriptOwnership);
  17669. setFakeDAQProperties(object,engine);
  17670. }
  17671. else
  17672. {
  17673. context->throwError("Incorrect number of arguments passed to DAQ"
  17674. "constructor. The DAQ constructor takes one"
  17675. "string as an argument specifying a device name."
  17676. "Example: Dev1");
  17677. }
  17678. return object;
  17679. }
  17680. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  17681. {
  17682. setQObjectProperties(value,engine);
  17683. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  17684. }
  17685. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  17686. {
  17687. FakeDAQ*self= getself<FakeDAQ*> (context);
  17688. QScriptValue object;
  17689. if(self)
  17690. {
  17691. object=
  17692. engine->newQObject(self->newChannel(argument<int> (0,context),
  17693. argument<int> (1,context)));
  17694. setChannelProperties(object,engine);
  17695. }
  17696. return object;
  17697. }
  17698. /*:328*//*332:*/
  17699. #line 7473 "./typica.w"
  17700. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  17701. {
  17702. setQObjectProperties(value,engine);
  17703. }
  17704. /*:332*//*339:*/
  17705. #line 7665 "./typica.w"
  17706. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  17707. {
  17708. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  17709. setLinearCalibratorProperties(object,engine);
  17710. return object;
  17711. }
  17712. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  17713. {
  17714. setQObjectProperties(value,engine);
  17715. }
  17716. /*:339*//*344:*/
  17717. #line 7803 "./typica.w"
  17718. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  17719. {
  17720. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  17721. setLinearSplineInterpolatorProperties(object,engine);
  17722. return object;
  17723. }
  17724. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  17725. {
  17726. setQObjectProperties(value,engine);
  17727. }
  17728. /*:344*//*354:*/
  17729. #line 8012 "./typica.w"
  17730. QScriptValue constructTemperatureDisplay(QScriptContext*,
  17731. QScriptEngine*engine)
  17732. {
  17733. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  17734. setTemperatureDisplayProperties(object,engine);
  17735. return object;
  17736. }
  17737. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  17738. {
  17739. setQLCDNumberProperties(value,engine);
  17740. value.setProperty("setDisplayUnits",
  17741. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  17742. }
  17743. /*:354*//*355:*/
  17744. #line 8036 "./typica.w"
  17745. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  17746. {
  17747. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  17748. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  17749. return QScriptValue();
  17750. }
  17751. /*:355*//*362:*/
  17752. #line 8173 "./typica.w"
  17753. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  17754. QScriptEngine*engine)
  17755. {
  17756. QScriptValue object=
  17757. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  17758. setMeasurementTimeOffsetProperties(object,engine);
  17759. return object;
  17760. }
  17761. void setMeasurementTimeOffsetProperties(QScriptValue value,
  17762. QScriptEngine*engine)
  17763. {
  17764. setQObjectProperties(value,engine);
  17765. }
  17766. /*:362*//*367:*/
  17767. #line 8282 "./typica.w"
  17768. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  17769. {
  17770. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  17771. return object;
  17772. }
  17773. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  17774. {
  17775. setQObjectProperties(value,engine);
  17776. }
  17777. /*:367*//*372:*/
  17778. #line 8379 "./typica.w"
  17779. QScriptValue constructZeroEmitter(QScriptContext*context,
  17780. QScriptEngine*engine)
  17781. {
  17782. QScriptValue object=
  17783. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  17784. setZeroEmitterProperties(object,engine);
  17785. return object;
  17786. }
  17787. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  17788. {
  17789. setQObjectProperties(value,engine);
  17790. }
  17791. /*:372*//*377:*/
  17792. #line 8459 "./typica.w"
  17793. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  17794. QScriptEngine*engine)
  17795. {
  17796. QScriptValue object=
  17797. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  17798. setMeasurementAdapterProperties(object,engine);
  17799. return object;
  17800. }
  17801. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  17802. {
  17803. setQObjectProperties(value,engine);
  17804. }
  17805. /*:377*//*394:*/
  17806. #line 8921 "./typica.w"
  17807. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  17808. {
  17809. QScriptValue object= engine->newQObject(new GraphView);
  17810. setGraphViewProperties(object,engine);
  17811. return object;
  17812. }
  17813. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  17814. {
  17815. setQGraphicsViewProperties(value,engine);
  17816. }
  17817. /*:394*//*417:*/
  17818. #line 9559 "./typica.w"
  17819. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  17820. {
  17821. QScriptValue object= engine->newQObject(new ZoomLog);
  17822. setZoomLogProperties(object,engine);
  17823. return object;
  17824. }
  17825. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  17826. {
  17827. setQTableViewProperties(value,engine);
  17828. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  17829. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  17830. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  17831. value.setProperty("restoreState",
  17832. engine->newFunction(ZoomLog_restoreState));
  17833. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  17834. value.setProperty("saveTemporary",
  17835. engine->newFunction(ZoomLog_saveTemporary));
  17836. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  17837. }
  17838. /*:417*//*418:*/
  17839. #line 9586 "./typica.w"
  17840. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  17841. {
  17842. ZoomLog*self= getself<ZoomLog*> (context);
  17843. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  17844. return QScriptValue(engine,retval);
  17845. }
  17846. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  17847. {
  17848. ZoomLog*self= getself<ZoomLog*> (context);
  17849. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  17850. return QScriptValue(engine,retval);
  17851. }
  17852. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  17853. QScriptEngine*engine)
  17854. {
  17855. ZoomLog*self= getself<ZoomLog*> (context);
  17856. QString filename= QDir::tempPath();
  17857. filename.append("/");
  17858. filename.append(QUuid::createUuid().toString());
  17859. filename.append(".xml");
  17860. QFile*file= new QFile(filename);
  17861. self->saveXML(file);
  17862. file->close();
  17863. delete file;
  17864. return QScriptValue(engine,filename);
  17865. }
  17866. /*:418*//*419:*/
  17867. #line 9634 "./typica.w"
  17868. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  17869. {
  17870. ZoomLog*self= getself<ZoomLog*> (context);
  17871. QString key= argument<QString> (0,context);
  17872. int columns= argument<int> (1,context);
  17873. QSettings settings;
  17874. for(int i= 0;i<columns;i++)
  17875. {
  17876. if(self->columnWidth(i))
  17877. {
  17878. settings.beginGroup(key);
  17879. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  17880. settings.endGroup();
  17881. }
  17882. }
  17883. return QScriptValue();
  17884. }
  17885. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  17886. {
  17887. ZoomLog*self= getself<ZoomLog*> (context);
  17888. QString key= argument<QString> (0,context);
  17889. int columns= argument<int> (1,context);
  17890. QSettings settings;
  17891. for(int i= 0;i<columns;i++)
  17892. {
  17893. settings.beginGroup(key);
  17894. self->setColumnWidth(i,
  17895. settings.value(QString("%1").arg(i),80).toInt());
  17896. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  17897. {
  17898. self->setColumnWidth(i,80);
  17899. }
  17900. settings.endGroup();
  17901. }
  17902. return QScriptValue();
  17903. }
  17904. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  17905. {
  17906. ZoomLog*self= getself<ZoomLog*> (context);
  17907. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  17908. }
  17909. /*:419*//*420:*/
  17910. #line 9687 "./typica.w"
  17911. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  17912. {
  17913. ZoomLog*self= getself<ZoomLog*> (context);
  17914. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  17915. return QScriptValue();
  17916. }
  17917. /*:420*//*455:*/
  17918. #line 10507 "./typica.w"
  17919. QScriptValue constructAnnotationButton(QScriptContext*context,
  17920. QScriptEngine*engine)
  17921. {
  17922. QScriptValue object=
  17923. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  17924. setAnnotationButtonProperties(object,engine);
  17925. return object;
  17926. }
  17927. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  17928. {
  17929. setQPushButtonProperties(value,engine);
  17930. }
  17931. /*:455*//*463:*/
  17932. #line 10650 "./typica.w"
  17933. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  17934. QScriptEngine*engine)
  17935. {
  17936. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  17937. argument<QString> (0,context),argument<QString> (1,context)));
  17938. setAnnotationSpinBoxProperties(object,engine);
  17939. return object;
  17940. }
  17941. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17942. {
  17943. setQDoubleSpinBoxProperties(value,engine);
  17944. }
  17945. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17946. {
  17947. setQAbstractSpinBoxProperties(value,engine);
  17948. }
  17949. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  17950. {
  17951. setQWidgetProperties(value,engine);
  17952. }
  17953. /*:463*//*484:*/
  17954. #line 11073 "./typica.w"
  17955. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  17956. {
  17957. QScriptValue object= engine->newQObject(new TimerDisplay);
  17958. setTimerDisplayProperties(object,engine);
  17959. return object;
  17960. }
  17961. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  17962. {
  17963. setQLCDNumberProperties(value,engine);
  17964. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  17965. }
  17966. /*:484*//*485:*/
  17967. #line 11092 "./typica.w"
  17968. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  17969. {
  17970. TimerDisplay*self= getself<TimerDisplay*> (context);
  17971. if(self)
  17972. {
  17973. switch(argument<int> (0,context))
  17974. {
  17975. case 0:
  17976. self->setMode(TimerDisplay::CountUp);
  17977. break;
  17978. case 1:
  17979. self->setMode(TimerDisplay::CountDown);
  17980. break;
  17981. case 2:
  17982. self->setMode(TimerDisplay::Clock);
  17983. break;
  17984. default:
  17985. break;
  17986. }
  17987. }
  17988. return QScriptValue();
  17989. }
  17990. /*:485*//*512:*/
  17991. #line 11598 "./typica.w"
  17992. QScriptValue constructWidgetDecorator(QScriptContext*context,
  17993. QScriptEngine*engine)
  17994. {
  17995. QWidget*widget= argument<QWidget*> (0,context);
  17996. QString text= argument<QString> (1,context);
  17997. Qt::Orientations orientation;
  17998. switch(argument<int> (2,context))
  17999. {
  18000. case 2:
  18001. orientation= Qt::Vertical;
  18002. break;
  18003. default:
  18004. orientation= Qt::Horizontal;
  18005. break;
  18006. }
  18007. QScriptValue object=
  18008. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  18009. setWidgetDecoratorProperties(object,engine);
  18010. return object;
  18011. }
  18012. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  18013. {
  18014. setQWidgetProperties(value,engine);
  18015. }
  18016. /*:512*//*525:*/
  18017. #line 11879 "./typica.w"
  18018. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  18019. {
  18020. QScriptValue object= engine->newQObject(new LogEditWindow);
  18021. return object;
  18022. }
  18023. /*:525*//*544:*/
  18024. #line 12406 "./typica.w"
  18025. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  18026. {
  18027. QIODevice*device= argument<QIODevice*> (0,context);
  18028. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  18029. argument<int> (1,context)));
  18030. object.setProperty("input",engine->newFunction(XMLInput_input));
  18031. return object;
  18032. }
  18033. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  18034. {
  18035. XMLInput*self= getself<XMLInput*> (context);
  18036. self->input();
  18037. return QScriptValue();
  18038. }
  18039. /*:544*//*558:*/
  18040. #line 157 "./webview.w"
  18041. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  18042. {
  18043. QScriptValue object= engine->newQObject(new TypicaWebView);
  18044. setQWebViewProperties(object,engine);
  18045. return object;
  18046. }
  18047. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  18048. {
  18049. setQWidgetProperties(value,engine);
  18050. }
  18051. /*:558*//*559:*/
  18052. #line 174 "./webview.w"
  18053. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  18054. QStack<QLayout*> *layoutStack)
  18055. {
  18056. TypicaWebView*view= new TypicaWebView;
  18057. if(element.hasAttribute("id"))
  18058. {
  18059. view->setObjectName(element.attribute("id"));
  18060. }
  18061. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18062. layout->addWidget(view);
  18063. }
  18064. /*:559*//*564:*/
  18065. #line 225 "./webview.w"
  18066. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  18067. {
  18068. QVariant var;
  18069. var.setValue(element);
  18070. QScriptValue object= engine->newVariant(var);
  18071. return object;
  18072. }
  18073. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  18074. {
  18075. element= value.toVariant().value<QWebElement> ();
  18076. }
  18077. /*:564*//*569:*/
  18078. #line 290 "./webview.w"
  18079. template<> QWebElement argument(int arg,QScriptContext*context)
  18080. {
  18081. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  18082. }
  18083. /*:569*//*570:*/
  18084. #line 299 "./webview.w"
  18085. QScriptValue constructWebElement(QScriptContext*context,
  18086. QScriptEngine*engine)
  18087. {
  18088. QWebElement element= argument<QWebElement> (0,context);
  18089. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  18090. return object;
  18091. }
  18092. /*:570*//*638:*/
  18093. #line 13759 "./typica.w"
  18094. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  18095. {
  18096. QScriptValue object= engine->newQObject(new SqlQueryView);
  18097. setSqlQueryViewProperties(object,engine);
  18098. return object;
  18099. }
  18100. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  18101. {
  18102. setQTableViewProperties(value,engine);
  18103. value.setProperty("setHeaderData",
  18104. engine->newFunction(SqlQueryView_setHeaderData));
  18105. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  18106. }
  18107. /*:638*//*639:*/
  18108. #line 13777 "./typica.w"
  18109. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  18110. {
  18111. SqlQueryView*self= getself<SqlQueryView*> (context);
  18112. QString query= argument<QString> (0,context);
  18113. self->setQuery(query);
  18114. self->reset();
  18115. return QScriptValue();
  18116. }
  18117. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  18118. QScriptEngine*)
  18119. {
  18120. SqlQueryView*self= getself<SqlQueryView*> (context);
  18121. int section= argument<int> (0,context);
  18122. QString data= argument<QString> (1,context);
  18123. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  18124. return QScriptValue();
  18125. }
  18126. /*:639*//*647:*/
  18127. #line 13986 "./typica.w"
  18128. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  18129. QStack<QLayout*> *layoutStack)
  18130. {
  18131. QTextEdit*widget= new QTextEdit;
  18132. if(element.hasAttribute("id"))
  18133. {
  18134. widget->setObjectName(element.attribute("id"));
  18135. }
  18136. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18137. layout->addWidget(widget);
  18138. QTextDocument*document= new QTextDocument;
  18139. QFont defaultFont;
  18140. defaultFont.setPointSize(11);
  18141. document->setDefaultFont(defaultFont);
  18142. QTextCursor cursor(document);
  18143. /*648:*/
  18144. #line 14009 "./typica.w"
  18145. QDomNodeList children= element.childNodes();
  18146. for(int i= 0;i<children.count();i++)
  18147. {
  18148. QDomNode current;
  18149. QDomElement currentElement;
  18150. current= children.at(i);
  18151. if(current.isElement())
  18152. {
  18153. currentElement= current.toElement();
  18154. /*649:*/
  18155. #line 14026 "./typica.w"
  18156. if(currentElement.tagName()=="style")
  18157. {
  18158. document->setDefaultStyleSheet(currentElement.text());
  18159. }
  18160. /*:649*//*650:*/
  18161. #line 14037 "./typica.w"
  18162. if(currentElement.tagName()=="html")
  18163. {
  18164. cursor.insertHtml(currentElement.text());
  18165. }
  18166. /*:650*//*651:*/
  18167. #line 14047 "./typica.w"
  18168. if(currentElement.tagName()=="text")
  18169. {
  18170. cursor.insertText(currentElement.text());
  18171. }
  18172. /*:651*//*652:*/
  18173. #line 14057 "./typica.w"
  18174. if(currentElement.tagName()=="table")
  18175. {
  18176. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  18177. ReportTable*table= new ReportTable(frame,currentElement);
  18178. table->setParent(widget);
  18179. if(currentElement.hasAttribute("id"))
  18180. {
  18181. table->setObjectName(currentElement.attribute("id"));
  18182. }
  18183. }
  18184. /*:652*/
  18185. #line 14019 "./typica.w"
  18186. }
  18187. }
  18188. /*:648*/
  18189. #line 14002 "./typica.w"
  18190. widget->setDocument(document);
  18191. }
  18192. /*:647*//*663:*/
  18193. #line 14270 "./typica.w"
  18194. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  18195. {
  18196. QTextEdit*self= getself<QTextEdit*> (context);
  18197. QTextDocument*document= self->document();
  18198. QPrinter printer;
  18199. QPrintDialog printwindow(&printer,self);
  18200. if(printwindow.exec()!=QDialog::Accepted)
  18201. {
  18202. return QScriptValue();
  18203. }
  18204. document->print(&printer);
  18205. return QScriptValue();
  18206. }
  18207. /*:663*//*664:*/
  18208. #line 14288 "./typica.w"
  18209. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  18210. {
  18211. setQAbstractScrollAreaProperties(value,engine);
  18212. value.setProperty("print",engine->newFunction(QTextEdit_print));
  18213. }
  18214. #line 1 "./daterangeselector.w"
  18215. /*:664*//*683:*/
  18216. #line 461 "./daterangeselector.w"
  18217. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  18218. QStack<QLayout*> *layoutStack)
  18219. {
  18220. DateRangeSelector*widget= new DateRangeSelector;
  18221. if(element.hasAttribute("id"))
  18222. {
  18223. widget->setObjectName(element.attribute("id"));
  18224. }
  18225. if(element.hasAttribute("initial"))
  18226. {
  18227. widget->setCurrentIndex(element.attribute("initial").toInt());
  18228. }
  18229. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18230. layout->addWidget(widget);
  18231. }
  18232. /*:683*//*694:*/
  18233. #line 14468 "./typica.w"
  18234. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  18235. QStack<QLayout*> *layoutStack)
  18236. {
  18237. FormArray*widget= new FormArray(element);
  18238. if(element.hasAttribute("id"))
  18239. {
  18240. widget->setObjectName(element.attribute("id"));
  18241. }
  18242. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18243. layout->addWidget(widget);
  18244. }
  18245. /*:694*//*715:*/
  18246. #line 15055 "./typica.w"
  18247. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  18248. QStack<QLayout*> *layoutStack)
  18249. {
  18250. ScaleControl*scale= new ScaleControl;
  18251. if(element.hasAttribute("id"))
  18252. {
  18253. scale->setObjectName(element.attribute("id"));
  18254. }
  18255. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18256. layout->addWidget(scale);
  18257. }
  18258. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  18259. QStack<QLayout*> *layoutStack)
  18260. {
  18261. IntensityControl*scale= new IntensityControl;
  18262. if(element.hasAttribute("id"))
  18263. {
  18264. scale->setObjectName(element.attribute("id"));
  18265. }
  18266. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18267. layout->addWidget(scale);
  18268. }
  18269. /*:715*//*741:*/
  18270. #line 15645 "./typica.w"
  18271. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  18272. {
  18273. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  18274. setDeviceTreeModelProperties(object,engine);
  18275. return object;
  18276. }
  18277. /*:741*//*743:*/
  18278. #line 15668 "./typica.w"
  18279. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  18280. {
  18281. setQAbstractItemModelProperties(value,engine);
  18282. value.setProperty("referenceElement",
  18283. engine->newFunction(DeviceTreeModel_referenceElement));
  18284. }
  18285. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  18286. {
  18287. setQObjectProperties(value,engine);
  18288. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  18289. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  18290. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  18291. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  18292. }
  18293. /*:743*//*744:*/
  18294. #line 15695 "./typica.w"
  18295. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  18296. QScriptEngine*engine)
  18297. {
  18298. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  18299. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  18300. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  18301. QDomElement node;
  18302. QVariantMap retval;
  18303. retval.insert("driver",referenceElement.attribute("driver"));
  18304. for(int i= 0;i<configData.size();i++)
  18305. {
  18306. node= configData.at(i).toElement();
  18307. retval.insert(node.attribute("name"),node.attribute("value"));
  18308. }
  18309. return engine->toScriptValue(retval);
  18310. }
  18311. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  18312. {
  18313. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18314. QModelIndex index= argument<QModelIndex> (0,context);
  18315. int role= argument<int> (1,context);
  18316. return engine->toScriptValue(model->data(index,role));
  18317. }
  18318. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  18319. {
  18320. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18321. int row= 0;
  18322. int column= 0;
  18323. QModelIndex index;
  18324. if(context->argumentCount()> 1)
  18325. {
  18326. row= argument<int> (0,context);
  18327. column= argument<int> (1,context);
  18328. }
  18329. if(context->argumentCount()> 2)
  18330. {
  18331. index= argument<QModelIndex> (2,context);
  18332. }
  18333. QModelIndex retval= model->index(row,column,index);
  18334. return engine->toScriptValue(retval);
  18335. }
  18336. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  18337. QScriptEngine*)
  18338. {
  18339. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18340. QModelIndex index;
  18341. if(context->argumentCount()==1)
  18342. {
  18343. index= argument<QModelIndex> (0,context);
  18344. }
  18345. return QScriptValue(model->rowCount(index));
  18346. }
  18347. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  18348. QScriptEngine*engine)
  18349. {
  18350. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18351. QModelIndex index;
  18352. if(context->argumentCount()==1)
  18353. {
  18354. index= argument<QModelIndex> (0,context);
  18355. }
  18356. return QScriptValue(engine,model->hasChildren(index));
  18357. }
  18358. /*:744*//*747:*/
  18359. #line 15779 "./typica.w"
  18360. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  18361. {
  18362. QVariant var;
  18363. var.setValue(index);
  18364. QScriptValue object= engine->newVariant(var);
  18365. return object;
  18366. }
  18367. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  18368. {
  18369. index= value.toVariant().value<QModelIndex> ();
  18370. }
  18371. /*:747*//*763:*/
  18372. #line 16077 "./typica.w"
  18373. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  18374. QScriptEngine*engine)
  18375. {
  18376. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  18377. return object;
  18378. }
  18379. /*:763*//*834:*/
  18380. #line 47 "./settings.w"
  18381. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  18382. {
  18383. QScriptValue object= engine->newQObject(new SettingsWindow);
  18384. return object;
  18385. }
  18386. /*:834*//*859:*/
  18387. #line 18727 "./typica.w"
  18388. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  18389. {
  18390. QScriptValue object;
  18391. if(context->argumentCount()==2)
  18392. {
  18393. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  18394. argument<QModelIndex> (1,context)),
  18395. QScriptEngine::ScriptOwnership);
  18396. setModbusRTUDeviceProperties(object,engine);
  18397. }
  18398. else
  18399. {
  18400. context->throwError("Incorrect number of arguments passed to "
  18401. "ModbusRTUDevice constructor. This takes the configuration model "
  18402. "and an index.");
  18403. }
  18404. return object;
  18405. }
  18406. /*:859*//*860:*/
  18407. #line 18749 "./typica.w"
  18408. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  18409. {
  18410. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  18411. QScriptValue object;
  18412. if(self)
  18413. {
  18414. if(self->channels.size()> 0)
  18415. {
  18416. object= engine->newQObject(self->channels.at(0));
  18417. setChannelProperties(object,engine);
  18418. }
  18419. }
  18420. return object;
  18421. }
  18422. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  18423. {
  18424. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  18425. QScriptValue object;
  18426. if(self)
  18427. {
  18428. if(self->channels.size()> 1)
  18429. {
  18430. object= engine->newQObject(self->channels.at(1));
  18431. setChannelProperties(object,engine);
  18432. }
  18433. }
  18434. return object;
  18435. }
  18436. /*:860*//*861:*/
  18437. #line 18782 "./typica.w"
  18438. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  18439. {
  18440. setQObjectProperties(value,engine);
  18441. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  18442. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  18443. }
  18444. /*:861*//*879:*/
  18445. #line 357 "./unsupportedserial.w"
  18446. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  18447. {
  18448. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  18449. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  18450. QScriptValue object= engine->newQObject(device);
  18451. setQObjectProperties(object,engine);
  18452. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  18453. return object;
  18454. }
  18455. /*:879*//*884:*/
  18456. #line 430 "./unsupportedserial.w"
  18457. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  18458. {
  18459. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  18460. QScriptValue object;
  18461. if(self)
  18462. {
  18463. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  18464. setChannelProperties(object,engine);
  18465. }
  18466. return object;
  18467. }
  18468. /*:884*//*891:*/
  18469. #line 630 "./unsupportedserial.w"
  18470. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  18471. {
  18472. return engine->toScriptValue<QTime> (QTime::currentTime());
  18473. }
  18474. /*:891*//*895:*/
  18475. #line 667 "./unsupportedserial.w"
  18476. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  18477. {
  18478. QScriptValue object= engine->newQObject(new QextSerialPort());
  18479. setSerialPortProperties(object,engine);
  18480. return object;
  18481. }
  18482. /*:895*//*896:*/
  18483. #line 678 "./unsupportedserial.w"
  18484. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  18485. {
  18486. setQIODeviceProperties(value,engine);
  18487. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  18488. }
  18489. /*:896*//*897:*/
  18490. #line 687 "./unsupportedserial.w"
  18491. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  18492. {
  18493. QextSerialPort*self= getself<QextSerialPort*> (context);
  18494. self->flush();
  18495. return QScriptValue();
  18496. }
  18497. /*:897*//*900:*/
  18498. #line 721 "./unsupportedserial.w"
  18499. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  18500. {
  18501. setQObjectProperties(value,engine);
  18502. }
  18503. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  18504. {
  18505. QScriptValue object= engine->newQObject(new QTimer);
  18506. setQTimerProperties(object,engine);
  18507. return object;
  18508. }
  18509. #line 19333 "./typica.w"
  18510. #line 1 "./phidgets.w"
  18511. /*:900*//*921:*/
  18512. #line 463 "./phidgets.w"
  18513. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  18514. {
  18515. if(context->argumentCount()!=1)
  18516. {
  18517. context->throwError("Incorrect number of arguments passed to "
  18518. "PhidgetsTemperatureSensor constructor. This takes "
  18519. "a QModelIndex.");
  18520. }
  18521. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  18522. setQObjectProperties(object,engine);
  18523. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  18524. return object;
  18525. }
  18526. /*:921*//*922:*/
  18527. #line 480 "./phidgets.w"
  18528. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  18529. {
  18530. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  18531. QScriptValue object;
  18532. if(self)
  18533. {
  18534. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  18535. setChannelProperties(object,engine);
  18536. }
  18537. return object;
  18538. }
  18539. #line 19335 "./typica.w"
  18540. /*:922*//*954:*/
  18541. #line 151 "./rate.w"
  18542. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  18543. {
  18544. int cachetime= 1;
  18545. int scaletime= 1;
  18546. if(context->argumentCount()> 0)
  18547. {
  18548. cachetime= argument<int> (0,context);
  18549. if(context->argumentCount()> 1)
  18550. {
  18551. scaletime= argument<int> (1,context);
  18552. }
  18553. }
  18554. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  18555. setRateOfChangeProperties(object,engine);
  18556. return object;
  18557. }
  18558. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  18559. {
  18560. setQObjectProperties(value,engine);
  18561. }
  18562. /*:954*//*979:*/
  18563. #line 614 "./dataqsdk.w"
  18564. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  18565. {
  18566. QScriptValue object;
  18567. if(context->argumentCount()==1)
  18568. {
  18569. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  18570. QScriptEngine::ScriptOwnership);
  18571. setDataqSdkDeviceProperties(object,engine);
  18572. }
  18573. else
  18574. {
  18575. context->throwError("Incorrect number of arguments passed to "
  18576. "DataqSdkDevice. The constructor takes one string "
  18577. "as an argument specifying a device name. "
  18578. "Example: Dev1");
  18579. }
  18580. return object;
  18581. }
  18582. /*:979*//*980:*/
  18583. #line 637 "./dataqsdk.w"
  18584. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  18585. {
  18586. setQObjectProperties(value,engine);
  18587. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  18588. }
  18589. /*:980*//*981:*/
  18590. #line 647 "./dataqsdk.w"
  18591. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  18592. {
  18593. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  18594. QScriptValue object;
  18595. if(self)
  18596. {
  18597. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  18598. setChannelProperties(object,engine);
  18599. }
  18600. return object;
  18601. }
  18602. /*:981*//*1006:*/
  18603. #line 80 "./scales.w"
  18604. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  18605. {
  18606. QScriptValue object;
  18607. QString labelText= "";
  18608. if(context->argumentCount()==1)
  18609. {
  18610. labelText= argument<QString> (0,context);
  18611. }
  18612. object= engine->newQObject(new DragLabel(labelText));
  18613. setDragLabelProperties(object,engine);
  18614. return object;
  18615. }
  18616. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  18617. {
  18618. setQLabelProperties(value,engine);
  18619. }
  18620. /*:1006*//*1016:*/
  18621. #line 272 "./scales.w"
  18622. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  18623. {
  18624. return engine->newVariant(QVariant((int)(value)));
  18625. }
  18626. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  18627. {
  18628. value= (BaudRateType)(sv.toVariant().toInt());
  18629. }
  18630. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  18631. {
  18632. return engine->newVariant(QVariant((int)(value)));
  18633. }
  18634. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  18635. {
  18636. value= (DataBitsType)(sv.toVariant().toInt());
  18637. }
  18638. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  18639. {
  18640. return engine->newVariant(QVariant((int)(value)));
  18641. }
  18642. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  18643. {
  18644. value= (ParityType)(sv.toVariant().toInt());
  18645. }
  18646. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  18647. {
  18648. return engine->newVariant(QVariant((int)(value)));
  18649. }
  18650. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  18651. {
  18652. value= (StopBitsType)(sv.toVariant().toInt());
  18653. }
  18654. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  18655. {
  18656. return engine->newVariant(QVariant((int)(value)));
  18657. }
  18658. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  18659. {
  18660. value= (FlowType)(sv.toVariant().toInt());
  18661. }
  18662. /*:1016*//*1019:*/
  18663. #line 341 "./scales.w"
  18664. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  18665. {
  18666. setQIODeviceProperties(value,engine);
  18667. }
  18668. /*:1019*//*1020:*/
  18669. #line 349 "./scales.w"
  18670. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  18671. {
  18672. QScriptValue object;
  18673. if(context->argumentCount()==1)
  18674. {
  18675. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  18676. setSerialScaleProperties(object,engine);
  18677. }
  18678. else
  18679. {
  18680. context->throwError("Incorrect number of arguments passed to "
  18681. "SerialScale. The constructor takes one string "
  18682. "as an argument specifying a port name.");
  18683. }
  18684. return object;
  18685. }
  18686. /*:1020*//*1042:*/
  18687. #line 278 "./valueannotation.w"
  18688. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  18689. {
  18690. QScriptValue object= engine->newQObject(new ValueAnnotation);
  18691. setValueAnnotationProperties(object,engine);
  18692. return object;
  18693. }
  18694. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  18695. {
  18696. setQObjectProperties(value,engine);
  18697. }
  18698. #line 19982 "./typica.w"
  18699. /*:1042*/
  18700. #line 530 "./typica.w"
  18701. /*617:*/
  18702. #line 13394 "./typica.w"
  18703. void messageFileOutput(QtMsgType,const char*msg)
  18704. {
  18705. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  18706. output.open(QIODevice::WriteOnly|QIODevice::Append);
  18707. QTextStream outstream(&output);
  18708. outstream<<msg<<"\r\n";
  18709. }
  18710. /*:617*/
  18711. #line 531 "./typica.w"
  18712. /*614:*/
  18713. #line 13355 "./typica.w"
  18714. int main(int argc,char**argv)
  18715. {
  18716. int*c= &argc;
  18717. Application app(*c,argv);
  18718. QSettings settings;
  18719. /*615:*/
  18720. #line 13381 "./typica.w"
  18721. if(settings.value("settings/advanced/logging",false).toBool())
  18722. {
  18723. qInstallMsgHandler(messageFileOutput);
  18724. }
  18725. /*:615*/
  18726. #line 13361 "./typica.w"
  18727. /*618:*/
  18728. #line 13407 "./typica.w"
  18729. QStringList themeSearchPath= QIcon::themeSearchPaths();
  18730. themeSearchPath.append(":/resources/icons/tango");
  18731. QIcon::setThemeSearchPaths(themeSearchPath);
  18732. QIcon::setThemeName(":/resources/icons/tango");
  18733. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  18734. /*:618*/
  18735. #line 13362 "./typica.w"
  18736. /*619:*/
  18737. #line 13427 "./typica.w"
  18738. QFile entypo(":/resources/fonts/entypo.ttf");
  18739. entypo.open(QIODevice::ReadOnly);
  18740. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  18741. entypo.close();
  18742. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  18743. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  18744. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  18745. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  18746. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  18747. /*:619*/
  18748. #line 13363 "./typica.w"
  18749. /*773:*/
  18750. #line 16367 "./typica.w"
  18751. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  18752. /*:773*//*783:*/
  18753. #line 16609 "./typica.w"
  18754. app.registerDeviceConfigurationWidget("nidaqmxbase",
  18755. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  18756. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  18757. NiDaqMxBase9211ConfWidget::staticMetaObject);
  18758. app.registerDeviceConfigurationWidget("ni9211seriestc",
  18759. Ni9211TcConfWidget::staticMetaObject);
  18760. /*:783*//*791:*/
  18761. #line 16840 "./typica.w"
  18762. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  18763. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  18764. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  18765. /*:791*//*815:*/
  18766. #line 17805 "./typica.w"
  18767. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  18768. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  18769. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  18770. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  18771. /*:815*//*820:*/
  18772. #line 17890 "./typica.w"
  18773. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  18774. /*:820*//*823:*/
  18775. #line 17960 "./typica.w"
  18776. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  18777. /*:823*//*826:*/
  18778. #line 18087 "./typica.w"
  18779. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  18780. #line 1 "./freeannotation.w"
  18781. /*:826*//*830:*/
  18782. #line 57 "./freeannotation.w"
  18783. app.registerDeviceConfigurationWidget("freeannotation",
  18784. FreeAnnotationConfWidget::staticMetaObject);
  18785. #line 18091 "./typica.w"
  18786. #line 1 "./settings.w"
  18787. /*:830*//*864:*/
  18788. #line 19323 "./typica.w"
  18789. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  18790. /*:864*//*874:*/
  18791. #line 264 "./unsupportedserial.w"
  18792. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  18793. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  18794. app.registerDeviceConfigurationWidget("unsupporteddevice",
  18795. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  18796. /*:874*//*908:*/
  18797. #line 181 "./phidgets.w"
  18798. app.registerDeviceConfigurationWidget("phidgets1048",
  18799. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  18800. app.registerDeviceConfigurationWidget("phidgets1048channel",
  18801. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  18802. /*:908*//*928:*/
  18803. #line 19457 "./typica.w"
  18804. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  18805. /*:928*//*931:*/
  18806. #line 19517 "./typica.w"
  18807. app.registerDeviceConfigurationWidget("coolingtimer",
  18808. CoolingTimerConfWidget::staticMetaObject);
  18809. /*:931*//*936:*/
  18810. #line 19776 "./typica.w"
  18811. app.registerDeviceConfigurationWidget("rangetimer",
  18812. RangeTimerConfWidget::staticMetaObject);
  18813. /*:936*//*941:*/
  18814. #line 19877 "./typica.w"
  18815. app.registerDeviceConfigurationWidget("multirangetimer",
  18816. MultiRangeTimerConfWidget::staticMetaObject);
  18817. /*:941*//*946:*/
  18818. #line 19972 "./typica.w"
  18819. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  18820. #line 1 "./rate.w"
  18821. /*:946*//*958:*/
  18822. #line 253 "./rate.w"
  18823. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  18824. /*:958*//*999:*/
  18825. #line 1233 "./dataqsdk.w"
  18826. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  18827. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  18828. DataqSdkChannelConfWidget::staticMetaObject);
  18829. /*:999*//*1024:*/
  18830. #line 490 "./scales.w"
  18831. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  18832. /*:1024*//*1032:*/
  18833. #line 138 "./valueannotation.w"
  18834. app.registerDeviceConfigurationWidget("valueannotation",
  18835. ValueAnnotationConfWidget::staticMetaObject);
  18836. /*:1032*/
  18837. #line 13365 "./typica.w"
  18838. /*620:*/
  18839. #line 13444 "./typica.w"
  18840. if(settings.value("database/exists","false").toString()=="true")
  18841. {
  18842. /*625:*/
  18843. #line 13573 "./typica.w"
  18844. QSqlDatabase database=
  18845. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  18846. database.setConnectOptions("application_name=Typica");
  18847. database.setHostName(settings.value("database/hostname").toString());
  18848. database.setPort(settings.value("database/portnumber",5432).toInt());
  18849. database.setDatabaseName(settings.value("database/dbname").toString());
  18850. database.setUserName(settings.value("database/user").toString());
  18851. database.setPassword(settings.value("database/password").toString());
  18852. if(!database.open())
  18853. {
  18854. settings.setValue("database/exists","false");
  18855. }
  18856. else
  18857. {
  18858. database.close();
  18859. }
  18860. /*:625*/
  18861. #line 13447 "./typica.w"
  18862. }
  18863. if(settings.value("database/exists","false").toString()=="false")
  18864. {
  18865. /*624:*/
  18866. #line 13564 "./typica.w"
  18867. SqlConnectionSetup dialog;
  18868. dialog.exec();
  18869. /*:624*/
  18870. #line 13451 "./typica.w"
  18871. }
  18872. /*:620*/
  18873. #line 13366 "./typica.w"
  18874. /*189:*/
  18875. #line 4332 "./typica.w"
  18876. QStringList arguments= QCoreApplication::arguments();
  18877. int position= arguments.indexOf("-c");
  18878. QString filename= QString();
  18879. if(position!=-1)
  18880. {
  18881. if(arguments.size()>=position+1)
  18882. {
  18883. filename= arguments.at(position+1);
  18884. }
  18885. }
  18886. if(filename.isEmpty())
  18887. {
  18888. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  18889. settings.value("config","").toString());
  18890. }
  18891. QDir directory;
  18892. if(!filename.isEmpty())
  18893. {
  18894. QFile file(filename);
  18895. QFileInfo info(filename);
  18896. directory= info.dir();
  18897. QTranslator*configtr= new QTranslator;
  18898. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  18899. QString("%1/Translations").arg(directory.canonicalPath())))
  18900. {
  18901. QCoreApplication::installTranslator(configtr);
  18902. }
  18903. settings.setValue("config",directory.path());
  18904. if(file.open(QIODevice::ReadOnly))
  18905. {
  18906. app.configuration()->setContent(&file,true);
  18907. }
  18908. }
  18909. /*190:*/
  18910. #line 4372 "./typica.w"
  18911. QDomElement root= app.configuration()->documentElement();
  18912. QDomNodeList children= root.childNodes();
  18913. QString replacementDoc;
  18914. QDomDocument includedDoc;
  18915. QDomDocumentFragment fragment;
  18916. for(int i= 0;i<children.size();i++)
  18917. {
  18918. QDomNode currentNode= children.at(i);
  18919. QDomElement currentElement;
  18920. if(currentNode.nodeName()=="include")
  18921. {
  18922. currentElement= currentNode.toElement();
  18923. if(currentElement.hasAttribute("src"))
  18924. {
  18925. replacementDoc= directory.path();
  18926. replacementDoc.append('/');
  18927. replacementDoc.append(currentElement.attribute("src"));
  18928. QFile doc(replacementDoc);
  18929. if(doc.open(QIODevice::ReadOnly))
  18930. {
  18931. includedDoc.setContent(&doc,true);
  18932. fragment= includedDoc.createDocumentFragment();
  18933. fragment.appendChild(includedDoc.documentElement());
  18934. root.replaceChild(fragment,currentNode);
  18935. doc.close();
  18936. }
  18937. }
  18938. }
  18939. }
  18940. /*:190*/
  18941. #line 4366 "./typica.w"
  18942. /*:189*/
  18943. #line 13367 "./typica.w"
  18944. /*7:*/
  18945. #line 660 "./typica.w"
  18946. QScriptEngine*engine= new QScriptEngine;
  18947. QScriptValue constructor;
  18948. QScriptValue value;
  18949. /*:7*//*17:*/
  18950. #line 857 "./typica.w"
  18951. constructor= engine->newFunction(constructQWidget);
  18952. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  18953. engine->globalObject().setProperty("QWidget",value);
  18954. /*:17*//*21:*/
  18955. #line 944 "./typica.w"
  18956. constructor= engine->newFunction(displayWarning);
  18957. engine->globalObject().setProperty("displayWarning",constructor);
  18958. constructor= engine->newFunction(displayError);
  18959. engine->globalObject().setProperty("displayError",constructor);
  18960. /*:21*//*31:*/
  18961. #line 1150 "./typica.w"
  18962. constructor= engine->newFunction(constructQMainWindow);
  18963. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  18964. constructor);
  18965. engine->globalObject().setProperty("QMainWindow",value);
  18966. /*:31*//*42:*/
  18967. #line 1355 "./typica.w"
  18968. constructor= engine->newFunction(constructQFrame);
  18969. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  18970. engine->globalObject().setProperty("QFrame",value);
  18971. /*:42*//*45:*/
  18972. #line 1388 "./typica.w"
  18973. constructor= engine->newFunction(constructQLabel);
  18974. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  18975. engine->globalObject().setProperty("QLabel",value);
  18976. /*:45*//*48:*/
  18977. #line 1431 "./typica.w"
  18978. constructor= engine->newFunction(constructQSvgWidget);
  18979. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  18980. engine->globalObject().setProperty("QSvgWidget",value);
  18981. /*:48*//*54:*/
  18982. #line 1513 "./typica.w"
  18983. constructor= engine->newFunction(constructQLineEdit);
  18984. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  18985. engine->globalObject().setProperty("QLineEdit",value);
  18986. /*:54*//*58:*/
  18987. #line 1560 "./typica.w"
  18988. constructor= engine->newFunction(constructQSplitter);
  18989. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  18990. engine->globalObject().setProperty("QSplitter",value);
  18991. /*:58*//*66:*/
  18992. #line 1749 "./typica.w"
  18993. constructor= engine->newFunction(constructQBoxLayout);
  18994. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  18995. engine->globalObject().setProperty("QBoxLayout",value);
  18996. /*:66*//*70:*/
  18997. #line 1861 "./typica.w"
  18998. constructor= engine->newFunction(constructQAction);
  18999. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  19000. engine->globalObject().setProperty("QAction",value);
  19001. /*:70*//*73:*/
  19002. #line 1920 "./typica.w"
  19003. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  19004. value.setProperty("getOpenFileName",
  19005. engine->newFunction(QFileDialog_getOpenFileName));
  19006. value.setProperty("getSaveFileName",
  19007. engine->newFunction(QFileDialog_getSaveFileName));
  19008. engine->globalObject().setProperty("QFileDialog",value);
  19009. /*:73*//*78:*/
  19010. #line 2038 "./typica.w"
  19011. constructor= engine->newFunction(constructQFile);
  19012. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  19013. engine->globalObject().setProperty("QFile",value);
  19014. /*:78*//*89:*/
  19015. #line 2256 "./typica.w"
  19016. constructor= engine->newFunction(constructQProcess);
  19017. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  19018. engine->globalObject().setProperty("QProcess",value);
  19019. /*:89*//*98:*/
  19020. #line 2405 "./typica.w"
  19021. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  19022. constructor= engine->newFunction(constructQByteArray);
  19023. engine->globalObject().setProperty("QByteArray",constructor);
  19024. /*:98*//*110:*/
  19025. #line 2647 "./typica.w"
  19026. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  19027. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  19028. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  19029. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  19030. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  19031. /*:110*//*113:*/
  19032. #line 2750 "./typica.w"
  19033. constructor= engine->newFunction(constructQBuffer);
  19034. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  19035. engine->globalObject().setProperty("QBuffer",value);
  19036. /*:113*//*116:*/
  19037. #line 2799 "./typica.w"
  19038. constructor= engine->newFunction(constructXQuery);
  19039. engine->globalObject().setProperty("XQuery",constructor);
  19040. /*:116*//*122:*/
  19041. #line 2901 "./typica.w"
  19042. constructor= engine->newFunction(constructXmlWriter);
  19043. engine->globalObject().setProperty("XmlWriter",constructor);
  19044. /*:122*//*131:*/
  19045. #line 3107 "./typica.w"
  19046. constructor= engine->newFunction(constructXmlReader);
  19047. engine->globalObject().setProperty("XmlReader",constructor);
  19048. /*:131*//*138:*/
  19049. #line 3231 "./typica.w"
  19050. value= engine->newQObject(&settings);
  19051. setQSettingsProperties(value,engine);
  19052. engine->globalObject().setProperty("QSettings",value);
  19053. /*:138*//*142:*/
  19054. #line 3312 "./typica.w"
  19055. constructor= engine->newFunction(constructQLCDNumber);
  19056. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  19057. engine->globalObject().setProperty("QLCDNumber",value);
  19058. /*:142*//*145:*/
  19059. #line 3368 "./typica.w"
  19060. constructor= engine->newFunction(constructQTime);
  19061. engine->globalObject().setProperty("QTime",constructor);
  19062. /*:145*//*167:*/
  19063. #line 3881 "./typica.w"
  19064. constructor= engine->newFunction(constructQPushButton);
  19065. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  19066. engine->globalObject().setProperty("QPushButton",value);
  19067. /*:167*//*174:*/
  19068. #line 3992 "./typica.w"
  19069. constructor= engine->newFunction(constructQSqlQuery);
  19070. engine->globalObject().setProperty("QSqlQuery",constructor);
  19071. /*:174*//*181:*/
  19072. #line 4156 "./typica.w"
  19073. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  19074. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  19075. engine->globalObject().setProperty("sqlToArray",
  19076. engine->newFunction(sqlToArray));
  19077. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  19078. engine->globalObject().setProperty("annotationFromRecord",
  19079. engine->newFunction(annotationFromRecord));
  19080. engine->globalObject().setProperty("setTabOrder",
  19081. engine->newFunction(setTabOrder));
  19082. engine->globalObject().setProperty("saveFileFromDatabase",
  19083. engine->newFunction(saveFileFromDatabase));
  19084. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  19085. /*:181*//*194:*/
  19086. #line 4539 "./typica.w"
  19087. engine->globalObject().setProperty("createWindow",
  19088. engine->newFunction(createWindow));
  19089. engine->globalObject().setProperty("createReport",
  19090. engine->newFunction(createReport));
  19091. /*:194*//*259:*/
  19092. #line 6177 "./typica.w"
  19093. engine->globalObject().setProperty("findChildObject",
  19094. engine->newFunction(findChildObject));
  19095. /*:259*//*285:*/
  19096. #line 389 "./units.w"
  19097. value= engine->newQMetaObject(&Units::staticMetaObject);
  19098. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  19099. value.setProperty("convertRelativeTemperature",
  19100. engine->newFunction(Units_convertRelativeTemperature));
  19101. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  19102. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  19103. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  19104. engine->globalObject().setProperty("Units",value);
  19105. /*:285*//*290:*/
  19106. #line 462 "./units.w"
  19107. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  19108. #line 6601 "./typica.w"
  19109. /*:290*//*298:*/
  19110. #line 141 "./measurement.w"
  19111. constructor= engine->newFunction(constructMeasurement);
  19112. engine->globalObject().setProperty("Measurement",constructor);
  19113. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  19114. /*:298*//*318:*/
  19115. #line 7172 "./typica.w"
  19116. constructor= engine->newFunction(constructDAQ);
  19117. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  19118. value.setProperty("Fahrenheit",Units::Fahrenheit);
  19119. value.setProperty("Celsius",Units::Celsius);
  19120. value.setProperty("Kelvin",Units::Kelvin);
  19121. value.setProperty("Rankine",Units::Rankine);
  19122. engine->globalObject().setProperty("DAQ",value);
  19123. /*:318*//*327:*/
  19124. #line 7374 "./typica.w"
  19125. constructor= engine->newFunction(constructFakeDAQ);
  19126. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  19127. engine->globalObject().setProperty("FakeDAQ",value);
  19128. /*:327*//*338:*/
  19129. #line 7657 "./typica.w"
  19130. constructor= engine->newFunction(constructLinearCalibrator);
  19131. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  19132. constructor);
  19133. engine->globalObject().setProperty("LinearCalibrator",value);
  19134. /*:338*//*343:*/
  19135. #line 7796 "./typica.w"
  19136. constructor= engine->newFunction(constructLinearSplineInterpolator);
  19137. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  19138. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  19139. /*:343*//*353:*/
  19140. #line 8004 "./typica.w"
  19141. constructor= engine->newFunction(constructTemperatureDisplay);
  19142. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  19143. constructor);
  19144. engine->globalObject().setProperty("TemperatureDisplay",value);
  19145. /*:353*//*361:*/
  19146. #line 8162 "./typica.w"
  19147. constructor= engine->newFunction(constructMeasurementTimeOffset);
  19148. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  19149. constructor);
  19150. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  19151. /*:361*//*366:*/
  19152. #line 8273 "./typica.w"
  19153. constructor= engine->newFunction(constructThresholdDetector);
  19154. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  19155. engine->globalObject().setProperty("ThresholdDetector",value);
  19156. /*:366*//*371:*/
  19157. #line 8372 "./typica.w"
  19158. constructor= engine->newFunction(constructZeroEmitter);
  19159. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  19160. engine->globalObject().setProperty("ZeroEmitter",value);
  19161. /*:371*//*376:*/
  19162. #line 8451 "./typica.w"
  19163. constructor= engine->newFunction(constructMeasurementAdapter);
  19164. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  19165. constructor);
  19166. engine->globalObject().setProperty("MeasurementAdapter",value);
  19167. /*:376*//*393:*/
  19168. #line 8914 "./typica.w"
  19169. constructor= engine->newFunction(constructGraphView);
  19170. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  19171. engine->globalObject().setProperty("GraphView",value);
  19172. /*:393*//*416:*/
  19173. #line 9551 "./typica.w"
  19174. constructor= engine->newFunction(constructZoomLog);
  19175. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  19176. engine->globalObject().setProperty("ZoomLog",value);
  19177. /*:416*//*454:*/
  19178. #line 10499 "./typica.w"
  19179. constructor= engine->newFunction(constructAnnotationButton);
  19180. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  19181. constructor);
  19182. engine->globalObject().setProperty("AnnotationButton",value);
  19183. /*:454*//*462:*/
  19184. #line 10641 "./typica.w"
  19185. constructor= engine->newFunction(constructAnnotationSpinBox);
  19186. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  19187. constructor);
  19188. engine->globalObject().setProperty("AnnotationSpinBox",value);
  19189. /*:462*//*483:*/
  19190. #line 11066 "./typica.w"
  19191. constructor= engine->newFunction(constructTimerDisplay);
  19192. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  19193. engine->globalObject().setProperty("TimerDisplay",value);
  19194. /*:483*//*511:*/
  19195. #line 11590 "./typica.w"
  19196. constructor= engine->newFunction(constructWidgetDecorator);
  19197. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  19198. engine->globalObject().setProperty("WidgetDecorator",value);
  19199. /*:511*//*524:*/
  19200. #line 11872 "./typica.w"
  19201. constructor= engine->newFunction(constructLogEditWindow);
  19202. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  19203. engine->globalObject().setProperty("LogEditWindow",value);
  19204. /*:524*//*543:*/
  19205. #line 12399 "./typica.w"
  19206. constructor= engine->newFunction(constructXMLInput);
  19207. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  19208. engine->globalObject().setProperty("XMLInput",value);
  19209. /*:543*//*557:*/
  19210. #line 149 "./webview.w"
  19211. constructor= engine->newFunction(constructWebView);
  19212. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  19213. engine->globalObject().setProperty("WebView",value);
  19214. /*:557*//*565:*/
  19215. #line 241 "./webview.w"
  19216. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  19217. /*:565*//*568:*/
  19218. #line 283 "./webview.w"
  19219. constructor= engine->newFunction(constructWebElement);
  19220. engine->globalObject().setProperty("WebElement",constructor);
  19221. /*:568*//*579:*/
  19222. #line 12642 "./typica.w"
  19223. value= engine->newQObject(AppInstance);
  19224. engine->globalObject().setProperty("Application",value);
  19225. /*:579*//*637:*/
  19226. #line 13751 "./typica.w"
  19227. constructor= engine->newFunction(constructSqlQueryView);
  19228. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  19229. engine->globalObject().setProperty("SqlQueryView",value);
  19230. /*:637*//*742:*/
  19231. #line 15655 "./typica.w"
  19232. constructor= engine->newFunction(constructDeviceTreeModel);
  19233. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  19234. constructor);
  19235. engine->globalObject().setProperty("DeviceTreeModel",value);
  19236. /*:742*//*748:*/
  19237. #line 15795 "./typica.w"
  19238. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  19239. /*:748*//*764:*/
  19240. #line 16087 "./typica.w"
  19241. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  19242. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  19243. constructor);
  19244. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  19245. /*:764*//*835:*/
  19246. #line 56 "./settings.w"
  19247. constructor= engine->newFunction(constructSettingsWindow);
  19248. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  19249. engine->globalObject().setProperty("SettingsWindow",value);
  19250. #line 1 "./graphsettings.w"
  19251. /*:835*//*858:*/
  19252. #line 18718 "./typica.w"
  19253. constructor= engine->newFunction(constructModbusRTUDevice);
  19254. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  19255. engine->globalObject().setProperty("ModbusRTUDevice",value);
  19256. /*:858*//*878:*/
  19257. #line 350 "./unsupportedserial.w"
  19258. engine->globalObject().setProperty("createDevice",
  19259. engine->newFunction(createDevice));
  19260. /*:878*//*890:*/
  19261. #line 622 "./unsupportedserial.w"
  19262. engine->globalObject().setProperty("getMeasurementTimestamp",
  19263. engine->newFunction(getMeasurementTimestamp));
  19264. /*:890*//*894:*/
  19265. #line 658 "./unsupportedserial.w"
  19266. constructor= engine->newFunction(constructSerialPort);
  19267. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  19268. engine->globalObject().setProperty("SerialPort",value);
  19269. /*:894*//*899:*/
  19270. #line 713 "./unsupportedserial.w"
  19271. constructor= engine->newFunction(constructQTimer);
  19272. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  19273. engine->globalObject().setProperty("Timer",value);
  19274. /*:899*//*919:*/
  19275. #line 450 "./phidgets.w"
  19276. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  19277. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  19278. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  19279. /*:919*//*953:*/
  19280. #line 144 "./rate.w"
  19281. constructor= engine->newFunction(constructRateOfChange);
  19282. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  19283. engine->globalObject().setProperty("RateOfChange",value);
  19284. /*:953*//*978:*/
  19285. #line 604 "./dataqsdk.w"
  19286. constructor= engine->newFunction(constructDataqSdkDevice);
  19287. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  19288. engine->globalObject().setProperty("DataqSdkDevice",value);
  19289. /*:978*//*1005:*/
  19290. #line 73 "./scales.w"
  19291. constructor= engine->newFunction(constructDragLabel);
  19292. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  19293. engine->globalObject().setProperty("DragLabel",value);
  19294. /*:1005*//*1013:*/
  19295. #line 239 "./scales.w"
  19296. constructor= engine->newFunction(constructSerialScale);
  19297. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  19298. engine->globalObject().setProperty("SerialScale",value);
  19299. /*:1013*//*1017:*/
  19300. #line 325 "./scales.w"
  19301. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  19302. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  19303. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  19304. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  19305. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  19306. /*:1017*//*1041:*/
  19307. #line 271 "./valueannotation.w"
  19308. constructor= engine->newFunction(constructValueAnnotation);
  19309. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  19310. engine->globalObject().setProperty("ValueAnnotation",value);
  19311. /*:1041*/
  19312. #line 13368 "./typica.w"
  19313. app.engine= engine;
  19314. /*191:*/
  19315. #line 4420 "./typica.w"
  19316. QString styleText;
  19317. QString programText;
  19318. QDomElement currentElement;
  19319. for(int i= 0;i<children.size();i++)
  19320. {
  19321. QDomNode currentNode= children.at(i);
  19322. if(currentNode.nodeName()=="style")
  19323. {
  19324. currentElement= currentNode.toElement();
  19325. styleText.append(currentElement.text());
  19326. }
  19327. else if(currentNode.nodeName()=="program")
  19328. {
  19329. currentElement= currentNode.toElement();
  19330. programText.append(currentElement.text());
  19331. }
  19332. }
  19333. app.setStyleSheet(styleText);
  19334. QScriptValue result= engine->evaluate(programText);
  19335. /*192:*/
  19336. #line 4445 "./typica.w"
  19337. if(engine->hasUncaughtException())
  19338. {
  19339. int line= engine->uncaughtExceptionLineNumber();
  19340. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  19341. result.toString();
  19342. QString trace;
  19343. foreach(trace,engine->uncaughtExceptionBacktrace())
  19344. {
  19345. qDebug()<<trace;
  19346. }
  19347. }
  19348. /*:192*/
  19349. #line 4440 "./typica.w"
  19350. /*:191*/
  19351. #line 13370 "./typica.w"
  19352. int retval= app.exec();
  19353. delete engine;
  19354. return retval;
  19355. }
  19356. /*:614*/
  19357. #line 532 "./typica.w"
  19358. #include "moc_typica.cpp"
  19359. /*:3*/