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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 614 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. /*:5*//*6:*/
  16. #line 629 "./typica.w"
  17. #include "helpmenu.h"
  18. /*:6*//*248:*/
  19. #line 5863 "./typica.w"
  20. #include "units.h"
  21. #line 1 "./measurement.w"
  22. /*:248*//*517:*/
  23. #line 197 "./webview.w"
  24. #include "webview.h"
  25. /*:517*//*530:*/
  26. #line 375 "./webview.w"
  27. #include "webelement.h"
  28. #line 11792 "./typica.w"
  29. /*:530*//*638:*/
  30. #line 477 "./daterangeselector.w"
  31. #include "daterangeselector.h"
  32. #line 13482 "./typica.w"
  33. /*:638*//*746:*/
  34. #line 15983 "./typica.w"
  35. #include "qextserialport.h"
  36. #include "qextserialenumerator.h"
  37. /*:746*//*873:*/
  38. #line 124 "./dataqsdk.w"
  39. #ifdef Q_OS_WIN32
  40. #include <windef.h>
  41. #else
  42. #define PASCAL
  43. #endif
  44. /*:873*//*897:*/
  45. #line 862 "./dataqsdk.w"
  46. #include <limits>
  47. /*:897*//*912:*/
  48. #line 62 "./scales.w"
  49. #include "draglabel.h"
  50. /*:912*//*927:*/
  51. #line 335 "./scales.w"
  52. #include "scale.h"
  53. /*:927*/
  54. #line 525 "./typica.w"
  55. /*20:*/
  56. #line 944 "./typica.w"
  57. class ScriptQMainWindow:public QMainWindow
  58. {
  59. Q_OBJECT
  60. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  61. public:
  62. ScriptQMainWindow();
  63. QString closePrompt();
  64. public slots:
  65. void show();
  66. void saveSizeAndPosition(const QString&key);
  67. void restoreSizeAndPosition(const QString&key);
  68. void displayStatus(const QString&message= QString());
  69. void setClosePrompt(QString prompt);
  70. protected:
  71. void closeEvent(QCloseEvent*event);
  72. void showEvent(QShowEvent*event);
  73. signals:
  74. void aboutToClose(void);
  75. private:
  76. QString cprompt;
  77. };
  78. /*:20*//*139:*/
  79. #line 3289 "./typica.w"
  80. class SqlQueryConnection:public QSqlQuery
  81. {
  82. public:
  83. SqlQueryConnection(const QString&query= QString());
  84. ~SqlQueryConnection();
  85. QSqlQuery*operator->()const;
  86. private:
  87. QString connection;
  88. QSqlQuery*q;
  89. };
  90. /*:139*//*202:*/
  91. #line 5142 "./typica.w"
  92. class NumericDelegate:public QItemDelegate
  93. {
  94. Q_OBJECT
  95. public:
  96. NumericDelegate(QObject*parent= NULL);
  97. QWidget*createEditor(QWidget*parent,
  98. const QStyleOptionViewItem&option,
  99. const QModelIndex&index)const;
  100. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  101. void setModelData(QWidget*editor,QAbstractItemModel*model,
  102. const QModelIndex&index)const;
  103. void updateEditorGeometry(QWidget*editor,
  104. const QStyleOptionViewItem&option,
  105. const QModelIndex&index)const;
  106. };
  107. /*:202*//*244:*/
  108. #line 425 "./units.w"
  109. Q_DECLARE_METATYPE(Units::Unit)
  110. /*:244*//*249:*/
  111. #line 19 "./measurement.w"
  112. class Measurement:public QVariantMap
  113. {
  114. public:
  115. Measurement(double temperature= 0,QTime time= QTime(),
  116. Units::Unit sc= Units::Fahrenheit);
  117. Measurement(double temperature);
  118. double temperature()const;
  119. QTime time()const;
  120. void setTemperature(double temperature);
  121. void setTime(QTime time);
  122. void setUnit(Units::Unit scale);
  123. Units::Unit scale()const;
  124. Measurement toFahrenheit();
  125. Measurement toCelsius();
  126. Measurement toKelvin();
  127. Measurement toRankine();
  128. };
  129. /*:249*//*253:*/
  130. #line 128 "./measurement.w"
  131. Q_DECLARE_METATYPE(Measurement)
  132. /*:253*//*260:*/
  133. #line 5927 "./typica.w"
  134. class Channel;
  135. class DAQImplementation;
  136. class DAQ:public QObject
  137. {
  138. Q_OBJECT
  139. Q_ENUMS(ThermocoupleType)
  140. DAQImplementation*imp;
  141. private slots:
  142. void threadFinished();
  143. public:
  144. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  145. ~DAQ();
  146. Channel*newChannel(int units,int thermocouple);
  147. Q_INVOKABLE void setClockRate(double Hz);
  148. Q_INVOKABLE void start();
  149. Q_INVOKABLE void stop();
  150. enum ThermocoupleType
  151. {
  152. TypeJ= 10072,
  153. TypeK= 10073,
  154. TypeN= 10077,
  155. TypeR= 10082,
  156. TypeS= 10085,
  157. TypeT= 10086,
  158. TypeB= 10047,
  159. TypeE= 10055
  160. };
  161. };
  162. /*:260*//*261:*/
  163. #line 5965 "./typica.w"
  164. class DAQImplementation:public QThread
  165. {
  166. Q_OBJECT
  167. public:
  168. DAQImplementation(const QString&driverinfo);
  169. ~DAQImplementation();
  170. void run();
  171. void measure();
  172. /*262:*/
  173. #line 5985 "./typica.w"
  174. typedef int(*daqfp)(...);
  175. daqfp read;
  176. daqfp errorInfo;
  177. daqfp startTask;
  178. daqfp createTask;
  179. daqfp createChannel;
  180. daqfp setClock;
  181. daqfp stopTask;
  182. daqfp clearTask;
  183. daqfp resetDevice;
  184. daqfp waitForMeasurement;
  185. /*:262*/
  186. #line 5974 "./typica.w"
  187. /*263:*/
  188. #line 6001 "./typica.w"
  189. bool useBase;
  190. QString device;
  191. QVector<Channel*> channelMap;
  192. unsigned int handle;
  193. int error;
  194. int channels;
  195. bool ready;
  196. QLibrary driver;
  197. QVector<Units::Unit> unitMap;
  198. /*:263*/
  199. #line 5975 "./typica.w"
  200. };
  201. /*:261*//*279:*/
  202. #line 6505 "./typica.w"
  203. class FakeDAQImplementation:public QThread
  204. {
  205. Q_OBJECT
  206. public:
  207. FakeDAQImplementation();
  208. ~FakeDAQImplementation();
  209. void run();
  210. void measure();
  211. QVector<Channel*> channelMap;
  212. int channels;
  213. bool ready;
  214. double clockRate;
  215. };
  216. class FakeDAQ:public QObject
  217. {
  218. Q_OBJECT
  219. FakeDAQImplementation*imp;
  220. public:
  221. FakeDAQ(QString device);
  222. ~FakeDAQ();
  223. Channel*newChannel(int units,int thermocouple);
  224. Q_INVOKABLE void setClockRate(double Hz);
  225. Q_INVOKABLE void start();
  226. };
  227. /*:279*//*286:*/
  228. #line 6692 "./typica.w"
  229. class Channel:public QObject
  230. {
  231. Q_OBJECT
  232. public:
  233. Channel();
  234. ~Channel();
  235. public slots:
  236. void input(Measurement measurement);
  237. signals:
  238. void newData(Measurement);
  239. };
  240. /*:286*//*290:*/
  241. #line 6759 "./typica.w"
  242. class LinearCalibrator:public QObject
  243. {
  244. Q_OBJECT
  245. Q_PROPERTY(double measuredLower READ measuredLower
  246. WRITE setMeasuredLower)
  247. Q_PROPERTY(double measuredUpper READ measuredUpper
  248. WRITE setMeasuredUpper)
  249. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  250. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  251. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  252. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  253. public:
  254. LinearCalibrator(QObject*parent= NULL);
  255. double measuredLower();
  256. double measuredUpper();
  257. double mappedLower();
  258. double mappedUpper();
  259. bool isClosedRange();
  260. double sensitivity();
  261. public slots:
  262. void setMeasuredLower(double lower);
  263. void setMeasuredUpper(double upper);
  264. void setMappedLower(double lower);
  265. void setMappedUpper(double upper);
  266. void setClosedRange(bool closed);
  267. void setSensitivity(double sensitivity);
  268. Measurement newMeasurement(Measurement measure);
  269. signals:
  270. void measurement(Measurement measure);
  271. void newData(Measurement measure);
  272. private:
  273. double Lo1;
  274. double Lo2;
  275. double Up1;
  276. double Up2;
  277. double sensitivitySetting;
  278. bool clamp;
  279. };
  280. /*:290*//*297:*/
  281. #line 6955 "./typica.w"
  282. class LinearSplineInterpolator:public QObject
  283. {
  284. Q_OBJECT
  285. public:
  286. LinearSplineInterpolator(QObject*parent= NULL);
  287. Q_INVOKABLE void add_pair(double source,double destination);
  288. public slots:
  289. Measurement newMeasurement(Measurement measure);
  290. signals:
  291. void newData(Measurement measure);
  292. private:
  293. void make_interpolators();
  294. QMap<double,double> *pairs;
  295. QList<LinearCalibrator*> *interpolators;
  296. };
  297. /*:297*//*302:*/
  298. #line 7091 "./typica.w"
  299. class TemperatureDisplay:public QLCDNumber
  300. {
  301. Q_OBJECT
  302. int unit;
  303. bool r;
  304. public:
  305. TemperatureDisplay(QWidget*parent= NULL);
  306. ~TemperatureDisplay();
  307. public slots:
  308. void setValue(Measurement temperature);
  309. void invalidate();
  310. void setDisplayUnits(Units::Unit scale);
  311. void setRelativeMode(bool relative);
  312. };
  313. /*:302*//*313:*/
  314. #line 7307 "./typica.w"
  315. class MeasurementTimeOffset:public QObject
  316. {
  317. Q_OBJECT
  318. QTime epoch;
  319. QTime previous;
  320. bool hasPrevious;
  321. public:
  322. MeasurementTimeOffset(QTime zero);
  323. QTime zeroTime();
  324. public slots:
  325. void newMeasurement(Measurement measure);
  326. void setZeroTime(QTime zero);
  327. signals:
  328. void measurement(Measurement measure);
  329. };
  330. /*:313*//*320:*/
  331. #line 7459 "./typica.w"
  332. class ThresholdDetector:public QObject
  333. {
  334. Q_OBJECT
  335. Q_ENUMS(EdgeDirection)
  336. public:
  337. enum EdgeDirection{
  338. Ascending,Descending
  339. };
  340. ThresholdDetector(double value);
  341. public slots:
  342. void newMeasurement(Measurement measure);
  343. void setThreshold(double value);
  344. void setEdgeDirection(EdgeDirection direction);
  345. signals:
  346. void timeForValue(double);
  347. private:
  348. double previousValue;
  349. double threshold;
  350. EdgeDirection currentDirection;
  351. };
  352. /*:320*//*325:*/
  353. #line 7565 "./typica.w"
  354. class ZeroEmitter:public QObject
  355. {
  356. Q_OBJECT
  357. Q_PROPERTY(int column READ column WRITE setColumn)
  358. Measurement cache;
  359. int col;
  360. public:
  361. ZeroEmitter(int tempcolumn= 1);
  362. int column();
  363. double lastTemperature();
  364. public slots:
  365. void newMeasurement(Measurement measure);
  366. void setColumn(int column);
  367. void emitZero();
  368. signals:
  369. void measurement(Measurement measure,int tempcolumn);
  370. };
  371. /*:325*//*330:*/
  372. #line 7659 "./typica.w"
  373. class MeasurementAdapter:public QObject
  374. {
  375. Q_OBJECT
  376. int col;
  377. public:
  378. MeasurementAdapter(int tempcolumn);
  379. int column();
  380. public slots:
  381. void newMeasurement(Measurement measure);
  382. void setColumn(int column);
  383. signals:
  384. void measurement(Measurement measure,int tempcolumn);
  385. };
  386. /*:330*//*335:*/
  387. #line 7748 "./typica.w"
  388. class GraphView:public QGraphicsView
  389. {
  390. Q_OBJECT
  391. QGraphicsScene*theScene;
  392. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  393. QMap<int,QPointF> *prevPoints;
  394. QMap<int,double> *translations;
  395. QList<QGraphicsItem*> *gridLinesF;
  396. QList<QGraphicsItem*> *gridLinesC;
  397. QList<QGraphicsItem*> *relativeGridLines;
  398. bool relativeEnabled;
  399. bool timeIndicatorEnabled;
  400. QGraphicsLineItem*timeLine;
  401. LinearSplineInterpolator*relativeAdjuster;
  402. public:
  403. GraphView(QWidget*parent= NULL);
  404. void removeSeries(int column);
  405. protected:
  406. void resizeEvent(QResizeEvent*event);
  407. public slots:
  408. void newMeasurement(Measurement measure,int tempcolumn);
  409. void setSeriesTranslation(int column,double offset);
  410. void setTimeIndicatorEnabled(bool enabled);
  411. void clear();
  412. void showF();
  413. void showC();
  414. };
  415. /*:335*//*352:*/
  416. #line 8213 "./typica.w"
  417. class MeasurementModel;
  418. class ZoomLog:public QTableView
  419. {
  420. Q_OBJECT
  421. /*353:*/
  422. #line 8262 "./typica.w"
  423. MeasurementModel*model_ms;
  424. MeasurementModel*model_1s;
  425. MeasurementModel*model_5s;
  426. MeasurementModel*model_10s;
  427. MeasurementModel*model_15s;
  428. MeasurementModel*model_30s;
  429. MeasurementModel*model_1m;
  430. QList<MeasurementModel*> modelSet;
  431. QHash<int,Measurement> lastMeasurement;
  432. MeasurementModel*currentModel;
  433. QList<int> saveTempCols;
  434. QList<int> saveControlCols;
  435. QList<int> saveNoteCols;
  436. QList<int> currentColumnSet;
  437. /*:353*/
  438. #line 8218 "./typica.w"
  439. void switchLOD(MeasurementModel*m);
  440. private slots:
  441. void centerOn(int row);
  442. void persistColumnResize(int column,int oldsize,int newsize);
  443. void restoreColumnWidths();
  444. public:
  445. ZoomLog();
  446. QVariant data(int row,int column)const;
  447. int rowCount();
  448. bool saveXML(QIODevice*device);
  449. bool saveCSV(QIODevice*device);
  450. QString lastTime(int series);
  451. Q_INVOKABLE Units::Unit displayUnits();
  452. public slots:
  453. void setVisible(bool visibility);
  454. void setHeaderData(int section,QString text);
  455. void LOD_ms();
  456. void LOD_1s();
  457. void LOD_5s();
  458. void LOD_10s();
  459. void LOD_15s();
  460. void LOD_30s();
  461. void LOD_1m();
  462. void newMeasurement(Measurement measure,int tempcolumn);
  463. void newAnnotation(QString annotation,int tempcolumn,
  464. int annotationcolumn);
  465. void clear();
  466. void addOutputTemperatureColumn(int column);
  467. void addOutputControlColumn(int column);
  468. void addOutputAnnotationColumn(int column);
  469. void clearOutputColumns();
  470. void setDisplayUnits(Units::Unit scale);
  471. void addToCurrentColumnSet(int column);
  472. void clearCurrentColumnSet();
  473. protected:
  474. virtual void showEvent(QShowEvent*event);
  475. };
  476. /*:352*//*378:*/
  477. #line 8958 "./typica.w"
  478. class MeasurementList;
  479. class MeasurementModel:public QAbstractItemModel
  480. {
  481. Q_OBJECT
  482. Units::Unit unit;
  483. QList<MeasurementList*> *entries;
  484. QStringList*hData;
  485. int colcount;
  486. QHash<int,int> *lastTemperature;
  487. QList<MeasurementList*> ::iterator lastInsertion;
  488. QHash<int,bool> *controlColumns;
  489. public:
  490. MeasurementModel(QObject*parent= NULL);
  491. ~MeasurementModel();
  492. int rowCount(const QModelIndex&parent= QModelIndex())const;
  493. int columnCount(const QModelIndex&parent= QModelIndex())const;
  494. bool setHeaderData(int section,Qt::Orientation orientation,
  495. const QVariant&value,int role= Qt::DisplayRole);
  496. QVariant data(const QModelIndex&index,int role)const;
  497. bool setData(const QModelIndex&index,const QVariant&value,
  498. int role= Qt::EditRole);
  499. Qt::ItemFlags flags(const QModelIndex&index)const;
  500. QVariant headerData(int section,Qt::Orientation orientation,
  501. int role= Qt::DisplayRole)const;
  502. QModelIndex index(int row,int column,
  503. const QModelIndex&parent= QModelIndex())const;
  504. QModelIndex parent(const QModelIndex&index)const;
  505. Units::Unit displayUnits();
  506. public slots:
  507. void newMeasurement(Measurement measure,int tempcolumn);
  508. void newAnnotation(QString annotation,int tempcolumn,
  509. int annotationColumn);
  510. void clear();
  511. void setDisplayUnits(Units::Unit scale);
  512. signals:
  513. void rowChanged(int);
  514. };
  515. /*:378*//*379:*/
  516. #line 9002 "./typica.w"
  517. class MeasurementList:public QVariantList
  518. {
  519. public:
  520. bool operator<(const MeasurementList&other)const;
  521. bool operator==(const MeasurementList&other)const;
  522. };
  523. /*:379*//*405:*/
  524. #line 9660 "./typica.w"
  525. class AnnotationButton:public QPushButton
  526. {
  527. Q_OBJECT
  528. QString note;
  529. int tc;
  530. int ac;
  531. int count;
  532. public:
  533. AnnotationButton(const QString&text,QWidget*parent= NULL);
  534. public slots:
  535. void setAnnotation(const QString&annotation);
  536. void setTemperatureColumn(int tempcolumn);
  537. void setAnnotationColumn(int annotationcolumn);
  538. void annotate();
  539. void resetCount();
  540. signals:
  541. void annotation(QString annotation,int tempcolumn,
  542. int notecolumn);
  543. };
  544. /*:405*//*413:*/
  545. #line 9785 "./typica.w"
  546. class AnnotationSpinBox:public QDoubleSpinBox
  547. {
  548. Q_OBJECT
  549. QString pretext;
  550. QString posttext;
  551. int tc;
  552. int ac;
  553. bool change;
  554. public:
  555. AnnotationSpinBox(const QString&pret,const QString&postt,
  556. QWidget*parent= NULL);
  557. public slots:
  558. void setPretext(const QString&pret);
  559. void setPosttext(const QString&postt);
  560. void setTemperatureColumn(int tempcolumn);
  561. void setAnnotationColumn(int annotationcolumn);
  562. void annotate();
  563. void resetChange();
  564. signals:
  565. void annotation(QString annotation,int tempcolumn,
  566. int notecolumn);
  567. };
  568. /*:413*//*421:*/
  569. #line 9944 "./typica.w"
  570. class TimerDisplay:public QLCDNumber
  571. {
  572. Q_OBJECT
  573. /*422:*/
  574. #line 9994 "./typica.w"
  575. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  576. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  577. Q_PROPERTY(bool running READ isRunning)
  578. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  579. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  580. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  581. /*:422*/
  582. #line 9948 "./typica.w"
  583. private slots:
  584. void updateTime();
  585. void setCountUpMode();
  586. void setCountDownMode();
  587. void setClockMode();
  588. public:
  589. TimerDisplay(QWidget*parent= NULL);
  590. ~TimerDisplay();
  591. enum TimerMode
  592. {
  593. CountUp,
  594. CountDown,
  595. Clock
  596. };
  597. QString value();
  598. QTime seconds();
  599. TimerMode mode();
  600. bool isRunning();
  601. QTime resetValue();
  602. QString displayFormat();
  603. bool autoReset();
  604. public slots:
  605. void setTimer(QTime value= QTime(0,0,0));
  606. void setMode(TimerMode mode);
  607. void startTimer();
  608. void stopTimer();
  609. void copyTimer();
  610. void setResetValue(QTime value= QTime(0,0,0));
  611. void reset();
  612. void setDisplayFormat(QString format);
  613. void setAutoReset(bool reset);
  614. void updateDisplay();
  615. signals:
  616. void valueChanged(QTime);
  617. void runStateChanged(bool);
  618. private:
  619. /*423:*/
  620. #line 10004 "./typica.w"
  621. QTime s;
  622. QTime r;
  623. QTimer clock;
  624. TimerDisplay::TimerMode m;
  625. bool running;
  626. bool ar;
  627. QAction*startAction;
  628. QAction*stopAction;
  629. QAction*resetAction;
  630. QString f;
  631. QTime relative;
  632. QTime base;
  633. /*:423*/
  634. #line 9985 "./typica.w"
  635. };
  636. /*:421*//*443:*/
  637. #line 10363 "./typica.w"
  638. class PackLayout:public QLayout
  639. {
  640. int doLayout(const QRect&rect,bool testOnly)const;
  641. QList<QLayoutItem*> itemList;
  642. Qt::Orientations orientation;
  643. public:
  644. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  645. PackLayout(int spacing= -1);
  646. ~PackLayout();
  647. void addItem(QLayoutItem*item);
  648. Qt::Orientations expandingDirections()const;
  649. bool hasHeightForWidth()const;
  650. int heightForWidth(int width)const;
  651. int count()const;
  652. QLayoutItem*itemAt(int index)const;
  653. QSize minimumSize()const;
  654. void setGeometry(const QRect&rect);
  655. void setOrientation(Qt::Orientations direction);
  656. QSize sizeHint()const;
  657. QLayoutItem*takeAt(int index);
  658. };
  659. /*:443*//*456:*/
  660. #line 10641 "./typica.w"
  661. class SceneButton:public QGraphicsScene
  662. {
  663. Q_OBJECT
  664. public:
  665. SceneButton();
  666. ~SceneButton();
  667. protected:
  668. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  669. signals:
  670. void clicked(QPoint pos);
  671. };
  672. /*:456*//*458:*/
  673. #line 10683 "./typica.w"
  674. class WidgetDecorator:public QWidget
  675. {
  676. Q_OBJECT
  677. PackLayout*layout;
  678. QGraphicsView*label;
  679. QGraphicsTextItem*text;
  680. SceneButton*scene;
  681. public:
  682. WidgetDecorator(QWidget*widget,const QString&labeltext,
  683. Qt::Orientations orientation= Qt::Horizontal,
  684. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  685. ~WidgetDecorator();
  686. void setBackgroundBrush(QBrush background);
  687. void setTextColor(QColor color);
  688. };
  689. /*:458*//*469:*/
  690. #line 10858 "./typica.w"
  691. class LogEditWindow:public QMainWindow
  692. {
  693. Q_OBJECT
  694. QWidget*centralWidget;
  695. PackLayout*mainLayout;
  696. QHBoxLayout*addRowsLayout;
  697. QLabel*startTimeLabel;
  698. QTimeEdit*startTime;
  699. QLabel*endTimeLabel;
  700. QTimeEdit*endTime;
  701. QLabel*intervalLabel;
  702. QSpinBox*interval;
  703. QPushButton*addRows;
  704. QAction*saveXml;
  705. QAction*saveCsv;
  706. QAction*openXml;
  707. MeasurementModel*model;
  708. QTableView*log;
  709. private slots:
  710. void addTheRows();
  711. void saveXML();
  712. void saveCSV();
  713. void openXML();
  714. protected:
  715. void closeEvent(QCloseEvent*event);
  716. public:
  717. LogEditWindow();
  718. };
  719. /*:469*//*483:*/
  720. #line 11166 "./typica.w"
  721. class XMLOutput:public QObject
  722. {
  723. Q_OBJECT
  724. MeasurementModel*data;
  725. QIODevice*out;
  726. int time;
  727. QMap<int,QString> temperatureColumns;
  728. QMap<int,QString> controlColumns;
  729. QMap<int,QString> annotationColumns;
  730. public:
  731. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  732. void addTemperatureColumn(const QString&series,int column);
  733. void addControlColumn(const QString&series,int column);
  734. void addAnnotationColumn(const QString&series,int column);
  735. void setModel(MeasurementModel*model);
  736. void setTimeColumn(int column);
  737. void setDevice(QIODevice*device);
  738. bool output();
  739. };
  740. /*:483*//*490:*/
  741. #line 11402 "./typica.w"
  742. class XMLInput:public QObject
  743. {
  744. Q_OBJECT
  745. int firstc;
  746. QIODevice*in;
  747. public:
  748. XMLInput(QIODevice*input,int c);
  749. void setFirstColumn(int column);
  750. void setDevice(QIODevice*device);
  751. bool input();
  752. signals:
  753. void measure(Measurement,int);
  754. void annotation(QString,int,int);
  755. void newTemperatureColumn(int,QString);
  756. void newAnnotationColumn(int,QString);
  757. void lastColumn(int);
  758. };
  759. /*:490*//*501:*/
  760. #line 11657 "./typica.w"
  761. class CSVOutput
  762. {
  763. MeasurementModel*data;
  764. QIODevice*out;
  765. int time;
  766. QMap<int,QString> temperatureColumns;
  767. QMap<int,QString> controlColumns;
  768. QMap<int,QString> annotationColumns;
  769. public:
  770. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  771. void addTemperatureColumn(const QString&series,int column);
  772. void addControlColumn(const QString&series,int column);
  773. void addAnnotationColumn(const QString&series,int column);
  774. void setModel(MeasurementModel*model);
  775. void setTimeColumn(int column);
  776. void setDevice(QIODevice*device);
  777. bool output();
  778. };
  779. /*:501*//*531:*/
  780. #line 11800 "./typica.w"
  781. #define AppInstance (qobject_cast<Application *> (qApp))
  782. class NodeInserter;
  783. class DeviceTreeModel;
  784. class Application:public QApplication
  785. {
  786. Q_OBJECT
  787. public:
  788. Application(int&argc,char**argv);
  789. QDomDocument*configuration();
  790. /*670:*/
  791. #line 14328 "./typica.w"
  792. QDomDocument deviceConfiguration();
  793. /*:670*//*703:*/
  794. #line 15001 "./typica.w"
  795. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  796. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  797. const QModelIndex&index);
  798. /*:703*//*708:*/
  799. #line 15105 "./typica.w"
  800. QList<NodeInserter*> topLevelNodeInserters;
  801. /*:708*/
  802. #line 11811 "./typica.w"
  803. QSqlDatabase database();
  804. QScriptEngine*engine;
  805. public slots:
  806. /*671:*/
  807. #line 14335 "./typica.w"
  808. void saveDeviceConfiguration();
  809. /*:671*/
  810. #line 11815 "./typica.w"
  811. private:
  812. /*669:*/
  813. #line 14319 "./typica.w"
  814. QDomDocument deviceConfigurationDocument;
  815. /*:669*//*702:*/
  816. #line 14995 "./typica.w"
  817. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  818. /*:702*/
  819. #line 11817 "./typica.w"
  820. QDomDocument conf;
  821. };
  822. /*:531*//*539:*/
  823. #line 11942 "./typica.w"
  824. class SaltModel:public QAbstractItemModel
  825. {
  826. Q_OBJECT
  827. QList<QList<QMap<int,QVariant> > > modelData;
  828. QStringList hData;
  829. int colcount;
  830. public:
  831. SaltModel(int columns);
  832. ~SaltModel();
  833. int rowCount(const QModelIndex&parent= QModelIndex())const;
  834. int columnCount(const QModelIndex&parent= QModelIndex())const;
  835. bool setHeaderData(int section,Qt::Orientation orientation,
  836. const QVariant&value,int role= Qt::DisplayRole);
  837. QVariant data(const QModelIndex&index,int role)const;
  838. bool setData(const QModelIndex&index,const QVariant&value,
  839. int role= Qt::EditRole);
  840. Qt::ItemFlags flags(const QModelIndex&index)const;
  841. QVariant headerData(int section,Qt::Orientation orientation,
  842. int role= Qt::DisplayRole)const;
  843. QModelIndex index(int row,int column,
  844. const QModelIndex&parent= QModelIndex())const;
  845. QModelIndex parent(const QModelIndex&index)const;
  846. QString arrayLiteral(int column,int role)const;
  847. QString quotedArrayLiteral(int column,int role)const;
  848. void clear();
  849. bool removeRows(int row,int count,
  850. const QModelIndex&parent= QModelIndex());
  851. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  852. };
  853. /*:539*//*555:*/
  854. #line 12327 "./typica.w"
  855. class SqlComboBox:public QComboBox
  856. {
  857. Q_OBJECT
  858. int dataColumn;
  859. int displayColumn;
  860. bool dataColumnShown;
  861. QString specialNullText;
  862. QVariant specialNullData;
  863. public:
  864. SqlComboBox();
  865. ~SqlComboBox();
  866. SqlComboBox*clone(QWidget*parent);
  867. public slots:
  868. void addNullOption();
  869. void addSqlOptions(QString query);
  870. void setDataColumn(int column);
  871. void setDisplayColumn(int column);
  872. void showData(bool show);
  873. void setNullText(QString nullText);
  874. void setNullData(QVariant nullData);
  875. };
  876. /*:555*//*562:*/
  877. #line 12474 "./typica.w"
  878. class SqlComboBoxDelegate:public QItemDelegate
  879. {
  880. Q_OBJECT
  881. SqlComboBox*delegate;
  882. public:
  883. SqlComboBoxDelegate(QObject*parent= NULL);
  884. QWidget*createEditor(QWidget*parent,
  885. const QStyleOptionViewItem&option,
  886. const QModelIndex&index)const;
  887. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  888. void setModelData(QWidget*editor,QAbstractItemModel*model,
  889. const QModelIndex&index)const;
  890. void setWidget(SqlComboBox*widget);
  891. virtual QSize sizeHint()const;
  892. void updateEditorGeometry(QWidget*editor,
  893. const QStyleOptionViewItem&option,
  894. const QModelIndex&index)const;
  895. };
  896. /*:562*//*574:*/
  897. #line 12659 "./typica.w"
  898. class SqlConnectionSetup:public QDialog
  899. {
  900. Q_OBJECT
  901. public:
  902. SqlConnectionSetup();
  903. ~SqlConnectionSetup();
  904. public slots:
  905. void testConnection();
  906. private:
  907. QFormLayout*formLayout;
  908. QComboBox*driver;
  909. QLineEdit*hostname;
  910. QLineEdit*dbname;
  911. QLineEdit*user;
  912. QLineEdit*password;
  913. QVBoxLayout*layout;
  914. QHBoxLayout*buttons;
  915. QPushButton*cancelButton;
  916. QPushButton*connectButton;
  917. };
  918. /*:574*//*579:*/
  919. #line 12794 "./typica.w"
  920. class SqlQueryView:public QTableView
  921. {
  922. Q_OBJECT
  923. public:
  924. SqlQueryView(QWidget*parent= NULL);
  925. void setQuery(const QString&query);
  926. bool setHeaderData(int section,Qt::Orientation orientation,
  927. const QVariant&value,int role);
  928. Q_INVOKABLE QVariant data(int row,int column,
  929. int role= Qt::DisplayRole);
  930. signals:
  931. void openEntry(QString key);
  932. void openEntryRow(int row);
  933. protected:
  934. virtual void showEvent(QShowEvent*event);
  935. private slots:
  936. void openRow(const QModelIndex&index);
  937. void persistColumnResize(int column,int oldsize,int newsize);
  938. };
  939. /*:579*//*594:*/
  940. #line 13049 "./typica.w"
  941. class ReportAction:public QAction
  942. {
  943. Q_OBJECT
  944. public:
  945. ReportAction(const QString&fileName,const QString&reportName,
  946. QObject*parent= NULL);
  947. private slots:
  948. void createReport();
  949. private:
  950. QString reportFile;
  951. };
  952. /*:594*//*606:*/
  953. #line 13258 "./typica.w"
  954. class ReportTable:public QObject
  955. {
  956. Q_OBJECT
  957. QTextFrame*area;
  958. QDomElement configuration;
  959. QMap<QString,QVariant> bindings;
  960. public:
  961. ReportTable(QTextFrame*frame,QDomElement description);
  962. ~ReportTable();
  963. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  964. public slots:
  965. void refresh();
  966. };
  967. /*:606*//*639:*/
  968. #line 13497 "./typica.w"
  969. class FormArray:public QScrollArea
  970. {
  971. Q_OBJECT
  972. QDomElement configuration;
  973. QWidget itemContainer;
  974. QVBoxLayout itemLayout;
  975. int maxwidth;
  976. int maxheight;
  977. public:
  978. FormArray(QDomElement description);
  979. Q_INVOKABLE QWidget*elementAt(int index);
  980. Q_INVOKABLE int elements();
  981. public slots:
  982. void addElements(int copies= 1);
  983. void removeAllElements();
  984. void setMaximumElementWidth(int width);
  985. void setMaximumElementHeight(int height);
  986. };
  987. /*:639*//*649:*/
  988. #line 13713 "./typica.w"
  989. class ScaleControl:public QGraphicsView
  990. {
  991. Q_OBJECT
  992. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  993. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  994. /*650:*/
  995. #line 13739 "./typica.w"
  996. QGraphicsScene scene;
  997. QGraphicsPolygonItem initialDecrement;
  998. QGraphicsPolygonItem initialIncrement;
  999. QGraphicsPolygonItem finalDecrement;
  1000. QGraphicsPolygonItem finalIncrement;
  1001. QGraphicsPolygonItem initialIndicator;
  1002. QGraphicsPolygonItem finalIndicator;
  1003. QGraphicsPathItem scaleLine;
  1004. QPolygonF left;
  1005. QPolygonF right;
  1006. QPolygonF down;
  1007. QPolygonF up;
  1008. QPainterPath scalePath;
  1009. QBrush initialBrush;
  1010. QBrush finalBrush;
  1011. double nonScoredValue;
  1012. double scoredValue;
  1013. bool initialSet;
  1014. bool finalSet;
  1015. bool scaleDown;
  1016. /*:650*/
  1017. #line 13719 "./typica.w"
  1018. public:
  1019. ScaleControl();
  1020. double initialValue(void);
  1021. double finalValue(void);
  1022. virtual QSize sizeHint()const;
  1023. public slots:
  1024. void setInitialValue(double value);
  1025. void setFinalValue(double value);
  1026. signals:
  1027. void initialChanged(double);
  1028. void finalChanged(double);
  1029. protected:
  1030. virtual void mousePressEvent(QMouseEvent*event);
  1031. virtual void mouseReleaseEvent(QMouseEvent*event);
  1032. };
  1033. /*:649*//*661:*/
  1034. #line 14036 "./typica.w"
  1035. class IntensityControl:public QGraphicsView
  1036. {
  1037. Q_OBJECT
  1038. Q_PROPERTY(double value READ value WRITE setValue)
  1039. QGraphicsScene scene;
  1040. QGraphicsPolygonItem decrement;
  1041. QGraphicsPolygonItem increment;
  1042. QGraphicsPolygonItem indicator;
  1043. QGraphicsPathItem scaleLine;
  1044. QPolygonF left;
  1045. QPolygonF up;
  1046. QPolygonF down;
  1047. QPainterPath scalePath;
  1048. QBrush theBrush;
  1049. double theValue;
  1050. bool valueSet;
  1051. bool scaleDown;
  1052. public:
  1053. IntensityControl();
  1054. double value();
  1055. virtual QSize sizeHint()const;
  1056. public slots:
  1057. void setValue(double val);
  1058. signals:
  1059. void valueChanged(double);
  1060. protected:
  1061. virtual void mousePressEvent(QMouseEvent*event);
  1062. virtual void mouseReleaseEvent(QMouseEvent*event);
  1063. };
  1064. /*:661*//*677:*/
  1065. #line 14424 "./typica.w"
  1066. class DeviceTreeModelNode
  1067. {
  1068. public:
  1069. DeviceTreeModelNode(QDomNode&node,int row,
  1070. DeviceTreeModelNode*parent= NULL);
  1071. ~DeviceTreeModelNode();
  1072. DeviceTreeModelNode*child(int index);
  1073. DeviceTreeModelNode*parent();
  1074. QDomNode node()const;
  1075. int row();
  1076. private:
  1077. QDomNode domNode;
  1078. QHash<int,DeviceTreeModelNode*> children;
  1079. int rowNumber;
  1080. DeviceTreeModelNode*parentItem;
  1081. };
  1082. /*:677*//*679:*/
  1083. #line 14499 "./typica.w"
  1084. class DeviceTreeModel:public QAbstractItemModel
  1085. {
  1086. Q_OBJECT
  1087. public:
  1088. DeviceTreeModel(QObject*parent= NULL);
  1089. ~DeviceTreeModel();
  1090. QVariant data(const QModelIndex&index,int role)const;
  1091. Qt::ItemFlags flags(const QModelIndex&index)const;
  1092. QVariant headerData(int section,Qt::Orientation orientation,
  1093. int role= Qt::DisplayRole)const;
  1094. QModelIndex index(int row,int column,
  1095. const QModelIndex&parent= QModelIndex())const;
  1096. QModelIndex parent(const QModelIndex&child)const;
  1097. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1098. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1099. bool setData(const QModelIndex&index,const QVariant&value,
  1100. int role);
  1101. bool removeRows(int row,int count,const QModelIndex&parent);
  1102. QDomElement referenceElement(const QString&id);
  1103. public slots:
  1104. void newNode(const QString&name,const QString&driver,
  1105. const QModelIndex&parent);
  1106. private:
  1107. QDomDocument document;
  1108. DeviceTreeModelNode*root;
  1109. QDomNode referenceSection;
  1110. QDomNode treeRoot;
  1111. };
  1112. /*:679*//*698:*/
  1113. #line 14953 "./typica.w"
  1114. Q_DECLARE_METATYPE(QModelIndex)
  1115. /*:698*//*706:*/
  1116. #line 15060 "./typica.w"
  1117. class NodeInserter:public QAction
  1118. {
  1119. Q_OBJECT
  1120. public:
  1121. NodeInserter(const QString&title,const QString&name,
  1122. const QString&driver,QObject*parent= NULL);
  1123. signals:
  1124. void triggered(QString name,QString driver);
  1125. private slots:
  1126. void onTriggered();
  1127. private:
  1128. QString defaultNodeName;
  1129. QString driverString;
  1130. };
  1131. /*:706*//*709:*/
  1132. #line 15115 "./typica.w"
  1133. class DeviceConfigurationWindow:public QWidget
  1134. {
  1135. Q_OBJECT
  1136. public:
  1137. DeviceConfigurationWindow();
  1138. public slots:
  1139. void addDevice();
  1140. void removeNode();
  1141. void newSelection(const QModelIndex&index);
  1142. private slots:
  1143. void resizeColumn();
  1144. private:
  1145. QDomDocument document;
  1146. DeviceTreeModel*model;
  1147. QTreeView*view;
  1148. QScrollArea*configArea;
  1149. };
  1150. /*:709*//*718:*/
  1151. #line 15285 "./typica.w"
  1152. class BasicDeviceConfigurationWidget:public QWidget
  1153. {
  1154. Q_OBJECT
  1155. public:
  1156. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1157. const QModelIndex&index);
  1158. public slots:
  1159. void insertChildNode(const QString&name,const QString&driver);
  1160. void updateAttribute(const QString&name,const QString&value);
  1161. protected:
  1162. DeviceTreeModel*deviceModel;
  1163. QModelIndex currentNode;
  1164. };
  1165. /*:718*//*722:*/
  1166. #line 15370 "./typica.w"
  1167. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1168. {
  1169. Q_OBJECT
  1170. public:
  1171. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1172. const QModelIndex&index);
  1173. private slots:
  1174. void updateRoasterId(int id);
  1175. };
  1176. /*:722*//*727:*/
  1177. #line 15505 "./typica.w"
  1178. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1179. {
  1180. Q_OBJECT
  1181. public:
  1182. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1183. const QModelIndex&index);
  1184. };
  1185. /*:727*//*729:*/
  1186. #line 15551 "./typica.w"
  1187. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1188. {
  1189. Q_OBJECT
  1190. public:
  1191. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1192. const QModelIndex&index);
  1193. private slots:
  1194. void addChannel();
  1195. void updateDeviceId(const QString&newId);
  1196. };
  1197. /*:729*//*733:*/
  1198. #line 15637 "./typica.w"
  1199. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1200. {
  1201. Q_OBJECT
  1202. public:
  1203. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1204. const QModelIndex&index);
  1205. private slots:
  1206. void updateThermocoupleType(const QString&type);
  1207. void updateColumnName(const QString&name);
  1208. void updateHidden(bool hidden);
  1209. };
  1210. /*:733*//*738:*/
  1211. #line 15753 "./typica.w"
  1212. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1213. {
  1214. Q_OBJECT
  1215. public:
  1216. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1217. const QModelIndex&index);
  1218. };
  1219. /*:738*//*740:*/
  1220. #line 15794 "./typica.w"
  1221. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1222. {
  1223. Q_OBJECT
  1224. public:
  1225. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1226. const QModelIndex&index);
  1227. private slots:
  1228. void addChannel();
  1229. void updateDeviceId(const QString&newId);
  1230. };
  1231. /*:740*//*742:*/
  1232. #line 15863 "./typica.w"
  1233. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1234. {
  1235. Q_OBJECT
  1236. public:
  1237. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1238. const QModelIndex&index);
  1239. private slots:
  1240. void updateDeviceId(const QString&newId);
  1241. void updateThermocoupleType(const QString&type);
  1242. void updateColumnName(const QString&name);
  1243. void updateHidden(bool hidden);
  1244. };
  1245. /*:742*//*747:*/
  1246. #line 15994 "./typica.w"
  1247. class PortSelector:public QComboBox
  1248. {
  1249. Q_OBJECT
  1250. public:
  1251. PortSelector(QWidget*parent= NULL);
  1252. private slots:
  1253. void addDevice(QextPortInfo port);
  1254. private:
  1255. QextSerialEnumerator*lister;
  1256. };
  1257. /*:747*//*749:*/
  1258. #line 16042 "./typica.w"
  1259. class BaudSelector:public QComboBox
  1260. {
  1261. Q_OBJECT
  1262. Q_ENUMS(BaudRateType)
  1263. public:
  1264. BaudSelector(QWidget*parent= NULL);
  1265. enum BaudRateType
  1266. {
  1267. #if defined(Q_OS_UNIX) || defined(qdoc)
  1268. BAUD50= 50,
  1269. BAUD75= 75,
  1270. BAUD134= 134,
  1271. BAUD150= 150,
  1272. BAUD200= 200,
  1273. BAUD1800= 1800,
  1274. #if defined(B76800) || defined(qdoc)
  1275. BAUD76800= 76800,
  1276. #endif
  1277. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1278. BAUD230400= 230400,
  1279. BAUD460800= 460800,
  1280. BAUD500000= 500000,
  1281. BAUD576000= 576000,
  1282. BAUD921600= 921600,
  1283. BAUD1000000= 1000000,
  1284. BAUD1152000= 1152000,
  1285. BAUD1500000= 1500000,
  1286. BAUD2000000= 2000000,
  1287. BAUD2500000= 2500000,
  1288. BAUD3000000= 3000000,
  1289. BAUD3500000= 3500000,
  1290. BAUD4000000= 4000000,
  1291. #endif
  1292. #endif
  1293. #if defined(Q_OS_WIN) || defined(qdoc)
  1294. BAUD14400= 14400,
  1295. BAUD56000= 56000,
  1296. BAUD128000= 128000,
  1297. BAUD256000= 256000,
  1298. #endif
  1299. BAUD110= 110,
  1300. BAUD300= 300,
  1301. BAUD600= 600,
  1302. BAUD1200= 1200,
  1303. BAUD2400= 2400,
  1304. BAUD4800= 4800,
  1305. BAUD9600= 9600,
  1306. BAUD19200= 19200,
  1307. BAUD38400= 38400,
  1308. BAUD57600= 57600,
  1309. BAUD115200= 115200
  1310. };
  1311. };
  1312. /*:749*//*751:*/
  1313. #line 16113 "./typica.w"
  1314. class ParitySelector:public QComboBox
  1315. {
  1316. Q_OBJECT
  1317. Q_ENUMS(ParityType)
  1318. public:
  1319. ParitySelector(QWidget*parent= NULL);
  1320. enum ParityType
  1321. {
  1322. PAR_NONE,
  1323. PAR_ODD,
  1324. PAR_EVEN,
  1325. #if defined(Q_OS_WIN) || defined(qdoc)
  1326. PAR_MARK,
  1327. #endif
  1328. PAR_SPACE
  1329. };
  1330. };
  1331. /*:751*//*753:*/
  1332. #line 16151 "./typica.w"
  1333. class FlowSelector:public QComboBox
  1334. {
  1335. Q_OBJECT
  1336. Q_ENUMS(FlowType)
  1337. public:
  1338. FlowSelector(QWidget*parent= NULL);
  1339. enum FlowType
  1340. {
  1341. FLOW_OFF,
  1342. FLOW_HARDWARE,
  1343. FLOW_XONXOFF
  1344. };
  1345. };
  1346. /*:753*//*755:*/
  1347. #line 16184 "./typica.w"
  1348. class StopSelector:public QComboBox
  1349. {
  1350. Q_OBJECT
  1351. Q_ENUMS(StopBitsType)
  1352. public:
  1353. StopSelector(QWidget*parent= NULL);
  1354. enum StopBitsType
  1355. {
  1356. STOP_1,
  1357. #if defined(Q_OS_WIN) || defined(qdoc)
  1358. STOP_1_5,
  1359. #endif
  1360. STOP_2
  1361. };
  1362. };
  1363. /*:755*//*758:*/
  1364. #line 16237 "./typica.w"
  1365. class ShortHexSpinBox:public QSpinBox
  1366. {
  1367. Q_OBJECT
  1368. public:
  1369. ShortHexSpinBox(QWidget*parent= NULL);
  1370. virtual QValidator::State validate(QString&input,int&pos)const;
  1371. protected:
  1372. virtual int valueFromText(const QString&text)const;
  1373. virtual QString textFromValue(int value)const;
  1374. };
  1375. /*:758*//*760:*/
  1376. #line 16299 "./typica.w"
  1377. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1378. {
  1379. Q_OBJECT
  1380. public:
  1381. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1382. const QModelIndex&index);
  1383. private slots:
  1384. void updatePort(const QString&newPort);
  1385. void updateBaudRate(const QString&newRate);
  1386. void updateParity(const QString&newParity);
  1387. void updateFlowControl(const QString&newFlow);
  1388. void updateStopBits(const QString&newStopBits);
  1389. };
  1390. /*:760*//*762:*/
  1391. #line 16450 "./typica.w"
  1392. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1393. {
  1394. Q_OBJECT
  1395. public:
  1396. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1397. const QModelIndex&index);
  1398. private slots:
  1399. void updateStationNumber(int newStation);
  1400. void updateFixedUnit(bool newFixed);
  1401. void updateFixedDecimal(bool newFixed);
  1402. void updateUnit(const QString&newUnit);
  1403. void updateUnitAddress(int newAddress);
  1404. void updateValueF(int newValue);
  1405. void updateValueC(int newValue);
  1406. void updatePrecisionAddress(int newAddress);
  1407. void updatePrecisionValue(int newValue);
  1408. private:
  1409. QStackedLayout*unitSpecificationLayout;
  1410. QStackedLayout*decimalSpecificationLayout;
  1411. };
  1412. /*:762*//*764:*/
  1413. #line 16709 "./typica.w"
  1414. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1415. {
  1416. Q_OBJECT
  1417. public:
  1418. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1419. const QModelIndex&index);
  1420. private slots:
  1421. void updateAddress(int newAddress);
  1422. };
  1423. /*:764*//*766:*/
  1424. #line 16755 "./typica.w"
  1425. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1426. {
  1427. Q_OBJECT
  1428. public:
  1429. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1430. const QModelIndex&index);
  1431. private slots:
  1432. void updateReadAddress(int newAddress);
  1433. void updateWriteAddress(int newAddress);
  1434. void updateFixedRange(bool fixed);
  1435. void updateLower(const QString&lower);
  1436. void updateUpper(const QString&upper);
  1437. void updateLowerAddress(int newAddress);
  1438. void updateUpperAddress(int newAddress);
  1439. private:
  1440. QStackedLayout*boundsLayout;
  1441. };
  1442. /*:766*//*770:*/
  1443. #line 16949 "./typica.w"
  1444. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1445. {
  1446. Q_OBJECT
  1447. public:
  1448. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1449. private slots:
  1450. void updateButtonText(const QString&text);
  1451. void updateAnnotationText(const QString&text);
  1452. };
  1453. /*:770*//*774:*/
  1454. #line 17017 "./typica.w"
  1455. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1456. {
  1457. Q_OBJECT
  1458. public:
  1459. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1460. private slots:
  1461. void updateButtonText(const QString&text);
  1462. void updateAnnotationText(const QString&text);
  1463. };
  1464. /*:774*//*777:*/
  1465. #line 17091 "./typica.w"
  1466. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1467. {
  1468. Q_OBJECT
  1469. public:
  1470. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1471. private slots:
  1472. void updateLabel(const QString&text);
  1473. void updateMinimum(const QString&minimum);
  1474. void updateMaximum(const QString&maximum);
  1475. void updatePrecision(int precision);
  1476. void updatePretext(const QString&text);
  1477. void updatePosttext(const QString&text);
  1478. };
  1479. /*:777*//*780:*/
  1480. #line 12 "./freeannotation.w"
  1481. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1482. {
  1483. Q_OBJECT
  1484. public:
  1485. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1486. private slots:
  1487. void updateLabel(const QString&text);
  1488. };
  1489. /*:780*//*784:*/
  1490. #line 11 "./settings.w"
  1491. class SettingsWindow:public QMainWindow
  1492. {
  1493. Q_OBJECT
  1494. public:
  1495. SettingsWindow();
  1496. };
  1497. /*:784*//*789:*/
  1498. #line 8 "./graphsettings.w"
  1499. class GraphSettingsWidget:public QWidget
  1500. {
  1501. Q_OBJECT
  1502. public:
  1503. GraphSettingsWidget();
  1504. };
  1505. /*:789*//*791:*/
  1506. #line 46 "./graphsettings.w"
  1507. class GraphSettingsRelativeTab:public QWidget
  1508. {
  1509. Q_OBJECT
  1510. public:
  1511. GraphSettingsRelativeTab();
  1512. public slots:
  1513. void updateEnableSetting(bool enable);
  1514. void updateColorSetting(const QString&color);
  1515. void updateAxisSetting(const QString&gridList);
  1516. void updateUnit(int unit);
  1517. void showColorPicker();
  1518. private:
  1519. QLineEdit*colorEdit;
  1520. };
  1521. /*:791*//*795:*/
  1522. #line 17216 "./typica.w"
  1523. class ModbusRTUDevice:public QObject
  1524. {
  1525. Q_OBJECT
  1526. public:
  1527. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1528. ~ModbusRTUDevice();
  1529. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1530. Q_INVOKABLE double SVLower();
  1531. Q_INVOKABLE double SVUpper();
  1532. Q_INVOKABLE int decimals();
  1533. QList<Channel*> channels;
  1534. public slots:
  1535. void outputSV(double sv);
  1536. signals:
  1537. void SVLowerChanged(double);
  1538. void SVUpperChanged(double);
  1539. void SVDecimalChanged(int);
  1540. void queueEmpty();
  1541. private slots:
  1542. void dataAvailable();
  1543. void sendNextMessage();
  1544. void decimalResponse(QByteArray response);
  1545. void unitResponse(QByteArray response);
  1546. void svlResponse(QByteArray response);
  1547. void svuResponse(QByteArray response);
  1548. void requestMeasurement();
  1549. void mResponse(QByteArray response);
  1550. void ignore(QByteArray response);
  1551. private:
  1552. QextSerialPort*port;
  1553. QByteArray responseBuffer;
  1554. QList<QByteArray> messageQueue;
  1555. QList<QObject*> retObjQueue;
  1556. QList<char*> callbackQueue;
  1557. quint16 calculateCRC(QByteArray data);
  1558. QTimer*messageDelayTimer;
  1559. int delayTime;
  1560. char station;
  1561. int decimalPosition;
  1562. int valueF;
  1563. int valueC;
  1564. bool unitIsF;
  1565. double outputSVLower;
  1566. double outputSVUpper;
  1567. QByteArray outputSVStub;
  1568. QByteArray pvStub;
  1569. QByteArray svStub;
  1570. QByteArray mStub;
  1571. quint16 pvaddress;
  1572. quint16 svaddress;
  1573. bool svenabled;
  1574. bool readingsv;
  1575. double savedpv;
  1576. bool waiting;
  1577. };
  1578. /*:795*//*810:*/
  1579. #line 17888 "./typica.w"
  1580. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1581. {
  1582. Q_OBJECT
  1583. public:
  1584. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1585. private slots:
  1586. void updatePort(const QString&newPort);
  1587. void updateBaudRate(const QString&newRate);
  1588. void updateParity(const QString&newParity);
  1589. void updateFlowControl(const QString&newFlow);
  1590. void updateStopBits(const QString&newStopBits);
  1591. void updateStation(int station);
  1592. void updateFixedDecimal(bool fixed);
  1593. void updateDecimalAddress(int address);
  1594. void updateDecimalPosition(int position);
  1595. void updateFixedUnit(bool fixed);
  1596. void updateUnitAddress(int address);
  1597. void updateValueForF(int value);
  1598. void updateValueForC(int value);
  1599. void updateUnit(const QString&newUnit);
  1600. void updatePVAddress(int address);
  1601. void updateSVEnabled(bool enabled);
  1602. void updateSVReadAddress(int address);
  1603. void updateDeviceLimit(bool query);
  1604. void updateSVLowerAddress(int address);
  1605. void updateSVUpperAddress(int address);
  1606. void updateSVLower(double value);
  1607. void updateSVUpper(double value);
  1608. void updateSVWritable(bool canWriteSV);
  1609. void updateSVWriteAddress(int address);
  1610. void updatePVColumnName(const QString&name);
  1611. void updateSVColumnName(const QString&name);
  1612. void updatePVHidden(bool hidden);
  1613. void updateSVHidden(bool hidden);
  1614. private:
  1615. PortSelector*port;
  1616. BaudSelector*baud;
  1617. ParitySelector*parity;
  1618. FlowSelector*flow;
  1619. StopSelector*stop;
  1620. QSpinBox*station;
  1621. QCheckBox*decimalQuery;
  1622. ShortHexSpinBox*decimalAddress;
  1623. QSpinBox*decimalPosition;
  1624. QCheckBox*unitQuery;
  1625. ShortHexSpinBox*unitAddress;
  1626. QSpinBox*valueF;
  1627. QSpinBox*valueC;
  1628. QComboBox*fixedUnit;
  1629. ShortHexSpinBox*pVAddress;
  1630. QCheckBox*sVEnabled;
  1631. ShortHexSpinBox*sVReadAddress;
  1632. QCheckBox*deviceLimit;
  1633. ShortHexSpinBox*sVLowerAddr;
  1634. ShortHexSpinBox*sVUpperAddr;
  1635. QDoubleSpinBox*sVLower;
  1636. QDoubleSpinBox*sVUpper;
  1637. QCheckBox*sVWritable;
  1638. ShortHexSpinBox*sVOutputAddr;
  1639. QLineEdit*pVColumnName;
  1640. QLineEdit*sVColumnName;
  1641. };
  1642. /*:810*//*814:*/
  1643. #line 36 "./unsupportedserial.w"
  1644. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1645. {
  1646. Q_OBJECT
  1647. public:
  1648. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1649. const QModelIndex&index);
  1650. private slots:
  1651. void updateConfiguration();
  1652. void saveScript();
  1653. void addChannel();
  1654. private:
  1655. SaltModel*deviceSettingsModel;
  1656. QTextEdit*scriptEditor;
  1657. };
  1658. /*:814*//*819:*/
  1659. #line 166 "./unsupportedserial.w"
  1660. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1661. {
  1662. Q_OBJECT
  1663. public:
  1664. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1665. const QModelIndex&index);
  1666. private slots:
  1667. void updateColumnName(const QString&value);
  1668. void updateHidden(bool hidden);
  1669. void updateConfiguration();
  1670. private:
  1671. SaltModel*channelSettingsModel;
  1672. };
  1673. /*:819*//*824:*/
  1674. #line 298 "./unsupportedserial.w"
  1675. class JavaScriptDevice:public QObject
  1676. {
  1677. Q_OBJECT
  1678. public:
  1679. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1680. QScriptEngine*engine);
  1681. Q_INVOKABLE int channelCount();
  1682. Channel*getChannel(int channel);
  1683. Q_INVOKABLE bool isChannelHidden(int channel);
  1684. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1685. Q_INVOKABLE QString channelColumnName(int channel);
  1686. Q_INVOKABLE QString channelIndicatorText(int channel);
  1687. public slots:
  1688. void setTemperatureColumn(int tcol);
  1689. void setAnnotationColumn(int ncol);
  1690. void start();
  1691. void stop();
  1692. signals:
  1693. void annotation(QString note,int tcol,int ncol);
  1694. void triggerStartBatch();
  1695. void triggerStopBatch();
  1696. void deviceStopRequested();
  1697. private:
  1698. QVariantMap deviceSettings;
  1699. QString deviceScript;
  1700. QList<Channel*> channelList;
  1701. QList<bool> hiddenState;
  1702. QList<Units::Unit> channelUnits;
  1703. QList<QString> columnNames;
  1704. QList<QString> indicatorTexts;
  1705. QList<QVariantMap> channelSettings;
  1706. int annotationTemperatureColumn;
  1707. int annotationNoteColumn;
  1708. QScriptEngine*scriptengine;
  1709. };
  1710. /*:824*//*846:*/
  1711. #line 18424 "./typica.w"
  1712. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1713. {
  1714. Q_OBJECT
  1715. public:
  1716. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1717. const QModelIndex&index);
  1718. private slots:
  1719. void updateSourceColumn(const QString&source);
  1720. void updateDestinationColumn(const QString&dest);
  1721. void updateKnots();
  1722. private:
  1723. SaltModel*tablemodel;
  1724. };
  1725. /*:846*//*852:*/
  1726. #line 18548 "./typica.w"
  1727. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1728. {
  1729. Q_OBJECT
  1730. public:
  1731. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1732. private slots:
  1733. void updateMatchingColumn(const QString&column);
  1734. void updateTemperature();
  1735. private:
  1736. QDoubleSpinBox*temperatureValue;
  1737. QComboBox*unitSelector;
  1738. };
  1739. /*:852*//*856:*/
  1740. #line 16 "./rate.w"
  1741. class RateOfChange:public QObject
  1742. {
  1743. Q_OBJECT
  1744. public:
  1745. RateOfChange(int cachetime= 1,int scaletime= 1);
  1746. public slots:
  1747. void newMeasurement(Measurement measure);
  1748. void setCacheTime(int seconds);
  1749. void setScaleTime(int seconds);
  1750. signals:
  1751. void newData(Measurement measure);
  1752. private:
  1753. int ct;
  1754. int st;
  1755. QList<Measurement> cache;
  1756. };
  1757. /*:856*//*864:*/
  1758. #line 177 "./rate.w"
  1759. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1760. {
  1761. Q_OBJECT
  1762. public:
  1763. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1764. private slots:
  1765. void updateColumn(const QString&column);
  1766. void updateCacheTime(const QString&seconds);
  1767. void updateScaleTime(const QString&seconds);
  1768. };
  1769. /*:864*//*870:*/
  1770. #line 19 "./dataqsdk.w"
  1771. class DataqSdkDeviceImplementation;
  1772. class DataqSdkDevice:public QObject
  1773. {
  1774. Q_OBJECT
  1775. DataqSdkDeviceImplementation*imp;
  1776. private slots:
  1777. void threadFinished();
  1778. public:
  1779. DataqSdkDevice(QString device);
  1780. ~DataqSdkDevice();
  1781. Channel*newChannel(Units::Unit scale);
  1782. Q_INVOKABLE void setClockRate(double Hz);
  1783. Q_INVOKABLE void start();
  1784. static QStringList detectPorts();
  1785. static QStringList detectHardware();
  1786. };
  1787. /*:870*//*871:*/
  1788. #line 49 "./dataqsdk.w"
  1789. class DataqSdkDeviceImplementation:public QThread
  1790. {
  1791. Q_OBJECT
  1792. public:
  1793. DataqSdkDeviceImplementation();
  1794. ~DataqSdkDeviceImplementation();
  1795. void run();
  1796. /*872:*/
  1797. #line 70 "./dataqsdk.w"
  1798. typedef struct di_inlist_struct{
  1799. unsigned short chan;
  1800. unsigned short diff;
  1801. unsigned short gain;
  1802. unsigned short unipolar;
  1803. unsigned short dig_out_enable;
  1804. unsigned short dig_out;
  1805. unsigned short ave;
  1806. unsigned short counter;
  1807. }DI_INLIST_STRUCT;
  1808. typedef int(PASCAL*FPDIOPEN)(unsigned);
  1809. typedef int(PASCAL*FPDICLOSE)(void);
  1810. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  1811. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  1812. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  1813. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  1814. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  1815. typedef int(PASCAL*FPDISTARTSCAN)(void);
  1816. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  1817. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  1818. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  1819. typedef int(PASCAL*FPDISTOPSCAN)(void);
  1820. FPDIOPEN di_open;
  1821. FPDICLOSE di_close;
  1822. FPDISAMPLERATE di_sample_rate;
  1823. FPDIMAXIMUMRATE di_maximum_rate;
  1824. FPDILISTLENGTH di_list_length;
  1825. FPDIINLIST di_inlist;
  1826. FPDIBUFFERALLOC di_buffer_alloc;
  1827. FPDISTARTSCAN di_start_scan;
  1828. FPDISTATUSREAD di_status_read;
  1829. FPDIBUFFERSTATUS di_buffer_status;
  1830. FPDIBURSTRATE di_burst_rate;
  1831. FPDISTOPSCAN di_stop_scan;
  1832. /*:872*/
  1833. #line 57 "./dataqsdk.w"
  1834. /*874:*/
  1835. #line 134 "./dataqsdk.w"
  1836. bool isOpen;
  1837. double sampleRate;
  1838. long oversample;
  1839. long burstDivisor;
  1840. QString device;
  1841. unsigned deviceNumber;
  1842. QVector<Channel*> channelMap;
  1843. int error;
  1844. int channels;
  1845. bool ready;
  1846. QLibrary*driver;
  1847. QVector<Units::Unit> unitMap;
  1848. int*input_buffer;
  1849. QTimer*eventClock;
  1850. QMultiMap<int,double> smoother;
  1851. /*:874*/
  1852. #line 58 "./dataqsdk.w"
  1853. public slots:
  1854. void measure();
  1855. private:
  1856. qint16*buffer;
  1857. };
  1858. /*:871*//*891:*/
  1859. #line 663 "./dataqsdk.w"
  1860. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  1861. {
  1862. Q_OBJECT
  1863. public:
  1864. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  1865. const QModelIndex&index);
  1866. private slots:
  1867. void updateAutoSelect(bool automatic);
  1868. void updateDeviceNumber(int deviceNumber);
  1869. void updatePort(QString portId);
  1870. void addChannel();
  1871. private:
  1872. QStackedWidget*deviceIdStack;
  1873. };
  1874. /*:891*//*896:*/
  1875. #line 808 "./dataqsdk.w"
  1876. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  1877. {
  1878. Q_OBJECT
  1879. public:
  1880. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  1881. const QModelIndex&index);
  1882. private slots:
  1883. void updateUnits(const QString&unit);
  1884. void updateColumnName(const QString&value);
  1885. void updateMeasuredLower(const QString&value);
  1886. void updateMeasuredUpper(const QString&value);
  1887. void updateMappedLower(const QString&value);
  1888. void updateMappedUpper(const QString&value);
  1889. void updateClosedInterval(bool closed);
  1890. void updateSmoothingEnabled(bool enabled);
  1891. void updateSensitivity(const QString&value);
  1892. void startCalibration();
  1893. void stopCalibration();
  1894. void resetCalibration();
  1895. void updateInput(Measurement measure);
  1896. void updateOutput(Measurement measure);
  1897. void updateHidden(bool hidden);
  1898. private:
  1899. QPushButton*startButton;
  1900. QPushButton*resetButton;
  1901. QPushButton*stopButton;
  1902. /*901:*/
  1903. #line 1098 "./dataqsdk.w"
  1904. bool autoSelect;
  1905. QString deviceID;
  1906. unsigned int channelOfInterest;
  1907. /*:901*/
  1908. #line 835 "./dataqsdk.w"
  1909. DataqSdkDevice*calibrationDevice;
  1910. LinearCalibrator*calibrator;
  1911. QLineEdit*currentMeasurement;
  1912. QLineEdit*minimumMeasurement;
  1913. QLineEdit*maximumMeasurement;
  1914. QLineEdit*averageMeasurement;
  1915. QLineEdit*currentMapped;
  1916. QLineEdit*minimumMapped;
  1917. QLineEdit*maximumMapped;
  1918. QLineEdit*averageMapped;
  1919. int rmCount;
  1920. int cmCount;
  1921. double rmin;
  1922. double rmax;
  1923. double rmean;
  1924. double cmin;
  1925. double cmax;
  1926. double cmean;
  1927. };
  1928. /*:896*//*923:*/
  1929. #line 247 "./scales.w"
  1930. Q_DECLARE_METATYPE(BaudRateType)
  1931. Q_DECLARE_METATYPE(DataBitsType)
  1932. Q_DECLARE_METATYPE(ParityType)
  1933. Q_DECLARE_METATYPE(StopBitsType)
  1934. Q_DECLARE_METATYPE(FlowType)
  1935. /*:923*//*930:*/
  1936. #line 370 "./scales.w"
  1937. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  1938. {
  1939. Q_OBJECT
  1940. public:
  1941. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  1942. const QModelIndex&index);
  1943. private slots:
  1944. void updatePort(const QString&newPort);
  1945. void updateBaudRate(const QString&rate);
  1946. void updateParity(int index);
  1947. void updateFlowControl(int index);
  1948. void updateStopBits(int index);
  1949. private:
  1950. PortSelector*port;
  1951. BaudSelector*baud;
  1952. ParitySelector*parity;
  1953. FlowSelector*flow;
  1954. StopSelector*stop;
  1955. };
  1956. /*:930*//*935:*/
  1957. #line 14 "./valueannotation.w"
  1958. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1959. {
  1960. Q_OBJECT
  1961. public:
  1962. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  1963. const QModelIndex&index);
  1964. private slots:
  1965. void updateSourceColumn(const QString&source);
  1966. void updateAnnotations();
  1967. void updateStart(bool noteOnStart);
  1968. private:
  1969. SaltModel*tablemodel;
  1970. };
  1971. /*:935*//*943:*/
  1972. #line 165 "./valueannotation.w"
  1973. class ValueAnnotation:public QObject
  1974. {
  1975. Q_OBJECT
  1976. public:
  1977. ValueAnnotation();
  1978. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  1979. public slots:
  1980. void newMeasurement(Measurement measure);
  1981. void annotate();
  1982. void setAnnotationColumn(int column);
  1983. void setTemperatureColumn(int column);
  1984. void setTolerance(double epsilon);
  1985. signals:
  1986. void annotation(QString annotation,int tempcolumn,int notecolumn);
  1987. private:
  1988. int lastIndex;
  1989. int annotationColumn;
  1990. int measurementColumn;
  1991. QList<double> values;
  1992. QStringList annotations;
  1993. double tolerance;
  1994. };
  1995. /*:943*/
  1996. #line 526 "./typica.w"
  1997. /*12:*/
  1998. #line 805 "./typica.w"
  1999. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2000. /*:12*//*14:*/
  2001. #line 820 "./typica.w"
  2002. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2003. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2004. /*:14*//*16:*/
  2005. #line 845 "./typica.w"
  2006. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2007. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2008. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2009. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2010. QScriptEngine*engine);
  2011. /*:16*//*27:*/
  2012. #line 1089 "./typica.w"
  2013. QScriptValue constructQMainWindow(QScriptContext*context,
  2014. QScriptEngine*engine);
  2015. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2016. QScriptEngine*engine);
  2017. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2018. QScriptEngine*engine);
  2019. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2020. /*:27*//*32:*/
  2021. #line 1188 "./typica.w"
  2022. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2023. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2024. /*:32*//*35:*/
  2025. #line 1233 "./typica.w"
  2026. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2027. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2028. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2029. /*:35*//*38:*/
  2030. #line 1299 "./typica.w"
  2031. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2032. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2033. /*:38*//*41:*/
  2034. #line 1332 "./typica.w"
  2035. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2036. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2037. /*:41*//*44:*/
  2038. #line 1370 "./typica.w"
  2039. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2040. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2041. /*:44*//*48:*/
  2042. #line 1409 "./typica.w"
  2043. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2044. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2045. QScriptEngine*engine);
  2046. QScriptValue QSplitter_saveState(QScriptContext*context,
  2047. QScriptEngine*engine);
  2048. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2049. QScriptEngine*engine);
  2050. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2051. /*:48*//*53:*/
  2052. #line 1528 "./typica.w"
  2053. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2054. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2055. /*:53*//*55:*/
  2056. #line 1583 "./typica.w"
  2057. QScriptValue constructQBoxLayout(QScriptContext*context,
  2058. QScriptEngine*engine);
  2059. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2060. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2061. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2062. /*:55*//*59:*/
  2063. #line 1696 "./typica.w"
  2064. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2065. QScriptValue QAction_setShortcut(QScriptContext*context,
  2066. QScriptEngine*engine);
  2067. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2068. /*:59*//*62:*/
  2069. #line 1752 "./typica.w"
  2070. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2071. QScriptEngine*engine);
  2072. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2073. QScriptEngine*engine);
  2074. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2075. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2076. /*:62*//*67:*/
  2077. #line 1863 "./typica.w"
  2078. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2079. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2080. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2081. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2082. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2083. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2084. QScriptValue QIODevice_readToString(QScriptContext*context,
  2085. QScriptEngine*engine);
  2086. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2087. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2088. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2089. /*:67*//*76:*/
  2090. #line 2044 "./typica.w"
  2091. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2092. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2093. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2094. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2095. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2096. /*:76*//*82:*/
  2097. #line 2114 "./typica.w"
  2098. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2099. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2100. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2101. /*:82*//*85:*/
  2102. #line 2159 "./typica.w"
  2103. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2104. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2105. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2106. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2107. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2108. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2109. /*:85*//*91:*/
  2110. #line 2241 "./typica.w"
  2111. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2112. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2113. QScriptEngine*engine);
  2114. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2115. QScriptEngine*engine);
  2116. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2117. QScriptEngine*engine);
  2118. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2119. QScriptEngine*engine);
  2120. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2121. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2122. QScriptEngine*engine);
  2123. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2124. QScriptEngine*engine);
  2125. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2126. QScriptEngine*engine);
  2127. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2128. QScriptEngine*engine);
  2129. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2130. QScriptEngine*engine);
  2131. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2132. QScriptEngine*engine);
  2133. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2134. QScriptEngine*engine);
  2135. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2136. QScriptEngine*engine);
  2137. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2138. /*:91*//*100:*/
  2139. #line 2459 "./typica.w"
  2140. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2141. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2142. QScriptValue XmlReader_attribute(QScriptContext*context,
  2143. QScriptEngine*engine);
  2144. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2145. QScriptEngine*engine);
  2146. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2147. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2148. QScriptEngine*engine);
  2149. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2150. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2151. QScriptEngine*engine);
  2152. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2153. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2154. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2155. /*:100*//*107:*/
  2156. #line 2594 "./typica.w"
  2157. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2158. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2159. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2160. /*:107*//*111:*/
  2161. #line 2676 "./typica.w"
  2162. QScriptValue constructQLCDNumber(QScriptContext*context,
  2163. QScriptEngine*engine);
  2164. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2165. /*:111*//*114:*/
  2166. #line 2714 "./typica.w"
  2167. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2168. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2169. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2170. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2171. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2172. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2173. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2174. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2175. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2176. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2177. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2178. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2179. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2180. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2181. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2182. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2183. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2184. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2185. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2186. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2187. /*:114*//*130:*/
  2188. #line 3192 "./typica.w"
  2189. void setQAbstractScrollAreaProperties(QScriptValue value,
  2190. QScriptEngine*engine);
  2191. /*:130*//*132:*/
  2192. #line 3207 "./typica.w"
  2193. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2194. /*:132*//*134:*/
  2195. #line 3220 "./typica.w"
  2196. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2197. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2198. /*:134*//*136:*/
  2199. #line 3244 "./typica.w"
  2200. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2201. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2202. QScriptValue constructQPushButton(QScriptContext*context,
  2203. QScriptEngine*engine);
  2204. /*:136*//*143:*/
  2205. #line 3343 "./typica.w"
  2206. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2207. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2208. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2209. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2210. QScriptEngine*engine);
  2211. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2212. QScriptEngine*engine);
  2213. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2214. QScriptEngine*engine);
  2215. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2216. QScriptEngine*engine);
  2217. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2218. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2219. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2220. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2221. /*:143*//*150:*/
  2222. #line 3515 "./typica.w"
  2223. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2224. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2225. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2226. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2227. QScriptValue annotationFromRecord(QScriptContext*context,
  2228. QScriptEngine*engine);
  2229. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2230. QScriptValue findWindowByName(QScriptContext*context,QScriptEngine*engine);
  2231. /*:150*//*162:*/
  2232. #line 3832 "./typica.w"
  2233. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2234. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2235. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2236. QStack<QLayout*> *layoutStack);
  2237. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2238. QStack<QLayout*> *layoutStack);
  2239. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2240. QStack<QLayout*> *layoutStack);
  2241. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2242. QStack<QLayout*> *layoutStack);
  2243. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2244. QStack<QLayout*> *layoutStack);
  2245. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2246. QStack<QLayout*> *layoutStack);
  2247. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2248. QStack<QLayout*> *layoutStack);
  2249. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2250. QStack<QLayout*> *layoutStack);
  2251. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2252. QStack<QLayout*> *layoutStack);
  2253. void addTemperatureDisplayToSplitter(QDomElement element,
  2254. QStack<QWidget*> *widgetStack,
  2255. QStack<QLayout*> *layoutStack);
  2256. void addTemperatureDisplayToLayout(QDomElement element,
  2257. QStack<QWidget*> *widgetStack,
  2258. QStack<QLayout*> *layoutStack);
  2259. void addTimerDisplayToSplitter(QDomElement element,
  2260. QStack<QWidget*> *widgetStack,
  2261. QStack<QLayout*> *layoutStack);
  2262. void addTimerDisplayToLayout(QDomElement element,
  2263. QStack<QWidget*> *widgetStack,
  2264. QStack<QLayout*> *layoutStack);
  2265. void addDecorationToSplitter(QDomElement element,
  2266. QStack<QWidget*> *widgetStack,
  2267. QStack<QLayout*> *layoutStack);
  2268. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2269. QStack<QLayout*> *layoutStack);
  2270. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2271. QStack<QLayout*> *layoutStack);
  2272. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2273. QStack<QLayout*> *layoutStack);
  2274. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2275. QStack<QLayout*> *layoutStack);
  2276. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2277. QStack<QLayout*> *layoutStack);
  2278. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2279. QStack<QLayout*> *layoutStack);
  2280. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2281. QStack<QLayout*> *layoutStack);
  2282. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2283. QStack<QLayout*> *layoutStack);
  2284. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2285. QStack<QLayout*> *layoutStack);
  2286. void addSqlQueryViewToLayout(QDomElement element,
  2287. QStack<QWidget*> *widgetStack,
  2288. QStack<QLayout*> *layoutStack);
  2289. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2290. QStack<QLayout*> *layoutStack);
  2291. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2292. QStack<QLayout*> *layoutStack);
  2293. /*:162*//*214:*/
  2294. #line 5420 "./typica.w"
  2295. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2296. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2297. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2298. QScriptEngine*engine);
  2299. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2300. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2301. QScriptEngine*engine);
  2302. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2303. /*:214*//*215:*/
  2304. #line 5435 "./typica.w"
  2305. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2306. /*:215*//*219:*/
  2307. #line 5570 "./typica.w"
  2308. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2309. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2310. QScriptEngine*engine);
  2311. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2312. QScriptEngine*engine);
  2313. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2314. QScriptEngine*engine);
  2315. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2316. QScriptEngine*engine);
  2317. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2318. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2319. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2320. QScriptEngine*engine);
  2321. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2322. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2323. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2324. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2325. /*:219*//*229:*/
  2326. #line 5786 "./typica.w"
  2327. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2328. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2329. QScriptValue QComboBox_currentData(QScriptContext*context,
  2330. QScriptEngine*engine);
  2331. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2332. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2333. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2334. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2335. /*:229*//*241:*/
  2336. #line 366 "./units.w"
  2337. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2338. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2339. QScriptEngine*engine);
  2340. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2341. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2342. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2343. /*:241*//*245:*/
  2344. #line 430 "./units.w"
  2345. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2346. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2347. /*:245*//*254:*/
  2348. #line 133 "./measurement.w"
  2349. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2350. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2351. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2352. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2353. /*:254*//*274:*/
  2354. #line 6420 "./typica.w"
  2355. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2356. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2357. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2358. /*:274*//*283:*/
  2359. #line 6625 "./typica.w"
  2360. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2361. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2362. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2363. /*:283*//*288:*/
  2364. #line 6726 "./typica.w"
  2365. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2366. /*:288*//*294:*/
  2367. #line 6908 "./typica.w"
  2368. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2369. QScriptEngine*engine);
  2370. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2371. /*:294*//*299:*/
  2372. #line 7048 "./typica.w"
  2373. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2374. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2375. /*:299*//*309:*/
  2376. #line 7250 "./typica.w"
  2377. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2378. QScriptEngine*engine);
  2379. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2380. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2381. QScriptEngine*engine);
  2382. /*:309*//*317:*/
  2383. #line 7409 "./typica.w"
  2384. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2385. QScriptEngine*engine);
  2386. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2387. QScriptEngine*engine);
  2388. /*:317*//*322:*/
  2389. #line 7522 "./typica.w"
  2390. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2391. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2392. /*:322*//*327:*/
  2393. #line 7620 "./typica.w"
  2394. QScriptValue constructZeroEmitter(QScriptContext*context,
  2395. QScriptEngine*engine);
  2396. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2397. /*:327*//*332:*/
  2398. #line 7699 "./typica.w"
  2399. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2400. QScriptEngine*engine);
  2401. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2402. /*:332*//*349:*/
  2403. #line 8163 "./typica.w"
  2404. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2405. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2406. /*:349*//*372:*/
  2407. #line 8790 "./typica.w"
  2408. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2409. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2410. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2411. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2412. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2413. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2414. QScriptEngine*engine);
  2415. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2416. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2417. QScriptEngine*engnie);
  2418. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2419. QScriptEngine*engine);
  2420. /*:372*//*410:*/
  2421. #line 9747 "./typica.w"
  2422. QScriptValue constructAnnotationButton(QScriptContext*context,
  2423. QScriptEngine*engine);
  2424. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2425. /*:410*//*418:*/
  2426. #line 9887 "./typica.w"
  2427. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2428. QScriptEngine*engine);
  2429. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2430. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2431. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2432. /*:418*//*439:*/
  2433. #line 10310 "./typica.w"
  2434. QScriptValue constructTimerDisplay(QScriptContext*context,
  2435. QScriptEngine*engine);
  2436. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2437. /*:439*//*466:*/
  2438. #line 10804 "./typica.w"
  2439. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2440. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2441. QScriptEngine*engine);
  2442. /*:466*//*479:*/
  2443. #line 11087 "./typica.w"
  2444. QScriptValue constructLogEditWindow(QScriptContext*context,
  2445. QScriptEngine*engine);
  2446. /*:479*//*498:*/
  2447. #line 11615 "./typica.w"
  2448. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2449. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2450. /*:498*//*516:*/
  2451. #line 189 "./webview.w"
  2452. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2453. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2454. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2455. QStack<QLayout*> *layoutStack);
  2456. /*:516*//*519:*/
  2457. #line 219 "./webview.w"
  2458. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2459. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2460. /*:519*//*523:*/
  2461. #line 277 "./webview.w"
  2462. QScriptValue constructWebElement(QScriptContext*context,
  2463. QScriptEngine*engine);
  2464. /*:523*//*589:*/
  2465. #line 12928 "./typica.w"
  2466. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2467. QScriptValue constructSqlQueryView(QScriptContext*context,
  2468. QScriptEngine*engine);
  2469. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2470. QScriptEngine*engine);
  2471. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2472. QScriptEngine*engine);
  2473. /*:589*//*599:*/
  2474. #line 13165 "./typica.w"
  2475. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2476. QStack<QLayout*> *layoutStack);
  2477. /*:599*//*615:*/
  2478. #line 13450 "./typica.w"
  2479. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2480. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2481. /*:615*//*637:*/
  2482. #line 470 "./daterangeselector.w"
  2483. void addDateRangeToLayout(QDomElement element,
  2484. QStack<QWidget*> *widgetStack,
  2485. QStack<QLayout*> *layoutStack);
  2486. /*:637*//*646:*/
  2487. #line 13647 "./typica.w"
  2488. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2489. QStack<QLayout*> *layoutStack);
  2490. /*:646*//*667:*/
  2491. #line 14231 "./typica.w"
  2492. void addScaleControlToLayout(QDomElement element,
  2493. QStack<QWidget*> *widgetStack,
  2494. QStack<QLayout*> *layoutStack);
  2495. void addIntensityControlToLayout(QDomElement element,
  2496. QStack<QWidget*> *widgetStack,
  2497. QStack<QLayout*> *layoutStack);
  2498. /*:667*//*693:*/
  2499. #line 14817 "./typica.w"
  2500. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2501. QScriptEngine*engine);
  2502. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2503. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2504. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2505. QScriptEngine*engine);
  2506. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2507. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2508. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2509. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2510. /*:693*//*699:*/
  2511. #line 14959 "./typica.w"
  2512. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2513. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2514. /*:699*//*715:*/
  2515. #line 15257 "./typica.w"
  2516. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2517. QScriptEngine*engine);
  2518. /*:715*//*786:*/
  2519. #line 40 "./settings.w"
  2520. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2521. /*:786*//*805:*/
  2522. #line 17795 "./typica.w"
  2523. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2524. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2525. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2526. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2527. /*:805*//*825:*/
  2528. #line 345 "./unsupportedserial.w"
  2529. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2530. /*:825*//*831:*/
  2531. #line 425 "./unsupportedserial.w"
  2532. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2533. /*:831*//*837:*/
  2534. #line 617 "./unsupportedserial.w"
  2535. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2536. /*:837*//*841:*/
  2537. #line 651 "./unsupportedserial.w"
  2538. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2539. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2540. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2541. /*:841*//*861:*/
  2542. #line 138 "./rate.w"
  2543. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2544. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2545. /*:861*//*886:*/
  2546. #line 597 "./dataqsdk.w"
  2547. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2548. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2549. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2550. /*:886*//*913:*/
  2551. #line 67 "./scales.w"
  2552. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2553. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2554. /*:913*//*921:*/
  2555. #line 233 "./scales.w"
  2556. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2557. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2558. /*:921*//*924:*/
  2559. #line 258 "./scales.w"
  2560. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2561. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2562. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2563. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2564. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2565. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2566. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2567. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2568. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2569. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2570. /*:924*//*949:*/
  2571. #line 265 "./valueannotation.w"
  2572. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2573. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2574. /*:949*/
  2575. #line 527 "./typica.w"
  2576. /*4:*/
  2577. #line 535 "./typica.w"
  2578. /*707:*/
  2579. #line 15080 "./typica.w"
  2580. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2581. const QString&driver,QObject*parent):
  2582. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2583. {
  2584. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2585. }
  2586. void NodeInserter::onTriggered()
  2587. {
  2588. emit triggered(defaultNodeName,driverString);
  2589. }
  2590. /*:707*/
  2591. #line 536 "./typica.w"
  2592. /*250:*/
  2593. #line 40 "./measurement.w"
  2594. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2595. {
  2596. insert("measurement",temperature);
  2597. insert("time",time);
  2598. insert("unit",sc);
  2599. }
  2600. Measurement::Measurement(double temperature)
  2601. {
  2602. insert("measurement",temperature);
  2603. insert("time",QTime::currentTime());
  2604. insert("unit",Units::Fahrenheit);
  2605. }
  2606. void Measurement::setTemperature(double temperature)
  2607. {
  2608. insert("measurement",temperature);
  2609. }
  2610. void Measurement::setTime(QTime time)
  2611. {
  2612. insert("time",time);
  2613. }
  2614. void Measurement::setUnit(Units::Unit scale)
  2615. {
  2616. insert("unit",scale);
  2617. }
  2618. double Measurement::temperature()const
  2619. {
  2620. return value("measurement").toDouble();
  2621. }
  2622. QTime Measurement::time()const
  2623. {
  2624. return value("time").toTime();
  2625. }
  2626. Units::Unit Measurement::scale()const
  2627. {
  2628. return(Units::Unit)(value("unit").toInt());
  2629. }
  2630. /*:250*//*251:*/
  2631. #line 88 "./measurement.w"
  2632. Measurement Measurement::toFahrenheit()
  2633. {
  2634. return Measurement(Units::convertTemperature(this->temperature(),
  2635. this->scale(),Units::Fahrenheit),
  2636. this->time(),Units::Fahrenheit);
  2637. }
  2638. Measurement Measurement::toCelsius()
  2639. {
  2640. return Measurement(Units::convertTemperature(this->temperature(),
  2641. this->scale(),Units::Celsius),
  2642. this->time(),Units::Celsius);
  2643. }
  2644. Measurement Measurement::toKelvin()
  2645. {
  2646. return Measurement(Units::convertTemperature(this->temperature(),
  2647. this->scale(),Units::Kelvin),
  2648. this->time(),Units::Kelvin);
  2649. }
  2650. Measurement Measurement::toRankine()
  2651. {
  2652. return Measurement(Units::convertTemperature(this->temperature(),
  2653. this->scale(),Units::Rankine),
  2654. this->time(),Units::Rankine);
  2655. }
  2656. /*:251*/
  2657. #line 537 "./typica.w"
  2658. /*264:*/
  2659. #line 6026 "./typica.w"
  2660. void DAQImplementation::measure()
  2661. {
  2662. int samplesRead= 0;
  2663. double buffer[channels];
  2664. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2665. (unsigned long)(0),buffer,(unsigned long)(channels),
  2666. &samplesRead,(signed long)(0));
  2667. if(error)
  2668. {
  2669. ready= false;
  2670. }
  2671. else
  2672. {
  2673. if(samplesRead)
  2674. {
  2675. QTime time= QTime::currentTime();
  2676. for(int i= 0;i<samplesRead;i++)
  2677. {
  2678. for(int j= 0;j<channels;j++)
  2679. {
  2680. Measurement measure(buffer[j+(i*channels)],time,
  2681. unitMap[j]);
  2682. channelMap[j]->input(measure);
  2683. }
  2684. }
  2685. }
  2686. }
  2687. }
  2688. /*:264*//*265:*/
  2689. #line 6068 "./typica.w"
  2690. void DAQImplementation::run()
  2691. {
  2692. setPriority(QThread::TimeCriticalPriority);
  2693. while(ready)
  2694. {
  2695. measure();
  2696. }
  2697. }
  2698. /*:265*//*266:*/
  2699. #line 6084 "./typica.w"
  2700. void DAQ::threadFinished()
  2701. {
  2702. if(imp->error)
  2703. {
  2704. /*267:*/
  2705. #line 6135 "./typica.w"
  2706. imp->ready= false;
  2707. QMessageBox warning;
  2708. warning.setStandardButtons(QMessageBox::Cancel);
  2709. warning.setIcon(QMessageBox::Warning);
  2710. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2711. unsigned long bytes= imp->errorInfo(NULL,0);
  2712. char string[bytes];
  2713. imp->errorInfo(string,bytes);
  2714. warning.setInformativeText(QString(string));
  2715. warning.setWindowTitle(QString(PROGRAM_NAME));
  2716. warning.exec();
  2717. /*:267*/
  2718. #line 6089 "./typica.w"
  2719. }
  2720. }
  2721. /*:266*//*268:*/
  2722. #line 6160 "./typica.w"
  2723. void DAQ::start()
  2724. {
  2725. if(imp->ready)
  2726. {
  2727. imp->error= imp->startTask(imp->handle);
  2728. if(imp->error)
  2729. {
  2730. /*267:*/
  2731. #line 6135 "./typica.w"
  2732. imp->ready= false;
  2733. QMessageBox warning;
  2734. warning.setStandardButtons(QMessageBox::Cancel);
  2735. warning.setIcon(QMessageBox::Warning);
  2736. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2737. unsigned long bytes= imp->errorInfo(NULL,0);
  2738. char string[bytes];
  2739. imp->errorInfo(string,bytes);
  2740. warning.setInformativeText(QString(string));
  2741. warning.setWindowTitle(QString(PROGRAM_NAME));
  2742. warning.exec();
  2743. /*:267*/
  2744. #line 6168 "./typica.w"
  2745. }
  2746. else
  2747. {
  2748. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2749. imp->start();
  2750. }
  2751. }
  2752. }
  2753. void DAQ::stop()
  2754. {
  2755. if(imp->useBase)
  2756. {
  2757. imp->ready= false;
  2758. imp->wait(ULONG_MAX);
  2759. imp->stopTask(imp->handle);
  2760. }
  2761. else
  2762. {
  2763. imp->ready= false;
  2764. imp->error= imp->stopTask(imp->handle);
  2765. if(imp->error)
  2766. {
  2767. /*267:*/
  2768. #line 6135 "./typica.w"
  2769. imp->ready= false;
  2770. QMessageBox warning;
  2771. warning.setStandardButtons(QMessageBox::Cancel);
  2772. warning.setIcon(QMessageBox::Warning);
  2773. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2774. unsigned long bytes= imp->errorInfo(NULL,0);
  2775. char string[bytes];
  2776. imp->errorInfo(string,bytes);
  2777. warning.setInformativeText(QString(string));
  2778. warning.setWindowTitle(QString(PROGRAM_NAME));
  2779. warning.exec();
  2780. /*:267*/
  2781. #line 6192 "./typica.w"
  2782. }
  2783. imp->error= imp->clearTask(imp->handle);
  2784. if(imp->error)
  2785. {
  2786. /*267:*/
  2787. #line 6135 "./typica.w"
  2788. imp->ready= false;
  2789. QMessageBox warning;
  2790. warning.setStandardButtons(QMessageBox::Cancel);
  2791. warning.setIcon(QMessageBox::Warning);
  2792. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2793. unsigned long bytes= imp->errorInfo(NULL,0);
  2794. char string[bytes];
  2795. imp->errorInfo(string,bytes);
  2796. warning.setInformativeText(QString(string));
  2797. warning.setWindowTitle(QString(PROGRAM_NAME));
  2798. warning.exec();
  2799. /*:267*/
  2800. #line 6197 "./typica.w"
  2801. }
  2802. }
  2803. }
  2804. /*:268*//*269:*/
  2805. #line 6207 "./typica.w"
  2806. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  2807. {
  2808. imp->device= device;
  2809. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  2810. if(imp->error)
  2811. {
  2812. /*267:*/
  2813. #line 6135 "./typica.w"
  2814. imp->ready= false;
  2815. QMessageBox warning;
  2816. warning.setStandardButtons(QMessageBox::Cancel);
  2817. warning.setIcon(QMessageBox::Warning);
  2818. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2819. unsigned long bytes= imp->errorInfo(NULL,0);
  2820. char string[bytes];
  2821. imp->errorInfo(string,bytes);
  2822. warning.setInformativeText(QString(string));
  2823. warning.setWindowTitle(QString(PROGRAM_NAME));
  2824. warning.exec();
  2825. /*:267*/
  2826. #line 6214 "./typica.w"
  2827. }
  2828. else
  2829. {
  2830. imp->ready= true;
  2831. }
  2832. }
  2833. /*:269*//*270:*/
  2834. #line 6228 "./typica.w"
  2835. Channel*DAQ::newChannel(int units,int thermocouple)
  2836. {
  2837. Channel*retval= new Channel();
  2838. imp->channelMap[imp->channels]= retval;
  2839. imp->unitMap[imp->channels]= (Units::Unit)units;
  2840. imp->channels++;
  2841. if(imp->ready)
  2842. {
  2843. if(imp->useBase)
  2844. {
  2845. imp->error= imp->createChannel(imp->handle,
  2846. QString("%1/ai%2").arg(imp->device).
  2847. arg(imp->channels-1).
  2848. toAscii().data(),
  2849. "",(double)(-1.0),(double)(100.0),
  2850. (signed long)(units),
  2851. (signed long)(thermocouple),
  2852. (signed long)(10200),(double)(0),
  2853. "");
  2854. }
  2855. else
  2856. {
  2857. imp->error= imp->createChannel(imp->handle,
  2858. QString("%1/ai%2").arg(imp->device).
  2859. arg(imp->channels-1).
  2860. toAscii().data(),
  2861. "",(double)(50.0),(double)(500.0),
  2862. (signed long)(units),
  2863. (signed long)(thermocouple),
  2864. (signed long)(10200),(double)(0),
  2865. "");
  2866. }
  2867. if(imp->error)
  2868. {
  2869. /*267:*/
  2870. #line 6135 "./typica.w"
  2871. imp->ready= false;
  2872. QMessageBox warning;
  2873. warning.setStandardButtons(QMessageBox::Cancel);
  2874. warning.setIcon(QMessageBox::Warning);
  2875. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2876. unsigned long bytes= imp->errorInfo(NULL,0);
  2877. char string[bytes];
  2878. imp->errorInfo(string,bytes);
  2879. warning.setInformativeText(QString(string));
  2880. warning.setWindowTitle(QString(PROGRAM_NAME));
  2881. warning.exec();
  2882. /*:267*/
  2883. #line 6263 "./typica.w"
  2884. }
  2885. }
  2886. return retval;
  2887. }
  2888. /*:270*//*271:*/
  2889. #line 6277 "./typica.w"
  2890. void DAQ::setClockRate(double Hz)
  2891. {
  2892. if(imp->ready)
  2893. {
  2894. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  2895. (signed long)(10280),(signed long)(10123),
  2896. (unsigned long long)(1));
  2897. if(imp->error)
  2898. {
  2899. /*267:*/
  2900. #line 6135 "./typica.w"
  2901. imp->ready= false;
  2902. QMessageBox warning;
  2903. warning.setStandardButtons(QMessageBox::Cancel);
  2904. warning.setIcon(QMessageBox::Warning);
  2905. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2906. unsigned long bytes= imp->errorInfo(NULL,0);
  2907. char string[bytes];
  2908. imp->errorInfo(string,bytes);
  2909. warning.setInformativeText(QString(string));
  2910. warning.setWindowTitle(QString(PROGRAM_NAME));
  2911. warning.exec();
  2912. /*:267*/
  2913. #line 6287 "./typica.w"
  2914. }
  2915. }
  2916. }
  2917. /*:271*//*272:*/
  2918. #line 6297 "./typica.w"
  2919. DAQ::~DAQ()
  2920. {
  2921. if(imp->useBase)
  2922. {
  2923. imp->resetDevice(imp->device.toAscii().data());
  2924. imp->clearTask(imp->handle);
  2925. }
  2926. else
  2927. {
  2928. if(imp->ready)
  2929. {
  2930. imp->ready= false;
  2931. imp->wait(ULONG_MAX);
  2932. imp->stopTask(imp->handle);
  2933. imp->resetDevice(imp->device.toAscii().data());
  2934. imp->clearTask(imp->handle);
  2935. }
  2936. }
  2937. delete imp;
  2938. }
  2939. /*:272*//*273:*/
  2940. #line 6328 "./typica.w"
  2941. DAQImplementation::DAQImplementation(const QString&driverinfo)
  2942. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  2943. unitMap(4)
  2944. {
  2945. if(driverinfo=="nidaqmxbase")
  2946. {
  2947. useBase= true;
  2948. }
  2949. else
  2950. {
  2951. useBase= false;
  2952. }
  2953. if(useBase)
  2954. {
  2955. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  2956. if(!driver.load())
  2957. {
  2958. driver.setFileName("nidaqmxbase");
  2959. if(!driver.load())
  2960. {
  2961. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2962. tr("Failed to find nidaqmxbase. Please install it."));
  2963. QApplication::quit();
  2964. }
  2965. }
  2966. }
  2967. else
  2968. {
  2969. driver.setFileName("nicaiu");
  2970. if(!driver.load())
  2971. {
  2972. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2973. tr("Failed to find nidaqmx. Please install it."));
  2974. QApplication::quit();
  2975. }
  2976. }
  2977. if(useBase)
  2978. {
  2979. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  2980. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  2981. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  2982. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  2983. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  2984. ==0||
  2985. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  2986. 0||
  2987. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  2988. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  2989. 0||
  2990. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  2991. {
  2992. waitForMeasurement= NULL;
  2993. QMessageBox::critical(NULL,tr("Typica: Link error"),
  2994. tr("Failed to link a required symbol in NI-DAQmxBase."));
  2995. QApplication::quit();
  2996. }
  2997. }
  2998. else
  2999. {
  3000. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3001. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3002. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3003. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3004. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3005. ==0||
  3006. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3007. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3008. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3009. 0||
  3010. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3011. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3012. {
  3013. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3014. tr("Failed to link a required symbol in NI-DAQmx."));
  3015. QApplication::quit();
  3016. }
  3017. }
  3018. }
  3019. DAQImplementation::~DAQImplementation()
  3020. {
  3021. driver.unload();
  3022. }
  3023. /*:273*/
  3024. #line 538 "./typica.w"
  3025. /*875:*/
  3026. #line 197 "./dataqsdk.w"
  3027. void DataqSdkDeviceImplementation::measure()
  3028. {
  3029. unsigned count= channels*40;
  3030. di_status_read(buffer,count);
  3031. QTime time= QTime::currentTime();
  3032. for(unsigned int i= 0;i<count;i++)
  3033. {
  3034. buffer[i]= buffer[i]&0xFFFC;
  3035. }
  3036. QList<int> countList;
  3037. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3038. {
  3039. QList<double> channelBuffer;
  3040. for(unsigned int j= 0;j<40;j++)
  3041. {
  3042. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3043. if(i==0)
  3044. {
  3045. countList<<buffer[i+(channels*j)];
  3046. }
  3047. }
  3048. double value= 0.0;
  3049. for(unsigned int j= 0;j<40;j++)
  3050. {
  3051. value+= channelBuffer[j];
  3052. }
  3053. value/= 40.0;
  3054. if(i==0)
  3055. {
  3056. QList<double> smoothingList;
  3057. smoothingList<<value;
  3058. QList<int> smoothingKeys= smoother.uniqueKeys();
  3059. for(int j= 0;j<smoothingKeys.size();j++)
  3060. {
  3061. if(countList.contains(smoothingKeys[j]))
  3062. {
  3063. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3064. for(int k= 0;k<keyValues.size();k++)
  3065. {
  3066. smoothingList<<keyValues[k];
  3067. }
  3068. }
  3069. else
  3070. {
  3071. smoother.remove(smoothingKeys[j]);
  3072. }
  3073. }
  3074. qSort(countList);
  3075. int lastCount= 0;
  3076. for(int j= 0;j<countList.size();j++)
  3077. {
  3078. if(j==0||countList[j]!=lastCount)
  3079. {
  3080. smoother.insert(countList[j],value);
  3081. lastCount= countList[j];
  3082. }
  3083. }
  3084. value= 0.0;
  3085. for(int j= 0;j<smoothingList.size();j++)
  3086. {
  3087. value+= smoothingList[j];
  3088. }
  3089. value/= smoothingList.size();
  3090. }
  3091. Measurement measure(value,time,unitMap[i]);
  3092. channelMap[i]->input(measure);
  3093. }
  3094. }
  3095. /*:875*//*876:*/
  3096. #line 290 "./dataqsdk.w"
  3097. void DataqSdkDeviceImplementation::run()
  3098. {
  3099. if(!ready)
  3100. {
  3101. error= 9;
  3102. return;
  3103. }
  3104. driver= new QLibrary(device);
  3105. if(!driver->load())
  3106. {
  3107. error= 1;
  3108. qDebug()<<"Failed to load driver: "<<device;
  3109. return;
  3110. }
  3111. di_open= (FPDIOPEN)driver->resolve("di_open");
  3112. di_close= (FPDICLOSE)driver->resolve("di_close");
  3113. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3114. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3115. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3116. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3117. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3118. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3119. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3120. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3121. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3122. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3123. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3124. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3125. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3126. (!di_burst_rate)||(!di_stop_scan))
  3127. {
  3128. error= 2;
  3129. return;
  3130. }
  3131. error= di_open(deviceNumber);
  3132. if(error)
  3133. {
  3134. di_close();
  3135. error= di_open(deviceNumber);
  3136. if(error)
  3137. {
  3138. error= 3;
  3139. di_close();
  3140. return;
  3141. }
  3142. }
  3143. isOpen= true;
  3144. di_maximum_rate(240.0);
  3145. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3146. &burstDivisor);
  3147. buffer= new qint16[(int)sampleRate];
  3148. di_inlist_struct inlist[16]= {{0}};
  3149. for(unsigned short i= 0;i<channels;i++)
  3150. {
  3151. inlist[i].chan= i;
  3152. inlist[i].gain= 0;
  3153. inlist[i].ave= 1;
  3154. inlist[i].counter= (oversample-1);
  3155. }
  3156. error= di_list_length(channels,0);
  3157. if(error)
  3158. {
  3159. error= 4;
  3160. return;
  3161. }
  3162. error= di_inlist(inlist);
  3163. if(error)
  3164. {
  3165. error= 5;
  3166. return;
  3167. }
  3168. input_buffer= di_buffer_alloc(0,4096);
  3169. if(input_buffer==NULL)
  3170. {
  3171. error= 6;
  3172. return;
  3173. }
  3174. error= di_start_scan();
  3175. if(error)
  3176. {
  3177. error= 7;
  3178. return;
  3179. }
  3180. while(ready)
  3181. {
  3182. measure();
  3183. }
  3184. }
  3185. /*:876*//*877:*/
  3186. #line 386 "./dataqsdk.w"
  3187. void DataqSdkDevice::threadFinished()
  3188. {
  3189. if(imp->error)
  3190. {
  3191. /*878:*/
  3192. #line 400 "./dataqsdk.w"
  3193. imp->ready= false;
  3194. QMessageBox warning;
  3195. warning.setStandardButtons(QMessageBox::Cancel);
  3196. warning.setIcon(QMessageBox::Warning);
  3197. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3198. warning.setInformativeText(tr("An error occurred"));
  3199. warning.setWindowTitle(QString(PROGRAM_NAME));
  3200. warning.exec();
  3201. /*:878*/
  3202. #line 391 "./dataqsdk.w"
  3203. }
  3204. }
  3205. /*:877*//*879:*/
  3206. #line 417 "./dataqsdk.w"
  3207. void DataqSdkDevice::start()
  3208. {
  3209. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3210. imp->start();
  3211. }
  3212. /*:879*//*880:*/
  3213. #line 428 "./dataqsdk.w"
  3214. QStringList DataqSdkDevice::detectHardware()
  3215. {
  3216. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3217. QSettings::NativeFormat);
  3218. QStringList keys= deviceLookup.childKeys();
  3219. QStringList devices;
  3220. for(int i= 0;i<keys.size();i++)
  3221. {
  3222. QString value= deviceLookup.value(keys.at(i)).toString();
  3223. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3224. {
  3225. devices.append(value.split("\\").at(2));
  3226. }
  3227. }
  3228. QStringList portList;
  3229. foreach(QString device,devices)
  3230. {
  3231. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3232. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3233. portList.append(deviceEntry.value("FriendlyName").toString());
  3234. }
  3235. return portList;
  3236. }
  3237. QStringList DataqSdkDevice::detectPorts()
  3238. {
  3239. QStringList friendlyNames= detectHardware();
  3240. QStringList portList;
  3241. foreach(QString name,friendlyNames)
  3242. {
  3243. name.remove(0,name.indexOf("COM"));
  3244. name.chop(1);
  3245. portList.append(name);
  3246. }
  3247. return portList;
  3248. }
  3249. /*:880*//*881:*/
  3250. #line 473 "./dataqsdk.w"
  3251. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3252. {
  3253. bool usesAuto= false;
  3254. int autoIndex= device.toInt(&usesAuto);
  3255. QString finalizedPort;
  3256. if(usesAuto)
  3257. {
  3258. QStringList portList= detectPorts();
  3259. if(autoIndex> 0&&autoIndex<=portList.size())
  3260. {
  3261. finalizedPort= portList.at(autoIndex-1);
  3262. }
  3263. else
  3264. {
  3265. imp->error= 8;
  3266. qDebug()<<"Failed to detect port.";
  3267. }
  3268. }
  3269. else
  3270. {
  3271. finalizedPort= device;
  3272. }
  3273. int rstart= finalizedPort.indexOf("COM");
  3274. finalizedPort.remove(0,rstart+3);
  3275. bool chopFinished= false;
  3276. int finalizedPortNumber= 0;
  3277. while(finalizedPort.size()> 0&&!chopFinished)
  3278. {
  3279. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3280. if(!chopFinished)
  3281. {
  3282. finalizedPort.chop(1);
  3283. }
  3284. }
  3285. if(finalizedPortNumber<10)
  3286. {
  3287. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3288. }
  3289. else
  3290. {
  3291. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3292. }
  3293. imp->deviceNumber= 0x12C02D00;
  3294. imp->deviceNumber+= finalizedPortNumber;
  3295. imp->ready= true;
  3296. }
  3297. /*:881*//*882:*/
  3298. #line 523 "./dataqsdk.w"
  3299. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3300. {
  3301. Channel*retval= NULL;
  3302. if(imp->ready)
  3303. {
  3304. retval= new Channel();
  3305. imp->channelMap[imp->channels]= retval;
  3306. imp->unitMap[imp->channels]= scale;
  3307. imp->channels++;
  3308. }
  3309. return retval;
  3310. }
  3311. /*:882*//*883:*/
  3312. #line 547 "./dataqsdk.w"
  3313. void DataqSdkDevice::setClockRate(double Hz)
  3314. {
  3315. imp->sampleRate= Hz;
  3316. }
  3317. /*:883*//*884:*/
  3318. #line 557 "./dataqsdk.w"
  3319. DataqSdkDevice::~DataqSdkDevice()
  3320. {
  3321. if(imp->ready)
  3322. {
  3323. imp->ready= false;
  3324. }
  3325. imp->wait(ULONG_MAX);
  3326. delete imp;
  3327. }
  3328. /*:884*//*885:*/
  3329. #line 575 "./dataqsdk.w"
  3330. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3331. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3332. {
  3333. }
  3334. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3335. {
  3336. if(isOpen)
  3337. {
  3338. di_stop_scan();
  3339. di_close();
  3340. }
  3341. if(driver->isLoaded())
  3342. {
  3343. driver->unload();
  3344. }
  3345. }
  3346. /*:885*/
  3347. #line 539 "./typica.w"
  3348. /*280:*/
  3349. #line 6537 "./typica.w"
  3350. void FakeDAQImplementation::measure()
  3351. {
  3352. msleep((int)(1000/clockRate));
  3353. QTime time= QTime::currentTime();
  3354. for(int i= 0;i<channels;i++)
  3355. {
  3356. Measurement measure(qrand()%500,time);
  3357. channelMap[i]->input(measure);
  3358. }
  3359. }
  3360. /*:280*//*281:*/
  3361. #line 6551 "./typica.w"
  3362. void FakeDAQImplementation::run()
  3363. {
  3364. setPriority(QThread::TimeCriticalPriority);
  3365. while(ready)
  3366. {
  3367. measure();
  3368. }
  3369. }
  3370. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3371. channels(0),ready(false),clockRate(1)
  3372. {
  3373. }
  3374. FakeDAQImplementation::~FakeDAQImplementation()
  3375. {
  3376. }
  3377. /*:281*//*282:*/
  3378. #line 6576 "./typica.w"
  3379. void FakeDAQ::start()
  3380. {
  3381. if(imp->ready)
  3382. {
  3383. imp->start();
  3384. }
  3385. }
  3386. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3387. {
  3388. imp->ready= true;
  3389. }
  3390. Channel*FakeDAQ::newChannel(int,int)
  3391. {
  3392. Channel*retval;
  3393. if(imp->ready)
  3394. {
  3395. retval= new Channel();
  3396. imp->channelMap[imp->channels]= retval;
  3397. imp->channels++;
  3398. }
  3399. else
  3400. {
  3401. return NULL;
  3402. }
  3403. return retval;
  3404. }
  3405. void FakeDAQ::setClockRate(double Hz)
  3406. {
  3407. if(imp->ready)
  3408. {
  3409. imp->clockRate= Hz;
  3410. }
  3411. }
  3412. FakeDAQ::~FakeDAQ()
  3413. {
  3414. imp->ready= false;
  3415. imp->wait(ULONG_MAX);
  3416. delete imp;
  3417. }
  3418. /*:282*/
  3419. #line 540 "./typica.w"
  3420. /*287:*/
  3421. #line 6707 "./typica.w"
  3422. Channel::Channel():QObject(NULL)
  3423. {
  3424. }
  3425. Channel::~Channel()
  3426. {
  3427. }
  3428. void Channel::input(Measurement measurement)
  3429. {
  3430. emit newData(measurement);
  3431. }
  3432. /*:287*/
  3433. #line 541 "./typica.w"
  3434. /*303:*/
  3435. #line 7112 "./typica.w"
  3436. void TemperatureDisplay::setRelativeMode(bool relative)
  3437. {
  3438. r= relative;
  3439. }
  3440. /*:303*//*304:*/
  3441. #line 7129 "./typica.w"
  3442. void TemperatureDisplay::setValue(Measurement temperature)
  3443. {
  3444. QString number;
  3445. switch(unit)
  3446. {
  3447. case Units::Fahrenheit:
  3448. display(QString("%1'F").
  3449. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3450. 2)));
  3451. break;
  3452. case Units::Celsius:
  3453. if(!r){
  3454. display(QString("%1'C").
  3455. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3456. 2)));
  3457. }else{
  3458. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3459. display(QString("%1'C").arg(number));
  3460. }
  3461. break;
  3462. case Units::Kelvin:
  3463. if(!r){
  3464. display(QString("%1").
  3465. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3466. 2)));
  3467. }else{
  3468. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3469. display(QString("%1").arg(number));
  3470. }
  3471. break;
  3472. case Units::Rankine:
  3473. display(QString("%1'r").
  3474. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3475. 2)));
  3476. break;
  3477. case Units::Unitless:
  3478. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3479. break;
  3480. default:
  3481. switch(temperature.scale())
  3482. {
  3483. case Units::Fahrenheit:
  3484. display(QString("%1'F").
  3485. arg(number.setNum(temperature.temperature(),'f',2)));
  3486. break;
  3487. case Units::Celsius:
  3488. display(QString("%1'C").
  3489. arg(number.setNum(temperature.temperature(),'f',2)));
  3490. break;
  3491. case Units::Kelvin:
  3492. display(QString("%1").
  3493. arg(number.setNum(temperature.temperature(),'f',2)));
  3494. break;
  3495. case Units::Rankine:
  3496. display(QString("%1'r").
  3497. arg(number.setNum(temperature.temperature(),'f',2)));
  3498. break;
  3499. case Units::Unitless:
  3500. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3501. break;
  3502. }
  3503. break;
  3504. }
  3505. }
  3506. /*:304*//*305:*/
  3507. #line 7205 "./typica.w"
  3508. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3509. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3510. {
  3511. setSegmentStyle(Filled);
  3512. display("---.--'F");
  3513. }
  3514. /*:305*//*306:*/
  3515. #line 7221 "./typica.w"
  3516. void TemperatureDisplay::invalidate()
  3517. {
  3518. display("---.--'F");
  3519. }
  3520. /*:306*//*307:*/
  3521. #line 7233 "./typica.w"
  3522. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3523. {
  3524. unit= scale;
  3525. }
  3526. /*:307*//*308:*/
  3527. #line 7241 "./typica.w"
  3528. TemperatureDisplay::~TemperatureDisplay()
  3529. {
  3530. }
  3531. /*:308*/
  3532. #line 542 "./typica.w"
  3533. /*314:*/
  3534. #line 7341 "./typica.w"
  3535. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3536. {
  3537. if(measure.time()<epoch)
  3538. {
  3539. if(hasPrevious)
  3540. {
  3541. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3542. epoch.msec());
  3543. QTime jitComp(epoch.hour(),measure.time().minute(),
  3544. measure.time().second(),measure.time().msec());
  3545. int relTime= jitBase.msecsTo(jitComp);
  3546. /*315:*/
  3547. #line 7375 "./typica.w"
  3548. QTime newTime(0,0,0,0);
  3549. newTime= newTime.addMSecs(relTime);
  3550. if(newTime.hour()> 0)
  3551. {
  3552. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3553. }
  3554. Measurement rel= measure;
  3555. rel.setTime(newTime);
  3556. emit measurement(rel);
  3557. /*:315*/
  3558. #line 7353 "./typica.w"
  3559. }
  3560. else
  3561. {
  3562. Measurement rel= measure;
  3563. rel.setTime(QTime(0,0,0,0));
  3564. emit measurement(rel);
  3565. }
  3566. }
  3567. else
  3568. {
  3569. int relTime= epoch.msecsTo(measure.time());
  3570. /*315:*/
  3571. #line 7375 "./typica.w"
  3572. QTime newTime(0,0,0,0);
  3573. newTime= newTime.addMSecs(relTime);
  3574. if(newTime.hour()> 0)
  3575. {
  3576. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3577. }
  3578. Measurement rel= measure;
  3579. rel.setTime(newTime);
  3580. emit measurement(rel);
  3581. /*:315*/
  3582. #line 7365 "./typica.w"
  3583. }
  3584. hasPrevious= true;
  3585. previous= measure.time();
  3586. }
  3587. /*:314*//*316:*/
  3588. #line 7388 "./typica.w"
  3589. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3590. previous(0,0,0,0),hasPrevious(false)
  3591. {
  3592. }
  3593. QTime MeasurementTimeOffset::zeroTime()
  3594. {
  3595. return epoch;
  3596. }
  3597. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3598. {
  3599. epoch= zero;
  3600. hasPrevious= false;
  3601. }
  3602. /*:316*/
  3603. #line 543 "./typica.w"
  3604. /*326:*/
  3605. #line 7586 "./typica.w"
  3606. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3607. {
  3608. }
  3609. int ZeroEmitter::column()
  3610. {
  3611. return col;
  3612. }
  3613. double ZeroEmitter::lastTemperature()
  3614. {
  3615. return cache.temperature();
  3616. }
  3617. void ZeroEmitter::newMeasurement(Measurement measure)
  3618. {
  3619. cache= measure;
  3620. }
  3621. void ZeroEmitter::setColumn(int column)
  3622. {
  3623. col= column;
  3624. }
  3625. void ZeroEmitter::emitZero()
  3626. {
  3627. cache.setTime(QTime(0,0,0,0));
  3628. emit measurement(cache,col);
  3629. }
  3630. /*:326*/
  3631. #line 544 "./typica.w"
  3632. /*331:*/
  3633. #line 7676 "./typica.w"
  3634. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3635. {
  3636. }
  3637. int MeasurementAdapter::column()
  3638. {
  3639. return col;
  3640. }
  3641. void MeasurementAdapter::newMeasurement(Measurement measure)
  3642. {
  3643. emit measurement(measure,col);
  3644. }
  3645. void MeasurementAdapter::setColumn(int column)
  3646. {
  3647. col= column;
  3648. }
  3649. /*:331*/
  3650. #line 545 "./typica.w"
  3651. /*336:*/
  3652. #line 7798 "./typica.w"
  3653. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3654. theScene(new QGraphicsScene),
  3655. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3656. prevPoints(new QMap<int,QPointF> ),
  3657. translations(new QMap<int,double> ),
  3658. gridLinesF(new QList<QGraphicsItem*> ),
  3659. gridLinesC(new QList<QGraphicsItem*> ),
  3660. relativeGridLines(new QList<QGraphicsItem*> ),
  3661. relativeEnabled(false),
  3662. timeIndicatorEnabled(false),
  3663. timeLine(new QGraphicsLineItem),
  3664. relativeAdjuster(new LinearSplineInterpolator)
  3665. {
  3666. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3667. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3668. setScene(theScene);
  3669. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3670. QPen timePen;
  3671. timePen.setColor(QColor(160,160,164,127));
  3672. timeLine->setPen(timePen);
  3673. timeLine->setLine(0,0,0,-500);
  3674. timeLine->hide();
  3675. theScene->addItem(timeLine);
  3676. /*337:*/
  3677. #line 7838 "./typica.w"
  3678. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3679. tempaxis->setLine(-10,-500,-10,0);
  3680. theScene->addItem(tempaxis);
  3681. QGraphicsLineItem*gridLine;
  3682. QGraphicsTextItem*label;
  3683. for(int y= -100;y> -600;y-= 100)
  3684. {
  3685. gridLine= new QGraphicsLineItem;
  3686. gridLine->setLine(0,y,1200,y);
  3687. theScene->addItem(gridLine);
  3688. label= new QGraphicsTextItem;
  3689. label->setHtml(QString("%1&deg;F").arg(-y));
  3690. label->setPos(-55,y-(label->boundingRect().height()/2));
  3691. theScene->addItem(label);
  3692. gridLinesF->append(gridLine);
  3693. gridLinesF->append(label);
  3694. }
  3695. for(int degC= 50;degC<=250;degC+= 50)
  3696. {
  3697. gridLine= new QGraphicsLineItem;
  3698. int y= -(degC*(9.0/5.0)+32);
  3699. gridLine->setLine(0,y,1200,y);
  3700. gridLine->hide();
  3701. theScene->addItem(gridLine);
  3702. gridLinesC->append(gridLine);
  3703. label= new QGraphicsTextItem;
  3704. label->setHtml(QString("%1&deg;C").arg(degC));
  3705. label->setPos(-55,y-(label->boundingRect().height()/2));
  3706. label->hide();
  3707. theScene->addItem(label);
  3708. gridLinesC->append(label);
  3709. }
  3710. /*:337*/
  3711. #line 7822 "./typica.w"
  3712. ;
  3713. /*338:*/
  3714. #line 7879 "./typica.w"
  3715. QSettings settings;
  3716. if(settings.contains("settings/graph/relative/enable"))
  3717. {
  3718. if(settings.value("settings/graph/relative/enable").toBool())
  3719. {
  3720. relativeEnabled= true;
  3721. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  3722. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  3723. QMap<double,QString> relativeAxisPairs;
  3724. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  3725. foreach(QString item,relativeAxisLabels)
  3726. {
  3727. relativeAxisPairs.insert(item.toDouble(),item);
  3728. }
  3729. if(relativeAxisPairs.size()> 1)
  3730. {
  3731. double skip= 500.0/(relativeAxisPairs.size()-1);
  3732. double y= 0;
  3733. foreach(double key,relativeAxisPairs.keys())
  3734. {
  3735. gridLine= new QGraphicsLineItem;
  3736. gridLine->setLine(0,y,1205,y);
  3737. gridLine->setPen(QPen(relativeColor));
  3738. theScene->addItem(gridLine);
  3739. relativeGridLines->append(gridLine);
  3740. label= new QGraphicsTextItem;
  3741. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  3742. label->setPos(1210,y-(label->boundingRect().height()/2));
  3743. theScene->addItem(label);
  3744. relativeGridLines->append(label);
  3745. if(unit=="F")
  3746. {
  3747. relativeAdjuster->add_pair(key,-y);
  3748. }
  3749. else
  3750. {
  3751. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  3752. }
  3753. y-= skip;
  3754. }
  3755. }
  3756. }
  3757. }
  3758. /*:338*/
  3759. #line 7823 "./typica.w"
  3760. /*340:*/
  3761. #line 7956 "./typica.w"
  3762. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  3763. timeaxis->setLine(0,10,1200,10);
  3764. theScene->addItem(timeaxis);
  3765. for(int x= 0;x<1201;x+= 120)
  3766. {
  3767. QGraphicsLineItem*tick= new QGraphicsLineItem;
  3768. tick->setLine(x,0,x,20);
  3769. theScene->addItem(tick);
  3770. QGraphicsTextItem*label= new QGraphicsTextItem;
  3771. label->setPlainText(QString("%1").arg(x/60));
  3772. label->setPos(x-(label->boundingRect().width()/2),20);
  3773. theScene->addItem(label);
  3774. }
  3775. /*:340*/
  3776. #line 7824 "./typica.w"
  3777. ;
  3778. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3779. }
  3780. /*:336*//*339:*/
  3781. #line 7926 "./typica.w"
  3782. void GraphView::showF()
  3783. {
  3784. for(int i= 0;i<gridLinesF->size();i++)
  3785. {
  3786. gridLinesF->at(i)->show();
  3787. }
  3788. for(int i= 0;i<gridLinesC->size();i++)
  3789. {
  3790. gridLinesC->at(i)->hide();
  3791. }
  3792. }
  3793. void GraphView::showC()
  3794. {
  3795. for(int i= 0;i<gridLinesF->size();i++)
  3796. {
  3797. gridLinesF->at(i)->hide();
  3798. }
  3799. for(int i= 0;i<gridLinesC->size();i++)
  3800. {
  3801. gridLinesC->at(i)->show();
  3802. }
  3803. }
  3804. /*:339*//*341:*/
  3805. #line 7975 "./typica.w"
  3806. void GraphView::resizeEvent(QResizeEvent*)
  3807. {
  3808. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  3809. }
  3810. /*:341*//*342:*/
  3811. #line 7989 "./typica.w"
  3812. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  3813. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  3814. {
  3815. double offset= 0;
  3816. if(measure.contains("relative"))
  3817. {
  3818. if(measure.value("relative").toBool())
  3819. {
  3820. if(relativeEnabled)
  3821. {
  3822. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  3823. }
  3824. else
  3825. {
  3826. return;
  3827. }
  3828. }
  3829. }
  3830. if(translations->contains(tempcolumn))
  3831. {
  3832. offset= translations->value(tempcolumn);
  3833. }
  3834. if(prevPoints->contains(tempcolumn))
  3835. {
  3836. /*344:*/
  3837. #line 8066 "./typica.w"
  3838. QGraphicsLineItem*segment= new QGraphicsLineItem;
  3839. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  3840. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  3841. -(prevPoints->value(tempcolumn).y()),
  3842. nextPoint.x()+offset,-(nextPoint.y()));
  3843. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  3844. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  3845. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  3846. Qt::darkYellow};
  3847. segment->setPen(p[tempcolumn%12]);
  3848. theScene->addItem(segment);
  3849. prevPoints->insert(tempcolumn,nextPoint);
  3850. if(timeIndicatorEnabled)
  3851. {
  3852. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  3853. }
  3854. /*:344*/
  3855. #line 8015 "./typica.w"
  3856. if(graphLines->contains(tempcolumn))
  3857. {
  3858. graphLines->value(tempcolumn)->append(segment);
  3859. }
  3860. else
  3861. {
  3862. QList<QGraphicsLineItem*> *newLine=
  3863. new QList<QGraphicsLineItem*> ;
  3864. newLine->append(segment);
  3865. graphLines->insert(tempcolumn,newLine);
  3866. }
  3867. }
  3868. else
  3869. {
  3870. /*343:*/
  3871. #line 8051 "./typica.w"
  3872. int x= FULLTIMETOINT(measure.time())/1000;
  3873. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  3874. if(timeIndicatorEnabled)
  3875. {
  3876. timeLine->setLine(x,0,x,-500);
  3877. }
  3878. /*:343*/
  3879. #line 8032 "./typica.w"
  3880. }
  3881. }
  3882. /*:342*//*345:*/
  3883. #line 8087 "./typica.w"
  3884. void GraphView::clear()
  3885. {
  3886. int i;
  3887. foreach(i,prevPoints->keys())
  3888. {
  3889. removeSeries(i);
  3890. }
  3891. translations->clear();
  3892. }
  3893. /*:345*//*346:*/
  3894. #line 8101 "./typica.w"
  3895. void GraphView::removeSeries(int column)
  3896. {
  3897. if(graphLines->contains(column))
  3898. {
  3899. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3900. QGraphicsLineItem*segment;
  3901. foreach(segment,*series)
  3902. {
  3903. theScene->removeItem(segment);
  3904. }
  3905. qDeleteAll(*series);
  3906. }
  3907. graphLines->remove(column);
  3908. prevPoints->remove(column);
  3909. }
  3910. /*:346*//*347:*/
  3911. #line 8120 "./typica.w"
  3912. void GraphView::setSeriesTranslation(int column,double offset)
  3913. {
  3914. if(graphLines->contains(column))
  3915. {
  3916. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3917. QGraphicsLineItem*segment;
  3918. foreach(segment,*series)
  3919. {
  3920. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  3921. }
  3922. }
  3923. if(translations->contains(column))
  3924. {
  3925. translations->insert(column,offset+translations->value(column));
  3926. }
  3927. else
  3928. {
  3929. translations->insert(column,offset);
  3930. }
  3931. }
  3932. /*:347*//*348:*/
  3933. #line 8147 "./typica.w"
  3934. void GraphView::setTimeIndicatorEnabled(bool enabled)
  3935. {
  3936. timeIndicatorEnabled= enabled;
  3937. if(enabled)
  3938. {
  3939. timeLine->show();
  3940. }
  3941. else
  3942. {
  3943. timeLine->hide();
  3944. }
  3945. }
  3946. /*:348*/
  3947. #line 546 "./typica.w"
  3948. /*354:*/
  3949. #line 8291 "./typica.w"
  3950. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  3951. {
  3952. if(measure.time()!=QTime(0,0,0,0))
  3953. {
  3954. /*356:*/
  3955. #line 8365 "./typica.w"
  3956. if(lastMeasurement.contains(tempcolumn))
  3957. {
  3958. if(lastMeasurement[tempcolumn].time()<measure.time())
  3959. {
  3960. QList<QTime> timelist;
  3961. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  3962. {
  3963. timelist.append(i);
  3964. }
  3965. for(int i= 0;i<timelist.size();i++)
  3966. {
  3967. Measurement synthesized= measure;
  3968. synthesized.setTime(timelist[i]);
  3969. newMeasurement(synthesized,tempcolumn);
  3970. }
  3971. }
  3972. }
  3973. /*:356*/
  3974. #line 8296 "./typica.w"
  3975. }
  3976. model_ms->newMeasurement(measure,tempcolumn);
  3977. if(lastMeasurement.contains(tempcolumn))
  3978. {
  3979. if(measure.time().second()!=
  3980. lastMeasurement.value(tempcolumn).time().second())
  3981. {
  3982. Measurement adjusted= measure;
  3983. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  3984. adjusted.setTime(adjtime);
  3985. model_1s->newMeasurement(adjusted,tempcolumn);
  3986. if(adjusted.time().second()%5==0)
  3987. {
  3988. model_5s->newMeasurement(adjusted,tempcolumn);
  3989. if(adjusted.time().second()%10==0)
  3990. {
  3991. model_10s->newMeasurement(adjusted,tempcolumn);
  3992. }
  3993. if(adjusted.time().second()%15==0)
  3994. {
  3995. model_15s->newMeasurement(adjusted,tempcolumn);
  3996. if(adjusted.time().second()%30==0)
  3997. {
  3998. model_30s->newMeasurement(adjusted,tempcolumn);
  3999. if(adjusted.time().second()==0)
  4000. {
  4001. model_1m->newMeasurement(adjusted,tempcolumn);
  4002. }
  4003. }
  4004. }
  4005. }
  4006. }
  4007. /*358:*/
  4008. #line 8409 "./typica.w"
  4009. if(currentColumnSet.contains(tempcolumn))
  4010. {
  4011. int replicationcolumn;
  4012. foreach(replicationcolumn,currentColumnSet)
  4013. {
  4014. if(replicationcolumn!=tempcolumn)
  4015. {
  4016. if(lastMeasurement.contains(replicationcolumn))
  4017. {
  4018. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4019. {
  4020. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4021. synthetic.setTime(measure.time());
  4022. model_ms->newMeasurement(synthetic,replicationcolumn);
  4023. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4024. {
  4025. Measurement adjusted= synthetic;
  4026. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4027. model_1s->newMeasurement(adjusted,replicationcolumn);
  4028. if(adjusted.time().second()%5==0)
  4029. {
  4030. model_5s->newMeasurement(adjusted,replicationcolumn);
  4031. if(adjusted.time().second()%10==0)
  4032. {
  4033. model_10s->newMeasurement(adjusted,replicationcolumn);
  4034. }
  4035. if(adjusted.time().second()%15==0)
  4036. {
  4037. model_15s->newMeasurement(adjusted,replicationcolumn);
  4038. if(adjusted.time().second()%30==0)
  4039. {
  4040. model_30s->newMeasurement(adjusted,replicationcolumn);
  4041. if(adjusted.time().second()==0)
  4042. {
  4043. model_1m->newMeasurement(adjusted,replicationcolumn);
  4044. }
  4045. }
  4046. }
  4047. }
  4048. }
  4049. lastMeasurement[replicationcolumn]= synthetic;
  4050. }
  4051. }
  4052. }
  4053. }
  4054. }
  4055. /*:358*/
  4056. #line 8329 "./typica.w"
  4057. }
  4058. else
  4059. {
  4060. /*355:*/
  4061. #line 8341 "./typica.w"
  4062. MeasurementModel*m;
  4063. foreach(m,modelSet)
  4064. {
  4065. m->newMeasurement(measure,tempcolumn);
  4066. }
  4067. /*:355*/
  4068. #line 8333 "./typica.w"
  4069. }
  4070. lastMeasurement.insert(tempcolumn,measure);
  4071. }
  4072. /*:354*//*357:*/
  4073. #line 8395 "./typica.w"
  4074. void ZoomLog::addToCurrentColumnSet(int column)
  4075. {
  4076. currentColumnSet.append(column);
  4077. }
  4078. void ZoomLog::clearCurrentColumnSet()
  4079. {
  4080. currentColumnSet.clear();
  4081. }
  4082. /*:357*//*359:*/
  4083. #line 8479 "./typica.w"
  4084. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4085. int annotationcolumn)
  4086. {
  4087. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4088. MeasurementModel*m;
  4089. if(lastMeasurement.contains(tempcolumn))
  4090. {
  4091. foreach(m,modelSet)
  4092. {
  4093. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4094. }
  4095. }
  4096. foreach(m,modelSet)
  4097. {
  4098. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4099. }
  4100. }
  4101. /*:359*//*360:*/
  4102. #line 8503 "./typica.w"
  4103. void ZoomLog::centerOn(int row)
  4104. {
  4105. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4106. }
  4107. /*:360*//*361:*/
  4108. #line 8513 "./typica.w"
  4109. void ZoomLog::clear()
  4110. {
  4111. MeasurementModel*m;
  4112. foreach(m,modelSet)
  4113. {
  4114. m->clear();
  4115. }
  4116. lastMeasurement.clear();
  4117. saveTempCols.clear();
  4118. saveControlCols.clear();
  4119. saveNoteCols.clear();
  4120. }
  4121. /*:361*//*362:*/
  4122. #line 8531 "./typica.w"
  4123. QVariant ZoomLog::data(int row,int column)const
  4124. {
  4125. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4126. Qt::DisplayRole);
  4127. }
  4128. int ZoomLog::rowCount()
  4129. {
  4130. return model_ms->rowCount();
  4131. }
  4132. /*:362*//*363:*/
  4133. #line 8554 "./typica.w"
  4134. bool ZoomLog::saveXML(QIODevice*device)
  4135. {
  4136. Units::Unit prevUnits= model_ms->displayUnits();
  4137. if(prevUnits!=Units::Fahrenheit)
  4138. {
  4139. model_ms->setDisplayUnits(Units::Fahrenheit);
  4140. }
  4141. XMLOutput writer(model_ms,device,0);
  4142. int c;
  4143. foreach(c,saveTempCols)
  4144. {
  4145. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4146. toString(),c);
  4147. }
  4148. foreach(c,saveControlCols)
  4149. {
  4150. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4151. toString(),c);
  4152. }
  4153. foreach(c,saveNoteCols)
  4154. {
  4155. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4156. toString(),c);
  4157. }
  4158. bool retval= writer.output();
  4159. if(prevUnits!=Units::Fahrenheit)
  4160. {
  4161. model_ms->setDisplayUnits(prevUnits);
  4162. }
  4163. return retval;
  4164. }
  4165. /*:363*//*364:*/
  4166. #line 8590 "./typica.w"
  4167. bool ZoomLog::saveCSV(QIODevice*device)
  4168. {
  4169. CSVOutput writer(currentModel,device,0);
  4170. int c;
  4171. foreach(c,saveTempCols)
  4172. {
  4173. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4174. toString(),c);
  4175. }
  4176. foreach(c,saveControlCols)
  4177. {
  4178. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4179. toString(),c);
  4180. }
  4181. foreach(c,saveNoteCols)
  4182. {
  4183. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4184. toString(),c);
  4185. }
  4186. return writer.output();
  4187. }
  4188. /*:364*//*365:*/
  4189. #line 8619 "./typica.w"
  4190. void ZoomLog::switchLOD(MeasurementModel*m)
  4191. {
  4192. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4193. setModel(m);
  4194. currentModel= m;
  4195. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4196. }
  4197. void ZoomLog::LOD_ms()
  4198. {
  4199. switchLOD(model_ms);
  4200. }
  4201. void ZoomLog::LOD_1s()
  4202. {
  4203. switchLOD(model_1s);
  4204. }
  4205. void ZoomLog::LOD_5s()
  4206. {
  4207. switchLOD(model_5s);
  4208. }
  4209. void ZoomLog::LOD_10s()
  4210. {
  4211. switchLOD(model_10s);
  4212. }
  4213. void ZoomLog::LOD_15s()
  4214. {
  4215. switchLOD(model_15s);
  4216. }
  4217. void ZoomLog::LOD_30s()
  4218. {
  4219. switchLOD(model_30s);
  4220. }
  4221. void ZoomLog::LOD_1m()
  4222. {
  4223. switchLOD(model_1m);
  4224. }
  4225. /*:365*//*366:*/
  4226. #line 8667 "./typica.w"
  4227. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4228. {
  4229. model_ms->setDisplayUnits(scale);
  4230. model_1s->setDisplayUnits(scale);
  4231. model_5s->setDisplayUnits(scale);
  4232. model_10s->setDisplayUnits(scale);
  4233. model_15s->setDisplayUnits(scale);
  4234. model_30s->setDisplayUnits(scale);
  4235. model_1m->setDisplayUnits(scale);
  4236. }
  4237. Units::Unit ZoomLog::displayUnits()
  4238. {
  4239. return model_ms->displayUnits();
  4240. }
  4241. /*:366*//*367:*/
  4242. #line 8687 "./typica.w"
  4243. QString ZoomLog::lastTime(int series)
  4244. {
  4245. Measurement measure= lastMeasurement.value(series);
  4246. QTime time= measure.time();
  4247. return time.toString("h:mm:ss.zzz");
  4248. }
  4249. /*:367*//*368:*/
  4250. #line 8697 "./typica.w"
  4251. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4252. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4253. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4254. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4255. {
  4256. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4257. setSelectionMode(QAbstractItemView::NoSelection);
  4258. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4259. model_30s<<model_1m;
  4260. currentModel= model_30s;
  4261. setModel(currentModel);
  4262. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4263. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4264. this,SLOT(persistColumnResize(int,int,int)));
  4265. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4266. this,SLOT(restoreColumnWidths()));
  4267. }
  4268. /*:368*//*369:*/
  4269. #line 8720 "./typica.w"
  4270. void ZoomLog::setHeaderData(int section,QString text)
  4271. {
  4272. MeasurementModel*m;
  4273. foreach(m,modelSet)
  4274. {
  4275. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4276. }
  4277. }
  4278. /*:369*//*370:*/
  4279. #line 8738 "./typica.w"
  4280. void ZoomLog::addOutputTemperatureColumn(int column)
  4281. {
  4282. saveTempCols.append(column);
  4283. }
  4284. void ZoomLog::addOutputControlColumn(int column)
  4285. {
  4286. saveControlCols.append(column);
  4287. }
  4288. void ZoomLog::addOutputAnnotationColumn(int column)
  4289. {
  4290. saveNoteCols.append(column);
  4291. }
  4292. void ZoomLog::clearOutputColumns()
  4293. {
  4294. saveTempCols.clear();
  4295. saveControlCols.clear();
  4296. saveNoteCols.clear();
  4297. }
  4298. /*:370*//*371:*/
  4299. #line 8764 "./typica.w"
  4300. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4301. {
  4302. /*582:*/
  4303. #line 12843 "./typica.w"
  4304. QSettings settings;
  4305. /*583:*/
  4306. #line 12856 "./typica.w"
  4307. QWidget*topLevelWidget= this;
  4308. while(topLevelWidget->parentWidget())
  4309. {
  4310. topLevelWidget= topLevelWidget->parentWidget();
  4311. }
  4312. /*:583*/
  4313. #line 12845 "./typica.w"
  4314. settings.setValue(QString("columnWidths/%1/%2/%3").
  4315. arg(topLevelWidget->objectName()).
  4316. arg(objectName()).arg(column),
  4317. QVariant(newsize));
  4318. /*:582*/
  4319. #line 8767 "./typica.w"
  4320. }
  4321. void ZoomLog::restoreColumnWidths()
  4322. {
  4323. /*585:*/
  4324. #line 12876 "./typica.w"
  4325. QSettings settings;
  4326. /*583:*/
  4327. #line 12856 "./typica.w"
  4328. QWidget*topLevelWidget= this;
  4329. while(topLevelWidget->parentWidget())
  4330. {
  4331. topLevelWidget= topLevelWidget->parentWidget();
  4332. }
  4333. /*:583*/
  4334. #line 12878 "./typica.w"
  4335. QString baseKey=
  4336. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4337. arg(objectName());
  4338. for(int i= 0;i<model()->columnCount();i++)
  4339. {
  4340. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4341. if(settings.contains(key))
  4342. {
  4343. setColumnWidth(i,settings.value(key).toInt());
  4344. }
  4345. }
  4346. /*:585*/
  4347. #line 8772 "./typica.w"
  4348. }
  4349. void ZoomLog::setVisible(bool visibility)
  4350. {
  4351. QTableView::setVisible(visibility);
  4352. }
  4353. void ZoomLog::showEvent(QShowEvent*)
  4354. {
  4355. /*585:*/
  4356. #line 12876 "./typica.w"
  4357. QSettings settings;
  4358. /*583:*/
  4359. #line 12856 "./typica.w"
  4360. QWidget*topLevelWidget= this;
  4361. while(topLevelWidget->parentWidget())
  4362. {
  4363. topLevelWidget= topLevelWidget->parentWidget();
  4364. }
  4365. /*:583*/
  4366. #line 12878 "./typica.w"
  4367. QString baseKey=
  4368. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4369. arg(objectName());
  4370. for(int i= 0;i<model()->columnCount();i++)
  4371. {
  4372. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4373. if(settings.contains(key))
  4374. {
  4375. setColumnWidth(i,settings.value(key).toInt());
  4376. }
  4377. }
  4378. /*:585*/
  4379. #line 8782 "./typica.w"
  4380. }
  4381. /*:371*/
  4382. #line 547 "./typica.w"
  4383. /*380:*/
  4384. #line 9015 "./typica.w"
  4385. bool MeasurementList::operator<(const MeasurementList&other)const
  4386. {
  4387. return this->first().toTime()<other.first().toTime();
  4388. }
  4389. bool MeasurementList::operator==(const MeasurementList&other)const
  4390. {
  4391. return this->first().toTime()==other.first().toTime();
  4392. }
  4393. /*:380*//*381:*/
  4394. #line 9031 "./typica.w"
  4395. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4396. {
  4397. return QModelIndex();
  4398. }
  4399. /*:381*//*382:*/
  4400. #line 9041 "./typica.w"
  4401. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4402. {
  4403. if(measure.scale()==Units::Unitless)
  4404. {
  4405. controlColumns->insert(tempcolumn,true);
  4406. }
  4407. else
  4408. {
  4409. controlColumns->insert(tempcolumn,false);
  4410. }
  4411. MeasurementList*temp;
  4412. temp= new MeasurementList;
  4413. temp->append(QVariant(measure.time()));
  4414. /*383:*/
  4415. #line 9100 "./typica.w"
  4416. /*384:*/
  4417. #line 9145 "./typica.w"
  4418. QList<MeasurementList*> ::iterator i= lastInsertion;
  4419. bool quickscan= false;
  4420. if(entries->size()> 5)
  4421. {
  4422. if(**i<*temp)
  4423. {
  4424. i+= 1;
  4425. for(int j= 10;j> 0;j--)
  4426. {
  4427. if(i!=entries->end())
  4428. {
  4429. if(**i<*temp)
  4430. {
  4431. i+= 1;
  4432. }
  4433. else
  4434. {
  4435. quickscan= true;
  4436. break;
  4437. }
  4438. }
  4439. else
  4440. {
  4441. quickscan= true;
  4442. break;
  4443. }
  4444. }
  4445. }
  4446. else
  4447. {
  4448. if(**i==*temp)
  4449. {
  4450. quickscan= true;
  4451. }
  4452. }
  4453. }
  4454. /*:384*/
  4455. #line 9101 "./typica.w"
  4456. if(quickscan==false)
  4457. {
  4458. i= entries->begin();
  4459. QList<MeasurementList*> ::iterator u= entries->end();
  4460. QList<MeasurementList*> ::iterator midpoint;
  4461. int n= u-i;
  4462. int rA;
  4463. while(n> 0)
  4464. {
  4465. rA= n>>1;
  4466. midpoint= i+rA;
  4467. if(**midpoint<*temp)
  4468. {
  4469. i= midpoint+1;
  4470. n-= rA+1;
  4471. }
  4472. else
  4473. {
  4474. n= rA;
  4475. }
  4476. }
  4477. }
  4478. /*:383*/
  4479. #line 9055 "./typica.w"
  4480. MeasurementList*newEntry;
  4481. int insertion;
  4482. if(i!=entries->end())
  4483. {
  4484. insertion= entries->indexOf(*i);
  4485. if((*i)->first().toTime()==measure.time())
  4486. {
  4487. /*385:*/
  4488. #line 9187 "./typica.w"
  4489. if((*i)->size()<tempcolumn+1)
  4490. {
  4491. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4492. {
  4493. (*i)->append(QVariant());
  4494. }
  4495. }
  4496. (*i)->replace(tempcolumn,measure);
  4497. lastInsertion= i;
  4498. emit dataChanged(createIndex(insertion,tempcolumn),
  4499. createIndex(insertion,tempcolumn));
  4500. lastTemperature->insert(tempcolumn,insertion);
  4501. /*:385*/
  4502. #line 9063 "./typica.w"
  4503. }
  4504. else
  4505. {
  4506. /*386:*/
  4507. #line 9205 "./typica.w"
  4508. beginInsertRows(QModelIndex(),insertion,insertion);
  4509. newEntry= new MeasurementList;
  4510. newEntry->append(QVariant(measure.time()));
  4511. for(int j= 0;j<tempcolumn+1;j++)
  4512. {
  4513. newEntry->append(QVariant());
  4514. }
  4515. newEntry->replace(tempcolumn,measure);
  4516. lastInsertion= entries->insert(i,newEntry);
  4517. endInsertRows();
  4518. lastTemperature->insert(tempcolumn,insertion);
  4519. /*:386*/
  4520. #line 9067 "./typica.w"
  4521. }
  4522. }
  4523. else
  4524. {
  4525. /*387:*/
  4526. #line 9223 "./typica.w"
  4527. insertion= entries->size();
  4528. /*386:*/
  4529. #line 9205 "./typica.w"
  4530. beginInsertRows(QModelIndex(),insertion,insertion);
  4531. newEntry= new MeasurementList;
  4532. newEntry->append(QVariant(measure.time()));
  4533. for(int j= 0;j<tempcolumn+1;j++)
  4534. {
  4535. newEntry->append(QVariant());
  4536. }
  4537. newEntry->replace(tempcolumn,measure);
  4538. lastInsertion= entries->insert(i,newEntry);
  4539. endInsertRows();
  4540. lastTemperature->insert(tempcolumn,insertion);
  4541. /*:386*/
  4542. #line 9225 "./typica.w"
  4543. /*:387*/
  4544. #line 9072 "./typica.w"
  4545. }
  4546. if(tempcolumn>=colcount)
  4547. {
  4548. colcount= tempcolumn+1;
  4549. }
  4550. emit rowChanged(insertion);
  4551. delete temp;
  4552. }
  4553. /*:382*//*388:*/
  4554. #line 9235 "./typica.w"
  4555. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4556. int annotationColumn)
  4557. {
  4558. int r;
  4559. if(lastTemperature->contains(tempcolumn))
  4560. {
  4561. r= lastTemperature->value(tempcolumn);
  4562. }
  4563. else
  4564. {
  4565. r= 0;
  4566. }
  4567. if(r==0&&entries->size()==0)
  4568. {
  4569. /*389:*/
  4570. #line 9273 "./typica.w"
  4571. beginInsertRows(QModelIndex(),0,0);
  4572. MeasurementList*newEntry= new MeasurementList;
  4573. newEntry->append(QVariant(QTime(0,0,0,0)));
  4574. entries->append(newEntry);
  4575. endInsertRows();
  4576. /*:389*/
  4577. #line 9250 "./typica.w"
  4578. }
  4579. MeasurementList*row= entries->at(r);
  4580. if(row->size()<=annotationColumn)
  4581. {
  4582. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4583. {
  4584. row->append(QVariant());
  4585. }
  4586. }
  4587. row->replace(annotationColumn,annotation);
  4588. emit dataChanged(createIndex(r,annotationColumn),
  4589. createIndex(r,annotationColumn));
  4590. emit rowChanged(r);
  4591. if(annotationColumn> colcount-1)
  4592. {
  4593. colcount= annotationColumn+1;
  4594. }
  4595. }
  4596. /*:388*//*390:*/
  4597. #line 9284 "./typica.w"
  4598. void MeasurementModel::clear()
  4599. {
  4600. beginRemoveRows(QModelIndex(),0,entries->size());
  4601. while(entries->size()!=0)
  4602. {
  4603. MeasurementList*row= entries->takeFirst();
  4604. delete row;
  4605. }
  4606. endRemoveRows();
  4607. colcount= hData->size();
  4608. lastTemperature->clear();
  4609. reset();
  4610. }
  4611. /*:390*//*391:*/
  4612. #line 9317 "./typica.w"
  4613. bool MeasurementModel::setData(const QModelIndex&index,
  4614. const QVariant&value,int role)
  4615. {
  4616. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4617. {
  4618. return false;
  4619. }
  4620. /*392:*/
  4621. #line 9349 "./typica.w"
  4622. bool valid= false;
  4623. if(index.isValid())
  4624. {
  4625. if(index.row()<entries->size())
  4626. {
  4627. if(index.column()<colcount)
  4628. {
  4629. valid= true;
  4630. }
  4631. }
  4632. }
  4633. /*:392*/
  4634. #line 9325 "./typica.w"
  4635. if(!valid)
  4636. {
  4637. return false;
  4638. }
  4639. MeasurementList*row= entries->at(index.row());
  4640. if(index.column()>=row->size())
  4641. {
  4642. /*393:*/
  4643. #line 9366 "./typica.w"
  4644. for(int i= row->size()-1;i<index.column();i++)
  4645. {
  4646. row->append(QVariant());
  4647. }
  4648. /*:393*/
  4649. #line 9333 "./typica.w"
  4650. }
  4651. if(index.column()==0)
  4652. {
  4653. /*394:*/
  4654. #line 9381 "./typica.w"
  4655. QTime time;
  4656. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4657. {
  4658. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4659. {
  4660. return false;
  4661. }
  4662. }
  4663. row= entries->takeAt(index.row());
  4664. row->replace(index.column(),QVariant(time));
  4665. MeasurementList*temp= row;
  4666. /*383:*/
  4667. #line 9100 "./typica.w"
  4668. /*384:*/
  4669. #line 9145 "./typica.w"
  4670. QList<MeasurementList*> ::iterator i= lastInsertion;
  4671. bool quickscan= false;
  4672. if(entries->size()> 5)
  4673. {
  4674. if(**i<*temp)
  4675. {
  4676. i+= 1;
  4677. for(int j= 10;j> 0;j--)
  4678. {
  4679. if(i!=entries->end())
  4680. {
  4681. if(**i<*temp)
  4682. {
  4683. i+= 1;
  4684. }
  4685. else
  4686. {
  4687. quickscan= true;
  4688. break;
  4689. }
  4690. }
  4691. else
  4692. {
  4693. quickscan= true;
  4694. break;
  4695. }
  4696. }
  4697. }
  4698. else
  4699. {
  4700. if(**i==*temp)
  4701. {
  4702. quickscan= true;
  4703. }
  4704. }
  4705. }
  4706. /*:384*/
  4707. #line 9101 "./typica.w"
  4708. if(quickscan==false)
  4709. {
  4710. i= entries->begin();
  4711. QList<MeasurementList*> ::iterator u= entries->end();
  4712. QList<MeasurementList*> ::iterator midpoint;
  4713. int n= u-i;
  4714. int rA;
  4715. while(n> 0)
  4716. {
  4717. rA= n>>1;
  4718. midpoint= i+rA;
  4719. if(**midpoint<*temp)
  4720. {
  4721. i= midpoint+1;
  4722. n-= rA+1;
  4723. }
  4724. else
  4725. {
  4726. n= rA;
  4727. }
  4728. }
  4729. }
  4730. /*:383*/
  4731. #line 9393 "./typica.w"
  4732. entries->insert(i,row);
  4733. int newRow= entries->indexOf(*i);
  4734. if(newRow<index.row())
  4735. {
  4736. emit dataChanged(createIndex(newRow,index.column()),index);
  4737. }
  4738. else
  4739. {
  4740. emit dataChanged(index,createIndex(newRow,index.column()));
  4741. }
  4742. /*:394*/
  4743. #line 9337 "./typica.w"
  4744. }
  4745. else
  4746. {
  4747. /*395:*/
  4748. #line 9407 "./typica.w"
  4749. row->replace(index.column(),value);
  4750. emit dataChanged(index,index);
  4751. /*:395*/
  4752. #line 9341 "./typica.w"
  4753. }
  4754. return true;
  4755. }
  4756. /*:391*//*396:*/
  4757. #line 9415 "./typica.w"
  4758. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  4759. unit(Units::Fahrenheit),hData(new QStringList),
  4760. lastTemperature(new QHash<int,int> ),
  4761. controlColumns(new QHash<int,bool> )
  4762. {
  4763. colcount= 1;
  4764. entries= new QList<MeasurementList*> ;
  4765. lastInsertion= entries->begin();
  4766. hData->append(tr("Time"));
  4767. }
  4768. /*:396*//*397:*/
  4769. #line 9429 "./typica.w"
  4770. MeasurementModel::~MeasurementModel()
  4771. {
  4772. clear();
  4773. delete entries;
  4774. delete hData;
  4775. }
  4776. /*:397*//*398:*/
  4777. #line 9441 "./typica.w"
  4778. int MeasurementModel::rowCount(const QModelIndex&parent)const
  4779. {
  4780. if(parent==QModelIndex())
  4781. {
  4782. return entries->size();
  4783. }
  4784. return 0;
  4785. }
  4786. int MeasurementModel::columnCount(const QModelIndex&parent)const
  4787. {
  4788. if(parent==QModelIndex())
  4789. {
  4790. return colcount;
  4791. }
  4792. return 0;
  4793. }
  4794. /*:398*//*399:*/
  4795. #line 9468 "./typica.w"
  4796. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  4797. const QVariant&value,int)
  4798. {
  4799. if(orientation==Qt::Horizontal)
  4800. {
  4801. if(hData->size()<section+1)
  4802. {
  4803. for(int i= hData->size();i<section+1;i++)
  4804. {
  4805. if(colcount<i)
  4806. {
  4807. beginInsertColumns(QModelIndex(),i,i);
  4808. }
  4809. hData->append(QString());
  4810. if(colcount<i)
  4811. {
  4812. endInsertColumns();
  4813. }
  4814. }
  4815. }
  4816. hData->replace(section,value.toString());
  4817. emit headerDataChanged(orientation,section,section);
  4818. if(colcount<section+1)
  4819. {
  4820. colcount= section+1;
  4821. }
  4822. return true;
  4823. }
  4824. return false;
  4825. }
  4826. /*:399*//*400:*/
  4827. #line 9508 "./typica.w"
  4828. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  4829. {
  4830. beginResetModel();
  4831. unit= scale;
  4832. endResetModel();
  4833. }
  4834. Units::Unit MeasurementModel::displayUnits()
  4835. {
  4836. return unit;
  4837. }
  4838. /*:400*//*401:*/
  4839. #line 9534 "./typica.w"
  4840. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  4841. {
  4842. /*392:*/
  4843. #line 9349 "./typica.w"
  4844. bool valid= false;
  4845. if(index.isValid())
  4846. {
  4847. if(index.row()<entries->size())
  4848. {
  4849. if(index.column()<colcount)
  4850. {
  4851. valid= true;
  4852. }
  4853. }
  4854. }
  4855. /*:392*/
  4856. #line 9537 "./typica.w"
  4857. if(!valid)
  4858. {
  4859. return QVariant();
  4860. }
  4861. MeasurementList*row= entries->at(index.row());
  4862. if(role==Qt::UserRole)
  4863. {
  4864. return QVariant(row->at(index.column()));
  4865. }
  4866. if(role==Qt::DisplayRole||role==Qt::EditRole)
  4867. {
  4868. if(index.column()> row->size())
  4869. {
  4870. return QVariant();
  4871. }
  4872. else
  4873. {
  4874. if(index.column()==0)
  4875. {
  4876. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  4877. }
  4878. else if(lastTemperature->contains(index.column()))
  4879. {
  4880. QVariantMap v= row->at(index.column()).toMap();
  4881. if(!v.contains("measurement"))
  4882. {
  4883. return QVariant();
  4884. }
  4885. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  4886. {
  4887. return v.value("measurement");
  4888. }
  4889. else
  4890. {
  4891. if(v.contains("relative"))
  4892. {
  4893. if(v.value("relative").toBool())
  4894. {
  4895. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  4896. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  4897. }
  4898. }
  4899. return QVariant(QString("%1").
  4900. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  4901. (Units::Unit)(v.value("unit").toInt()),unit)));
  4902. }
  4903. }
  4904. return QVariant(row->at(index.column()).toString());
  4905. }
  4906. }
  4907. return QVariant();
  4908. }
  4909. /*:401*//*402:*/
  4910. #line 9593 "./typica.w"
  4911. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  4912. int role)const
  4913. {
  4914. if(orientation==Qt::Horizontal)
  4915. {
  4916. if(role==Qt::DisplayRole)
  4917. {
  4918. if(section<hData->size())
  4919. {
  4920. return QVariant(hData->at(section));
  4921. }
  4922. }
  4923. }
  4924. return QVariant();
  4925. }
  4926. /*:402*//*403:*/
  4927. #line 9620 "./typica.w"
  4928. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  4929. {
  4930. /*392:*/
  4931. #line 9349 "./typica.w"
  4932. bool valid= false;
  4933. if(index.isValid())
  4934. {
  4935. if(index.row()<entries->size())
  4936. {
  4937. if(index.column()<colcount)
  4938. {
  4939. valid= true;
  4940. }
  4941. }
  4942. }
  4943. /*:392*/
  4944. #line 9623 "./typica.w"
  4945. if(valid)
  4946. {
  4947. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  4948. }
  4949. return 0;
  4950. }
  4951. /*:403*//*404:*/
  4952. #line 9635 "./typica.w"
  4953. QModelIndex MeasurementModel::index(int row,int column,
  4954. const QModelIndex&parent)const
  4955. {
  4956. if(parent==QModelIndex())
  4957. {
  4958. if(row<entries->size()&&entries->isEmpty()==false)
  4959. {
  4960. if(column<entries->at(row)->size())
  4961. {
  4962. return createIndex(row,column);
  4963. }
  4964. }
  4965. }
  4966. return QModelIndex();
  4967. }
  4968. /*:404*/
  4969. #line 548 "./typica.w"
  4970. /*406:*/
  4971. #line 9686 "./typica.w"
  4972. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  4973. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  4974. {
  4975. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  4976. }
  4977. /*:406*//*407:*/
  4978. #line 9701 "./typica.w"
  4979. void AnnotationButton::annotate()
  4980. {
  4981. if(note.contains("%1"))
  4982. {
  4983. count++;
  4984. emit annotation(note.arg(count),tc,ac);
  4985. }
  4986. else
  4987. {
  4988. emit annotation(note,tc,ac);
  4989. }
  4990. }
  4991. /*:407*//*408:*/
  4992. #line 9719 "./typica.w"
  4993. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  4994. {
  4995. tc= tempcolumn;
  4996. }
  4997. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  4998. {
  4999. ac= annotationcolumn;
  5000. }
  5001. void AnnotationButton::setAnnotation(const QString&annotation)
  5002. {
  5003. note= annotation;
  5004. }
  5005. /*:408*//*409:*/
  5006. #line 9738 "./typica.w"
  5007. void AnnotationButton::resetCount()
  5008. {
  5009. count= 0;
  5010. }
  5011. /*:409*/
  5012. #line 549 "./typica.w"
  5013. /*414:*/
  5014. #line 9821 "./typica.w"
  5015. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5016. const QString&postt,
  5017. QWidget*parent)
  5018. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5019. {
  5020. resetChange();
  5021. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5022. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5023. }
  5024. /*:414*//*415:*/
  5025. #line 9838 "./typica.w"
  5026. void AnnotationSpinBox::resetChange()
  5027. {
  5028. change= true;
  5029. }
  5030. /*:415*//*416:*/
  5031. #line 9849 "./typica.w"
  5032. void AnnotationSpinBox::annotate()
  5033. {
  5034. if(change)
  5035. {
  5036. change= false;
  5037. emit annotation(QString("%1%2%3").arg(pretext).
  5038. arg(value()).arg(posttext),tc,ac);
  5039. }
  5040. }
  5041. /*:416*//*417:*/
  5042. #line 9862 "./typica.w"
  5043. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5044. {
  5045. tc= tempcolumn;
  5046. }
  5047. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5048. {
  5049. ac= annotationcolumn;
  5050. }
  5051. void AnnotationSpinBox::setPretext(const QString&pret)
  5052. {
  5053. pretext= pret;
  5054. }
  5055. void AnnotationSpinBox::setPosttext(const QString&postt)
  5056. {
  5057. posttext= postt;
  5058. }
  5059. /*:417*/
  5060. #line 550 "./typica.w"
  5061. /*424:*/
  5062. #line 10030 "./typica.w"
  5063. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5064. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5065. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5066. stopAction(new QAction(tr("Stop"),NULL)),
  5067. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5068. relative(QTime::currentTime()),base(QTime(0,0,0))
  5069. {
  5070. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5071. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5072. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5073. clock.setInterval(500);
  5074. clock.setSingleShot(false);
  5075. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5076. setSegmentStyle(Filled);
  5077. updateDisplay();
  5078. }
  5079. /*:424*//*425:*/
  5080. #line 10051 "./typica.w"
  5081. void TimerDisplay::updateTime()
  5082. {
  5083. QTime time;
  5084. int cseconds= 0;
  5085. int oseconds= 0;
  5086. int r= 0;
  5087. QTime nt= QTime(0,0,0);
  5088. int n= 0;
  5089. int bseconds= 0;
  5090. switch(m)
  5091. {
  5092. case TimerDisplay::CountUp:
  5093. /*426:*/
  5094. #line 10083 "./typica.w"
  5095. /*427:*/
  5096. #line 10096 "./typica.w"
  5097. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5098. time= QTime::currentTime();
  5099. cseconds= TIMETOINT(time);
  5100. oseconds= TIMETOINT(relative);
  5101. r= cseconds-oseconds;
  5102. /*:427*/
  5103. #line 10084 "./typica.w"
  5104. nt= nt.addSecs(r);
  5105. if(nt!=s)
  5106. {
  5107. s= nt;
  5108. emit valueChanged(s);
  5109. }
  5110. /*:426*/
  5111. #line 10064 "./typica.w"
  5112. ;
  5113. break;
  5114. case TimerDisplay::CountDown:
  5115. /*428:*/
  5116. #line 10108 "./typica.w"
  5117. if(s> QTime(0,0,0))
  5118. {
  5119. /*427:*/
  5120. #line 10096 "./typica.w"
  5121. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5122. time= QTime::currentTime();
  5123. cseconds= TIMETOINT(time);
  5124. oseconds= TIMETOINT(relative);
  5125. r= cseconds-oseconds;
  5126. /*:427*/
  5127. #line 10111 "./typica.w"
  5128. bseconds= TIMETOINT(base);
  5129. n= bseconds-r;
  5130. nt= nt.addSecs(n);
  5131. if(nt!=s)
  5132. {
  5133. s= nt;
  5134. emit valueChanged(s);
  5135. }
  5136. }
  5137. /*:428*/
  5138. #line 10067 "./typica.w"
  5139. ;
  5140. break;
  5141. case TimerDisplay::Clock:
  5142. /*429:*/
  5143. #line 10125 "./typica.w"
  5144. time= QTime::currentTime();
  5145. if(time!=s)
  5146. {
  5147. s= time;
  5148. emit valueChanged(s);
  5149. }
  5150. /*:429*/
  5151. #line 10070 "./typica.w"
  5152. ;
  5153. break;
  5154. default:
  5155. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5156. break;
  5157. }
  5158. updateDisplay();
  5159. }
  5160. /*:425*//*430:*/
  5161. #line 10137 "./typica.w"
  5162. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5163. void TimerDisplay::startTimer()
  5164. {
  5165. if(!running)
  5166. {
  5167. relative= QTime::currentTime();
  5168. if(ar)
  5169. {
  5170. reset();
  5171. }
  5172. else
  5173. {
  5174. relative= TIMESUBTRACT(relative,s);
  5175. }
  5176. if(m==Clock)
  5177. {
  5178. updateTime();
  5179. }
  5180. base= s;
  5181. clock.start();
  5182. running= true;
  5183. emit runStateChanged(true);
  5184. }
  5185. }
  5186. /*:430*//*431:*/
  5187. #line 10167 "./typica.w"
  5188. void TimerDisplay::stopTimer()
  5189. {
  5190. if(running)
  5191. {
  5192. clock.stop();
  5193. running= false;
  5194. emit runStateChanged(false);
  5195. }
  5196. }
  5197. /*:431*//*432:*/
  5198. #line 10180 "./typica.w"
  5199. TimerDisplay::~TimerDisplay()
  5200. {
  5201. clock.stop();
  5202. }
  5203. /*:432*//*433:*/
  5204. #line 10189 "./typica.w"
  5205. void TimerDisplay::setCountUpMode()
  5206. {
  5207. m= TimerDisplay::CountUp;
  5208. }
  5209. void TimerDisplay::setCountDownMode()
  5210. {
  5211. m= TimerDisplay::CountDown;
  5212. }
  5213. void TimerDisplay::setClockMode()
  5214. {
  5215. m= TimerDisplay::Clock;
  5216. }
  5217. /*:433*//*434:*/
  5218. #line 10207 "./typica.w"
  5219. QString TimerDisplay::value()
  5220. {
  5221. return s.toString(f);
  5222. }
  5223. QTime TimerDisplay::seconds()
  5224. {
  5225. return s;
  5226. }
  5227. TimerDisplay::TimerMode TimerDisplay::mode()
  5228. {
  5229. return m;
  5230. }
  5231. bool TimerDisplay::isRunning()
  5232. {
  5233. return running;
  5234. }
  5235. QTime TimerDisplay::resetValue()
  5236. {
  5237. return r;
  5238. }
  5239. QString TimerDisplay::displayFormat()
  5240. {
  5241. return f;
  5242. }
  5243. bool TimerDisplay::autoReset()
  5244. {
  5245. return ar;
  5246. }
  5247. /*:434*//*435:*/
  5248. #line 10245 "./typica.w"
  5249. void TimerDisplay::setTimer(QTime value)
  5250. {
  5251. if(value.isValid())
  5252. {
  5253. s= value;
  5254. updateDisplay();
  5255. emit valueChanged(value);
  5256. }
  5257. }
  5258. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5259. {
  5260. m= mode;
  5261. }
  5262. void TimerDisplay::setResetValue(QTime value)
  5263. {
  5264. r= value;
  5265. }
  5266. void TimerDisplay::setDisplayFormat(QString format)
  5267. {
  5268. f= format;
  5269. setNumDigits(format.length());
  5270. }
  5271. void TimerDisplay::setAutoReset(bool reset)
  5272. {
  5273. ar= reset;
  5274. }
  5275. /*:435*//*436:*/
  5276. #line 10280 "./typica.w"
  5277. void TimerDisplay::copyTimer()
  5278. {
  5279. QApplication::clipboard()->setText(value());
  5280. }
  5281. /*:436*//*437:*/
  5282. #line 10289 "./typica.w"
  5283. void TimerDisplay::reset()
  5284. {
  5285. if(!running)
  5286. {
  5287. s= r;
  5288. updateDisplay();
  5289. }
  5290. }
  5291. /*:437*//*438:*/
  5292. #line 10302 "./typica.w"
  5293. void TimerDisplay::updateDisplay()
  5294. {
  5295. display(value());
  5296. }
  5297. /*:438*/
  5298. #line 551 "./typica.w"
  5299. /*444:*/
  5300. #line 10396 "./typica.w"
  5301. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5302. {
  5303. int x= rect.x();
  5304. int y= rect.y();
  5305. QLayoutItem*item;
  5306. if(orientation==Qt::Horizontal)
  5307. {
  5308. /*445:*/
  5309. #line 10420 "./typica.w"
  5310. foreach(item,itemList)
  5311. {
  5312. int nextX= x+item->sizeHint().width()+spacing();
  5313. int right= x+item->sizeHint().width();
  5314. if(item==itemList.last())
  5315. {
  5316. right= rect.right();
  5317. }
  5318. int bottom= rect.bottom();
  5319. if(!testOnly)
  5320. {
  5321. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5322. }
  5323. x= nextX;
  5324. }
  5325. /*:445*/
  5326. #line 10404 "./typica.w"
  5327. }
  5328. else
  5329. {
  5330. /*446:*/
  5331. #line 10439 "./typica.w"
  5332. foreach(item,itemList)
  5333. {
  5334. int nextY= y+item->sizeHint().height()+spacing();
  5335. int bottom= y+item->sizeHint().height();
  5336. if(item==itemList.last())
  5337. {
  5338. bottom= rect.bottom();
  5339. }
  5340. int right= rect.right();
  5341. if(!testOnly)
  5342. {
  5343. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5344. }
  5345. y= nextY;
  5346. }
  5347. /*:446*/
  5348. #line 10408 "./typica.w"
  5349. }
  5350. return y;
  5351. }
  5352. /*:444*//*447:*/
  5353. #line 10463 "./typica.w"
  5354. QSize PackLayout::minimumSize()const
  5355. {
  5356. QSize size;
  5357. QLayoutItem*item;
  5358. foreach(item,itemList)
  5359. {
  5360. if(orientation==Qt::Horizontal)
  5361. {
  5362. size+= QSize(item->minimumSize().width(),0);
  5363. if(size.height()<item->minimumSize().height())
  5364. {
  5365. size.setHeight(item->minimumSize().height());
  5366. }
  5367. }
  5368. else
  5369. {
  5370. size+= QSize(0,item->minimumSize().height());
  5371. if(size.width()<item->minimumSize().width())
  5372. {
  5373. size.setWidth(item->minimumSize().width());
  5374. }
  5375. }
  5376. }
  5377. size+= QSize(2*margin(),2*margin());
  5378. return size;
  5379. }
  5380. /*:447*//*448:*/
  5381. #line 10495 "./typica.w"
  5382. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5383. QLayout(parent)
  5384. {
  5385. setMargin(margin);
  5386. setSpacing(spacing);
  5387. setOrientation(Qt::Horizontal);
  5388. }
  5389. PackLayout::PackLayout(int spacing)
  5390. {
  5391. setSpacing(spacing);
  5392. setOrientation(Qt::Horizontal);
  5393. }
  5394. /*:448*//*449:*/
  5395. #line 10513 "./typica.w"
  5396. PackLayout::~PackLayout()
  5397. {
  5398. QLayoutItem*item;
  5399. while((item= takeAt(0)))
  5400. {
  5401. delete item;
  5402. }
  5403. }
  5404. /*:449*//*450:*/
  5405. #line 10527 "./typica.w"
  5406. QLayoutItem*PackLayout::takeAt(int index)
  5407. {
  5408. if(index>=0&&index<itemList.size())
  5409. {
  5410. return itemList.takeAt(index);
  5411. }
  5412. else
  5413. {
  5414. return NULL;
  5415. }
  5416. }
  5417. /*:450*//*451:*/
  5418. #line 10543 "./typica.w"
  5419. QLayoutItem*PackLayout::itemAt(int index)const
  5420. {
  5421. if(index>=0&&index<itemList.size())
  5422. {
  5423. return itemList.at(index);
  5424. }
  5425. else
  5426. {
  5427. return NULL;
  5428. }
  5429. }
  5430. /*:451*//*452:*/
  5431. #line 10566 "./typica.w"
  5432. void PackLayout::addItem(QLayoutItem*item)
  5433. {
  5434. itemList.append(item);
  5435. }
  5436. /*:452*//*453:*/
  5437. #line 10574 "./typica.w"
  5438. int PackLayout::count()const
  5439. {
  5440. return itemList.size();
  5441. }
  5442. /*:453*//*454:*/
  5443. #line 10586 "./typica.w"
  5444. Qt::Orientations PackLayout::expandingDirections()const
  5445. {
  5446. return Qt::Vertical|Qt::Horizontal;
  5447. }
  5448. bool PackLayout::hasHeightForWidth()const
  5449. {
  5450. return false;
  5451. }
  5452. int PackLayout::heightForWidth(int width)const
  5453. {
  5454. return doLayout(QRect(0,0,width,0),true);
  5455. }
  5456. void PackLayout::setGeometry(const QRect&rect)
  5457. {
  5458. QLayout::setGeometry(rect);
  5459. doLayout(rect,false);
  5460. }
  5461. QSize PackLayout::sizeHint()const
  5462. {
  5463. return minimumSize();
  5464. }
  5465. /*:454*//*455:*/
  5466. #line 10617 "./typica.w"
  5467. void PackLayout::setOrientation(Qt::Orientations direction)
  5468. {
  5469. orientation= direction;
  5470. doLayout(geometry(),false);
  5471. }
  5472. /*:455*/
  5473. #line 552 "./typica.w"
  5474. /*457:*/
  5475. #line 10656 "./typica.w"
  5476. SceneButton::SceneButton():QGraphicsScene()
  5477. {
  5478. }
  5479. SceneButton::~SceneButton()
  5480. {
  5481. }
  5482. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5483. {
  5484. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5485. }
  5486. /*:457*/
  5487. #line 553 "./typica.w"
  5488. /*459:*/
  5489. #line 10702 "./typica.w"
  5490. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5491. Qt::Orientations orientation,
  5492. QWidget*parent,Qt::WindowFlags f):
  5493. QWidget(parent,f),label(new QGraphicsView()),
  5494. scene(new SceneButton())
  5495. {
  5496. layout= new PackLayout(this);
  5497. layout->setOrientation(orientation);
  5498. /*460:*/
  5499. #line 10722 "./typica.w"
  5500. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5501. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5502. label->setFrameShape(QFrame::NoFrame);
  5503. label->setInteractive(true);
  5504. /*:460*/
  5505. #line 10711 "./typica.w"
  5506. /*461:*/
  5507. #line 10733 "./typica.w"
  5508. scene->setBackgroundBrush(Qt::cyan);
  5509. text= scene->addText(labeltext);
  5510. if(orientation==Qt::Horizontal)
  5511. {
  5512. text->rotate(270.0);
  5513. }
  5514. label->setScene(scene);
  5515. /*:461*/
  5516. #line 10712 "./typica.w"
  5517. /*462:*/
  5518. #line 10751 "./typica.w"
  5519. if(orientation==Qt::Horizontal)
  5520. {
  5521. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5522. }
  5523. else
  5524. {
  5525. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5526. }
  5527. label->centerOn(text);
  5528. /*:462*/
  5529. #line 10713 "./typica.w"
  5530. /*463:*/
  5531. #line 10766 "./typica.w"
  5532. layout->addWidget(label);
  5533. layout->addWidget(widget);
  5534. if(orientation==Qt::Horizontal)
  5535. {
  5536. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5537. widget->sizeHint().height());
  5538. }
  5539. else
  5540. {
  5541. setMinimumSize(widget->sizeHint().width(),
  5542. widget->sizeHint().height()+label->sizeHint().height());
  5543. }
  5544. /*:463*/
  5545. #line 10714 "./typica.w"
  5546. }
  5547. /*:459*//*464:*/
  5548. #line 10783 "./typica.w"
  5549. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5550. {
  5551. scene->setBackgroundBrush(background);
  5552. }
  5553. void WidgetDecorator::setTextColor(QColor color)
  5554. {
  5555. text->setDefaultTextColor(color);
  5556. }
  5557. /*:464*//*465:*/
  5558. #line 10796 "./typica.w"
  5559. WidgetDecorator::~WidgetDecorator()
  5560. {
  5561. }
  5562. /*:465*/
  5563. #line 554 "./typica.w"
  5564. /*470:*/
  5565. #line 10895 "./typica.w"
  5566. void LogEditWindow::addTheRows()
  5567. {
  5568. QTime s= startTime->time();
  5569. while(s<endTime->time())
  5570. {
  5571. model->newMeasurement(Measurement(0,s),1);
  5572. s= s.addSecs(interval->value());
  5573. }
  5574. model->newMeasurement(Measurement(0,endTime->time()),1);
  5575. }
  5576. /*:470*//*471:*/
  5577. #line 10909 "./typica.w"
  5578. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5579. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5580. addRowsLayout(new QHBoxLayout(NULL)),
  5581. startTimeLabel(new QLabel("Start Time")),
  5582. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5583. endTimeLabel(new QLabel("End Time")),
  5584. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5585. intervalLabel(new QLabel("Interval (seconds)")),
  5586. interval(new QSpinBox()),
  5587. addRows(new QPushButton("Add Rows")),
  5588. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5589. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5590. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5591. model(new MeasurementModel()),
  5592. log(new QTableView())
  5593. {
  5594. /*472:*/
  5595. #line 10946 "./typica.w"
  5596. QSettings settings;
  5597. resize(settings.value("logSize",QSize(620,400)).toSize());
  5598. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5599. /*:472*/
  5600. #line 10926 "./typica.w"
  5601. /*473:*/
  5602. #line 10959 "./typica.w"
  5603. mainLayout->setOrientation(Qt::Vertical);
  5604. addRowsLayout->addSpacing(10);
  5605. addRowsLayout->addWidget(startTimeLabel);
  5606. addRowsLayout->addWidget(startTime);
  5607. addRowsLayout->addSpacing(10);
  5608. startTime->setDisplayFormat("mm:ss");
  5609. addRowsLayout->addWidget(endTimeLabel);
  5610. addRowsLayout->addWidget(endTime);
  5611. addRowsLayout->addSpacing(10);
  5612. endTime->setDisplayFormat("mm:ss");
  5613. addRowsLayout->addWidget(intervalLabel);
  5614. addRowsLayout->addWidget(interval);
  5615. addRowsLayout->addSpacing(10);
  5616. interval->setRange(0,60);
  5617. interval->setValue(30);
  5618. addRowsLayout->addWidget(addRows);
  5619. addRowsLayout->addSpacing(10);
  5620. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5621. /*:473*/
  5622. #line 10927 "./typica.w"
  5623. /*474:*/
  5624. #line 10982 "./typica.w"
  5625. model->setHeaderData(0,Qt::Horizontal,"Time");
  5626. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5627. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5628. model->clear();
  5629. /*:474*/
  5630. #line 10928 "./typica.w"
  5631. /*475:*/
  5632. #line 10991 "./typica.w"
  5633. log->setModel(model);
  5634. log->setColumnWidth(0,100);
  5635. log->setColumnWidth(1,100);
  5636. log->setColumnWidth(2,100);
  5637. /*:475*/
  5638. #line 10929 "./typica.w"
  5639. mainLayout->addItem(addRowsLayout);
  5640. mainLayout->addWidget(log);
  5641. centralWidget->setLayout(mainLayout);
  5642. setCentralWidget(centralWidget);
  5643. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5644. fileMenu->addAction(openXml);
  5645. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5646. fileMenu->addAction(saveXml);
  5647. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5648. fileMenu->addAction(saveCsv);
  5649. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5650. }
  5651. /*:471*//*476:*/
  5652. #line 11002 "./typica.w"
  5653. void LogEditWindow::saveXML()
  5654. {
  5655. QSettings settings;
  5656. QString lastDir= settings.value("lastDirectory").toString();
  5657. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5658. lastDir,"",0);
  5659. QFile file(filename);
  5660. XMLOutput writer(model,&file,0);
  5661. writer.addTemperatureColumn("Temperature",1);
  5662. writer.addAnnotationColumn("Annotation",2);
  5663. if(writer.output())
  5664. {
  5665. QFileInfo info(filename);
  5666. QDir directory= info.dir();
  5667. lastDir= directory.path();
  5668. settings.setValue("lastDirectory",lastDir);
  5669. }
  5670. }
  5671. void LogEditWindow::saveCSV()
  5672. {
  5673. QSettings settings;
  5674. QString lastDir= settings.value("lastDirectory").toString();
  5675. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5676. lastDir,"",0);
  5677. QFile file(filename);
  5678. CSVOutput writer(model,&file,0);
  5679. writer.addTemperatureColumn("Temperature",1);
  5680. writer.addAnnotationColumn("Annotation",2);
  5681. if(writer.output())
  5682. {
  5683. QFileInfo info(filename);
  5684. QDir directory= info.dir();
  5685. lastDir= directory.path();
  5686. settings.setValue("lastDirectory",lastDir);
  5687. }
  5688. }
  5689. /*:476*//*477:*/
  5690. #line 11045 "./typica.w"
  5691. void LogEditWindow::openXML()
  5692. {
  5693. QSettings settings;
  5694. QString lastDir= settings.value("lastDirectory").toString();
  5695. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  5696. lastDir,"",0);
  5697. if(filename.isNull())
  5698. {
  5699. return;
  5700. }
  5701. QFile file(filename);
  5702. XMLInput reader(&file,1);
  5703. connect(&reader,SIGNAL(measure(Measurement,int)),
  5704. model,SLOT(newMeasurement(Measurement,int)));
  5705. connect(&reader,SIGNAL(annotation(QString,int,int)),
  5706. model,SLOT(newAnnotation(QString,int,int)));
  5707. if(reader.input())
  5708. {
  5709. QFileInfo info(filename);
  5710. setWindowTitle(QString(tr("%1 - %2")).
  5711. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  5712. QDir directory= info.dir();
  5713. lastDir= directory.path();
  5714. settings.setValue("lastDirectory",lastDir);
  5715. }
  5716. }
  5717. /*:477*//*478:*/
  5718. #line 11076 "./typica.w"
  5719. void LogEditWindow::closeEvent(QCloseEvent*event)
  5720. {
  5721. QSettings settings;
  5722. settings.setValue("logSize",size());
  5723. settings.setValue("logPos",pos());
  5724. event->accept();
  5725. }
  5726. /*:478*/
  5727. #line 555 "./typica.w"
  5728. /*484:*/
  5729. #line 11191 "./typica.w"
  5730. bool XMLOutput::output()
  5731. {
  5732. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5733. {
  5734. return false;
  5735. }
  5736. QXmlStreamWriter xmlout(out);
  5737. xmlout.writeStartDocument("1.0");
  5738. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  5739. xmlout.writeStartElement("roastlog");
  5740. /*485:*/
  5741. #line 11224 "./typica.w"
  5742. foreach(int c,temperatureColumns.keys())
  5743. {
  5744. xmlout.writeStartElement("tempseries");
  5745. xmlout.writeAttribute("name",temperatureColumns.value(c));
  5746. xmlout.writeEndElement();
  5747. }
  5748. foreach(int c,controlColumns.keys())
  5749. {
  5750. xmlout.writeStartElement("controlseries");
  5751. xmlout.writeAttribute("name",controlColumns.value(c));
  5752. xmlout.writeEndElement();
  5753. }
  5754. foreach(int c,annotationColumns.keys())
  5755. {
  5756. xmlout.writeStartElement("noteseries");
  5757. xmlout.writeAttribute("name",annotationColumns.value(c));
  5758. xmlout.writeEndElement();
  5759. }
  5760. /*:485*/
  5761. #line 11202 "./typica.w"
  5762. xmlout.writeStartElement("roast");
  5763. bool oresult;
  5764. for(int i= 0;i<data->rowCount();i++)
  5765. {
  5766. /*486:*/
  5767. #line 11249 "./typica.w"
  5768. oresult= false;
  5769. foreach(int c,temperatureColumns.keys())
  5770. {
  5771. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5772. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5773. {
  5774. oresult= true;
  5775. break;
  5776. }
  5777. }
  5778. foreach(int c,controlColumns.keys())
  5779. {
  5780. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5781. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5782. {
  5783. oresult= true;
  5784. break;
  5785. }
  5786. }
  5787. if(oresult==false)
  5788. {
  5789. foreach(int c,annotationColumns.keys())
  5790. {
  5791. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5792. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5793. isEmpty()))
  5794. {
  5795. oresult= true;
  5796. break;
  5797. }
  5798. }
  5799. }
  5800. /*:486*/
  5801. #line 11207 "./typica.w"
  5802. if(oresult)
  5803. {
  5804. /*487:*/
  5805. #line 11288 "./typica.w"
  5806. xmlout.writeStartElement("tuple");
  5807. xmlout.writeTextElement("time",data->data(data->index(i,time),
  5808. Qt::DisplayRole).toString());
  5809. foreach(int c,temperatureColumns.keys())
  5810. {
  5811. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5812. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5813. {
  5814. xmlout.writeStartElement("temperature");
  5815. xmlout.writeAttribute("series",temperatureColumns.value(c));
  5816. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  5817. {
  5818. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  5819. {
  5820. xmlout.writeAttribute("relative","true");
  5821. }
  5822. }
  5823. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5824. toString());
  5825. xmlout.writeEndElement();
  5826. }
  5827. }
  5828. foreach(int c,controlColumns.keys())
  5829. {
  5830. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5831. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5832. {
  5833. xmlout.writeStartElement("control");
  5834. xmlout.writeAttribute("series",controlColumns.value(c));
  5835. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  5836. xmlout.writeEndElement();
  5837. }
  5838. }
  5839. foreach(int c,annotationColumns.keys())
  5840. {
  5841. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5842. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5843. {
  5844. xmlout.writeStartElement("annotation");
  5845. xmlout.writeAttribute("series",annotationColumns.value(c));
  5846. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  5847. toString());
  5848. xmlout.writeEndElement();
  5849. }
  5850. }
  5851. xmlout.writeEndElement();
  5852. /*:487*/
  5853. #line 11210 "./typica.w"
  5854. }
  5855. }
  5856. xmlout.writeEndElement();
  5857. xmlout.writeEndElement();
  5858. xmlout.writeEndDocument();
  5859. out->close();
  5860. return true;
  5861. }
  5862. /*:484*//*488:*/
  5863. #line 11338 "./typica.w"
  5864. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  5865. :QObject(NULL),data(model),out(device),time(timec)
  5866. {
  5867. }
  5868. void XMLOutput::setModel(MeasurementModel*model)
  5869. {
  5870. data= model;
  5871. }
  5872. void XMLOutput::setTimeColumn(int column)
  5873. {
  5874. time= column;
  5875. }
  5876. void XMLOutput::setDevice(QIODevice*device)
  5877. {
  5878. out= device;
  5879. }
  5880. /*:488*//*489:*/
  5881. #line 11367 "./typica.w"
  5882. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  5883. {
  5884. temperatureColumns.insert(column,series);
  5885. }
  5886. void XMLOutput::addControlColumn(const QString&series,int column)
  5887. {
  5888. controlColumns.insert(column,series);
  5889. }
  5890. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  5891. {
  5892. annotationColumns.insert(column,series);
  5893. }
  5894. /*:489*/
  5895. #line 556 "./typica.w"
  5896. /*491:*/
  5897. #line 11424 "./typica.w"
  5898. bool XMLInput::input()
  5899. {
  5900. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  5901. {
  5902. return false;
  5903. }
  5904. QXmlStreamReader xmlin(in);
  5905. QMap<QString,int> temperatureColumns;
  5906. QMap<QString,int> annotationColumns;
  5907. int nextColumn= firstc;
  5908. /*492:*/
  5909. #line 11455 "./typica.w"
  5910. while(!xmlin.isDTD())
  5911. {
  5912. xmlin.readNext();
  5913. }
  5914. if(xmlin.isDTD())
  5915. {
  5916. if(xmlin.text()=="<!DOCTYPE roastlog>")
  5917. {
  5918. /*493:*/
  5919. #line 11477 "./typica.w"
  5920. emit newTemperatureColumn(firstc,"Bean");
  5921. emit newAnnotationColumn(firstc+1,"Note");
  5922. emit lastColumn(firstc+1);
  5923. /*:493*/
  5924. #line 11464 "./typica.w"
  5925. }
  5926. else
  5927. {
  5928. xmlin.readNext();
  5929. /*494:*/
  5930. #line 11486 "./typica.w"
  5931. while(xmlin.name()!="roast")
  5932. {
  5933. if(xmlin.isStartElement())
  5934. {
  5935. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  5936. {
  5937. temperatureColumns.insert(xmlin.attributes().value("name").
  5938. toString(),
  5939. nextColumn);
  5940. emit newTemperatureColumn(nextColumn,
  5941. xmlin.attributes().value("name").
  5942. toString());
  5943. nextColumn++;
  5944. }
  5945. else if(xmlin.name()=="noteseries")
  5946. {
  5947. annotationColumns.insert(xmlin.attributes().value("name").
  5948. toString(),nextColumn);
  5949. emit newAnnotationColumn(nextColumn,
  5950. xmlin.attributes().value("name").
  5951. toString());
  5952. nextColumn++;
  5953. }
  5954. }
  5955. xmlin.readNext();
  5956. }
  5957. emit lastColumn(nextColumn-1);
  5958. /*:494*/
  5959. #line 11469 "./typica.w"
  5960. }
  5961. }
  5962. /*:492*/
  5963. #line 11435 "./typica.w"
  5964. QTime timeval= QTime();
  5965. double tempval= 0;
  5966. QString noteval= QString();
  5967. int column;
  5968. int counter= 0;
  5969. while(!xmlin.atEnd())
  5970. {
  5971. /*495:*/
  5972. #line 11527 "./typica.w"
  5973. xmlin.readNext();
  5974. if(xmlin.isStartElement())
  5975. {
  5976. /*496:*/
  5977. #line 11553 "./typica.w"
  5978. if(xmlin.name()=="time")
  5979. {
  5980. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  5981. }
  5982. else if(xmlin.name()=="temperature")
  5983. {
  5984. column= xmlin.attributes().value("series").toString().isEmpty()?
  5985. firstc:temperatureColumns.value(xmlin.attributes().
  5986. value("series").toString());
  5987. bool relative= (xmlin.attributes().value("relative")=="true");
  5988. tempval= xmlin.readElementText().toDouble();
  5989. Measurement measurement(tempval,timeval);
  5990. if(relative)
  5991. {
  5992. measurement.insert("relative",true);
  5993. }
  5994. emit measure(measurement,column);
  5995. }
  5996. else if(xmlin.name()=="control")
  5997. {
  5998. column= xmlin.attributes().value("series").toString().isEmpty()?
  5999. firstc:temperatureColumns.value(xmlin.attributes().
  6000. value("series").toString());
  6001. tempval= xmlin.readElementText().toDouble();
  6002. Measurement measurement(tempval,timeval,Units::Unitless);
  6003. emit measure(measurement,column);
  6004. }
  6005. else if(xmlin.name()=="annotation")
  6006. {
  6007. column= xmlin.attributes().value("series").toString().isEmpty()?
  6008. firstc+1:annotationColumns.value(xmlin.attributes().
  6009. value("series").toString());
  6010. noteval= xmlin.readElementText();
  6011. if(!noteval.isEmpty())
  6012. {
  6013. emit annotation(noteval,firstc,column);
  6014. }
  6015. }
  6016. /*:496*/
  6017. #line 11531 "./typica.w"
  6018. }
  6019. counter++;
  6020. if(counter%100==0)
  6021. {
  6022. QCoreApplication::processEvents();
  6023. }
  6024. /*:495*/
  6025. #line 11443 "./typica.w"
  6026. }
  6027. return true;
  6028. }
  6029. /*:491*//*497:*/
  6030. #line 11595 "./typica.w"
  6031. XMLInput::XMLInput(QIODevice*input,int c):
  6032. firstc(c),in(input)
  6033. {
  6034. }
  6035. void XMLInput::setFirstColumn(int column)
  6036. {
  6037. firstc= column;
  6038. }
  6039. void XMLInput::setDevice(QIODevice*device)
  6040. {
  6041. in= device;
  6042. }
  6043. /*:497*/
  6044. #line 557 "./typica.w"
  6045. /*502:*/
  6046. #line 11686 "./typica.w"
  6047. bool CSVOutput::output()
  6048. {
  6049. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6050. {
  6051. return false;
  6052. }
  6053. QTextStream output(out);
  6054. /*503:*/
  6055. #line 11710 "./typica.w"
  6056. output<<"Time";
  6057. foreach(int c,temperatureColumns.keys())
  6058. {
  6059. output<<','<<temperatureColumns.value(c);
  6060. }
  6061. foreach(int c,controlColumns.keys())
  6062. {
  6063. output<<','<<controlColumns.value(c);
  6064. }
  6065. foreach(int c,annotationColumns.keys())
  6066. {
  6067. output<<','<<annotationColumns.value(c);
  6068. }
  6069. output<<'\n';
  6070. /*:503*/
  6071. #line 11694 "./typica.w"
  6072. bool oresult;
  6073. for(int i= 0;i<data->rowCount();i++)
  6074. {
  6075. /*486:*/
  6076. #line 11249 "./typica.w"
  6077. oresult= false;
  6078. foreach(int c,temperatureColumns.keys())
  6079. {
  6080. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6081. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6082. {
  6083. oresult= true;
  6084. break;
  6085. }
  6086. }
  6087. foreach(int c,controlColumns.keys())
  6088. {
  6089. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6090. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6091. {
  6092. oresult= true;
  6093. break;
  6094. }
  6095. }
  6096. if(oresult==false)
  6097. {
  6098. foreach(int c,annotationColumns.keys())
  6099. {
  6100. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6101. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6102. isEmpty()))
  6103. {
  6104. oresult= true;
  6105. break;
  6106. }
  6107. }
  6108. }
  6109. /*:486*/
  6110. #line 11698 "./typica.w"
  6111. if(oresult)
  6112. {
  6113. /*504:*/
  6114. #line 11735 "./typica.w"
  6115. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6116. foreach(int c,temperatureColumns.keys())
  6117. {
  6118. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6119. }
  6120. foreach(int c,controlColumns.keys())
  6121. {
  6122. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6123. }
  6124. foreach(int c,annotationColumns.keys())
  6125. {
  6126. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6127. }
  6128. output<<'\n';
  6129. /*:504*/
  6130. #line 11701 "./typica.w"
  6131. }
  6132. }
  6133. out->close();
  6134. return true;
  6135. }
  6136. /*:502*//*505:*/
  6137. #line 11754 "./typica.w"
  6138. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6139. data(model),out(device),time(timec)
  6140. {
  6141. }
  6142. void CSVOutput::setModel(MeasurementModel*model)
  6143. {
  6144. data= model;
  6145. }
  6146. void CSVOutput::setTimeColumn(int column)
  6147. {
  6148. time= column;
  6149. }
  6150. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6151. {
  6152. temperatureColumns.insert(column,series);
  6153. }
  6154. void CSVOutput::addControlColumn(const QString&series,int column)
  6155. {
  6156. controlColumns.insert(column,series);
  6157. }
  6158. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6159. {
  6160. annotationColumns.insert(column,series);
  6161. }
  6162. void CSVOutput::setDevice(QIODevice*device)
  6163. {
  6164. out= device;
  6165. }
  6166. #line 1 "./webview.w"
  6167. /*:505*/
  6168. #line 558 "./typica.w"
  6169. /*540:*/
  6170. #line 12015 "./typica.w"
  6171. QString SaltModel::arrayLiteral(int column,int role)const
  6172. {
  6173. QString literal= "'{";
  6174. for(int i= 0;i<rowCount();i++)
  6175. {
  6176. QString datum= data(index(i,column),role).toString();
  6177. if(!datum.isEmpty())
  6178. {
  6179. literal.append(datum);
  6180. literal.append(", ");
  6181. }
  6182. }
  6183. if(literal.size()> 2)
  6184. {
  6185. literal.chop(2);
  6186. }
  6187. literal.append("}'");
  6188. return literal;
  6189. }
  6190. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6191. {
  6192. QString literal= "'{";
  6193. for(int i= 0;i<rowCount();i++)
  6194. {
  6195. QString datum= data(index(i,column),role).toString();
  6196. if(!datum.isEmpty())
  6197. {
  6198. literal.append("\"");
  6199. literal.append(datum);
  6200. literal.append("\", ");
  6201. }
  6202. }
  6203. if(literal.size()> 2)
  6204. {
  6205. literal.chop(2);
  6206. }
  6207. literal.append("}'");
  6208. return literal;
  6209. }
  6210. /*:540*//*541:*/
  6211. #line 12059 "./typica.w"
  6212. QModelIndex SaltModel::parent(const QModelIndex&)const
  6213. {
  6214. return QModelIndex();
  6215. }
  6216. /*:541*//*542:*/
  6217. #line 12078 "./typica.w"
  6218. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6219. int role)
  6220. {
  6221. /*543:*/
  6222. #line 12109 "./typica.w"
  6223. bool valid= false;
  6224. if(index.isValid())
  6225. {
  6226. if(index.row()<modelData.size())
  6227. {
  6228. if(index.column()<colcount)
  6229. {
  6230. valid= true;
  6231. }
  6232. }
  6233. }
  6234. /*:543*/
  6235. #line 12082 "./typica.w"
  6236. if(!valid)
  6237. {
  6238. return false;
  6239. }
  6240. if(index.row()==modelData.size()-1)
  6241. {
  6242. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6243. /*544:*/
  6244. #line 12125 "./typica.w"
  6245. QList<QMap<int,QVariant> > newRow;
  6246. QMap<int,QVariant> defaults;
  6247. for(int i= 0;i<colcount;i++)
  6248. {
  6249. newRow.append(defaults);
  6250. }
  6251. modelData.append(newRow);
  6252. /*:544*/
  6253. #line 12090 "./typica.w"
  6254. endInsertRows();
  6255. }
  6256. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6257. QMap<int,QVariant> cell= row.at(index.column());
  6258. cell.insert(role,value);
  6259. if(role==Qt::EditRole)
  6260. {
  6261. cell.insert(Qt::DisplayRole,value);
  6262. }
  6263. row.replace(index.column(),cell);
  6264. modelData.replace(index.row(),row);
  6265. emit dataChanged(index,index);
  6266. return true;
  6267. }
  6268. /*:542*//*545:*/
  6269. #line 12136 "./typica.w"
  6270. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6271. {
  6272. for(int i= 0;i<columns;i++)
  6273. {
  6274. hData<<"";
  6275. }
  6276. /*544:*/
  6277. #line 12125 "./typica.w"
  6278. QList<QMap<int,QVariant> > newRow;
  6279. QMap<int,QVariant> defaults;
  6280. for(int i= 0;i<colcount;i++)
  6281. {
  6282. newRow.append(defaults);
  6283. }
  6284. modelData.append(newRow);
  6285. /*:544*/
  6286. #line 12143 "./typica.w"
  6287. }
  6288. /*:545*//*546:*/
  6289. #line 12148 "./typica.w"
  6290. SaltModel::~SaltModel()
  6291. {
  6292. }
  6293. /*:546*//*547:*/
  6294. #line 12158 "./typica.w"
  6295. int SaltModel::rowCount(const QModelIndex&parent)const
  6296. {
  6297. return(parent==QModelIndex()?modelData.size():0);
  6298. }
  6299. int SaltModel::columnCount(const QModelIndex&parent)const
  6300. {
  6301. return(parent==QModelIndex()?colcount:0);
  6302. }
  6303. /*:547*//*548:*/
  6304. #line 12171 "./typica.w"
  6305. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6306. const QVariant&value,int)
  6307. {
  6308. if(orientation==Qt::Horizontal&&section<colcount)
  6309. {
  6310. hData.replace(section,value.toString());
  6311. emit headerDataChanged(orientation,section,section);
  6312. return true;
  6313. }
  6314. return false;
  6315. }
  6316. /*:548*//*549:*/
  6317. #line 12186 "./typica.w"
  6318. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6319. {
  6320. /*543:*/
  6321. #line 12109 "./typica.w"
  6322. bool valid= false;
  6323. if(index.isValid())
  6324. {
  6325. if(index.row()<modelData.size())
  6326. {
  6327. if(index.column()<colcount)
  6328. {
  6329. valid= true;
  6330. }
  6331. }
  6332. }
  6333. /*:543*/
  6334. #line 12189 "./typica.w"
  6335. if(!valid)
  6336. {
  6337. return QVariant();
  6338. }
  6339. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6340. QMap<int,QVariant> cell= row.at(index.column());
  6341. return cell.value(role,QVariant());
  6342. }
  6343. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6344. int role)const
  6345. {
  6346. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6347. section<colcount)
  6348. {
  6349. return QVariant(hData.at(section));
  6350. }
  6351. return QVariant();
  6352. }
  6353. /*:549*//*550:*/
  6354. #line 12213 "./typica.w"
  6355. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6356. {
  6357. /*543:*/
  6358. #line 12109 "./typica.w"
  6359. bool valid= false;
  6360. if(index.isValid())
  6361. {
  6362. if(index.row()<modelData.size())
  6363. {
  6364. if(index.column()<colcount)
  6365. {
  6366. valid= true;
  6367. }
  6368. }
  6369. }
  6370. /*:543*/
  6371. #line 12216 "./typica.w"
  6372. if(valid)
  6373. {
  6374. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6375. }
  6376. return 0;
  6377. }
  6378. /*:550*//*551:*/
  6379. #line 12227 "./typica.w"
  6380. QModelIndex SaltModel::index(int row,int column,
  6381. const QModelIndex&parent)const
  6382. {
  6383. if(parent==QModelIndex())
  6384. {
  6385. if(row<modelData.size()&&column<colcount)
  6386. {
  6387. return createIndex(row,column);
  6388. }
  6389. }
  6390. return QModelIndex();
  6391. }
  6392. /*:551*//*552:*/
  6393. #line 12245 "./typica.w"
  6394. void SaltModel::clear()
  6395. {
  6396. beginResetModel();
  6397. modelData.clear();
  6398. /*544:*/
  6399. #line 12125 "./typica.w"
  6400. QList<QMap<int,QVariant> > newRow;
  6401. QMap<int,QVariant> defaults;
  6402. for(int i= 0;i<colcount;i++)
  6403. {
  6404. newRow.append(defaults);
  6405. }
  6406. modelData.append(newRow);
  6407. /*:544*/
  6408. #line 12250 "./typica.w"
  6409. endResetModel();
  6410. }
  6411. /*:552*//*553:*/
  6412. #line 12259 "./typica.w"
  6413. bool SaltModel::removeRows(int row,int count,
  6414. const QModelIndex&parent)
  6415. {
  6416. if(parent==QModelIndex())
  6417. {
  6418. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6419. {
  6420. beginRemoveRows(parent,row,row+count-1);
  6421. for(int i= 0;i<count;i++)
  6422. {
  6423. modelData.removeAt(row);
  6424. }
  6425. endRemoveRows();
  6426. if(modelData.size()==0)
  6427. {
  6428. beginInsertRows(parent,0,0);
  6429. /*544:*/
  6430. #line 12125 "./typica.w"
  6431. QList<QMap<int,QVariant> > newRow;
  6432. QMap<int,QVariant> defaults;
  6433. for(int i= 0;i<colcount;i++)
  6434. {
  6435. newRow.append(defaults);
  6436. }
  6437. modelData.append(newRow);
  6438. /*:544*/
  6439. #line 12276 "./typica.w"
  6440. endInsertRows();
  6441. }
  6442. return true;
  6443. }
  6444. }
  6445. return false;
  6446. }
  6447. /*:553*//*554:*/
  6448. #line 12290 "./typica.w"
  6449. int SaltModel::findData(const QVariant&value,int column,int role)
  6450. {
  6451. for(int i= 0;i<modelData.size();i++)
  6452. {
  6453. if(modelData.at(i).size()> column)
  6454. {
  6455. if(modelData.at(i).at(column).contains(role))
  6456. {
  6457. if(modelData.at(i).at(column).value(role)==value)
  6458. {
  6459. return i;
  6460. }
  6461. }
  6462. }
  6463. }
  6464. return-1;
  6465. }
  6466. /*:554*/
  6467. #line 559 "./typica.w"
  6468. /*556:*/
  6469. #line 12354 "./typica.w"
  6470. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6471. {
  6472. SqlComboBox*widget= new SqlComboBox();
  6473. widget->setParent(parent);
  6474. for(int i= 0;i<count();i++)
  6475. {
  6476. widget->addItem(itemText(i),itemData(i));
  6477. }
  6478. return widget;
  6479. }
  6480. /*:556*//*557:*/
  6481. #line 12371 "./typica.w"
  6482. void SqlComboBox::showData(bool show)
  6483. {
  6484. dataColumnShown= show;
  6485. }
  6486. /*:557*//*558:*/
  6487. #line 12385 "./typica.w"
  6488. void SqlComboBox::addNullOption()
  6489. {
  6490. addItem(specialNullText,specialNullData);
  6491. }
  6492. void SqlComboBox::setNullText(QString nullText)
  6493. {
  6494. specialNullText= nullText;
  6495. }
  6496. void SqlComboBox::setNullData(QVariant nullData)
  6497. {
  6498. specialNullData= nullData;
  6499. }
  6500. /*:558*//*559:*/
  6501. #line 12408 "./typica.w"
  6502. void SqlComboBox::setDataColumn(int column)
  6503. {
  6504. dataColumn= column;
  6505. }
  6506. void SqlComboBox::setDisplayColumn(int column)
  6507. {
  6508. displayColumn= column;
  6509. }
  6510. /*:559*//*560:*/
  6511. #line 12422 "./typica.w"
  6512. void SqlComboBox::addSqlOptions(QString query)
  6513. {
  6514. SqlQueryConnection h;
  6515. QSqlQuery*dbquery= h.operator->();
  6516. if(!dbquery->exec(query))
  6517. {
  6518. QSqlError error= dbquery->lastError();
  6519. qDebug()<<error.databaseText();
  6520. qDebug()<<error.driverText();
  6521. qDebug()<<error.text();
  6522. qDebug()<<dbquery->lastQuery();
  6523. }
  6524. while(dbquery->next())
  6525. {
  6526. QString displayValue(dbquery->value(displayColumn).toString());
  6527. QString dataValue(dbquery->value(dataColumn).toString());
  6528. if(dataColumnShown)
  6529. {
  6530. displayValue.append(QString(" (%1)").arg(dataValue));
  6531. }
  6532. addItem(displayValue,dataValue);
  6533. }
  6534. }
  6535. /*:560*//*561:*/
  6536. #line 12458 "./typica.w"
  6537. SqlComboBox::SqlComboBox():
  6538. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6539. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6540. {
  6541. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6542. }
  6543. SqlComboBox::~SqlComboBox()
  6544. {
  6545. }
  6546. /*:561*/
  6547. #line 560 "./typica.w"
  6548. /*563:*/
  6549. #line 12497 "./typica.w"
  6550. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6551. {
  6552. delegate= widget;
  6553. }
  6554. /*:563*//*564:*/
  6555. #line 12506 "./typica.w"
  6556. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6557. const QStyleOptionViewItem&,
  6558. const QModelIndex&)const
  6559. {
  6560. return delegate->clone(parent);
  6561. }
  6562. /*:564*//*565:*/
  6563. #line 12517 "./typica.w"
  6564. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6565. const QModelIndex&index)const
  6566. {
  6567. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6568. self->setCurrentIndex(self->findData(
  6569. index.model()->data(index,
  6570. Qt::UserRole).toString()));
  6571. }
  6572. /*:565*//*566:*/
  6573. #line 12530 "./typica.w"
  6574. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6575. QAbstractItemModel*model,
  6576. const QModelIndex&index)const
  6577. {
  6578. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6579. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6580. Qt::UserRole);
  6581. model->setData(index,self->currentText(),Qt::DisplayRole);
  6582. }
  6583. /*:566*//*567:*/
  6584. #line 12543 "./typica.w"
  6585. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6586. const QStyleOptionViewItem&option,
  6587. const QModelIndex&)const
  6588. {
  6589. editor->setGeometry(option.rect);
  6590. }
  6591. /*:567*//*568:*/
  6592. #line 12554 "./typica.w"
  6593. QSize SqlComboBoxDelegate::sizeHint()const
  6594. {
  6595. return delegate->sizeHint();
  6596. }
  6597. /*:568*//*569:*/
  6598. #line 12562 "./typica.w"
  6599. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6600. :QItemDelegate(parent)
  6601. {
  6602. }
  6603. /*:569*/
  6604. #line 561 "./typica.w"
  6605. /*532:*/
  6606. #line 11824 "./typica.w"
  6607. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6608. {
  6609. /*533:*/
  6610. #line 11839 "./typica.w"
  6611. setOrganizationName("Wilson's Coffee & Tea");
  6612. setOrganizationDomain("wilsonscoffee.com");
  6613. setApplicationName(PROGRAM_NAME);
  6614. /*:533*/
  6615. #line 11827 "./typica.w"
  6616. /*534:*/
  6617. #line 11848 "./typica.w"
  6618. QTranslator base;
  6619. if(base.load(QString("qt_%1").arg(QLocale::system().name())))
  6620. {
  6621. installTranslator(&base);
  6622. }
  6623. QTranslator app;
  6624. if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
  6625. {
  6626. installTranslator(&app);
  6627. }
  6628. /*:534*/
  6629. #line 11828 "./typica.w"
  6630. /*252:*/
  6631. #line 123 "./measurement.w"
  6632. qRegisterMetaType<Measurement> ("Measurement");
  6633. /*:252*/
  6634. #line 11829 "./typica.w"
  6635. /*737:*/
  6636. #line 15737 "./typica.w"
  6637. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6638. tr("NI DAQmx Base"),
  6639. "nidaqmxbase",NULL);
  6640. topLevelNodeInserters.append(inserter);
  6641. /*:737*//*745:*/
  6642. #line 15968 "./typica.w"
  6643. #ifdef Q_OS_WIN32
  6644. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6645. topLevelNodeInserters.append(inserter);
  6646. #endif
  6647. /*:745*//*769:*/
  6648. #line 16931 "./typica.w"
  6649. #if 0
  6650. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6651. topLevelNodeInserters.append(inserter);
  6652. #endif
  6653. /*:769*//*813:*/
  6654. #line 18413 "./typica.w"
  6655. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6656. topLevelNodeInserters.append(inserter);
  6657. #line 1 "./unsupportedserial.w"
  6658. /*:813*//*823:*/
  6659. #line 272 "./unsupportedserial.w"
  6660. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  6661. "unsupporteddevice",NULL);
  6662. topLevelNodeInserters.append(inserter);
  6663. /*:823*//*909:*/
  6664. #line 1241 "./dataqsdk.w"
  6665. #ifdef Q_OS_WIN32
  6666. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  6667. "dataqsdk",NULL);
  6668. topLevelNodeInserters.append(inserter);
  6669. #endif
  6670. #line 18635 "./typica.w"
  6671. #line 1 "./scales.w"
  6672. /*:909*//*934:*/
  6673. #line 495 "./scales.w"
  6674. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  6675. topLevelNodeInserters.append(inserter);
  6676. #line 18637 "./typica.w"
  6677. #line 1 "./valueannotation.w"
  6678. /*:934*/
  6679. #line 11830 "./typica.w"
  6680. }
  6681. /*:532*//*536:*/
  6682. #line 11871 "./typica.w"
  6683. QDomDocument*Application::configuration()
  6684. {
  6685. return&conf;
  6686. }
  6687. /*:536*//*537:*/
  6688. #line 11880 "./typica.w"
  6689. QSqlDatabase Application::database()
  6690. {
  6691. QString connectionName;
  6692. QSqlDatabase connection=
  6693. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  6694. do
  6695. {
  6696. connectionName= QUuid::createUuid().toString();
  6697. }while(QSqlDatabase::connectionNames().contains(connectionName));
  6698. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  6699. }
  6700. /*:537*//*672:*/
  6701. #line 14340 "./typica.w"
  6702. void Application::saveDeviceConfiguration()
  6703. {
  6704. QSettings settings;
  6705. settings.setValue("DeviceConfiguration",
  6706. QVariant(deviceConfigurationDocument.toByteArray()));
  6707. }
  6708. /*:672*//*673:*/
  6709. #line 14352 "./typica.w"
  6710. QDomDocument Application::deviceConfiguration()
  6711. {
  6712. if(deviceConfigurationDocument.isNull())
  6713. {
  6714. /*674:*/
  6715. #line 14366 "./typica.w"
  6716. QSettings settings;
  6717. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  6718. QString etext;
  6719. int eline;
  6720. int ecol;
  6721. if(document.length()==0)
  6722. {
  6723. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  6724. /*675:*/
  6725. #line 14390 "./typica.w"
  6726. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6727. emptyDocument.open(QIODevice::ReadOnly);
  6728. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6729. &etext,&eline,&ecol))
  6730. {
  6731. /*676:*/
  6732. #line 14407 "./typica.w"
  6733. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6734. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6735. qDebug()<<etext;
  6736. /*:676*/
  6737. #line 14396 "./typica.w"
  6738. }
  6739. else
  6740. {
  6741. saveDeviceConfiguration();
  6742. }
  6743. /*:675*/
  6744. #line 14375 "./typica.w"
  6745. }
  6746. else
  6747. {
  6748. if(!deviceConfigurationDocument.setContent(document,false,
  6749. &etext,&eline,&ecol))
  6750. {
  6751. /*676:*/
  6752. #line 14407 "./typica.w"
  6753. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6754. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6755. qDebug()<<etext;
  6756. /*:676*/
  6757. #line 14382 "./typica.w"
  6758. /*675:*/
  6759. #line 14390 "./typica.w"
  6760. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  6761. emptyDocument.open(QIODevice::ReadOnly);
  6762. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  6763. &etext,&eline,&ecol))
  6764. {
  6765. /*676:*/
  6766. #line 14407 "./typica.w"
  6767. qDebug()<<QString(tr("An error occurred loading device configuration."));
  6768. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  6769. qDebug()<<etext;
  6770. /*:676*/
  6771. #line 14396 "./typica.w"
  6772. }
  6773. else
  6774. {
  6775. saveDeviceConfiguration();
  6776. }
  6777. /*:675*/
  6778. #line 14383 "./typica.w"
  6779. }
  6780. }
  6781. /*:674*/
  6782. #line 14357 "./typica.w"
  6783. }
  6784. return deviceConfigurationDocument;
  6785. }
  6786. /*:673*//*704:*/
  6787. #line 15008 "./typica.w"
  6788. void Application::registerDeviceConfigurationWidget(QString driver,
  6789. QMetaObject widget)
  6790. {
  6791. deviceConfigurationWidgets.insert(driver,widget);
  6792. }
  6793. /*:704*//*705:*/
  6794. #line 15024 "./typica.w"
  6795. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  6796. const QModelIndex&index)
  6797. {
  6798. QVariant nodeReference= index.data(Qt::UserRole);
  6799. QDomElement referenceElement= model->referenceElement(
  6800. model->data(index,Qt::UserRole).toString());
  6801. QMetaObject metaObject=
  6802. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  6803. QWidget::staticMetaObject);
  6804. QWidget*editor;
  6805. if(metaObject.className()==QWidget::staticMetaObject.className())
  6806. {
  6807. editor= NULL;
  6808. }
  6809. else
  6810. {
  6811. editor= qobject_cast<QWidget*> (
  6812. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  6813. Q_ARG(QModelIndex,index)));
  6814. }
  6815. return editor;
  6816. }
  6817. /*:705*/
  6818. #line 562 "./typica.w"
  6819. /*575:*/
  6820. #line 12683 "./typica.w"
  6821. SqlConnectionSetup::SqlConnectionSetup():
  6822. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  6823. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  6824. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  6825. cancelButton(new QPushButton(tr("Cancel"))),
  6826. connectButton(new QPushButton(tr("Connect")))
  6827. {
  6828. driver->addItem("PostgreSQL","QPSQL");
  6829. formLayout->addRow(tr("Database driver:"),driver);
  6830. formLayout->addRow(tr("Host name:"),hostname);
  6831. formLayout->addRow(tr("Database name:"),dbname);
  6832. formLayout->addRow(tr("User name:"),user);
  6833. password->setEchoMode(QLineEdit::Password);
  6834. formLayout->addRow(tr("Password:"),password);
  6835. layout->addLayout(formLayout);
  6836. buttons->addStretch(1);
  6837. buttons->addWidget(cancelButton);
  6838. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  6839. buttons->addWidget(connectButton);
  6840. layout->addLayout(buttons);
  6841. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  6842. setLayout(layout);
  6843. setModal(true);
  6844. }
  6845. SqlConnectionSetup::~SqlConnectionSetup()
  6846. {
  6847. }
  6848. /*:575*//*576:*/
  6849. #line 12717 "./typica.w"
  6850. void SqlConnectionSetup::testConnection()
  6851. {
  6852. QSqlDatabase database=
  6853. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  6854. toString());
  6855. database.setConnectOptions("application_name=Typica");
  6856. database.setHostName(hostname->text());
  6857. database.setDatabaseName(dbname->text());
  6858. database.setUserName(user->text());
  6859. database.setPassword(password->text());
  6860. if(database.open())
  6861. {
  6862. QSettings settings;
  6863. settings.setValue("database/exists","true");
  6864. settings.setValue("database/driver",
  6865. driver->itemData(driver->currentIndex()).toString());
  6866. settings.setValue("database/hostname",hostname->text());
  6867. settings.setValue("database/dbname",dbname->text());
  6868. settings.setValue("database/user",user->text());
  6869. settings.setValue("database/password",password->text());
  6870. database.close();
  6871. accept();
  6872. }
  6873. else
  6874. {
  6875. QMessageBox::information(this,tr("Database connection failed"),
  6876. tr("Failed to connect to database."));
  6877. }
  6878. }
  6879. /*:576*/
  6880. #line 563 "./typica.w"
  6881. /*580:*/
  6882. #line 12819 "./typica.w"
  6883. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  6884. {
  6885. setModel(new QSqlQueryModel);
  6886. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  6887. this,SLOT(openRow(QModelIndex)));
  6888. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  6889. this,SLOT(persistColumnResize(int,int,int)));
  6890. }
  6891. /*:580*//*581:*/
  6892. #line 12834 "./typica.w"
  6893. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  6894. {
  6895. /*582:*/
  6896. #line 12843 "./typica.w"
  6897. QSettings settings;
  6898. /*583:*/
  6899. #line 12856 "./typica.w"
  6900. QWidget*topLevelWidget= this;
  6901. while(topLevelWidget->parentWidget())
  6902. {
  6903. topLevelWidget= topLevelWidget->parentWidget();
  6904. }
  6905. /*:583*/
  6906. #line 12845 "./typica.w"
  6907. settings.setValue(QString("columnWidths/%1/%2/%3").
  6908. arg(topLevelWidget->objectName()).
  6909. arg(objectName()).arg(column),
  6910. QVariant(newsize));
  6911. /*:582*/
  6912. #line 12837 "./typica.w"
  6913. }
  6914. /*:581*//*584:*/
  6915. #line 12866 "./typica.w"
  6916. void SqlQueryView::showEvent(QShowEvent*event)
  6917. {
  6918. /*585:*/
  6919. #line 12876 "./typica.w"
  6920. QSettings settings;
  6921. /*583:*/
  6922. #line 12856 "./typica.w"
  6923. QWidget*topLevelWidget= this;
  6924. while(topLevelWidget->parentWidget())
  6925. {
  6926. topLevelWidget= topLevelWidget->parentWidget();
  6927. }
  6928. /*:583*/
  6929. #line 12878 "./typica.w"
  6930. QString baseKey=
  6931. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  6932. arg(objectName());
  6933. for(int i= 0;i<model()->columnCount();i++)
  6934. {
  6935. QString key= QString("%1/%2").arg(baseKey).arg(i);
  6936. if(settings.contains(key))
  6937. {
  6938. setColumnWidth(i,settings.value(key).toInt());
  6939. }
  6940. }
  6941. /*:585*/
  6942. #line 12869 "./typica.w"
  6943. event->accept();
  6944. }
  6945. /*:584*//*586:*/
  6946. #line 12893 "./typica.w"
  6947. void SqlQueryView::openRow(const QModelIndex&index)
  6948. {
  6949. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  6950. emit openEntryRow(index.row());
  6951. }
  6952. /*:586*//*587:*/
  6953. #line 12902 "./typica.w"
  6954. void SqlQueryView::setQuery(const QString&query)
  6955. {
  6956. QSqlDatabase database= AppInstance->database();
  6957. database.open();
  6958. QSqlQuery q(query,database);
  6959. ((QSqlQueryModel*)model())->setQuery(q);
  6960. database.close();
  6961. }
  6962. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  6963. const QVariant&value,int role)
  6964. {
  6965. return model()->setHeaderData(section,orientation,value,role);
  6966. }
  6967. /*:587*//*588:*/
  6968. #line 12920 "./typica.w"
  6969. QVariant SqlQueryView::data(int row,int column,int role)
  6970. {
  6971. return model()->data(model()->index(row,column),role);
  6972. }
  6973. /*:588*/
  6974. #line 564 "./typica.w"
  6975. /*140:*/
  6976. #line 3307 "./typica.w"
  6977. SqlQueryConnection::SqlQueryConnection(const QString&query)
  6978. {
  6979. QSqlDatabase database= AppInstance->database();
  6980. database.open();
  6981. q= new QSqlQuery(query,database);
  6982. connection= database.connectionName();
  6983. }
  6984. /*:140*//*141:*/
  6985. #line 3320 "./typica.w"
  6986. SqlQueryConnection::~SqlQueryConnection()
  6987. {
  6988. delete q;
  6989. {
  6990. QSqlDatabase database= QSqlDatabase::database(connection);
  6991. database.close();
  6992. }
  6993. QSqlDatabase::removeDatabase(connection);
  6994. }
  6995. /*:141*//*142:*/
  6996. #line 3334 "./typica.w"
  6997. QSqlQuery*SqlQueryConnection::operator->()const
  6998. {
  6999. return q;
  7000. }
  7001. /*:142*/
  7002. #line 565 "./typica.w"
  7003. /*607:*/
  7004. #line 13277 "./typica.w"
  7005. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7006. area(frame),configuration(description)
  7007. {
  7008. refresh();
  7009. }
  7010. ReportTable::~ReportTable()
  7011. {
  7012. }
  7013. /*:607*//*608:*/
  7014. #line 13293 "./typica.w"
  7015. void ReportTable::bind(QString placeholder,QVariant value)
  7016. {
  7017. bindings.insert(placeholder,value);
  7018. }
  7019. /*:608*//*609:*/
  7020. #line 13303 "./typica.w"
  7021. void ReportTable::refresh()
  7022. {
  7023. /*610:*/
  7024. #line 13324 "./typica.w"
  7025. QTextCursor cursor= area->firstCursorPosition();
  7026. while(cursor<area->lastCursorPosition())
  7027. {
  7028. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7029. }
  7030. cursor.removeSelectedText();
  7031. /*:610*/
  7032. #line 13306 "./typica.w"
  7033. int rows= 1;
  7034. int columns= 1;
  7035. int currentRow= 0;
  7036. QTextTable*table= cursor.insertTable(rows,columns);
  7037. /*611:*/
  7038. #line 13337 "./typica.w"
  7039. QTextTableFormat format= table->format();
  7040. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7041. if(configuration.hasAttribute("align"))
  7042. {
  7043. if(configuration.attribute("align")=="center")
  7044. {
  7045. format.setAlignment(Qt::AlignHCenter);
  7046. }
  7047. }
  7048. table->setFormat(format);
  7049. /*:611*/
  7050. #line 13311 "./typica.w"
  7051. /*612:*/
  7052. #line 13351 "./typica.w"
  7053. QDomNodeList children= configuration.childNodes();
  7054. for(int i= 0;i<children.count();i++)
  7055. {
  7056. QDomNode current;
  7057. QDomElement currentElement;
  7058. current= children.at(i);
  7059. if(current.isElement())
  7060. {
  7061. currentElement= current.toElement();
  7062. if(currentElement.tagName()=="query")
  7063. {
  7064. /*613:*/
  7065. #line 13378 "./typica.w"
  7066. SqlQueryConnection h;
  7067. QSqlQuery*query= h.operator->();
  7068. query->prepare(currentElement.text());
  7069. foreach(QString key,bindings.uniqueKeys())
  7070. {
  7071. if(currentElement.text().contains(key))
  7072. {
  7073. query->bindValue(key,bindings.value(key));
  7074. }
  7075. }
  7076. query->exec();
  7077. if(!query->next())
  7078. {
  7079. continue;
  7080. }
  7081. if(query->record().count()> columns)
  7082. {
  7083. table->appendColumns(query->record().count()-columns);
  7084. }
  7085. do
  7086. {
  7087. table->appendRows(1);
  7088. rows++;
  7089. currentRow++;
  7090. for(int j= 0;j<query->record().count();j++)
  7091. {
  7092. QTextTableCell cell= table->cellAt(currentRow,j);
  7093. cursor= cell.firstCursorPosition();
  7094. cursor.insertText(query->value(j).toString());
  7095. }
  7096. }while(query->next());
  7097. /*:613*/
  7098. #line 13363 "./typica.w"
  7099. }
  7100. else if(currentElement.tagName()=="row")
  7101. {
  7102. /*614:*/
  7103. #line 13418 "./typica.w"
  7104. table->appendRows(1);
  7105. currentRow++;
  7106. rows++;
  7107. QDomNodeList rowChildren= currentElement.childNodes();
  7108. int currentColumn= 0;
  7109. for(int j= 0;j<rowChildren.count();j++)
  7110. {
  7111. QDomNode node;
  7112. QDomElement nodeElement;
  7113. node= rowChildren.at(j);
  7114. if(node.isElement())
  7115. {
  7116. nodeElement= node.toElement();
  7117. if(nodeElement.tagName()=="cell")
  7118. {
  7119. if(currentColumn==columns)
  7120. {
  7121. table->appendColumns(1);
  7122. columns++;
  7123. }
  7124. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7125. cursor= cell.firstCursorPosition();
  7126. cursor.insertText(nodeElement.text());
  7127. currentColumn++;
  7128. }
  7129. }
  7130. }
  7131. /*:614*/
  7132. #line 13367 "./typica.w"
  7133. }
  7134. }
  7135. }
  7136. /*:612*/
  7137. #line 13312 "./typica.w"
  7138. if(rows> 1)
  7139. {
  7140. table->removeRows(0,1);
  7141. }
  7142. }
  7143. /*:609*/
  7144. #line 566 "./typica.w"
  7145. /*640:*/
  7146. #line 13522 "./typica.w"
  7147. FormArray::FormArray(QDomElement description):configuration(description),
  7148. maxwidth(-1),maxheight(-1)
  7149. {
  7150. setWidget(&itemContainer);
  7151. itemContainer.setLayout(&itemLayout);
  7152. }
  7153. /*:640*//*641:*/
  7154. #line 13539 "./typica.w"
  7155. void FormArray::addElements(int copies)
  7156. {
  7157. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7158. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7159. QWidget*widget;
  7160. for(int i= 0;i<copies;i++)
  7161. {
  7162. widget= new QWidget;
  7163. if(maxwidth> -1)
  7164. {
  7165. widget->setMaximumWidth(maxwidth);
  7166. }
  7167. if(maxheight> -1)
  7168. {
  7169. widget->setMaximumHeight(maxheight);
  7170. }
  7171. if(configuration.hasChildNodes())
  7172. {
  7173. widgetStack->push(widget);
  7174. populateWidget(configuration,widgetStack,layoutStack);
  7175. widgetStack->pop();
  7176. widget->setMinimumHeight(widget->sizeHint().height());
  7177. itemLayout.addWidget(widget);
  7178. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7179. {
  7180. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7181. }
  7182. else
  7183. {
  7184. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7185. +widget->sizeHint().height());
  7186. }
  7187. if(maxwidth> -1)
  7188. {
  7189. itemContainer.setMinimumWidth(maxwidth+50);
  7190. }
  7191. else
  7192. {
  7193. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7194. }
  7195. }
  7196. }
  7197. }
  7198. /*:641*//*642:*/
  7199. #line 13589 "./typica.w"
  7200. QWidget*FormArray::elementAt(int index)
  7201. {
  7202. if(index<itemLayout.count())
  7203. {
  7204. QLayoutItem*item= itemLayout.itemAt(index);
  7205. return item->widget();
  7206. }
  7207. else
  7208. {
  7209. return NULL;
  7210. }
  7211. }
  7212. /*:642*//*643:*/
  7213. #line 13606 "./typica.w"
  7214. void FormArray::removeAllElements()
  7215. {
  7216. while(itemLayout.count()> 0)
  7217. {
  7218. QLayoutItem*item;
  7219. item= itemLayout.itemAt(0);
  7220. item->widget()->hide();
  7221. itemLayout.removeWidget(item->widget());
  7222. }
  7223. itemContainer.setMinimumHeight(0);
  7224. }
  7225. /*:643*//*644:*/
  7226. #line 13622 "./typica.w"
  7227. int FormArray::elements()
  7228. {
  7229. return itemLayout.count();
  7230. }
  7231. /*:644*//*645:*/
  7232. #line 13633 "./typica.w"
  7233. void FormArray::setMaximumElementWidth(int width)
  7234. {
  7235. maxwidth= width;
  7236. }
  7237. void FormArray::setMaximumElementHeight(int height)
  7238. {
  7239. maxheight= height;
  7240. }
  7241. /*:645*/
  7242. #line 567 "./typica.w"
  7243. /*651:*/
  7244. #line 13764 "./typica.w"
  7245. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7246. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7247. {
  7248. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7249. QPointF(0,5);
  7250. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7251. QPointF(10,5);
  7252. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7253. QPointF(0,0);
  7254. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7255. initialBrush.setColor(QColor(170,170,255));
  7256. initialBrush.setStyle(Qt::SolidPattern);
  7257. finalBrush.setColor(Qt::blue);
  7258. finalBrush.setStyle(Qt::SolidPattern);
  7259. initialDecrement.setPolygon(left);
  7260. initialDecrement.setBrush(initialBrush);
  7261. initialDecrement.setPos(0,0);
  7262. scene.addItem(&initialDecrement);
  7263. initialIncrement.setPolygon(right);
  7264. initialIncrement.setBrush(initialBrush);
  7265. initialIncrement.setPos(122,0);
  7266. scene.addItem(&initialIncrement);
  7267. finalDecrement.setPolygon(left);
  7268. finalDecrement.setBrush(finalBrush);
  7269. finalDecrement.setPos(0,12);
  7270. scene.addItem(&finalDecrement);
  7271. finalIncrement.setPolygon(right);
  7272. finalIncrement.setBrush(finalBrush);
  7273. finalIncrement.setPos(122,12);
  7274. scene.addItem(&finalIncrement);
  7275. scalePath.moveTo(0,10);
  7276. scalePath.lineTo(100,10);
  7277. scalePath.moveTo(0,0);
  7278. scalePath.lineTo(0,20);
  7279. scalePath.moveTo(10,5);
  7280. scalePath.lineTo(10,15);
  7281. scalePath.moveTo(20,5);
  7282. scalePath.lineTo(20,15);
  7283. scalePath.moveTo(30,5);
  7284. scalePath.lineTo(30,15);
  7285. scalePath.moveTo(40,5);
  7286. scalePath.lineTo(40,15);
  7287. scalePath.moveTo(50,0);
  7288. scalePath.lineTo(50,20);
  7289. scalePath.moveTo(60,5);
  7290. scalePath.lineTo(60,15);
  7291. scalePath.moveTo(70,5);
  7292. scalePath.lineTo(70,15);
  7293. scalePath.moveTo(80,5);
  7294. scalePath.lineTo(80,15);
  7295. scalePath.moveTo(90,5);
  7296. scalePath.lineTo(90,15);
  7297. scalePath.moveTo(100,0);
  7298. scalePath.lineTo(100,20);
  7299. scaleLine.setPath(scalePath);
  7300. scaleLine.setPos(16,1);
  7301. scene.addItem(&scaleLine);
  7302. setScene(&scene);
  7303. initialIndicator.setPolygon(down);
  7304. initialIndicator.setBrush(initialBrush);
  7305. finalIndicator.setPolygon(up);
  7306. finalIndicator.setBrush(finalBrush);
  7307. setMinimumSize(sizeHint());
  7308. setMaximumSize(sizeHint());
  7309. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7310. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7311. setMinimumSize(sizeHint());
  7312. }
  7313. /*:651*//*652:*/
  7314. #line 13837 "./typica.w"
  7315. QSize ScaleControl::sizeHint()const
  7316. {
  7317. return QSize(140,30);
  7318. }
  7319. /*:652*//*653:*/
  7320. #line 13846 "./typica.w"
  7321. void ScaleControl::setInitialValue(double value)
  7322. {
  7323. if(value>=0&&value<=10)
  7324. {
  7325. nonScoredValue= value;
  7326. if(!initialSet)
  7327. {
  7328. scene.addItem(&initialIndicator);
  7329. }
  7330. initialSet= true;
  7331. initialIndicator.setPos(value*10+16,10);
  7332. emit initialChanged(value);
  7333. if(!finalSet)
  7334. {
  7335. setFinalValue(value);
  7336. }
  7337. }
  7338. }
  7339. void ScaleControl::setFinalValue(double value)
  7340. {
  7341. if(value>=0&&value<=10)
  7342. {
  7343. scoredValue= value;
  7344. if(!finalSet)
  7345. {
  7346. scene.addItem(&finalIndicator);
  7347. }
  7348. finalSet= true;
  7349. finalIndicator.setPos(value*10+16,11);
  7350. emit finalChanged(value);
  7351. }
  7352. }
  7353. /*:653*//*654:*/
  7354. #line 13883 "./typica.w"
  7355. double ScaleControl::initialValue(void)
  7356. {
  7357. return nonScoredValue;
  7358. }
  7359. double ScaleControl::finalValue(void)
  7360. {
  7361. return scoredValue;
  7362. }
  7363. /*:654*//*655:*/
  7364. #line 13904 "./typica.w"
  7365. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7366. {
  7367. /*656:*/
  7368. #line 13916 "./typica.w"
  7369. if(event->button()!=Qt::LeftButton)
  7370. {
  7371. event->ignore();
  7372. return;
  7373. }
  7374. /*:656*/
  7375. #line 13907 "./typica.w"
  7376. scaleDown= true;
  7377. event->accept();
  7378. }
  7379. /*:655*//*657:*/
  7380. #line 13927 "./typica.w"
  7381. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7382. {
  7383. /*656:*/
  7384. #line 13916 "./typica.w"
  7385. if(event->button()!=Qt::LeftButton)
  7386. {
  7387. event->ignore();
  7388. return;
  7389. }
  7390. /*:656*/
  7391. #line 13930 "./typica.w"
  7392. if(!scaleDown)
  7393. {
  7394. event->ignore();
  7395. return;
  7396. }
  7397. scaleDown= false;
  7398. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7399. /*658:*/
  7400. #line 13952 "./typica.w"
  7401. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7402. {
  7403. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7404. {
  7405. if(initialSet)
  7406. {
  7407. setInitialValue(nonScoredValue-0.05);
  7408. }
  7409. event->accept();
  7410. return;
  7411. }
  7412. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7413. {
  7414. if(finalSet)
  7415. {
  7416. setFinalValue(scoredValue-0.05);
  7417. event->accept();
  7418. return;
  7419. }
  7420. }
  7421. }
  7422. /*:658*/
  7423. #line 13938 "./typica.w"
  7424. /*659:*/
  7425. #line 13978 "./typica.w"
  7426. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7427. {
  7428. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7429. {
  7430. if(initialSet)
  7431. {
  7432. setInitialValue(nonScoredValue+0.05);
  7433. event->accept();
  7434. return;
  7435. }
  7436. }
  7437. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7438. {
  7439. if(finalSet)
  7440. {
  7441. setFinalValue(scoredValue+0.05);
  7442. event->accept();
  7443. return;
  7444. }
  7445. }
  7446. }
  7447. /*:659*/
  7448. #line 13939 "./typica.w"
  7449. /*660:*/
  7450. #line 14004 "./typica.w"
  7451. double relativeX= sceneCoordinate.x()-16;
  7452. if(initialSet)
  7453. {
  7454. if(relativeX>=0&&relativeX<=100)
  7455. {
  7456. setFinalValue(relativeX/10.0);
  7457. event->accept();
  7458. return;
  7459. }
  7460. }
  7461. else
  7462. {
  7463. if(relativeX>=0&&relativeX<=100)
  7464. {
  7465. setInitialValue(relativeX/10.0);
  7466. event->accept();
  7467. return;
  7468. }
  7469. }
  7470. /*:660*/
  7471. #line 13940 "./typica.w"
  7472. event->ignore();
  7473. return;
  7474. }
  7475. /*:657*/
  7476. #line 568 "./typica.w"
  7477. /*662:*/
  7478. #line 14070 "./typica.w"
  7479. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7480. valueSet(false),scaleDown(false)
  7481. {
  7482. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7483. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7484. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7485. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7486. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7487. theBrush.setColor(Qt::blue);
  7488. theBrush.setStyle(Qt::SolidPattern);
  7489. increment.setPolygon(up);
  7490. increment.setBrush(theBrush);
  7491. increment.setPos(0,0);
  7492. scene.addItem(&increment);
  7493. decrement.setPolygon(down);
  7494. decrement.setBrush(theBrush);
  7495. decrement.setPos(0,122);
  7496. scene.addItem(&decrement);
  7497. scalePath.moveTo(5,0);
  7498. scalePath.lineTo(5,100);
  7499. scalePath.moveTo(0,0);
  7500. scalePath.lineTo(10,0);
  7501. scalePath.moveTo(0,10);
  7502. scalePath.lineTo(10,10);
  7503. scalePath.moveTo(0,20);
  7504. scalePath.lineTo(10,20);
  7505. scalePath.moveTo(0,30);
  7506. scalePath.lineTo(10,30);
  7507. scalePath.moveTo(0,40);
  7508. scalePath.lineTo(10,40);
  7509. scalePath.moveTo(0,50);
  7510. scalePath.lineTo(10,50);
  7511. scalePath.moveTo(0,60);
  7512. scalePath.lineTo(10,60);
  7513. scalePath.moveTo(0,70);
  7514. scalePath.lineTo(10,70);
  7515. scalePath.moveTo(0,80);
  7516. scalePath.lineTo(10,80);
  7517. scalePath.moveTo(0,90);
  7518. scalePath.lineTo(10,90);
  7519. scalePath.moveTo(0,100);
  7520. scalePath.lineTo(10,100);
  7521. scaleLine.setPath(scalePath);
  7522. scaleLine.setPos(0,16);
  7523. scene.addItem(&scaleLine);
  7524. setScene(&scene);
  7525. indicator.setPolygon(left);
  7526. indicator.setBrush(theBrush);
  7527. setMinimumSize(sizeHint());
  7528. setMaximumSize(sizeHint());
  7529. }
  7530. /*:662*//*663:*/
  7531. #line 14125 "./typica.w"
  7532. QSize IntensityControl::sizeHint()const
  7533. {
  7534. return QSize(25,160);
  7535. }
  7536. /*:663*//*664:*/
  7537. #line 14140 "./typica.w"
  7538. void IntensityControl::setValue(double val)
  7539. {
  7540. if(val>=0&&val<=10)
  7541. {
  7542. theValue= val;
  7543. if(!valueSet)
  7544. {
  7545. scene.addItem(&indicator);
  7546. }
  7547. valueSet= true;
  7548. indicator.setPos(6,(100-(val*10))+16);
  7549. emit(valueChanged(val));
  7550. }
  7551. else if(val<1)
  7552. {
  7553. setValue(0);
  7554. }
  7555. else
  7556. {
  7557. setValue(10);
  7558. }
  7559. }
  7560. double IntensityControl::value()
  7561. {
  7562. return theValue;
  7563. }
  7564. /*:664*//*665:*/
  7565. #line 14172 "./typica.w"
  7566. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7567. {
  7568. /*656:*/
  7569. #line 13916 "./typica.w"
  7570. if(event->button()!=Qt::LeftButton)
  7571. {
  7572. event->ignore();
  7573. return;
  7574. }
  7575. /*:656*/
  7576. #line 14175 "./typica.w"
  7577. scaleDown= true;
  7578. event->accept();
  7579. }
  7580. /*:665*//*666:*/
  7581. #line 14186 "./typica.w"
  7582. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7583. {
  7584. /*656:*/
  7585. #line 13916 "./typica.w"
  7586. if(event->button()!=Qt::LeftButton)
  7587. {
  7588. event->ignore();
  7589. return;
  7590. }
  7591. /*:656*/
  7592. #line 14189 "./typica.w"
  7593. if(!scaleDown)
  7594. {
  7595. event->ignore();
  7596. return;
  7597. }
  7598. scaleDown= false;
  7599. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7600. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7601. {
  7602. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7603. {
  7604. if(valueSet)
  7605. {
  7606. setValue(theValue+0.05);
  7607. }
  7608. event->accept();
  7609. return;
  7610. }
  7611. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7612. {
  7613. if(valueSet)
  7614. {
  7615. setValue(theValue-0.05);
  7616. }
  7617. event->accept();
  7618. return;
  7619. }
  7620. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7621. {
  7622. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7623. event->accept();
  7624. return;
  7625. }
  7626. }
  7627. }
  7628. /*:666*/
  7629. #line 569 "./typica.w"
  7630. /*321:*/
  7631. #line 7484 "./typica.w"
  7632. void ThresholdDetector::newMeasurement(Measurement measure)
  7633. {
  7634. if((currentDirection==Ascending&&previousValue<threshold&&
  7635. previousValue>=0)||(currentDirection==Descending&&
  7636. previousValue> threshold&&previousValue>=0))
  7637. {
  7638. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7639. (currentDirection==Descending&&measure.temperature()<=threshold))
  7640. {
  7641. double offset= measure.time().hour()*60*60;
  7642. offset+= measure.time().minute()*60;
  7643. offset+= measure.time().second();
  7644. offset+= measure.time().msec()/1000;
  7645. emit timeForValue(offset);
  7646. }
  7647. }
  7648. previousValue= measure.temperature();
  7649. }
  7650. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7651. previousValue(-1),threshold(value),currentDirection(Ascending)
  7652. {
  7653. }
  7654. void ThresholdDetector::setThreshold(double value)
  7655. {
  7656. threshold= value;
  7657. }
  7658. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7659. {
  7660. currentDirection= direction;
  7661. }
  7662. /*:321*/
  7663. #line 570 "./typica.w"
  7664. /*748:*/
  7665. #line 16008 "./typica.w"
  7666. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  7667. lister(new QextSerialEnumerator)
  7668. {
  7669. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  7670. QextPortInfo port;
  7671. foreach(port,ports)
  7672. {
  7673. #ifdef Q_OS_WIN32
  7674. addItem(port.portName);
  7675. #else
  7676. addItem(port.physName);
  7677. #endif
  7678. }
  7679. lister->setUpNotifications();
  7680. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  7681. this,SLOT(addDevice(QextPortInfo)));
  7682. setEditable(true);
  7683. }
  7684. void PortSelector::addDevice(QextPortInfo port)
  7685. {
  7686. addItem(port.portName);
  7687. }
  7688. /*:748*/
  7689. #line 571 "./typica.w"
  7690. /*750:*/
  7691. #line 16100 "./typica.w"
  7692. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  7693. {
  7694. QMetaObject meta= BaudSelector::staticMetaObject;
  7695. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  7696. for(int i= 0;i<type.keyCount();i++)
  7697. {
  7698. addItem(QString("%1").arg(type.value(i)));
  7699. }
  7700. }
  7701. /*:750*/
  7702. #line 572 "./typica.w"
  7703. /*752:*/
  7704. #line 16138 "./typica.w"
  7705. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  7706. {
  7707. QMetaObject meta= ParitySelector::staticMetaObject;
  7708. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  7709. for(int i= 0;i<type.keyCount();i++)
  7710. {
  7711. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7712. }
  7713. }
  7714. /*:752*/
  7715. #line 573 "./typica.w"
  7716. /*754:*/
  7717. #line 16168 "./typica.w"
  7718. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  7719. {
  7720. QMetaObject meta= FlowSelector::staticMetaObject;
  7721. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  7722. for(int i= 0;i<type.keyCount();i++)
  7723. {
  7724. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7725. }
  7726. }
  7727. /*:754*/
  7728. #line 574 "./typica.w"
  7729. /*756:*/
  7730. #line 16203 "./typica.w"
  7731. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  7732. {
  7733. QMetaObject meta= StopSelector::staticMetaObject;
  7734. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  7735. for(int i= 0;i<type.keyCount();i++)
  7736. {
  7737. addItem(QString(type.key(i)),QVariant(type.value(i)));
  7738. }
  7739. }
  7740. /*:756*/
  7741. #line 575 "./typica.w"
  7742. /*811:*/
  7743. #line 17954 "./typica.w"
  7744. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  7745. :BasicDeviceConfigurationWidget(model,index),
  7746. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  7747. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  7748. decimalQuery(new QCheckBox(tr("Enable"))),
  7749. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  7750. unitQuery(new QCheckBox(tr("Enable"))),
  7751. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  7752. valueC(new QSpinBox),fixedUnit(new QComboBox),
  7753. pVAddress(new ShortHexSpinBox),
  7754. sVEnabled(new QCheckBox(tr("Enable"))),
  7755. sVReadAddress(new ShortHexSpinBox),
  7756. deviceLimit(new QCheckBox(tr("Enable"))),
  7757. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  7758. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  7759. sVWritable(new QCheckBox(tr("Enable"))),
  7760. sVOutputAddr(new ShortHexSpinBox),
  7761. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  7762. {
  7763. QHBoxLayout*layout= new QHBoxLayout;
  7764. QWidget*form= new QWidget;
  7765. QHBoxLayout*masterLayout= new QHBoxLayout;
  7766. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  7767. QVBoxLayout*seriesLayout= new QVBoxLayout;
  7768. QFormLayout*serialSection= new QFormLayout;
  7769. serialSection->addRow(QString(tr("Port:")),port);
  7770. serialSection->addRow(QString(tr("Baud rate:")),baud);
  7771. serialSection->addRow(QString(tr("Parity:")),parity);
  7772. serialSection->addRow(QString(tr("Flow control:")),flow);
  7773. serialSection->addRow(QString(tr("Stop bits:")),stop);
  7774. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  7775. serialSectionBox->setLayout(serialSection);
  7776. portAndDeviceLayout->addWidget(serialSectionBox);
  7777. QFormLayout*deviceSection= new QFormLayout;
  7778. station->setMinimum(1);
  7779. station->setMaximum(255);
  7780. decimalPosition->setMinimum(0);
  7781. decimalPosition->setMaximum(9);
  7782. valueF->setMinimum(0);
  7783. valueF->setMaximum(0xFFFF);
  7784. valueC->setMinimum(0);
  7785. valueC->setMaximum(0xFFFF);
  7786. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  7787. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  7788. deviceSection->addRow(tr("Station:"),station);
  7789. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  7790. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  7791. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  7792. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  7793. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  7794. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  7795. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  7796. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  7797. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  7798. deviceSectionBox->setLayout(deviceSection);
  7799. portAndDeviceLayout->addWidget(deviceSectionBox);
  7800. QFormLayout*pVSection= new QFormLayout;
  7801. pVSection->addRow(tr("Value relative address:"),pVAddress);
  7802. pVSection->addRow(tr("PV column name:"),pVColumnName);
  7803. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  7804. pVSection->addRow(pVHideBox);
  7805. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  7806. processValueBox->setLayout(pVSection);
  7807. seriesLayout->addWidget(processValueBox);
  7808. QFormLayout*sVSection= new QFormLayout;
  7809. sVLower->setDecimals(1);
  7810. sVLower->setMinimum(0.0);
  7811. sVLower->setMaximum(999.9);
  7812. sVUpper->setDecimals(1);
  7813. sVUpper->setMinimum(0.0);
  7814. sVUpper->setMaximum(999.9);
  7815. sVSection->addRow(tr("Set value:"),sVEnabled);
  7816. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  7817. sVSection->addRow(tr("SV column name:"),sVColumnName);
  7818. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  7819. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  7820. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  7821. sVSection->addRow(tr("Lower limit:"),sVLower);
  7822. sVSection->addRow(tr("Upper limit:"),sVUpper);
  7823. sVSection->addRow(tr("Output set value:"),sVWritable);
  7824. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  7825. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  7826. sVSection->addRow(sVHideBox);
  7827. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  7828. setValueBox->setLayout(sVSection);
  7829. seriesLayout->addWidget(setValueBox);
  7830. masterLayout->addLayout(portAndDeviceLayout);
  7831. masterLayout->addLayout(seriesLayout);
  7832. form->setLayout(masterLayout);
  7833. /*724:*/
  7834. #line 15464 "./typica.w"
  7835. QDomElement referenceElement=
  7836. model->referenceElement(model->data(index,Qt::UserRole).toString());
  7837. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  7838. QDomElement node;
  7839. /*:724*/
  7840. #line 18044 "./typica.w"
  7841. for(int i= 0;i<configData.size();i++)
  7842. {
  7843. node= configData.at(i).toElement();
  7844. if(node.attribute("name")=="port")
  7845. {
  7846. QString portname= node.attribute("value");
  7847. int idx= port->findText(portname);
  7848. if(idx>=0)
  7849. {
  7850. port->setCurrentIndex(idx);
  7851. }
  7852. else
  7853. {
  7854. port->addItem(portname);
  7855. }
  7856. }
  7857. else if(node.attribute("name")=="baud")
  7858. {
  7859. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  7860. }
  7861. else if(node.attribute("name")=="parity")
  7862. {
  7863. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  7864. }
  7865. else if(node.attribute("name")=="flow")
  7866. {
  7867. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  7868. }
  7869. else if(node.attribute("name")=="stop")
  7870. {
  7871. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  7872. }
  7873. else if(node.attribute("name")=="station")
  7874. {
  7875. station->setValue(node.attribute("value").toInt());
  7876. }
  7877. else if(node.attribute("name")=="decimalQuery")
  7878. {
  7879. if(node.attribute("value")=="true")
  7880. {
  7881. decimalQuery->setChecked(true);
  7882. }
  7883. else
  7884. {
  7885. decimalQuery->setChecked(false);
  7886. }
  7887. }
  7888. else if(node.attribute("name")=="decimalAddress")
  7889. {
  7890. decimalAddress->setValue(node.attribute("value").toInt());
  7891. }
  7892. else if(node.attribute("name")=="decimalPosition")
  7893. {
  7894. decimalPosition->setValue(node.attribute("value").toInt());
  7895. }
  7896. else if(node.attribute("name")=="unitQuery")
  7897. {
  7898. if(node.attribute("value")=="true")
  7899. {
  7900. unitQuery->setChecked(true);
  7901. }
  7902. else
  7903. {
  7904. unitQuery->setChecked(false);
  7905. }
  7906. }
  7907. else if(node.attribute("name")=="unitAddress")
  7908. {
  7909. unitAddress->setValue(node.attribute("value").toInt());
  7910. }
  7911. else if(node.attribute("name")=="valueF")
  7912. {
  7913. valueF->setValue(node.attribute("value").toInt());
  7914. }
  7915. else if(node.attribute("name")=="valueC")
  7916. {
  7917. valueC->setValue(node.attribute("value").toInt());
  7918. }
  7919. else if(node.attribute("name")=="fixedUnit")
  7920. {
  7921. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  7922. }
  7923. else if(node.attribute("name")=="pVAddress")
  7924. {
  7925. pVAddress->setValue(node.attribute("value").toInt());
  7926. }
  7927. else if(node.attribute("name")=="sVEnabled")
  7928. {
  7929. if(node.attribute("value")=="true")
  7930. {
  7931. sVEnabled->setChecked(true);
  7932. }
  7933. else
  7934. {
  7935. sVEnabled->setChecked(false);
  7936. }
  7937. }
  7938. else if(node.attribute("name")=="sVReadAddress")
  7939. {
  7940. sVReadAddress->setValue(node.attribute("value").toInt());
  7941. }
  7942. else if(node.attribute("name")=="deviceLimit")
  7943. {
  7944. if(node.attribute("value")=="true")
  7945. {
  7946. deviceLimit->setChecked(true);
  7947. }
  7948. else
  7949. {
  7950. deviceLimit->setChecked(false);
  7951. }
  7952. }
  7953. else if(node.attribute("name")=="sVLowerAddr")
  7954. {
  7955. sVLowerAddr->setValue(node.attribute("value").toInt());
  7956. }
  7957. else if(node.attribute("name")=="sVUpperAddr")
  7958. {
  7959. sVUpperAddr->setValue(node.attribute("value").toInt());
  7960. }
  7961. else if(node.attribute("name")=="sVLower")
  7962. {
  7963. sVLower->setValue(node.attribute("value").toDouble());
  7964. }
  7965. else if(node.attribute("name")=="sVUpper")
  7966. {
  7967. sVUpper->setValue(node.attribute("value").toDouble());
  7968. }
  7969. else if(node.attribute("name")=="sVWritable")
  7970. {
  7971. if(node.attribute("value")=="true")
  7972. {
  7973. sVWritable->setChecked(true);
  7974. }
  7975. else
  7976. {
  7977. sVWritable->setChecked(false);
  7978. }
  7979. }
  7980. else if(node.attribute("name")=="sVOutputAddr")
  7981. {
  7982. sVOutputAddr->setValue(node.attribute("value").toInt());
  7983. }
  7984. else if(node.attribute("name")=="pvcolname")
  7985. {
  7986. pVColumnName->setText(node.attribute("value"));
  7987. }
  7988. else if(node.attribute("name")=="svcolname")
  7989. {
  7990. sVColumnName->setText(node.attribute("value"));
  7991. }
  7992. else if(node.attribute("name")=="pvhidden")
  7993. {
  7994. pVHideBox->setChecked(node.attribute("value")=="true");
  7995. }
  7996. else if(node.attribute("name")=="svhidden")
  7997. {
  7998. sVHideBox->setChecked(node.attribute("value")=="true");
  7999. }
  8000. }
  8001. updatePort(port->currentText());
  8002. updateBaudRate(baud->currentText());
  8003. updateParity(parity->itemData(parity->currentIndex()).toString());
  8004. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8005. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8006. updateStation(station->value());
  8007. updateFixedDecimal(decimalQuery->isChecked());
  8008. updateDecimalAddress(decimalAddress->value());
  8009. updateDecimalPosition(decimalPosition->value());
  8010. updateFixedUnit(unitQuery->isChecked());
  8011. updateUnitAddress(unitAddress->value());
  8012. updateValueForF(valueF->value());
  8013. updateValueForC(valueC->value());
  8014. updateUnit(fixedUnit->currentText());
  8015. updatePVAddress(pVAddress->value());
  8016. updateSVEnabled(sVEnabled->isChecked());
  8017. updateSVReadAddress(sVReadAddress->value());
  8018. updateDeviceLimit(deviceLimit->isChecked());
  8019. updateSVLowerAddress(sVLowerAddr->value());
  8020. updateSVUpperAddress(sVUpperAddr->value());
  8021. updateSVLower(sVLower->value());
  8022. updateSVUpper(sVUpper->value());
  8023. updateSVWritable(sVWritable->isChecked());
  8024. updateSVWriteAddress(sVOutputAddr->value());
  8025. updatePVColumnName(pVColumnName->text());
  8026. updateSVColumnName(sVColumnName->text());
  8027. updatePVHidden(pVHideBox->isChecked());
  8028. updateSVHidden(sVHideBox->isChecked());
  8029. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8030. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8031. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8032. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8033. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8034. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8035. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8036. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8037. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8038. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8039. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8040. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8041. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8042. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8043. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8044. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8045. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8046. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8047. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8048. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8049. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8050. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8051. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8052. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8053. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8054. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8055. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8056. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8057. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8058. layout->addWidget(form);
  8059. setLayout(layout);
  8060. }
  8061. void ModbusConfigurator::updatePort(const QString&newPort)
  8062. {
  8063. updateAttribute("port",newPort);
  8064. }
  8065. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8066. {
  8067. updateAttribute("baud",newRate);
  8068. }
  8069. void ModbusConfigurator::updateParity(const QString&)
  8070. {
  8071. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8072. }
  8073. void ModbusConfigurator::updateFlowControl(const QString&)
  8074. {
  8075. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8076. }
  8077. void ModbusConfigurator::updateStopBits(const QString&)
  8078. {
  8079. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8080. }
  8081. void ModbusConfigurator::updateStation(int station)
  8082. {
  8083. updateAttribute("station",QString("%1").arg(station));
  8084. }
  8085. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8086. {
  8087. updateAttribute("decimalQuery",fixed?"true":"false");
  8088. }
  8089. void ModbusConfigurator::updateDecimalAddress(int address)
  8090. {
  8091. updateAttribute("decimalAddress",QString("%1").arg(address));
  8092. }
  8093. void ModbusConfigurator::updateDecimalPosition(int position)
  8094. {
  8095. updateAttribute("decimalPosition",QString("%1").arg(position));
  8096. }
  8097. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8098. {
  8099. updateAttribute("unitQuery",fixed?"true":"false");
  8100. }
  8101. void ModbusConfigurator::updateUnitAddress(int address)
  8102. {
  8103. updateAttribute("unitAddress",QString("%1").arg(address));
  8104. }
  8105. void ModbusConfigurator::updateValueForF(int value)
  8106. {
  8107. updateAttribute("valueF",QString("%1").arg(value));
  8108. }
  8109. void ModbusConfigurator::updateValueForC(int value)
  8110. {
  8111. updateAttribute("valueC",QString("%1").arg(value));
  8112. }
  8113. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8114. {
  8115. updateAttribute("fixedUnit",newUnit);
  8116. }
  8117. void ModbusConfigurator::updatePVAddress(int address)
  8118. {
  8119. updateAttribute("pVAddress",QString("%1").arg(address));
  8120. }
  8121. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8122. {
  8123. updateAttribute("sVEnabled",enabled?"true":"false");
  8124. }
  8125. void ModbusConfigurator::updateSVReadAddress(int address)
  8126. {
  8127. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8128. }
  8129. void ModbusConfigurator::updateDeviceLimit(bool query)
  8130. {
  8131. updateAttribute("deviceLimit",query?"true":"false");
  8132. }
  8133. void ModbusConfigurator::updateSVLowerAddress(int address)
  8134. {
  8135. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8136. }
  8137. void ModbusConfigurator::updateSVUpperAddress(int address)
  8138. {
  8139. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8140. }
  8141. void ModbusConfigurator::updateSVLower(double value)
  8142. {
  8143. updateAttribute("sVLower",QString("%1").arg(value));
  8144. }
  8145. void ModbusConfigurator::updateSVUpper(double value)
  8146. {
  8147. updateAttribute("sVUpper",QString("%1").arg(value));
  8148. }
  8149. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8150. {
  8151. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8152. }
  8153. void ModbusConfigurator::updateSVWriteAddress(int address)
  8154. {
  8155. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8156. }
  8157. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8158. {
  8159. updateAttribute("pvcolname",name);
  8160. }
  8161. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8162. {
  8163. updateAttribute("svcolname",name);
  8164. }
  8165. void ModbusConfigurator::updatePVHidden(bool hidden)
  8166. {
  8167. updateAttribute("pvhidden",hidden?"true":"false");
  8168. }
  8169. void ModbusConfigurator::updateSVHidden(bool hidden)
  8170. {
  8171. updateAttribute("svhidden",hidden?"true":"false");
  8172. }
  8173. /*:811*/
  8174. #line 576 "./typica.w"
  8175. /*759:*/
  8176. #line 16252 "./typica.w"
  8177. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8178. {
  8179. setMinimum(0);
  8180. setMaximum(0xFFFF);
  8181. setPrefix("0x");
  8182. setMinimumWidth(65);
  8183. }
  8184. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8185. {
  8186. if(input.size()==2)
  8187. {
  8188. return QValidator::Intermediate;
  8189. }
  8190. bool okay;
  8191. input.toInt(&okay,16);
  8192. if(okay)
  8193. {
  8194. return QValidator::Acceptable;
  8195. }
  8196. return QValidator::Invalid;
  8197. }
  8198. int ShortHexSpinBox::valueFromText(const QString&text)const
  8199. {
  8200. return text.toInt(NULL,16);
  8201. }
  8202. QString ShortHexSpinBox::textFromValue(int value)const
  8203. {
  8204. QString retval;
  8205. retval.setNum(value,16);
  8206. while(retval.size()<4)
  8207. {
  8208. retval.prepend("0");
  8209. }
  8210. return retval.toUpper();
  8211. }
  8212. /*:759*/
  8213. #line 577 "./typica.w"
  8214. /*796:*/
  8215. #line 17282 "./typica.w"
  8216. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8217. :QObject(NULL),messageDelayTimer(new QTimer),unitIsF(true),readingsv(false),
  8218. waiting(false)
  8219. {
  8220. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8221. Qt::UserRole).toString());
  8222. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8223. QDomElement node;
  8224. QVariantMap attributes;
  8225. for(int i= 0;i<portConfigData.size();i++)
  8226. {
  8227. node= portConfigData.at(i).toElement();
  8228. attributes.insert(node.attribute("name"),node.attribute("value"));
  8229. }
  8230. port= new QextSerialPort(attributes.value("port").toString(),
  8231. QextSerialPort::EventDriven);
  8232. int baudRate= attributes.value("baud").toInt();
  8233. port->setBaudRate((BaudRateType)baudRate);
  8234. double temp= ((double)(1)/(double)(baudRate))*48;
  8235. delayTime= (int)(temp*3000);
  8236. messageDelayTimer->setSingleShot(true);
  8237. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8238. port->setDataBits(DATA_8);
  8239. port->setParity((ParityType)attributes.value("parity").toInt());
  8240. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8241. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8242. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8243. port->open(QIODevice::ReadWrite);
  8244. station= (char)attributes.value("station").toInt();
  8245. if(attributes.value("decimalQuery")=="true")
  8246. {
  8247. decimalPosition= 0;
  8248. QByteArray message;
  8249. message.append(station);
  8250. message.append((char)0x03);
  8251. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8252. char*addressBytes= (char*)&address;
  8253. message.append(addressBytes[1]);
  8254. message.append(addressBytes[0]);
  8255. message.append((char)0x00);
  8256. message.append((char)0x01);
  8257. queueMessage(message,this,"decimalResponse(QByteArray)");
  8258. }
  8259. else
  8260. {
  8261. decimalPosition= attributes.value("decimalPosition").toInt();
  8262. }
  8263. valueF= attributes.value("valueF").toInt();
  8264. valueC= attributes.value("valueC").toInt();
  8265. if(attributes.value("unitQuery")=="true")
  8266. {
  8267. QByteArray message;
  8268. message.append(station);
  8269. message.append((char)0x03);
  8270. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8271. char*addressBytes= (char*)&address;
  8272. message.append(addressBytes[1]);
  8273. message.append(addressBytes[0]);
  8274. message.append((char)0x00);
  8275. message.append((char)0x01);
  8276. queueMessage(message,this,"unitResponse(QByteArray)");
  8277. }
  8278. else
  8279. {
  8280. if(attributes.value("fixedUnit")=="Celsius")
  8281. {
  8282. unitIsF= false;
  8283. }
  8284. }
  8285. if(attributes.value("sVWritable")=="true")
  8286. {
  8287. if(attributes.value("deviceLimit")=="true")
  8288. {
  8289. QByteArray lmessage;
  8290. lmessage.append(station);
  8291. lmessage.append((char)0x03);
  8292. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8293. char*addressBytes= (char*)&laddress;
  8294. lmessage.append(addressBytes[1]);
  8295. lmessage.append(addressBytes[0]);
  8296. lmessage.append((char)0x00);
  8297. lmessage.append((char)0x01);
  8298. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8299. QByteArray umessage;
  8300. umessage.append(station);
  8301. umessage.append((char)0x03);
  8302. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8303. addressBytes= (char*)&uaddress;
  8304. umessage.append(addressBytes[1]);
  8305. umessage.append(addressBytes[0]);
  8306. umessage.append((char)0x00);
  8307. umessage.append((char)0x01);
  8308. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8309. }
  8310. else
  8311. {
  8312. outputSVLower= attributes.value("sVLower").toDouble();
  8313. outputSVUpper= attributes.value("sVUpper").toDouble();
  8314. }
  8315. outputSVStub.append(station);
  8316. outputSVStub.append((char)0x06);
  8317. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8318. char*addressBytes= (char*)&address;
  8319. outputSVStub.append(addressBytes[1]);
  8320. outputSVStub.append(addressBytes[0]);
  8321. }
  8322. Channel*pv= new Channel;
  8323. channels.append(pv);
  8324. pvStub.append(station);
  8325. pvStub.append((char)0x04);
  8326. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8327. char*pvac= (char*)&pvaddress;
  8328. pvStub.append(pvac[1]);
  8329. pvStub.append(pvac[0]);
  8330. pvStub.append((char)0x00);
  8331. pvStub.append((char)0x01);
  8332. svenabled= attributes.value("sVEnabled").toBool();
  8333. if(svenabled)
  8334. {
  8335. Channel*sv= new Channel;
  8336. channels.append(sv);
  8337. svStub.append(station);
  8338. svStub.append((char)0x04);
  8339. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8340. char*svac= (char*)&svaddress;
  8341. svStub.append(svac[1]);
  8342. svStub.append(svac[0]);
  8343. svStub.append((char)0x00);
  8344. svStub.append((char)0x01);
  8345. if(svaddress-pvaddress==1)
  8346. {
  8347. mStub.append(station);
  8348. mStub.append((char)0x04);
  8349. mStub.append(pvac[1]);
  8350. mStub.append(pvac[0]);
  8351. mStub.append((char)0x00);
  8352. mStub.append((char)0x02);
  8353. }
  8354. }
  8355. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8356. requestMeasurement();
  8357. }
  8358. double ModbusRTUDevice::SVLower()
  8359. {
  8360. return outputSVLower;
  8361. }
  8362. double ModbusRTUDevice::SVUpper()
  8363. {
  8364. return outputSVUpper;
  8365. }
  8366. int ModbusRTUDevice::decimals()
  8367. {
  8368. return decimalPosition;
  8369. }
  8370. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8371. {
  8372. quint16 temp;
  8373. char*tchar= (char*)&temp;
  8374. tchar[1]= response.at(3);
  8375. tchar[0]= response.at(4);
  8376. decimalPosition= temp;
  8377. emit SVDecimalChanged(decimalPosition);
  8378. qDebug()<<"Received decimal response";
  8379. }
  8380. void ModbusRTUDevice::unitResponse(QByteArray response)
  8381. {
  8382. quint16 temp;
  8383. char*tchar= (char*)&temp;
  8384. tchar[1]= response.at(3);
  8385. tchar[0]= response.at(4);
  8386. int value= temp;
  8387. if(value==valueF)
  8388. {
  8389. unitIsF= true;
  8390. }
  8391. else
  8392. {
  8393. unitIsF= false;
  8394. }
  8395. }
  8396. void ModbusRTUDevice::svlResponse(QByteArray response)
  8397. {
  8398. quint16 temp;
  8399. char*tchar= (char*)&temp;
  8400. tchar[1]= response.at(3);
  8401. tchar[0]= response.at(4);
  8402. outputSVLower= (double)temp;
  8403. for(int i= 0;i<decimalPosition;i++)
  8404. {
  8405. outputSVLower/= 10;
  8406. }
  8407. emit SVLowerChanged(outputSVLower);
  8408. }
  8409. void ModbusRTUDevice::svuResponse(QByteArray response)
  8410. {
  8411. quint16 temp;
  8412. char*tchar= (char*)&temp;
  8413. tchar[1]= response.at(3);
  8414. tchar[0]= response.at(4);
  8415. outputSVUpper= (double)temp;
  8416. for(int i= 0;i<decimalPosition;i++)
  8417. {
  8418. outputSVUpper/= 10;
  8419. }
  8420. emit SVUpperChanged(outputSVUpper);
  8421. }
  8422. void ModbusRTUDevice::requestMeasurement()
  8423. {
  8424. if(mStub.length()> 0)
  8425. {
  8426. queueMessage(mStub,this,"mResponse(QByteArray)");
  8427. }
  8428. else
  8429. {
  8430. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8431. if(svenabled)
  8432. {
  8433. queueMessage(svStub,this,"mResponse(QByteArray)");
  8434. }
  8435. }
  8436. }
  8437. void ModbusRTUDevice::mResponse(QByteArray response)
  8438. {
  8439. QTime time= QTime::currentTime();
  8440. if(response.at(2)==0x04)
  8441. {
  8442. /*797:*/
  8443. #line 17531 "./typica.w"
  8444. quint16 pv;
  8445. quint16 sv;
  8446. char*pvBytes= (char*)&pv;
  8447. char*svBytes= (char*)&sv;
  8448. pvBytes[1]= response.at(3);
  8449. pvBytes[0]= response.at(4);
  8450. svBytes[1]= response.at(5);
  8451. svBytes[0]= response.at(6);
  8452. double pvOut= (double)pv;
  8453. double svOut= (double)sv;
  8454. for(int i= 0;i<decimalPosition;i++)
  8455. {
  8456. pvOut/= 10;
  8457. svOut/= 10;
  8458. }
  8459. if(!unitIsF)
  8460. {
  8461. pvOut= pvOut*9/5+32;
  8462. svOut= svOut*9/5+32;
  8463. }
  8464. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8465. Measurement svm(svOut,time,Units::Fahrenheit);
  8466. channels.at(0)->input(pvm);
  8467. channels.at(1)->input(svm);
  8468. /*:797*/
  8469. #line 17518 "./typica.w"
  8470. }
  8471. else
  8472. {
  8473. /*798:*/
  8474. #line 17561 "./typica.w"
  8475. quint16 value;
  8476. char*valueBytes= (char*)&value;
  8477. valueBytes[1]= response.at(3);
  8478. valueBytes[0]= response.at(4);
  8479. double valueOut= (double)value;
  8480. for(int i= 0;i<decimalPosition;i++)
  8481. {
  8482. valueOut/= 10;
  8483. }
  8484. if(!unitIsF)
  8485. {
  8486. valueOut= valueOut*9/5+32;
  8487. }
  8488. if(!svenabled)
  8489. {
  8490. Measurement vm(valueOut,time,Units::Fahrenheit);
  8491. channels.at(0)->input(vm);
  8492. }
  8493. else
  8494. {
  8495. if(readingsv)
  8496. {
  8497. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8498. Measurement svm(valueOut,time,Units::Fahrenheit);
  8499. channels.at(0)->input(pvm);
  8500. channels.at(1)->input(svm);
  8501. readingsv= false;
  8502. }
  8503. else
  8504. {
  8505. savedpv= valueOut;
  8506. readingsv= true;
  8507. }
  8508. }
  8509. /*:798*/
  8510. #line 17522 "./typica.w"
  8511. }
  8512. }
  8513. /*:796*//*799:*/
  8514. #line 17599 "./typica.w"
  8515. ModbusRTUDevice::~ModbusRTUDevice()
  8516. {
  8517. messageDelayTimer->stop();
  8518. port->close();
  8519. }
  8520. /*:799*//*800:*/
  8521. #line 17621 "./typica.w"
  8522. void ModbusRTUDevice::dataAvailable()
  8523. {
  8524. if(messageDelayTimer->isActive())
  8525. {
  8526. messageDelayTimer->stop();
  8527. }
  8528. responseBuffer.append(port->readAll());
  8529. /*801:*/
  8530. #line 17666 "./typica.w"
  8531. if(responseBuffer.size()<5)
  8532. {
  8533. return;
  8534. }
  8535. switch(responseBuffer.at(1))
  8536. {
  8537. case 0x01:
  8538. case 0x02:
  8539. if(responseBuffer.size()<6)
  8540. {
  8541. return;
  8542. }
  8543. responseBuffer= responseBuffer.left(6);
  8544. break;
  8545. case 0x03:
  8546. case 0x04:
  8547. if(responseBuffer.size()<5+responseBuffer.at(2))
  8548. {
  8549. return;
  8550. }
  8551. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8552. break;
  8553. case 0x05:
  8554. case 0x06:
  8555. case 0x10:
  8556. if(responseBuffer.size()<8)
  8557. {
  8558. return;
  8559. }
  8560. responseBuffer= responseBuffer.left(8);
  8561. break;
  8562. }
  8563. /*:801*/
  8564. #line 17629 "./typica.w"
  8565. if(calculateCRC(responseBuffer)==0)
  8566. {
  8567. QObject*object= retObjQueue.at(0);
  8568. char*method= callbackQueue.at(0);
  8569. QMetaMethod metamethod= object->metaObject()->
  8570. method(object->metaObject()->
  8571. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8572. metamethod.invoke(object,Qt::QueuedConnection,
  8573. Q_ARG(QByteArray,responseBuffer));
  8574. messageQueue.removeAt(0);
  8575. retObjQueue.removeAt(0);
  8576. callbackQueue.removeAt(0);
  8577. messageDelayTimer->start(delayTime);
  8578. }
  8579. else
  8580. {
  8581. qDebug()<<"CRC failed";
  8582. }
  8583. waiting= false;
  8584. responseBuffer.clear();
  8585. }
  8586. /*:800*//*802:*/
  8587. #line 17708 "./typica.w"
  8588. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8589. {
  8590. quint16 retval= 0xFFFF;
  8591. int i= 0;
  8592. while(i<data.size())
  8593. {
  8594. retval^= 0x00FF&(quint16)data.at(i);
  8595. for(int j= 0;j<8;j++)
  8596. {
  8597. if(retval&1)
  8598. {
  8599. retval= (retval>>1)^0xA001;
  8600. }
  8601. else
  8602. {
  8603. retval>>= 1;
  8604. }
  8605. }
  8606. i++;
  8607. }
  8608. return retval;
  8609. }
  8610. /*:802*//*803:*/
  8611. #line 17739 "./typica.w"
  8612. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8613. const char*callback)
  8614. {
  8615. messageQueue.append(request);
  8616. retObjQueue.append(object);
  8617. callbackQueue.append(const_cast<char*> (callback));
  8618. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8619. {
  8620. sendNextMessage();
  8621. }
  8622. }
  8623. void ModbusRTUDevice::sendNextMessage()
  8624. {
  8625. if(messageQueue.size()> 0&&!waiting)
  8626. {
  8627. QByteArray message= messageQueue.at(0);
  8628. quint16 crc= calculateCRC(message);
  8629. char*check= (char*)&crc;
  8630. message.append(check[0]);
  8631. message.append(check[1]);
  8632. port->write(message);
  8633. messageDelayTimer->start(delayTime);
  8634. waiting= true;
  8635. }
  8636. else
  8637. {
  8638. emit queueEmpty();
  8639. }
  8640. }
  8641. void ModbusRTUDevice::outputSV(double value)
  8642. {
  8643. for(int i= 0;i<decimalPosition;i++)
  8644. {
  8645. value*= 10;
  8646. }
  8647. quint16 outval= (quint16)value;
  8648. QByteArray message(outputSVStub);
  8649. char*valBytes= (char*)&outval;
  8650. message.append(valBytes[1]);
  8651. message.append(valBytes[0]);
  8652. queueMessage(message,this,"ignore(QByteArray)");
  8653. }
  8654. /*:803*//*804:*/
  8655. #line 17787 "./typica.w"
  8656. void ModbusRTUDevice::ignore(QByteArray)
  8657. {
  8658. return;
  8659. }
  8660. /*:804*/
  8661. #line 578 "./typica.w"
  8662. /*678:*/
  8663. #line 14444 "./typica.w"
  8664. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  8665. DeviceTreeModelNode*parent)
  8666. :domNode(node),rowNumber(row),parentItem(parent)
  8667. {
  8668. }
  8669. DeviceTreeModelNode::~DeviceTreeModelNode()
  8670. {
  8671. QHash<int,DeviceTreeModelNode*> ::iterator i;
  8672. for(i= children.begin();i!=children.end();i++)
  8673. {
  8674. delete i.value();
  8675. }
  8676. }
  8677. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  8678. {
  8679. return parentItem;
  8680. }
  8681. int DeviceTreeModelNode::row()
  8682. {
  8683. return rowNumber;
  8684. }
  8685. QDomNode DeviceTreeModelNode::node()const
  8686. {
  8687. return domNode;
  8688. }
  8689. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  8690. {
  8691. if(children.contains(index))
  8692. {
  8693. return children[index];
  8694. }
  8695. if(index>=0&&index<domNode.childNodes().count())
  8696. {
  8697. QDomNode childNode= domNode.childNodes().item(index);
  8698. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  8699. index,this);
  8700. children[index]= childItem;
  8701. return childItem;
  8702. }
  8703. return NULL;
  8704. }
  8705. /*:678*/
  8706. #line 579 "./typica.w"
  8707. /*680:*/
  8708. #line 14533 "./typica.w"
  8709. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  8710. :QAbstractItemModel(parent)
  8711. {
  8712. document= AppInstance->deviceConfiguration();
  8713. QDomNodeList elements= document.elementsByTagName("devices");
  8714. if(elements.size()!=1)
  8715. {
  8716. qDebug()<<"Unexpected result when loading device map.";
  8717. }
  8718. treeRoot= elements.at(0);
  8719. root= new DeviceTreeModelNode(treeRoot,0);
  8720. elements= document.elementsByTagName("references");
  8721. if(elements.size()!=1)
  8722. {
  8723. qDebug()<<"No references section. Creating.";
  8724. referenceSection= document.createElement("references");
  8725. document.appendChild(referenceSection);
  8726. }
  8727. else
  8728. {
  8729. referenceSection= elements.at(0);
  8730. }
  8731. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  8732. AppInstance,SLOT(saveDeviceConfiguration()));
  8733. connect(this,SIGNAL(modelReset()),
  8734. AppInstance,SLOT(saveDeviceConfiguration()));
  8735. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  8736. AppInstance,SLOT(saveDeviceConfiguration()));
  8737. }
  8738. /*:680*//*681:*/
  8739. #line 14568 "./typica.w"
  8740. int DeviceTreeModel::columnCount(const QModelIndex&)const
  8741. {
  8742. return 1;
  8743. }
  8744. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  8745. {
  8746. if(parent.column()> 0)
  8747. {
  8748. return 0;
  8749. }
  8750. /*682:*/
  8751. #line 14587 "./typica.w"
  8752. DeviceTreeModelNode*parentItem;
  8753. if(!parent.isValid())
  8754. {
  8755. parentItem= root;
  8756. }
  8757. else
  8758. {
  8759. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8760. }
  8761. /*:682*/
  8762. #line 14580 "./typica.w"
  8763. return parentItem->node().childNodes().count();
  8764. }
  8765. /*:681*//*683:*/
  8766. #line 14601 "./typica.w"
  8767. QModelIndex DeviceTreeModel::index(int row,int column,
  8768. const QModelIndex&parent)const
  8769. {
  8770. if(!hasIndex(row,column,parent))
  8771. {
  8772. return QModelIndex();
  8773. }
  8774. /*682:*/
  8775. #line 14587 "./typica.w"
  8776. DeviceTreeModelNode*parentItem;
  8777. if(!parent.isValid())
  8778. {
  8779. parentItem= root;
  8780. }
  8781. else
  8782. {
  8783. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8784. }
  8785. /*:682*/
  8786. #line 14609 "./typica.w"
  8787. DeviceTreeModelNode*childItem= parentItem->child(row);
  8788. if(childItem)
  8789. {
  8790. return createIndex(row,column,childItem);
  8791. }
  8792. return QModelIndex();
  8793. }
  8794. /*:683*//*684:*/
  8795. #line 14620 "./typica.w"
  8796. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  8797. {
  8798. if(!child.isValid())
  8799. {
  8800. return QModelIndex();
  8801. }
  8802. DeviceTreeModelNode*childItem=
  8803. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  8804. DeviceTreeModelNode*parentItem= childItem->parent();
  8805. if(!parentItem||parentItem==root)
  8806. {
  8807. return QModelIndex();
  8808. }
  8809. return createIndex(parentItem->row(),0,parentItem);
  8810. }
  8811. /*:684*//*685:*/
  8812. #line 14639 "./typica.w"
  8813. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  8814. {
  8815. if(!index.isValid())
  8816. {
  8817. return 0;
  8818. }
  8819. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  8820. }
  8821. /*:685*//*686:*/
  8822. #line 14654 "./typica.w"
  8823. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  8824. {
  8825. if(!index.isValid())
  8826. {
  8827. return QVariant();
  8828. }
  8829. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  8830. {
  8831. return QVariant();
  8832. }
  8833. DeviceTreeModelNode*item=
  8834. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  8835. QDomNode node= item->node();
  8836. QDomElement element= node.toElement();
  8837. switch(role)
  8838. {
  8839. case Qt::DisplayRole:
  8840. case Qt::EditRole:
  8841. return QVariant(element.attribute("name"));
  8842. case Qt::UserRole:
  8843. return QVariant(element.attribute("reference"));
  8844. default:
  8845. return QVariant();
  8846. }
  8847. return QVariant();
  8848. }
  8849. /*:686*//*687:*/
  8850. #line 14686 "./typica.w"
  8851. bool DeviceTreeModel::setData(const QModelIndex&index,
  8852. const QVariant&value,int)
  8853. {
  8854. if(!index.isValid())
  8855. {
  8856. return false;
  8857. }
  8858. DeviceTreeModelNode*item=
  8859. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  8860. QDomNode node= item->node();
  8861. QDomElement element= node.toElement();
  8862. element.setAttribute("name",value.toString());
  8863. emit dataChanged(index,index);
  8864. return true;
  8865. }
  8866. /*:687*//*688:*/
  8867. #line 14709 "./typica.w"
  8868. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  8869. const QModelIndex&parent)
  8870. {
  8871. QString referenceID= QUuid::createUuid().toString();
  8872. /*682:*/
  8873. #line 14587 "./typica.w"
  8874. DeviceTreeModelNode*parentItem;
  8875. if(!parent.isValid())
  8876. {
  8877. parentItem= root;
  8878. }
  8879. else
  8880. {
  8881. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8882. }
  8883. /*:682*/
  8884. #line 14714 "./typica.w"
  8885. QDomNode parentNode= parentItem->node();
  8886. int newRowNumber= rowCount(parent);
  8887. beginInsertRows(parent,newRowNumber,newRowNumber);
  8888. QDomElement deviceElement= document.createElement("node");
  8889. deviceElement.setAttribute("name",name);
  8890. deviceElement.setAttribute("reference",referenceID);
  8891. parentNode.appendChild(deviceElement);
  8892. QDomElement referenceElement= document.createElement("reference");
  8893. referenceElement.setAttribute("id",referenceID);
  8894. referenceElement.setAttribute("driver",driver);
  8895. referenceSection.appendChild(referenceElement);
  8896. endInsertRows();
  8897. }
  8898. /*:688*//*689:*/
  8899. #line 14732 "./typica.w"
  8900. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  8901. {
  8902. /*682:*/
  8903. #line 14587 "./typica.w"
  8904. DeviceTreeModelNode*parentItem;
  8905. if(!parent.isValid())
  8906. {
  8907. parentItem= root;
  8908. }
  8909. else
  8910. {
  8911. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  8912. }
  8913. /*:682*/
  8914. #line 14735 "./typica.w"
  8915. QDomNode parentNode= parentItem->node();
  8916. QDomNodeList childNodes= parentNode.childNodes();
  8917. if(childNodes.size()<row+count)
  8918. {
  8919. return false;
  8920. }
  8921. beginRemoveRows(parent,row,row+count-1);
  8922. QList<QDomElement> removalList;
  8923. for(int i= row;i<row+count;i++)
  8924. {
  8925. removalList.append(childNodes.at(i).toElement());
  8926. }
  8927. QDomElement element;
  8928. QDomElement reference;
  8929. for(int i= 0;i<count;i++)
  8930. {
  8931. element= removalList.at(i);
  8932. if(element.hasAttribute("reference"))
  8933. {
  8934. reference= referenceElement(element.attribute("reference"));
  8935. if(!reference.isNull())
  8936. {
  8937. referenceSection.removeChild(reference);
  8938. }
  8939. }
  8940. parentNode.removeChild(element);
  8941. }
  8942. endRemoveRows();
  8943. beginResetModel();
  8944. delete root;
  8945. root= new DeviceTreeModelNode(treeRoot,0);
  8946. endResetModel();
  8947. return true;
  8948. }
  8949. /*:689*//*690:*/
  8950. #line 14774 "./typica.w"
  8951. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  8952. {
  8953. QDomNodeList childNodes= referenceSection.childNodes();
  8954. QDomElement element;
  8955. for(int i= 0;i<childNodes.size();i++)
  8956. {
  8957. element= childNodes.at(i).toElement();
  8958. if(element.hasAttribute("id"))
  8959. {
  8960. if(element.attribute("id")==id)
  8961. {
  8962. return element;
  8963. }
  8964. }
  8965. }
  8966. return QDomElement();
  8967. }
  8968. /*:690*//*691:*/
  8969. #line 14795 "./typica.w"
  8970. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  8971. {
  8972. return QVariant();
  8973. }
  8974. /*:691*//*692:*/
  8975. #line 14804 "./typica.w"
  8976. DeviceTreeModel::~DeviceTreeModel()
  8977. {
  8978. delete root;
  8979. }
  8980. /*:692*/
  8981. #line 580 "./typica.w"
  8982. /*719:*/
  8983. #line 15304 "./typica.w"
  8984. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  8985. DeviceTreeModel*model,const QModelIndex&index)
  8986. :QWidget(NULL),deviceModel(model),currentNode(index)
  8987. {
  8988. }
  8989. /*:719*//*720:*/
  8990. #line 15316 "./typica.w"
  8991. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  8992. const QString&value)
  8993. {
  8994. QDomElement referenceElement= deviceModel->referenceElement(
  8995. deviceModel->data(currentNode,Qt::UserRole).toString());
  8996. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8997. QDomElement node;
  8998. bool found= false;
  8999. for(int i= 0;i<configData.size();i++)
  9000. {
  9001. node= configData.at(i).toElement();
  9002. if(node.attribute("name")==name)
  9003. {
  9004. node.setAttribute("value",value);
  9005. found= true;
  9006. break;
  9007. }
  9008. }
  9009. if(!found)
  9010. {
  9011. node= AppInstance->deviceConfiguration().createElement("attribute");
  9012. node.setAttribute("name",name);
  9013. node.setAttribute("value",value);
  9014. referenceElement.appendChild(node);
  9015. }
  9016. AppInstance->saveDeviceConfiguration();
  9017. }
  9018. /*:720*//*721:*/
  9019. #line 15350 "./typica.w"
  9020. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9021. const QString&driver)
  9022. {
  9023. deviceModel->newNode(name,driver,currentNode);
  9024. }
  9025. /*:721*/
  9026. #line 581 "./typica.w"
  9027. /*710:*/
  9028. #line 15148 "./typica.w"
  9029. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9030. view(new QTreeView),configArea(new QScrollArea)
  9031. {
  9032. QSplitter*splitter= new QSplitter;
  9033. QWidget*leftWidget= new QWidget;
  9034. leftWidget->setMinimumWidth(200);
  9035. QVBoxLayout*left= new QVBoxLayout;
  9036. view->setAnimated(true);
  9037. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9038. document= AppInstance->deviceConfiguration();
  9039. model= new DeviceTreeModel;
  9040. view->setModel(model);
  9041. view->setTextElideMode(Qt::ElideNone);
  9042. view->expandAll();
  9043. view->resizeColumnToContents(0);
  9044. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9045. QHBoxLayout*treeButtons= new QHBoxLayout;
  9046. QToolButton*addDeviceButton= new QToolButton;
  9047. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9048. addDeviceButton->setToolTip(tr("New Roaster"));
  9049. connect(addDeviceButton,SIGNAL(clicked()),
  9050. this,SLOT(addDevice()));
  9051. QToolButton*removeNodeButton= new QToolButton;
  9052. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9053. removeNodeButton->setToolTip(tr("Delete Selection"));
  9054. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9055. treeButtons->addWidget(addDeviceButton);
  9056. treeButtons->addWidget(removeNodeButton);
  9057. left->addWidget(view);
  9058. left->addLayout(treeButtons);
  9059. leftWidget->setLayout(left);
  9060. splitter->addWidget(leftWidget);
  9061. configArea->setMinimumWidth(580);
  9062. configArea->setMinimumHeight(460);
  9063. configArea->setWidgetResizable(true);
  9064. splitter->addWidget(configArea);
  9065. QVBoxLayout*centralLayout= new QVBoxLayout;
  9066. centralLayout->addWidget(splitter);
  9067. setLayout(centralLayout);
  9068. connect(view,SIGNAL(activated(QModelIndex)),
  9069. this,SLOT(newSelection(QModelIndex)));
  9070. connect(view,SIGNAL(clicked(QModelIndex)),
  9071. this,SLOT(newSelection(QModelIndex)));
  9072. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9073. view,SLOT(expand(QModelIndex)));
  9074. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9075. this,SLOT(resizeColumn()));
  9076. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9077. this,SLOT(resizeColumn()));
  9078. }
  9079. /*:710*//*711:*/
  9080. #line 15203 "./typica.w"
  9081. void DeviceConfigurationWindow::addDevice()
  9082. {
  9083. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9084. }
  9085. /*:711*//*712:*/
  9086. #line 15211 "./typica.w"
  9087. void DeviceConfigurationWindow::removeNode()
  9088. {
  9089. QModelIndex index= view->currentIndex();
  9090. if(index.isValid())
  9091. {
  9092. int row= index.row();
  9093. QModelIndex parent= index.parent();
  9094. model->removeRow(row,parent);
  9095. }
  9096. }
  9097. /*:712*//*713:*/
  9098. #line 15227 "./typica.w"
  9099. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9100. {
  9101. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9102. if(editor)
  9103. {
  9104. configArea->setWidget(editor);
  9105. editor->show();
  9106. }
  9107. }
  9108. /*:713*//*714:*/
  9109. #line 15244 "./typica.w"
  9110. void DeviceConfigurationWindow::resizeColumn()
  9111. {
  9112. view->resizeColumnToContents(0);
  9113. }
  9114. /*:714*/
  9115. #line 582 "./typica.w"
  9116. /*734:*/
  9117. #line 15655 "./typica.w"
  9118. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9119. const QModelIndex&index):
  9120. BasicDeviceConfigurationWidget(model,index)
  9121. {
  9122. QFormLayout*layout= new QFormLayout;
  9123. QLineEdit*columnName= new QLineEdit;
  9124. layout->addRow(tr("Column Name:"),columnName);
  9125. QComboBox*typeSelector= new QComboBox;
  9126. typeSelector->addItem("J");
  9127. typeSelector->addItem("K");
  9128. typeSelector->addItem("T");
  9129. typeSelector->addItem("B");
  9130. typeSelector->addItem("E");
  9131. typeSelector->addItem("N");
  9132. typeSelector->addItem("R");
  9133. typeSelector->addItem("S");
  9134. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9135. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9136. layout->addRow(hideSeries);
  9137. setLayout(layout);
  9138. /*724:*/
  9139. #line 15464 "./typica.w"
  9140. QDomElement referenceElement=
  9141. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9142. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9143. QDomElement node;
  9144. /*:724*/
  9145. #line 15676 "./typica.w"
  9146. for(int i= 0;i<configData.size();i++)
  9147. {
  9148. node= configData.at(i).toElement();
  9149. if(node.attribute("name")=="type")
  9150. {
  9151. typeSelector->setCurrentIndex(
  9152. typeSelector->findText(node.attribute("value")));
  9153. }
  9154. else if(node.attribute("name")=="columnname")
  9155. {
  9156. columnName->setText(node.attribute("value"));
  9157. }
  9158. else if(node.attribute("name")=="hidden")
  9159. {
  9160. hideSeries->setChecked(node.attribute("value")=="true");
  9161. }
  9162. }
  9163. updateThermocoupleType(typeSelector->currentText());
  9164. updateColumnName(columnName->text());
  9165. updateHidden(hideSeries->isChecked());
  9166. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9167. this,SLOT(updateThermocoupleType(QString)));
  9168. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9169. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9170. }
  9171. /*:734*//*735:*/
  9172. #line 15706 "./typica.w"
  9173. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9174. {
  9175. updateAttribute("type",type);
  9176. }
  9177. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9178. {
  9179. updateAttribute("columnname",name);
  9180. }
  9181. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9182. {
  9183. updateAttribute("hidden",hidden?"true":"false");
  9184. }
  9185. /*:735*/
  9186. #line 583 "./typica.w"
  9187. /*730:*/
  9188. #line 15569 "./typica.w"
  9189. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9190. const QModelIndex&index)
  9191. :BasicDeviceConfigurationWidget(model,index)
  9192. {
  9193. QVBoxLayout*layout= new QVBoxLayout;
  9194. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9195. QLabel*label= new QLabel(tr("Device ID:"));
  9196. QLineEdit*deviceId= new QLineEdit;
  9197. deviceIdLayout->addWidget(label);
  9198. deviceIdLayout->addWidget(deviceId);
  9199. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9200. layout->addLayout(deviceIdLayout);
  9201. layout->addWidget(addChannelButton);
  9202. /*724:*/
  9203. #line 15464 "./typica.w"
  9204. QDomElement referenceElement=
  9205. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9206. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9207. QDomElement node;
  9208. /*:724*/
  9209. #line 15583 "./typica.w"
  9210. for(int i= 0;i<configData.size();i++)
  9211. {
  9212. node= configData.at(i).toElement();
  9213. if(node.attribute("name")=="deviceID")
  9214. {
  9215. deviceId->setText(node.attribute("value","Dev1"));
  9216. break;
  9217. }
  9218. }
  9219. updateDeviceId(deviceId->text());
  9220. connect(addChannelButton,SIGNAL(clicked()),
  9221. this,SLOT(addChannel()));
  9222. connect(deviceId,SIGNAL(textEdited(QString)),
  9223. this,SLOT(updateDeviceId(QString)));
  9224. setLayout(layout);
  9225. }
  9226. /*:730*//*731:*/
  9227. #line 15605 "./typica.w"
  9228. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9229. {
  9230. updateAttribute("deviceID",newId);
  9231. }
  9232. /*:731*//*732:*/
  9233. #line 15613 "./typica.w"
  9234. void NiDaqMxBase9211ConfWidget::addChannel()
  9235. {
  9236. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9237. }
  9238. /*:732*/
  9239. #line 584 "./typica.w"
  9240. /*728:*/
  9241. #line 15520 "./typica.w"
  9242. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9243. DeviceTreeModel*model,const QModelIndex&index):
  9244. BasicDeviceConfigurationWidget(model,index)
  9245. {
  9246. QHBoxLayout*layout= new QHBoxLayout;
  9247. QToolButton*addDeviceButton= new QToolButton;
  9248. addDeviceButton->setText(tr("Add Device"));
  9249. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9250. "nidaqmxbase9211series");
  9251. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9252. "nidaqmxbase9211series");
  9253. connect(add9211,SIGNAL(triggered(QString,QString)),
  9254. this,SLOT(insertChildNode(QString,QString)));
  9255. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9256. this,SLOT(insertChildNode(QString,QString)));
  9257. QMenu*deviceMenu= new QMenu;
  9258. deviceMenu->addAction(add9211);
  9259. deviceMenu->addAction(add9211a);
  9260. addDeviceButton->setMenu(deviceMenu);
  9261. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9262. layout->addWidget(addDeviceButton);
  9263. setLayout(layout);
  9264. }
  9265. /*:728*/
  9266. #line 585 "./typica.w"
  9267. /*595:*/
  9268. #line 13066 "./typica.w"
  9269. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9270. QObject*parent):
  9271. QAction(reportName,parent),reportFile(fileName)
  9272. {
  9273. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9274. }
  9275. /*:595*//*596:*/
  9276. #line 13082 "./typica.w"
  9277. void ReportAction::createReport()
  9278. {
  9279. QFile file(reportFile);
  9280. QDomDocument document;
  9281. if(file.open(QIODevice::ReadOnly))
  9282. {
  9283. document.setContent(&file,true);
  9284. QDomElement element= document.documentElement();
  9285. QScriptEngine*engine= AppInstance->engine;
  9286. QScriptContext*context= engine->pushContext();
  9287. QScriptValue object;
  9288. QString targetID= reportFile;
  9289. /*167:*/
  9290. #line 3986 "./typica.w"
  9291. ScriptQMainWindow*window= new ScriptQMainWindow;
  9292. window->setObjectName(targetID);
  9293. object= engine->newQObject(window);
  9294. setQMainWindowProperties(object,engine);
  9295. QWidget*central= new(QWidget);
  9296. central->setParent(window);
  9297. central->setObjectName("centralWidget");
  9298. window->setCentralWidget(central);
  9299. if(element.hasChildNodes())
  9300. {
  9301. /*168:*/
  9302. #line 4021 "./typica.w"
  9303. QStack<QWidget*> widgetStack;
  9304. QStack<QLayout*> layoutStack;
  9305. QString windowScript;
  9306. widgetStack.push(central);
  9307. QDomNodeList windowChildren= element.childNodes();
  9308. int i= 0;
  9309. while(i<windowChildren.count())
  9310. {
  9311. QDomNode current;
  9312. QDomElement element;
  9313. current= windowChildren.at(i);
  9314. if(current.isElement())
  9315. {
  9316. element= current.toElement();
  9317. if(element.tagName()=="program")
  9318. {
  9319. windowScript.append(element.text());
  9320. }
  9321. else if(element.tagName()=="layout")
  9322. {
  9323. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9324. }
  9325. else if(element.tagName()=="menu")
  9326. {
  9327. /*169:*/
  9328. #line 4068 "./typica.w"
  9329. QMenuBar*bar= window->menuBar();
  9330. bar->setParent(window);
  9331. bar->setObjectName("menuBar");
  9332. if(element.hasAttribute("name"))
  9333. {
  9334. QMenu*menu= bar->addMenu(element.attribute("name"));
  9335. menu->setParent(bar);
  9336. if(element.hasAttribute("type"))
  9337. {
  9338. if(element.attribute("type")=="reports")
  9339. {
  9340. if(element.hasAttribute("src"))
  9341. {
  9342. /*593:*/
  9343. #line 13026 "./typica.w"
  9344. QSettings settings;
  9345. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9346. toString()).
  9347. arg(element.attribute("src"));
  9348. QDir::addSearchPath("reports",reportDirectory);
  9349. QDir directory(reportDirectory);
  9350. directory.setFilter(QDir::Files);
  9351. directory.setSorting(QDir::Name);
  9352. QStringList nameFilter;
  9353. nameFilter<<"*.xml";
  9354. directory.setNameFilters(nameFilter);
  9355. QFileInfoList reportFiles= directory.entryInfoList();
  9356. for(int i= 0;i<reportFiles.size();i++)
  9357. {
  9358. QFileInfo reportFile= reportFiles.at(i);
  9359. /*597:*/
  9360. #line 13106 "./typica.w"
  9361. QString path= reportFile.absoluteFilePath();
  9362. QFile file(path);
  9363. if(file.open(QIODevice::ReadOnly))
  9364. {
  9365. QDomDocument document;
  9366. document.setContent(&file,true);
  9367. QDomElement root= document.documentElement();
  9368. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9369. if(!titleNode.isNull())
  9370. {
  9371. QDomElement titleElement= titleNode.toElement();
  9372. QString title= titleElement.text();
  9373. if(!title.isEmpty())
  9374. {
  9375. QStringList hierarchy= title.split(":->");
  9376. QMenu*insertionPoint= menu;
  9377. /*598:*/
  9378. #line 13133 "./typica.w"
  9379. for(int j= 0;j<hierarchy.size()-1;j++)
  9380. {
  9381. QObjectList menuList= insertionPoint->children();
  9382. bool menuFound= false;
  9383. for(int k= 0;k<menuList.size();k++)
  9384. {
  9385. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9386. if(currentItem)
  9387. {
  9388. if(currentItem->title()==hierarchy.at(j))
  9389. {
  9390. menuFound= true;
  9391. insertionPoint= currentItem;
  9392. break;
  9393. }
  9394. }
  9395. }
  9396. if(!menuFound)
  9397. {
  9398. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9399. }
  9400. }
  9401. /*:598*/
  9402. #line 13123 "./typica.w"
  9403. ReportAction*action= new ReportAction(path,hierarchy.last());
  9404. insertionPoint->addAction(action);
  9405. }
  9406. }
  9407. }
  9408. /*:597*/
  9409. #line 13042 "./typica.w"
  9410. }
  9411. /*:593*/
  9412. #line 4082 "./typica.w"
  9413. }
  9414. }
  9415. }
  9416. if(element.hasChildNodes())
  9417. {
  9418. /*170:*/
  9419. #line 4095 "./typica.w"
  9420. QDomNodeList menuItems= element.childNodes();
  9421. int j= 0;
  9422. while(j<menuItems.count())
  9423. {
  9424. QDomNode item= menuItems.at(j);
  9425. if(item.isElement())
  9426. {
  9427. QDomElement itemElement= item.toElement();
  9428. if(itemElement.tagName()=="item")
  9429. {
  9430. QAction*itemAction= new QAction(itemElement.text(),menu);
  9431. if(itemElement.hasAttribute("id"))
  9432. {
  9433. itemAction->setObjectName(itemElement.attribute("id"));
  9434. }
  9435. if(itemElement.hasAttribute("shortcut"))
  9436. {
  9437. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9438. }
  9439. menu->addAction(itemAction);
  9440. }
  9441. else if(itemElement.tagName()=="separator")
  9442. {
  9443. menu->addSeparator();
  9444. }
  9445. }
  9446. j++;
  9447. }
  9448. #line 1 "./helpmenu.w"
  9449. /*:170*/
  9450. #line 4088 "./typica.w"
  9451. }
  9452. }
  9453. /*:169*/
  9454. #line 4046 "./typica.w"
  9455. }
  9456. }
  9457. i++;
  9458. }
  9459. QScriptValue oldThis= context->thisObject();
  9460. context->setThisObject(object);
  9461. QScriptValue result= engine->evaluate(windowScript);
  9462. /*161:*/
  9463. #line 3803 "./typica.w"
  9464. if(engine->hasUncaughtException())
  9465. {
  9466. int line= engine->uncaughtExceptionLineNumber();
  9467. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9468. result.toString();
  9469. QString trace;
  9470. foreach(trace,engine->uncaughtExceptionBacktrace())
  9471. {
  9472. qDebug()<<trace;
  9473. }
  9474. }
  9475. /*:161*/
  9476. #line 4054 "./typica.w"
  9477. context->setThisObject(oldThis);
  9478. /*:168*/
  9479. #line 3997 "./typica.w"
  9480. }
  9481. /*171:*/
  9482. #line 9 "./helpmenu.w"
  9483. HelpMenu*helpMenu= new HelpMenu();
  9484. window->menuBar()->addMenu(helpMenu);
  9485. /*:171*/
  9486. #line 3999 "./typica.w"
  9487. window->show();
  9488. /*:167*/
  9489. #line 13095 "./typica.w"
  9490. file.close();
  9491. engine->popContext();
  9492. }
  9493. }
  9494. /*:596*/
  9495. #line 586 "./typica.w"
  9496. /*203:*/
  9497. #line 5161 "./typica.w"
  9498. NumericDelegate::NumericDelegate(QObject*parent):
  9499. QItemDelegate(parent)
  9500. {
  9501. }
  9502. /*:203*//*204:*/
  9503. #line 5173 "./typica.w"
  9504. void NumericDelegate::setEditorData(QWidget*editor,
  9505. const QModelIndex&index)const
  9506. {
  9507. QString value= index.model()->data(index,Qt::EditRole).toString();
  9508. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9509. line->setText(value);
  9510. }
  9511. /*:204*//*205:*/
  9512. #line 5188 "./typica.w"
  9513. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9514. const QModelIndex&index)const
  9515. {
  9516. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9517. model->setData(index,line->text(),Qt::EditRole);
  9518. QScriptEngine*engine= AppInstance->engine;
  9519. engine->pushContext();
  9520. QString script= QString("Number(%1)").arg(line->text());
  9521. QScriptValue result= engine->evaluate(line->text());
  9522. if(result.isNumber())
  9523. {
  9524. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9525. }
  9526. else
  9527. {
  9528. model->setData(index,QVariant(),Qt::DisplayRole);
  9529. }
  9530. engine->popContext();
  9531. }
  9532. /*:205*//*206:*/
  9533. #line 5211 "./typica.w"
  9534. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9535. const QStyleOptionViewItem&,
  9536. const QModelIndex&)const
  9537. {
  9538. return(new QLineEdit(parent));
  9539. }
  9540. /*:206*//*207:*/
  9541. #line 5222 "./typica.w"
  9542. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9543. const QStyleOptionViewItem&option,
  9544. const QModelIndex&)const
  9545. {
  9546. editor->setGeometry(option.rect);
  9547. }
  9548. /*:207*/
  9549. #line 587 "./typica.w"
  9550. /*739:*/
  9551. #line 15765 "./typica.w"
  9552. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9553. const QModelIndex&index)
  9554. :BasicDeviceConfigurationWidget(model,index)
  9555. {
  9556. QHBoxLayout*layout= new QHBoxLayout;
  9557. QToolButton*addDeviceButton= new QToolButton;
  9558. addDeviceButton->setText(tr("Add Device"));
  9559. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9560. "nidaqmx9211series");
  9561. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9562. "nidaqmxtc01");
  9563. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9564. this,SLOT(insertChildNode(QString,QString)));
  9565. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9566. this,SLOT(insertChildNode(QString,QString)));
  9567. QMenu*deviceMenu= new QMenu;
  9568. deviceMenu->addAction(add9211a);
  9569. deviceMenu->addAction(addtc01);
  9570. addDeviceButton->setMenu(deviceMenu);
  9571. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9572. layout->addWidget(addDeviceButton);
  9573. setLayout(layout);
  9574. }
  9575. /*:739*/
  9576. #line 588 "./typica.w"
  9577. /*741:*/
  9578. #line 15814 "./typica.w"
  9579. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9580. const QModelIndex&index)
  9581. :BasicDeviceConfigurationWidget(model,index)
  9582. {
  9583. QVBoxLayout*layout= new QVBoxLayout;
  9584. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9585. QLabel*label= new QLabel(tr("Device ID:"));
  9586. QLineEdit*deviceId= new QLineEdit;
  9587. deviceIdLayout->addWidget(label);
  9588. deviceIdLayout->addWidget(deviceId);
  9589. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9590. layout->addLayout(deviceIdLayout);
  9591. layout->addWidget(addChannelButton);
  9592. /*724:*/
  9593. #line 15464 "./typica.w"
  9594. QDomElement referenceElement=
  9595. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9596. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9597. QDomElement node;
  9598. /*:724*/
  9599. #line 15828 "./typica.w"
  9600. for(int i= 0;i<configData.size();i++)
  9601. {
  9602. node= configData.at(i).toElement();
  9603. if(node.attribute("name")=="deviceID")
  9604. {
  9605. deviceId->setText(node.attribute("value","Dev1"));
  9606. break;
  9607. }
  9608. }
  9609. updateDeviceId(deviceId->text());
  9610. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9611. connect(deviceId,SIGNAL(textEdited(QString)),
  9612. this,SLOT(updateDeviceId(QString)));
  9613. setLayout(layout);
  9614. }
  9615. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9616. {
  9617. updateAttribute("deviceID",newId);
  9618. }
  9619. void NiDaqMx9211ConfWidget::addChannel()
  9620. {
  9621. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9622. }
  9623. /*:741*/
  9624. #line 589 "./typica.w"
  9625. /*743:*/
  9626. #line 15879 "./typica.w"
  9627. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9628. const QModelIndex&index)
  9629. :BasicDeviceConfigurationWidget(model,index)
  9630. {
  9631. QFormLayout*layout= new QFormLayout;
  9632. QLineEdit*deviceId= new QLineEdit;
  9633. layout->addRow(tr("Device ID:"),deviceId);
  9634. QLineEdit*columnName= new QLineEdit;
  9635. layout->addRow(tr("Column Name:"),columnName);
  9636. QComboBox*typeSelector= new QComboBox;
  9637. typeSelector->addItem("J");
  9638. typeSelector->addItem("K");
  9639. typeSelector->addItem("T");
  9640. typeSelector->addItem("B");
  9641. typeSelector->addItem("E");
  9642. typeSelector->addItem("N");
  9643. typeSelector->addItem("R");
  9644. typeSelector->addItem("S");
  9645. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9646. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  9647. layout->addRow(hideSeries);
  9648. /*724:*/
  9649. #line 15464 "./typica.w"
  9650. QDomElement referenceElement=
  9651. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9652. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9653. QDomElement node;
  9654. /*:724*/
  9655. #line 15901 "./typica.w"
  9656. for(int i= 0;i<configData.size();i++)
  9657. {
  9658. node= configData.at(i).toElement();
  9659. if(node.attribute("name")=="deviceID")
  9660. {
  9661. deviceId->setText(node.attribute("value"));
  9662. }
  9663. else if(node.attribute("name")=="type")
  9664. {
  9665. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  9666. }
  9667. else if(node.attribute("name")=="columnname")
  9668. {
  9669. columnName->setText(node.attribute("value"));
  9670. }
  9671. else if(node.attribute("name")=="hidden")
  9672. {
  9673. hideSeries->setChecked(node.attribute("value")=="true");
  9674. }
  9675. }
  9676. updateDeviceId(deviceId->text());
  9677. updateThermocoupleType(typeSelector->currentText());
  9678. updateColumnName(columnName->text());
  9679. updateHidden(hideSeries->isChecked());
  9680. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  9681. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  9682. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9683. setLayout(layout);
  9684. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9685. }
  9686. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  9687. {
  9688. updateAttribute("deviceID",newId);
  9689. }
  9690. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  9691. {
  9692. updateAttribute("type",type);
  9693. }
  9694. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  9695. {
  9696. updateAttribute("columnname",name);
  9697. }
  9698. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  9699. {
  9700. updateAttribute("hidden",hidden?"true":"false");
  9701. }
  9702. /*:743*/
  9703. #line 590 "./typica.w"
  9704. /*761:*/
  9705. #line 16317 "./typica.w"
  9706. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  9707. const QModelIndex&index)
  9708. :BasicDeviceConfigurationWidget(model,index)
  9709. {
  9710. QFormLayout*layout= new QFormLayout;
  9711. QToolButton*addDeviceButton= new QToolButton;
  9712. addDeviceButton->setText(tr("Add Device"));
  9713. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  9714. "Modbus RTU Device",
  9715. "modbusrtudevice");
  9716. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  9717. this,SLOT(insertChildNode(QString,QString)));
  9718. QMenu*deviceMenu= new QMenu;
  9719. deviceMenu->addAction(addModbusRtuDevice);
  9720. addDeviceButton->setMenu(deviceMenu);
  9721. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9722. layout->addRow(QString(),addDeviceButton);
  9723. PortSelector*port= new PortSelector;
  9724. layout->addRow(tr("Port:"),port);
  9725. connect(port,SIGNAL(currentIndexChanged(QString)),
  9726. this,SLOT(updatePort(QString)));
  9727. connect(port,SIGNAL(editTextChanged(QString)),
  9728. this,SLOT(updatePort(QString)));
  9729. BaudSelector*rate= new BaudSelector;
  9730. layout->addRow(tr("Baud:"),rate);
  9731. connect(rate,SIGNAL(currentIndexChanged(QString)),
  9732. this,SLOT(updateBaudRate(QString)));
  9733. ParitySelector*parity= new ParitySelector;
  9734. layout->addRow(tr("Parity:"),parity);
  9735. connect(parity,SIGNAL(currentIndexChanged(QString)),
  9736. this,SLOT(updateParity(QString)));
  9737. FlowSelector*flow= new FlowSelector;
  9738. layout->addRow(tr("Flow Control:"),flow);
  9739. connect(flow,SIGNAL(currentIndexChanged(QString)),
  9740. this,SLOT(updateFlowControl(QString)));
  9741. StopSelector*stop= new StopSelector;
  9742. layout->addRow(tr("Stop Bits:"),stop);
  9743. connect(stop,SIGNAL(currentIndexChanged(QString)),
  9744. this,SLOT(updateStopBits(QString)));
  9745. /*724:*/
  9746. #line 15464 "./typica.w"
  9747. QDomElement referenceElement=
  9748. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9749. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9750. QDomElement node;
  9751. /*:724*/
  9752. #line 16357 "./typica.w"
  9753. for(int i= 0;i<configData.size();i++)
  9754. {
  9755. node= configData.at(i).toElement();
  9756. if(node.attribute("name")=="port")
  9757. {
  9758. int j= port->findText(node.attribute("value"));
  9759. if(j>=0)
  9760. {
  9761. port->setCurrentIndex(j);
  9762. }
  9763. else
  9764. {
  9765. port->insertItem(0,node.attribute("value"));
  9766. port->setCurrentIndex(0);
  9767. }
  9768. }
  9769. else if(node.attribute("name")=="baudrate")
  9770. {
  9771. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  9772. }
  9773. else if(node.attribute("name")=="parity")
  9774. {
  9775. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  9776. }
  9777. else if(node.attribute("name")=="flowcontrol")
  9778. {
  9779. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  9780. }
  9781. else if(node.attribute("name")=="stopbits")
  9782. {
  9783. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  9784. }
  9785. }
  9786. updatePort(port->currentText());
  9787. updateBaudRate(rate->currentText());
  9788. updateParity(parity->currentText());
  9789. updateFlowControl(flow->currentText());
  9790. updateStopBits(stop->currentText());
  9791. setLayout(layout);
  9792. }
  9793. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  9794. {
  9795. updateAttribute("port",newPort);
  9796. }
  9797. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  9798. {
  9799. updateAttribute("baudrate",newRate);
  9800. }
  9801. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  9802. {
  9803. updateAttribute("parity",newParity);
  9804. }
  9805. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  9806. {
  9807. updateAttribute("flowcontrol",newFlow);
  9808. }
  9809. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  9810. {
  9811. updateAttribute("stopbits",newStopBits);
  9812. }
  9813. /*:761*/
  9814. #line 591 "./typica.w"
  9815. /*763:*/
  9816. #line 16480 "./typica.w"
  9817. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  9818. const QModelIndex&index)
  9819. :BasicDeviceConfigurationWidget(model,index),
  9820. unitSpecificationLayout(new QStackedLayout),
  9821. decimalSpecificationLayout(new QStackedLayout)
  9822. {
  9823. QVBoxLayout*layout= new QVBoxLayout;
  9824. QToolButton*addChannelButton= new QToolButton;
  9825. addChannelButton->setText(tr("Add Channel"));
  9826. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  9827. "Temperature Process Value",
  9828. "modbustemperaturepv");
  9829. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  9830. "Temperature Set Value",
  9831. "modbustemperaturesv");
  9832. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  9833. this,SLOT(insertChildNode(QString,QString)));
  9834. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  9835. this,SLOT(insertChildNode(QString,QString)));
  9836. QMenu*channelMenu= new QMenu;
  9837. channelMenu->addAction(addTemperaturePV);
  9838. channelMenu->addAction(addTemperatureSV);
  9839. addChannelButton->setMenu(channelMenu);
  9840. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  9841. layout->addWidget(addChannelButton);
  9842. QHBoxLayout*stationLayout= new QHBoxLayout;
  9843. QLabel*stationLabel= new QLabel(tr("Station:"));
  9844. QSpinBox*stationNumber= new QSpinBox;
  9845. stationNumber->setMinimum(0);
  9846. stationNumber->setMaximum(255);
  9847. stationLayout->addWidget(stationLabel);
  9848. stationLayout->addWidget(stationNumber);
  9849. layout->addLayout(stationLayout);
  9850. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  9851. layout->addWidget(fixedUnit);
  9852. QWidget*fixedUnitPlaceholder= new QWidget(this);
  9853. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  9854. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  9855. QComboBox*fixedUnitSelector= new QComboBox;
  9856. fixedUnitSelector->addItem("Fahrenheit");
  9857. fixedUnitSelector->addItem("Celsius");
  9858. fixedUnitLayout->addWidget(fixedUnitLabel);
  9859. fixedUnitLayout->addWidget(fixedUnitSelector);
  9860. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  9861. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  9862. QWidget*queriedUnitPlaceholder= new QWidget(this);
  9863. QFormLayout*queriedUnitLayout= new QFormLayout;
  9864. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  9865. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  9866. QSpinBox*valueF= new QSpinBox;
  9867. valueF->setMinimum(0);
  9868. valueF->setMaximum(65535);
  9869. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  9870. QSpinBox*valueC= new QSpinBox;
  9871. valueC->setMinimum(0);
  9872. valueC->setMaximum(65535);
  9873. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  9874. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  9875. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  9876. layout->addLayout(unitSpecificationLayout);
  9877. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  9878. layout->addWidget(fixedPrecision);
  9879. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  9880. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  9881. QSpinBox*fixedPrecisionValue= new QSpinBox;
  9882. fixedPrecisionValue->setMinimum(0);
  9883. fixedPrecisionValue->setMaximum(9);
  9884. fixedPrecisionLayout->addRow("Places after the decimal point:",
  9885. fixedPrecisionValue);
  9886. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  9887. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  9888. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  9889. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  9890. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  9891. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  9892. precisionAddress);
  9893. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  9894. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  9895. layout->addLayout(decimalSpecificationLayout);
  9896. /*724:*/
  9897. #line 15464 "./typica.w"
  9898. QDomElement referenceElement=
  9899. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9900. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9901. QDomElement node;
  9902. /*:724*/
  9903. #line 16560 "./typica.w"
  9904. for(int i= 0;i<configData.size();i++)
  9905. {
  9906. node= configData.at(i).toElement();
  9907. if(node.attribute("name")=="station")
  9908. {
  9909. stationNumber->setValue(node.attribute("value").toInt());
  9910. }
  9911. else if(node.attribute("name")=="fixedunit")
  9912. {
  9913. if(node.attribute("value")=="true")
  9914. {
  9915. fixedUnit->setCheckState(Qt::Checked);
  9916. }
  9917. else if(node.attribute("value")=="false")
  9918. {
  9919. fixedUnit->setCheckState(Qt::Unchecked);
  9920. }
  9921. }
  9922. else if(node.attribute("name")=="fixedprecision")
  9923. {
  9924. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  9925. }
  9926. else if(node.attribute("name")=="unit")
  9927. {
  9928. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  9929. }
  9930. else if(node.attribute("name")=="unitaddress")
  9931. {
  9932. unitAddress->setValue(node.attribute("value").toInt());
  9933. }
  9934. else if(node.attribute("name")=="fvalue")
  9935. {
  9936. valueF->setValue(node.attribute("value").toInt());
  9937. }
  9938. else if(node.attribute("name")=="cvalue")
  9939. {
  9940. valueC->setValue(node.attribute("value").toInt());
  9941. }
  9942. else if(node.attribute("name")=="precisionaddress")
  9943. {
  9944. precisionAddress->setValue(node.attribute("value").toInt());
  9945. }
  9946. else if(node.attribute("name")=="precision")
  9947. {
  9948. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  9949. }
  9950. }
  9951. updateStationNumber(stationNumber->value());
  9952. updateFixedUnit(fixedUnit->isChecked());
  9953. updateFixedDecimal(fixedPrecision->isChecked());
  9954. updateUnit(fixedUnitSelector->currentText());
  9955. updateUnitAddress(unitAddress->value());
  9956. updateValueF(valueF->value());
  9957. updateValueC(valueC->value());
  9958. updatePrecisionAddress(precisionAddress->value());
  9959. updatePrecisionValue(fixedPrecisionValue->value());
  9960. connect(stationNumber,SIGNAL(valueChanged(int)),
  9961. this,SLOT(updateStationNumber(int)));
  9962. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  9963. this,SLOT(updateUnit(QString)));
  9964. connect(unitAddress,SIGNAL(valueChanged(int)),
  9965. this,SLOT(updateUnitAddress(int)));
  9966. connect(valueF,SIGNAL(valueChanged(int)),
  9967. this,SLOT(updateValueF(int)));
  9968. connect(valueC,SIGNAL(valueChanged(int)),
  9969. this,SLOT(updateValueC(int)));
  9970. connect(fixedUnit,SIGNAL(toggled(bool)),
  9971. this,SLOT(updateFixedUnit(bool)));
  9972. connect(fixedPrecision,SIGNAL(toggled(bool)),
  9973. this,SLOT(updateFixedDecimal(bool)));
  9974. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  9975. this,SLOT(updatePrecisionValue(int)));
  9976. connect(precisionAddress,SIGNAL(valueChanged(int)),
  9977. this,SLOT(updatePrecisionAddress(int)));
  9978. setLayout(layout);
  9979. }
  9980. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  9981. {
  9982. updateAttribute("station",QString("%1").arg(newStation));
  9983. }
  9984. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  9985. {
  9986. if(newFixed)
  9987. {
  9988. unitSpecificationLayout->setCurrentIndex(0);
  9989. updateAttribute("fixedunit","true");
  9990. }
  9991. else
  9992. {
  9993. unitSpecificationLayout->setCurrentIndex(1);
  9994. updateAttribute("fixedunit","false");
  9995. }
  9996. }
  9997. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  9998. {
  9999. if(newFixed)
  10000. {
  10001. decimalSpecificationLayout->setCurrentIndex(0);
  10002. updateAttribute("fixedprecision","true");
  10003. }
  10004. else
  10005. {
  10006. decimalSpecificationLayout->setCurrentIndex(1);
  10007. updateAttribute("fixedprecision","false");
  10008. }
  10009. }
  10010. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10011. {
  10012. updateAttribute("unit",newUnit);
  10013. }
  10014. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10015. {
  10016. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10017. }
  10018. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10019. {
  10020. updateAttribute("fvalue",QString("%1").arg(newValue));
  10021. }
  10022. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10023. {
  10024. updateAttribute("cvalue",QString("%1").arg(newValue));
  10025. }
  10026. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10027. {
  10028. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10029. }
  10030. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10031. {
  10032. updateAttribute("precision",QString("%1").arg(newValue));
  10033. }
  10034. /*:763*/
  10035. #line 592 "./typica.w"
  10036. /*765:*/
  10037. #line 16723 "./typica.w"
  10038. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10039. const QModelIndex&index)
  10040. :BasicDeviceConfigurationWidget(model,index)
  10041. {
  10042. QFormLayout*layout= new QFormLayout;
  10043. ShortHexSpinBox*address= new ShortHexSpinBox;
  10044. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10045. /*724:*/
  10046. #line 15464 "./typica.w"
  10047. QDomElement referenceElement=
  10048. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10049. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10050. QDomElement node;
  10051. /*:724*/
  10052. #line 16731 "./typica.w"
  10053. for(int i= 0;i<configData.size();i++)
  10054. {
  10055. node= configData.at(i).toElement();
  10056. if(node.attribute("name")=="address")
  10057. {
  10058. address->setValue(node.attribute("value").toInt());
  10059. break;
  10060. }
  10061. }
  10062. updateAddress(address->value());
  10063. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10064. setLayout(layout);
  10065. }
  10066. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10067. {
  10068. updateAttribute("address",QString("%1").arg(newAddress));
  10069. }
  10070. /*:765*/
  10071. #line 593 "./typica.w"
  10072. /*767:*/
  10073. #line 16779 "./typica.w"
  10074. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10075. const QModelIndex&index)
  10076. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10077. {
  10078. QVBoxLayout*layout= new QVBoxLayout;
  10079. QFormLayout*addressLayout= new QFormLayout;
  10080. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10081. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10082. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10083. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10084. layout->addLayout(addressLayout);
  10085. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10086. layout->addWidget(fixedRange);
  10087. QWidget*queriedRangePlaceholder= new QWidget(this);
  10088. QFormLayout*queriedRangeLayout= new QFormLayout;
  10089. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10090. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10091. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10092. lowerAddress);
  10093. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10094. upperAddress);
  10095. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10096. boundsLayout->addWidget(queriedRangePlaceholder);
  10097. QWidget*fixedRangePlaceholder= new QWidget(this);
  10098. QFormLayout*fixedRangeLayout= new QFormLayout;
  10099. QLineEdit*fixedLower= new QLineEdit;
  10100. QLineEdit*fixedUpper= new QLineEdit;
  10101. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10102. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10103. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10104. boundsLayout->addWidget(fixedRangePlaceholder);
  10105. layout->addLayout(boundsLayout);
  10106. /*724:*/
  10107. #line 15464 "./typica.w"
  10108. QDomElement referenceElement=
  10109. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10110. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10111. QDomElement node;
  10112. /*:724*/
  10113. #line 16812 "./typica.w"
  10114. for(int i= 0;i<configData.size();i++)
  10115. {
  10116. node= configData.at(i).toElement();
  10117. if(node.attribute("name")=="readaddress")
  10118. {
  10119. readAddress->setValue(node.attribute("value").toInt());
  10120. }
  10121. else if(node.attribute("name")=="writeaddress")
  10122. {
  10123. writeAddress->setValue(node.attribute("value").toInt());
  10124. }
  10125. else if(node.attribute("name")=="fixedrange")
  10126. {
  10127. if(node.attribute("value")=="true")
  10128. {
  10129. fixedRange->setCheckState(Qt::Checked);
  10130. }
  10131. else if(node.attribute("value")=="false")
  10132. {
  10133. fixedRange->setCheckState(Qt::Unchecked);
  10134. }
  10135. }
  10136. else if(node.attribute("name")=="fixedlower")
  10137. {
  10138. fixedLower->setText(node.attribute("value"));
  10139. }
  10140. else if(node.attribute("name")=="fixedupper")
  10141. {
  10142. fixedUpper->setText(node.attribute("value"));
  10143. }
  10144. else if(node.attribute("name")=="loweraddress")
  10145. {
  10146. lowerAddress->setValue(node.attribute("value").toInt());
  10147. }
  10148. else if(node.attribute("name")=="upperaddress")
  10149. {
  10150. upperAddress->setValue(node.attribute("value").toInt());
  10151. }
  10152. }
  10153. updateReadAddress(readAddress->value());
  10154. updateWriteAddress(writeAddress->value());
  10155. updateFixedRange(fixedRange->isChecked());
  10156. updateLower(fixedLower->text());
  10157. updateUpper(fixedUpper->text());
  10158. updateLowerAddress(lowerAddress->value());
  10159. updateUpperAddress(upperAddress->value());
  10160. connect(readAddress,SIGNAL(valueChanged(int)),
  10161. this,SLOT(updateReadAddress(int)));
  10162. connect(writeAddress,SIGNAL(valueChanged(int)),
  10163. this,SLOT(updateWriteAddress(int)));
  10164. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10165. connect(fixedLower,SIGNAL(textChanged(QString)),
  10166. this,SLOT(updateLower(QString)));
  10167. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10168. this,SLOT(updateUpper(QString)));
  10169. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10170. this,SLOT(updateLowerAddress(int)));
  10171. connect(upperAddress,SIGNAL(valueChanged(int)),
  10172. this,SLOT(updateUpperAddress(int)));
  10173. setLayout(layout);
  10174. }
  10175. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10176. {
  10177. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10178. }
  10179. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10180. {
  10181. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10182. }
  10183. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10184. {
  10185. if(fixed)
  10186. {
  10187. updateAttribute("fixedrange","true");
  10188. boundsLayout->setCurrentIndex(1);
  10189. }
  10190. else
  10191. {
  10192. updateAttribute("fixedrange","false");
  10193. boundsLayout->setCurrentIndex(0);
  10194. }
  10195. }
  10196. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10197. {
  10198. updateAttribute("fixedlower",lower);
  10199. }
  10200. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10201. {
  10202. updateAttribute("fixedupper",upper);
  10203. }
  10204. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10205. {
  10206. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10207. }
  10208. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10209. {
  10210. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10211. }
  10212. /*:767*/
  10213. #line 594 "./typica.w"
  10214. /*723:*/
  10215. #line 15386 "./typica.w"
  10216. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10217. :BasicDeviceConfigurationWidget(model,index)
  10218. {
  10219. QVBoxLayout*layout= new QVBoxLayout;
  10220. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10221. QMenu*deviceMenu= new QMenu;
  10222. NodeInserter*insertAction;
  10223. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10224. {
  10225. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10226. this,SLOT(insertChildNode(QString,QString)));
  10227. deviceMenu->addAction(insertAction);
  10228. }
  10229. addDeviceButton->setMenu(deviceMenu);
  10230. layout->addWidget(addDeviceButton);
  10231. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10232. QMenu*annotationMenu= new QMenu;
  10233. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10234. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10235. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10236. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10237. tr("Free Text"),
  10238. "freeannotation");
  10239. annotationMenu->addAction(basicButtonInserter);
  10240. annotationMenu->addAction(countingButtonInserter);
  10241. annotationMenu->addAction(spinBoxInserter);
  10242. annotationMenu->addAction(freeAnnotationInserter);
  10243. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10244. this,SLOT(insertChildNode(QString,QString)));
  10245. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10246. this,SLOT(insertChildNode(QString,QString)));
  10247. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10248. this,SLOT(insertChildNode(QString,QString)));
  10249. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10250. this,SLOT(insertChildNode(QString,QString)));
  10251. /*942:*/
  10252. #line 144 "./valueannotation.w"
  10253. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10254. tr("Value Annotation"),
  10255. "valueannotation");
  10256. annotationMenu->addAction(valueAnnotationInserter);
  10257. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10258. this,SLOT(insertChildNode(QString,QString)));
  10259. /*:942*/
  10260. #line 15422 "./typica.w"
  10261. addAnnotationControlButton->setMenu(annotationMenu);
  10262. layout->addWidget(addAnnotationControlButton);
  10263. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10264. QMenu*advancedMenu= new QMenu;
  10265. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10266. advancedMenu->addAction(linearsplineinserter);
  10267. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10268. advancedMenu->addAction(translationinserter);
  10269. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10270. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10271. /*868:*/
  10272. #line 258 "./rate.w"
  10273. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10274. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10275. advancedMenu->addAction(rateOfChangeInserter);
  10276. /*:868*/
  10277. #line 15433 "./typica.w"
  10278. advancedButton->setMenu(advancedMenu);
  10279. layout->addWidget(advancedButton);
  10280. QHBoxLayout*idLayout= new QHBoxLayout;
  10281. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10282. idLayout->addWidget(idLabel);
  10283. QSpinBox*id= new QSpinBox;
  10284. idLayout->addWidget(id);
  10285. layout->addLayout(idLayout);
  10286. /*724:*/
  10287. #line 15464 "./typica.w"
  10288. QDomElement referenceElement=
  10289. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10290. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10291. QDomElement node;
  10292. /*:724*/
  10293. #line 15442 "./typica.w"
  10294. for(int i= 0;i<configData.size();i++)
  10295. {
  10296. node= configData.at(i).toElement();
  10297. if(node.attribute("name")=="databaseid")
  10298. {
  10299. id->setValue(node.attribute("value").toInt());
  10300. break;
  10301. }
  10302. }
  10303. updateRoasterId(id->value());
  10304. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10305. setLayout(layout);
  10306. }
  10307. /*:723*//*725:*/
  10308. #line 15474 "./typica.w"
  10309. void RoasterConfWidget::updateRoasterId(int id)
  10310. {
  10311. updateAttribute("databaseid",QString("%1").arg(id));
  10312. }
  10313. /*:725*/
  10314. #line 595 "./typica.w"
  10315. /*771:*/
  10316. #line 16962 "./typica.w"
  10317. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10318. :BasicDeviceConfigurationWidget(model,index)
  10319. {
  10320. QFormLayout*layout= new QFormLayout;
  10321. QLineEdit*buttonTextEdit= new QLineEdit;
  10322. QLineEdit*annotationTextEdit= new QLineEdit;
  10323. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10324. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10325. /*724:*/
  10326. #line 15464 "./typica.w"
  10327. QDomElement referenceElement=
  10328. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10329. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10330. QDomElement node;
  10331. /*:724*/
  10332. #line 16971 "./typica.w"
  10333. for(int i= 0;i<configData.size();i++)
  10334. {
  10335. node= configData.at(i).toElement();
  10336. if(node.attribute("name")=="buttontext")
  10337. {
  10338. buttonTextEdit->setText(node.attribute("value"));
  10339. }
  10340. else if(node.attribute("name")=="annotationtext")
  10341. {
  10342. annotationTextEdit->setText(node.attribute("value"));
  10343. }
  10344. }
  10345. updateButtonText(buttonTextEdit->text());
  10346. updateAnnotationText(annotationTextEdit->text());
  10347. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10348. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10349. setLayout(layout);
  10350. }
  10351. /*:771*//*772:*/
  10352. #line 16993 "./typica.w"
  10353. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10354. {
  10355. updateAttribute("buttontext",text);
  10356. }
  10357. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10358. {
  10359. updateAttribute("annotationtext",text);
  10360. }
  10361. /*:772*//*775:*/
  10362. #line 17031 "./typica.w"
  10363. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10364. :BasicDeviceConfigurationWidget(model,index)
  10365. {
  10366. QFormLayout*layout= new QFormLayout;
  10367. QLineEdit*buttonTextEdit= new QLineEdit;
  10368. QLineEdit*annotationTextEdit= new QLineEdit;
  10369. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10370. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10371. /*724:*/
  10372. #line 15464 "./typica.w"
  10373. QDomElement referenceElement=
  10374. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10375. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10376. QDomElement node;
  10377. /*:724*/
  10378. #line 17040 "./typica.w"
  10379. for(int i= 0;i<configData.size();i++)
  10380. {
  10381. node= configData.at(i).toElement();
  10382. if(node.attribute("name")=="buttontext")
  10383. {
  10384. buttonTextEdit->setText(node.attribute("value"));
  10385. }
  10386. else if(node.attribute("name")=="annotationtext")
  10387. {
  10388. annotationTextEdit->setText(node.attribute("value"));
  10389. }
  10390. }
  10391. updateButtonText(buttonTextEdit->text());
  10392. updateAnnotationText(annotationTextEdit->text());
  10393. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10394. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10395. QTextEdit*documentation= new QTextEdit;
  10396. 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."));
  10397. documentation->setReadOnly(true);
  10398. layout->addRow("",documentation);
  10399. setLayout(layout);
  10400. }
  10401. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10402. {
  10403. updateAttribute("buttontext",text);
  10404. }
  10405. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10406. {
  10407. updateAttribute("annotationtext",text);
  10408. }
  10409. /*:775*/
  10410. #line 596 "./typica.w"
  10411. /*778:*/
  10412. #line 17108 "./typica.w"
  10413. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10414. :BasicDeviceConfigurationWidget(model,index)
  10415. {
  10416. QFormLayout*layout= new QFormLayout;
  10417. QLineEdit*labelEdit= new QLineEdit;
  10418. layout->addRow(tr("Control Label: "),labelEdit);
  10419. QLineEdit*minimumEdit= new QLineEdit;
  10420. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10421. QLineEdit*maximumEdit= new QLineEdit;
  10422. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10423. QSpinBox*precisionEdit= new QSpinBox;
  10424. precisionEdit->setMinimum(0);
  10425. precisionEdit->setMaximum(9);
  10426. layout->addRow(tr("Precision"),precisionEdit);
  10427. QLineEdit*pretext= new QLineEdit;
  10428. layout->addRow(tr("Prefix text"),pretext);
  10429. QLineEdit*posttext= new QLineEdit;
  10430. layout->addRow(tr("Suffix text"),posttext);
  10431. /*724:*/
  10432. #line 15464 "./typica.w"
  10433. QDomElement referenceElement=
  10434. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10435. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10436. QDomElement node;
  10437. /*:724*/
  10438. #line 17127 "./typica.w"
  10439. for(int i= 0;i<configData.size();i++)
  10440. {
  10441. node= configData.at(i).toElement();
  10442. if(node.attribute("name")=="label")
  10443. {
  10444. labelEdit->setText(node.attribute("value"));
  10445. }
  10446. else if(node.attribute("name")=="minimum")
  10447. {
  10448. minimumEdit->setText(node.attribute("value"));
  10449. }
  10450. else if(node.attribute("name")=="maximum")
  10451. {
  10452. maximumEdit->setText(node.attribute("value"));
  10453. }
  10454. else if(node.attribute("name")=="precision")
  10455. {
  10456. precisionEdit->setValue(node.attribute("value").toInt());
  10457. }
  10458. else if(node.attribute("name")=="pretext")
  10459. {
  10460. pretext->setText(node.attribute("value"));
  10461. }
  10462. else if(node.attribute("name")=="posttext")
  10463. {
  10464. posttext->setText(node.attribute("value"));
  10465. }
  10466. }
  10467. updateLabel(labelEdit->text());
  10468. updateMinimum(minimumEdit->text());
  10469. updateMaximum(maximumEdit->text());
  10470. updatePrecision(precisionEdit->value());
  10471. updatePretext(pretext->text());
  10472. updatePosttext(posttext->text());
  10473. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10474. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10475. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10476. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10477. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10478. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10479. setLayout(layout);
  10480. }
  10481. void NoteSpinConfWidget::updateLabel(const QString&text)
  10482. {
  10483. updateAttribute("label",text);
  10484. }
  10485. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10486. {
  10487. updateAttribute("minimum",minimum);
  10488. }
  10489. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10490. {
  10491. updateAttribute("maximum",maximum);
  10492. }
  10493. void NoteSpinConfWidget::updatePrecision(int precision)
  10494. {
  10495. updateAttribute("precision",QString("%1").arg(precision));
  10496. }
  10497. void NoteSpinConfWidget::updatePretext(const QString&text)
  10498. {
  10499. updateAttribute("pretext",text);
  10500. }
  10501. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10502. {
  10503. updateAttribute("posttext",text);
  10504. }
  10505. /*:778*/
  10506. #line 597 "./typica.w"
  10507. /*291:*/
  10508. #line 6803 "./typica.w"
  10509. LinearCalibrator::LinearCalibrator(QObject*parent):
  10510. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10511. {
  10512. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10513. }
  10514. /*:291*//*292:*/
  10515. #line 6817 "./typica.w"
  10516. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10517. {
  10518. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10519. if(clamp)
  10520. {
  10521. if(outval<Lo1)
  10522. {
  10523. outval= Lo1;
  10524. }
  10525. else if(outval> Up1)
  10526. {
  10527. outval= Up1;
  10528. }
  10529. }
  10530. if(sensitivitySetting>=0.05)
  10531. {
  10532. int temp= qRound(outval/sensitivitySetting);
  10533. outval= temp*sensitivitySetting;
  10534. }
  10535. Measurement adjusted(outval,measure.time(),measure.scale());
  10536. emit measurement(adjusted);
  10537. return adjusted;
  10538. }
  10539. /*:292*//*293:*/
  10540. #line 6844 "./typica.w"
  10541. double LinearCalibrator::measuredLower()
  10542. {
  10543. return Lo2;
  10544. }
  10545. double LinearCalibrator::measuredUpper()
  10546. {
  10547. return Up2;
  10548. }
  10549. double LinearCalibrator::mappedLower()
  10550. {
  10551. return Lo1;
  10552. }
  10553. double LinearCalibrator::mappedUpper()
  10554. {
  10555. return Up1;
  10556. }
  10557. bool LinearCalibrator::isClosedRange()
  10558. {
  10559. return clamp;
  10560. }
  10561. void LinearCalibrator::setMeasuredLower(double lower)
  10562. {
  10563. Lo2= lower;
  10564. }
  10565. void LinearCalibrator::setMeasuredUpper(double upper)
  10566. {
  10567. Up2= upper;
  10568. }
  10569. void LinearCalibrator::setMappedLower(double lower)
  10570. {
  10571. Lo1= lower;
  10572. }
  10573. void LinearCalibrator::setMappedUpper(double upper)
  10574. {
  10575. Up1= upper;
  10576. }
  10577. void LinearCalibrator::setClosedRange(bool closed)
  10578. {
  10579. clamp= closed;
  10580. }
  10581. void LinearCalibrator::setSensitivity(double sensitivity)
  10582. {
  10583. sensitivitySetting= sensitivity;
  10584. }
  10585. double LinearCalibrator::sensitivity()
  10586. {
  10587. return sensitivitySetting;
  10588. }
  10589. /*:293*/
  10590. #line 598 "./typica.w"
  10591. /*298:*/
  10592. #line 6977 "./typica.w"
  10593. void LinearSplineInterpolator::add_pair(double source,double destination)
  10594. {
  10595. pairs->insert(source,destination);
  10596. make_interpolators();
  10597. }
  10598. void LinearSplineInterpolator::make_interpolators()
  10599. {
  10600. if(pairs->size()> 1)
  10601. {
  10602. while(interpolators->size()> 0)
  10603. {
  10604. LinearCalibrator*removed= interpolators->takeFirst();
  10605. removed->deleteLater();
  10606. }
  10607. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10608. QMap<double,double> ::const_iterator j= i+1;
  10609. while(j!=pairs->constEnd())
  10610. {
  10611. LinearCalibrator*segment= new LinearCalibrator();
  10612. segment->setMeasuredLower(i.key());
  10613. segment->setMappedLower(i.value());
  10614. segment->setMeasuredUpper(j.key());
  10615. segment->setMappedUpper(j.value());
  10616. segment->setClosedRange(false);
  10617. interpolators->append(segment);
  10618. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10619. i++;
  10620. j++;
  10621. }
  10622. }
  10623. }
  10624. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  10625. QObject(parent),pairs(new QMap<double,double> ),
  10626. interpolators(new QList<LinearCalibrator*> )
  10627. {
  10628. }
  10629. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  10630. {
  10631. QMap<double,double> ::const_iterator i= pairs->constBegin();
  10632. int index= -1;
  10633. while(i!=pairs->constEnd())
  10634. {
  10635. if(measure.temperature()<=i.key())
  10636. {
  10637. break;
  10638. }
  10639. i++;
  10640. index++;
  10641. }
  10642. if(index<0)
  10643. {
  10644. index= 0;
  10645. }
  10646. if(index>=interpolators->size())
  10647. {
  10648. index= interpolators->size()-1;
  10649. }
  10650. if(interpolators->at(index)!=NULL)
  10651. {
  10652. return interpolators->at(index)->newMeasurement(measure);
  10653. }
  10654. return Measurement();
  10655. }
  10656. /*:298*/
  10657. #line 599 "./typica.w"
  10658. /*847:*/
  10659. #line 18443 "./typica.w"
  10660. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10661. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  10662. {
  10663. QFormLayout*layout= new QFormLayout;
  10664. QLineEdit*source= new QLineEdit;
  10665. layout->addRow(tr("Source column name:"),source);
  10666. QLineEdit*destination= new QLineEdit;
  10667. layout->addRow(tr("Destination column name:"),destination);
  10668. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  10669. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  10670. QTableView*mappingTable= new QTableView;
  10671. mappingTable->setModel(tablemodel);
  10672. NumericDelegate*delegate= new NumericDelegate;
  10673. mappingTable->setItemDelegate(delegate);
  10674. layout->addRow(tr("Mapping data:"),mappingTable);
  10675. /*724:*/
  10676. #line 15464 "./typica.w"
  10677. QDomElement referenceElement=
  10678. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10679. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10680. QDomElement node;
  10681. /*:724*/
  10682. #line 18459 "./typica.w"
  10683. for(int i= 0;i<configData.size();i++)
  10684. {
  10685. node= configData.at(i).toElement();
  10686. if(node.attribute("name")=="source")
  10687. {
  10688. source->setText(node.attribute("value"));
  10689. }
  10690. else if(node.attribute("name")=="destination")
  10691. {
  10692. destination->setText(node.attribute("value"));
  10693. }
  10694. else if(node.attribute("name")=="sourcevalues")
  10695. {
  10696. /*848:*/
  10697. #line 18498 "./typica.w"
  10698. QString data= node.attribute("value");
  10699. if(data.length()> 3)
  10700. {
  10701. data.chop(2);
  10702. data= data.remove(0,2);
  10703. }
  10704. QStringList itemList= data.split(",");
  10705. /*:848*/
  10706. #line 18473 "./typica.w"
  10707. int column= 0;
  10708. /*849:*/
  10709. #line 18510 "./typica.w"
  10710. for(int i= 0;i<itemList.size();i++)
  10711. {
  10712. tablemodel->setData(tablemodel->index(i,column),
  10713. QVariant(itemList.at(i).toDouble()),
  10714. Qt::DisplayRole);
  10715. }
  10716. /*:849*/
  10717. #line 18475 "./typica.w"
  10718. }
  10719. else if(node.attribute("name")=="destinationvalues")
  10720. {
  10721. /*848:*/
  10722. #line 18498 "./typica.w"
  10723. QString data= node.attribute("value");
  10724. if(data.length()> 3)
  10725. {
  10726. data.chop(2);
  10727. data= data.remove(0,2);
  10728. }
  10729. QStringList itemList= data.split(",");
  10730. /*:848*/
  10731. #line 18480 "./typica.w"
  10732. int column= 1;
  10733. /*849:*/
  10734. #line 18510 "./typica.w"
  10735. for(int i= 0;i<itemList.size();i++)
  10736. {
  10737. tablemodel->setData(tablemodel->index(i,column),
  10738. QVariant(itemList.at(i).toDouble()),
  10739. Qt::DisplayRole);
  10740. }
  10741. /*:849*/
  10742. #line 18482 "./typica.w"
  10743. }
  10744. }
  10745. updateSourceColumn(source->text());
  10746. updateDestinationColumn(destination->text());
  10747. updateKnots();
  10748. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  10749. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  10750. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  10751. setLayout(layout);
  10752. }
  10753. /*:847*//*850:*/
  10754. #line 18521 "./typica.w"
  10755. void LinearSplineInterpolationConfWidget::updateKnots()
  10756. {
  10757. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  10758. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  10759. }
  10760. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  10761. {
  10762. updateAttribute("source",source);
  10763. }
  10764. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  10765. {
  10766. updateAttribute("destination",dest);
  10767. }
  10768. /*:850*/
  10769. #line 600 "./typica.w"
  10770. /*853:*/
  10771. #line 18564 "./typica.w"
  10772. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10773. :BasicDeviceConfigurationWidget(model,index),
  10774. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  10775. {
  10776. unitSelector->addItem("Fahrenheit");
  10777. unitSelector->addItem("Celsius");
  10778. temperatureValue->setMinimum(0);
  10779. temperatureValue->setMaximum(1000);
  10780. QFormLayout*layout= new QFormLayout;
  10781. QLineEdit*column= new QLineEdit;
  10782. layout->addRow(tr("Column to match:"),column);
  10783. layout->addRow(tr("Unit:"),unitSelector);
  10784. layout->addRow(tr("Value:"),temperatureValue);
  10785. /*724:*/
  10786. #line 15464 "./typica.w"
  10787. QDomElement referenceElement=
  10788. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10789. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10790. QDomElement node;
  10791. /*:724*/
  10792. #line 18578 "./typica.w"
  10793. for(int i= 0;i<configData.size();i++)
  10794. {
  10795. node= configData.at(i).toElement();
  10796. if(node.attribute("name")=="column")
  10797. {
  10798. column->setText(node.attribute("value"));
  10799. }
  10800. else if(node.attribute("name")=="unit")
  10801. {
  10802. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  10803. }
  10804. else if(node.attribute("name")=="value")
  10805. {
  10806. temperatureValue->setValue(node.attribute("value").toDouble());
  10807. }
  10808. }
  10809. updateMatchingColumn(column->text());
  10810. updateTemperature();
  10811. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  10812. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  10813. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  10814. setLayout(layout);
  10815. }
  10816. /*:853*//*854:*/
  10817. #line 18607 "./typica.w"
  10818. void TranslationConfWidget::updateTemperature()
  10819. {
  10820. updateAttribute("unit",unitSelector->currentText());
  10821. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  10822. if(unitSelector->currentText()=="Fahrenheit")
  10823. {
  10824. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  10825. }
  10826. else
  10827. {
  10828. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  10829. }
  10830. }
  10831. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  10832. {
  10833. updateAttribute("column",column);
  10834. }
  10835. /*:854*/
  10836. #line 601 "./typica.w"
  10837. /*781:*/
  10838. #line 24 "./freeannotation.w"
  10839. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  10840. const QModelIndex&index)
  10841. :BasicDeviceConfigurationWidget(model,index)
  10842. {
  10843. QFormLayout*layout= new QFormLayout;
  10844. QLineEdit*labelEdit= new QLineEdit;
  10845. layout->addRow(tr("Label Text:"),labelEdit);
  10846. /*724:*/
  10847. #line 15464 "./typica.w"
  10848. QDomElement referenceElement=
  10849. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10850. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10851. QDomElement node;
  10852. /*:724*/
  10853. #line 32 "./freeannotation.w"
  10854. for(int i= 0;i<configData.size();i++)
  10855. {
  10856. node= configData.at(i).toElement();
  10857. if(node.attribute("name")=="labeltext")
  10858. {
  10859. labelEdit->setText(node.attribute("value"));
  10860. }
  10861. }
  10862. updateLabel(labelEdit->text());
  10863. connect(labelEdit,SIGNAL(textEdited(QString)),
  10864. this,SLOT(updateLabel(QString)));
  10865. setLayout(layout);
  10866. }
  10867. /*:781*//*782:*/
  10868. #line 49 "./freeannotation.w"
  10869. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  10870. {
  10871. updateAttribute("labeltext",text);
  10872. }
  10873. /*:782*/
  10874. #line 602 "./typica.w"
  10875. /*857:*/
  10876. #line 39 "./rate.w"
  10877. void RateOfChange::newMeasurement(Measurement measure)
  10878. {
  10879. cache.append(measure);
  10880. /*858:*/
  10881. #line 64 "./rate.w"
  10882. if(cache.size()> 2)
  10883. {
  10884. bool done= false;
  10885. while(!done)
  10886. {
  10887. if(cache.front().time().secsTo(cache.back().time())> ct)
  10888. {
  10889. cache.removeFirst();
  10890. }
  10891. else if(cache.back().time()<cache.front().time())
  10892. {
  10893. cache.removeFirst();
  10894. done= true;
  10895. }
  10896. else
  10897. {
  10898. done= true;
  10899. }
  10900. if(cache.size()<3)
  10901. {
  10902. done= true;
  10903. }
  10904. }
  10905. }
  10906. /*:858*/
  10907. #line 43 "./rate.w"
  10908. if(cache.size()>=2)
  10909. {
  10910. /*859:*/
  10911. #line 96 "./rate.w"
  10912. int N= cache.size();
  10913. double SXY= 0;
  10914. double SX= 0;
  10915. double SXX= 0;
  10916. double SY= 0;
  10917. double y;
  10918. double x;
  10919. for(int i= 0;i<N;i++)
  10920. {
  10921. y= cache.at(i).temperature();
  10922. SY+= y;
  10923. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  10924. SX+= x;
  10925. SXX+= (x*x);
  10926. SXY+= (x*y);
  10927. }
  10928. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  10929. Measurement value(M*st,cache.back().time(),cache.back().scale());
  10930. value.insert("relative",true);
  10931. emit newData(value);
  10932. /*:859*/
  10933. #line 46 "./rate.w"
  10934. }
  10935. }
  10936. /*:857*//*860:*/
  10937. #line 120 "./rate.w"
  10938. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  10939. {
  10940. setScaleTime(scaletime);
  10941. }
  10942. void RateOfChange::setCacheTime(int seconds)
  10943. {
  10944. ct= seconds;
  10945. }
  10946. void RateOfChange::setScaleTime(int seconds)
  10947. {
  10948. st= (seconds> 0?seconds:1);
  10949. }
  10950. /*:860*/
  10951. #line 603 "./typica.w"
  10952. /*785:*/
  10953. #line 26 "./settings.w"
  10954. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  10955. {
  10956. QTabWidget*settingsTab= new QTabWidget;
  10957. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  10958. settingsTab->addTab(deviceSettings,tr("Roasters"));
  10959. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  10960. settingsTab->addTab(graphSettings,tr("Graph"));
  10961. setCentralWidget(settingsTab);
  10962. }
  10963. /*:785*/
  10964. #line 604 "./typica.w"
  10965. /*790:*/
  10966. #line 27 "./graphsettings.w"
  10967. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  10968. {
  10969. QTabWidget*graphCategories= new QTabWidget;
  10970. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  10971. graphCategories->addTab(relative,tr("Relative Temperatures"));
  10972. QVBoxLayout*layout= new QVBoxLayout;
  10973. layout->addWidget(graphCategories);
  10974. setLayout(layout);
  10975. }
  10976. /*:790*//*792:*/
  10977. #line 65 "./graphsettings.w"
  10978. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  10979. colorEdit(new QLineEdit)
  10980. {
  10981. QSettings settings;
  10982. QVBoxLayout*layout= new QVBoxLayout;
  10983. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  10984. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  10985. updateEnableSetting(enable->isChecked());
  10986. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  10987. layout->addWidget(enable);
  10988. QHBoxLayout*colorLayout= new QHBoxLayout;
  10989. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  10990. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  10991. updateColorSetting(colorEdit->text());
  10992. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  10993. QToolButton*colorPickerButton= new QToolButton();
  10994. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  10995. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  10996. colorLayout->addWidget(colorLabel);
  10997. colorLayout->addWidget(colorEdit);
  10998. colorLayout->addWidget(colorPickerButton);
  10999. colorLayout->addStretch();
  11000. layout->addLayout(colorLayout);
  11001. QHBoxLayout*unitLayout= new QHBoxLayout;
  11002. QLabel*unitLabel= new QLabel(tr("Unit"));
  11003. QComboBox*unitSelector= new QComboBox;
  11004. unitSelector->addItem(tr("Fahrenheit"));
  11005. unitSelector->addItem(tr("Celsius"));
  11006. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11007. updateUnit(unitSelector->currentIndex());
  11008. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11009. unitLayout->addWidget(unitLabel);
  11010. unitLayout->addWidget(unitSelector);
  11011. unitLayout->addStretch();
  11012. layout->addLayout(unitLayout);
  11013. QHBoxLayout*axisLayout= new QHBoxLayout;
  11014. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11015. QLineEdit*axisEdit= new QLineEdit;
  11016. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11017. updateAxisSetting(axisEdit->text());
  11018. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11019. axisLayout->addWidget(axisLabel);
  11020. axisLayout->addWidget(axisEdit);
  11021. layout->addLayout(axisLayout);
  11022. layout->addStretch();
  11023. setLayout(layout);
  11024. }
  11025. /*:792*//*793:*/
  11026. #line 116 "./graphsettings.w"
  11027. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11028. {
  11029. QSettings settings;
  11030. settings.setValue("settings/graph/relative/enable",enabled);
  11031. }
  11032. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11033. {
  11034. QSettings settings;
  11035. settings.setValue("settings/graph/relative/color",color);
  11036. }
  11037. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11038. {
  11039. QSettings settings;
  11040. QString settingValue;
  11041. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11042. QStringList numbers;
  11043. foreach(QString text,points)
  11044. {
  11045. bool okay= false;
  11046. text.toDouble(&okay);
  11047. if(okay)
  11048. {
  11049. numbers.append(text);
  11050. }
  11051. }
  11052. numbers.removeDuplicates();
  11053. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11054. }
  11055. void GraphSettingsRelativeTab::updateUnit(int unit)
  11056. {
  11057. QSettings settings;
  11058. settings.setValue("settings/graph/relative/unit",unit);
  11059. }
  11060. /*:793*//*794:*/
  11061. #line 159 "./graphsettings.w"
  11062. void GraphSettingsRelativeTab::showColorPicker()
  11063. {
  11064. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11065. colorEdit->setText(color.name());
  11066. }
  11067. #line 17209 "./typica.w"
  11068. /*:794*/
  11069. #line 605 "./typica.w"
  11070. /*892:*/
  11071. #line 682 "./dataqsdk.w"
  11072. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11073. const QModelIndex&index)
  11074. :BasicDeviceConfigurationWidget(model,index),
  11075. deviceIdStack(new QStackedWidget)
  11076. {
  11077. QVBoxLayout*layout= new QVBoxLayout;
  11078. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11079. layout->addWidget(autoDetect);
  11080. QWidget*autoLayerWidget= new QWidget;
  11081. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11082. QLabel*autoLabel= new QLabel(tr("Device number"));
  11083. QSpinBox*autoNumber= new QSpinBox;
  11084. autoNumber->setMinimum(1);
  11085. autoNumber->setMaximum(99);
  11086. autoLayerLayout->addWidget(autoLabel);
  11087. autoLayerLayout->addWidget(autoNumber);
  11088. autoLayerWidget->setLayout(autoLayerLayout);
  11089. QWidget*fixedLayerWidget= new QWidget;
  11090. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11091. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11092. QComboBox*portSelection= new QComboBox;
  11093. portSelection->setEditable(true);
  11094. portSelection->addItems(DataqSdkDevice::detectHardware());
  11095. fixedLayerLayout->addWidget(fixedLabel);
  11096. fixedLayerLayout->addWidget(portSelection);
  11097. fixedLayerWidget->setLayout(fixedLayerLayout);
  11098. deviceIdStack->addWidget(autoLayerWidget);
  11099. deviceIdStack->addWidget(fixedLayerWidget);
  11100. layout->addWidget(deviceIdStack);
  11101. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11102. layout->addWidget(addChannelButton);
  11103. /*724:*/
  11104. #line 15464 "./typica.w"
  11105. QDomElement referenceElement=
  11106. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11107. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11108. QDomElement node;
  11109. /*:724*/
  11110. #line 714 "./dataqsdk.w"
  11111. for(int i= 0;i<configData.size();i++)
  11112. {
  11113. node= configData.at(i).toElement();
  11114. if(node.attribute("name")=="autoSelect")
  11115. {
  11116. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11117. }
  11118. else if(node.attribute("name")=="deviceNumber")
  11119. {
  11120. autoNumber->setValue(node.attribute("value").toInt());
  11121. }
  11122. else if(node.attribute("name")=="port")
  11123. {
  11124. int index= portSelection->findText(node.attribute("value"));
  11125. if(index> -1)
  11126. {
  11127. portSelection->setCurrentIndex(index);
  11128. }
  11129. else
  11130. {
  11131. portSelection->setEditText(node.attribute("value"));
  11132. }
  11133. }
  11134. }
  11135. updateAutoSelect(autoDetect->isChecked());
  11136. updateDeviceNumber(autoNumber->value());
  11137. updatePort(portSelection->currentText());
  11138. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11139. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11140. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11141. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11142. setLayout(layout);
  11143. }
  11144. /*:892*//*893:*/
  11145. #line 758 "./dataqsdk.w"
  11146. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11147. {
  11148. if(automatic)
  11149. {
  11150. updateAttribute("autoSelect","true");
  11151. deviceIdStack->setCurrentIndex(0);
  11152. }
  11153. else
  11154. {
  11155. updateAttribute("autoSelect","false");
  11156. deviceIdStack->setCurrentIndex(1);
  11157. }
  11158. }
  11159. /*:893*//*894:*/
  11160. #line 775 "./dataqsdk.w"
  11161. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11162. {
  11163. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11164. }
  11165. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11166. {
  11167. updateAttribute("port",portId);
  11168. }
  11169. /*:894*//*895:*/
  11170. #line 788 "./dataqsdk.w"
  11171. void DataqSdkDeviceConfWidget::addChannel()
  11172. {
  11173. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11174. }
  11175. /*:895*//*898:*/
  11176. #line 868 "./dataqsdk.w"
  11177. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11178. const QModelIndex&index)
  11179. :BasicDeviceConfigurationWidget(model,index),
  11180. startButton(new QPushButton(tr("Start"))),
  11181. resetButton(new QPushButton(tr("Reset"))),
  11182. stopButton(new QPushButton(tr("Stop"))),
  11183. calibrator(new LinearCalibrator),
  11184. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11185. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11186. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11187. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11188. rmCount(0),cmCount(0),
  11189. rmin(std::numeric_limits<double> ::max()),
  11190. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11191. cmin(std::numeric_limits<double> ::max()),
  11192. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11193. {
  11194. /*902:*/
  11195. #line 1107 "./dataqsdk.w"
  11196. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11197. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11198. QDomElement deviceNode;
  11199. QString configPort;
  11200. QString configAuto;
  11201. for(int i= 0;i<deviceConfigData.size();i++)
  11202. {
  11203. deviceNode= deviceConfigData.at(i).toElement();
  11204. if(deviceNode.attribute("name")=="autoSelect")
  11205. {
  11206. autoSelect= (deviceNode.attribute("value")=="true");
  11207. }
  11208. else if(deviceNode.attribute("name")=="deviceNumber")
  11209. {
  11210. configAuto= deviceNode.attribute("value");
  11211. }
  11212. else if(deviceNode.attribute("name")=="port")
  11213. {
  11214. configPort= deviceNode.attribute("value");
  11215. }
  11216. }
  11217. deviceID= autoSelect?configAuto:configPort;
  11218. channelOfInterest= index.row();
  11219. /*:902*/
  11220. #line 886 "./dataqsdk.w"
  11221. resetButton->setEnabled(false);
  11222. stopButton->setEnabled(false);
  11223. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11224. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11225. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11226. QVBoxLayout*layout= new QVBoxLayout;
  11227. QFormLayout*topLayout= new QFormLayout;
  11228. QLineEdit*columnEdit= new QLineEdit;
  11229. topLayout->addRow(tr("Column name"),columnEdit);
  11230. QComboBox*unitSelector= new QComboBox;
  11231. unitSelector->addItem(tr("Temperature"));
  11232. unitSelector->addItem(tr("Control"));
  11233. topLayout->addRow(tr("Measurement type"),unitSelector);
  11234. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11235. topLayout->addRow(smoothingBox);
  11236. layout->addLayout(topLayout);
  11237. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11238. topLayout->addRow(hideSeries);
  11239. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11240. layout->addWidget(calibrationLabel);
  11241. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11242. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11243. QLineEdit*measuredLowerEdit= new QLineEdit;
  11244. measuredLowerEdit->setText("0");
  11245. QLineEdit*measuredUpperEdit= new QLineEdit;
  11246. measuredUpperEdit->setText("10");
  11247. QLineEdit*mappedLowerEdit= new QLineEdit;
  11248. mappedLowerEdit->setText("0");
  11249. QLineEdit*mappedUpperEdit= new QLineEdit;
  11250. mappedUpperEdit->setText("10");
  11251. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11252. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11253. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11254. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11255. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11256. calibrationControlsLayout->addRow(closedBox);
  11257. QLineEdit*sensitivityEdit= new QLineEdit;
  11258. sensitivityEdit->setText("0");
  11259. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11260. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11261. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11262. deviceControlLayout->addWidget(startButton);
  11263. deviceControlLayout->addWidget(resetButton);
  11264. deviceControlLayout->addWidget(stopButton);
  11265. QFormLayout*indicatorLayout= new QFormLayout;
  11266. currentMeasurement->setReadOnly(true);
  11267. minimumMeasurement->setReadOnly(true);
  11268. maximumMeasurement->setReadOnly(true);
  11269. averageMeasurement->setReadOnly(true);
  11270. currentMapped->setReadOnly(true);
  11271. minimumMapped->setReadOnly(true);
  11272. maximumMapped->setReadOnly(true);
  11273. averageMapped->setReadOnly(true);
  11274. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11275. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11276. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11277. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11278. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11279. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11280. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11281. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11282. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11283. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11284. calibrationTestLayout->addLayout(deviceControlLayout);
  11285. calibrationTestLayout->addLayout(indicatorLayout);
  11286. calibrationLayout->addLayout(calibrationControlsLayout);
  11287. calibrationLayout->addLayout(calibrationTestLayout);
  11288. layout->addLayout(calibrationLayout);
  11289. /*724:*/
  11290. #line 15464 "./typica.w"
  11291. QDomElement referenceElement=
  11292. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11293. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11294. QDomElement node;
  11295. /*:724*/
  11296. #line 955 "./dataqsdk.w"
  11297. for(int i= 0;i<configData.size();i++)
  11298. {
  11299. node= configData.at(i).toElement();
  11300. if(node.attribute("name")=="column")
  11301. {
  11302. columnEdit->setText(node.attribute("value"));
  11303. }
  11304. else if(node.attribute("name")=="type")
  11305. {
  11306. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11307. }
  11308. else if(node.attribute("name")=="smoothing")
  11309. {
  11310. smoothingBox->setChecked(node.attribute("value")=="true");
  11311. }
  11312. else if(node.attribute("name")=="calibrationMeasuredLower")
  11313. {
  11314. measuredLowerEdit->setText(node.attribute("value"));
  11315. }
  11316. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11317. {
  11318. measuredUpperEdit->setText(node.attribute("value"));
  11319. }
  11320. else if(node.attribute("name")=="calibrationMappedLower")
  11321. {
  11322. mappedLowerEdit->setText(node.attribute("value"));
  11323. }
  11324. else if(node.attribute("name")=="calibrationMappedUpper")
  11325. {
  11326. mappedUpperEdit->setText(node.attribute("value"));
  11327. }
  11328. else if(node.attribute("name")=="calibrationClosedInterval")
  11329. {
  11330. closedBox->setChecked(node.attribute("value")=="true");
  11331. }
  11332. else if(node.attribute("name")=="calibrationSensitivity")
  11333. {
  11334. sensitivityEdit->setText(node.attribute("value"));
  11335. }
  11336. else if(node.attribute("name")=="hidden")
  11337. {
  11338. hideSeries->setChecked(node.attribute("value")=="true");
  11339. }
  11340. }
  11341. updateColumnName(columnEdit->text());
  11342. updateUnits(unitSelector->currentText());
  11343. updateSmoothingEnabled(smoothingBox->isChecked());
  11344. updateMeasuredLower(measuredLowerEdit->text());
  11345. updateMeasuredUpper(measuredUpperEdit->text());
  11346. updateMappedLower(mappedLowerEdit->text());
  11347. updateMappedUpper(mappedUpperEdit->text());
  11348. updateClosedInterval(closedBox->isChecked());
  11349. updateSensitivity(sensitivityEdit->text());
  11350. updateHidden(hideSeries->isChecked());
  11351. connect(columnEdit,SIGNAL(textChanged(QString)),
  11352. this,SLOT(updateColumnName(QString)));
  11353. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11354. this,SLOT(updateUnits(QString)));
  11355. connect(smoothingBox,SIGNAL(toggled(bool)),
  11356. this,SLOT(updateSmoothingEnabled(bool)));
  11357. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11358. this,SLOT(updateMeasuredLower(QString)));
  11359. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11360. this,SLOT(updateMappedLower(QString)));
  11361. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11362. this,SLOT(updateMeasuredUpper(QString)));
  11363. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11364. this,SLOT(updateMappedUpper(QString)));
  11365. connect(closedBox,SIGNAL(toggled(bool)),
  11366. this,SLOT(updateClosedInterval(bool)));
  11367. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11368. this,SLOT(updateSensitivity(QString)));
  11369. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11370. setLayout(layout);
  11371. }
  11372. /*:898*//*899:*/
  11373. #line 1038 "./dataqsdk.w"
  11374. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11375. {
  11376. updateAttribute("type",unit);
  11377. }
  11378. /*:899*//*900:*/
  11379. #line 1047 "./dataqsdk.w"
  11380. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11381. {
  11382. updateAttribute("calibrationMeasuredLower",value);
  11383. calibrator->setMeasuredLower(value.toDouble());
  11384. }
  11385. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11386. {
  11387. updateAttribute("calibrationMeasuredUpper",value);
  11388. calibrator->setMeasuredUpper(value.toDouble());
  11389. }
  11390. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11391. {
  11392. updateAttribute("calibrationMappedLower",value);
  11393. calibrator->setMappedLower(value.toDouble());
  11394. }
  11395. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11396. {
  11397. updateAttribute("calibrationMappedUpper",value);
  11398. calibrator->setMappedUpper(value.toDouble());
  11399. }
  11400. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11401. {
  11402. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11403. calibrator->setClosedRange(closed);
  11404. }
  11405. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11406. {
  11407. updateAttribute("smoothing",enabled?"true":"false");
  11408. }
  11409. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11410. {
  11411. updateAttribute("calibrationSensitivity",value);
  11412. calibrator->setSensitivity(value.toDouble());
  11413. }
  11414. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11415. {
  11416. updateAttribute("hidden",hidden?"true":"false");
  11417. }
  11418. /*:900*//*903:*/
  11419. #line 1136 "./dataqsdk.w"
  11420. void DataqSdkChannelConfWidget::startCalibration()
  11421. {
  11422. startButton->setEnabled(false);
  11423. stopButton->setEnabled(true);
  11424. resetButton->setEnabled(true);
  11425. calibrationDevice= new DataqSdkDevice(deviceID);
  11426. Channel*channel;
  11427. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11428. {
  11429. channel= calibrationDevice->newChannel(Units::Unitless);
  11430. }
  11431. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11432. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11433. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11434. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11435. calibrationDevice->start();
  11436. }
  11437. void DataqSdkChannelConfWidget::stopCalibration()
  11438. {
  11439. startButton->setEnabled(true);
  11440. stopButton->setEnabled(false);
  11441. resetButton->setEnabled(false);
  11442. calibrationDevice->deleteLater();
  11443. /*905:*/
  11444. #line 1181 "./dataqsdk.w"
  11445. rmCount= 0;
  11446. cmCount= 0;
  11447. rmin= std::numeric_limits<double> ::max();
  11448. rmax= std::numeric_limits<double> ::min();
  11449. rmean= 0;
  11450. cmin= std::numeric_limits<double> ::max();
  11451. cmax= std::numeric_limits<double> ::min();
  11452. cmean= 0;
  11453. /*:905*/
  11454. #line 1161 "./dataqsdk.w"
  11455. }
  11456. /*:903*//*904:*/
  11457. #line 1172 "./dataqsdk.w"
  11458. void DataqSdkChannelConfWidget::resetCalibration()
  11459. {
  11460. /*905:*/
  11461. #line 1181 "./dataqsdk.w"
  11462. rmCount= 0;
  11463. cmCount= 0;
  11464. rmin= std::numeric_limits<double> ::max();
  11465. rmax= std::numeric_limits<double> ::min();
  11466. rmean= 0;
  11467. cmin= std::numeric_limits<double> ::max();
  11468. cmax= std::numeric_limits<double> ::min();
  11469. cmean= 0;
  11470. /*:905*/
  11471. #line 1175 "./dataqsdk.w"
  11472. }
  11473. /*:904*//*906:*/
  11474. #line 1195 "./dataqsdk.w"
  11475. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11476. {
  11477. double nv= measure.temperature();
  11478. currentMeasurement->setText(QString("%1").arg(nv));
  11479. rmin= qMin(nv,rmin);
  11480. minimumMeasurement->setText(QString("%1").arg(rmin));
  11481. rmax= qMax(nv,rmax);
  11482. maximumMeasurement->setText(QString("%1").arg(rmax));
  11483. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11484. rmCount++;
  11485. averageMeasurement->setText(QString("%1").arg(rmean));
  11486. }
  11487. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11488. {
  11489. double nv= measure.temperature();
  11490. currentMapped->setText(QString("%1").arg(nv));
  11491. cmin= qMin(nv,cmin);
  11492. minimumMapped->setText(QString("%1").arg(cmin));
  11493. cmax= qMax(nv,cmax);
  11494. maximumMapped->setText(QString("%1").arg(cmax));
  11495. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11496. cmCount++;
  11497. averageMapped->setText(QString("%1").arg(cmean));
  11498. }
  11499. /*:906*//*907:*/
  11500. #line 1224 "./dataqsdk.w"
  11501. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11502. {
  11503. updateAttribute("column",value);
  11504. }
  11505. /*:907*/
  11506. #line 606 "./typica.w"
  11507. /*931:*/
  11508. #line 393 "./scales.w"
  11509. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11510. const QModelIndex&index)
  11511. :BasicDeviceConfigurationWidget(model,index),
  11512. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11513. flow(new FlowSelector),stop(new StopSelector)
  11514. {
  11515. QFormLayout*layout= new QFormLayout;
  11516. layout->addRow(tr("Port:"),port);
  11517. connect(port,SIGNAL(currentIndexChanged(QString)),
  11518. this,SLOT(updatePort(QString)));
  11519. connect(port,SIGNAL(editTextChanged(QString)),
  11520. this,SLOT(updatePort(QString)));
  11521. layout->addRow(tr("Baud:"),baud);
  11522. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11523. this,SLOT(updateBaudRate(QString)));
  11524. layout->addRow(tr("Parity:"),parity);
  11525. connect(parity,SIGNAL(currentIndexChanged(int)),
  11526. this,SLOT(updateParity(int)));
  11527. layout->addRow(tr("Flow Control:"),flow);
  11528. connect(flow,SIGNAL(currentIndexChanged(int)),
  11529. this,SLOT(updateFlowControl(int)));
  11530. layout->addRow(tr("Stop Bits:"),stop);
  11531. connect(stop,SIGNAL(currentIndexChanged(int)),
  11532. this,SLOT(updateStopBits(int)));
  11533. /*724:*/
  11534. #line 15464 "./typica.w"
  11535. QDomElement referenceElement=
  11536. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11537. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11538. QDomElement node;
  11539. /*:724*/
  11540. #line 418 "./scales.w"
  11541. for(int i= 0;i<configData.size();i++)
  11542. {
  11543. node= configData.at(i).toElement();
  11544. if(node.attribute("name")=="port")
  11545. {
  11546. int j= port->findText(node.attribute("value"));
  11547. if(j>=0)
  11548. {
  11549. port->setCurrentIndex(j);
  11550. }
  11551. else
  11552. {
  11553. port->insertItem(0,node.attribute("value"));
  11554. port->setCurrentIndex(0);
  11555. }
  11556. }
  11557. else if(node.attribute("name")=="baudrate")
  11558. {
  11559. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11560. }
  11561. else if(node.attribute("name")=="parity")
  11562. {
  11563. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11564. }
  11565. else if(node.attribute("name")=="flowcontrol")
  11566. {
  11567. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  11568. }
  11569. else if(node.attribute("name")=="stopbits")
  11570. {
  11571. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  11572. }
  11573. }
  11574. updatePort(port->currentText());
  11575. updateBaudRate(baud->currentText());
  11576. updateParity(parity->currentIndex());
  11577. updateFlowControl(flow->currentIndex());
  11578. updateStopBits(stop->currentIndex());
  11579. setLayout(layout);
  11580. }
  11581. /*:931*//*932:*/
  11582. #line 462 "./scales.w"
  11583. void SerialScaleConfWidget::updatePort(const QString&newPort)
  11584. {
  11585. updateAttribute("port",newPort);
  11586. }
  11587. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  11588. {
  11589. updateAttribute("baudrate",rate);
  11590. }
  11591. void SerialScaleConfWidget::updateParity(int index)
  11592. {
  11593. updateAttribute("parity",parity->itemData(index).toString());
  11594. }
  11595. void SerialScaleConfWidget::updateFlowControl(int index)
  11596. {
  11597. updateAttribute("flowcontrol",flow->itemData(index).toString());
  11598. }
  11599. void SerialScaleConfWidget::updateStopBits(int index)
  11600. {
  11601. updateAttribute("stopbits",stop->itemData(index).toString());
  11602. }
  11603. /*:932*/
  11604. #line 607 "./typica.w"
  11605. /*944:*/
  11606. #line 195 "./valueannotation.w"
  11607. void ValueAnnotation::newMeasurement(Measurement measure)
  11608. {
  11609. for(int i= 0;i<values.size();i++)
  11610. {
  11611. if(measure.temperature()> values.at(i)-tolerance&&
  11612. measure.temperature()<values.at(i)+tolerance)
  11613. {
  11614. if(i!=lastIndex)
  11615. {
  11616. lastIndex= i;
  11617. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  11618. }
  11619. }
  11620. }
  11621. }
  11622. /*:944*//*945:*/
  11623. #line 216 "./valueannotation.w"
  11624. void ValueAnnotation::annotate()
  11625. {
  11626. if(lastIndex> -1)
  11627. {
  11628. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  11629. }
  11630. }
  11631. /*:945*//*946:*/
  11632. #line 228 "./valueannotation.w"
  11633. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  11634. {
  11635. values.append(value);
  11636. annotations.append(annotation);
  11637. }
  11638. /*:946*//*947:*/
  11639. #line 237 "./valueannotation.w"
  11640. void ValueAnnotation::setAnnotationColumn(int column)
  11641. {
  11642. annotationColumn= column;
  11643. }
  11644. void ValueAnnotation::setTemperatureColumn(int column)
  11645. {
  11646. measurementColumn= column;
  11647. }
  11648. void ValueAnnotation::setTolerance(double epsilon)
  11649. {
  11650. tolerance= epsilon;
  11651. }
  11652. /*:947*//*948:*/
  11653. #line 255 "./valueannotation.w"
  11654. ValueAnnotation::ValueAnnotation():QObject(),
  11655. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  11656. {
  11657. }
  11658. /*:948*/
  11659. #line 608 "./typica.w"
  11660. /*936:*/
  11661. #line 33 "./valueannotation.w"
  11662. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  11663. const QModelIndex&index)
  11664. :BasicDeviceConfigurationWidget(model,index),
  11665. tablemodel(new SaltModel(2))
  11666. {
  11667. QFormLayout*layout= new QFormLayout;
  11668. QLineEdit*source= new QLineEdit;
  11669. layout->addRow(tr("Source column name:"),source);
  11670. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  11671. noteOnStart->setChecked(true);
  11672. layout->addRow(noteOnStart);
  11673. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  11674. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  11675. QTableView*annotationTable= new QTableView;
  11676. annotationTable->setModel(tablemodel);
  11677. NumericDelegate*delegate= new NumericDelegate;
  11678. annotationTable->setItemDelegateForColumn(0,delegate);
  11679. layout->addRow(tr("Annotations for values:"),annotationTable);
  11680. /*724:*/
  11681. #line 15464 "./typica.w"
  11682. QDomElement referenceElement=
  11683. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11684. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11685. QDomElement node;
  11686. /*:724*/
  11687. #line 52 "./valueannotation.w"
  11688. for(int i= 0;i<configData.size();i++)
  11689. {
  11690. node= configData.at(i).toElement();
  11691. if(node.attribute("name")=="source")
  11692. {
  11693. source->setText(node.attribute("value"));
  11694. }
  11695. else if(node.attribute("name")=="emitOnStart")
  11696. {
  11697. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  11698. }
  11699. else if(node.attribute("name")=="measuredValues")
  11700. {
  11701. /*848:*/
  11702. #line 18498 "./typica.w"
  11703. QString data= node.attribute("value");
  11704. if(data.length()> 3)
  11705. {
  11706. data.chop(2);
  11707. data= data.remove(0,2);
  11708. }
  11709. QStringList itemList= data.split(",");
  11710. /*:848*/
  11711. #line 66 "./valueannotation.w"
  11712. int column= 0;
  11713. /*849:*/
  11714. #line 18510 "./typica.w"
  11715. for(int i= 0;i<itemList.size();i++)
  11716. {
  11717. tablemodel->setData(tablemodel->index(i,column),
  11718. QVariant(itemList.at(i).toDouble()),
  11719. Qt::DisplayRole);
  11720. }
  11721. /*:849*/
  11722. #line 68 "./valueannotation.w"
  11723. }
  11724. else if(node.attribute("name")=="annotations")
  11725. {
  11726. /*937:*/
  11727. #line 89 "./valueannotation.w"
  11728. QString data= node.attribute("value");
  11729. if(data.length()> 3)
  11730. {
  11731. data.chop(2);
  11732. data= data.remove(0,2);
  11733. }
  11734. QStringList itemList= data.split(",");
  11735. for(int i= 0;i<itemList.size();i++)
  11736. {
  11737. itemList[i]= itemList[i].simplified();
  11738. }
  11739. /*:937*/
  11740. #line 72 "./valueannotation.w"
  11741. int column= 1;
  11742. /*938:*/
  11743. #line 104 "./valueannotation.w"
  11744. for(int i= 0;i<itemList.size();i++)
  11745. {
  11746. tablemodel->setData(tablemodel->index(i,column),
  11747. QVariant(itemList.at(i)),
  11748. Qt::DisplayRole);
  11749. }
  11750. /*:938*/
  11751. #line 74 "./valueannotation.w"
  11752. }
  11753. }
  11754. updateSourceColumn(source->text());
  11755. updateStart(noteOnStart->isChecked());
  11756. updateAnnotations();
  11757. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11758. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  11759. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  11760. setLayout(layout);
  11761. }
  11762. /*:936*//*939:*/
  11763. #line 115 "./valueannotation.w"
  11764. void ValueAnnotationConfWidget::updateAnnotations()
  11765. {
  11766. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11767. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11768. }
  11769. /*:939*//*940:*/
  11770. #line 125 "./valueannotation.w"
  11771. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  11772. {
  11773. updateAttribute("source",source);
  11774. }
  11775. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  11776. {
  11777. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  11778. }
  11779. /*:940*/
  11780. #line 609 "./typica.w"
  11781. /*:4*//*840:*/
  11782. #line 639 "./unsupportedserial.w"
  11783. /*815:*/
  11784. #line 58 "./unsupportedserial.w"
  11785. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  11786. const QModelIndex&index)
  11787. :BasicDeviceConfigurationWidget(model,index),
  11788. deviceSettingsModel(new SaltModel(2)),
  11789. scriptEditor(new QTextEdit)
  11790. {
  11791. scriptEditor->setTabStopWidth(20);
  11792. QVBoxLayout*dummyLayout= new QVBoxLayout;
  11793. QTabWidget*central= new QTabWidget;
  11794. QWidget*deviceConfigurationWidget= new QWidget;
  11795. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  11796. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11797. deviceConfigurationLayout->addWidget(addChannelButton);
  11798. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11799. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  11800. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  11801. QTableView*deviceSettingsView= new QTableView;
  11802. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  11803. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  11804. deviceSettingsView->setModel(deviceSettingsModel);
  11805. deviceConfigurationLayout->addWidget(deviceSettingsView);
  11806. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  11807. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  11808. central->addTab(scriptEditor,tr("Script"));
  11809. dummyLayout->addWidget(central);
  11810. /*724:*/
  11811. #line 15464 "./typica.w"
  11812. QDomElement referenceElement=
  11813. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11814. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11815. QDomElement node;
  11816. /*:724*/
  11817. #line 86 "./unsupportedserial.w"
  11818. for(int i= 0;i<configData.size();i++)
  11819. {
  11820. node= configData.at(i).toElement();
  11821. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  11822. {
  11823. int column= 0;
  11824. if(node.attribute("name")=="values")
  11825. {
  11826. column= 1;
  11827. }
  11828. QString data= node.attribute("value");
  11829. if(data.length()> 3)
  11830. {
  11831. data.chop(2);
  11832. data= data.remove(0,2);
  11833. }
  11834. QStringList keyList= data.split(", ");
  11835. for(int j= 0;j<keyList.size();j++)
  11836. {
  11837. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  11838. QVariant(keyList.at(j)),
  11839. Qt::EditRole);
  11840. }
  11841. }
  11842. else if(node.attribute("name")=="script")
  11843. {
  11844. scriptEditor->setPlainText(node.attribute("value"));
  11845. }
  11846. }
  11847. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  11848. this,SLOT(updateConfiguration()));
  11849. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  11850. setLayout(dummyLayout);
  11851. }
  11852. /*:815*//*816:*/
  11853. #line 131 "./unsupportedserial.w"
  11854. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  11855. {
  11856. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  11857. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  11858. }
  11859. /*:816*//*817:*/
  11860. #line 144 "./unsupportedserial.w"
  11861. void UnsupportedSerialDeviceConfWidget::saveScript()
  11862. {
  11863. updateAttribute("script",scriptEditor->toPlainText());
  11864. }
  11865. /*:817*//*818:*/
  11866. #line 155 "./unsupportedserial.w"
  11867. void UnsupportedSerialDeviceConfWidget::addChannel()
  11868. {
  11869. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  11870. }
  11871. /*:818*//*820:*/
  11872. #line 183 "./unsupportedserial.w"
  11873. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  11874. const QModelIndex&index)
  11875. :BasicDeviceConfigurationWidget(model,index),
  11876. channelSettingsModel(new SaltModel(2))
  11877. {
  11878. QFormLayout*layout= new QFormLayout;
  11879. QLineEdit*columnName= new QLineEdit;
  11880. layout->addRow(tr("Column Name:"),columnName);
  11881. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  11882. layout->addRow(hideSeries);
  11883. QTableView*channelSettings= new QTableView;
  11884. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  11885. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  11886. channelSettings->setModel(channelSettingsModel);
  11887. layout->addRow(channelSettings);
  11888. setLayout(layout);
  11889. /*724:*/
  11890. #line 15464 "./typica.w"
  11891. QDomElement referenceElement=
  11892. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11893. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11894. QDomElement node;
  11895. /*:724*/
  11896. #line 200 "./unsupportedserial.w"
  11897. for(int i= 0;i<configData.size();i++)
  11898. {
  11899. node= configData.at(i).toElement();
  11900. if(node.attribute("name")=="columnname")
  11901. {
  11902. columnName->setText(node.attribute("value"));
  11903. }
  11904. else if(node.attribute("name")=="hidden")
  11905. {
  11906. hideSeries->setChecked(node.attribute("value")=="true");
  11907. }
  11908. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  11909. {
  11910. int column= 0;
  11911. if(node.attribute("name")=="values")
  11912. {
  11913. column= 1;
  11914. }
  11915. QString data= node.attribute("value");
  11916. if(data.length()> 3)
  11917. {
  11918. data.chop(2);
  11919. data= data.remove(0,2);
  11920. }
  11921. QStringList keyList= data.split(", ");
  11922. for(int j= 0;j<keyList.size();j++)
  11923. {
  11924. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  11925. QVariant(keyList.at(j)),
  11926. Qt::EditRole);
  11927. }
  11928. }
  11929. }
  11930. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  11931. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11932. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  11933. this,SLOT(updateConfiguration()));
  11934. }
  11935. /*:820*//*821:*/
  11936. #line 244 "./unsupportedserial.w"
  11937. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  11938. {
  11939. updateAttribute("columnname",value);
  11940. }
  11941. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  11942. {
  11943. updateAttribute("hidden",hidden?"true":"false");
  11944. }
  11945. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  11946. {
  11947. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  11948. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  11949. }
  11950. /*:821*/
  11951. #line 640 "./unsupportedserial.w"
  11952. /*828:*/
  11953. #line 371 "./unsupportedserial.w"
  11954. void JavaScriptDevice::start()
  11955. {
  11956. QScriptValue object= scriptengine->newQObject(this);
  11957. /*829:*/
  11958. #line 390 "./unsupportedserial.w"
  11959. QScriptValue settingsObject= scriptengine->newObject();
  11960. QVariantMap::const_iterator i= deviceSettings.constBegin();
  11961. while(i!=deviceSettings.constEnd())
  11962. {
  11963. settingsObject.setProperty(i.key(),i.value().toString());
  11964. i++;
  11965. }
  11966. object.setProperty("settings",settingsObject);
  11967. /*:829*/
  11968. #line 375 "./unsupportedserial.w"
  11969. /*830:*/
  11970. #line 405 "./unsupportedserial.w"
  11971. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  11972. for(int i= 0;i<channelCount();i++)
  11973. {
  11974. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  11975. QScriptValue channelSettingsObject= scriptengine->newObject();
  11976. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  11977. while(j!=channelSettings.at(i).constEnd())
  11978. {
  11979. channelSettingsObject.setProperty(j.key(),j.value().toString());
  11980. j++;
  11981. }
  11982. channelObject.setProperty("settings",channelSettingsObject);
  11983. channelsArray.setProperty(i,channelObject);
  11984. }
  11985. object.setProperty("channels",channelsArray);
  11986. /*:830*/
  11987. #line 376 "./unsupportedserial.w"
  11988. QScriptContext*context= scriptengine->currentContext();
  11989. QScriptValue oldThis= context->thisObject();
  11990. context->setThisObject(object);
  11991. QScriptValue result= scriptengine->evaluate(deviceScript);
  11992. QScriptEngine*engine= scriptengine;
  11993. /*161:*/
  11994. #line 3803 "./typica.w"
  11995. if(engine->hasUncaughtException())
  11996. {
  11997. int line= engine->uncaughtExceptionLineNumber();
  11998. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  11999. result.toString();
  12000. QString trace;
  12001. foreach(trace,engine->uncaughtExceptionBacktrace())
  12002. {
  12003. qDebug()<<trace;
  12004. }
  12005. }
  12006. /*:161*/
  12007. #line 382 "./unsupportedserial.w"
  12008. context->setThisObject(oldThis);
  12009. }
  12010. /*:828*//*833:*/
  12011. #line 446 "./unsupportedserial.w"
  12012. void JavaScriptDevice::stop()
  12013. {
  12014. emit deviceStopRequested();
  12015. }
  12016. /*:833*//*834:*/
  12017. #line 459 "./unsupportedserial.w"
  12018. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  12019. QScriptEngine*engine):
  12020. QObject(NULL),scriptengine(engine)
  12021. {
  12022. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  12023. QDomElement deviceReferenceElement=
  12024. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12025. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  12026. QDomElement node;
  12027. QStringList deviceKeys;
  12028. QStringList deviceValues;
  12029. for(int i= 0;i<deviceConfigData.size();i++)
  12030. {
  12031. node= deviceConfigData.at(i).toElement();
  12032. if(node.attribute("name")=="keys")
  12033. {
  12034. QString data= node.attribute("value");
  12035. if(data.length()> 3)
  12036. {
  12037. data.chop(2);
  12038. data= data.remove(0,2);
  12039. }
  12040. deviceKeys= data.split(", ");
  12041. }
  12042. else if(node.attribute("name")=="values")
  12043. {
  12044. QString data= node.attribute("value");
  12045. if(data.length()> 3)
  12046. {
  12047. data.chop(2);
  12048. data= data.remove(0,2);
  12049. }
  12050. deviceValues= data.split(", ");
  12051. }
  12052. else if(node.attribute("name")=="script")
  12053. {
  12054. deviceScript= node.attribute("value");
  12055. }
  12056. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  12057. }
  12058. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  12059. {
  12060. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  12061. }
  12062. if(model->hasChildren(index))
  12063. {
  12064. for(int i= 0;i<model->rowCount(index);i++)
  12065. {
  12066. QModelIndex channelIndex= model->index(i,0,index);
  12067. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  12068. channelList.append(new Channel);
  12069. QDomElement channelReferenceElement=
  12070. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12071. QDomNodeList channelConfigData=
  12072. channelReferenceElement.elementsByTagName("attribute");
  12073. QStringList channelKeys;
  12074. QStringList channelValues;
  12075. for(int j= 0;j<channelConfigData.size();j++)
  12076. {
  12077. node= channelConfigData.at(j).toElement();
  12078. if(node.attribute("name")=="keys")
  12079. {
  12080. QString data= node.attribute("value");
  12081. if(data.length()> 3)
  12082. {
  12083. data.chop(2);
  12084. data= data.remove(0,2);
  12085. }
  12086. channelKeys= data.split(", ");
  12087. }
  12088. else if(node.attribute("name")=="values")
  12089. {
  12090. QString data= node.attribute("value");
  12091. if(data.length()> 3)
  12092. {
  12093. data.chop(2);
  12094. data= data.remove(0,2);
  12095. }
  12096. channelValues= data.split(", ");
  12097. }
  12098. else if(node.attribute("name")=="hidden")
  12099. {
  12100. hiddenState.append(node.attribute("value")=="true");
  12101. }
  12102. else if(node.attribute("name")=="columnname")
  12103. {
  12104. columnNames.append(node.attribute("value"));
  12105. }
  12106. }
  12107. QVariantMap cs;
  12108. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  12109. {
  12110. cs.insert(channelKeys[j],channelValues[j]);
  12111. }
  12112. channelSettings.append(cs);
  12113. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  12114. channelUnits.append(Units::Fahrenheit);
  12115. }
  12116. }
  12117. }
  12118. /*:834*//*835:*/
  12119. #line 564 "./unsupportedserial.w"
  12120. int JavaScriptDevice::channelCount()
  12121. {
  12122. return channelList.length();
  12123. }
  12124. Channel*JavaScriptDevice::getChannel(int channel)
  12125. {
  12126. return channelList.at(channel);
  12127. }
  12128. bool JavaScriptDevice::isChannelHidden(int channel)
  12129. {
  12130. return hiddenState.at(channel);
  12131. }
  12132. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  12133. {
  12134. return channelUnits.at(channel);
  12135. }
  12136. QString JavaScriptDevice::channelColumnName(int channel)
  12137. {
  12138. if(channel>=0&&channel<columnNames.length())
  12139. {
  12140. return columnNames.at(channel);
  12141. }
  12142. return QString();
  12143. }
  12144. QString JavaScriptDevice::channelIndicatorText(int channel)
  12145. {
  12146. return indicatorTexts.at(channel);
  12147. }
  12148. /*:835*//*836:*/
  12149. #line 601 "./unsupportedserial.w"
  12150. void JavaScriptDevice::setTemperatureColumn(int tcol)
  12151. {
  12152. annotationTemperatureColumn= tcol;
  12153. }
  12154. void JavaScriptDevice::setAnnotationColumn(int ncol)
  12155. {
  12156. annotationNoteColumn= ncol;
  12157. }
  12158. /*:836*/
  12159. #line 641 "./unsupportedserial.w"
  12160. /*:840*//*869:*/
  12161. #line 265 "./rate.w"
  12162. /*865:*/
  12163. #line 191 "./rate.w"
  12164. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  12165. :BasicDeviceConfigurationWidget(model,index)
  12166. {
  12167. QFormLayout*layout= new QFormLayout;
  12168. QLineEdit*column= new QLineEdit;
  12169. layout->addRow(tr("Primary series column name:"),column);
  12170. QSpinBox*cacheTime= new QSpinBox;
  12171. cacheTime->setMinimum(0);
  12172. cacheTime->setMaximum(300);
  12173. layout->addRow(tr("Cache time:"),cacheTime);
  12174. QSpinBox*scaleTime= new QSpinBox;
  12175. scaleTime->setMinimum(1);
  12176. scaleTime->setMaximum(300);
  12177. layout->addRow(tr("Scale time:"),scaleTime);
  12178. /*724:*/
  12179. #line 15464 "./typica.w"
  12180. QDomElement referenceElement=
  12181. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12182. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12183. QDomElement node;
  12184. /*:724*/
  12185. #line 206 "./rate.w"
  12186. for(int i= 0;i<configData.size();i++)
  12187. {
  12188. node= configData.at(i).toElement();
  12189. if(node.attribute("name")=="column")
  12190. {
  12191. column->setText(node.attribute("value"));
  12192. }
  12193. else if(node.attribute("name")=="cache")
  12194. {
  12195. cacheTime->setValue(node.attribute("value").toInt());
  12196. }
  12197. else if(node.attribute("name")=="scale")
  12198. {
  12199. scaleTime->setValue(node.attribute("value").toInt());
  12200. }
  12201. }
  12202. updateColumn(column->text());
  12203. updateCacheTime(cacheTime->text());
  12204. updateScaleTime(scaleTime->text());
  12205. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  12206. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  12207. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  12208. setLayout(layout);
  12209. }
  12210. /*:865*//*866:*/
  12211. #line 235 "./rate.w"
  12212. void RateOfChangeConfWidget::updateColumn(const QString&column)
  12213. {
  12214. updateAttribute("column",column);
  12215. }
  12216. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  12217. {
  12218. updateAttribute("cache",seconds);
  12219. }
  12220. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  12221. {
  12222. updateAttribute("scale",seconds);
  12223. }
  12224. /*:866*/
  12225. #line 266 "./rate.w"
  12226. #line 18633 "./typica.w"
  12227. #line 1 "./dataqsdk.w"
  12228. /*:869*/
  12229. #line 528 "./typica.w"
  12230. /*8:*/
  12231. #line 669 "./typica.w"
  12232. template<class TYPE> TYPE getself(QScriptContext*context)
  12233. {
  12234. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  12235. return self;
  12236. }
  12237. template<> QTime getself(QScriptContext*context)
  12238. {
  12239. QTime self= context->thisObject().toVariant().toTime();
  12240. return self;
  12241. }
  12242. template<> QByteArray getself(QScriptContext*context)
  12243. {
  12244. QByteArray self= context->thisObject().toVariant().toByteArray();
  12245. return self;
  12246. }
  12247. template<> SqlQueryConnection*getself(QScriptContext*context)
  12248. {
  12249. SqlQueryConnection*self=
  12250. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  12251. return self;
  12252. }
  12253. template<> QXmlQuery*getself(QScriptContext*context)
  12254. {
  12255. QXmlQuery*self=
  12256. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  12257. return self;
  12258. }
  12259. template<> QXmlStreamWriter*getself(QScriptContext*context)
  12260. {
  12261. QXmlStreamWriter*self=
  12262. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  12263. return self;
  12264. }
  12265. template<> QXmlStreamReader*getself(QScriptContext*context)
  12266. {
  12267. QXmlStreamReader*self=
  12268. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  12269. return self;
  12270. }
  12271. /*:8*//*9:*/
  12272. #line 720 "./typica.w"
  12273. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  12274. {
  12275. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  12276. return argument;
  12277. }
  12278. template<> QString argument(int arg,QScriptContext*context)
  12279. {
  12280. return context->argument(arg).toString();
  12281. }
  12282. template<> QVariant argument(int arg,QScriptContext*context)
  12283. {
  12284. return context->argument(arg).toVariant();
  12285. }
  12286. template<> int argument(int arg,QScriptContext*context)
  12287. {
  12288. return context->argument(arg).toInt32();
  12289. }
  12290. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  12291. {
  12292. return(SqlQueryConnection*)
  12293. qscriptvalue_cast<void*> (context->argument(arg));
  12294. }
  12295. template<> QModelIndex argument(int arg,QScriptContext*context)
  12296. {
  12297. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  12298. }
  12299. template<> double argument(int arg,QScriptContext*context)
  12300. {
  12301. return(double)(context->argument(arg).toNumber());
  12302. }
  12303. template<> Units::Unit argument(int arg,QScriptContext*context)
  12304. {
  12305. return(Units::Unit)(context->argument(arg).toInt32());
  12306. }
  12307. template<> QByteArray argument(int arg,QScriptContext*context)
  12308. {
  12309. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  12310. }
  12311. /*:9*//*13:*/
  12312. #line 812 "./typica.w"
  12313. void setQObjectProperties(QScriptValue,QScriptEngine*)
  12314. {
  12315. }
  12316. /*:13*//*15:*/
  12317. #line 826 "./typica.w"
  12318. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  12319. {
  12320. }
  12321. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  12322. {
  12323. }
  12324. /*:15*//*18:*/
  12325. #line 865 "./typica.w"
  12326. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  12327. {
  12328. QScriptValue object= engine->newQObject(new QWidget);
  12329. setQWidgetProperties(object,engine);
  12330. return object;
  12331. }
  12332. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  12333. {
  12334. setQObjectProperties(value,engine);
  12335. setQPaintDeviceProperties(value,engine);
  12336. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  12337. value.setProperty("activateWindow",
  12338. engine->newFunction(QWidget_activateWindow));
  12339. }
  12340. /*:18*//*19:*/
  12341. #line 887 "./typica.w"
  12342. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  12343. {
  12344. if(context->argumentCount()==1)
  12345. {
  12346. QWidget*self= getself<QWidget*> (context);
  12347. QLayout*layout= argument<QLayout*> (0,context);
  12348. if(layout)
  12349. {
  12350. self->setLayout(layout);
  12351. }
  12352. else
  12353. {
  12354. context->throwError("Incorrect argument type passed to "
  12355. "QWidget::setLayout(). This method requires "
  12356. "a QLayout.");
  12357. }
  12358. }
  12359. else
  12360. {
  12361. context->throwError("Incorrect number of arguments passed to "
  12362. "QWidget::setLayout(). This method takes one "
  12363. "QLayout as an argument.");
  12364. }
  12365. return QScriptValue();
  12366. }
  12367. QScriptValue QWidget_activateWindow(QScriptContext*context,
  12368. QScriptEngine*)
  12369. {
  12370. QWidget*self= getself<QWidget*> (context);
  12371. self->activateWindow();
  12372. return QScriptValue();
  12373. }
  12374. /*:19*//*21:*/
  12375. #line 969 "./typica.w"
  12376. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  12377. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  12378. {
  12379. }
  12380. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  12381. {
  12382. QSettings settings;
  12383. settings.beginGroup(key);
  12384. settings.setValue("pos",pos());
  12385. settings.setValue("size",size());
  12386. settings.endGroup();
  12387. }
  12388. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  12389. {
  12390. QSettings settings;
  12391. settings.beginGroup(key);
  12392. if(settings.contains("size"))
  12393. {
  12394. resize(settings.value("size").toSize());
  12395. }
  12396. if(settings.contains("pos"))
  12397. {
  12398. move(settings.value("pos").toPoint());
  12399. }
  12400. settings.endGroup();
  12401. }
  12402. void ScriptQMainWindow::displayStatus(const QString&message)
  12403. {
  12404. statusBar()->showMessage(message);
  12405. }
  12406. void ScriptQMainWindow::showEvent(QShowEvent*event)
  12407. {
  12408. if(!event->spontaneous())
  12409. {
  12410. /*26:*/
  12411. #line 1081 "./typica.w"
  12412. QSettings settings;
  12413. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  12414. toByteArray());
  12415. /*:26*/
  12416. #line 1009 "./typica.w"
  12417. event->accept();
  12418. }
  12419. else
  12420. {
  12421. event->ignore();
  12422. }
  12423. }
  12424. void ScriptQMainWindow::show()
  12425. {
  12426. QMainWindow::show();
  12427. }
  12428. /*:21*//*22:*/
  12429. #line 1030 "./typica.w"
  12430. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  12431. {
  12432. if(isWindowModified()){
  12433. /*23:*/
  12434. #line 1044 "./typica.w"
  12435. QMessageBox::StandardButton result;
  12436. result= QMessageBox::warning(this,"Typica",closePrompt(),
  12437. QMessageBox::Ok|QMessageBox::Cancel);
  12438. if(result==QMessageBox::Cancel)
  12439. {
  12440. event->ignore();
  12441. return;
  12442. }
  12443. /*:23*/
  12444. #line 1034 "./typica.w"
  12445. }
  12446. emit aboutToClose();
  12447. /*25:*/
  12448. #line 1075 "./typica.w"
  12449. QSettings settings;
  12450. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  12451. /*:25*/
  12452. #line 1037 "./typica.w"
  12453. event->accept();
  12454. }
  12455. /*:22*//*24:*/
  12456. #line 1056 "./typica.w"
  12457. QString ScriptQMainWindow::closePrompt()
  12458. {
  12459. return cprompt;
  12460. }
  12461. void ScriptQMainWindow::setClosePrompt(QString prompt)
  12462. {
  12463. cprompt= prompt;
  12464. }
  12465. /*:24*//*29:*/
  12466. #line 1109 "./typica.w"
  12467. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  12468. {
  12469. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  12470. setQMainWindowProperties(object,engine);
  12471. return object;
  12472. }
  12473. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  12474. {
  12475. setQWidgetProperties(value,engine);
  12476. value.setProperty("setCentralWidget",
  12477. engine->newFunction(QMainWindow_setCentralWidget));
  12478. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  12479. }
  12480. /*:29*//*30:*/
  12481. #line 1131 "./typica.w"
  12482. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  12483. QScriptEngine*)
  12484. {
  12485. if(context->argumentCount()==1)
  12486. {
  12487. QMainWindow*self= getself<QMainWindow*> (context);
  12488. QWidget*widget= argument<QWidget*> (0,context);
  12489. if(widget)
  12490. {
  12491. self->setCentralWidget(widget);
  12492. }
  12493. else
  12494. {
  12495. context->throwError("Incorrect argument type passed to "
  12496. "QMainWindow::setCentralWidget(). This "
  12497. "method requires a QWidget.");
  12498. }
  12499. }
  12500. else
  12501. {
  12502. context->throwError("Incorrect number of arguments passed to "
  12503. "QMainWindow::setCentralWidget(). This method "
  12504. "takes one QWidget as an argument.");
  12505. }
  12506. return QScriptValue();
  12507. }
  12508. /*:30*//*31:*/
  12509. #line 1165 "./typica.w"
  12510. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  12511. {
  12512. QScriptValue object;
  12513. if(context->argumentCount()==0)
  12514. {
  12515. QMainWindow*self= getself<QMainWindow*> (context);
  12516. QMenuBar*bar= self->menuBar();
  12517. object= engine->newQObject(bar);
  12518. setQMenuBarProperties(object,engine);
  12519. }
  12520. else
  12521. {
  12522. context->throwError("Incorrect number of arguments passed to "
  12523. "QMainWindow::menuBar(). This method takes no "
  12524. "arguments.");
  12525. }
  12526. return object;
  12527. }
  12528. /*:31*//*33:*/
  12529. #line 1195 "./typica.w"
  12530. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  12531. {
  12532. setQWidgetProperties(value,engine);
  12533. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  12534. }
  12535. /*:33*//*34:*/
  12536. #line 1210 "./typica.w"
  12537. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  12538. {
  12539. QScriptValue object;
  12540. if(context->argumentCount()==1)
  12541. {
  12542. QMenuBar*self= getself<QMenuBar*> (context);
  12543. QString title= argument<QString> (0,context);
  12544. object= engine->newQObject(self->addMenu(title));
  12545. setQMenuProperties(object,engine);
  12546. }
  12547. else
  12548. {
  12549. context->throwError("Incorrect number of arguments passed to "
  12550. "QMenuBar::addMenu(). This method takes one "
  12551. "string as an argument.");
  12552. }
  12553. return object;
  12554. }
  12555. /*:34*//*36:*/
  12556. #line 1240 "./typica.w"
  12557. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  12558. {
  12559. setQWidgetProperties(value,engine);
  12560. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  12561. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  12562. }
  12563. /*:36*//*37:*/
  12564. #line 1250 "./typica.w"
  12565. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  12566. {
  12567. if(context->argumentCount()==1)
  12568. {
  12569. QMenu*self= getself<QMenu*> (context);
  12570. QAction*action= argument<QAction*> (0,context);
  12571. if(action)
  12572. {
  12573. self->addAction(action);
  12574. }
  12575. else
  12576. {
  12577. context->throwError("Incorrect argument type passed to "
  12578. "QMenu::addAction(). This method requires a "
  12579. "QAction.");
  12580. }
  12581. }
  12582. else
  12583. {
  12584. context->throwError("Incorrect number of arguments passed to "
  12585. "QMenu::addAction(). This method takes one "
  12586. "QAction as an argument.");
  12587. }
  12588. return QScriptValue();
  12589. }
  12590. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  12591. {
  12592. if(context->argumentCount()==0)
  12593. {
  12594. QMenu*self= getself<QMenu*> (context);
  12595. self->addSeparator();
  12596. }
  12597. else
  12598. {
  12599. context->throwError("Incorrect number of arguments passed to "
  12600. "QMenu::addSeparator(). This method takes no "
  12601. "arguments.");
  12602. }
  12603. return QScriptValue();
  12604. }
  12605. /*:37*//*40:*/
  12606. #line 1312 "./typica.w"
  12607. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  12608. {
  12609. QScriptValue object= engine->newQObject(new QFrame);
  12610. setQFrameProperties(object,engine);
  12611. return object;
  12612. }
  12613. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  12614. {
  12615. setQWidgetProperties(value,engine);
  12616. }
  12617. /*:40*//*43:*/
  12618. #line 1346 "./typica.w"
  12619. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  12620. {
  12621. QString text;
  12622. if(context->argumentCount()==1)
  12623. {
  12624. text= argument<QString> (0,context);
  12625. }
  12626. QScriptValue object= engine->newQObject(new QLabel(text));
  12627. setQLabelProperties(object,engine);
  12628. return object;
  12629. }
  12630. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  12631. {
  12632. setQFrameProperties(value,engine);
  12633. }
  12634. /*:43*//*46:*/
  12635. #line 1383 "./typica.w"
  12636. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  12637. {
  12638. QScriptValue object= engine->newQObject(new QLineEdit());
  12639. setQLineEditProperties(object,engine);
  12640. return object;
  12641. }
  12642. /*:46*//*47:*/
  12643. #line 1394 "./typica.w"
  12644. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  12645. {
  12646. setQWidgetProperties(value,engine);
  12647. }
  12648. /*:47*//*50:*/
  12649. #line 1428 "./typica.w"
  12650. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  12651. {
  12652. QScriptValue object= engine->newQObject(new QSplitter);
  12653. setQSplitterProperties(object,engine);
  12654. return object;
  12655. }
  12656. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  12657. {
  12658. setQFrameProperties(value,engine);
  12659. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  12660. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  12661. value.setProperty("restoreState",
  12662. engine->newFunction(QSplitter_restoreState));
  12663. }
  12664. /*:50*//*51:*/
  12665. #line 1448 "./typica.w"
  12666. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  12667. {
  12668. if(context->argumentCount()==1)
  12669. {
  12670. QSplitter*self= getself<QSplitter*> (context);
  12671. QWidget*widget= argument<QWidget*> (0,context);
  12672. if(widget)
  12673. {
  12674. self->addWidget(widget);
  12675. }
  12676. else
  12677. {
  12678. context->throwError("Incorrect argument type passed to "
  12679. "QSplitter::addWidget(). This method "
  12680. "requires a QWidget.");
  12681. }
  12682. }
  12683. else
  12684. {
  12685. context->throwError("Incorrect number of arguments passed to "
  12686. "QSplitter::addWidget(). This method takes one "
  12687. "QWidget as an argument.");
  12688. }
  12689. return QScriptValue();
  12690. }
  12691. /*:51*//*52:*/
  12692. #line 1481 "./typica.w"
  12693. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  12694. {
  12695. if(context->argumentCount()==1)
  12696. {
  12697. QSplitter*self= getself<QSplitter*> (context);
  12698. QString key= argument<QString> (0,context);
  12699. QSettings settings;
  12700. settings.setValue(key,self->saveState());
  12701. }
  12702. else
  12703. {
  12704. context->throwError("Incorrect number of arguments passed to "
  12705. "QSplitter::saveState(). This method takes one "
  12706. "string as an argument.");
  12707. }
  12708. return QScriptValue();
  12709. }
  12710. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  12711. {
  12712. if(context->argumentCount()==1)
  12713. {
  12714. QSplitter*self= getself<QSplitter*> (context);
  12715. QString key= argument<QString> (0,context);
  12716. QSettings settings;
  12717. self->restoreState(settings.value(key).toByteArray());
  12718. }
  12719. else
  12720. {
  12721. context->throwError("Incorrect number of arguments passed to "
  12722. "QSplitter::restoreState(). This method takes "
  12723. "one string as an argument.");
  12724. }
  12725. return QScriptValue();
  12726. }
  12727. /*:52*//*54:*/
  12728. #line 1534 "./typica.w"
  12729. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  12730. {
  12731. setQLayoutItemProperties(value,engine);
  12732. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  12733. }
  12734. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  12735. {
  12736. if(context->argumentCount()==1)
  12737. {
  12738. QLayout*self= getself<QLayout*> (context);
  12739. QWidget*widget= argument<QWidget*> (0,context);
  12740. if(widget)
  12741. {
  12742. self->addWidget(widget);
  12743. }
  12744. else
  12745. {
  12746. context->throwError("Incorrect argument type passed to "
  12747. "QLayout::addWidget(). This method requires "
  12748. "a QWidget.");
  12749. }
  12750. }
  12751. else
  12752. {
  12753. context->throwError("Incorrect number of arguments passed to "
  12754. "QLayout::addWidget(). This method takes one "
  12755. "QWidget as an argument.");
  12756. }
  12757. return QScriptValue();
  12758. }
  12759. /*:54*//*57:*/
  12760. #line 1601 "./typica.w"
  12761. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  12762. {
  12763. QScriptValue object=
  12764. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  12765. setQBoxLayoutProperties(object,engine);
  12766. return object;
  12767. }
  12768. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  12769. {
  12770. setQLayoutProperties(value,engine);
  12771. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  12772. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  12773. }
  12774. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  12775. {
  12776. if(context->argumentCount()> 0&&context->argumentCount()<3)
  12777. {
  12778. QBoxLayout*self= getself<QBoxLayout*> (context);
  12779. QLayout*layout= argument<QLayout*> (0,context);
  12780. int stretch= 0;
  12781. if(context->argumentCount()==2)
  12782. {
  12783. stretch= argument<int> (1,context);
  12784. }
  12785. if(layout)
  12786. {
  12787. self->addLayout(layout,stretch);
  12788. }
  12789. else
  12790. {
  12791. context->throwError("Incorrect argument type passed to "
  12792. "QLayout::addLayout(). This method requires "
  12793. "a QLayout.");
  12794. }
  12795. }
  12796. else
  12797. {
  12798. context->throwError("Incorrect number of arguments passed to "
  12799. "QLayout::addLayout(). This method takes one "
  12800. "QLayout as an argument and optionally one integer.");
  12801. }
  12802. return QScriptValue();
  12803. }
  12804. /*:57*//*58:*/
  12805. #line 1652 "./typica.w"
  12806. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  12807. {
  12808. if(context->argumentCount()> 0&&context->argumentCount()<4)
  12809. {
  12810. QBoxLayout*self= getself<QBoxLayout*> (context);
  12811. QWidget*widget= argument<QWidget*> (0,context);
  12812. int stretch= 0;
  12813. Qt::Alignment alignment= 0;
  12814. if(context->argumentCount()> 1)
  12815. {
  12816. stretch= argument<int> (1,context);
  12817. }
  12818. if(context->argumentCount()> 2)
  12819. {
  12820. alignment= (Qt::Alignment)(argument<int> (2,context));
  12821. }
  12822. if(widget)
  12823. {
  12824. self->addWidget(widget,stretch,alignment);
  12825. }
  12826. else
  12827. {
  12828. context->throwError("Incorrect argument type passed to "
  12829. "QBoxLayout::addWidget(). This method requires "
  12830. "a QWidget.");
  12831. }
  12832. }
  12833. else
  12834. {
  12835. context->throwError("Incorrect number of arguments passed to "
  12836. "QBoxLayout::addWidget(). This method takes one "
  12837. "QWidget and optionally up to two integers as "
  12838. "arguments.");
  12839. }
  12840. return QScriptValue();
  12841. }
  12842. /*:58*//*61:*/
  12843. #line 1716 "./typica.w"
  12844. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  12845. {
  12846. QScriptValue object= engine->newQObject(new QAction(NULL));
  12847. setQActionProperties(object,engine);
  12848. return object;
  12849. }
  12850. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  12851. {
  12852. setQObjectProperties(value,engine);
  12853. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  12854. }
  12855. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  12856. {
  12857. if(context->argumentCount()==1)
  12858. {
  12859. QAction*self= getself<QAction*> (context);
  12860. self->setShortcut(argument<QString> (0,context));
  12861. }
  12862. else
  12863. {
  12864. context->throwError("Incorrect number of arguments passed to "
  12865. "QAction::setShortcut(). This method takes one "
  12866. "string as an argument.");
  12867. }
  12868. return QScriptValue();
  12869. }
  12870. /*:61*//*64:*/
  12871. #line 1774 "./typica.w"
  12872. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  12873. QScriptEngine*engine)
  12874. {
  12875. QScriptValue retval;
  12876. if(context->argumentCount()==3)
  12877. {
  12878. QWidget*widget= argument<QWidget*> (0,context);
  12879. if(widget)
  12880. {
  12881. QString caption= argument<QString> (1,context);
  12882. QString dir= argument<QString> (2,context);
  12883. retval= QScriptValue(engine,
  12884. QFileDialog::getOpenFileName(widget,caption,
  12885. dir,"",0,0));
  12886. setQFileDialogProperties(retval,engine);
  12887. }
  12888. else
  12889. {
  12890. context->throwError("Incorrect argument type passed to "
  12891. "QFileDialog::getOpenFileName(). The first "
  12892. "argument to this method must be a QWidget.");
  12893. }
  12894. }
  12895. else
  12896. {
  12897. context->throwError("Incorrect number of arguments passed to "
  12898. "QFileDialog::getOpenFileName(). This method "
  12899. "takes one QWidget followed by two strings for a "
  12900. "total of three arguments.");
  12901. }
  12902. return retval;
  12903. }
  12904. /*:64*//*65:*/
  12905. #line 1810 "./typica.w"
  12906. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  12907. QScriptEngine*engine)
  12908. {
  12909. QScriptValue retval;
  12910. if(context->argumentCount()==3)
  12911. {
  12912. QWidget*widget= argument<QWidget*> (0,context);
  12913. if(widget)
  12914. {
  12915. QString caption= argument<QString> (1,context);
  12916. QString dir= argument<QString> (2,context);
  12917. retval= QScriptValue(engine,
  12918. QFileDialog::getSaveFileName(widget,caption,
  12919. dir,"",0,0));
  12920. setQFileDialogProperties(retval,engine);
  12921. }
  12922. else
  12923. {
  12924. context->throwError("Incorrect argument type passed to "
  12925. "QFileDialog::getSaveFileName(). The first "
  12926. "argument to this method must be a QWidget.");
  12927. }
  12928. }
  12929. else
  12930. {
  12931. context->throwError("Incorrect number of arguments passed to "
  12932. "QFileDialog::getSaveFileName(). This method "
  12933. "takes one QWidget followed by two strings for a "
  12934. "total of three arguments.");
  12935. }
  12936. return retval;
  12937. }
  12938. /*:65*//*66:*/
  12939. #line 1847 "./typica.w"
  12940. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  12941. {
  12942. setQDialogProperties(value,engine);
  12943. }
  12944. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  12945. {
  12946. setQWidgetProperties(value,engine);
  12947. }
  12948. /*:66*//*69:*/
  12949. #line 1885 "./typica.w"
  12950. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  12951. {
  12952. QScriptValue object=
  12953. engine->newQObject(new QFile(argument<QString> (0,context)));
  12954. setQFileProperties(object,engine);
  12955. return object;
  12956. }
  12957. /*:69*//*70:*/
  12958. #line 1896 "./typica.w"
  12959. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  12960. {
  12961. setQIODeviceProperties(value,engine);
  12962. value.setProperty("remove",engine->newFunction(QFile_remove));
  12963. }
  12964. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  12965. {
  12966. QFile*self= getself<QFile*> (context);
  12967. bool retval= self->remove();
  12968. return QScriptValue(engine,retval);
  12969. }
  12970. /*:70*//*71:*/
  12971. #line 1918 "./typica.w"
  12972. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  12973. {
  12974. setQObjectProperties(value,engine);
  12975. value.setProperty("open",engine->newFunction(QIODevice_open));
  12976. value.setProperty("close",engine->newFunction(QIODevice_close));
  12977. value.setProperty("readToString",
  12978. engine->newFunction(QIODevice_readToString));
  12979. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  12980. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  12981. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  12982. }
  12983. /*:71*//*72:*/
  12984. #line 1936 "./typica.w"
  12985. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  12986. {
  12987. QIODevice*self= getself<QIODevice*> (context);
  12988. bool retval= false;
  12989. if(context->argumentCount()==1)
  12990. {
  12991. switch(argument<int> (0,context))
  12992. {
  12993. case 1:
  12994. retval= self->open(QIODevice::ReadOnly);
  12995. break;
  12996. case 2:
  12997. retval= self->open(QIODevice::WriteOnly);
  12998. break;
  12999. case 3:
  13000. retval= self->open(QIODevice::ReadWrite);
  13001. break;
  13002. default:
  13003. break;
  13004. }
  13005. }
  13006. else
  13007. {
  13008. retval= self->open(QIODevice::ReadWrite);
  13009. }
  13010. return QScriptValue(retval);
  13011. }
  13012. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  13013. {
  13014. QIODevice*self= getself<QIODevice*> (context);
  13015. self->close();
  13016. return QScriptValue();
  13017. }
  13018. /*:72*//*73:*/
  13019. #line 1976 "./typica.w"
  13020. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  13021. {
  13022. QIODevice*self= getself<QIODevice*> (context);
  13023. self->reset();
  13024. return QScriptValue(QString(self->readAll()));
  13025. }
  13026. /*:73*//*74:*/
  13027. #line 1992 "./typica.w"
  13028. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  13029. {
  13030. QIODevice*self= getself<QIODevice*> (context);
  13031. if(context->argumentCount()==1)
  13032. {
  13033. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  13034. }
  13035. context->throwError("Incorrect number of arguments passed to "
  13036. "QIODevice::putChar()");
  13037. return QScriptValue();
  13038. }
  13039. /*:74*//*75:*/
  13040. #line 2010 "./typica.w"
  13041. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  13042. {
  13043. QIODevice*self= getself<QIODevice*> (context);
  13044. if(context->argumentCount()==1)
  13045. {
  13046. self->write(argument<QString> (0,context).toUtf8());
  13047. }
  13048. else
  13049. {
  13050. context->throwError("Incorrect number of arguments passed to "
  13051. "QIODevice::writeString()");
  13052. }
  13053. return QScriptValue();
  13054. }
  13055. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  13056. {
  13057. QIODevice*self= getself<QIODevice*> (context);
  13058. if(context->argumentCount()==1)
  13059. {
  13060. self->write(argument<QByteArray> (0,context));
  13061. }
  13062. else
  13063. {
  13064. context->throwError("Incorrect number of arguments passed to "
  13065. "QIODevice::writeBytes()");
  13066. }
  13067. return QScriptValue();
  13068. }
  13069. /*:75*//*77:*/
  13070. #line 2054 "./typica.w"
  13071. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  13072. {
  13073. QScriptValue object= engine->newVariant(QVariant(bytes));
  13074. setQByteArrayProperties(object,engine);
  13075. return object;
  13076. }
  13077. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  13078. {
  13079. bytes= value.toVariant().toByteArray();
  13080. }
  13081. /*:77*//*79:*/
  13082. #line 2077 "./typica.w"
  13083. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  13084. {
  13085. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  13086. setQByteArrayProperties(object,engine);
  13087. return object;
  13088. }
  13089. /*:79*//*80:*/
  13090. #line 2088 "./typica.w"
  13091. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  13092. {
  13093. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  13094. }
  13095. /*:80*//*81:*/
  13096. #line 2097 "./typica.w"
  13097. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  13098. {
  13099. QByteArray self= getself<QByteArray> (context);
  13100. QByteArray retval;
  13101. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  13102. return engine->toScriptValue<QByteArray> (retval);
  13103. }
  13104. /*:81*//*84:*/
  13105. #line 2128 "./typica.w"
  13106. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  13107. {
  13108. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  13109. QScriptValue object= engine->newQObject(new QBuffer(array));
  13110. setQBufferProperties(object,engine);
  13111. return object;
  13112. }
  13113. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  13114. {
  13115. setQIODeviceProperties(value,engine);
  13116. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  13117. }
  13118. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  13119. {
  13120. QBuffer*self= getself<QBuffer*> (context);
  13121. self->setData(argument<QString> (0,context).toAscii());
  13122. return QScriptValue();
  13123. }
  13124. /*:84*//*87:*/
  13125. #line 2177 "./typica.w"
  13126. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  13127. {
  13128. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  13129. setXQueryProperties(object,engine);
  13130. return object;
  13131. }
  13132. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  13133. {
  13134. QXmlQuery*self= getself<QXmlQuery*> (context);
  13135. delete self;
  13136. return QScriptValue();
  13137. }
  13138. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  13139. {
  13140. value.setProperty("bind",engine->newFunction(XQuery_bind));
  13141. value.setProperty("exec",engine->newFunction(XQuery_exec));
  13142. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  13143. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  13144. }
  13145. /*:87*//*88:*/
  13146. #line 2203 "./typica.w"
  13147. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  13148. {
  13149. QXmlQuery*self= getself<QXmlQuery*> (context);
  13150. QIODevice*buffer= argument<QIODevice*> (1,context);
  13151. self->bindVariable(argument<QString> (0,context),buffer);
  13152. return QScriptValue();
  13153. }
  13154. /*:88*//*89:*/
  13155. #line 2214 "./typica.w"
  13156. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  13157. {
  13158. QXmlQuery*self= getself<QXmlQuery*> (context);
  13159. self->setQuery(argument<QString> (0,context));
  13160. return QScriptValue();
  13161. }
  13162. /*:89*//*90:*/
  13163. #line 2224 "./typica.w"
  13164. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  13165. {
  13166. QXmlQuery*self= getself<QXmlQuery*> (context);
  13167. QString result;
  13168. self->evaluateTo(&result);
  13169. return QScriptValue(result);
  13170. }
  13171. /*:90*//*93:*/
  13172. #line 2279 "./typica.w"
  13173. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  13174. {
  13175. QXmlStreamWriter*retval;
  13176. if(context->argumentCount()==1)
  13177. {
  13178. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  13179. }
  13180. else
  13181. {
  13182. retval= new QXmlStreamWriter;
  13183. }
  13184. QScriptValue object= engine->toScriptValue<void*> (retval);
  13185. setXmlWriterProperties(object,engine);
  13186. return object;
  13187. }
  13188. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  13189. {
  13190. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  13191. value.setProperty("writeAttribute",
  13192. engine->newFunction(XmlWriter_writeAttribute));
  13193. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  13194. value.setProperty("writeCharacters",
  13195. engine->newFunction(XmlWriter_writeCharacters));
  13196. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  13197. value.setProperty("writeEmptyElement",
  13198. engine->newFunction(XmlWriter_writeEmptyElement));
  13199. value.setProperty("writeEndDocument",
  13200. engine->newFunction(XmlWriter_writeEndDocument));
  13201. value.setProperty("writeEndElement",
  13202. engine->newFunction(XmlWriter_writeEndElement));
  13203. value.setProperty("writeEntityReference",
  13204. engine->newFunction(XmlWriter_writeEntityReference));
  13205. value.setProperty("writeProcessingInstruction",
  13206. engine->newFunction(XmlWriter_writeProcessingInstruction));
  13207. value.setProperty("writeStartDocument",
  13208. engine->newFunction(XmlWriter_writeStartDocument));
  13209. value.setProperty("writeStartElement",
  13210. engine->newFunction(XmlWriter_writeStartElement));
  13211. value.setProperty("writeTextElement",
  13212. engine->newFunction(XmlWriter_writeTextElement));
  13213. }
  13214. /*:93*//*94:*/
  13215. #line 2326 "./typica.w"
  13216. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  13217. {
  13218. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13219. QIODevice*device= argument<QIODevice*> (0,context);
  13220. self->setDevice(device);
  13221. return QScriptValue();
  13222. }
  13223. /*:94*//*95:*/
  13224. #line 2340 "./typica.w"
  13225. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  13226. QScriptEngine*)
  13227. {
  13228. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13229. self->writeStartDocument(argument<QString> (0,context));
  13230. return QScriptValue();
  13231. }
  13232. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  13233. QScriptEngine*)
  13234. {
  13235. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13236. self->writeEndDocument();
  13237. return QScriptValue();
  13238. }
  13239. /*:95*//*96:*/
  13240. #line 2359 "./typica.w"
  13241. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  13242. {
  13243. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13244. self->writeDTD(argument<QString> (0,context));
  13245. return QScriptValue();
  13246. }
  13247. /*:96*//*97:*/
  13248. #line 2370 "./typica.w"
  13249. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  13250. QScriptEngine*)
  13251. {
  13252. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13253. self->writeStartElement(argument<QString> (0,context));
  13254. return QScriptValue();
  13255. }
  13256. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  13257. {
  13258. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13259. self->writeAttribute(argument<QString> (0,context),
  13260. argument<QString> (1,context));
  13261. return QScriptValue();
  13262. }
  13263. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  13264. {
  13265. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13266. self->writeCharacters(argument<QString> (0,context));
  13267. return QScriptValue();
  13268. }
  13269. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  13270. {
  13271. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13272. self->writeEndElement();
  13273. return QScriptValue();
  13274. }
  13275. /*:97*//*98:*/
  13276. #line 2406 "./typica.w"
  13277. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  13278. QScriptEngine*)
  13279. {
  13280. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13281. self->writeEmptyElement(argument<QString> (0,context));
  13282. return QScriptValue();
  13283. }
  13284. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  13285. QScriptEngine*)
  13286. {
  13287. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13288. self->writeTextElement(argument<QString> (0,context),
  13289. argument<QString> (1,context));
  13290. return QScriptValue();
  13291. }
  13292. /*:98*//*99:*/
  13293. #line 2427 "./typica.w"
  13294. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  13295. {
  13296. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13297. self->writeCDATA(argument<QString> (0,context));
  13298. return QScriptValue();
  13299. }
  13300. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  13301. QScriptEngine*)
  13302. {
  13303. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13304. self->writeEntityReference(argument<QString> (0,context));
  13305. return QScriptValue();
  13306. }
  13307. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  13308. QScriptEngine*)
  13309. {
  13310. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  13311. self->writeProcessingInstruction(argument<QString> (0,context),
  13312. argument<QString> (1,context));
  13313. return QScriptValue();
  13314. }
  13315. /*:99*//*102:*/
  13316. #line 2486 "./typica.w"
  13317. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  13318. {
  13319. QXmlStreamReader*retval=
  13320. new QXmlStreamReader(argument<QIODevice*> (0,context));
  13321. QScriptValue object= engine->toScriptValue<void*> (retval);
  13322. setXmlReaderProperties(object,engine);
  13323. return object;
  13324. }
  13325. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  13326. {
  13327. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  13328. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  13329. value.setProperty("hasAttribute",
  13330. engine->newFunction(XmlReader_hasAttribute));
  13331. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  13332. value.setProperty("isStartElement",
  13333. engine->newFunction(XmlReader_isStartElement));
  13334. value.setProperty("name",engine->newFunction(XmlReader_name));
  13335. value.setProperty("readElementText",
  13336. engine->newFunction(XmlReader_readElementText));
  13337. value.setProperty("readNext",
  13338. engine->newFunction(XmlReader_readNext));
  13339. value.setProperty("text",engine->newFunction(XmlReader_text));
  13340. }
  13341. /*:102*//*103:*/
  13342. #line 2516 "./typica.w"
  13343. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  13344. {
  13345. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13346. QString retval=
  13347. self->attributes().value(argument<QString> (0,context)).toString();
  13348. return QScriptValue(retval);
  13349. }
  13350. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  13351. {
  13352. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13353. bool retval=
  13354. self->attributes().hasAttribute(argument<QString> (0,context));
  13355. return QScriptValue(retval);
  13356. }
  13357. /*:103*//*104:*/
  13358. #line 2536 "./typica.w"
  13359. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  13360. {
  13361. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13362. return QScriptValue(self->atEnd());
  13363. }
  13364. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  13365. {
  13366. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13367. return QScriptValue(self->isDTD());
  13368. }
  13369. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  13370. {
  13371. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13372. return QScriptValue(self->isStartElement());
  13373. }
  13374. /*:104*//*105:*/
  13375. #line 2557 "./typica.w"
  13376. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  13377. {
  13378. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13379. self->readNext();
  13380. return QScriptValue();
  13381. }
  13382. /*:105*//*106:*/
  13383. #line 2567 "./typica.w"
  13384. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  13385. {
  13386. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13387. return QScriptValue(self->name().toString());
  13388. }
  13389. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  13390. {
  13391. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13392. return QScriptValue(self->readElementText());
  13393. }
  13394. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  13395. {
  13396. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  13397. return QScriptValue(self->text().toString());
  13398. }
  13399. /*:106*//*109:*/
  13400. #line 2609 "./typica.w"
  13401. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  13402. {
  13403. setQObjectProperties(value,engine);
  13404. value.setProperty("value",engine->newFunction(QSettings_value));
  13405. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  13406. }
  13407. /*:109*//*110:*/
  13408. #line 2621 "./typica.w"
  13409. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  13410. {
  13411. QScriptValue object;
  13412. if(context->argumentCount()==1||context->argumentCount()==2)
  13413. {
  13414. QSettings settings;
  13415. QString key= argument<QString> (0,context);
  13416. QVariant value;
  13417. QVariant retval;
  13418. if(context->argumentCount()> 1)
  13419. {
  13420. value= argument<QVariant> (1,context);
  13421. retval= settings.value(key,value);
  13422. }
  13423. else
  13424. {
  13425. retval= settings.value(key);
  13426. }
  13427. object= engine->newVariant(retval);
  13428. }
  13429. else
  13430. {
  13431. context->throwError("Incorrect number of arguments passed to "
  13432. "QSettings::value(). This method takes one "
  13433. "string and one optional variant type.");
  13434. }
  13435. return object;
  13436. }
  13437. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  13438. {
  13439. if(context->argumentCount()==2)
  13440. {
  13441. QSettings settings;
  13442. QString key= argument<QString> (0,context);
  13443. QVariant value= argument<QVariant> (1,context);
  13444. settings.setValue(key,value);
  13445. }
  13446. else
  13447. {
  13448. context->throwError("Incorrect number of arguments passed to "
  13449. "QSettings::setValue(). This method takes one "
  13450. "string and one variant type for a total of two "
  13451. "arguments.");
  13452. }
  13453. return QScriptValue();
  13454. }
  13455. /*:110*//*113:*/
  13456. #line 2690 "./typica.w"
  13457. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  13458. {
  13459. QScriptValue object= engine->newQObject(new QLCDNumber());
  13460. setQLCDNumberProperties(object,engine);
  13461. return object;
  13462. }
  13463. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  13464. {
  13465. setQFrameProperties(value,engine);
  13466. }
  13467. /*:113*//*116:*/
  13468. #line 2748 "./typica.w"
  13469. QScriptValue constructQTime(QScriptContext*context,
  13470. QScriptEngine*engine)
  13471. {
  13472. QScriptValue object;
  13473. if(context->argumentCount()==0||
  13474. (context->argumentCount()>=2&&context->argumentCount()<=4))
  13475. {
  13476. int arg1= 0;
  13477. int arg2= 0;
  13478. int arg3= 0;
  13479. int arg4= 0;
  13480. switch(context->argumentCount())
  13481. {
  13482. case 4:
  13483. arg4= argument<int> (3,context);
  13484. case 3:
  13485. arg3= argument<int> (2,context);
  13486. case 2:
  13487. arg2= argument<int> (1,context);
  13488. arg1= argument<int> (0,context);
  13489. default:
  13490. break;
  13491. }
  13492. if(context->argumentCount())
  13493. {
  13494. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  13495. arg4));
  13496. }
  13497. else
  13498. {
  13499. object= engine->toScriptValue<QTime> (QTime());
  13500. }
  13501. setQTimeProperties(object,engine);
  13502. }
  13503. else
  13504. {
  13505. context->throwError("Incorrect number of arguments passed to "
  13506. "QTime::QTime(). This method takes zero, two, "
  13507. "three, or four integer arguments.");
  13508. }
  13509. return object;
  13510. }
  13511. /*:116*//*117:*/
  13512. #line 2796 "./typica.w"
  13513. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  13514. {
  13515. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  13516. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  13517. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  13518. value.setProperty("hour",engine->newFunction(QTime_hour));
  13519. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  13520. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  13521. value.setProperty("minute",engine->newFunction(QTime_minute));
  13522. value.setProperty("msec",engine->newFunction(QTime_msec));
  13523. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  13524. value.setProperty("restart",engine->newFunction(QTime_restart));
  13525. value.setProperty("second",engine->newFunction(QTime_second));
  13526. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  13527. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  13528. value.setProperty("start",engine->newFunction(QTime_start));
  13529. value.setProperty("toString",engine->newFunction(QTime_toString));
  13530. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  13531. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  13532. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  13533. }
  13534. /*:117*//*118:*/
  13535. #line 2825 "./typica.w"
  13536. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  13537. {
  13538. QTime self= getself<QTime> (context);
  13539. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  13540. (self.second()*1000)+self.msec();
  13541. return QScriptValue(retval);
  13542. }
  13543. /*:118*//*119:*/
  13544. #line 2839 "./typica.w"
  13545. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  13546. {
  13547. QTime time;
  13548. QScriptValue retval;
  13549. if(context->argumentCount()==1)
  13550. {
  13551. QTime self= getself<QTime> (context);
  13552. time= self.addMSecs(argument<int> (0,context));
  13553. retval= engine->toScriptValue<QTime> (time);
  13554. setQTimeProperties(retval,engine);
  13555. }
  13556. else
  13557. {
  13558. context->throwError("Incorrect number of arguments passed to "
  13559. "QTime::addMSecs(). This method takes one "
  13560. "integer as an argument.");
  13561. }
  13562. return retval;
  13563. }
  13564. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  13565. {
  13566. QTime time;
  13567. QScriptValue retval;
  13568. if(context->argumentCount()==1)
  13569. {
  13570. QTime self= getself<QTime> (context);
  13571. time= self.addSecs(argument<int> (0,context));
  13572. retval= engine->toScriptValue<QTime> (time);
  13573. setQTimeProperties(retval,engine);
  13574. }
  13575. else
  13576. {
  13577. context->throwError("Incorrect number of arguments passed to "
  13578. "QTime::addSecs(). This method takes one "
  13579. "integer as an argument.");
  13580. }
  13581. return retval;
  13582. }
  13583. /*:119*//*120:*/
  13584. #line 2882 "./typica.w"
  13585. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  13586. {
  13587. QScriptValue retval;
  13588. if(context->argumentCount()==0)
  13589. {
  13590. QTime self= getself<QTime> (context);
  13591. retval= QScriptValue(engine,self.elapsed());
  13592. }
  13593. else
  13594. {
  13595. context->throwError("Incorrect number of arguments passed to "
  13596. "QTime::elapsed(). This method takes no "
  13597. "arguments.");
  13598. }
  13599. return retval;
  13600. }
  13601. /*:120*//*121:*/
  13602. #line 2903 "./typica.w"
  13603. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  13604. {
  13605. QScriptValue retval;
  13606. if(context->argumentCount()==0)
  13607. {
  13608. QTime self= getself<QTime> (context);
  13609. retval= QScriptValue(engine,self.hour());
  13610. }
  13611. else
  13612. {
  13613. context->throwError("Incorrect number of arguments passed to "
  13614. "QTime::hour(). This method takes no "
  13615. "arguments.");
  13616. }
  13617. return retval;
  13618. }
  13619. /*:121*//*122:*/
  13620. #line 2923 "./typica.w"
  13621. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  13622. {
  13623. QScriptValue retval;
  13624. if(context->argumentCount()==0)
  13625. {
  13626. QTime self= getself<QTime> (context);
  13627. retval= QScriptValue(engine,self.minute());
  13628. }
  13629. else
  13630. {
  13631. context->throwError("Incorrect number of arguments passed to "
  13632. "QTime::minute(). This method takes no "
  13633. "arguments.");
  13634. }
  13635. return retval;
  13636. }
  13637. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  13638. {
  13639. QScriptValue retval;
  13640. if(context->argumentCount()==0)
  13641. {
  13642. QTime self= getself<QTime> (context);
  13643. retval= QScriptValue(engine,self.second());
  13644. }
  13645. else
  13646. {
  13647. context->throwError("Incorrect number of arguments passed to "
  13648. "QTime::second(). This method takes no "
  13649. "arguments.");
  13650. }
  13651. return retval;
  13652. }
  13653. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  13654. {
  13655. QScriptValue retval;
  13656. if(context->argumentCount()==0)
  13657. {
  13658. QTime self= getself<QTime> (context);
  13659. retval= QScriptValue(engine,self.msec());
  13660. }
  13661. else
  13662. {
  13663. context->throwError("Incorrect number of arguments passed to "
  13664. "QTime::msec(). This method takes no "
  13665. "arguments.");
  13666. }
  13667. return retval;
  13668. }
  13669. /*:122*//*123:*/
  13670. #line 2979 "./typica.w"
  13671. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  13672. {
  13673. QScriptValue retval;
  13674. if(context->argumentCount()==0)
  13675. {
  13676. QTime self= getself<QTime> (context);
  13677. retval= QScriptValue(engine,self.isNull());
  13678. }
  13679. else
  13680. {
  13681. context->throwError("Incorrect number of arguments passed to "
  13682. "QTime::isNull(). This method takes no "
  13683. "arguments.");
  13684. }
  13685. return retval;
  13686. }
  13687. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  13688. {
  13689. QScriptValue retval;
  13690. if(context->argumentCount()==0)
  13691. {
  13692. QTime self= getself<QTime> (context);
  13693. retval= QScriptValue(engine,self.isValid());
  13694. }
  13695. else
  13696. {
  13697. context->throwError("Incorrect number of arguments passed to "
  13698. "QTime::isValid(). This method takes no "
  13699. "arguments.");
  13700. }
  13701. return retval;
  13702. }
  13703. /*:123*//*124:*/
  13704. #line 3017 "./typica.w"
  13705. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  13706. {
  13707. QScriptValue retval;
  13708. if(context->argumentCount()==1)
  13709. {
  13710. QTime self= getself<QTime> (context);
  13711. QTime arg= argument<QVariant> (0,context).toTime();
  13712. retval= QScriptValue(engine,self.msecsTo(arg));
  13713. }
  13714. else
  13715. {
  13716. context->throwError("Incorrect number of arguments passed to "
  13717. "QTime::msecsTo(). This method takes one QTime.");
  13718. }
  13719. return retval;
  13720. }
  13721. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  13722. {
  13723. QScriptValue retval;
  13724. if(context->argumentCount()==1)
  13725. {
  13726. QTime self= getself<QTime> (context);
  13727. QTime arg= argument<QVariant> (0,context).toTime();
  13728. retval= QScriptValue(engine,self.secsTo(arg));
  13729. }
  13730. else
  13731. {
  13732. context->throwError("Incorrect number of arguments passed to "
  13733. "QTime::secsTo(). This method takes one QTime.");
  13734. }
  13735. return retval;
  13736. }
  13737. /*:124*//*125:*/
  13738. #line 3056 "./typica.w"
  13739. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  13740. {
  13741. QScriptValue retval;
  13742. if(context->argumentCount()==0)
  13743. {
  13744. QTime self= getself<QTime> (context);
  13745. retval= QScriptValue(engine,self.restart());
  13746. }
  13747. else
  13748. {
  13749. context->throwError("Incorrect number of arguments passed to "
  13750. "QTime::restart(). This method takes no "
  13751. "arguments.");
  13752. }
  13753. return retval;
  13754. }
  13755. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  13756. {
  13757. if(context->argumentCount()==0)
  13758. {
  13759. QTime self= getself<QTime> (context);
  13760. self.start();
  13761. }
  13762. else
  13763. {
  13764. context->throwError("Incorrect number of arguments passed to "
  13765. "QTime::start(). This method takes no arguments.");
  13766. }
  13767. return QScriptValue();
  13768. }
  13769. /*:125*//*126:*/
  13770. #line 3092 "./typica.w"
  13771. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  13772. {
  13773. QScriptValue retval;
  13774. if(context->argumentCount()==3||context->argumentCount()==4)
  13775. {
  13776. QTime self= getself<QTime> (context);
  13777. int arg1= 0;
  13778. int arg2= 0;
  13779. int arg3= 0;
  13780. int arg4= 0;
  13781. switch(context->argumentCount())
  13782. {
  13783. case 4:
  13784. arg4= argument<int> (3,context);
  13785. case 3:
  13786. arg3= argument<int> (2,context);
  13787. arg2= argument<int> (1,context);
  13788. arg1= argument<int> (0,context);
  13789. default:
  13790. break;
  13791. }
  13792. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  13793. }
  13794. else
  13795. {
  13796. context->throwError("Incorrect number of arguments passed to "
  13797. "QTime::setHMS(). This method takes three or "
  13798. "four integer arguments.");
  13799. }
  13800. return retval;
  13801. }
  13802. /*:126*//*127:*/
  13803. #line 3128 "./typica.w"
  13804. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  13805. {
  13806. QScriptValue retval;
  13807. if(context->argumentCount()==1)
  13808. {
  13809. QTime self= getself<QTime> (context);
  13810. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  13811. }
  13812. else
  13813. {
  13814. context->throwError("Incorrect number of arguments passed to "
  13815. "QTime::toString(). This method takes one QString "
  13816. "as an argument.");
  13817. }
  13818. return retval;
  13819. }
  13820. /*:127*//*128:*/
  13821. #line 3149 "./typica.w"
  13822. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  13823. {
  13824. QScriptValue object;
  13825. object= engine->toScriptValue<QTime> (QTime::currentTime());
  13826. setQTimeProperties(object,engine);
  13827. return object;
  13828. }
  13829. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  13830. {
  13831. QScriptValue object;
  13832. if(context->argumentCount()==2)
  13833. {
  13834. QString time= argument<QString> (0,context);
  13835. QString format= argument<QString> (1,context);
  13836. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  13837. setQTimeProperties(object,engine);
  13838. }
  13839. else
  13840. {
  13841. context->throwError("Incorrect number of arguments passed to "
  13842. "QTime::fromString(). This method takes two "
  13843. "string arguments.");
  13844. }
  13845. return object;
  13846. }
  13847. /*:128*//*129:*/
  13848. #line 3180 "./typica.w"
  13849. template<> QTime argument(int arg,QScriptContext*context)
  13850. {
  13851. return qscriptvalue_cast<QTime> (context->argument(arg));
  13852. }
  13853. /*:129*//*131:*/
  13854. #line 3198 "./typica.w"
  13855. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  13856. {
  13857. setQFrameProperties(value,engine);
  13858. }
  13859. /*:131*//*133:*/
  13860. #line 3212 "./typica.w"
  13861. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  13862. {
  13863. setQAbstractScrollAreaProperties(value,engine);
  13864. }
  13865. /*:133*//*135:*/
  13866. #line 3226 "./typica.w"
  13867. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  13868. {
  13869. setQAbstractScrollAreaProperties(value,engine);
  13870. }
  13871. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  13872. {
  13873. setQAbstractItemViewProperties(value,engine);
  13874. }
  13875. /*:135*//*138:*/
  13876. #line 3259 "./typica.w"
  13877. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  13878. {
  13879. QScriptValue object= engine->newQObject(new QPushButton());
  13880. setQPushButtonProperties(object,engine);
  13881. return object;
  13882. }
  13883. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  13884. {
  13885. setQAbstractButtonProperties(value,engine);
  13886. }
  13887. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  13888. {
  13889. setQWidgetProperties(value,engine);
  13890. }
  13891. /*:138*//*145:*/
  13892. #line 3371 "./typica.w"
  13893. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  13894. {
  13895. SqlQueryConnection*obj= new SqlQueryConnection();
  13896. QScriptValue object=
  13897. engine->toScriptValue<void*> (obj);
  13898. setQSqlQueryProperties(object,engine);
  13899. return object;
  13900. }
  13901. /*:145*//*146:*/
  13902. #line 3384 "./typica.w"
  13903. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  13904. {
  13905. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  13906. value.setProperty("bindFileData",
  13907. engine->newFunction(QSqlQuery_bindFileData));
  13908. value.setProperty("bindDeviceData",
  13909. engine->newFunction(QSqlQuery_bindDeviceData));
  13910. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  13911. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  13912. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  13913. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  13914. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  13915. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  13916. }
  13917. /*:146*//*147:*/
  13918. #line 3402 "./typica.w"
  13919. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  13920. {
  13921. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  13922. QScriptValue retval;
  13923. if(context->argumentCount()==1)
  13924. {
  13925. retval= QScriptValue(engine,
  13926. q->exec(argument<QString> (0,context)));
  13927. }
  13928. else
  13929. {
  13930. retval= QScriptValue(engine,q->exec());
  13931. }
  13932. if(q->lastError().isValid())
  13933. {
  13934. qDebug()<<q->lastQuery();
  13935. qDebug()<<q->lastError().text();
  13936. }
  13937. return retval;
  13938. }
  13939. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  13940. {
  13941. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13942. return QScriptValue(query->lastQuery());
  13943. }
  13944. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  13945. {
  13946. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13947. return QScriptValue(engine,query->next());
  13948. }
  13949. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  13950. {
  13951. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13952. return QScriptValue(engine,
  13953. query->value(argument<int> (0,context)).toString());
  13954. }
  13955. /*:147*//*148:*/
  13956. #line 3446 "./typica.w"
  13957. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  13958. {
  13959. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13960. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  13961. }
  13962. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  13963. {
  13964. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13965. query->bindValue(argument<QString> (0,context),
  13966. argument<QVariant> (1,context));
  13967. return QScriptValue();
  13968. }
  13969. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  13970. QScriptEngine*)
  13971. {
  13972. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13973. QString placeholder= argument<QString> (0,context);
  13974. QString filename= argument<QString> (1,context);
  13975. QFile file(filename);
  13976. QByteArray data;
  13977. if(file.open(QIODevice::ReadOnly))
  13978. {
  13979. data= file.readAll();
  13980. file.close();
  13981. }
  13982. query->bindValue(placeholder,data);
  13983. return QScriptValue();
  13984. }
  13985. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  13986. QScriptEngine*)
  13987. {
  13988. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  13989. QString placeholder= argument<QString> (0,context);
  13990. QIODevice*device= argument<QIODevice*> (1,context);
  13991. device->reset();
  13992. QByteArray data;
  13993. data= device->readAll();
  13994. query->bindValue(placeholder,data);
  13995. return QScriptValue();
  13996. }
  13997. /*:148*//*149:*/
  13998. #line 3498 "./typica.w"
  13999. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  14000. {
  14001. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  14002. delete query;
  14003. return QScriptValue::UndefinedValue;
  14004. }
  14005. /*:149*//*152:*/
  14006. #line 3544 "./typica.w"
  14007. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  14008. {
  14009. QFileInfo info(argument<QString> (0,context));
  14010. QScriptValue retval(engine,info.baseName());
  14011. return retval;
  14012. }
  14013. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  14014. {
  14015. QFileInfo info(argument<QString> (0,context));
  14016. QDir dir= info.dir();
  14017. QScriptValue retval(engine,dir.path());
  14018. return retval;
  14019. }
  14020. /*:152*//*153:*/
  14021. #line 3563 "./typica.w"
  14022. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  14023. {
  14024. QString source= argument<QString> (0,context);
  14025. source.remove(0,1);
  14026. source.chop(1);
  14027. QStringList elements= source.split(",");
  14028. QString element;
  14029. QScriptValue dest= engine->newArray(elements.size());
  14030. int i= 0;
  14031. foreach(element,elements)
  14032. {
  14033. if(element.startsWith("\"")&&element.endsWith("\""))
  14034. {
  14035. element.chop(1);
  14036. element= element.remove(0,1);
  14037. }
  14038. dest.setProperty(i,QScriptValue(engine,element));
  14039. i++;
  14040. }
  14041. return dest;
  14042. }
  14043. /*:153*//*154:*/
  14044. #line 3589 "./typica.w"
  14045. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  14046. {
  14047. QString font= argument<QString> (0,context);
  14048. QString classname;
  14049. if(context->argumentCount()> 1)
  14050. {
  14051. classname= argument<QString> (1,context);
  14052. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  14053. }
  14054. else
  14055. {
  14056. QApplication::setFont(QFont(font));
  14057. }
  14058. return QScriptValue();
  14059. }
  14060. /*:154*//*155:*/
  14061. #line 3609 "./typica.w"
  14062. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  14063. {
  14064. SqlQueryConnection h;
  14065. QSqlQuery*query= h.operator->();
  14066. QString q= "SELECT file FROM files WHERE id = :file";
  14067. query->prepare(q);
  14068. query->bindValue(":file",argument<int> (0,context));
  14069. query->exec();
  14070. query->next();
  14071. QByteArray array= query->value(0).toByteArray();
  14072. QBuffer buffer(&array);
  14073. buffer.open(QIODevice::ReadOnly);
  14074. QXmlQuery xquery;
  14075. xquery.bindVariable("profile",&buffer);
  14076. QString xq;
  14077. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  14078. xquery.setQuery(xq);
  14079. QString result;
  14080. xquery.evaluateTo(&result);
  14081. return QScriptValue(result);
  14082. }
  14083. /*:155*//*156:*/
  14084. #line 3636 "./typica.w"
  14085. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  14086. {
  14087. QWidget::setTabOrder(argument<QWidget*> (0,context),
  14088. argument<QWidget*> (1,context));
  14089. return QScriptValue();
  14090. }
  14091. /*:156*//*157:*/
  14092. #line 3648 "./typica.w"
  14093. QScriptValue findWindowByName(QScriptContext*context,QScriptEngine*engine)
  14094. {
  14095. QWidgetList windows= QApplication::topLevelWidgets();
  14096. QVariantList matches;
  14097. QScriptValue value;
  14098. foreach(QWidget*object,windows)
  14099. {
  14100. if(object->isWindow())
  14101. {
  14102. if(object->objectName()==argument<QString> (0,context))
  14103. {
  14104. value= engine->newQObject(object);
  14105. QString className= object->metaObject()->className();
  14106. /*218:*/
  14107. #line 5466 "./typica.w"
  14108. if(className=="TemperatureDisplay")
  14109. {
  14110. setTemperatureDisplayProperties(value,engine);
  14111. }
  14112. else if(className=="TimerDisplay")
  14113. {
  14114. setTimerDisplayProperties(value,engine);
  14115. }
  14116. else if(className=="QAction")
  14117. {
  14118. setQActionProperties(value,engine);
  14119. }
  14120. else if(className=="QBoxLayout")
  14121. {
  14122. setQBoxLayoutProperties(value,engine);
  14123. }
  14124. else if(className=="QDateEdit")
  14125. {
  14126. setQDateEditProperties(value,engine);
  14127. }
  14128. else if(className=="QDateTimeEdit")
  14129. {
  14130. setQDateTimeEditProperties(value,engine);
  14131. }
  14132. else if(className=="QFrame")
  14133. {
  14134. setQFrameProperties(value,engine);
  14135. }
  14136. else if(className=="QHBoxLayout")
  14137. {
  14138. setQBoxLayoutProperties(value,engine);
  14139. }
  14140. else if(className=="QLCDNumber")
  14141. {
  14142. setQLCDNumberProperties(value,engine);
  14143. }
  14144. else if(className=="QMenu")
  14145. {
  14146. setQMenuProperties(value,engine);
  14147. }
  14148. else if(className=="QMenuBar")
  14149. {
  14150. setQMenuBarProperties(value,engine);
  14151. }
  14152. else if(className=="QPushButton")
  14153. {
  14154. setQPushButtonProperties(value,engine);
  14155. }
  14156. else if(className=="QSplitter")
  14157. {
  14158. setQSplitterProperties(value,engine);
  14159. }
  14160. else if(className=="QTableView")
  14161. {
  14162. if(object->property("tabletype").isValid())
  14163. {
  14164. if(object->property("tabletype").toString()=="SaltTable")
  14165. {
  14166. setSaltTableProperties(value,engine);
  14167. }
  14168. }
  14169. }
  14170. else if(className=="QVBoxLayout")
  14171. {
  14172. setQBoxLayoutProperties(value,engine);
  14173. }
  14174. else if(className=="QWidget")
  14175. {
  14176. setQWidgetProperties(value,engine);
  14177. }
  14178. else if(className=="ScriptQMainWindow")
  14179. {
  14180. setQMainWindowProperties(value,engine);
  14181. }
  14182. else if(className=="SqlComboBox")
  14183. {
  14184. setSqlComboBoxProperties(value,engine);
  14185. }
  14186. else if(className=="SqlQueryView")
  14187. {
  14188. setSqlQueryViewProperties(value,engine);
  14189. }
  14190. else if(className=="ZoomLog")
  14191. {
  14192. setZoomLogProperties(value,engine);
  14193. }
  14194. else if(className=="QTextEdit")
  14195. {
  14196. setQTextEditProperties(value,engine);
  14197. }
  14198. else if(className=="QWebView")
  14199. {
  14200. setQWebViewProperties(value,engine);
  14201. }
  14202. else if(className=="QLineEdit")
  14203. {
  14204. setQLineEditProperties(value,engine);
  14205. }
  14206. /*:218*/
  14207. #line 3662 "./typica.w"
  14208. matches.append(value.toVariant());
  14209. }
  14210. }
  14211. }
  14212. return engine->toScriptValue(matches);
  14213. }
  14214. /*:157*//*164:*/
  14215. #line 3907 "./typica.w"
  14216. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  14217. {
  14218. QString targetID= argument<QString> (0,context);
  14219. QDomNode element;
  14220. QScriptValue object;
  14221. /*166:*/
  14222. #line 3954 "./typica.w"
  14223. QDomNodeList windows=
  14224. AppInstance->configuration()->documentElement().elementsByTagName("window");
  14225. QDomNode nullNode;
  14226. int i= 0;
  14227. element= nullNode;
  14228. while(i<windows.count())
  14229. {
  14230. element= windows.at(i);
  14231. QDomNamedNodeMap attributes= element.attributes();
  14232. if(attributes.contains("id"))
  14233. {
  14234. if(attributes.namedItem("id").toAttr().value()==targetID)
  14235. {
  14236. break;
  14237. }
  14238. }
  14239. element= nullNode;
  14240. i++;
  14241. }
  14242. /*:166*/
  14243. #line 3913 "./typica.w"
  14244. if(!element.isNull())
  14245. {
  14246. /*167:*/
  14247. #line 3986 "./typica.w"
  14248. ScriptQMainWindow*window= new ScriptQMainWindow;
  14249. window->setObjectName(targetID);
  14250. object= engine->newQObject(window);
  14251. setQMainWindowProperties(object,engine);
  14252. QWidget*central= new(QWidget);
  14253. central->setParent(window);
  14254. central->setObjectName("centralWidget");
  14255. window->setCentralWidget(central);
  14256. if(element.hasChildNodes())
  14257. {
  14258. /*168:*/
  14259. #line 4021 "./typica.w"
  14260. QStack<QWidget*> widgetStack;
  14261. QStack<QLayout*> layoutStack;
  14262. QString windowScript;
  14263. widgetStack.push(central);
  14264. QDomNodeList windowChildren= element.childNodes();
  14265. int i= 0;
  14266. while(i<windowChildren.count())
  14267. {
  14268. QDomNode current;
  14269. QDomElement element;
  14270. current= windowChildren.at(i);
  14271. if(current.isElement())
  14272. {
  14273. element= current.toElement();
  14274. if(element.tagName()=="program")
  14275. {
  14276. windowScript.append(element.text());
  14277. }
  14278. else if(element.tagName()=="layout")
  14279. {
  14280. addLayoutToWidget(element,&widgetStack,&layoutStack);
  14281. }
  14282. else if(element.tagName()=="menu")
  14283. {
  14284. /*169:*/
  14285. #line 4068 "./typica.w"
  14286. QMenuBar*bar= window->menuBar();
  14287. bar->setParent(window);
  14288. bar->setObjectName("menuBar");
  14289. if(element.hasAttribute("name"))
  14290. {
  14291. QMenu*menu= bar->addMenu(element.attribute("name"));
  14292. menu->setParent(bar);
  14293. if(element.hasAttribute("type"))
  14294. {
  14295. if(element.attribute("type")=="reports")
  14296. {
  14297. if(element.hasAttribute("src"))
  14298. {
  14299. /*593:*/
  14300. #line 13026 "./typica.w"
  14301. QSettings settings;
  14302. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  14303. toString()).
  14304. arg(element.attribute("src"));
  14305. QDir::addSearchPath("reports",reportDirectory);
  14306. QDir directory(reportDirectory);
  14307. directory.setFilter(QDir::Files);
  14308. directory.setSorting(QDir::Name);
  14309. QStringList nameFilter;
  14310. nameFilter<<"*.xml";
  14311. directory.setNameFilters(nameFilter);
  14312. QFileInfoList reportFiles= directory.entryInfoList();
  14313. for(int i= 0;i<reportFiles.size();i++)
  14314. {
  14315. QFileInfo reportFile= reportFiles.at(i);
  14316. /*597:*/
  14317. #line 13106 "./typica.w"
  14318. QString path= reportFile.absoluteFilePath();
  14319. QFile file(path);
  14320. if(file.open(QIODevice::ReadOnly))
  14321. {
  14322. QDomDocument document;
  14323. document.setContent(&file,true);
  14324. QDomElement root= document.documentElement();
  14325. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  14326. if(!titleNode.isNull())
  14327. {
  14328. QDomElement titleElement= titleNode.toElement();
  14329. QString title= titleElement.text();
  14330. if(!title.isEmpty())
  14331. {
  14332. QStringList hierarchy= title.split(":->");
  14333. QMenu*insertionPoint= menu;
  14334. /*598:*/
  14335. #line 13133 "./typica.w"
  14336. for(int j= 0;j<hierarchy.size()-1;j++)
  14337. {
  14338. QObjectList menuList= insertionPoint->children();
  14339. bool menuFound= false;
  14340. for(int k= 0;k<menuList.size();k++)
  14341. {
  14342. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  14343. if(currentItem)
  14344. {
  14345. if(currentItem->title()==hierarchy.at(j))
  14346. {
  14347. menuFound= true;
  14348. insertionPoint= currentItem;
  14349. break;
  14350. }
  14351. }
  14352. }
  14353. if(!menuFound)
  14354. {
  14355. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  14356. }
  14357. }
  14358. /*:598*/
  14359. #line 13123 "./typica.w"
  14360. ReportAction*action= new ReportAction(path,hierarchy.last());
  14361. insertionPoint->addAction(action);
  14362. }
  14363. }
  14364. }
  14365. /*:597*/
  14366. #line 13042 "./typica.w"
  14367. }
  14368. /*:593*/
  14369. #line 4082 "./typica.w"
  14370. }
  14371. }
  14372. }
  14373. if(element.hasChildNodes())
  14374. {
  14375. /*170:*/
  14376. #line 4095 "./typica.w"
  14377. QDomNodeList menuItems= element.childNodes();
  14378. int j= 0;
  14379. while(j<menuItems.count())
  14380. {
  14381. QDomNode item= menuItems.at(j);
  14382. if(item.isElement())
  14383. {
  14384. QDomElement itemElement= item.toElement();
  14385. if(itemElement.tagName()=="item")
  14386. {
  14387. QAction*itemAction= new QAction(itemElement.text(),menu);
  14388. if(itemElement.hasAttribute("id"))
  14389. {
  14390. itemAction->setObjectName(itemElement.attribute("id"));
  14391. }
  14392. if(itemElement.hasAttribute("shortcut"))
  14393. {
  14394. itemAction->setShortcut(itemElement.attribute("shortcut"));
  14395. }
  14396. menu->addAction(itemAction);
  14397. }
  14398. else if(itemElement.tagName()=="separator")
  14399. {
  14400. menu->addSeparator();
  14401. }
  14402. }
  14403. j++;
  14404. }
  14405. #line 1 "./helpmenu.w"
  14406. /*:170*/
  14407. #line 4088 "./typica.w"
  14408. }
  14409. }
  14410. /*:169*/
  14411. #line 4046 "./typica.w"
  14412. }
  14413. }
  14414. i++;
  14415. }
  14416. QScriptValue oldThis= context->thisObject();
  14417. context->setThisObject(object);
  14418. QScriptValue result= engine->evaluate(windowScript);
  14419. /*161:*/
  14420. #line 3803 "./typica.w"
  14421. if(engine->hasUncaughtException())
  14422. {
  14423. int line= engine->uncaughtExceptionLineNumber();
  14424. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  14425. result.toString();
  14426. QString trace;
  14427. foreach(trace,engine->uncaughtExceptionBacktrace())
  14428. {
  14429. qDebug()<<trace;
  14430. }
  14431. }
  14432. /*:161*/
  14433. #line 4054 "./typica.w"
  14434. context->setThisObject(oldThis);
  14435. /*:168*/
  14436. #line 3997 "./typica.w"
  14437. }
  14438. /*171:*/
  14439. #line 9 "./helpmenu.w"
  14440. HelpMenu*helpMenu= new HelpMenu();
  14441. window->menuBar()->addMenu(helpMenu);
  14442. /*:171*/
  14443. #line 3999 "./typica.w"
  14444. window->show();
  14445. /*:167*/
  14446. #line 3916 "./typica.w"
  14447. }
  14448. return object;
  14449. }
  14450. /*:164*//*165:*/
  14451. #line 3927 "./typica.w"
  14452. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  14453. {
  14454. QString targetID= argument<QString> (0,context);
  14455. QFile file(QString("reports:%1").arg(targetID));
  14456. QScriptValue object;
  14457. if(file.open(QIODevice::ReadOnly))
  14458. {
  14459. QDomDocument document;
  14460. document.setContent(&file,true);
  14461. QDomElement element= document.documentElement();
  14462. if(!element.isNull())
  14463. {
  14464. /*167:*/
  14465. #line 3986 "./typica.w"
  14466. ScriptQMainWindow*window= new ScriptQMainWindow;
  14467. window->setObjectName(targetID);
  14468. object= engine->newQObject(window);
  14469. setQMainWindowProperties(object,engine);
  14470. QWidget*central= new(QWidget);
  14471. central->setParent(window);
  14472. central->setObjectName("centralWidget");
  14473. window->setCentralWidget(central);
  14474. if(element.hasChildNodes())
  14475. {
  14476. /*168:*/
  14477. #line 4021 "./typica.w"
  14478. QStack<QWidget*> widgetStack;
  14479. QStack<QLayout*> layoutStack;
  14480. QString windowScript;
  14481. widgetStack.push(central);
  14482. QDomNodeList windowChildren= element.childNodes();
  14483. int i= 0;
  14484. while(i<windowChildren.count())
  14485. {
  14486. QDomNode current;
  14487. QDomElement element;
  14488. current= windowChildren.at(i);
  14489. if(current.isElement())
  14490. {
  14491. element= current.toElement();
  14492. if(element.tagName()=="program")
  14493. {
  14494. windowScript.append(element.text());
  14495. }
  14496. else if(element.tagName()=="layout")
  14497. {
  14498. addLayoutToWidget(element,&widgetStack,&layoutStack);
  14499. }
  14500. else if(element.tagName()=="menu")
  14501. {
  14502. /*169:*/
  14503. #line 4068 "./typica.w"
  14504. QMenuBar*bar= window->menuBar();
  14505. bar->setParent(window);
  14506. bar->setObjectName("menuBar");
  14507. if(element.hasAttribute("name"))
  14508. {
  14509. QMenu*menu= bar->addMenu(element.attribute("name"));
  14510. menu->setParent(bar);
  14511. if(element.hasAttribute("type"))
  14512. {
  14513. if(element.attribute("type")=="reports")
  14514. {
  14515. if(element.hasAttribute("src"))
  14516. {
  14517. /*593:*/
  14518. #line 13026 "./typica.w"
  14519. QSettings settings;
  14520. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  14521. toString()).
  14522. arg(element.attribute("src"));
  14523. QDir::addSearchPath("reports",reportDirectory);
  14524. QDir directory(reportDirectory);
  14525. directory.setFilter(QDir::Files);
  14526. directory.setSorting(QDir::Name);
  14527. QStringList nameFilter;
  14528. nameFilter<<"*.xml";
  14529. directory.setNameFilters(nameFilter);
  14530. QFileInfoList reportFiles= directory.entryInfoList();
  14531. for(int i= 0;i<reportFiles.size();i++)
  14532. {
  14533. QFileInfo reportFile= reportFiles.at(i);
  14534. /*597:*/
  14535. #line 13106 "./typica.w"
  14536. QString path= reportFile.absoluteFilePath();
  14537. QFile file(path);
  14538. if(file.open(QIODevice::ReadOnly))
  14539. {
  14540. QDomDocument document;
  14541. document.setContent(&file,true);
  14542. QDomElement root= document.documentElement();
  14543. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  14544. if(!titleNode.isNull())
  14545. {
  14546. QDomElement titleElement= titleNode.toElement();
  14547. QString title= titleElement.text();
  14548. if(!title.isEmpty())
  14549. {
  14550. QStringList hierarchy= title.split(":->");
  14551. QMenu*insertionPoint= menu;
  14552. /*598:*/
  14553. #line 13133 "./typica.w"
  14554. for(int j= 0;j<hierarchy.size()-1;j++)
  14555. {
  14556. QObjectList menuList= insertionPoint->children();
  14557. bool menuFound= false;
  14558. for(int k= 0;k<menuList.size();k++)
  14559. {
  14560. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  14561. if(currentItem)
  14562. {
  14563. if(currentItem->title()==hierarchy.at(j))
  14564. {
  14565. menuFound= true;
  14566. insertionPoint= currentItem;
  14567. break;
  14568. }
  14569. }
  14570. }
  14571. if(!menuFound)
  14572. {
  14573. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  14574. }
  14575. }
  14576. /*:598*/
  14577. #line 13123 "./typica.w"
  14578. ReportAction*action= new ReportAction(path,hierarchy.last());
  14579. insertionPoint->addAction(action);
  14580. }
  14581. }
  14582. }
  14583. /*:597*/
  14584. #line 13042 "./typica.w"
  14585. }
  14586. /*:593*/
  14587. #line 4082 "./typica.w"
  14588. }
  14589. }
  14590. }
  14591. if(element.hasChildNodes())
  14592. {
  14593. /*170:*/
  14594. #line 4095 "./typica.w"
  14595. QDomNodeList menuItems= element.childNodes();
  14596. int j= 0;
  14597. while(j<menuItems.count())
  14598. {
  14599. QDomNode item= menuItems.at(j);
  14600. if(item.isElement())
  14601. {
  14602. QDomElement itemElement= item.toElement();
  14603. if(itemElement.tagName()=="item")
  14604. {
  14605. QAction*itemAction= new QAction(itemElement.text(),menu);
  14606. if(itemElement.hasAttribute("id"))
  14607. {
  14608. itemAction->setObjectName(itemElement.attribute("id"));
  14609. }
  14610. if(itemElement.hasAttribute("shortcut"))
  14611. {
  14612. itemAction->setShortcut(itemElement.attribute("shortcut"));
  14613. }
  14614. menu->addAction(itemAction);
  14615. }
  14616. else if(itemElement.tagName()=="separator")
  14617. {
  14618. menu->addSeparator();
  14619. }
  14620. }
  14621. j++;
  14622. }
  14623. #line 1 "./helpmenu.w"
  14624. /*:170*/
  14625. #line 4088 "./typica.w"
  14626. }
  14627. }
  14628. /*:169*/
  14629. #line 4046 "./typica.w"
  14630. }
  14631. }
  14632. i++;
  14633. }
  14634. QScriptValue oldThis= context->thisObject();
  14635. context->setThisObject(object);
  14636. QScriptValue result= engine->evaluate(windowScript);
  14637. /*161:*/
  14638. #line 3803 "./typica.w"
  14639. if(engine->hasUncaughtException())
  14640. {
  14641. int line= engine->uncaughtExceptionLineNumber();
  14642. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  14643. result.toString();
  14644. QString trace;
  14645. foreach(trace,engine->uncaughtExceptionBacktrace())
  14646. {
  14647. qDebug()<<trace;
  14648. }
  14649. }
  14650. /*:161*/
  14651. #line 4054 "./typica.w"
  14652. context->setThisObject(oldThis);
  14653. /*:168*/
  14654. #line 3997 "./typica.w"
  14655. }
  14656. /*171:*/
  14657. #line 9 "./helpmenu.w"
  14658. HelpMenu*helpMenu= new HelpMenu();
  14659. window->menuBar()->addMenu(helpMenu);
  14660. /*:171*/
  14661. #line 3999 "./typica.w"
  14662. window->show();
  14663. /*:167*/
  14664. #line 3940 "./typica.w"
  14665. }
  14666. file.close();
  14667. }
  14668. return object;
  14669. }
  14670. /*:165*//*176:*/
  14671. #line 4137 "./typica.w"
  14672. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  14673. QStack<QLayout*> *layoutStack)
  14674. {
  14675. if(element.hasAttribute("type"))
  14676. {
  14677. /*177:*/
  14678. #line 4158 "./typica.w"
  14679. QLayout*layout;
  14680. QString layoutType= element.attribute("type");
  14681. if(layoutType=="horizontal")
  14682. {
  14683. layout= new QHBoxLayout;
  14684. layoutStack->push(layout);
  14685. populateBoxLayout(element,widgetStack,layoutStack);
  14686. }
  14687. else if(layoutType=="vertical")
  14688. {
  14689. layout= new QVBoxLayout;
  14690. layoutStack->push(layout);
  14691. populateBoxLayout(element,widgetStack,layoutStack);
  14692. }
  14693. else if(layoutType=="grid")
  14694. {
  14695. layout= new QGridLayout;
  14696. layoutStack->push(layout);
  14697. populateGridLayout(element,widgetStack,layoutStack);
  14698. }
  14699. else if(layoutType=="stack")
  14700. {
  14701. layout= new QStackedLayout;
  14702. layoutStack->push(layout);
  14703. populateStackedLayout(element,widgetStack,layoutStack);
  14704. }
  14705. if(element.hasAttribute("id"))
  14706. {
  14707. layout->setObjectName(element.attribute("id"));
  14708. }
  14709. if(element.hasAttribute("spacing"))
  14710. {
  14711. layout->setSpacing(element.attribute("spacing").toInt());
  14712. }
  14713. if(element.hasAttribute("margin"))
  14714. {
  14715. int m= element.attribute("margin").toInt();
  14716. layout->setContentsMargins(m,m,m,m);
  14717. }
  14718. /*:177*/
  14719. #line 4143 "./typica.w"
  14720. QWidget*widget= widgetStack->top();
  14721. if(layout)
  14722. {
  14723. widget->setLayout(layout);
  14724. }
  14725. layoutStack->pop();
  14726. }
  14727. }
  14728. /*:176*//*178:*/
  14729. #line 4205 "./typica.w"
  14730. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  14731. QStack<QLayout*> *layoutStack)
  14732. {
  14733. QDomNodeList children= element.childNodes();
  14734. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  14735. for(int i= 0;i<children.count();i++)
  14736. {
  14737. QDomNode current;
  14738. QDomElement currentElement;
  14739. current= children.at(i);
  14740. if(current.isElement())
  14741. {
  14742. currentElement= current.toElement();
  14743. if(currentElement.tagName()=="page")
  14744. {
  14745. QWidget*widget= new QWidget;
  14746. layout->addWidget(widget);
  14747. widgetStack->push(widget);
  14748. populateWidget(currentElement,widgetStack,layoutStack);
  14749. widgetStack->pop();
  14750. }
  14751. }
  14752. }
  14753. }
  14754. /*:178*//*179:*/
  14755. #line 4237 "./typica.w"
  14756. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  14757. QStack<QLayout*> *layoutStack)
  14758. {
  14759. QDomNodeList children= element.childNodes();
  14760. int row= -1;
  14761. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  14762. for(int i= 0;i<children.count();i++)
  14763. {
  14764. QDomNode current;
  14765. QDomElement currentElement;
  14766. current= children.at(i);
  14767. if(current.isElement())
  14768. {
  14769. currentElement= current.toElement();
  14770. if(currentElement.tagName()=="row")
  14771. {
  14772. row++;
  14773. if(currentElement.hasAttribute("height"))
  14774. {
  14775. layout->setRowMinimumHeight(row,
  14776. currentElement.attribute("height").toInt());
  14777. }
  14778. if(currentElement.hasAttribute("stretch"))
  14779. {
  14780. layout->setRowStretch(row,
  14781. currentElement.attribute("stretch").toInt());
  14782. }
  14783. /*180:*/
  14784. #line 4293 "./typica.w"
  14785. int column= -1;
  14786. QDomNodeList rowChildren= currentElement.childNodes();
  14787. for(int j= 0;j<rowChildren.count();j++)
  14788. {
  14789. QDomNode columnNode;
  14790. QDomElement columnElement;
  14791. columnNode= rowChildren.at(j);
  14792. if(columnNode.isElement())
  14793. {
  14794. columnElement= columnNode.toElement();
  14795. if(columnElement.tagName()=="column")
  14796. {
  14797. column++;
  14798. if(columnElement.hasAttribute("column"))
  14799. {
  14800. column= columnElement.attribute("column").toInt();
  14801. }
  14802. if(columnElement.hasAttribute("width"))
  14803. {
  14804. layout->setColumnMinimumWidth(column,
  14805. columnElement.attribute("width").toInt());
  14806. }
  14807. if(columnElement.hasAttribute("stretch"))
  14808. {
  14809. layout->setColumnStretch(column,
  14810. columnElement.attribute("stretch").toInt());
  14811. }
  14812. int hspan= 1;
  14813. int vspan= 1;
  14814. if(columnElement.hasAttribute("rowspan"))
  14815. {
  14816. vspan= columnElement.attribute("rowspan").toInt();
  14817. }
  14818. if(columnElement.hasAttribute("colspan"))
  14819. {
  14820. hspan= columnElement.attribute("colspan").toInt();
  14821. }
  14822. QHBoxLayout*cell= new QHBoxLayout;
  14823. layout->addLayout(cell,row,column,vspan,hspan);
  14824. layoutStack->push(cell);
  14825. populateBoxLayout(columnElement,widgetStack,layoutStack);
  14826. layoutStack->pop();
  14827. }
  14828. }
  14829. }
  14830. /*:180*/
  14831. #line 4265 "./typica.w"
  14832. }
  14833. }
  14834. }
  14835. }
  14836. /*:179*//*181:*/
  14837. #line 4343 "./typica.w"
  14838. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  14839. QStack<QLayout*> *layoutStack)
  14840. {
  14841. QDomNodeList children= element.childNodes();
  14842. for(int i= 0;i<children.count();i++)
  14843. {
  14844. QDomNode current;
  14845. QDomElement currentElement;
  14846. current= children.at(i);
  14847. if(current.isElement())
  14848. {
  14849. currentElement= current.toElement();
  14850. if(currentElement.tagName()=="button")
  14851. {
  14852. addButtonToLayout(currentElement,widgetStack,layoutStack);
  14853. }
  14854. else if(currentElement.tagName()=="calendar")
  14855. {
  14856. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  14857. }
  14858. else if(currentElement.tagName()=="decoration")
  14859. {
  14860. addDecorationToLayout(currentElement,widgetStack,
  14861. layoutStack);
  14862. }
  14863. else if(currentElement.tagName()=="layout")
  14864. {
  14865. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  14866. }
  14867. else if(currentElement.tagName()=="splitter")
  14868. {
  14869. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  14870. }
  14871. else if(currentElement.tagName()=="label")
  14872. {
  14873. QBoxLayout*layout=
  14874. qobject_cast<QBoxLayout*> (layoutStack->top());
  14875. QLabel*label= new QLabel(currentElement.text());
  14876. layout->addWidget(label);
  14877. }
  14878. else if(currentElement.tagName()=="lcdtemperature")
  14879. {
  14880. addTemperatureDisplayToLayout(currentElement,widgetStack,
  14881. layoutStack);
  14882. }
  14883. else if(currentElement.tagName()=="lcdtimer")
  14884. {
  14885. addTimerDisplayToLayout(currentElement,widgetStack,
  14886. layoutStack);
  14887. }
  14888. else if(currentElement.tagName()=="line")
  14889. {
  14890. addLineToLayout(currentElement,widgetStack,layoutStack);
  14891. }
  14892. else if(currentElement.tagName()=="report")
  14893. {
  14894. addReportToLayout(currentElement,widgetStack,layoutStack);
  14895. }
  14896. else if(currentElement.tagName()=="sqldrop")
  14897. {
  14898. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  14899. }
  14900. else if(currentElement.tagName()=="sqltablearray")
  14901. {
  14902. addSaltToLayout(currentElement,widgetStack,layoutStack);
  14903. }
  14904. else if(currentElement.tagName()=="sqlview")
  14905. {
  14906. addSqlQueryViewToLayout(currentElement,widgetStack,
  14907. layoutStack);
  14908. }
  14909. else if(currentElement.tagName()=="textarea")
  14910. {
  14911. addTextToLayout(currentElement,widgetStack,layoutStack);
  14912. }
  14913. else if(currentElement.tagName()=="spinbox")
  14914. {
  14915. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  14916. }
  14917. else if(currentElement.tagName()=="formarray")
  14918. {
  14919. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  14920. }
  14921. else if(currentElement.tagName()=="hscale")
  14922. {
  14923. addScaleControlToLayout(currentElement,widgetStack,
  14924. layoutStack);
  14925. }
  14926. else if(currentElement.tagName()=="vscale")
  14927. {
  14928. addIntensityControlToLayout(currentElement,widgetStack,
  14929. layoutStack);
  14930. }
  14931. else if(currentElement.tagName()=="webview")
  14932. {
  14933. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  14934. }
  14935. else if(currentElement.tagName()=="stretch")
  14936. {
  14937. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14938. layout->addStretch();
  14939. }
  14940. /*635:*/
  14941. #line 441 "./daterangeselector.w"
  14942. else if(currentElement.tagName()=="daterange")
  14943. {
  14944. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  14945. }
  14946. /*:635*/
  14947. #line 4446 "./typica.w"
  14948. }
  14949. }
  14950. }
  14951. /*:181*//*182:*/
  14952. #line 4454 "./typica.w"
  14953. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  14954. QStack<QLayout*> *layoutStack)
  14955. {
  14956. QLayout*targetLayout= layoutStack->pop();
  14957. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  14958. if(element.hasAttribute("type"))
  14959. {
  14960. /*177:*/
  14961. #line 4158 "./typica.w"
  14962. QLayout*layout;
  14963. QString layoutType= element.attribute("type");
  14964. if(layoutType=="horizontal")
  14965. {
  14966. layout= new QHBoxLayout;
  14967. layoutStack->push(layout);
  14968. populateBoxLayout(element,widgetStack,layoutStack);
  14969. }
  14970. else if(layoutType=="vertical")
  14971. {
  14972. layout= new QVBoxLayout;
  14973. layoutStack->push(layout);
  14974. populateBoxLayout(element,widgetStack,layoutStack);
  14975. }
  14976. else if(layoutType=="grid")
  14977. {
  14978. layout= new QGridLayout;
  14979. layoutStack->push(layout);
  14980. populateGridLayout(element,widgetStack,layoutStack);
  14981. }
  14982. else if(layoutType=="stack")
  14983. {
  14984. layout= new QStackedLayout;
  14985. layoutStack->push(layout);
  14986. populateStackedLayout(element,widgetStack,layoutStack);
  14987. }
  14988. if(element.hasAttribute("id"))
  14989. {
  14990. layout->setObjectName(element.attribute("id"));
  14991. }
  14992. if(element.hasAttribute("spacing"))
  14993. {
  14994. layout->setSpacing(element.attribute("spacing").toInt());
  14995. }
  14996. if(element.hasAttribute("margin"))
  14997. {
  14998. int m= element.attribute("margin").toInt();
  14999. layout->setContentsMargins(m,m,m,m);
  15000. }
  15001. /*:177*/
  15002. #line 4462 "./typica.w"
  15003. boxLayout->addLayout(layout);
  15004. layoutStack->pop();
  15005. }
  15006. layoutStack->push(targetLayout);
  15007. }
  15008. /*:182*//*183:*/
  15009. #line 4473 "./typica.w"
  15010. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  15011. QStack<QLayout*> *layoutStack)
  15012. {
  15013. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15014. QSplitter*splitter= new(QSplitter);
  15015. layout->addWidget(splitter);
  15016. /*184:*/
  15017. #line 4486 "./typica.w"
  15018. QString orientation= element.attribute("type");
  15019. if(orientation=="horizontal")
  15020. {
  15021. splitter->setOrientation(Qt::Horizontal);
  15022. }
  15023. else if(orientation=="vertical")
  15024. {
  15025. splitter->setOrientation(Qt::Vertical);
  15026. }
  15027. QString id= element.attribute("id");
  15028. if(!id.isEmpty())
  15029. {
  15030. splitter->setObjectName(id);
  15031. }
  15032. if(element.hasChildNodes())
  15033. {
  15034. widgetStack->push(splitter);
  15035. populateSplitter(element,widgetStack,layoutStack);
  15036. widgetStack->pop();
  15037. }
  15038. /*:184*/
  15039. #line 4480 "./typica.w"
  15040. }
  15041. /*:183*//*185:*/
  15042. #line 4512 "./typica.w"
  15043. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15044. QStack<QLayout*> *layoutStack)
  15045. {
  15046. QDomNodeList children= element.childNodes();
  15047. for(int i= 0;i<children.count();i++)
  15048. {
  15049. QDomNode current;
  15050. QDomElement currentElement;
  15051. current= children.at(i);
  15052. if(current.isElement())
  15053. {
  15054. currentElement= current.toElement();
  15055. if(currentElement.tagName()=="decoration")
  15056. {
  15057. addDecorationToSplitter(currentElement,widgetStack,
  15058. layoutStack);
  15059. }
  15060. else if(currentElement.tagName()=="graph")
  15061. {
  15062. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  15063. }
  15064. else if(currentElement.tagName()=="splitter")
  15065. {
  15066. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  15067. }
  15068. else if(currentElement.tagName()=="lcdtemperature")
  15069. {
  15070. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  15071. layoutStack);
  15072. }
  15073. else if(currentElement.tagName()=="lcdtimer")
  15074. {
  15075. addTimerDisplayToSplitter(currentElement,widgetStack,
  15076. layoutStack);
  15077. }
  15078. else if(currentElement.tagName()=="measurementtable")
  15079. {
  15080. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  15081. }
  15082. else if(currentElement.tagName()=="widget")
  15083. {
  15084. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  15085. }
  15086. }
  15087. }
  15088. }
  15089. /*:185*//*186:*/
  15090. #line 4562 "./typica.w"
  15091. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15092. QStack<QLayout*> *layoutStack)
  15093. {
  15094. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  15095. QSplitter*splitter= new(QSplitter);
  15096. splitter->setParent(parent);
  15097. parent->addWidget(splitter);
  15098. /*184:*/
  15099. #line 4486 "./typica.w"
  15100. QString orientation= element.attribute("type");
  15101. if(orientation=="horizontal")
  15102. {
  15103. splitter->setOrientation(Qt::Horizontal);
  15104. }
  15105. else if(orientation=="vertical")
  15106. {
  15107. splitter->setOrientation(Qt::Vertical);
  15108. }
  15109. QString id= element.attribute("id");
  15110. if(!id.isEmpty())
  15111. {
  15112. splitter->setObjectName(id);
  15113. }
  15114. if(element.hasChildNodes())
  15115. {
  15116. widgetStack->push(splitter);
  15117. populateSplitter(element,widgetStack,layoutStack);
  15118. widgetStack->pop();
  15119. }
  15120. /*:184*/
  15121. #line 4570 "./typica.w"
  15122. }
  15123. /*:186*//*187:*/
  15124. #line 4579 "./typica.w"
  15125. void addTemperatureDisplayToSplitter(QDomElement element,
  15126. QStack<QWidget*> *widgetStack,
  15127. QStack<QLayout*> *)
  15128. {
  15129. TemperatureDisplay*display= new(TemperatureDisplay);
  15130. if(element.hasAttribute("id"))
  15131. {
  15132. display->setObjectName(element.attribute("id"));
  15133. }
  15134. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15135. splitter->addWidget(display);
  15136. }
  15137. void addTemperatureDisplayToLayout(QDomElement element,
  15138. QStack<QWidget*> *,
  15139. QStack<QLayout*> *layoutStack)
  15140. {
  15141. TemperatureDisplay*display= new(TemperatureDisplay);
  15142. if(element.hasAttribute("id"))
  15143. {
  15144. display->setObjectName(element.attribute("id"));
  15145. }
  15146. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15147. layout->addWidget(display);
  15148. }
  15149. /*:187*//*188:*/
  15150. #line 4610 "./typica.w"
  15151. void addTimerDisplayToSplitter(QDomElement element,
  15152. QStack<QWidget*> *widgetStack,
  15153. QStack<QLayout*> *)
  15154. {
  15155. TimerDisplay*display= new(TimerDisplay);
  15156. if(element.hasAttribute("id"))
  15157. {
  15158. display->setObjectName(element.attribute("id"));
  15159. }
  15160. if(element.hasAttribute("format"))
  15161. {
  15162. display->setDisplayFormat(element.attribute("format"));
  15163. }
  15164. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15165. splitter->addWidget(display);
  15166. }
  15167. void addTimerDisplayToLayout(QDomElement element,
  15168. QStack<QWidget*> *,
  15169. QStack<QLayout*> *layoutStack)
  15170. {
  15171. TimerDisplay*display= new(TimerDisplay);
  15172. if(element.hasAttribute("id"))
  15173. {
  15174. display->setObjectName(element.attribute("id"));
  15175. }
  15176. if(element.hasAttribute("format"))
  15177. {
  15178. display->setDisplayFormat(element.attribute("format"));
  15179. }
  15180. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15181. layout->addWidget(display);
  15182. }
  15183. /*:188*//*189:*/
  15184. #line 4648 "./typica.w"
  15185. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  15186. QStack<QLayout*> *layoutStack)
  15187. {
  15188. /*190:*/
  15189. #line 4669 "./typica.w"
  15190. QString labelText= element.attribute("name");
  15191. Qt::Orientations orientation= Qt::Horizontal;
  15192. if(element.hasAttribute("type"))
  15193. {
  15194. if(element.attribute("type")=="horizontal")
  15195. {
  15196. orientation= Qt::Horizontal;
  15197. }
  15198. else if(element.attribute("type")=="vertical")
  15199. {
  15200. orientation= Qt::Vertical;
  15201. }
  15202. }
  15203. /*191:*/
  15204. #line 4694 "./typica.w"
  15205. QWidget*theWidget= NULL;
  15206. QDomNodeList children= element.childNodes();
  15207. for(int i= 0;i<children.count();i++)
  15208. {
  15209. QDomNode item= children.at(i);
  15210. if(item.isElement())
  15211. {
  15212. QDomElement itemElement= item.toElement();
  15213. if(itemElement.tagName()=="lcdtemperature")
  15214. {
  15215. TemperatureDisplay*display= new TemperatureDisplay;
  15216. if(itemElement.hasAttribute("id"))
  15217. {
  15218. display->setObjectName(itemElement.attribute("id"));
  15219. }
  15220. theWidget= display;
  15221. }
  15222. else if(itemElement.tagName()=="lcdtimer")
  15223. {
  15224. TimerDisplay*display= new TimerDisplay;
  15225. if(itemElement.hasAttribute("id"))
  15226. {
  15227. display->setObjectName(itemElement.attribute("id"));
  15228. }
  15229. if(itemElement.hasAttribute("format"))
  15230. {
  15231. display->setDisplayFormat(itemElement.attribute("format"));
  15232. }
  15233. theWidget= display;
  15234. }
  15235. }
  15236. }
  15237. /*:191*/
  15238. #line 4683 "./typica.w"
  15239. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  15240. orientation);
  15241. if(element.hasAttribute("id"))
  15242. {
  15243. decoration->setObjectName(element.attribute("id"));
  15244. }
  15245. /*:190*/
  15246. #line 4652 "./typica.w"
  15247. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15248. layout->addWidget(decoration);
  15249. }
  15250. void addDecorationToSplitter(QDomElement element,
  15251. QStack<QWidget*> *widgetStack,
  15252. QStack<QLayout*> *)
  15253. {
  15254. /*190:*/
  15255. #line 4669 "./typica.w"
  15256. QString labelText= element.attribute("name");
  15257. Qt::Orientations orientation= Qt::Horizontal;
  15258. if(element.hasAttribute("type"))
  15259. {
  15260. if(element.attribute("type")=="horizontal")
  15261. {
  15262. orientation= Qt::Horizontal;
  15263. }
  15264. else if(element.attribute("type")=="vertical")
  15265. {
  15266. orientation= Qt::Vertical;
  15267. }
  15268. }
  15269. /*191:*/
  15270. #line 4694 "./typica.w"
  15271. QWidget*theWidget= NULL;
  15272. QDomNodeList children= element.childNodes();
  15273. for(int i= 0;i<children.count();i++)
  15274. {
  15275. QDomNode item= children.at(i);
  15276. if(item.isElement())
  15277. {
  15278. QDomElement itemElement= item.toElement();
  15279. if(itemElement.tagName()=="lcdtemperature")
  15280. {
  15281. TemperatureDisplay*display= new TemperatureDisplay;
  15282. if(itemElement.hasAttribute("id"))
  15283. {
  15284. display->setObjectName(itemElement.attribute("id"));
  15285. }
  15286. theWidget= display;
  15287. }
  15288. else if(itemElement.tagName()=="lcdtimer")
  15289. {
  15290. TimerDisplay*display= new TimerDisplay;
  15291. if(itemElement.hasAttribute("id"))
  15292. {
  15293. display->setObjectName(itemElement.attribute("id"));
  15294. }
  15295. if(itemElement.hasAttribute("format"))
  15296. {
  15297. display->setDisplayFormat(itemElement.attribute("format"));
  15298. }
  15299. theWidget= display;
  15300. }
  15301. }
  15302. }
  15303. /*:191*/
  15304. #line 4683 "./typica.w"
  15305. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  15306. orientation);
  15307. if(element.hasAttribute("id"))
  15308. {
  15309. decoration->setObjectName(element.attribute("id"));
  15310. }
  15311. /*:190*/
  15312. #line 4661 "./typica.w"
  15313. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15314. splitter->addWidget(decoration);
  15315. }
  15316. /*:189*//*192:*/
  15317. #line 4733 "./typica.w"
  15318. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15319. QStack<QLayout*> *layoutStack)
  15320. {
  15321. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15322. QWidget*widget= new QWidget;
  15323. if(element.hasAttribute("id"))
  15324. {
  15325. widget->setObjectName(element.attribute("id"));
  15326. }
  15327. splitter->addWidget(widget);
  15328. if(element.hasChildNodes())
  15329. {
  15330. widgetStack->push(widget);
  15331. populateWidget(element,widgetStack,layoutStack);
  15332. widgetStack->pop();
  15333. }
  15334. }
  15335. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  15336. QStack<QLayout*> *layoutStack)
  15337. {
  15338. QDomNodeList children= element.childNodes();
  15339. for(int i= 0;i<children.count();i++)
  15340. {
  15341. QDomNode current;
  15342. QDomElement currentElement;
  15343. current= children.at(i);
  15344. if(current.isElement())
  15345. {
  15346. currentElement= current.toElement();
  15347. if(currentElement.tagName()=="layout")
  15348. {
  15349. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  15350. }
  15351. }
  15352. }
  15353. }
  15354. /*:192*//*193:*/
  15355. #line 4776 "./typica.w"
  15356. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  15357. QStack<QLayout*> *layoutStack)
  15358. {
  15359. QAbstractButton*button= NULL;
  15360. QString text= element.attribute("name");
  15361. if(element.hasAttribute("type"))
  15362. {
  15363. QString type= element.attribute("type");
  15364. if(type=="annotation")
  15365. {
  15366. AnnotationButton*abutton= new AnnotationButton(text);
  15367. if(element.hasAttribute("annotation"))
  15368. {
  15369. abutton->setAnnotation(element.attribute("annotation"));
  15370. }
  15371. if(element.hasAttribute("series"))
  15372. {
  15373. abutton->setTemperatureColumn(element.attribute("series").
  15374. toInt());
  15375. }
  15376. if(element.hasAttribute("column"))
  15377. {
  15378. abutton->setAnnotationColumn(element.attribute("column").
  15379. toInt());
  15380. }
  15381. button= abutton;
  15382. }
  15383. else if(type=="check")
  15384. {
  15385. button= new QCheckBox(text);
  15386. }
  15387. else if(type=="push")
  15388. {
  15389. button= new QPushButton(text);
  15390. }
  15391. }
  15392. if(element.hasAttribute("id"))
  15393. {
  15394. button->setObjectName(element.attribute("id"));
  15395. }
  15396. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15397. layout->addWidget(button);
  15398. }
  15399. /*:193*//*194:*/
  15400. #line 4828 "./typica.w"
  15401. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  15402. QStack<QLayout*> *layoutStack)
  15403. {
  15404. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  15405. if(element.hasAttribute("pretext"))
  15406. {
  15407. box->setPretext(element.attribute("pretext"));
  15408. }
  15409. if(element.hasAttribute("posttext"))
  15410. {
  15411. box->setPosttext(element.attribute("posttext"));
  15412. }
  15413. if(element.hasAttribute("series"))
  15414. {
  15415. box->setTemperatureColumn(element.attribute("series").toInt());
  15416. }
  15417. if(element.hasAttribute("column"))
  15418. {
  15419. box->setAnnotationColumn(element.attribute("column").toInt());
  15420. }
  15421. if(element.hasAttribute("min"))
  15422. {
  15423. box->setMinimum(element.attribute("min").toDouble());
  15424. }
  15425. if(element.hasAttribute("max"))
  15426. {
  15427. box->setMaximum(element.attribute("max").toDouble());
  15428. }
  15429. if(element.hasAttribute("decimals"))
  15430. {
  15431. box->setDecimals(element.attribute("decimals").toInt());
  15432. }
  15433. if(element.hasAttribute("step"))
  15434. {
  15435. box->setSingleStep(element.attribute("step").toDouble());
  15436. }
  15437. if(element.hasAttribute("id"))
  15438. {
  15439. box->setObjectName(element.attribute("id"));
  15440. }
  15441. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15442. layout->addWidget(box);
  15443. }
  15444. /*:194*//*195:*/
  15445. #line 4884 "./typica.w"
  15446. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15447. QStack<QLayout*> *)
  15448. {
  15449. ZoomLog*widget= new ZoomLog;
  15450. if(!widget)
  15451. {
  15452. qDebug()<<"Error constructing widget!";
  15453. }
  15454. if(element.hasAttribute("id"))
  15455. {
  15456. widget->setObjectName(element.attribute("id"));
  15457. }
  15458. if(element.hasChildNodes())
  15459. {
  15460. QDomNodeList children= element.childNodes();
  15461. int column= 0;
  15462. for(int i= 0;i<children.count();i++)
  15463. {
  15464. QDomNode current;
  15465. QDomElement currentElement;
  15466. current= children.at(i);
  15467. if(current.isElement())
  15468. {
  15469. currentElement= current.toElement();
  15470. if(currentElement.tagName()=="column")
  15471. {
  15472. QString text= currentElement.text();
  15473. widget->setHeaderData(column,text);
  15474. column++;
  15475. }
  15476. }
  15477. }
  15478. }
  15479. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15480. if(splitter)
  15481. {
  15482. splitter->addWidget(widget);
  15483. }
  15484. else
  15485. {
  15486. qDebug()<<"Splitter not found at top of widget stack!";
  15487. }
  15488. }
  15489. /*:195*//*196:*/
  15490. #line 4932 "./typica.w"
  15491. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  15492. QStack<QLayout*> *)
  15493. {
  15494. GraphView*view= new GraphView;
  15495. if(element.hasAttribute("id"))
  15496. {
  15497. view->setObjectName(element.attribute("id"));
  15498. }
  15499. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  15500. splitter->addWidget(view);
  15501. }
  15502. /*:196*//*197:*/
  15503. #line 4949 "./typica.w"
  15504. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  15505. QStack<QLayout*> *layoutStack)
  15506. {
  15507. SqlComboBox*box= new SqlComboBox();
  15508. if(element.hasAttribute("data"))
  15509. {
  15510. box->setDataColumn(element.attribute("data").toInt());
  15511. }
  15512. if(element.hasAttribute("display"))
  15513. {
  15514. box->setDisplayColumn(element.attribute("display").toInt());
  15515. }
  15516. if(element.hasAttribute("showdata"))
  15517. {
  15518. if(element.attribute("showdata")=="true")
  15519. {
  15520. box->showData(true);
  15521. }
  15522. }
  15523. if(element.hasAttribute("editable"))
  15524. {
  15525. if(element.attribute("editable")=="true")
  15526. {
  15527. box->setEditable(true);
  15528. }
  15529. }
  15530. if(element.hasChildNodes())
  15531. {
  15532. QDomNodeList children= element.childNodes();
  15533. for(int i= 0;i<children.count();i++)
  15534. {
  15535. QDomNode current;
  15536. QDomElement currentElement;
  15537. current= children.at(i);
  15538. if(current.isElement())
  15539. {
  15540. currentElement= current.toElement();
  15541. if(currentElement.tagName()=="null")
  15542. {
  15543. box->addNullOption();
  15544. }
  15545. else if(currentElement.tagName()=="query")
  15546. {
  15547. box->addSqlOptions(currentElement.text());
  15548. }
  15549. }
  15550. }
  15551. }
  15552. if(element.hasAttribute("id"))
  15553. {
  15554. box->setObjectName(element.attribute("id"));
  15555. }
  15556. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15557. layout->addWidget(box);
  15558. }
  15559. /*:197*//*198:*/
  15560. #line 5028 "./typica.w"
  15561. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  15562. QStack<QLayout*> *layoutStack)
  15563. {
  15564. QTableView*view= new QTableView;
  15565. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  15566. SaltModel*model= new SaltModel(element.childNodes().count());
  15567. if(element.hasAttribute("id"))
  15568. {
  15569. view->setObjectName(element.attribute("id"));
  15570. }
  15571. if(element.hasChildNodes())
  15572. {
  15573. QDomNodeList children= element.childNodes();
  15574. int currentColumn= 0;
  15575. for(int i= 0;i<children.count();i++)
  15576. {
  15577. QDomNode current;
  15578. QDomElement currentElement;
  15579. current= children.at(i);
  15580. if(current.isElement())
  15581. {
  15582. currentElement= current.toElement();
  15583. if(currentElement.tagName()=="column")
  15584. {
  15585. if(currentElement.hasAttribute("name"))
  15586. {
  15587. model->setHeaderData(currentColumn,Qt::Horizontal,
  15588. currentElement.attribute("name"));
  15589. }
  15590. if(currentElement.hasAttribute("delegate"))
  15591. {
  15592. /*199:*/
  15593. #line 5076 "./typica.w"
  15594. if(currentElement.attribute("delegate")=="sql")
  15595. {
  15596. /*200:*/
  15597. #line 5092 "./typica.w"
  15598. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  15599. SqlComboBox*widget= new SqlComboBox();
  15600. if(currentElement.hasAttribute("nulltext"))
  15601. {
  15602. widget->setNullText(currentElement.attribute("nulltext"));
  15603. }
  15604. if(currentElement.hasAttribute("nulldata"))
  15605. {
  15606. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  15607. }
  15608. if(currentElement.hasAttribute("null"))
  15609. {
  15610. if(currentElement.attribute("null")=="true")
  15611. {
  15612. widget->addNullOption();
  15613. }
  15614. }
  15615. if(currentElement.hasAttribute("showdata"))
  15616. {
  15617. if(currentElement.attribute("showdata")=="true")
  15618. {
  15619. widget->showData(true);
  15620. }
  15621. }
  15622. if(currentElement.hasAttribute("data"))
  15623. {
  15624. widget->setDataColumn(currentElement.attribute("data").toInt());
  15625. }
  15626. if(currentElement.hasAttribute("display"))
  15627. {
  15628. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  15629. }
  15630. widget->addSqlOptions(currentElement.text());
  15631. delegate->setWidget(widget);
  15632. view->setItemDelegateForColumn(currentColumn,delegate);
  15633. /*:200*/
  15634. #line 5079 "./typica.w"
  15635. }
  15636. else if(currentElement.attribute("delegate")=="numeric")
  15637. {
  15638. /*201:*/
  15639. #line 5133 "./typica.w"
  15640. NumericDelegate*delegate= new NumericDelegate;
  15641. view->setItemDelegateForColumn(currentColumn,delegate);
  15642. /*:201*/
  15643. #line 5083 "./typica.w"
  15644. }
  15645. /*:199*/
  15646. #line 5060 "./typica.w"
  15647. }
  15648. currentColumn++;
  15649. }
  15650. }
  15651. }
  15652. }
  15653. view->setModel(model);
  15654. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15655. layout->addWidget(view);
  15656. }
  15657. /*:198*//*208:*/
  15658. #line 5243 "./typica.w"
  15659. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  15660. QStack<QLayout*> *layoutStack)
  15661. {
  15662. QLineEdit*widget= new QLineEdit(element.text());
  15663. if(element.hasAttribute("id"))
  15664. {
  15665. widget->setObjectName(element.attribute("id"));
  15666. }
  15667. if(element.hasAttribute("writable"))
  15668. {
  15669. if(element.attribute("writable")=="false")
  15670. {
  15671. widget->setReadOnly(true);
  15672. }
  15673. }
  15674. if(element.hasAttribute("validator"))
  15675. {
  15676. if(element.attribute("validator")=="numeric")
  15677. {
  15678. widget->setValidator(new QDoubleValidator(NULL));
  15679. }
  15680. else if(element.attribute("validator")=="integer")
  15681. {
  15682. widget->setValidator(new QIntValidator(NULL));
  15683. }
  15684. else if(element.attribute("validator")=="expression"&&
  15685. element.hasAttribute("expression"))
  15686. {
  15687. widget->setValidator(new QRegExpValidator(
  15688. QRegExp(element.attribute("expression")),
  15689. NULL));
  15690. }
  15691. }
  15692. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15693. layout->addWidget(widget);
  15694. }
  15695. /*:208*//*209:*/
  15696. #line 5284 "./typica.w"
  15697. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  15698. QStack<QLayout*> *layoutStack)
  15699. {
  15700. QTextEdit*widget= new QTextEdit;
  15701. if(element.hasAttribute("id"))
  15702. {
  15703. widget->setObjectName(element.attribute("id"));
  15704. }
  15705. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15706. layout->addWidget(widget);
  15707. }
  15708. /*:209*//*210:*/
  15709. #line 5301 "./typica.w"
  15710. void addSqlQueryViewToLayout(QDomElement element,
  15711. QStack<QWidget*> *,
  15712. QStack<QLayout*> *layoutStack)
  15713. {
  15714. SqlQueryView*view= new SqlQueryView;
  15715. if(element.hasAttribute("id"))
  15716. {
  15717. view->setObjectName(element.attribute("id"));
  15718. }
  15719. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15720. layout->addWidget(view);
  15721. }
  15722. /*:210*//*211:*/
  15723. #line 5318 "./typica.w"
  15724. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  15725. QStack<QLayout*> *layoutStack)
  15726. {
  15727. QWidget*widget;
  15728. if(element.hasAttribute("time"))
  15729. {
  15730. if(element.attribute("time")=="true")
  15731. {
  15732. QDateTimeEdit*edit= new QDateTimeEdit;
  15733. edit->setDateTime(QDateTime::currentDateTime());
  15734. edit->setCalendarPopup(true);
  15735. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  15736. widget= qobject_cast<QWidget*> (edit);
  15737. }
  15738. else
  15739. {
  15740. QDateEdit*edit= new QDateEdit;
  15741. edit->setDate(QDate::currentDate());
  15742. edit->setCalendarPopup(true);
  15743. edit->setDisplayFormat("yyyy-MM-dd");
  15744. widget= qobject_cast<QWidget*> (edit);
  15745. }
  15746. }
  15747. else
  15748. {
  15749. QDateEdit*edit= new QDateEdit;
  15750. edit->setDate(QDate::currentDate());
  15751. edit->setCalendarPopup(true);
  15752. edit->setDisplayFormat("yyyy-MM-dd");
  15753. widget= qobject_cast<QWidget*> (edit);
  15754. }
  15755. if(element.hasAttribute("id"))
  15756. {
  15757. widget->setObjectName(element.attribute("id"));
  15758. }
  15759. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15760. layout->addWidget(widget);
  15761. }
  15762. /*:211*//*212:*/
  15763. #line 5361 "./typica.w"
  15764. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  15765. {
  15766. setQDateTimeEditProperties(value,engine);
  15767. }
  15768. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  15769. {
  15770. setQAbstractSpinBoxProperties(value,engine);
  15771. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  15772. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  15773. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  15774. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  15775. }
  15776. /*:212*//*213:*/
  15777. #line 5381 "./typica.w"
  15778. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  15779. {
  15780. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  15781. if(context->argumentCount()==3)
  15782. {
  15783. self->setDate(QDate(argument<int> (0,context),
  15784. argument<int> (1,context),
  15785. argument<int> (2,context)));
  15786. }
  15787. else
  15788. {
  15789. context->throwError("Incorrect number of arguments passed to "
  15790. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  15791. "specifying the year, month, and day.");
  15792. }
  15793. return QScriptValue();
  15794. }
  15795. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  15796. {
  15797. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  15798. return QScriptValue(self->date().day());
  15799. }
  15800. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  15801. {
  15802. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  15803. return QScriptValue(self->date().month());
  15804. }
  15805. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  15806. {
  15807. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  15808. return QScriptValue(self->date().year());
  15809. }
  15810. /*:213*//*217:*/
  15811. #line 5448 "./typica.w"
  15812. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  15813. {
  15814. QObject*parent= argument<QObject*> (0,context);
  15815. QString name= argument<QString> (1,context);
  15816. QObject*object= parent->findChild<QObject*> (name);
  15817. QScriptValue value;
  15818. if(object)
  15819. {
  15820. value= engine->newQObject(object);
  15821. QString className= object->metaObject()->className();
  15822. /*218:*/
  15823. #line 5466 "./typica.w"
  15824. if(className=="TemperatureDisplay")
  15825. {
  15826. setTemperatureDisplayProperties(value,engine);
  15827. }
  15828. else if(className=="TimerDisplay")
  15829. {
  15830. setTimerDisplayProperties(value,engine);
  15831. }
  15832. else if(className=="QAction")
  15833. {
  15834. setQActionProperties(value,engine);
  15835. }
  15836. else if(className=="QBoxLayout")
  15837. {
  15838. setQBoxLayoutProperties(value,engine);
  15839. }
  15840. else if(className=="QDateEdit")
  15841. {
  15842. setQDateEditProperties(value,engine);
  15843. }
  15844. else if(className=="QDateTimeEdit")
  15845. {
  15846. setQDateTimeEditProperties(value,engine);
  15847. }
  15848. else if(className=="QFrame")
  15849. {
  15850. setQFrameProperties(value,engine);
  15851. }
  15852. else if(className=="QHBoxLayout")
  15853. {
  15854. setQBoxLayoutProperties(value,engine);
  15855. }
  15856. else if(className=="QLCDNumber")
  15857. {
  15858. setQLCDNumberProperties(value,engine);
  15859. }
  15860. else if(className=="QMenu")
  15861. {
  15862. setQMenuProperties(value,engine);
  15863. }
  15864. else if(className=="QMenuBar")
  15865. {
  15866. setQMenuBarProperties(value,engine);
  15867. }
  15868. else if(className=="QPushButton")
  15869. {
  15870. setQPushButtonProperties(value,engine);
  15871. }
  15872. else if(className=="QSplitter")
  15873. {
  15874. setQSplitterProperties(value,engine);
  15875. }
  15876. else if(className=="QTableView")
  15877. {
  15878. if(object->property("tabletype").isValid())
  15879. {
  15880. if(object->property("tabletype").toString()=="SaltTable")
  15881. {
  15882. setSaltTableProperties(value,engine);
  15883. }
  15884. }
  15885. }
  15886. else if(className=="QVBoxLayout")
  15887. {
  15888. setQBoxLayoutProperties(value,engine);
  15889. }
  15890. else if(className=="QWidget")
  15891. {
  15892. setQWidgetProperties(value,engine);
  15893. }
  15894. else if(className=="ScriptQMainWindow")
  15895. {
  15896. setQMainWindowProperties(value,engine);
  15897. }
  15898. else if(className=="SqlComboBox")
  15899. {
  15900. setSqlComboBoxProperties(value,engine);
  15901. }
  15902. else if(className=="SqlQueryView")
  15903. {
  15904. setSqlQueryViewProperties(value,engine);
  15905. }
  15906. else if(className=="ZoomLog")
  15907. {
  15908. setZoomLogProperties(value,engine);
  15909. }
  15910. else if(className=="QTextEdit")
  15911. {
  15912. setQTextEditProperties(value,engine);
  15913. }
  15914. else if(className=="QWebView")
  15915. {
  15916. setQWebViewProperties(value,engine);
  15917. }
  15918. else if(className=="QLineEdit")
  15919. {
  15920. setQLineEditProperties(value,engine);
  15921. }
  15922. /*:218*/
  15923. #line 5459 "./typica.w"
  15924. }
  15925. return value;
  15926. }
  15927. /*:217*//*220:*/
  15928. #line 5595 "./typica.w"
  15929. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  15930. {
  15931. QTableView*self= getself<QTableView*> (context);
  15932. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  15933. QString datum;
  15934. double total= 0.0;
  15935. int column= argument<int> (0,context);
  15936. int role= argument<int> (1,context);
  15937. for(int i= 0;i<model->rowCount();i++)
  15938. {
  15939. datum= model->data(model->index(i,column),role).toString();
  15940. if(!datum.isEmpty())
  15941. {
  15942. total+= datum.toDouble();
  15943. }
  15944. }
  15945. return QScriptValue(engine,total);
  15946. }
  15947. /*:220*//*221:*/
  15948. #line 5619 "./typica.w"
  15949. QScriptValue SaltTable_columnArray(QScriptContext*context,
  15950. QScriptEngine*engine)
  15951. {
  15952. QTableView*self= getself<QTableView*> (context);
  15953. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  15954. int column= argument<int> (0,context);
  15955. int role= argument<int> (1,context);
  15956. QString literal= model->arrayLiteral(column,role);
  15957. return QScriptValue(engine,literal);
  15958. }
  15959. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  15960. QScriptEngine*engine)
  15961. {
  15962. QTableView*self= getself<QTableView*> (context);
  15963. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  15964. int column= argument<int> (0,context);
  15965. int role= argument<int> (1,context);
  15966. QString literal= model->quotedArrayLiteral(column,role);
  15967. return QScriptValue(engine,literal);
  15968. }
  15969. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  15970. QScriptEngine*engine)
  15971. {
  15972. QTableView*self= getself<QTableView*> (context);
  15973. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  15974. int column= argument<int> (0,context);
  15975. int role= argument<int> (1,context);
  15976. QString literal= model->arrayLiteral(column,role);
  15977. literal.chop(1);
  15978. literal= literal.remove(0,1);
  15979. return QScriptValue(engine,literal);
  15980. }
  15981. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  15982. QScriptEngine*engine)
  15983. {
  15984. QTableView*self= getself<QTableView*> (context);
  15985. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  15986. int column= argument<int> (0,context);
  15987. int role= argument<int> (1,context);
  15988. QString literal= model->quotedArrayLiteral(column,role);
  15989. literal.chop(1);
  15990. literal= literal.remove(0,1);
  15991. return QScriptValue(engine,literal);
  15992. }
  15993. /*:221*//*222:*/
  15994. #line 5671 "./typica.w"
  15995. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  15996. {
  15997. QTableView*self= getself<QTableView*> (context);
  15998. QScriptValue value= engine->newQObject(self->model());
  15999. return value;
  16000. }
  16001. /*:222*//*223:*/
  16002. #line 5685 "./typica.w"
  16003. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  16004. {
  16005. QTableView*self= getself<QTableView*> (context);
  16006. int row= argument<int> (0,context);
  16007. int column= argument<int> (1,context);
  16008. QVariant value= argument<QVariant> (2,context);
  16009. int role= argument<int> (3,context);
  16010. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16011. QModelIndex cell= model->index(row,column);
  16012. model->setData(cell,value,role);
  16013. self->update(cell);
  16014. return QScriptValue();
  16015. }
  16016. /*:223*//*224:*/
  16017. #line 5703 "./typica.w"
  16018. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  16019. {
  16020. QTableView*self= getself<QTableView*> (context);
  16021. int row= argument<int> (0,context);
  16022. int column= argument<int> (1,context);
  16023. int role= argument<int> (2,context);
  16024. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16025. QModelIndex cell= model->index(row,column);
  16026. QVariant value= model->data(cell,role);
  16027. QScriptValue retval= engine->newVariant(value);
  16028. retval.setProperty("value",QScriptValue(value.toString()));
  16029. return retval;
  16030. }
  16031. /*:224*//*225:*/
  16032. #line 5723 "./typica.w"
  16033. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  16034. {
  16035. QTableView*self= getself<QTableView*> (context);
  16036. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16037. model->clear();
  16038. return QScriptValue();
  16039. }
  16040. /*:225*//*226:*/
  16041. #line 5735 "./typica.w"
  16042. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  16043. {
  16044. QTableView*self= getself<QTableView*> (context);
  16045. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16046. int row= argument<int> (0,context);
  16047. return engine->newVariant(model->removeRow(row));
  16048. }
  16049. /*:226*//*227:*/
  16050. #line 5748 "./typica.w"
  16051. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  16052. {
  16053. QTableView*self= getself<QTableView*> (context);
  16054. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  16055. QVariant value= argument<QVariant> (0,context);
  16056. int column= argument<int> (1,context);
  16057. return engine->newVariant(model->findData(value,column));
  16058. }
  16059. /*:227*//*228:*/
  16060. #line 5761 "./typica.w"
  16061. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  16062. {
  16063. setQWidgetProperties(value,engine);
  16064. value.setProperty("columnArray",
  16065. engine->newFunction(SaltTable_columnArray));
  16066. value.setProperty("quotedColumnArray",
  16067. engine->newFunction(SaltTable_quotedColumnArray));
  16068. value.setProperty("bindableColumnArray",
  16069. engine->newFunction(SaltTable_bindableColumnArray));
  16070. value.setProperty("bindableQuotedColumnArray",
  16071. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  16072. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  16073. value.setProperty("data",engine->newFunction(SaltTable_data));
  16074. value.setProperty("model",engine->newFunction(SaltTable_model));
  16075. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  16076. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  16077. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  16078. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  16079. }
  16080. /*:228*//*230:*/
  16081. #line 5798 "./typica.w"
  16082. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16083. {
  16084. setQComboBoxProperties(value,engine);
  16085. }
  16086. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  16087. {
  16088. setQWidgetProperties(value,engine);
  16089. value.setProperty("currentData",
  16090. engine->newFunction(QComboBox_currentData));
  16091. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  16092. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  16093. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  16094. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  16095. }
  16096. QScriptValue QComboBox_currentData(QScriptContext*context,
  16097. QScriptEngine*engine)
  16098. {
  16099. QComboBox*self= getself<QComboBox*> (context);
  16100. return QScriptValue(engine,
  16101. self->itemData(self->currentIndex()).toString());
  16102. }
  16103. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  16104. {
  16105. QComboBox*self= getself<QComboBox*> (context);
  16106. self->addItem(argument<QString> (0,context));
  16107. return QScriptValue();
  16108. }
  16109. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  16110. {
  16111. QComboBox*self= getself<QComboBox*> (context);
  16112. self->setModel(argument<QAbstractItemModel*> (0,context));
  16113. return QScriptValue();
  16114. }
  16115. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  16116. {
  16117. QComboBox*self= getself<QComboBox*> (context);
  16118. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  16119. }
  16120. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  16121. {
  16122. QComboBox*self= getself<QComboBox*> (context);
  16123. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  16124. }
  16125. #line 1 "./abouttypica.w"
  16126. /*:230*//*243:*/
  16127. #line 388 "./units.w"
  16128. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  16129. {
  16130. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  16131. argument<Units::Unit> (1,context),
  16132. argument<Units::Unit> (2,context)));
  16133. }
  16134. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  16135. QScriptEngine*)
  16136. {
  16137. return QScriptValue(Units::convertRelativeTemperature(
  16138. argument<double> (0,context),
  16139. argument<Units::Unit> (1,context),
  16140. argument<Units::Unit> (2,context)));
  16141. }
  16142. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  16143. {
  16144. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  16145. }
  16146. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  16147. {
  16148. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  16149. argument<Units::Unit> (1,context),
  16150. argument<Units::Unit> (2,context)));
  16151. }
  16152. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  16153. {
  16154. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  16155. }
  16156. /*:243*//*246:*/
  16157. #line 436 "./units.w"
  16158. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  16159. {
  16160. return engine->newVariant(QVariant(value));
  16161. }
  16162. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  16163. {
  16164. value= sv.toVariant().value<Units::Unit> ();
  16165. }
  16166. /*:246*//*256:*/
  16167. #line 149 "./measurement.w"
  16168. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  16169. {
  16170. QScriptValue object;
  16171. if(context->argumentCount()==2||context->argumentCount()==3)
  16172. {
  16173. double measurement= argument<double> (0,context);
  16174. QTime timestamp= argument<QTime> (1,context);
  16175. Units::Unit unit= Units::Fahrenheit;
  16176. if(context->argumentCount()==3)
  16177. {
  16178. unit= argument<Units::Unit> (2,context);
  16179. }
  16180. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  16181. setMeasurementProperties(object,engine);
  16182. }
  16183. else
  16184. {
  16185. context->throwError("Incorrect number of arguments passed to "
  16186. "Measurement::Measurement(). This method takes two "
  16187. "or three arguments.");
  16188. }
  16189. return object;
  16190. }
  16191. /*:256*//*257:*/
  16192. #line 176 "./measurement.w"
  16193. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  16194. {
  16195. }
  16196. /*:257*//*258:*/
  16197. #line 184 "./measurement.w"
  16198. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  16199. {
  16200. QVariant var;
  16201. var.setValue(measurement);
  16202. return engine->newVariant(var);
  16203. }
  16204. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  16205. {
  16206. measurement= value.toVariant().value<Measurement> ();
  16207. }
  16208. #line 5867 "./typica.w"
  16209. /*:258*//*276:*/
  16210. #line 6444 "./typica.w"
  16211. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  16212. {
  16213. QScriptValue object;
  16214. if(context->argumentCount()==1)
  16215. {
  16216. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  16217. QScriptEngine::ScriptOwnership);
  16218. setDAQProperties(object,engine);
  16219. }
  16220. else if(context->argumentCount()==2)
  16221. {
  16222. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  16223. argument<QString> (1,context)),
  16224. QScriptEngine::ScriptOwnership);
  16225. setDAQProperties(object,engine);
  16226. }
  16227. else
  16228. {
  16229. context->throwError("Incorrect number of arguments passed to DAQ"
  16230. "constructor. The DAQ constructor takes one"
  16231. "string as an argument specifying a device name."
  16232. "Example: Dev1");
  16233. }
  16234. return object;
  16235. }
  16236. /*:276*//*277:*/
  16237. #line 6474 "./typica.w"
  16238. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  16239. {
  16240. setQObjectProperties(value,engine);
  16241. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  16242. }
  16243. /*:277*//*278:*/
  16244. #line 6484 "./typica.w"
  16245. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  16246. {
  16247. DAQ*self= getself<DAQ*> (context);
  16248. QScriptValue object;
  16249. if(self)
  16250. {
  16251. object=
  16252. engine->newQObject(self->newChannel(argument<int> (0,context),
  16253. argument<int> (1,context)));
  16254. setChannelProperties(object,engine);
  16255. }
  16256. return object;
  16257. }
  16258. /*:278*//*285:*/
  16259. #line 6640 "./typica.w"
  16260. QScriptValue constructFakeDAQ(QScriptContext*context,
  16261. QScriptEngine*engine)
  16262. {
  16263. QScriptValue object;
  16264. if(context->argumentCount()==1)
  16265. {
  16266. object=
  16267. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  16268. QScriptEngine::ScriptOwnership);
  16269. setFakeDAQProperties(object,engine);
  16270. }
  16271. else
  16272. {
  16273. context->throwError("Incorrect number of arguments passed to DAQ"
  16274. "constructor. The DAQ constructor takes one"
  16275. "string as an argument specifying a device name."
  16276. "Example: Dev1");
  16277. }
  16278. return object;
  16279. }
  16280. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  16281. {
  16282. setQObjectProperties(value,engine);
  16283. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  16284. }
  16285. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  16286. {
  16287. FakeDAQ*self= getself<FakeDAQ*> (context);
  16288. QScriptValue object;
  16289. if(self)
  16290. {
  16291. object=
  16292. engine->newQObject(self->newChannel(argument<int> (0,context),
  16293. argument<int> (1,context)));
  16294. setChannelProperties(object,engine);
  16295. }
  16296. return object;
  16297. }
  16298. /*:285*//*289:*/
  16299. #line 6731 "./typica.w"
  16300. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  16301. {
  16302. setQObjectProperties(value,engine);
  16303. }
  16304. /*:289*//*296:*/
  16305. #line 6923 "./typica.w"
  16306. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  16307. {
  16308. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  16309. setLinearCalibratorProperties(object,engine);
  16310. return object;
  16311. }
  16312. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  16313. {
  16314. setQObjectProperties(value,engine);
  16315. }
  16316. /*:296*//*301:*/
  16317. #line 7061 "./typica.w"
  16318. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  16319. {
  16320. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  16321. setLinearSplineInterpolatorProperties(object,engine);
  16322. return object;
  16323. }
  16324. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  16325. {
  16326. setQObjectProperties(value,engine);
  16327. }
  16328. /*:301*//*311:*/
  16329. #line 7267 "./typica.w"
  16330. QScriptValue constructTemperatureDisplay(QScriptContext*,
  16331. QScriptEngine*engine)
  16332. {
  16333. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  16334. setTemperatureDisplayProperties(object,engine);
  16335. return object;
  16336. }
  16337. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  16338. {
  16339. setQLCDNumberProperties(value,engine);
  16340. value.setProperty("setDisplayUnits",
  16341. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  16342. }
  16343. /*:311*//*312:*/
  16344. #line 7291 "./typica.w"
  16345. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  16346. {
  16347. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  16348. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  16349. return QScriptValue();
  16350. }
  16351. /*:312*//*319:*/
  16352. #line 7428 "./typica.w"
  16353. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  16354. QScriptEngine*engine)
  16355. {
  16356. QScriptValue object=
  16357. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  16358. setMeasurementTimeOffsetProperties(object,engine);
  16359. return object;
  16360. }
  16361. void setMeasurementTimeOffsetProperties(QScriptValue value,
  16362. QScriptEngine*engine)
  16363. {
  16364. setQObjectProperties(value,engine);
  16365. }
  16366. /*:319*//*324:*/
  16367. #line 7537 "./typica.w"
  16368. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  16369. {
  16370. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  16371. return object;
  16372. }
  16373. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  16374. {
  16375. setQObjectProperties(value,engine);
  16376. }
  16377. /*:324*//*329:*/
  16378. #line 7634 "./typica.w"
  16379. QScriptValue constructZeroEmitter(QScriptContext*context,
  16380. QScriptEngine*engine)
  16381. {
  16382. QScriptValue object=
  16383. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  16384. setZeroEmitterProperties(object,engine);
  16385. return object;
  16386. }
  16387. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  16388. {
  16389. setQObjectProperties(value,engine);
  16390. }
  16391. /*:329*//*334:*/
  16392. #line 7714 "./typica.w"
  16393. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  16394. QScriptEngine*engine)
  16395. {
  16396. QScriptValue object=
  16397. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  16398. setMeasurementAdapterProperties(object,engine);
  16399. return object;
  16400. }
  16401. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  16402. {
  16403. setQObjectProperties(value,engine);
  16404. }
  16405. /*:334*//*351:*/
  16406. #line 8176 "./typica.w"
  16407. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  16408. {
  16409. QScriptValue object= engine->newQObject(new GraphView);
  16410. setGraphViewProperties(object,engine);
  16411. return object;
  16412. }
  16413. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  16414. {
  16415. setQGraphicsViewProperties(value,engine);
  16416. }
  16417. /*:351*//*374:*/
  16418. #line 8814 "./typica.w"
  16419. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  16420. {
  16421. QScriptValue object= engine->newQObject(new ZoomLog);
  16422. setZoomLogProperties(object,engine);
  16423. return object;
  16424. }
  16425. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  16426. {
  16427. setQTableViewProperties(value,engine);
  16428. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  16429. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  16430. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  16431. value.setProperty("restoreState",
  16432. engine->newFunction(ZoomLog_restoreState));
  16433. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  16434. value.setProperty("saveTemporary",
  16435. engine->newFunction(ZoomLog_saveTemporary));
  16436. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  16437. }
  16438. /*:374*//*375:*/
  16439. #line 8841 "./typica.w"
  16440. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  16441. {
  16442. ZoomLog*self= getself<ZoomLog*> (context);
  16443. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  16444. return QScriptValue(engine,retval);
  16445. }
  16446. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  16447. {
  16448. ZoomLog*self= getself<ZoomLog*> (context);
  16449. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  16450. return QScriptValue(engine,retval);
  16451. }
  16452. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  16453. QScriptEngine*engine)
  16454. {
  16455. ZoomLog*self= getself<ZoomLog*> (context);
  16456. QString filename= QDir::tempPath();
  16457. filename.append("/");
  16458. filename.append(QUuid::createUuid().toString());
  16459. filename.append(".xml");
  16460. QFile*file= new QFile(filename);
  16461. self->saveXML(file);
  16462. file->close();
  16463. delete file;
  16464. return QScriptValue(engine,filename);
  16465. }
  16466. /*:375*//*376:*/
  16467. #line 8889 "./typica.w"
  16468. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  16469. {
  16470. ZoomLog*self= getself<ZoomLog*> (context);
  16471. QString key= argument<QString> (0,context);
  16472. int columns= argument<int> (1,context);
  16473. QSettings settings;
  16474. for(int i= 0;i<columns;i++)
  16475. {
  16476. if(self->columnWidth(i))
  16477. {
  16478. settings.beginGroup(key);
  16479. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  16480. settings.endGroup();
  16481. }
  16482. }
  16483. return QScriptValue();
  16484. }
  16485. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  16486. {
  16487. ZoomLog*self= getself<ZoomLog*> (context);
  16488. QString key= argument<QString> (0,context);
  16489. int columns= argument<int> (1,context);
  16490. QSettings settings;
  16491. for(int i= 0;i<columns;i++)
  16492. {
  16493. settings.beginGroup(key);
  16494. self->setColumnWidth(i,
  16495. settings.value(QString("%1").arg(i),80).toInt());
  16496. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  16497. {
  16498. self->setColumnWidth(i,80);
  16499. }
  16500. settings.endGroup();
  16501. }
  16502. return QScriptValue();
  16503. }
  16504. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  16505. {
  16506. ZoomLog*self= getself<ZoomLog*> (context);
  16507. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  16508. }
  16509. /*:376*//*377:*/
  16510. #line 8942 "./typica.w"
  16511. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  16512. {
  16513. ZoomLog*self= getself<ZoomLog*> (context);
  16514. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  16515. return QScriptValue();
  16516. }
  16517. /*:377*//*412:*/
  16518. #line 9762 "./typica.w"
  16519. QScriptValue constructAnnotationButton(QScriptContext*context,
  16520. QScriptEngine*engine)
  16521. {
  16522. QScriptValue object=
  16523. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  16524. setAnnotationButtonProperties(object,engine);
  16525. return object;
  16526. }
  16527. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  16528. {
  16529. setQPushButtonProperties(value,engine);
  16530. }
  16531. /*:412*//*420:*/
  16532. #line 9905 "./typica.w"
  16533. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  16534. QScriptEngine*engine)
  16535. {
  16536. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  16537. argument<QString> (0,context),argument<QString> (1,context)));
  16538. setAnnotationSpinBoxProperties(object,engine);
  16539. return object;
  16540. }
  16541. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16542. {
  16543. setQDoubleSpinBoxProperties(value,engine);
  16544. }
  16545. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16546. {
  16547. setQAbstractSpinBoxProperties(value,engine);
  16548. }
  16549. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  16550. {
  16551. setQWidgetProperties(value,engine);
  16552. }
  16553. /*:420*//*441:*/
  16554. #line 10324 "./typica.w"
  16555. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  16556. {
  16557. QScriptValue object= engine->newQObject(new TimerDisplay);
  16558. setTimerDisplayProperties(object,engine);
  16559. return object;
  16560. }
  16561. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  16562. {
  16563. setQLCDNumberProperties(value,engine);
  16564. }
  16565. /*:441*//*468:*/
  16566. #line 10819 "./typica.w"
  16567. QScriptValue constructWidgetDecorator(QScriptContext*context,
  16568. QScriptEngine*engine)
  16569. {
  16570. QWidget*widget= argument<QWidget*> (0,context);
  16571. QString text= argument<QString> (1,context);
  16572. Qt::Orientations orientation;
  16573. switch(argument<int> (2,context))
  16574. {
  16575. case 2:
  16576. orientation= Qt::Vertical;
  16577. break;
  16578. default:
  16579. orientation= Qt::Horizontal;
  16580. break;
  16581. }
  16582. QScriptValue object=
  16583. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  16584. setWidgetDecoratorProperties(object,engine);
  16585. return object;
  16586. }
  16587. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  16588. {
  16589. setQWidgetProperties(value,engine);
  16590. }
  16591. /*:468*//*481:*/
  16592. #line 11100 "./typica.w"
  16593. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  16594. {
  16595. QScriptValue object= engine->newQObject(new LogEditWindow);
  16596. return object;
  16597. }
  16598. /*:481*//*500:*/
  16599. #line 11628 "./typica.w"
  16600. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  16601. {
  16602. QIODevice*device= argument<QIODevice*> (0,context);
  16603. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  16604. argument<int> (1,context)));
  16605. object.setProperty("input",engine->newFunction(XMLInput_input));
  16606. return object;
  16607. }
  16608. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  16609. {
  16610. XMLInput*self= getself<XMLInput*> (context);
  16611. self->input();
  16612. return QScriptValue();
  16613. }
  16614. /*:500*//*514:*/
  16615. #line 157 "./webview.w"
  16616. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  16617. {
  16618. QScriptValue object= engine->newQObject(new TypicaWebView);
  16619. setQWebViewProperties(object,engine);
  16620. return object;
  16621. }
  16622. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  16623. {
  16624. setQWidgetProperties(value,engine);
  16625. }
  16626. /*:514*//*515:*/
  16627. #line 174 "./webview.w"
  16628. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  16629. QStack<QLayout*> *layoutStack)
  16630. {
  16631. TypicaWebView*view= new TypicaWebView;
  16632. if(element.hasAttribute("id"))
  16633. {
  16634. view->setObjectName(element.attribute("id"));
  16635. }
  16636. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16637. layout->addWidget(view);
  16638. }
  16639. /*:515*//*520:*/
  16640. #line 225 "./webview.w"
  16641. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  16642. {
  16643. QVariant var;
  16644. var.setValue(element);
  16645. QScriptValue object= engine->newVariant(var);
  16646. return object;
  16647. }
  16648. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  16649. {
  16650. element= value.toVariant().value<QWebElement> ();
  16651. }
  16652. /*:520*//*525:*/
  16653. #line 290 "./webview.w"
  16654. template<> QWebElement argument(int arg,QScriptContext*context)
  16655. {
  16656. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  16657. }
  16658. /*:525*//*526:*/
  16659. #line 299 "./webview.w"
  16660. QScriptValue constructWebElement(QScriptContext*context,
  16661. QScriptEngine*engine)
  16662. {
  16663. QWebElement element= argument<QWebElement> (0,context);
  16664. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  16665. return object;
  16666. }
  16667. /*:526*//*591:*/
  16668. #line 12947 "./typica.w"
  16669. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  16670. {
  16671. QScriptValue object= engine->newQObject(new SqlQueryView);
  16672. setSqlQueryViewProperties(object,engine);
  16673. return object;
  16674. }
  16675. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  16676. {
  16677. setQTableViewProperties(value,engine);
  16678. value.setProperty("setHeaderData",
  16679. engine->newFunction(SqlQueryView_setHeaderData));
  16680. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  16681. }
  16682. /*:591*//*592:*/
  16683. #line 12965 "./typica.w"
  16684. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  16685. {
  16686. SqlQueryView*self= getself<SqlQueryView*> (context);
  16687. QString query= argument<QString> (0,context);
  16688. self->setQuery(query);
  16689. self->reset();
  16690. return QScriptValue();
  16691. }
  16692. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  16693. QScriptEngine*)
  16694. {
  16695. SqlQueryView*self= getself<SqlQueryView*> (context);
  16696. int section= argument<int> (0,context);
  16697. QString data= argument<QString> (1,context);
  16698. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  16699. return QScriptValue();
  16700. }
  16701. /*:592*//*600:*/
  16702. #line 13172 "./typica.w"
  16703. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  16704. QStack<QLayout*> *layoutStack)
  16705. {
  16706. QTextEdit*widget= new QTextEdit;
  16707. if(element.hasAttribute("id"))
  16708. {
  16709. widget->setObjectName(element.attribute("id"));
  16710. }
  16711. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16712. layout->addWidget(widget);
  16713. QTextDocument*document= new QTextDocument;
  16714. QFont defaultFont;
  16715. defaultFont.setPointSize(11);
  16716. document->setDefaultFont(defaultFont);
  16717. QTextCursor cursor(document);
  16718. /*601:*/
  16719. #line 13195 "./typica.w"
  16720. QDomNodeList children= element.childNodes();
  16721. for(int i= 0;i<children.count();i++)
  16722. {
  16723. QDomNode current;
  16724. QDomElement currentElement;
  16725. current= children.at(i);
  16726. if(current.isElement())
  16727. {
  16728. currentElement= current.toElement();
  16729. /*602:*/
  16730. #line 13212 "./typica.w"
  16731. if(currentElement.tagName()=="style")
  16732. {
  16733. document->setDefaultStyleSheet(currentElement.text());
  16734. }
  16735. /*:602*//*603:*/
  16736. #line 13223 "./typica.w"
  16737. if(currentElement.tagName()=="html")
  16738. {
  16739. cursor.insertHtml(currentElement.text());
  16740. }
  16741. /*:603*//*604:*/
  16742. #line 13233 "./typica.w"
  16743. if(currentElement.tagName()=="text")
  16744. {
  16745. cursor.insertText(currentElement.text());
  16746. }
  16747. /*:604*//*605:*/
  16748. #line 13243 "./typica.w"
  16749. if(currentElement.tagName()=="table")
  16750. {
  16751. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  16752. ReportTable*table= new ReportTable(frame,currentElement);
  16753. table->setParent(widget);
  16754. if(currentElement.hasAttribute("id"))
  16755. {
  16756. table->setObjectName(currentElement.attribute("id"));
  16757. }
  16758. }
  16759. /*:605*/
  16760. #line 13205 "./typica.w"
  16761. }
  16762. }
  16763. /*:601*/
  16764. #line 13188 "./typica.w"
  16765. widget->setDocument(document);
  16766. }
  16767. /*:600*//*616:*/
  16768. #line 13456 "./typica.w"
  16769. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  16770. {
  16771. QTextEdit*self= getself<QTextEdit*> (context);
  16772. QTextDocument*document= self->document();
  16773. QPrinter printer;
  16774. QPrintDialog printwindow(&printer,self);
  16775. if(printwindow.exec()!=QDialog::Accepted)
  16776. {
  16777. return QScriptValue();
  16778. }
  16779. document->print(&printer);
  16780. return QScriptValue();
  16781. }
  16782. /*:616*//*617:*/
  16783. #line 13474 "./typica.w"
  16784. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  16785. {
  16786. setQAbstractScrollAreaProperties(value,engine);
  16787. value.setProperty("print",engine->newFunction(QTextEdit_print));
  16788. }
  16789. #line 1 "./daterangeselector.w"
  16790. /*:617*//*636:*/
  16791. #line 451 "./daterangeselector.w"
  16792. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  16793. QStack<QLayout*> *layoutStack)
  16794. {
  16795. DateRangeSelector*widget= new DateRangeSelector;
  16796. if(element.hasAttribute("id"))
  16797. {
  16798. widget->setObjectName(element.attribute("id"));
  16799. }
  16800. if(element.hasAttribute("initial"))
  16801. {
  16802. widget->setCurrentIndex(element.attribute("initial").toInt());
  16803. }
  16804. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16805. layout->addWidget(widget);
  16806. }
  16807. /*:636*//*647:*/
  16808. #line 13654 "./typica.w"
  16809. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  16810. QStack<QLayout*> *layoutStack)
  16811. {
  16812. FormArray*widget= new FormArray(element);
  16813. if(element.hasAttribute("id"))
  16814. {
  16815. widget->setObjectName(element.attribute("id"));
  16816. }
  16817. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16818. layout->addWidget(widget);
  16819. }
  16820. /*:647*//*668:*/
  16821. #line 14241 "./typica.w"
  16822. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  16823. QStack<QLayout*> *layoutStack)
  16824. {
  16825. ScaleControl*scale= new ScaleControl;
  16826. if(element.hasAttribute("id"))
  16827. {
  16828. scale->setObjectName(element.attribute("id"));
  16829. }
  16830. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16831. layout->addWidget(scale);
  16832. }
  16833. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  16834. QStack<QLayout*> *layoutStack)
  16835. {
  16836. IntensityControl*scale= new IntensityControl;
  16837. if(element.hasAttribute("id"))
  16838. {
  16839. scale->setObjectName(element.attribute("id"));
  16840. }
  16841. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16842. layout->addWidget(scale);
  16843. }
  16844. /*:668*//*694:*/
  16845. #line 14831 "./typica.w"
  16846. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  16847. {
  16848. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  16849. setDeviceTreeModelProperties(object,engine);
  16850. return object;
  16851. }
  16852. /*:694*//*696:*/
  16853. #line 14854 "./typica.w"
  16854. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  16855. {
  16856. setQAbstractItemModelProperties(value,engine);
  16857. value.setProperty("referenceElement",
  16858. engine->newFunction(DeviceTreeModel_referenceElement));
  16859. }
  16860. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  16861. {
  16862. setQObjectProperties(value,engine);
  16863. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  16864. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  16865. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  16866. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  16867. }
  16868. /*:696*//*697:*/
  16869. #line 14881 "./typica.w"
  16870. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  16871. QScriptEngine*engine)
  16872. {
  16873. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  16874. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  16875. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  16876. QDomElement node;
  16877. QVariantMap retval;
  16878. retval.insert("driver",referenceElement.attribute("driver"));
  16879. for(int i= 0;i<configData.size();i++)
  16880. {
  16881. node= configData.at(i).toElement();
  16882. retval.insert(node.attribute("name"),node.attribute("value"));
  16883. }
  16884. return engine->toScriptValue(retval);
  16885. }
  16886. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  16887. {
  16888. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  16889. QModelIndex index= argument<QModelIndex> (0,context);
  16890. int role= argument<int> (1,context);
  16891. return engine->toScriptValue(model->data(index,role));
  16892. }
  16893. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  16894. {
  16895. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  16896. int row= 0;
  16897. int column= 0;
  16898. QModelIndex index;
  16899. if(context->argumentCount()> 1)
  16900. {
  16901. row= argument<int> (0,context);
  16902. column= argument<int> (1,context);
  16903. }
  16904. if(context->argumentCount()> 2)
  16905. {
  16906. index= argument<QModelIndex> (2,context);
  16907. }
  16908. QModelIndex retval= model->index(row,column,index);
  16909. return engine->toScriptValue(retval);
  16910. }
  16911. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  16912. QScriptEngine*)
  16913. {
  16914. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  16915. QModelIndex index;
  16916. if(context->argumentCount()==1)
  16917. {
  16918. index= argument<QModelIndex> (0,context);
  16919. }
  16920. return QScriptValue(model->rowCount(index));
  16921. }
  16922. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  16923. QScriptEngine*engine)
  16924. {
  16925. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  16926. QModelIndex index;
  16927. if(context->argumentCount()==1)
  16928. {
  16929. index= argument<QModelIndex> (0,context);
  16930. }
  16931. return QScriptValue(engine,model->hasChildren(index));
  16932. }
  16933. /*:697*//*700:*/
  16934. #line 14965 "./typica.w"
  16935. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  16936. {
  16937. QVariant var;
  16938. var.setValue(index);
  16939. QScriptValue object= engine->newVariant(var);
  16940. return object;
  16941. }
  16942. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  16943. {
  16944. index= value.toVariant().value<QModelIndex> ();
  16945. }
  16946. /*:700*//*716:*/
  16947. #line 15263 "./typica.w"
  16948. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  16949. QScriptEngine*engine)
  16950. {
  16951. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  16952. return object;
  16953. }
  16954. /*:716*//*787:*/
  16955. #line 45 "./settings.w"
  16956. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  16957. {
  16958. QScriptValue object= engine->newQObject(new SettingsWindow);
  16959. return object;
  16960. }
  16961. /*:787*//*807:*/
  16962. #line 17812 "./typica.w"
  16963. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  16964. {
  16965. QScriptValue object;
  16966. if(context->argumentCount()==2)
  16967. {
  16968. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  16969. argument<QModelIndex> (1,context)),
  16970. QScriptEngine::ScriptOwnership);
  16971. setModbusRTUDeviceProperties(object,engine);
  16972. }
  16973. else
  16974. {
  16975. context->throwError("Incorrect number of arguments passed to "
  16976. "ModbusRTUDevice constructor. This takes the configuration model "
  16977. "and an index.");
  16978. }
  16979. return object;
  16980. }
  16981. /*:807*//*808:*/
  16982. #line 17834 "./typica.w"
  16983. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  16984. {
  16985. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  16986. QScriptValue object;
  16987. if(self)
  16988. {
  16989. if(self->channels.size()> 0)
  16990. {
  16991. object= engine->newQObject(self->channels.at(0));
  16992. setChannelProperties(object,engine);
  16993. }
  16994. }
  16995. return object;
  16996. }
  16997. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  16998. {
  16999. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  17000. QScriptValue object;
  17001. if(self)
  17002. {
  17003. if(self->channels.size()> 1)
  17004. {
  17005. object= engine->newQObject(self->channels.at(1));
  17006. setChannelProperties(object,engine);
  17007. }
  17008. }
  17009. return object;
  17010. }
  17011. /*:808*//*809:*/
  17012. #line 17867 "./typica.w"
  17013. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17014. {
  17015. setQObjectProperties(value,engine);
  17016. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  17017. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  17018. }
  17019. /*:809*//*827:*/
  17020. #line 357 "./unsupportedserial.w"
  17021. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  17022. {
  17023. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  17024. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  17025. QScriptValue object= engine->newQObject(device);
  17026. setQObjectProperties(object,engine);
  17027. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  17028. return object;
  17029. }
  17030. /*:827*//*832:*/
  17031. #line 430 "./unsupportedserial.w"
  17032. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  17033. {
  17034. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  17035. QScriptValue object;
  17036. if(self)
  17037. {
  17038. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  17039. setChannelProperties(object,engine);
  17040. }
  17041. return object;
  17042. }
  17043. /*:832*//*839:*/
  17044. #line 630 "./unsupportedserial.w"
  17045. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  17046. {
  17047. return engine->toScriptValue<QTime> (QTime::currentTime());
  17048. }
  17049. /*:839*//*843:*/
  17050. #line 667 "./unsupportedserial.w"
  17051. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  17052. {
  17053. QScriptValue object= engine->newQObject(new QextSerialPort());
  17054. setSerialPortProperties(object,engine);
  17055. return object;
  17056. }
  17057. /*:843*//*844:*/
  17058. #line 678 "./unsupportedserial.w"
  17059. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  17060. {
  17061. setQIODeviceProperties(value,engine);
  17062. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  17063. }
  17064. /*:844*//*845:*/
  17065. #line 687 "./unsupportedserial.w"
  17066. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  17067. {
  17068. QextSerialPort*self= getself<QextSerialPort*> (context);
  17069. self->flush();
  17070. return QScriptValue();
  17071. }
  17072. #line 18418 "./typica.w"
  17073. /*:845*//*863:*/
  17074. #line 151 "./rate.w"
  17075. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  17076. {
  17077. int cachetime= 1;
  17078. int scaletime= 1;
  17079. if(context->argumentCount()> 0)
  17080. {
  17081. cachetime= argument<int> (0,context);
  17082. if(context->argumentCount()> 1)
  17083. {
  17084. scaletime= argument<int> (1,context);
  17085. }
  17086. }
  17087. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  17088. setRateOfChangeProperties(object,engine);
  17089. return object;
  17090. }
  17091. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  17092. {
  17093. setQObjectProperties(value,engine);
  17094. }
  17095. /*:863*//*888:*/
  17096. #line 614 "./dataqsdk.w"
  17097. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  17098. {
  17099. QScriptValue object;
  17100. if(context->argumentCount()==1)
  17101. {
  17102. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  17103. QScriptEngine::ScriptOwnership);
  17104. setDataqSdkDeviceProperties(object,engine);
  17105. }
  17106. else
  17107. {
  17108. context->throwError("Incorrect number of arguments passed to "
  17109. "DataqSdkDevice. The constructor takes one string "
  17110. "as an argument specifying a device name. "
  17111. "Example: Dev1");
  17112. }
  17113. return object;
  17114. }
  17115. /*:888*//*889:*/
  17116. #line 637 "./dataqsdk.w"
  17117. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  17118. {
  17119. setQObjectProperties(value,engine);
  17120. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  17121. }
  17122. /*:889*//*890:*/
  17123. #line 647 "./dataqsdk.w"
  17124. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  17125. {
  17126. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  17127. QScriptValue object;
  17128. if(self)
  17129. {
  17130. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  17131. setChannelProperties(object,engine);
  17132. }
  17133. return object;
  17134. }
  17135. /*:890*//*915:*/
  17136. #line 80 "./scales.w"
  17137. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  17138. {
  17139. QScriptValue object;
  17140. QString labelText= "";
  17141. if(context->argumentCount()==1)
  17142. {
  17143. labelText= argument<QString> (0,context);
  17144. }
  17145. object= engine->newQObject(new DragLabel(labelText));
  17146. setDragLabelProperties(object,engine);
  17147. return object;
  17148. }
  17149. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  17150. {
  17151. setQLabelProperties(value,engine);
  17152. }
  17153. /*:915*//*925:*/
  17154. #line 272 "./scales.w"
  17155. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  17156. {
  17157. return engine->newVariant(QVariant((int)(value)));
  17158. }
  17159. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  17160. {
  17161. value= (BaudRateType)(sv.toVariant().toInt());
  17162. }
  17163. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  17164. {
  17165. return engine->newVariant(QVariant((int)(value)));
  17166. }
  17167. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  17168. {
  17169. value= (DataBitsType)(sv.toVariant().toInt());
  17170. }
  17171. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  17172. {
  17173. return engine->newVariant(QVariant((int)(value)));
  17174. }
  17175. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  17176. {
  17177. value= (ParityType)(sv.toVariant().toInt());
  17178. }
  17179. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  17180. {
  17181. return engine->newVariant(QVariant((int)(value)));
  17182. }
  17183. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  17184. {
  17185. value= (StopBitsType)(sv.toVariant().toInt());
  17186. }
  17187. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  17188. {
  17189. return engine->newVariant(QVariant((int)(value)));
  17190. }
  17191. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  17192. {
  17193. value= (FlowType)(sv.toVariant().toInt());
  17194. }
  17195. /*:925*//*928:*/
  17196. #line 341 "./scales.w"
  17197. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  17198. {
  17199. setQIODeviceProperties(value,engine);
  17200. }
  17201. /*:928*//*929:*/
  17202. #line 349 "./scales.w"
  17203. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  17204. {
  17205. QScriptValue object;
  17206. if(context->argumentCount()==1)
  17207. {
  17208. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  17209. setSerialScaleProperties(object,engine);
  17210. }
  17211. else
  17212. {
  17213. context->throwError("Incorrect number of arguments passed to "
  17214. "SerialScale. The constructor takes one string "
  17215. "as an argument specifying a port name.");
  17216. }
  17217. return object;
  17218. }
  17219. /*:929*//*951:*/
  17220. #line 278 "./valueannotation.w"
  17221. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  17222. {
  17223. QScriptValue object= engine->newQObject(new ValueAnnotation);
  17224. setValueAnnotationProperties(object,engine);
  17225. return object;
  17226. }
  17227. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  17228. {
  17229. setQObjectProperties(value,engine);
  17230. }
  17231. #line 18639 "./typica.w"
  17232. /*:951*/
  17233. #line 529 "./typica.w"
  17234. /*570:*/
  17235. #line 12577 "./typica.w"
  17236. int main(int argc,char**argv)
  17237. {
  17238. int*c= &argc;
  17239. Application app(*c,argv);
  17240. /*571:*/
  17241. #line 12603 "./typica.w"
  17242. QStringList themeSearchPath= QIcon::themeSearchPaths();
  17243. themeSearchPath.append(":/resources/icons/tango");
  17244. QIcon::setThemeSearchPaths(themeSearchPath);
  17245. QIcon::setThemeName(":/resources/icons/tango");
  17246. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  17247. /*:571*/
  17248. #line 12582 "./typica.w"
  17249. /*572:*/
  17250. #line 12623 "./typica.w"
  17251. QFile entypo(":/resources/fonts/entypo.ttf");
  17252. entypo.open(QIODevice::ReadOnly);
  17253. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  17254. entypo.close();
  17255. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  17256. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  17257. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  17258. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  17259. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  17260. /*:572*/
  17261. #line 12583 "./typica.w"
  17262. QSettings settings;
  17263. /*726:*/
  17264. #line 15483 "./typica.w"
  17265. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  17266. /*:726*//*736:*/
  17267. #line 15725 "./typica.w"
  17268. app.registerDeviceConfigurationWidget("nidaqmxbase",
  17269. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  17270. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  17271. NiDaqMxBase9211ConfWidget::staticMetaObject);
  17272. app.registerDeviceConfigurationWidget("ni9211seriestc",
  17273. Ni9211TcConfWidget::staticMetaObject);
  17274. /*:736*//*744:*/
  17275. #line 15956 "./typica.w"
  17276. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  17277. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  17278. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  17279. /*:744*//*768:*/
  17280. #line 16921 "./typica.w"
  17281. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  17282. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  17283. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  17284. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  17285. /*:768*//*773:*/
  17286. #line 17006 "./typica.w"
  17287. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  17288. /*:773*//*776:*/
  17289. #line 17076 "./typica.w"
  17290. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  17291. /*:776*//*779:*/
  17292. #line 17203 "./typica.w"
  17293. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  17294. #line 1 "./freeannotation.w"
  17295. /*:779*//*783:*/
  17296. #line 57 "./freeannotation.w"
  17297. app.registerDeviceConfigurationWidget("freeannotation",
  17298. FreeAnnotationConfWidget::staticMetaObject);
  17299. #line 17207 "./typica.w"
  17300. #line 1 "./settings.w"
  17301. /*:783*//*812:*/
  17302. #line 18408 "./typica.w"
  17303. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  17304. /*:812*//*822:*/
  17305. #line 264 "./unsupportedserial.w"
  17306. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  17307. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  17308. app.registerDeviceConfigurationWidget("unsupporteddevice",
  17309. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  17310. /*:822*//*851:*/
  17311. #line 18540 "./typica.w"
  17312. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  17313. /*:851*//*855:*/
  17314. #line 18629 "./typica.w"
  17315. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  17316. #line 1 "./rate.w"
  17317. /*:855*//*867:*/
  17318. #line 253 "./rate.w"
  17319. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  17320. /*:867*//*908:*/
  17321. #line 1233 "./dataqsdk.w"
  17322. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  17323. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  17324. DataqSdkChannelConfWidget::staticMetaObject);
  17325. /*:908*//*933:*/
  17326. #line 490 "./scales.w"
  17327. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  17328. /*:933*//*941:*/
  17329. #line 138 "./valueannotation.w"
  17330. app.registerDeviceConfigurationWidget("valueannotation",
  17331. ValueAnnotationConfWidget::staticMetaObject);
  17332. /*:941*/
  17333. #line 12587 "./typica.w"
  17334. /*573:*/
  17335. #line 12640 "./typica.w"
  17336. if(settings.value("database/exists","false").toString()=="true")
  17337. {
  17338. /*578:*/
  17339. #line 12762 "./typica.w"
  17340. QSqlDatabase database=
  17341. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  17342. database.setConnectOptions("application_name=Typica");
  17343. database.setHostName(settings.value("database/hostname").toString());
  17344. database.setDatabaseName(settings.value("database/dbname").toString());
  17345. database.setUserName(settings.value("database/user").toString());
  17346. database.setPassword(settings.value("database/password").toString());
  17347. if(!database.open())
  17348. {
  17349. settings.setValue("database/exists","false");
  17350. }
  17351. else
  17352. {
  17353. database.close();
  17354. }
  17355. /*:578*/
  17356. #line 12643 "./typica.w"
  17357. }
  17358. if(settings.value("database/exists","false").toString()=="false")
  17359. {
  17360. /*577:*/
  17361. #line 12753 "./typica.w"
  17362. SqlConnectionSetup dialog;
  17363. dialog.exec();
  17364. /*:577*/
  17365. #line 12647 "./typica.w"
  17366. }
  17367. /*:573*/
  17368. #line 12588 "./typica.w"
  17369. /*158:*/
  17370. #line 3696 "./typica.w"
  17371. QStringList arguments= QCoreApplication::arguments();
  17372. int position= arguments.indexOf("-c");
  17373. QString filename= QString();
  17374. if(position!=-1)
  17375. {
  17376. if(arguments.size()>=position+1)
  17377. {
  17378. filename= arguments.at(position+1);
  17379. }
  17380. }
  17381. if(filename.isEmpty())
  17382. {
  17383. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  17384. settings.value("config","").toString());
  17385. }
  17386. QDir directory;
  17387. if(!filename.isEmpty())
  17388. {
  17389. QFile file(filename);
  17390. QFileInfo info(filename);
  17391. directory= info.dir();
  17392. settings.setValue("config",directory.path());
  17393. if(file.open(QIODevice::ReadOnly))
  17394. {
  17395. app.configuration()->setContent(&file,true);
  17396. }
  17397. }
  17398. /*159:*/
  17399. #line 3730 "./typica.w"
  17400. QDomElement root= app.configuration()->documentElement();
  17401. QDomNodeList children= root.childNodes();
  17402. QString replacementDoc;
  17403. QDomDocument includedDoc;
  17404. QDomDocumentFragment fragment;
  17405. for(int i= 0;i<children.size();i++)
  17406. {
  17407. QDomNode currentNode= children.at(i);
  17408. QDomElement currentElement;
  17409. if(currentNode.nodeName()=="include")
  17410. {
  17411. currentElement= currentNode.toElement();
  17412. if(currentElement.hasAttribute("src"))
  17413. {
  17414. replacementDoc= directory.path();
  17415. replacementDoc.append('/');
  17416. replacementDoc.append(currentElement.attribute("src"));
  17417. QFile doc(replacementDoc);
  17418. if(doc.open(QIODevice::ReadOnly))
  17419. {
  17420. includedDoc.setContent(&doc,true);
  17421. fragment= includedDoc.createDocumentFragment();
  17422. fragment.appendChild(includedDoc.documentElement());
  17423. root.replaceChild(fragment,currentNode);
  17424. doc.close();
  17425. }
  17426. }
  17427. }
  17428. }
  17429. /*:159*/
  17430. #line 3724 "./typica.w"
  17431. /*:158*/
  17432. #line 12589 "./typica.w"
  17433. /*7:*/
  17434. #line 657 "./typica.w"
  17435. QScriptEngine*engine= new QScriptEngine;
  17436. QScriptValue constructor;
  17437. QScriptValue value;
  17438. /*:7*//*17:*/
  17439. #line 854 "./typica.w"
  17440. constructor= engine->newFunction(constructQWidget);
  17441. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  17442. engine->globalObject().setProperty("QWidget",value);
  17443. /*:17*//*28:*/
  17444. #line 1100 "./typica.w"
  17445. constructor= engine->newFunction(constructQMainWindow);
  17446. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  17447. constructor);
  17448. engine->globalObject().setProperty("QMainWindow",value);
  17449. /*:28*//*39:*/
  17450. #line 1305 "./typica.w"
  17451. constructor= engine->newFunction(constructQFrame);
  17452. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  17453. engine->globalObject().setProperty("QFrame",value);
  17454. /*:39*//*42:*/
  17455. #line 1338 "./typica.w"
  17456. constructor= engine->newFunction(constructQLabel);
  17457. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  17458. engine->globalObject().setProperty("QLabel",value);
  17459. /*:42*//*45:*/
  17460. #line 1376 "./typica.w"
  17461. constructor= engine->newFunction(constructQLineEdit);
  17462. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  17463. engine->globalObject().setProperty("QLineEdit",value);
  17464. /*:45*//*49:*/
  17465. #line 1421 "./typica.w"
  17466. constructor= engine->newFunction(constructQSplitter);
  17467. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  17468. engine->globalObject().setProperty("QSplitter",value);
  17469. /*:49*//*56:*/
  17470. #line 1592 "./typica.w"
  17471. constructor= engine->newFunction(constructQBoxLayout);
  17472. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  17473. engine->globalObject().setProperty("QBoxLayout",value);
  17474. /*:56*//*60:*/
  17475. #line 1704 "./typica.w"
  17476. constructor= engine->newFunction(constructQAction);
  17477. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  17478. engine->globalObject().setProperty("QAction",value);
  17479. /*:60*//*63:*/
  17480. #line 1763 "./typica.w"
  17481. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  17482. value.setProperty("getOpenFileName",
  17483. engine->newFunction(QFileDialog_getOpenFileName));
  17484. value.setProperty("getSaveFileName",
  17485. engine->newFunction(QFileDialog_getSaveFileName));
  17486. engine->globalObject().setProperty("QFileDialog",value);
  17487. /*:63*//*68:*/
  17488. #line 1878 "./typica.w"
  17489. constructor= engine->newFunction(constructQFile);
  17490. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  17491. engine->globalObject().setProperty("QFile",value);
  17492. /*:68*//*78:*/
  17493. #line 2070 "./typica.w"
  17494. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  17495. constructor= engine->newFunction(constructQByteArray);
  17496. engine->globalObject().setProperty("QByteArray",constructor);
  17497. /*:78*//*83:*/
  17498. #line 2121 "./typica.w"
  17499. constructor= engine->newFunction(constructQBuffer);
  17500. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  17501. engine->globalObject().setProperty("QBuffer",value);
  17502. /*:83*//*86:*/
  17503. #line 2170 "./typica.w"
  17504. constructor= engine->newFunction(constructXQuery);
  17505. engine->globalObject().setProperty("XQuery",constructor);
  17506. /*:86*//*92:*/
  17507. #line 2272 "./typica.w"
  17508. constructor= engine->newFunction(constructXmlWriter);
  17509. engine->globalObject().setProperty("XmlWriter",constructor);
  17510. /*:92*//*101:*/
  17511. #line 2478 "./typica.w"
  17512. constructor= engine->newFunction(constructXmlReader);
  17513. engine->globalObject().setProperty("XmlReader",constructor);
  17514. /*:101*//*108:*/
  17515. #line 2602 "./typica.w"
  17516. value= engine->newQObject(&settings);
  17517. setQSettingsProperties(value,engine);
  17518. engine->globalObject().setProperty("QSettings",value);
  17519. /*:108*//*112:*/
  17520. #line 2683 "./typica.w"
  17521. constructor= engine->newFunction(constructQLCDNumber);
  17522. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  17523. engine->globalObject().setProperty("QLCDNumber",value);
  17524. /*:112*//*115:*/
  17525. #line 2739 "./typica.w"
  17526. constructor= engine->newFunction(constructQTime);
  17527. engine->globalObject().setProperty("QTime",constructor);
  17528. /*:115*//*137:*/
  17529. #line 3252 "./typica.w"
  17530. constructor= engine->newFunction(constructQPushButton);
  17531. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  17532. engine->globalObject().setProperty("QPushButton",value);
  17533. /*:137*//*144:*/
  17534. #line 3363 "./typica.w"
  17535. constructor= engine->newFunction(constructQSqlQuery);
  17536. engine->globalObject().setProperty("QSqlQuery",constructor);
  17537. /*:144*//*151:*/
  17538. #line 3527 "./typica.w"
  17539. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  17540. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  17541. engine->globalObject().setProperty("sqlToArray",
  17542. engine->newFunction(sqlToArray));
  17543. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  17544. engine->globalObject().setProperty("annotationFromRecord",
  17545. engine->newFunction(annotationFromRecord));
  17546. engine->globalObject().setProperty("setTabOrder",
  17547. engine->newFunction(setTabOrder));
  17548. engine->globalObject().setProperty("findWindowByName",
  17549. engine->newFunction(findWindowByName));
  17550. /*:151*//*163:*/
  17551. #line 3897 "./typica.w"
  17552. engine->globalObject().setProperty("createWindow",
  17553. engine->newFunction(createWindow));
  17554. engine->globalObject().setProperty("createReport",
  17555. engine->newFunction(createReport));
  17556. /*:163*//*216:*/
  17557. #line 5440 "./typica.w"
  17558. engine->globalObject().setProperty("findChildObject",
  17559. engine->newFunction(findChildObject));
  17560. /*:216*//*242:*/
  17561. #line 376 "./units.w"
  17562. value= engine->newQMetaObject(&Units::staticMetaObject);
  17563. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  17564. value.setProperty("convertRelativeTemperature",
  17565. engine->newFunction(Units_convertRelativeTemperature));
  17566. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  17567. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  17568. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  17569. engine->globalObject().setProperty("Units",value);
  17570. /*:242*//*247:*/
  17571. #line 449 "./units.w"
  17572. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  17573. #line 5860 "./typica.w"
  17574. /*:247*//*255:*/
  17575. #line 141 "./measurement.w"
  17576. constructor= engine->newFunction(constructMeasurement);
  17577. engine->globalObject().setProperty("Measurement",constructor);
  17578. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  17579. /*:255*//*275:*/
  17580. #line 6430 "./typica.w"
  17581. constructor= engine->newFunction(constructDAQ);
  17582. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  17583. value.setProperty("Fahrenheit",Units::Fahrenheit);
  17584. value.setProperty("Celsius",Units::Celsius);
  17585. value.setProperty("Kelvin",Units::Kelvin);
  17586. value.setProperty("Rankine",Units::Rankine);
  17587. engine->globalObject().setProperty("DAQ",value);
  17588. /*:275*//*284:*/
  17589. #line 6632 "./typica.w"
  17590. constructor= engine->newFunction(constructFakeDAQ);
  17591. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  17592. engine->globalObject().setProperty("FakeDAQ",value);
  17593. /*:284*//*295:*/
  17594. #line 6915 "./typica.w"
  17595. constructor= engine->newFunction(constructLinearCalibrator);
  17596. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  17597. constructor);
  17598. engine->globalObject().setProperty("LinearCalibrator",value);
  17599. /*:295*//*300:*/
  17600. #line 7054 "./typica.w"
  17601. constructor= engine->newFunction(constructLinearSplineInterpolator);
  17602. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  17603. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  17604. /*:300*//*310:*/
  17605. #line 7259 "./typica.w"
  17606. constructor= engine->newFunction(constructTemperatureDisplay);
  17607. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  17608. constructor);
  17609. engine->globalObject().setProperty("TemperatureDisplay",value);
  17610. /*:310*//*318:*/
  17611. #line 7417 "./typica.w"
  17612. constructor= engine->newFunction(constructMeasurementTimeOffset);
  17613. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  17614. constructor);
  17615. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  17616. /*:318*//*323:*/
  17617. #line 7528 "./typica.w"
  17618. constructor= engine->newFunction(constructThresholdDetector);
  17619. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  17620. engine->globalObject().setProperty("ThresholdDetector",value);
  17621. /*:323*//*328:*/
  17622. #line 7627 "./typica.w"
  17623. constructor= engine->newFunction(constructZeroEmitter);
  17624. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  17625. engine->globalObject().setProperty("ZeroEmitter",value);
  17626. /*:328*//*333:*/
  17627. #line 7706 "./typica.w"
  17628. constructor= engine->newFunction(constructMeasurementAdapter);
  17629. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  17630. constructor);
  17631. engine->globalObject().setProperty("MeasurementAdapter",value);
  17632. /*:333*//*350:*/
  17633. #line 8169 "./typica.w"
  17634. constructor= engine->newFunction(constructGraphView);
  17635. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  17636. engine->globalObject().setProperty("GraphView",value);
  17637. /*:350*//*373:*/
  17638. #line 8806 "./typica.w"
  17639. constructor= engine->newFunction(constructZoomLog);
  17640. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  17641. engine->globalObject().setProperty("ZoomLog",value);
  17642. /*:373*//*411:*/
  17643. #line 9754 "./typica.w"
  17644. constructor= engine->newFunction(constructAnnotationButton);
  17645. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  17646. constructor);
  17647. engine->globalObject().setProperty("AnnotationButton",value);
  17648. /*:411*//*419:*/
  17649. #line 9896 "./typica.w"
  17650. constructor= engine->newFunction(constructAnnotationSpinBox);
  17651. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  17652. constructor);
  17653. engine->globalObject().setProperty("AnnotationSpinBox",value);
  17654. /*:419*//*440:*/
  17655. #line 10317 "./typica.w"
  17656. constructor= engine->newFunction(constructTimerDisplay);
  17657. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  17658. engine->globalObject().setProperty("TimerDisplay",value);
  17659. /*:440*//*467:*/
  17660. #line 10811 "./typica.w"
  17661. constructor= engine->newFunction(constructWidgetDecorator);
  17662. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  17663. engine->globalObject().setProperty("WidgetDecorator",value);
  17664. /*:467*//*480:*/
  17665. #line 11093 "./typica.w"
  17666. constructor= engine->newFunction(constructLogEditWindow);
  17667. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  17668. engine->globalObject().setProperty("LogEditWindow",value);
  17669. /*:480*//*499:*/
  17670. #line 11621 "./typica.w"
  17671. constructor= engine->newFunction(constructXMLInput);
  17672. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  17673. engine->globalObject().setProperty("XMLInput",value);
  17674. /*:499*//*513:*/
  17675. #line 149 "./webview.w"
  17676. constructor= engine->newFunction(constructWebView);
  17677. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  17678. engine->globalObject().setProperty("WebView",value);
  17679. /*:513*//*521:*/
  17680. #line 241 "./webview.w"
  17681. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  17682. /*:521*//*524:*/
  17683. #line 283 "./webview.w"
  17684. constructor= engine->newFunction(constructWebElement);
  17685. engine->globalObject().setProperty("WebElement",constructor);
  17686. /*:524*//*535:*/
  17687. #line 11864 "./typica.w"
  17688. value= engine->newQObject(AppInstance);
  17689. engine->globalObject().setProperty("Application",value);
  17690. /*:535*//*590:*/
  17691. #line 12939 "./typica.w"
  17692. constructor= engine->newFunction(constructSqlQueryView);
  17693. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  17694. engine->globalObject().setProperty("SqlQueryView",value);
  17695. /*:590*//*695:*/
  17696. #line 14841 "./typica.w"
  17697. constructor= engine->newFunction(constructDeviceTreeModel);
  17698. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  17699. constructor);
  17700. engine->globalObject().setProperty("DeviceTreeModel",value);
  17701. /*:695*//*701:*/
  17702. #line 14981 "./typica.w"
  17703. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  17704. /*:701*//*717:*/
  17705. #line 15273 "./typica.w"
  17706. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  17707. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  17708. constructor);
  17709. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  17710. /*:717*//*788:*/
  17711. #line 54 "./settings.w"
  17712. constructor= engine->newFunction(constructSettingsWindow);
  17713. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  17714. engine->globalObject().setProperty("SettingsWindow",value);
  17715. #line 1 "./graphsettings.w"
  17716. /*:788*//*806:*/
  17717. #line 17803 "./typica.w"
  17718. constructor= engine->newFunction(constructModbusRTUDevice);
  17719. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  17720. engine->globalObject().setProperty("ModbusRTUDevice",value);
  17721. /*:806*//*826:*/
  17722. #line 350 "./unsupportedserial.w"
  17723. engine->globalObject().setProperty("createDevice",
  17724. engine->newFunction(createDevice));
  17725. /*:826*//*838:*/
  17726. #line 622 "./unsupportedserial.w"
  17727. engine->globalObject().setProperty("getMeasurementTimestamp",
  17728. engine->newFunction(getMeasurementTimestamp));
  17729. /*:838*//*842:*/
  17730. #line 658 "./unsupportedserial.w"
  17731. constructor= engine->newFunction(constructSerialPort);
  17732. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  17733. engine->globalObject().setProperty("SerialPort",value);
  17734. /*:842*//*862:*/
  17735. #line 144 "./rate.w"
  17736. constructor= engine->newFunction(constructRateOfChange);
  17737. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  17738. engine->globalObject().setProperty("RateOfChange",value);
  17739. /*:862*//*887:*/
  17740. #line 604 "./dataqsdk.w"
  17741. constructor= engine->newFunction(constructDataqSdkDevice);
  17742. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  17743. engine->globalObject().setProperty("DataqSdkDevice",value);
  17744. /*:887*//*914:*/
  17745. #line 73 "./scales.w"
  17746. constructor= engine->newFunction(constructDragLabel);
  17747. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  17748. engine->globalObject().setProperty("DragLabel",value);
  17749. /*:914*//*922:*/
  17750. #line 239 "./scales.w"
  17751. constructor= engine->newFunction(constructSerialScale);
  17752. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  17753. engine->globalObject().setProperty("SerialScale",value);
  17754. /*:922*//*926:*/
  17755. #line 325 "./scales.w"
  17756. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  17757. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  17758. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  17759. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  17760. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  17761. /*:926*//*950:*/
  17762. #line 271 "./valueannotation.w"
  17763. constructor= engine->newFunction(constructValueAnnotation);
  17764. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  17765. engine->globalObject().setProperty("ValueAnnotation",value);
  17766. /*:950*/
  17767. #line 12590 "./typica.w"
  17768. app.engine= engine;
  17769. /*160:*/
  17770. #line 3778 "./typica.w"
  17771. QString styleText;
  17772. QString programText;
  17773. QDomElement currentElement;
  17774. for(int i= 0;i<children.size();i++)
  17775. {
  17776. QDomNode currentNode= children.at(i);
  17777. if(currentNode.nodeName()=="style")
  17778. {
  17779. currentElement= currentNode.toElement();
  17780. styleText.append(currentElement.text());
  17781. }
  17782. else if(currentNode.nodeName()=="program")
  17783. {
  17784. currentElement= currentNode.toElement();
  17785. programText.append(currentElement.text());
  17786. }
  17787. }
  17788. app.setStyleSheet(styleText);
  17789. QScriptValue result= engine->evaluate(programText);
  17790. /*161:*/
  17791. #line 3803 "./typica.w"
  17792. if(engine->hasUncaughtException())
  17793. {
  17794. int line= engine->uncaughtExceptionLineNumber();
  17795. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  17796. result.toString();
  17797. QString trace;
  17798. foreach(trace,engine->uncaughtExceptionBacktrace())
  17799. {
  17800. qDebug()<<trace;
  17801. }
  17802. }
  17803. /*:161*/
  17804. #line 3798 "./typica.w"
  17805. /*:160*/
  17806. #line 12592 "./typica.w"
  17807. int retval= app.exec();
  17808. delete engine;
  17809. return retval;
  17810. }
  17811. /*:570*/
  17812. #line 530 "./typica.w"
  17813. #include "moc_typica.cpp"
  17814. /*:3*/