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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 617 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. /*:5*//*6:*/
  17. #line 633 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*291:*/
  20. #line 6606 "./typica.w"
  21. #include "units.h"
  22. #line 1 "./measurement.w"
  23. /*:291*//*561:*/
  24. #line 197 "./webview.w"
  25. #include "webview.h"
  26. /*:561*//*574:*/
  27. #line 375 "./webview.w"
  28. #include "webelement.h"
  29. #line 12572 "./typica.w"
  30. /*:574*//*685:*/
  31. #line 489 "./daterangeselector.w"
  32. #include "daterangeselector.h"
  33. #line 14298 "./typica.w"
  34. /*:685*//*793:*/
  35. #line 16869 "./typica.w"
  36. #include "qextserialport.h"
  37. #include "qextserialenumerator.h"
  38. /*:793*//*976:*/
  39. #line 124 "./dataqsdk.w"
  40. #ifdef Q_OS_WIN32
  41. #include <windef.h>
  42. #else
  43. #define PASCAL
  44. #endif
  45. /*:976*//*1000:*/
  46. #line 862 "./dataqsdk.w"
  47. #include <limits>
  48. /*:1000*//*1015:*/
  49. #line 62 "./scales.w"
  50. #include "draglabel.h"
  51. /*:1015*//*1030:*/
  52. #line 361 "./scales.w"
  53. #include "scale.h"
  54. /*:1030*/
  55. #line 525 "./typica.w"
  56. /*23:*/
  57. #line 995 "./typica.w"
  58. class ScriptQMainWindow:public QMainWindow
  59. {
  60. Q_OBJECT
  61. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  62. public:
  63. ScriptQMainWindow();
  64. QString closePrompt();
  65. public slots:
  66. void show();
  67. void saveSizeAndPosition(const QString&key);
  68. void restoreSizeAndPosition(const QString&key);
  69. void displayStatus(const QString&message= QString());
  70. void setClosePrompt(QString prompt);
  71. protected:
  72. void closeEvent(QCloseEvent*event);
  73. void showEvent(QShowEvent*event);
  74. signals:
  75. void aboutToClose(void);
  76. private:
  77. QString cprompt;
  78. };
  79. /*:23*//*169:*/
  80. #line 3919 "./typica.w"
  81. class SqlQueryConnection:public QSqlQuery
  82. {
  83. public:
  84. SqlQueryConnection(const QString&query= QString());
  85. ~SqlQueryConnection();
  86. QSqlQuery*operator->()const;
  87. private:
  88. QString connection;
  89. QSqlQuery*q;
  90. };
  91. /*:169*//*240:*/
  92. #line 5808 "./typica.w"
  93. class NumericDelegate:public QItemDelegate
  94. {
  95. Q_OBJECT
  96. public:
  97. NumericDelegate(QObject*parent= NULL);
  98. QWidget*createEditor(QWidget*parent,
  99. const QStyleOptionViewItem&option,
  100. const QModelIndex&index)const;
  101. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  102. void setModelData(QWidget*editor,QAbstractItemModel*model,
  103. const QModelIndex&index)const;
  104. void updateEditorGeometry(QWidget*editor,
  105. const QStyleOptionViewItem&option,
  106. const QModelIndex&index)const;
  107. };
  108. /*:240*//*246:*/
  109. #line 5901 "./typica.w"
  110. class ScriptValidator:public QValidator
  111. {
  112. Q_OBJECT
  113. public:
  114. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  115. void fixup(QString&input)const;
  116. QValidator::State validate(QString&input,int&pos)const;
  117. private:
  118. QValidator*v;
  119. };
  120. /*:246*//*287:*/
  121. #line 438 "./units.w"
  122. Q_DECLARE_METATYPE(Units::Unit)
  123. /*:287*//*292:*/
  124. #line 19 "./measurement.w"
  125. class Measurement:public QVariantMap
  126. {
  127. public:
  128. Measurement(double temperature= 0,QTime time= QTime(),
  129. Units::Unit sc= Units::Fahrenheit);
  130. Measurement(double temperature);
  131. double temperature()const;
  132. QTime time()const;
  133. void setTemperature(double temperature);
  134. void setTime(QTime time);
  135. void setUnit(Units::Unit scale);
  136. Units::Unit scale()const;
  137. Measurement toFahrenheit();
  138. Measurement toCelsius();
  139. Measurement toKelvin();
  140. Measurement toRankine();
  141. };
  142. /*:292*//*296:*/
  143. #line 128 "./measurement.w"
  144. Q_DECLARE_METATYPE(Measurement)
  145. /*:296*//*303:*/
  146. #line 6670 "./typica.w"
  147. class Channel;
  148. class DAQImplementation;
  149. class DAQ:public QObject
  150. {
  151. Q_OBJECT
  152. Q_ENUMS(ThermocoupleType)
  153. DAQImplementation*imp;
  154. private slots:
  155. void threadFinished();
  156. public:
  157. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  158. ~DAQ();
  159. Channel*newChannel(int units,int thermocouple);
  160. Q_INVOKABLE void setClockRate(double Hz);
  161. Q_INVOKABLE void start();
  162. Q_INVOKABLE void stop();
  163. enum ThermocoupleType
  164. {
  165. TypeJ= 10072,
  166. TypeK= 10073,
  167. TypeN= 10077,
  168. TypeR= 10082,
  169. TypeS= 10085,
  170. TypeT= 10086,
  171. TypeB= 10047,
  172. TypeE= 10055
  173. };
  174. };
  175. /*:303*//*304:*/
  176. #line 6708 "./typica.w"
  177. class DAQImplementation:public QThread
  178. {
  179. Q_OBJECT
  180. public:
  181. DAQImplementation(const QString&driverinfo);
  182. ~DAQImplementation();
  183. void run();
  184. void measure();
  185. /*305:*/
  186. #line 6728 "./typica.w"
  187. typedef int(*daqfp)(...);
  188. daqfp read;
  189. daqfp errorInfo;
  190. daqfp startTask;
  191. daqfp createTask;
  192. daqfp createChannel;
  193. daqfp setClock;
  194. daqfp stopTask;
  195. daqfp clearTask;
  196. daqfp resetDevice;
  197. daqfp waitForMeasurement;
  198. /*:305*/
  199. #line 6717 "./typica.w"
  200. /*306:*/
  201. #line 6744 "./typica.w"
  202. bool useBase;
  203. QString device;
  204. QVector<Channel*> channelMap;
  205. unsigned int handle;
  206. int error;
  207. int channels;
  208. bool ready;
  209. QLibrary driver;
  210. QVector<Units::Unit> unitMap;
  211. /*:306*/
  212. #line 6718 "./typica.w"
  213. };
  214. /*:304*//*322:*/
  215. #line 7249 "./typica.w"
  216. class FakeDAQImplementation:public QThread
  217. {
  218. Q_OBJECT
  219. public:
  220. FakeDAQImplementation();
  221. ~FakeDAQImplementation();
  222. void run();
  223. void measure();
  224. QVector<Channel*> channelMap;
  225. int channels;
  226. bool ready;
  227. double clockRate;
  228. };
  229. class FakeDAQ:public QObject
  230. {
  231. Q_OBJECT
  232. FakeDAQImplementation*imp;
  233. public:
  234. FakeDAQ(QString device);
  235. ~FakeDAQ();
  236. Channel*newChannel(int units,int thermocouple);
  237. Q_INVOKABLE void setClockRate(double Hz);
  238. Q_INVOKABLE void start();
  239. };
  240. /*:322*//*329:*/
  241. #line 7436 "./typica.w"
  242. class Channel:public QObject
  243. {
  244. Q_OBJECT
  245. public:
  246. Channel();
  247. ~Channel();
  248. public slots:
  249. void input(Measurement measurement);
  250. signals:
  251. void newData(Measurement);
  252. };
  253. /*:329*//*333:*/
  254. #line 7503 "./typica.w"
  255. class LinearCalibrator:public QObject
  256. {
  257. Q_OBJECT
  258. Q_PROPERTY(double measuredLower READ measuredLower
  259. WRITE setMeasuredLower)
  260. Q_PROPERTY(double measuredUpper READ measuredUpper
  261. WRITE setMeasuredUpper)
  262. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  263. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  264. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  265. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  266. public:
  267. LinearCalibrator(QObject*parent= NULL);
  268. double measuredLower();
  269. double measuredUpper();
  270. double mappedLower();
  271. double mappedUpper();
  272. bool isClosedRange();
  273. double sensitivity();
  274. public slots:
  275. void setMeasuredLower(double lower);
  276. void setMeasuredUpper(double upper);
  277. void setMappedLower(double lower);
  278. void setMappedUpper(double upper);
  279. void setClosedRange(bool closed);
  280. void setSensitivity(double sensitivity);
  281. Measurement newMeasurement(Measurement measure);
  282. signals:
  283. void measurement(Measurement measure);
  284. void newData(Measurement measure);
  285. private:
  286. double Lo1;
  287. double Lo2;
  288. double Up1;
  289. double Up2;
  290. double sensitivitySetting;
  291. bool clamp;
  292. };
  293. /*:333*//*340:*/
  294. #line 7699 "./typica.w"
  295. class LinearSplineInterpolator:public QObject
  296. {
  297. Q_OBJECT
  298. public:
  299. LinearSplineInterpolator(QObject*parent= NULL);
  300. Q_INVOKABLE void add_pair(double source,double destination);
  301. public slots:
  302. Measurement newMeasurement(Measurement measure);
  303. signals:
  304. void newData(Measurement measure);
  305. private:
  306. void make_interpolators();
  307. QMap<double,double> *pairs;
  308. QList<LinearCalibrator*> *interpolators;
  309. };
  310. /*:340*//*345:*/
  311. #line 7835 "./typica.w"
  312. class TemperatureDisplay:public QLCDNumber
  313. {
  314. Q_OBJECT
  315. int unit;
  316. bool r;
  317. public:
  318. TemperatureDisplay(QWidget*parent= NULL);
  319. ~TemperatureDisplay();
  320. public slots:
  321. void setValue(Measurement temperature);
  322. void invalidate();
  323. void setDisplayUnits(Units::Unit scale);
  324. void setRelativeMode(bool relative);
  325. };
  326. /*:345*//*356:*/
  327. #line 8054 "./typica.w"
  328. class MeasurementTimeOffset:public QObject
  329. {
  330. Q_OBJECT
  331. QTime epoch;
  332. QTime previous;
  333. bool hasPrevious;
  334. public:
  335. MeasurementTimeOffset(QTime zero);
  336. QTime zeroTime();
  337. public slots:
  338. void newMeasurement(Measurement measure);
  339. void setZeroTime(QTime zero);
  340. signals:
  341. void measurement(Measurement measure);
  342. };
  343. /*:356*//*363:*/
  344. #line 8206 "./typica.w"
  345. class ThresholdDetector:public QObject
  346. {
  347. Q_OBJECT
  348. Q_ENUMS(EdgeDirection)
  349. public:
  350. enum EdgeDirection{
  351. Ascending,Descending
  352. };
  353. ThresholdDetector(double value);
  354. public slots:
  355. void newMeasurement(Measurement measure);
  356. void setThreshold(double value);
  357. void setEdgeDirection(EdgeDirection direction);
  358. signals:
  359. void timeForValue(double);
  360. private:
  361. double previousValue;
  362. double threshold;
  363. EdgeDirection currentDirection;
  364. };
  365. /*:363*//*368:*/
  366. #line 8312 "./typica.w"
  367. class ZeroEmitter:public QObject
  368. {
  369. Q_OBJECT
  370. Q_PROPERTY(int column READ column WRITE setColumn)
  371. Measurement cache;
  372. int col;
  373. public:
  374. ZeroEmitter(int tempcolumn= 1);
  375. int column();
  376. double lastTemperature();
  377. public slots:
  378. void newMeasurement(Measurement measure);
  379. void setColumn(int column);
  380. void emitZero();
  381. signals:
  382. void measurement(Measurement measure,int tempcolumn);
  383. };
  384. /*:368*//*373:*/
  385. #line 8406 "./typica.w"
  386. class MeasurementAdapter:public QObject
  387. {
  388. Q_OBJECT
  389. int col;
  390. public:
  391. MeasurementAdapter(int tempcolumn);
  392. int column();
  393. public slots:
  394. void newMeasurement(Measurement measure);
  395. void setColumn(int column);
  396. signals:
  397. void measurement(Measurement measure,int tempcolumn);
  398. };
  399. /*:373*//*378:*/
  400. #line 8495 "./typica.w"
  401. class GraphView:public QGraphicsView
  402. {
  403. Q_OBJECT
  404. QGraphicsScene*theScene;
  405. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  406. QMap<int,QPointF> *prevPoints;
  407. QMap<int,double> *translations;
  408. QList<QGraphicsItem*> *gridLinesF;
  409. QList<QGraphicsItem*> *gridLinesC;
  410. QList<QGraphicsItem*> *relativeGridLines;
  411. bool relativeEnabled;
  412. bool timeIndicatorEnabled;
  413. QGraphicsLineItem*timeLine;
  414. LinearSplineInterpolator*relativeAdjuster;
  415. public:
  416. GraphView(QWidget*parent= NULL);
  417. void removeSeries(int column);
  418. protected:
  419. void resizeEvent(QResizeEvent*event);
  420. public slots:
  421. void newMeasurement(Measurement measure,int tempcolumn);
  422. void setSeriesTranslation(int column,double offset);
  423. void setTimeIndicatorEnabled(bool enabled);
  424. void clear();
  425. void showF();
  426. void showC();
  427. };
  428. /*:378*//*395:*/
  429. #line 8960 "./typica.w"
  430. class MeasurementModel;
  431. class ZoomLog:public QTableView
  432. {
  433. Q_OBJECT
  434. /*396:*/
  435. #line 9009 "./typica.w"
  436. MeasurementModel*model_ms;
  437. MeasurementModel*model_1s;
  438. MeasurementModel*model_5s;
  439. MeasurementModel*model_10s;
  440. MeasurementModel*model_15s;
  441. MeasurementModel*model_30s;
  442. MeasurementModel*model_1m;
  443. QList<MeasurementModel*> modelSet;
  444. QHash<int,Measurement> lastMeasurement;
  445. MeasurementModel*currentModel;
  446. QList<int> saveTempCols;
  447. QList<int> saveControlCols;
  448. QList<int> saveNoteCols;
  449. QList<int> currentColumnSet;
  450. /*:396*/
  451. #line 8965 "./typica.w"
  452. void switchLOD(MeasurementModel*m);
  453. private slots:
  454. void centerOn(int row);
  455. void persistColumnResize(int column,int oldsize,int newsize);
  456. void restoreColumnWidths();
  457. public:
  458. ZoomLog();
  459. QVariant data(int row,int column)const;
  460. int rowCount();
  461. bool saveXML(QIODevice*device);
  462. bool saveCSV(QIODevice*device);
  463. QString lastTime(int series);
  464. Q_INVOKABLE Units::Unit displayUnits();
  465. public slots:
  466. void setVisible(bool visibility);
  467. void setHeaderData(int section,QString text);
  468. void LOD_ms();
  469. void LOD_1s();
  470. void LOD_5s();
  471. void LOD_10s();
  472. void LOD_15s();
  473. void LOD_30s();
  474. void LOD_1m();
  475. void newMeasurement(Measurement measure,int tempcolumn);
  476. void newAnnotation(QString annotation,int tempcolumn,
  477. int annotationcolumn);
  478. void clear();
  479. void addOutputTemperatureColumn(int column);
  480. void addOutputControlColumn(int column);
  481. void addOutputAnnotationColumn(int column);
  482. void clearOutputColumns();
  483. void setDisplayUnits(Units::Unit scale);
  484. void addToCurrentColumnSet(int column);
  485. void clearCurrentColumnSet();
  486. protected:
  487. virtual void showEvent(QShowEvent*event);
  488. };
  489. /*:395*//*421:*/
  490. #line 9705 "./typica.w"
  491. class MeasurementList;
  492. class MeasurementModel:public QAbstractItemModel
  493. {
  494. Q_OBJECT
  495. Units::Unit unit;
  496. QList<MeasurementList*> *entries;
  497. QStringList*hData;
  498. int colcount;
  499. QHash<int,int> *lastTemperature;
  500. QList<MeasurementList*> ::iterator lastInsertion;
  501. QHash<int,bool> *controlColumns;
  502. public:
  503. MeasurementModel(QObject*parent= NULL);
  504. ~MeasurementModel();
  505. int rowCount(const QModelIndex&parent= QModelIndex())const;
  506. int columnCount(const QModelIndex&parent= QModelIndex())const;
  507. bool setHeaderData(int section,Qt::Orientation orientation,
  508. const QVariant&value,int role= Qt::DisplayRole);
  509. QVariant data(const QModelIndex&index,int role)const;
  510. bool setData(const QModelIndex&index,const QVariant&value,
  511. int role= Qt::EditRole);
  512. Qt::ItemFlags flags(const QModelIndex&index)const;
  513. QVariant headerData(int section,Qt::Orientation orientation,
  514. int role= Qt::DisplayRole)const;
  515. QModelIndex index(int row,int column,
  516. const QModelIndex&parent= QModelIndex())const;
  517. QModelIndex parent(const QModelIndex&index)const;
  518. Units::Unit displayUnits();
  519. public slots:
  520. void newMeasurement(Measurement measure,int tempcolumn);
  521. void newAnnotation(QString annotation,int tempcolumn,
  522. int annotationColumn);
  523. void clear();
  524. void setDisplayUnits(Units::Unit scale);
  525. signals:
  526. void rowChanged(int);
  527. };
  528. /*:421*//*422:*/
  529. #line 9749 "./typica.w"
  530. class MeasurementList:public QVariantList
  531. {
  532. public:
  533. bool operator<(const MeasurementList&other)const;
  534. bool operator==(const MeasurementList&other)const;
  535. };
  536. /*:422*//*448:*/
  537. #line 10407 "./typica.w"
  538. class AnnotationButton:public QPushButton
  539. {
  540. Q_OBJECT
  541. QString note;
  542. int tc;
  543. int ac;
  544. int count;
  545. public:
  546. AnnotationButton(const QString&text,QWidget*parent= NULL);
  547. public slots:
  548. void setAnnotation(const QString&annotation);
  549. void setTemperatureColumn(int tempcolumn);
  550. void setAnnotationColumn(int annotationcolumn);
  551. void annotate();
  552. void resetCount();
  553. signals:
  554. void annotation(QString annotation,int tempcolumn,
  555. int notecolumn);
  556. };
  557. /*:448*//*456:*/
  558. #line 10532 "./typica.w"
  559. class AnnotationSpinBox:public QDoubleSpinBox
  560. {
  561. Q_OBJECT
  562. QString pretext;
  563. QString posttext;
  564. int tc;
  565. int ac;
  566. bool change;
  567. public:
  568. AnnotationSpinBox(const QString&pret,const QString&postt,
  569. QWidget*parent= NULL);
  570. public slots:
  571. void setPretext(const QString&pret);
  572. void setPosttext(const QString&postt);
  573. void setTemperatureColumn(int tempcolumn);
  574. void setAnnotationColumn(int annotationcolumn);
  575. void annotate();
  576. void resetChange();
  577. signals:
  578. void annotation(QString annotation,int tempcolumn,
  579. int notecolumn);
  580. };
  581. /*:456*//*464:*/
  582. #line 10691 "./typica.w"
  583. class TimerDisplay:public QLCDNumber
  584. {
  585. Q_OBJECT
  586. /*465:*/
  587. #line 10741 "./typica.w"
  588. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  589. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  590. Q_PROPERTY(bool running READ isRunning)
  591. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  592. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  593. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  594. Q_PROPERTY(QString value READ value)
  595. /*:465*/
  596. #line 10695 "./typica.w"
  597. private slots:
  598. void updateTime();
  599. void setCountUpMode();
  600. void setCountDownMode();
  601. void setClockMode();
  602. public:
  603. TimerDisplay(QWidget*parent= NULL);
  604. ~TimerDisplay();
  605. enum TimerMode
  606. {
  607. CountUp,
  608. CountDown,
  609. Clock
  610. };
  611. QString value();
  612. QTime seconds();
  613. TimerMode mode();
  614. bool isRunning();
  615. QTime resetValue();
  616. QString displayFormat();
  617. bool autoReset();
  618. public slots:
  619. void setTimer(QTime value= QTime(0,0,0));
  620. void setMode(TimerMode mode);
  621. void startTimer();
  622. void stopTimer();
  623. void copyTimer();
  624. void setResetValue(QTime value= QTime(0,0,0));
  625. void reset();
  626. void setDisplayFormat(QString format);
  627. void setAutoReset(bool reset);
  628. void updateDisplay();
  629. signals:
  630. void valueChanged(QTime);
  631. void runStateChanged(bool);
  632. private:
  633. /*466:*/
  634. #line 10752 "./typica.w"
  635. QTime s;
  636. QTime r;
  637. QTimer clock;
  638. TimerDisplay::TimerMode m;
  639. bool running;
  640. bool ar;
  641. QAction*startAction;
  642. QAction*stopAction;
  643. QAction*resetAction;
  644. QString f;
  645. QTime relative;
  646. QTime base;
  647. /*:466*/
  648. #line 10732 "./typica.w"
  649. };
  650. /*:464*//*487:*/
  651. #line 11144 "./typica.w"
  652. class PackLayout:public QLayout
  653. {
  654. int doLayout(const QRect&rect,bool testOnly)const;
  655. QList<QLayoutItem*> itemList;
  656. Qt::Orientations orientation;
  657. public:
  658. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  659. PackLayout(int spacing= -1);
  660. ~PackLayout();
  661. void addItem(QLayoutItem*item);
  662. Qt::Orientations expandingDirections()const;
  663. bool hasHeightForWidth()const;
  664. int heightForWidth(int width)const;
  665. int count()const;
  666. QLayoutItem*itemAt(int index)const;
  667. QSize minimumSize()const;
  668. void setGeometry(const QRect&rect);
  669. void setOrientation(Qt::Orientations direction);
  670. QSize sizeHint()const;
  671. QLayoutItem*takeAt(int index);
  672. };
  673. /*:487*//*500:*/
  674. #line 11422 "./typica.w"
  675. class SceneButton:public QGraphicsScene
  676. {
  677. Q_OBJECT
  678. public:
  679. SceneButton();
  680. ~SceneButton();
  681. protected:
  682. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  683. signals:
  684. void clicked(QPoint pos);
  685. };
  686. /*:500*//*502:*/
  687. #line 11464 "./typica.w"
  688. class WidgetDecorator:public QWidget
  689. {
  690. Q_OBJECT
  691. PackLayout*layout;
  692. QGraphicsView*label;
  693. QGraphicsTextItem*text;
  694. SceneButton*scene;
  695. public:
  696. WidgetDecorator(QWidget*widget,const QString&labeltext,
  697. Qt::Orientations orientation= Qt::Horizontal,
  698. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  699. ~WidgetDecorator();
  700. void setBackgroundBrush(QBrush background);
  701. void setTextColor(QColor color);
  702. };
  703. /*:502*//*513:*/
  704. #line 11639 "./typica.w"
  705. class LogEditWindow:public QMainWindow
  706. {
  707. Q_OBJECT
  708. QWidget*centralWidget;
  709. PackLayout*mainLayout;
  710. QHBoxLayout*addRowsLayout;
  711. QLabel*startTimeLabel;
  712. QTimeEdit*startTime;
  713. QLabel*endTimeLabel;
  714. QTimeEdit*endTime;
  715. QLabel*intervalLabel;
  716. QSpinBox*interval;
  717. QPushButton*addRows;
  718. QAction*saveXml;
  719. QAction*saveCsv;
  720. QAction*openXml;
  721. MeasurementModel*model;
  722. QTableView*log;
  723. private slots:
  724. void addTheRows();
  725. void saveXML();
  726. void saveCSV();
  727. void openXML();
  728. protected:
  729. void closeEvent(QCloseEvent*event);
  730. public:
  731. LogEditWindow();
  732. };
  733. /*:513*//*527:*/
  734. #line 11947 "./typica.w"
  735. class XMLOutput:public QObject
  736. {
  737. Q_OBJECT
  738. MeasurementModel*data;
  739. QIODevice*out;
  740. int time;
  741. QMap<int,QString> temperatureColumns;
  742. QMap<int,QString> controlColumns;
  743. QMap<int,QString> annotationColumns;
  744. public:
  745. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  746. void addTemperatureColumn(const QString&series,int column);
  747. void addControlColumn(const QString&series,int column);
  748. void addAnnotationColumn(const QString&series,int column);
  749. void setModel(MeasurementModel*model);
  750. void setTimeColumn(int column);
  751. void setDevice(QIODevice*device);
  752. bool output();
  753. };
  754. /*:527*//*534:*/
  755. #line 12183 "./typica.w"
  756. class XMLInput:public QObject
  757. {
  758. Q_OBJECT
  759. int firstc;
  760. QIODevice*in;
  761. public:
  762. XMLInput(QIODevice*input,int c);
  763. void setFirstColumn(int column);
  764. void setDevice(QIODevice*device);
  765. bool input();
  766. signals:
  767. void measure(Measurement,int);
  768. void annotation(QString,int,int);
  769. void newTemperatureColumn(int,QString);
  770. void newAnnotationColumn(int,QString);
  771. void lastColumn(int);
  772. };
  773. /*:534*//*545:*/
  774. #line 12437 "./typica.w"
  775. class CSVOutput
  776. {
  777. MeasurementModel*data;
  778. QIODevice*out;
  779. int time;
  780. QMap<int,QString> temperatureColumns;
  781. QMap<int,QString> controlColumns;
  782. QMap<int,QString> annotationColumns;
  783. public:
  784. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  785. void addTemperatureColumn(const QString&series,int column);
  786. void addControlColumn(const QString&series,int column);
  787. void addAnnotationColumn(const QString&series,int column);
  788. void setModel(MeasurementModel*model);
  789. void setTimeColumn(int column);
  790. void setDevice(QIODevice*device);
  791. bool output();
  792. };
  793. /*:545*//*575:*/
  794. #line 12580 "./typica.w"
  795. #define AppInstance (qobject_cast<Application *> (qApp))
  796. class NodeInserter;
  797. class DeviceTreeModel;
  798. class Application:public QApplication
  799. {
  800. Q_OBJECT
  801. public:
  802. Application(int&argc,char**argv);
  803. QDomDocument*configuration();
  804. /*717:*/
  805. #line 15144 "./typica.w"
  806. QDomDocument deviceConfiguration();
  807. /*:717*//*750:*/
  808. #line 15817 "./typica.w"
  809. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  810. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  811. const QModelIndex&index);
  812. /*:750*//*755:*/
  813. #line 15921 "./typica.w"
  814. QList<NodeInserter*> topLevelNodeInserters;
  815. /*:755*/
  816. #line 12591 "./typica.w"
  817. QSqlDatabase database();
  818. QScriptEngine*engine;
  819. public slots:
  820. /*718:*/
  821. #line 15151 "./typica.w"
  822. void saveDeviceConfiguration();
  823. /*:718*/
  824. #line 12595 "./typica.w"
  825. private:
  826. /*716:*/
  827. #line 15135 "./typica.w"
  828. QDomDocument deviceConfigurationDocument;
  829. /*:716*//*749:*/
  830. #line 15811 "./typica.w"
  831. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  832. /*:749*/
  833. #line 12597 "./typica.w"
  834. QDomDocument conf;
  835. };
  836. /*:575*//*583:*/
  837. #line 12722 "./typica.w"
  838. class SaltModel:public QAbstractItemModel
  839. {
  840. Q_OBJECT
  841. QList<QList<QMap<int,QVariant> > > modelData;
  842. QStringList hData;
  843. int colcount;
  844. public:
  845. SaltModel(int columns);
  846. ~SaltModel();
  847. int rowCount(const QModelIndex&parent= QModelIndex())const;
  848. int columnCount(const QModelIndex&parent= QModelIndex())const;
  849. bool setHeaderData(int section,Qt::Orientation orientation,
  850. const QVariant&value,int role= Qt::DisplayRole);
  851. QVariant data(const QModelIndex&index,int role)const;
  852. bool setData(const QModelIndex&index,const QVariant&value,
  853. int role= Qt::EditRole);
  854. Qt::ItemFlags flags(const QModelIndex&index)const;
  855. QVariant headerData(int section,Qt::Orientation orientation,
  856. int role= Qt::DisplayRole)const;
  857. QModelIndex index(int row,int column,
  858. const QModelIndex&parent= QModelIndex())const;
  859. QModelIndex parent(const QModelIndex&index)const;
  860. QString arrayLiteral(int column,int role)const;
  861. QString quotedArrayLiteral(int column,int role)const;
  862. void clear();
  863. bool removeRows(int row,int count,
  864. const QModelIndex&parent= QModelIndex());
  865. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  866. };
  867. /*:583*//*599:*/
  868. #line 13107 "./typica.w"
  869. class SqlComboBox:public QComboBox
  870. {
  871. Q_OBJECT
  872. int dataColumn;
  873. int displayColumn;
  874. bool dataColumnShown;
  875. QString specialNullText;
  876. QVariant specialNullData;
  877. public:
  878. SqlComboBox();
  879. ~SqlComboBox();
  880. SqlComboBox*clone(QWidget*parent);
  881. public slots:
  882. void addNullOption();
  883. void addSqlOptions(QString query);
  884. void setDataColumn(int column);
  885. void setDisplayColumn(int column);
  886. void showData(bool show);
  887. void setNullText(QString nullText);
  888. void setNullData(QVariant nullData);
  889. };
  890. /*:599*//*606:*/
  891. #line 13254 "./typica.w"
  892. class SqlComboBoxDelegate:public QItemDelegate
  893. {
  894. Q_OBJECT
  895. SqlComboBox*delegate;
  896. public:
  897. SqlComboBoxDelegate(QObject*parent= NULL);
  898. QWidget*createEditor(QWidget*parent,
  899. const QStyleOptionViewItem&option,
  900. const QModelIndex&index)const;
  901. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  902. void setModelData(QWidget*editor,QAbstractItemModel*model,
  903. const QModelIndex&index)const;
  904. void setWidget(SqlComboBox*widget);
  905. virtual QSize sizeHint()const;
  906. void updateEditorGeometry(QWidget*editor,
  907. const QStyleOptionViewItem&option,
  908. const QModelIndex&index)const;
  909. };
  910. /*:606*//*621:*/
  911. #line 13465 "./typica.w"
  912. class SqlConnectionSetup:public QDialog
  913. {
  914. Q_OBJECT
  915. public:
  916. SqlConnectionSetup();
  917. ~SqlConnectionSetup();
  918. public slots:
  919. void testConnection();
  920. private:
  921. QFormLayout*formLayout;
  922. QComboBox*driver;
  923. QLineEdit*hostname;
  924. QLineEdit*portnumber;
  925. QLineEdit*dbname;
  926. QLineEdit*user;
  927. QLineEdit*password;
  928. QVBoxLayout*layout;
  929. QHBoxLayout*buttons;
  930. QPushButton*cancelButton;
  931. QPushButton*connectButton;
  932. };
  933. /*:621*//*626:*/
  934. #line 13608 "./typica.w"
  935. class SqlQueryView:public QTableView
  936. {
  937. Q_OBJECT
  938. public:
  939. SqlQueryView(QWidget*parent= NULL);
  940. void setQuery(const QString&query);
  941. bool setHeaderData(int section,Qt::Orientation orientation,
  942. const QVariant&value,int role);
  943. Q_INVOKABLE QVariant data(int row,int column,
  944. int role= Qt::DisplayRole);
  945. signals:
  946. void openEntry(QString key);
  947. void openEntryRow(int row);
  948. protected:
  949. virtual void showEvent(QShowEvent*event);
  950. private slots:
  951. void openRow(const QModelIndex&index);
  952. void persistColumnResize(int column,int oldsize,int newsize);
  953. };
  954. /*:626*//*641:*/
  955. #line 13863 "./typica.w"
  956. class ReportAction:public QAction
  957. {
  958. Q_OBJECT
  959. public:
  960. ReportAction(const QString&fileName,const QString&reportName,
  961. QObject*parent= NULL);
  962. private slots:
  963. void createReport();
  964. private:
  965. QString reportFile;
  966. };
  967. /*:641*//*653:*/
  968. #line 14074 "./typica.w"
  969. class ReportTable:public QObject
  970. {
  971. Q_OBJECT
  972. QTextFrame*area;
  973. QDomElement configuration;
  974. QMap<QString,QVariant> bindings;
  975. public:
  976. ReportTable(QTextFrame*frame,QDomElement description);
  977. ~ReportTable();
  978. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  979. public slots:
  980. void refresh();
  981. };
  982. /*:653*//*686:*/
  983. #line 14313 "./typica.w"
  984. class FormArray:public QScrollArea
  985. {
  986. Q_OBJECT
  987. QDomElement configuration;
  988. QWidget itemContainer;
  989. QVBoxLayout itemLayout;
  990. int maxwidth;
  991. int maxheight;
  992. public:
  993. FormArray(QDomElement description);
  994. Q_INVOKABLE QWidget*elementAt(int index);
  995. Q_INVOKABLE int elements();
  996. public slots:
  997. void addElements(int copies= 1);
  998. void removeAllElements();
  999. void setMaximumElementWidth(int width);
  1000. void setMaximumElementHeight(int height);
  1001. };
  1002. /*:686*//*696:*/
  1003. #line 14529 "./typica.w"
  1004. class ScaleControl:public QGraphicsView
  1005. {
  1006. Q_OBJECT
  1007. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1008. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1009. /*697:*/
  1010. #line 14555 "./typica.w"
  1011. QGraphicsScene scene;
  1012. QGraphicsPolygonItem initialDecrement;
  1013. QGraphicsPolygonItem initialIncrement;
  1014. QGraphicsPolygonItem finalDecrement;
  1015. QGraphicsPolygonItem finalIncrement;
  1016. QGraphicsPolygonItem initialIndicator;
  1017. QGraphicsPolygonItem finalIndicator;
  1018. QGraphicsPathItem scaleLine;
  1019. QPolygonF left;
  1020. QPolygonF right;
  1021. QPolygonF down;
  1022. QPolygonF up;
  1023. QPainterPath scalePath;
  1024. QBrush initialBrush;
  1025. QBrush finalBrush;
  1026. double nonScoredValue;
  1027. double scoredValue;
  1028. bool initialSet;
  1029. bool finalSet;
  1030. bool scaleDown;
  1031. /*:697*/
  1032. #line 14535 "./typica.w"
  1033. public:
  1034. ScaleControl();
  1035. double initialValue(void);
  1036. double finalValue(void);
  1037. virtual QSize sizeHint()const;
  1038. public slots:
  1039. void setInitialValue(double value);
  1040. void setFinalValue(double value);
  1041. signals:
  1042. void initialChanged(double);
  1043. void finalChanged(double);
  1044. protected:
  1045. virtual void mousePressEvent(QMouseEvent*event);
  1046. virtual void mouseReleaseEvent(QMouseEvent*event);
  1047. };
  1048. /*:696*//*708:*/
  1049. #line 14852 "./typica.w"
  1050. class IntensityControl:public QGraphicsView
  1051. {
  1052. Q_OBJECT
  1053. Q_PROPERTY(double value READ value WRITE setValue)
  1054. QGraphicsScene scene;
  1055. QGraphicsPolygonItem decrement;
  1056. QGraphicsPolygonItem increment;
  1057. QGraphicsPolygonItem indicator;
  1058. QGraphicsPathItem scaleLine;
  1059. QPolygonF left;
  1060. QPolygonF up;
  1061. QPolygonF down;
  1062. QPainterPath scalePath;
  1063. QBrush theBrush;
  1064. double theValue;
  1065. bool valueSet;
  1066. bool scaleDown;
  1067. public:
  1068. IntensityControl();
  1069. double value();
  1070. virtual QSize sizeHint()const;
  1071. public slots:
  1072. void setValue(double val);
  1073. signals:
  1074. void valueChanged(double);
  1075. protected:
  1076. virtual void mousePressEvent(QMouseEvent*event);
  1077. virtual void mouseReleaseEvent(QMouseEvent*event);
  1078. };
  1079. /*:708*//*724:*/
  1080. #line 15240 "./typica.w"
  1081. class DeviceTreeModelNode
  1082. {
  1083. public:
  1084. DeviceTreeModelNode(QDomNode&node,int row,
  1085. DeviceTreeModelNode*parent= NULL);
  1086. ~DeviceTreeModelNode();
  1087. DeviceTreeModelNode*child(int index);
  1088. DeviceTreeModelNode*parent();
  1089. QDomNode node()const;
  1090. int row();
  1091. private:
  1092. QDomNode domNode;
  1093. QHash<int,DeviceTreeModelNode*> children;
  1094. int rowNumber;
  1095. DeviceTreeModelNode*parentItem;
  1096. };
  1097. /*:724*//*726:*/
  1098. #line 15315 "./typica.w"
  1099. class DeviceTreeModel:public QAbstractItemModel
  1100. {
  1101. Q_OBJECT
  1102. public:
  1103. DeviceTreeModel(QObject*parent= NULL);
  1104. ~DeviceTreeModel();
  1105. QVariant data(const QModelIndex&index,int role)const;
  1106. Qt::ItemFlags flags(const QModelIndex&index)const;
  1107. QVariant headerData(int section,Qt::Orientation orientation,
  1108. int role= Qt::DisplayRole)const;
  1109. QModelIndex index(int row,int column,
  1110. const QModelIndex&parent= QModelIndex())const;
  1111. QModelIndex parent(const QModelIndex&child)const;
  1112. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1113. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1114. bool setData(const QModelIndex&index,const QVariant&value,
  1115. int role);
  1116. bool removeRows(int row,int count,const QModelIndex&parent);
  1117. QDomElement referenceElement(const QString&id);
  1118. public slots:
  1119. void newNode(const QString&name,const QString&driver,
  1120. const QModelIndex&parent);
  1121. private:
  1122. QDomDocument document;
  1123. DeviceTreeModelNode*root;
  1124. QDomNode referenceSection;
  1125. QDomNode treeRoot;
  1126. };
  1127. /*:726*//*745:*/
  1128. #line 15769 "./typica.w"
  1129. Q_DECLARE_METATYPE(QModelIndex)
  1130. /*:745*//*753:*/
  1131. #line 15876 "./typica.w"
  1132. class NodeInserter:public QAction
  1133. {
  1134. Q_OBJECT
  1135. public:
  1136. NodeInserter(const QString&title,const QString&name,
  1137. const QString&driver,QObject*parent= NULL);
  1138. signals:
  1139. void triggered(QString name,QString driver);
  1140. private slots:
  1141. void onTriggered();
  1142. private:
  1143. QString defaultNodeName;
  1144. QString driverString;
  1145. };
  1146. /*:753*//*756:*/
  1147. #line 15931 "./typica.w"
  1148. class DeviceConfigurationWindow:public QWidget
  1149. {
  1150. Q_OBJECT
  1151. public:
  1152. DeviceConfigurationWindow();
  1153. public slots:
  1154. void addDevice();
  1155. void removeNode();
  1156. void newSelection(const QModelIndex&index);
  1157. private slots:
  1158. void resizeColumn();
  1159. private:
  1160. QDomDocument document;
  1161. DeviceTreeModel*model;
  1162. QTreeView*view;
  1163. QScrollArea*configArea;
  1164. };
  1165. /*:756*//*765:*/
  1166. #line 16101 "./typica.w"
  1167. class BasicDeviceConfigurationWidget:public QWidget
  1168. {
  1169. Q_OBJECT
  1170. public:
  1171. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1172. const QModelIndex&index);
  1173. public slots:
  1174. void insertChildNode(const QString&name,const QString&driver);
  1175. void updateAttribute(const QString&name,const QString&value);
  1176. protected:
  1177. DeviceTreeModel*deviceModel;
  1178. QModelIndex currentNode;
  1179. };
  1180. /*:765*//*769:*/
  1181. #line 16186 "./typica.w"
  1182. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1183. {
  1184. Q_OBJECT
  1185. public:
  1186. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1187. const QModelIndex&index);
  1188. private slots:
  1189. void updateRoasterId(int id);
  1190. void updateCapacityCheck(int value);
  1191. void updateCapacity(const QString&value);
  1192. void updateCapacityUnit(const QString&value);
  1193. };
  1194. /*:769*//*774:*/
  1195. #line 16391 "./typica.w"
  1196. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1197. {
  1198. Q_OBJECT
  1199. public:
  1200. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1201. const QModelIndex&index);
  1202. };
  1203. /*:774*//*776:*/
  1204. #line 16437 "./typica.w"
  1205. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1206. {
  1207. Q_OBJECT
  1208. public:
  1209. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1210. const QModelIndex&index);
  1211. private slots:
  1212. void addChannel();
  1213. void updateDeviceId(const QString&newId);
  1214. };
  1215. /*:776*//*780:*/
  1216. #line 16523 "./typica.w"
  1217. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1218. {
  1219. Q_OBJECT
  1220. public:
  1221. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1222. const QModelIndex&index);
  1223. private slots:
  1224. void updateThermocoupleType(const QString&type);
  1225. void updateColumnName(const QString&name);
  1226. void updateHidden(bool hidden);
  1227. };
  1228. /*:780*//*785:*/
  1229. #line 16639 "./typica.w"
  1230. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1231. {
  1232. Q_OBJECT
  1233. public:
  1234. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1235. const QModelIndex&index);
  1236. };
  1237. /*:785*//*787:*/
  1238. #line 16680 "./typica.w"
  1239. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1240. {
  1241. Q_OBJECT
  1242. public:
  1243. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1244. const QModelIndex&index);
  1245. private slots:
  1246. void addChannel();
  1247. void updateDeviceId(const QString&newId);
  1248. };
  1249. /*:787*//*789:*/
  1250. #line 16749 "./typica.w"
  1251. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1252. {
  1253. Q_OBJECT
  1254. public:
  1255. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1256. const QModelIndex&index);
  1257. private slots:
  1258. void updateDeviceId(const QString&newId);
  1259. void updateThermocoupleType(const QString&type);
  1260. void updateColumnName(const QString&name);
  1261. void updateHidden(bool hidden);
  1262. };
  1263. /*:789*//*794:*/
  1264. #line 16880 "./typica.w"
  1265. class PortSelector:public QComboBox
  1266. {
  1267. Q_OBJECT
  1268. public:
  1269. PortSelector(QWidget*parent= NULL);
  1270. private slots:
  1271. void addDevice(QextPortInfo port);
  1272. private:
  1273. QextSerialEnumerator*lister;
  1274. };
  1275. /*:794*//*796:*/
  1276. #line 16928 "./typica.w"
  1277. class BaudSelector:public QComboBox
  1278. {
  1279. Q_OBJECT
  1280. Q_ENUMS(BaudRateType)
  1281. public:
  1282. BaudSelector(QWidget*parent= NULL);
  1283. enum BaudRateType
  1284. {
  1285. #if defined(Q_OS_UNIX) || defined(qdoc)
  1286. BAUD50= 50,
  1287. BAUD75= 75,
  1288. BAUD134= 134,
  1289. BAUD150= 150,
  1290. BAUD200= 200,
  1291. BAUD1800= 1800,
  1292. #if defined(B76800) || defined(qdoc)
  1293. BAUD76800= 76800,
  1294. #endif
  1295. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1296. BAUD230400= 230400,
  1297. BAUD460800= 460800,
  1298. BAUD500000= 500000,
  1299. BAUD576000= 576000,
  1300. BAUD921600= 921600,
  1301. BAUD1000000= 1000000,
  1302. BAUD1152000= 1152000,
  1303. BAUD1500000= 1500000,
  1304. BAUD2000000= 2000000,
  1305. BAUD2500000= 2500000,
  1306. BAUD3000000= 3000000,
  1307. BAUD3500000= 3500000,
  1308. BAUD4000000= 4000000,
  1309. #endif
  1310. #endif
  1311. #if defined(Q_OS_WIN) || defined(qdoc)
  1312. BAUD14400= 14400,
  1313. BAUD56000= 56000,
  1314. BAUD128000= 128000,
  1315. BAUD256000= 256000,
  1316. #endif
  1317. BAUD110= 110,
  1318. BAUD300= 300,
  1319. BAUD600= 600,
  1320. BAUD1200= 1200,
  1321. BAUD2400= 2400,
  1322. BAUD4800= 4800,
  1323. BAUD9600= 9600,
  1324. BAUD19200= 19200,
  1325. BAUD38400= 38400,
  1326. BAUD57600= 57600,
  1327. BAUD115200= 115200
  1328. };
  1329. };
  1330. /*:796*//*798:*/
  1331. #line 16999 "./typica.w"
  1332. class ParitySelector:public QComboBox
  1333. {
  1334. Q_OBJECT
  1335. Q_ENUMS(ParityType)
  1336. public:
  1337. ParitySelector(QWidget*parent= NULL);
  1338. enum ParityType
  1339. {
  1340. PAR_NONE,
  1341. PAR_ODD,
  1342. PAR_EVEN,
  1343. #if defined(Q_OS_WIN) || defined(qdoc)
  1344. PAR_MARK,
  1345. #endif
  1346. PAR_SPACE
  1347. };
  1348. };
  1349. /*:798*//*800:*/
  1350. #line 17037 "./typica.w"
  1351. class FlowSelector:public QComboBox
  1352. {
  1353. Q_OBJECT
  1354. Q_ENUMS(FlowType)
  1355. public:
  1356. FlowSelector(QWidget*parent= NULL);
  1357. enum FlowType
  1358. {
  1359. FLOW_OFF,
  1360. FLOW_HARDWARE,
  1361. FLOW_XONXOFF
  1362. };
  1363. };
  1364. /*:800*//*802:*/
  1365. #line 17070 "./typica.w"
  1366. class StopSelector:public QComboBox
  1367. {
  1368. Q_OBJECT
  1369. Q_ENUMS(StopBitsType)
  1370. public:
  1371. StopSelector(QWidget*parent= NULL);
  1372. enum StopBitsType
  1373. {
  1374. STOP_1,
  1375. #if defined(Q_OS_WIN) || defined(qdoc)
  1376. STOP_1_5,
  1377. #endif
  1378. STOP_2
  1379. };
  1380. };
  1381. /*:802*//*805:*/
  1382. #line 17127 "./typica.w"
  1383. class ShortHexSpinBox:public QSpinBox
  1384. {
  1385. Q_OBJECT
  1386. public:
  1387. ShortHexSpinBox(QWidget*parent= NULL);
  1388. virtual QValidator::State validate(QString&input,int&pos)const;
  1389. protected:
  1390. virtual int valueFromText(const QString&text)const;
  1391. virtual QString textFromValue(int value)const;
  1392. };
  1393. /*:805*//*807:*/
  1394. #line 17189 "./typica.w"
  1395. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1396. {
  1397. Q_OBJECT
  1398. public:
  1399. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1400. const QModelIndex&index);
  1401. private slots:
  1402. void updatePort(const QString&newPort);
  1403. void updateBaudRate(const QString&newRate);
  1404. void updateParity(const QString&newParity);
  1405. void updateFlowControl(const QString&newFlow);
  1406. void updateStopBits(const QString&newStopBits);
  1407. };
  1408. /*:807*//*809:*/
  1409. #line 17340 "./typica.w"
  1410. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1411. {
  1412. Q_OBJECT
  1413. public:
  1414. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1415. const QModelIndex&index);
  1416. private slots:
  1417. void updateStationNumber(int newStation);
  1418. void updateFixedUnit(bool newFixed);
  1419. void updateFixedDecimal(bool newFixed);
  1420. void updateUnit(const QString&newUnit);
  1421. void updateUnitAddress(int newAddress);
  1422. void updateValueF(int newValue);
  1423. void updateValueC(int newValue);
  1424. void updatePrecisionAddress(int newAddress);
  1425. void updatePrecisionValue(int newValue);
  1426. private:
  1427. QStackedLayout*unitSpecificationLayout;
  1428. QStackedLayout*decimalSpecificationLayout;
  1429. };
  1430. /*:809*//*811:*/
  1431. #line 17599 "./typica.w"
  1432. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1433. {
  1434. Q_OBJECT
  1435. public:
  1436. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1437. const QModelIndex&index);
  1438. private slots:
  1439. void updateAddress(int newAddress);
  1440. };
  1441. /*:811*//*813:*/
  1442. #line 17645 "./typica.w"
  1443. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1444. {
  1445. Q_OBJECT
  1446. public:
  1447. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1448. const QModelIndex&index);
  1449. private slots:
  1450. void updateReadAddress(int newAddress);
  1451. void updateWriteAddress(int newAddress);
  1452. void updateFixedRange(bool fixed);
  1453. void updateLower(const QString&lower);
  1454. void updateUpper(const QString&upper);
  1455. void updateLowerAddress(int newAddress);
  1456. void updateUpperAddress(int newAddress);
  1457. private:
  1458. QStackedLayout*boundsLayout;
  1459. };
  1460. /*:813*//*817:*/
  1461. #line 17839 "./typica.w"
  1462. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1463. {
  1464. Q_OBJECT
  1465. public:
  1466. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1467. private slots:
  1468. void updateButtonText(const QString&text);
  1469. void updateAnnotationText(const QString&text);
  1470. };
  1471. /*:817*//*821:*/
  1472. #line 17907 "./typica.w"
  1473. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1474. {
  1475. Q_OBJECT
  1476. public:
  1477. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1478. private slots:
  1479. void updateButtonText(const QString&text);
  1480. void updateAnnotationText(const QString&text);
  1481. };
  1482. /*:821*//*824:*/
  1483. #line 17981 "./typica.w"
  1484. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1485. {
  1486. Q_OBJECT
  1487. public:
  1488. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1489. private slots:
  1490. void updateLabel(const QString&text);
  1491. void updateMinimum(const QString&minimum);
  1492. void updateMaximum(const QString&maximum);
  1493. void updatePrecision(int precision);
  1494. void updatePretext(const QString&text);
  1495. void updatePosttext(const QString&text);
  1496. };
  1497. /*:824*//*827:*/
  1498. #line 12 "./freeannotation.w"
  1499. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1500. {
  1501. Q_OBJECT
  1502. public:
  1503. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1504. private slots:
  1505. void updateLabel(const QString&text);
  1506. };
  1507. /*:827*//*831:*/
  1508. #line 11 "./settings.w"
  1509. class SettingsWindow:public QMainWindow
  1510. {
  1511. Q_OBJECT
  1512. public:
  1513. SettingsWindow();
  1514. };
  1515. /*:831*//*836:*/
  1516. #line 8 "./graphsettings.w"
  1517. class GraphSettingsWidget:public QWidget
  1518. {
  1519. Q_OBJECT
  1520. public:
  1521. GraphSettingsWidget();
  1522. };
  1523. /*:836*//*838:*/
  1524. #line 46 "./graphsettings.w"
  1525. class GraphSettingsRelativeTab:public QWidget
  1526. {
  1527. Q_OBJECT
  1528. public:
  1529. GraphSettingsRelativeTab();
  1530. public slots:
  1531. void updateEnableSetting(bool enable);
  1532. void updateColorSetting(const QString&color);
  1533. void updateAxisSetting(const QString&gridList);
  1534. void updateUnit(int unit);
  1535. void showColorPicker();
  1536. private:
  1537. QLineEdit*colorEdit;
  1538. };
  1539. /*:838*//*842:*/
  1540. #line 7 "./advancedsettings.w"
  1541. class AdvancedSettingsWidget:public QWidget
  1542. {
  1543. Q_OBJECT
  1544. public:
  1545. AdvancedSettingsWidget();
  1546. public slots:
  1547. void enableDiagnosticLogging(bool enabled);
  1548. };
  1549. /*:842*//*846:*/
  1550. #line 18106 "./typica.w"
  1551. class ModbusRTUDevice:public QObject
  1552. {
  1553. Q_OBJECT
  1554. public:
  1555. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1556. ~ModbusRTUDevice();
  1557. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1558. Q_INVOKABLE double SVLower();
  1559. Q_INVOKABLE double SVUpper();
  1560. Q_INVOKABLE int decimals();
  1561. QList<Channel*> channels;
  1562. public slots:
  1563. void outputSV(double sv);
  1564. signals:
  1565. void SVLowerChanged(double);
  1566. void SVUpperChanged(double);
  1567. void SVDecimalChanged(int);
  1568. void queueEmpty();
  1569. private slots:
  1570. void dataAvailable();
  1571. void sendNextMessage();
  1572. void decimalResponse(QByteArray response);
  1573. void unitResponse(QByteArray response);
  1574. void svlResponse(QByteArray response);
  1575. void svuResponse(QByteArray response);
  1576. void requestMeasurement();
  1577. void mResponse(QByteArray response);
  1578. void ignore(QByteArray response);
  1579. void timeout();
  1580. private:
  1581. QextSerialPort*port;
  1582. QByteArray responseBuffer;
  1583. QList<QByteArray> messageQueue;
  1584. QList<QObject*> retObjQueue;
  1585. QList<char*> callbackQueue;
  1586. quint16 calculateCRC(QByteArray data);
  1587. QTimer*messageDelayTimer;
  1588. QTimer*commTimeout;
  1589. int delayTime;
  1590. char station;
  1591. int decimalPosition;
  1592. int valueF;
  1593. int valueC;
  1594. bool unitIsF;
  1595. double outputSVLower;
  1596. double outputSVUpper;
  1597. QByteArray outputSVStub;
  1598. QByteArray pvStub;
  1599. QByteArray svStub;
  1600. QByteArray mStub;
  1601. quint16 pvaddress;
  1602. quint16 svaddress;
  1603. bool svenabled;
  1604. bool readingsv;
  1605. double savedpv;
  1606. bool waiting;
  1607. };
  1608. /*:846*//*862:*/
  1609. #line 18808 "./typica.w"
  1610. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1611. {
  1612. Q_OBJECT
  1613. public:
  1614. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1615. private slots:
  1616. void updatePort(const QString&newPort);
  1617. void updateBaudRate(const QString&newRate);
  1618. void updateParity(const QString&newParity);
  1619. void updateFlowControl(const QString&newFlow);
  1620. void updateStopBits(const QString&newStopBits);
  1621. void updateStation(int station);
  1622. void updateFixedDecimal(bool fixed);
  1623. void updateDecimalAddress(int address);
  1624. void updateDecimalPosition(int position);
  1625. void updateFixedUnit(bool fixed);
  1626. void updateUnitAddress(int address);
  1627. void updateValueForF(int value);
  1628. void updateValueForC(int value);
  1629. void updateUnit(const QString&newUnit);
  1630. void updatePVAddress(int address);
  1631. void updateSVEnabled(bool enabled);
  1632. void updateSVReadAddress(int address);
  1633. void updateDeviceLimit(bool query);
  1634. void updateSVLowerAddress(int address);
  1635. void updateSVUpperAddress(int address);
  1636. void updateSVLower(double value);
  1637. void updateSVUpper(double value);
  1638. void updateSVWritable(bool canWriteSV);
  1639. void updateSVWriteAddress(int address);
  1640. void updatePVColumnName(const QString&name);
  1641. void updateSVColumnName(const QString&name);
  1642. void updatePVHidden(bool hidden);
  1643. void updateSVHidden(bool hidden);
  1644. private:
  1645. PortSelector*port;
  1646. BaudSelector*baud;
  1647. ParitySelector*parity;
  1648. FlowSelector*flow;
  1649. StopSelector*stop;
  1650. QSpinBox*station;
  1651. QCheckBox*decimalQuery;
  1652. ShortHexSpinBox*decimalAddress;
  1653. QSpinBox*decimalPosition;
  1654. QCheckBox*unitQuery;
  1655. ShortHexSpinBox*unitAddress;
  1656. QSpinBox*valueF;
  1657. QSpinBox*valueC;
  1658. QComboBox*fixedUnit;
  1659. ShortHexSpinBox*pVAddress;
  1660. QCheckBox*sVEnabled;
  1661. ShortHexSpinBox*sVReadAddress;
  1662. QCheckBox*deviceLimit;
  1663. ShortHexSpinBox*sVLowerAddr;
  1664. ShortHexSpinBox*sVUpperAddr;
  1665. QDoubleSpinBox*sVLower;
  1666. QDoubleSpinBox*sVUpper;
  1667. QCheckBox*sVWritable;
  1668. ShortHexSpinBox*sVOutputAddr;
  1669. QLineEdit*pVColumnName;
  1670. QLineEdit*sVColumnName;
  1671. };
  1672. /*:862*//*866:*/
  1673. #line 22 "./modbus.w"
  1674. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1675. {
  1676. Q_OBJECT
  1677. public:
  1678. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1679. private slots:
  1680. void updatePort(const QString&value);
  1681. void updateBaudRate(const QString&value);
  1682. void updateParity(int value);
  1683. void updateFlowControl(int value);
  1684. void updateStopBits(int value);
  1685. void addInput();
  1686. private:
  1687. ParitySelector*m_parity;
  1688. FlowSelector*m_flow;
  1689. StopSelector*m_stop;
  1690. };
  1691. /*:866*//*868:*/
  1692. #line 144 "./modbus.w"
  1693. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1694. {
  1695. Q_OBJECT
  1696. public:
  1697. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1698. private slots:
  1699. void updateStation(int value);
  1700. void updateAddress(int value);
  1701. void updateFunction(int value);
  1702. void updateFormat(int value);
  1703. void updateDecimals(int value);
  1704. void updateUnit(int value);
  1705. void updateColumnName(const QString&value);
  1706. void updateHidden(bool value);
  1707. };
  1708. /*:868*//*872:*/
  1709. #line 338 "./modbus.w"
  1710. enum ModbusDataFormat
  1711. {
  1712. Int16,
  1713. FloatHL,
  1714. FloatLH
  1715. };
  1716. struct ModbusScanItem
  1717. {
  1718. QByteArray request;
  1719. ModbusDataFormat format;
  1720. int decimalPosition;
  1721. Units::Unit unit;
  1722. mutable double lastValue;
  1723. };
  1724. /*:872*//*873:*/
  1725. #line 358 "./modbus.w"
  1726. class ModbusNG:public QObject
  1727. {
  1728. Q_OBJECT
  1729. public:
  1730. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1731. ~ModbusNG();
  1732. Q_INVOKABLE int channelCount();
  1733. Channel*getChannel(int);
  1734. Q_INVOKABLE QString channelColumnName(int);
  1735. Q_INVOKABLE QString channelIndicatorText(int);
  1736. Q_INVOKABLE bool isChannelHidden(int);
  1737. private slots:
  1738. void sendNextMessage();
  1739. void timeout();
  1740. void dataAvailable();
  1741. private:
  1742. quint16 calculateCRC(QByteArray data);
  1743. QextSerialPort*port;
  1744. int delayTime;
  1745. QTimer*messageDelayTimer;
  1746. QTimer*commTimeout;
  1747. int scanPosition;
  1748. QByteArray responseBuffer;
  1749. QList<Channel*> channels;
  1750. QList<ModbusScanItem> scanList;
  1751. QList<QString> channelNames;
  1752. QList<QString> channelLabels;
  1753. QList<bool> hiddenStates;
  1754. };
  1755. /*:873*//*878:*/
  1756. #line 36 "./unsupportedserial.w"
  1757. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1758. {
  1759. Q_OBJECT
  1760. public:
  1761. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1762. const QModelIndex&index);
  1763. private slots:
  1764. void updateConfiguration();
  1765. void saveScript();
  1766. void addChannel();
  1767. private:
  1768. SaltModel*deviceSettingsModel;
  1769. QTextEdit*scriptEditor;
  1770. };
  1771. /*:878*//*883:*/
  1772. #line 166 "./unsupportedserial.w"
  1773. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1774. {
  1775. Q_OBJECT
  1776. public:
  1777. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1778. const QModelIndex&index);
  1779. private slots:
  1780. void updateColumnName(const QString&value);
  1781. void updateHidden(bool hidden);
  1782. void updateConfiguration();
  1783. private:
  1784. SaltModel*channelSettingsModel;
  1785. };
  1786. /*:883*//*888:*/
  1787. #line 298 "./unsupportedserial.w"
  1788. class JavaScriptDevice:public QObject
  1789. {
  1790. Q_OBJECT
  1791. public:
  1792. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1793. QScriptEngine*engine);
  1794. Q_INVOKABLE int channelCount();
  1795. Channel*getChannel(int channel);
  1796. Q_INVOKABLE bool isChannelHidden(int channel);
  1797. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1798. Q_INVOKABLE QString channelColumnName(int channel);
  1799. Q_INVOKABLE QString channelIndicatorText(int channel);
  1800. public slots:
  1801. void setTemperatureColumn(int tcol);
  1802. void setAnnotationColumn(int ncol);
  1803. void start();
  1804. void stop();
  1805. signals:
  1806. void annotation(QString note,int tcol,int ncol);
  1807. void triggerStartBatch();
  1808. void triggerStopBatch();
  1809. void deviceStopRequested();
  1810. private:
  1811. QVariantMap deviceSettings;
  1812. QString deviceScript;
  1813. QList<Channel*> channelList;
  1814. QList<bool> hiddenState;
  1815. QList<Units::Unit> channelUnits;
  1816. QList<QString> columnNames;
  1817. QList<QString> indicatorTexts;
  1818. QList<QVariantMap> channelSettings;
  1819. int annotationTemperatureColumn;
  1820. int annotationNoteColumn;
  1821. QScriptEngine*scriptengine;
  1822. };
  1823. /*:888*//*913:*/
  1824. #line 11 "./phidgets.w"
  1825. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1826. {
  1827. Q_OBJECT
  1828. public:
  1829. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1830. const QModelIndex&index);
  1831. private slots:
  1832. void addChannel();
  1833. void updateRate(int ms);
  1834. };
  1835. /*:913*//*917:*/
  1836. #line 82 "./phidgets.w"
  1837. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1838. {
  1839. Q_OBJECT
  1840. public:
  1841. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1842. const QModelIndex&index);
  1843. private slots:
  1844. void updateColumnName(const QString&value);
  1845. void updateHidden(bool hidden);
  1846. void updateTC(int index);
  1847. void updateChannel(int channel);
  1848. private:
  1849. QComboBox*tcType;
  1850. };
  1851. /*:917*//*922:*/
  1852. #line 213 "./phidgets.w"
  1853. class PhidgetsTemperatureSensor:public QObject
  1854. {
  1855. Q_OBJECT
  1856. public:
  1857. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1858. Q_INVOKABLE int channelCount();
  1859. Channel*getChannel(int channel);
  1860. Q_INVOKABLE bool isChannelHidden(int channel);
  1861. Q_INVOKABLE QString channelColumnName(int channel);
  1862. Q_INVOKABLE QString channelIndicatorText(int channel);
  1863. public slots:
  1864. void start();
  1865. void stop();
  1866. private slots:
  1867. void getMeasurements();
  1868. private:
  1869. QList<int> channelIndices;
  1870. QList<int> tctypes;
  1871. QList<Channel*> channelList;
  1872. QMap<int,Channel*> channelMap;
  1873. QList<bool> hiddenState;
  1874. QList<QString> columnNames;
  1875. QList<QString> indicatorTexts;
  1876. QLibrary driver;
  1877. QTimer sampleTimer;
  1878. void*device;
  1879. /*926:*/
  1880. #line 349 "./phidgets.w"
  1881. #ifdef _WIN32
  1882. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1883. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1884. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1885. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1886. #else
  1887. typedef int(*PhidgetHandleOnly)(void*);
  1888. typedef int(*PhidgetHandleInt)(void*,int);
  1889. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1890. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1891. #endif
  1892. PhidgetHandleOnly createDevice;
  1893. PhidgetHandleInt openDevice;
  1894. PhidgetHandleInt waitForOpen;
  1895. PhidgetHandleIntInt setTCType;
  1896. PhidgetHandleIntDoubleOut getTemperature;
  1897. PhidgetHandleOnly closeDevice;
  1898. PhidgetHandleOnly deleteDevice;
  1899. /*:926*/
  1900. #line 240 "./phidgets.w"
  1901. };
  1902. /*:922*//*935:*/
  1903. #line 19348 "./typica.w"
  1904. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1905. {
  1906. Q_OBJECT
  1907. public:
  1908. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1909. const QModelIndex&index);
  1910. private slots:
  1911. void updateSourceColumn(const QString&source);
  1912. void updateDestinationColumn(const QString&dest);
  1913. void updateKnots();
  1914. private:
  1915. SaltModel*tablemodel;
  1916. };
  1917. /*:935*//*941:*/
  1918. #line 19478 "./typica.w"
  1919. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1920. {
  1921. Q_OBJECT
  1922. public:
  1923. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1924. const QModelIndex&index);
  1925. private slots:
  1926. void updateResetTime(QTime time);
  1927. };
  1928. /*:941*//*945:*/
  1929. #line 19544 "./typica.w"
  1930. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1931. {
  1932. Q_OBJECT
  1933. public:
  1934. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1935. private slots:
  1936. void updateStartButtonText(const QString&text);
  1937. void updateStopButtonText(const QString&text);
  1938. void updateStartColumnName(const QString&text);
  1939. void updateStopColumnName(const QString&text);
  1940. void updateStartValue(const QString&text);
  1941. void updateStopValue(const QString&text);
  1942. void updateStartTrigger(int option);
  1943. void updateStopTrigger(int option);
  1944. };
  1945. /*:945*//*950:*/
  1946. #line 19796 "./typica.w"
  1947. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1948. {
  1949. Q_OBJECT
  1950. public:
  1951. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1952. const QModelIndex&index);
  1953. private slots:
  1954. void updateColumnName(const QString&text);
  1955. void updateRangeData();
  1956. private:
  1957. SaltModel*tablemodel;
  1958. };
  1959. /*:950*//*955:*/
  1960. #line 19898 "./typica.w"
  1961. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1962. {
  1963. Q_OBJECT
  1964. public:
  1965. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1966. private slots:
  1967. void updateMatchingColumn(const QString&column);
  1968. void updateTemperature();
  1969. private:
  1970. QDoubleSpinBox*temperatureValue;
  1971. QComboBox*unitSelector;
  1972. };
  1973. /*:955*//*959:*/
  1974. #line 16 "./rate.w"
  1975. class RateOfChange:public QObject
  1976. {
  1977. Q_OBJECT
  1978. public:
  1979. RateOfChange(int cachetime= 1,int scaletime= 1);
  1980. public slots:
  1981. void newMeasurement(Measurement measure);
  1982. void setCacheTime(int seconds);
  1983. void setScaleTime(int seconds);
  1984. signals:
  1985. void newData(Measurement measure);
  1986. private:
  1987. int ct;
  1988. int st;
  1989. QList<Measurement> cache;
  1990. };
  1991. /*:959*//*967:*/
  1992. #line 177 "./rate.w"
  1993. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1994. {
  1995. Q_OBJECT
  1996. public:
  1997. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1998. private slots:
  1999. void updateColumn(const QString&column);
  2000. void updateCacheTime(const QString&seconds);
  2001. void updateScaleTime(const QString&seconds);
  2002. };
  2003. /*:967*//*973:*/
  2004. #line 19 "./dataqsdk.w"
  2005. class DataqSdkDeviceImplementation;
  2006. class DataqSdkDevice:public QObject
  2007. {
  2008. Q_OBJECT
  2009. DataqSdkDeviceImplementation*imp;
  2010. private slots:
  2011. void threadFinished();
  2012. public:
  2013. DataqSdkDevice(QString device);
  2014. ~DataqSdkDevice();
  2015. Channel*newChannel(Units::Unit scale);
  2016. Q_INVOKABLE void setClockRate(double Hz);
  2017. Q_INVOKABLE void start();
  2018. static QStringList detectPorts();
  2019. static QStringList detectHardware();
  2020. };
  2021. /*:973*//*974:*/
  2022. #line 49 "./dataqsdk.w"
  2023. class DataqSdkDeviceImplementation:public QThread
  2024. {
  2025. Q_OBJECT
  2026. public:
  2027. DataqSdkDeviceImplementation();
  2028. ~DataqSdkDeviceImplementation();
  2029. void run();
  2030. /*975:*/
  2031. #line 70 "./dataqsdk.w"
  2032. typedef struct di_inlist_struct{
  2033. unsigned short chan;
  2034. unsigned short diff;
  2035. unsigned short gain;
  2036. unsigned short unipolar;
  2037. unsigned short dig_out_enable;
  2038. unsigned short dig_out;
  2039. unsigned short ave;
  2040. unsigned short counter;
  2041. }DI_INLIST_STRUCT;
  2042. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2043. typedef int(PASCAL*FPDICLOSE)(void);
  2044. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2045. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2046. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2047. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2048. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2049. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2050. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2051. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2052. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2053. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2054. FPDIOPEN di_open;
  2055. FPDICLOSE di_close;
  2056. FPDISAMPLERATE di_sample_rate;
  2057. FPDIMAXIMUMRATE di_maximum_rate;
  2058. FPDILISTLENGTH di_list_length;
  2059. FPDIINLIST di_inlist;
  2060. FPDIBUFFERALLOC di_buffer_alloc;
  2061. FPDISTARTSCAN di_start_scan;
  2062. FPDISTATUSREAD di_status_read;
  2063. FPDIBUFFERSTATUS di_buffer_status;
  2064. FPDIBURSTRATE di_burst_rate;
  2065. FPDISTOPSCAN di_stop_scan;
  2066. /*:975*/
  2067. #line 57 "./dataqsdk.w"
  2068. /*977:*/
  2069. #line 134 "./dataqsdk.w"
  2070. bool isOpen;
  2071. double sampleRate;
  2072. long oversample;
  2073. long burstDivisor;
  2074. QString device;
  2075. unsigned deviceNumber;
  2076. QVector<Channel*> channelMap;
  2077. int error;
  2078. int channels;
  2079. bool ready;
  2080. QLibrary*driver;
  2081. QVector<Units::Unit> unitMap;
  2082. int*input_buffer;
  2083. QTimer*eventClock;
  2084. QMultiMap<int,double> smoother;
  2085. /*:977*/
  2086. #line 58 "./dataqsdk.w"
  2087. public slots:
  2088. void measure();
  2089. private:
  2090. qint16*buffer;
  2091. };
  2092. /*:974*//*994:*/
  2093. #line 663 "./dataqsdk.w"
  2094. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2095. {
  2096. Q_OBJECT
  2097. public:
  2098. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2099. const QModelIndex&index);
  2100. private slots:
  2101. void updateAutoSelect(bool automatic);
  2102. void updateDeviceNumber(int deviceNumber);
  2103. void updatePort(QString portId);
  2104. void addChannel();
  2105. private:
  2106. QStackedWidget*deviceIdStack;
  2107. };
  2108. /*:994*//*999:*/
  2109. #line 808 "./dataqsdk.w"
  2110. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2111. {
  2112. Q_OBJECT
  2113. public:
  2114. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2115. const QModelIndex&index);
  2116. private slots:
  2117. void updateUnits(const QString&unit);
  2118. void updateColumnName(const QString&value);
  2119. void updateMeasuredLower(const QString&value);
  2120. void updateMeasuredUpper(const QString&value);
  2121. void updateMappedLower(const QString&value);
  2122. void updateMappedUpper(const QString&value);
  2123. void updateClosedInterval(bool closed);
  2124. void updateSmoothingEnabled(bool enabled);
  2125. void updateSensitivity(const QString&value);
  2126. void startCalibration();
  2127. void stopCalibration();
  2128. void resetCalibration();
  2129. void updateInput(Measurement measure);
  2130. void updateOutput(Measurement measure);
  2131. void updateHidden(bool hidden);
  2132. private:
  2133. QPushButton*startButton;
  2134. QPushButton*resetButton;
  2135. QPushButton*stopButton;
  2136. /*1004:*/
  2137. #line 1098 "./dataqsdk.w"
  2138. bool autoSelect;
  2139. QString deviceID;
  2140. unsigned int channelOfInterest;
  2141. /*:1004*/
  2142. #line 835 "./dataqsdk.w"
  2143. DataqSdkDevice*calibrationDevice;
  2144. LinearCalibrator*calibrator;
  2145. QLineEdit*currentMeasurement;
  2146. QLineEdit*minimumMeasurement;
  2147. QLineEdit*maximumMeasurement;
  2148. QLineEdit*averageMeasurement;
  2149. QLineEdit*currentMapped;
  2150. QLineEdit*minimumMapped;
  2151. QLineEdit*maximumMapped;
  2152. QLineEdit*averageMapped;
  2153. int rmCount;
  2154. int cmCount;
  2155. double rmin;
  2156. double rmax;
  2157. double rmean;
  2158. double cmin;
  2159. double cmax;
  2160. double cmean;
  2161. };
  2162. /*:999*//*1026:*/
  2163. #line 273 "./scales.w"
  2164. Q_DECLARE_METATYPE(BaudRateType)
  2165. Q_DECLARE_METATYPE(DataBitsType)
  2166. Q_DECLARE_METATYPE(ParityType)
  2167. Q_DECLARE_METATYPE(StopBitsType)
  2168. Q_DECLARE_METATYPE(FlowType)
  2169. /*:1026*//*1033:*/
  2170. #line 396 "./scales.w"
  2171. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2172. {
  2173. Q_OBJECT
  2174. public:
  2175. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2176. const QModelIndex&index);
  2177. private slots:
  2178. void updatePort(const QString&newPort);
  2179. void updateBaudRate(const QString&rate);
  2180. void updateParity(int index);
  2181. void updateFlowControl(int index);
  2182. void updateStopBits(int index);
  2183. void updateWeighCommand(const QString&command);
  2184. void updateCommandTerminator(const QString&terminator);
  2185. private:
  2186. PortSelector*port;
  2187. BaudSelector*baud;
  2188. ParitySelector*parity;
  2189. FlowSelector*flow;
  2190. StopSelector*stop;
  2191. QLineEdit*weighcommand;
  2192. QComboBox*commandterminator;
  2193. };
  2194. /*:1033*//*1038:*/
  2195. #line 14 "./valueannotation.w"
  2196. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2197. {
  2198. Q_OBJECT
  2199. public:
  2200. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2201. const QModelIndex&index);
  2202. private slots:
  2203. void updateSourceColumn(const QString&source);
  2204. void updateAnnotations();
  2205. void updateStart(bool noteOnStart);
  2206. private:
  2207. SaltModel*tablemodel;
  2208. };
  2209. /*:1038*//*1046:*/
  2210. #line 165 "./valueannotation.w"
  2211. class ValueAnnotation:public QObject
  2212. {
  2213. Q_OBJECT
  2214. public:
  2215. ValueAnnotation();
  2216. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2217. public slots:
  2218. void newMeasurement(Measurement measure);
  2219. void annotate();
  2220. void setAnnotationColumn(int column);
  2221. void setTemperatureColumn(int column);
  2222. void setTolerance(double epsilon);
  2223. signals:
  2224. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2225. private:
  2226. int lastIndex;
  2227. int annotationColumn;
  2228. int measurementColumn;
  2229. QList<double> values;
  2230. QStringList annotations;
  2231. double tolerance;
  2232. };
  2233. /*:1046*/
  2234. #line 526 "./typica.w"
  2235. /*12:*/
  2236. #line 809 "./typica.w"
  2237. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2238. /*:12*//*14:*/
  2239. #line 824 "./typica.w"
  2240. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2241. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2242. /*:14*//*16:*/
  2243. #line 849 "./typica.w"
  2244. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2245. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2246. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2247. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2248. QScriptEngine*engine);
  2249. /*:16*//*20:*/
  2250. #line 939 "./typica.w"
  2251. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2252. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2253. /*:20*//*30:*/
  2254. #line 1140 "./typica.w"
  2255. QScriptValue constructQMainWindow(QScriptContext*context,
  2256. QScriptEngine*engine);
  2257. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2258. QScriptEngine*engine);
  2259. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2260. QScriptEngine*engine);
  2261. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2262. /*:30*//*35:*/
  2263. #line 1239 "./typica.w"
  2264. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2265. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2266. /*:35*//*38:*/
  2267. #line 1284 "./typica.w"
  2268. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2269. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2270. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2271. /*:38*//*41:*/
  2272. #line 1350 "./typica.w"
  2273. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2274. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2275. /*:41*//*44:*/
  2276. #line 1383 "./typica.w"
  2277. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2278. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2279. /*:44*//*47:*/
  2280. #line 1421 "./typica.w"
  2281. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2282. QScriptValue constructQSvgWidget(QScriptContext*context,
  2283. QScriptEngine*engine);
  2284. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2285. QScriptEngine*engine);
  2286. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2287. QStack<QLayout*> *layoutStack);
  2288. /*:47*//*53:*/
  2289. #line 1508 "./typica.w"
  2290. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2291. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2292. /*:53*//*57:*/
  2293. #line 1547 "./typica.w"
  2294. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2295. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2296. QScriptEngine*engine);
  2297. QScriptValue QSplitter_saveState(QScriptContext*context,
  2298. QScriptEngine*engine);
  2299. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2300. QScriptEngine*engine);
  2301. QScriptValue QSplitter_count(QScriptContext*context,
  2302. QScriptEngine*engine);
  2303. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2304. /*:57*//*63:*/
  2305. #line 1686 "./typica.w"
  2306. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2307. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2308. /*:63*//*65:*/
  2309. #line 1741 "./typica.w"
  2310. QScriptValue constructQBoxLayout(QScriptContext*context,
  2311. QScriptEngine*engine);
  2312. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2313. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2314. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2315. /*:65*//*69:*/
  2316. #line 1854 "./typica.w"
  2317. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2318. QScriptValue QAction_setShortcut(QScriptContext*context,
  2319. QScriptEngine*engine);
  2320. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2321. /*:69*//*72:*/
  2322. #line 1910 "./typica.w"
  2323. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2324. QScriptEngine*engine);
  2325. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2326. QScriptEngine*engine);
  2327. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2328. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2329. /*:72*//*77:*/
  2330. #line 2021 "./typica.w"
  2331. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2332. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2333. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2334. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2335. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2336. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2337. QScriptValue QIODevice_readToString(QScriptContext*context,
  2338. QScriptEngine*engine);
  2339. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2340. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2341. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2342. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2343. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2344. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2345. /*:77*//*88:*/
  2346. #line 2247 "./typica.w"
  2347. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2348. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2349. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2350. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2351. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2352. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2353. /*:88*//*96:*/
  2354. #line 2365 "./typica.w"
  2355. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2356. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2357. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2358. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2359. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2360. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2361. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2362. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2363. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2364. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2365. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2366. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2367. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2368. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2369. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2370. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2371. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2372. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2373. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2374. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2375. /*:96*//*109:*/
  2376. #line 2639 "./typica.w"
  2377. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2378. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2379. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2380. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2381. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2382. /*:109*//*112:*/
  2383. #line 2744 "./typica.w"
  2384. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2385. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2386. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2387. /*:112*//*115:*/
  2388. #line 2789 "./typica.w"
  2389. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2390. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2391. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2392. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2393. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2394. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2395. /*:115*//*121:*/
  2396. #line 2871 "./typica.w"
  2397. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2398. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2399. QScriptEngine*engine);
  2400. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2401. QScriptEngine*engine);
  2402. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2403. QScriptEngine*engine);
  2404. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2405. QScriptEngine*engine);
  2406. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2407. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2408. QScriptEngine*engine);
  2409. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2410. QScriptEngine*engine);
  2411. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2412. QScriptEngine*engine);
  2413. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2414. QScriptEngine*engine);
  2415. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2416. QScriptEngine*engine);
  2417. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2418. QScriptEngine*engine);
  2419. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2420. QScriptEngine*engine);
  2421. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2422. QScriptEngine*engine);
  2423. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2424. /*:121*//*130:*/
  2425. #line 3089 "./typica.w"
  2426. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2427. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2428. QScriptValue XmlReader_attribute(QScriptContext*context,
  2429. QScriptEngine*engine);
  2430. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2431. QScriptEngine*engine);
  2432. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2433. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2434. QScriptEngine*engine);
  2435. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2436. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2437. QScriptEngine*engine);
  2438. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2439. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2440. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2441. /*:130*//*137:*/
  2442. #line 3224 "./typica.w"
  2443. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2444. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2445. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2446. /*:137*//*141:*/
  2447. #line 3306 "./typica.w"
  2448. QScriptValue constructQLCDNumber(QScriptContext*context,
  2449. QScriptEngine*engine);
  2450. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2451. /*:141*//*144:*/
  2452. #line 3344 "./typica.w"
  2453. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2454. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2455. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2456. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2457. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2458. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2459. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2460. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2461. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2462. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2463. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2464. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2465. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2466. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2467. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2468. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2469. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2470. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2471. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2472. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2473. /*:144*//*160:*/
  2474. #line 3822 "./typica.w"
  2475. void setQAbstractScrollAreaProperties(QScriptValue value,
  2476. QScriptEngine*engine);
  2477. /*:160*//*162:*/
  2478. #line 3837 "./typica.w"
  2479. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2480. /*:162*//*164:*/
  2481. #line 3850 "./typica.w"
  2482. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2483. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2484. /*:164*//*166:*/
  2485. #line 3874 "./typica.w"
  2486. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2487. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2488. QScriptValue constructQPushButton(QScriptContext*context,
  2489. QScriptEngine*engine);
  2490. /*:166*//*173:*/
  2491. #line 3973 "./typica.w"
  2492. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2493. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2494. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2495. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2496. QScriptEngine*engine);
  2497. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2498. QScriptEngine*engine);
  2499. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2500. QScriptEngine*engine);
  2501. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2502. QScriptEngine*engine);
  2503. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2504. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2505. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2506. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2507. /*:173*//*180:*/
  2508. #line 4144 "./typica.w"
  2509. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2510. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2511. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2512. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2513. QScriptValue annotationFromRecord(QScriptContext*context,
  2514. QScriptEngine*engine);
  2515. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2516. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2517. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2518. /*:180*//*193:*/
  2519. #line 4476 "./typica.w"
  2520. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2521. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2522. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2523. QStack<QLayout*> *layoutStack);
  2524. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2525. QStack<QLayout*> *layoutStack);
  2526. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2527. QStack<QLayout*> *layoutStack);
  2528. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2529. QStack<QLayout*> *layoutStack);
  2530. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2531. QStack<QLayout*> *layoutStack);
  2532. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2533. QStack<QLayout*> *layoutStack);
  2534. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2535. QStack<QLayout*> *layoutStack);
  2536. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2537. QStack<QLayout*> *layoutStack);
  2538. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2539. QStack<QLayout*> *layoutStack);
  2540. void addTemperatureDisplayToSplitter(QDomElement element,
  2541. QStack<QWidget*> *widgetStack,
  2542. QStack<QLayout*> *layoutStack);
  2543. void addTemperatureDisplayToLayout(QDomElement element,
  2544. QStack<QWidget*> *widgetStack,
  2545. QStack<QLayout*> *layoutStack);
  2546. void addTimerDisplayToSplitter(QDomElement element,
  2547. QStack<QWidget*> *widgetStack,
  2548. QStack<QLayout*> *layoutStack);
  2549. void addTimerDisplayToLayout(QDomElement element,
  2550. QStack<QWidget*> *widgetStack,
  2551. QStack<QLayout*> *layoutStack);
  2552. void addDecorationToSplitter(QDomElement element,
  2553. QStack<QWidget*> *widgetStack,
  2554. QStack<QLayout*> *layoutStack);
  2555. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2556. QStack<QLayout*> *layoutStack);
  2557. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2558. QStack<QLayout*> *layoutStack);
  2559. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2560. QStack<QLayout*> *layoutStack);
  2561. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2562. QStack<QLayout*> *layoutStack);
  2563. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2564. QStack<QLayout*> *layoutStack);
  2565. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2566. QStack<QLayout*> *layoutStack);
  2567. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2568. QStack<QLayout*> *layoutStack);
  2569. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2570. QStack<QLayout*> *layoutStack);
  2571. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2572. QStack<QLayout*> *layoutStack);
  2573. void addSqlQueryViewToLayout(QDomElement element,
  2574. QStack<QWidget*> *widgetStack,
  2575. QStack<QLayout*> *layoutStack);
  2576. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2577. QStack<QLayout*> *layoutStack);
  2578. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2579. QStack<QLayout*> *layoutStack);
  2580. /*:193*//*257:*/
  2581. #line 6158 "./typica.w"
  2582. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2583. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2584. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2585. QScriptEngine*engine);
  2586. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2587. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2588. QScriptEngine*engine);
  2589. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2590. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2591. /*:257*//*258:*/
  2592. #line 6174 "./typica.w"
  2593. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2594. /*:258*//*262:*/
  2595. #line 6313 "./typica.w"
  2596. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2597. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2598. QScriptEngine*engine);
  2599. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2600. QScriptEngine*engine);
  2601. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2602. QScriptEngine*engine);
  2603. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2604. QScriptEngine*engine);
  2605. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2606. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2607. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2608. QScriptEngine*engine);
  2609. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2610. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2611. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2612. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2613. /*:262*//*272:*/
  2614. #line 6529 "./typica.w"
  2615. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2616. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2617. QScriptValue QComboBox_currentData(QScriptContext*context,
  2618. QScriptEngine*engine);
  2619. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2620. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2621. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2622. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2623. /*:272*//*284:*/
  2624. #line 379 "./units.w"
  2625. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2626. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2627. QScriptEngine*engine);
  2628. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2629. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2630. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2631. /*:284*//*288:*/
  2632. #line 443 "./units.w"
  2633. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2634. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2635. /*:288*//*297:*/
  2636. #line 133 "./measurement.w"
  2637. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2638. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2639. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2640. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2641. /*:297*//*317:*/
  2642. #line 7164 "./typica.w"
  2643. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2644. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2645. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2646. /*:317*//*326:*/
  2647. #line 7369 "./typica.w"
  2648. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2649. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2650. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2651. /*:326*//*331:*/
  2652. #line 7470 "./typica.w"
  2653. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2654. /*:331*//*337:*/
  2655. #line 7652 "./typica.w"
  2656. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2657. QScriptEngine*engine);
  2658. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2659. /*:337*//*342:*/
  2660. #line 7792 "./typica.w"
  2661. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2662. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2663. /*:342*//*352:*/
  2664. #line 7997 "./typica.w"
  2665. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2666. QScriptEngine*engine);
  2667. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2668. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2669. QScriptEngine*engine);
  2670. /*:352*//*360:*/
  2671. #line 8156 "./typica.w"
  2672. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2673. QScriptEngine*engine);
  2674. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2675. QScriptEngine*engine);
  2676. /*:360*//*365:*/
  2677. #line 8269 "./typica.w"
  2678. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2679. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2680. /*:365*//*370:*/
  2681. #line 8367 "./typica.w"
  2682. QScriptValue constructZeroEmitter(QScriptContext*context,
  2683. QScriptEngine*engine);
  2684. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2685. /*:370*//*375:*/
  2686. #line 8446 "./typica.w"
  2687. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2688. QScriptEngine*engine);
  2689. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2690. /*:375*//*392:*/
  2691. #line 8910 "./typica.w"
  2692. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2693. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2694. /*:392*//*415:*/
  2695. #line 9537 "./typica.w"
  2696. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2697. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2698. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2699. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2700. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2701. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2702. QScriptEngine*engine);
  2703. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2704. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2705. QScriptEngine*engnie);
  2706. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2707. QScriptEngine*engine);
  2708. /*:415*//*453:*/
  2709. #line 10494 "./typica.w"
  2710. QScriptValue constructAnnotationButton(QScriptContext*context,
  2711. QScriptEngine*engine);
  2712. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2713. /*:453*//*461:*/
  2714. #line 10634 "./typica.w"
  2715. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2716. QScriptEngine*engine);
  2717. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2718. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2719. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2720. /*:461*//*482:*/
  2721. #line 11060 "./typica.w"
  2722. QScriptValue constructTimerDisplay(QScriptContext*context,
  2723. QScriptEngine*engine);
  2724. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2725. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2726. /*:482*//*510:*/
  2727. #line 11585 "./typica.w"
  2728. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2729. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2730. QScriptEngine*engine);
  2731. /*:510*//*523:*/
  2732. #line 11868 "./typica.w"
  2733. QScriptValue constructLogEditWindow(QScriptContext*context,
  2734. QScriptEngine*engine);
  2735. /*:523*//*542:*/
  2736. #line 12395 "./typica.w"
  2737. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2738. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2739. /*:542*//*560:*/
  2740. #line 189 "./webview.w"
  2741. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2742. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2743. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2744. QStack<QLayout*> *layoutStack);
  2745. /*:560*//*563:*/
  2746. #line 219 "./webview.w"
  2747. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2748. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2749. /*:563*//*567:*/
  2750. #line 277 "./webview.w"
  2751. QScriptValue constructWebElement(QScriptContext*context,
  2752. QScriptEngine*engine);
  2753. /*:567*//*636:*/
  2754. #line 13742 "./typica.w"
  2755. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2756. QScriptValue constructSqlQueryView(QScriptContext*context,
  2757. QScriptEngine*engine);
  2758. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2759. QScriptEngine*engine);
  2760. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2761. QScriptEngine*engine);
  2762. /*:636*//*646:*/
  2763. #line 13981 "./typica.w"
  2764. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2765. QStack<QLayout*> *layoutStack);
  2766. /*:646*//*662:*/
  2767. #line 14266 "./typica.w"
  2768. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2769. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2770. /*:662*//*684:*/
  2771. #line 482 "./daterangeselector.w"
  2772. void addDateRangeToLayout(QDomElement element,
  2773. QStack<QWidget*> *widgetStack,
  2774. QStack<QLayout*> *layoutStack);
  2775. /*:684*//*693:*/
  2776. #line 14463 "./typica.w"
  2777. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2778. QStack<QLayout*> *layoutStack);
  2779. /*:693*//*714:*/
  2780. #line 15047 "./typica.w"
  2781. void addScaleControlToLayout(QDomElement element,
  2782. QStack<QWidget*> *widgetStack,
  2783. QStack<QLayout*> *layoutStack);
  2784. void addIntensityControlToLayout(QDomElement element,
  2785. QStack<QWidget*> *widgetStack,
  2786. QStack<QLayout*> *layoutStack);
  2787. /*:714*//*740:*/
  2788. #line 15633 "./typica.w"
  2789. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2790. QScriptEngine*engine);
  2791. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2792. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2793. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2794. QScriptEngine*engine);
  2795. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2796. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2797. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2798. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2799. /*:740*//*746:*/
  2800. #line 15775 "./typica.w"
  2801. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2802. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2803. /*:746*//*762:*/
  2804. #line 16073 "./typica.w"
  2805. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2806. QScriptEngine*engine);
  2807. /*:762*//*833:*/
  2808. #line 42 "./settings.w"
  2809. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2810. /*:833*//*857:*/
  2811. #line 18715 "./typica.w"
  2812. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2813. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2814. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2815. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2816. /*:857*//*875:*/
  2817. #line 635 "./modbus.w"
  2818. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  2819. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  2820. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  2821. /*:875*//*889:*/
  2822. #line 345 "./unsupportedserial.w"
  2823. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2824. /*:889*//*895:*/
  2825. #line 425 "./unsupportedserial.w"
  2826. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2827. /*:895*//*901:*/
  2828. #line 617 "./unsupportedserial.w"
  2829. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2830. /*:901*//*905:*/
  2831. #line 651 "./unsupportedserial.w"
  2832. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2833. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2834. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2835. /*:905*//*932:*/
  2836. #line 457 "./phidgets.w"
  2837. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2838. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2839. /*:932*//*964:*/
  2840. #line 138 "./rate.w"
  2841. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2842. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2843. /*:964*//*989:*/
  2844. #line 597 "./dataqsdk.w"
  2845. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2846. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2847. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2848. /*:989*//*1016:*/
  2849. #line 67 "./scales.w"
  2850. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2851. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2852. /*:1016*//*1024:*/
  2853. #line 259 "./scales.w"
  2854. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2855. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2856. /*:1024*//*1027:*/
  2857. #line 284 "./scales.w"
  2858. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2859. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2860. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2861. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2862. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2863. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2864. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2865. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2866. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2867. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2868. /*:1027*//*1052:*/
  2869. #line 265 "./valueannotation.w"
  2870. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2871. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2872. /*:1052*/
  2873. #line 527 "./typica.w"
  2874. /*616:*/
  2875. #line 13391 "./typica.w"
  2876. void messageFileOutput(QtMsgType type,const char*msg);
  2877. /*:616*/
  2878. #line 528 "./typica.w"
  2879. /*4:*/
  2880. #line 537 "./typica.w"
  2881. /*754:*/
  2882. #line 15896 "./typica.w"
  2883. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2884. const QString&driver,QObject*parent):
  2885. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2886. {
  2887. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2888. }
  2889. void NodeInserter::onTriggered()
  2890. {
  2891. emit triggered(defaultNodeName,driverString);
  2892. }
  2893. /*:754*/
  2894. #line 538 "./typica.w"
  2895. /*293:*/
  2896. #line 40 "./measurement.w"
  2897. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2898. {
  2899. insert("measurement",temperature);
  2900. insert("time",time);
  2901. insert("unit",sc);
  2902. }
  2903. Measurement::Measurement(double temperature)
  2904. {
  2905. insert("measurement",temperature);
  2906. insert("time",QTime::currentTime());
  2907. insert("unit",Units::Fahrenheit);
  2908. }
  2909. void Measurement::setTemperature(double temperature)
  2910. {
  2911. insert("measurement",temperature);
  2912. }
  2913. void Measurement::setTime(QTime time)
  2914. {
  2915. insert("time",time);
  2916. }
  2917. void Measurement::setUnit(Units::Unit scale)
  2918. {
  2919. insert("unit",scale);
  2920. }
  2921. double Measurement::temperature()const
  2922. {
  2923. return value("measurement").toDouble();
  2924. }
  2925. QTime Measurement::time()const
  2926. {
  2927. return value("time").toTime();
  2928. }
  2929. Units::Unit Measurement::scale()const
  2930. {
  2931. return(Units::Unit)(value("unit").toInt());
  2932. }
  2933. /*:293*//*294:*/
  2934. #line 88 "./measurement.w"
  2935. Measurement Measurement::toFahrenheit()
  2936. {
  2937. return Measurement(Units::convertTemperature(this->temperature(),
  2938. this->scale(),Units::Fahrenheit),
  2939. this->time(),Units::Fahrenheit);
  2940. }
  2941. Measurement Measurement::toCelsius()
  2942. {
  2943. return Measurement(Units::convertTemperature(this->temperature(),
  2944. this->scale(),Units::Celsius),
  2945. this->time(),Units::Celsius);
  2946. }
  2947. Measurement Measurement::toKelvin()
  2948. {
  2949. return Measurement(Units::convertTemperature(this->temperature(),
  2950. this->scale(),Units::Kelvin),
  2951. this->time(),Units::Kelvin);
  2952. }
  2953. Measurement Measurement::toRankine()
  2954. {
  2955. return Measurement(Units::convertTemperature(this->temperature(),
  2956. this->scale(),Units::Rankine),
  2957. this->time(),Units::Rankine);
  2958. }
  2959. /*:294*/
  2960. #line 539 "./typica.w"
  2961. /*307:*/
  2962. #line 6769 "./typica.w"
  2963. void DAQImplementation::measure()
  2964. {
  2965. int samplesRead= 0;
  2966. double buffer[channels];
  2967. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2968. (unsigned long)(0),buffer,(unsigned long)(channels),
  2969. &samplesRead,(signed long)(0));
  2970. if(error)
  2971. {
  2972. ready= false;
  2973. }
  2974. else
  2975. {
  2976. if(samplesRead)
  2977. {
  2978. QTime time= QTime::currentTime();
  2979. for(int i= 0;i<samplesRead;i++)
  2980. {
  2981. for(int j= 0;j<channels;j++)
  2982. {
  2983. double measuredValue= buffer[j+(i*channels)];
  2984. Measurement measure(measuredValue,time,
  2985. unitMap[j]);
  2986. channelMap[j]->input(measure);
  2987. }
  2988. }
  2989. }
  2990. }
  2991. }
  2992. /*:307*//*308:*/
  2993. #line 6812 "./typica.w"
  2994. void DAQImplementation::run()
  2995. {
  2996. setPriority(QThread::TimeCriticalPriority);
  2997. while(ready)
  2998. {
  2999. measure();
  3000. }
  3001. }
  3002. /*:308*//*309:*/
  3003. #line 6828 "./typica.w"
  3004. void DAQ::threadFinished()
  3005. {
  3006. if(imp->error)
  3007. {
  3008. /*310:*/
  3009. #line 6879 "./typica.w"
  3010. imp->ready= false;
  3011. QMessageBox warning;
  3012. warning.setStandardButtons(QMessageBox::Cancel);
  3013. warning.setIcon(QMessageBox::Warning);
  3014. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3015. unsigned long bytes= imp->errorInfo(NULL,0);
  3016. char string[bytes];
  3017. imp->errorInfo(string,bytes);
  3018. warning.setInformativeText(QString(string));
  3019. warning.setWindowTitle(QString(PROGRAM_NAME));
  3020. warning.exec();
  3021. /*:310*/
  3022. #line 6833 "./typica.w"
  3023. }
  3024. }
  3025. /*:309*//*311:*/
  3026. #line 6904 "./typica.w"
  3027. void DAQ::start()
  3028. {
  3029. if(imp->ready)
  3030. {
  3031. imp->error= imp->startTask(imp->handle);
  3032. if(imp->error)
  3033. {
  3034. /*310:*/
  3035. #line 6879 "./typica.w"
  3036. imp->ready= false;
  3037. QMessageBox warning;
  3038. warning.setStandardButtons(QMessageBox::Cancel);
  3039. warning.setIcon(QMessageBox::Warning);
  3040. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3041. unsigned long bytes= imp->errorInfo(NULL,0);
  3042. char string[bytes];
  3043. imp->errorInfo(string,bytes);
  3044. warning.setInformativeText(QString(string));
  3045. warning.setWindowTitle(QString(PROGRAM_NAME));
  3046. warning.exec();
  3047. /*:310*/
  3048. #line 6912 "./typica.w"
  3049. }
  3050. else
  3051. {
  3052. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3053. imp->start();
  3054. }
  3055. }
  3056. }
  3057. void DAQ::stop()
  3058. {
  3059. if(imp->useBase)
  3060. {
  3061. imp->ready= false;
  3062. imp->wait(ULONG_MAX);
  3063. imp->stopTask(imp->handle);
  3064. }
  3065. else
  3066. {
  3067. imp->ready= false;
  3068. imp->error= imp->stopTask(imp->handle);
  3069. if(imp->error)
  3070. {
  3071. /*310:*/
  3072. #line 6879 "./typica.w"
  3073. imp->ready= false;
  3074. QMessageBox warning;
  3075. warning.setStandardButtons(QMessageBox::Cancel);
  3076. warning.setIcon(QMessageBox::Warning);
  3077. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3078. unsigned long bytes= imp->errorInfo(NULL,0);
  3079. char string[bytes];
  3080. imp->errorInfo(string,bytes);
  3081. warning.setInformativeText(QString(string));
  3082. warning.setWindowTitle(QString(PROGRAM_NAME));
  3083. warning.exec();
  3084. /*:310*/
  3085. #line 6936 "./typica.w"
  3086. }
  3087. imp->error= imp->clearTask(imp->handle);
  3088. if(imp->error)
  3089. {
  3090. /*310:*/
  3091. #line 6879 "./typica.w"
  3092. imp->ready= false;
  3093. QMessageBox warning;
  3094. warning.setStandardButtons(QMessageBox::Cancel);
  3095. warning.setIcon(QMessageBox::Warning);
  3096. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3097. unsigned long bytes= imp->errorInfo(NULL,0);
  3098. char string[bytes];
  3099. imp->errorInfo(string,bytes);
  3100. warning.setInformativeText(QString(string));
  3101. warning.setWindowTitle(QString(PROGRAM_NAME));
  3102. warning.exec();
  3103. /*:310*/
  3104. #line 6941 "./typica.w"
  3105. }
  3106. }
  3107. }
  3108. /*:311*//*312:*/
  3109. #line 6951 "./typica.w"
  3110. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3111. {
  3112. imp->device= device;
  3113. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3114. if(imp->error)
  3115. {
  3116. /*310:*/
  3117. #line 6879 "./typica.w"
  3118. imp->ready= false;
  3119. QMessageBox warning;
  3120. warning.setStandardButtons(QMessageBox::Cancel);
  3121. warning.setIcon(QMessageBox::Warning);
  3122. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3123. unsigned long bytes= imp->errorInfo(NULL,0);
  3124. char string[bytes];
  3125. imp->errorInfo(string,bytes);
  3126. warning.setInformativeText(QString(string));
  3127. warning.setWindowTitle(QString(PROGRAM_NAME));
  3128. warning.exec();
  3129. /*:310*/
  3130. #line 6958 "./typica.w"
  3131. }
  3132. else
  3133. {
  3134. imp->ready= true;
  3135. }
  3136. }
  3137. /*:312*//*313:*/
  3138. #line 6972 "./typica.w"
  3139. Channel*DAQ::newChannel(int units,int thermocouple)
  3140. {
  3141. Channel*retval= new Channel();
  3142. imp->channelMap[imp->channels]= retval;
  3143. imp->unitMap[imp->channels]= (Units::Unit)units;
  3144. imp->channels++;
  3145. if(imp->ready)
  3146. {
  3147. if(imp->useBase)
  3148. {
  3149. imp->error= imp->createChannel(imp->handle,
  3150. QString("%1/ai%2").arg(imp->device).
  3151. arg(imp->channels-1).
  3152. toAscii().data(),
  3153. "",(double)(-1.0),(double)(100.0),
  3154. (signed long)(units),
  3155. (signed long)(thermocouple),
  3156. (signed long)(10200),(double)(0),
  3157. "");
  3158. }
  3159. else
  3160. {
  3161. imp->error= imp->createChannel(imp->handle,
  3162. QString("%1/ai%2").arg(imp->device).
  3163. arg(imp->channels-1).
  3164. toAscii().data(),
  3165. "",(double)(50.0),(double)(500.0),
  3166. (signed long)(units),
  3167. (signed long)(thermocouple),
  3168. (signed long)(10200),(double)(0),
  3169. "");
  3170. }
  3171. if(imp->error)
  3172. {
  3173. /*310:*/
  3174. #line 6879 "./typica.w"
  3175. imp->ready= false;
  3176. QMessageBox warning;
  3177. warning.setStandardButtons(QMessageBox::Cancel);
  3178. warning.setIcon(QMessageBox::Warning);
  3179. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3180. unsigned long bytes= imp->errorInfo(NULL,0);
  3181. char string[bytes];
  3182. imp->errorInfo(string,bytes);
  3183. warning.setInformativeText(QString(string));
  3184. warning.setWindowTitle(QString(PROGRAM_NAME));
  3185. warning.exec();
  3186. /*:310*/
  3187. #line 7007 "./typica.w"
  3188. }
  3189. }
  3190. return retval;
  3191. }
  3192. /*:313*//*314:*/
  3193. #line 7021 "./typica.w"
  3194. void DAQ::setClockRate(double Hz)
  3195. {
  3196. if(imp->ready)
  3197. {
  3198. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3199. (signed long)(10280),(signed long)(10123),
  3200. (unsigned long long)(1));
  3201. if(imp->error)
  3202. {
  3203. /*310:*/
  3204. #line 6879 "./typica.w"
  3205. imp->ready= false;
  3206. QMessageBox warning;
  3207. warning.setStandardButtons(QMessageBox::Cancel);
  3208. warning.setIcon(QMessageBox::Warning);
  3209. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3210. unsigned long bytes= imp->errorInfo(NULL,0);
  3211. char string[bytes];
  3212. imp->errorInfo(string,bytes);
  3213. warning.setInformativeText(QString(string));
  3214. warning.setWindowTitle(QString(PROGRAM_NAME));
  3215. warning.exec();
  3216. /*:310*/
  3217. #line 7031 "./typica.w"
  3218. }
  3219. }
  3220. }
  3221. /*:314*//*315:*/
  3222. #line 7041 "./typica.w"
  3223. DAQ::~DAQ()
  3224. {
  3225. if(imp->useBase)
  3226. {
  3227. imp->resetDevice(imp->device.toAscii().data());
  3228. imp->clearTask(imp->handle);
  3229. }
  3230. else
  3231. {
  3232. if(imp->ready)
  3233. {
  3234. imp->ready= false;
  3235. imp->wait(ULONG_MAX);
  3236. imp->stopTask(imp->handle);
  3237. imp->resetDevice(imp->device.toAscii().data());
  3238. imp->clearTask(imp->handle);
  3239. }
  3240. }
  3241. delete imp;
  3242. }
  3243. /*:315*//*316:*/
  3244. #line 7072 "./typica.w"
  3245. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3246. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3247. unitMap(4)
  3248. {
  3249. if(driverinfo=="nidaqmxbase")
  3250. {
  3251. useBase= true;
  3252. }
  3253. else
  3254. {
  3255. useBase= false;
  3256. }
  3257. if(useBase)
  3258. {
  3259. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3260. if(!driver.load())
  3261. {
  3262. driver.setFileName("nidaqmxbase");
  3263. if(!driver.load())
  3264. {
  3265. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3266. tr("Failed to find nidaqmxbase. Please install it."));
  3267. QApplication::quit();
  3268. }
  3269. }
  3270. }
  3271. else
  3272. {
  3273. driver.setFileName("nicaiu");
  3274. if(!driver.load())
  3275. {
  3276. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3277. tr("Failed to find nidaqmx. Please install it."));
  3278. QApplication::quit();
  3279. }
  3280. }
  3281. if(useBase)
  3282. {
  3283. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3284. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3285. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3286. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3287. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3288. ==0||
  3289. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3290. 0||
  3291. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3292. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3293. 0||
  3294. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3295. {
  3296. waitForMeasurement= NULL;
  3297. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3298. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3299. QApplication::quit();
  3300. }
  3301. }
  3302. else
  3303. {
  3304. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3305. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3306. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3307. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3308. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3309. ==0||
  3310. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3311. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3312. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3313. 0||
  3314. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3315. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3316. {
  3317. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3318. tr("Failed to link a required symbol in NI-DAQmx."));
  3319. QApplication::quit();
  3320. }
  3321. }
  3322. }
  3323. DAQImplementation::~DAQImplementation()
  3324. {
  3325. driver.unload();
  3326. }
  3327. /*:316*/
  3328. #line 540 "./typica.w"
  3329. /*978:*/
  3330. #line 197 "./dataqsdk.w"
  3331. void DataqSdkDeviceImplementation::measure()
  3332. {
  3333. unsigned count= channels*40;
  3334. di_status_read(buffer,count);
  3335. QTime time= QTime::currentTime();
  3336. for(unsigned int i= 0;i<count;i++)
  3337. {
  3338. buffer[i]= buffer[i]&0xFFFC;
  3339. }
  3340. QList<int> countList;
  3341. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3342. {
  3343. QList<double> channelBuffer;
  3344. for(unsigned int j= 0;j<40;j++)
  3345. {
  3346. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3347. if(i==0)
  3348. {
  3349. countList<<buffer[i+(channels*j)];
  3350. }
  3351. }
  3352. double value= 0.0;
  3353. for(unsigned int j= 0;j<40;j++)
  3354. {
  3355. value+= channelBuffer[j];
  3356. }
  3357. value/= 40.0;
  3358. if(i==0)
  3359. {
  3360. QList<double> smoothingList;
  3361. smoothingList<<value;
  3362. QList<int> smoothingKeys= smoother.uniqueKeys();
  3363. for(int j= 0;j<smoothingKeys.size();j++)
  3364. {
  3365. if(countList.contains(smoothingKeys[j]))
  3366. {
  3367. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3368. for(int k= 0;k<keyValues.size();k++)
  3369. {
  3370. smoothingList<<keyValues[k];
  3371. }
  3372. }
  3373. else
  3374. {
  3375. smoother.remove(smoothingKeys[j]);
  3376. }
  3377. }
  3378. qSort(countList);
  3379. int lastCount= 0;
  3380. for(int j= 0;j<countList.size();j++)
  3381. {
  3382. if(j==0||countList[j]!=lastCount)
  3383. {
  3384. smoother.insert(countList[j],value);
  3385. lastCount= countList[j];
  3386. }
  3387. }
  3388. value= 0.0;
  3389. for(int j= 0;j<smoothingList.size();j++)
  3390. {
  3391. value+= smoothingList[j];
  3392. }
  3393. value/= smoothingList.size();
  3394. }
  3395. Measurement measure(value,time,unitMap[i]);
  3396. channelMap[i]->input(measure);
  3397. }
  3398. }
  3399. /*:978*//*979:*/
  3400. #line 290 "./dataqsdk.w"
  3401. void DataqSdkDeviceImplementation::run()
  3402. {
  3403. if(!ready)
  3404. {
  3405. error= 9;
  3406. return;
  3407. }
  3408. driver= new QLibrary(device);
  3409. if(!driver->load())
  3410. {
  3411. error= 1;
  3412. qDebug()<<"Failed to load driver: "<<device;
  3413. return;
  3414. }
  3415. di_open= (FPDIOPEN)driver->resolve("di_open");
  3416. di_close= (FPDICLOSE)driver->resolve("di_close");
  3417. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3418. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3419. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3420. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3421. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3422. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3423. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3424. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3425. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3426. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3427. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3428. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3429. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3430. (!di_burst_rate)||(!di_stop_scan))
  3431. {
  3432. error= 2;
  3433. return;
  3434. }
  3435. error= di_open(deviceNumber);
  3436. if(error)
  3437. {
  3438. di_close();
  3439. error= di_open(deviceNumber);
  3440. if(error)
  3441. {
  3442. error= 3;
  3443. di_close();
  3444. return;
  3445. }
  3446. }
  3447. isOpen= true;
  3448. di_maximum_rate(240.0);
  3449. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3450. &burstDivisor);
  3451. buffer= new qint16[(int)sampleRate];
  3452. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3453. for(unsigned short i= 0;i<channels;i++)
  3454. {
  3455. inlist[i].chan= i;
  3456. inlist[i].gain= 0;
  3457. inlist[i].ave= 1;
  3458. inlist[i].counter= (oversample-1);
  3459. }
  3460. error= di_list_length(channels,0);
  3461. if(error)
  3462. {
  3463. error= 4;
  3464. return;
  3465. }
  3466. error= di_inlist(inlist);
  3467. if(error)
  3468. {
  3469. error= 5;
  3470. return;
  3471. }
  3472. input_buffer= di_buffer_alloc(0,4096);
  3473. if(input_buffer==NULL)
  3474. {
  3475. error= 6;
  3476. return;
  3477. }
  3478. error= di_start_scan();
  3479. if(error)
  3480. {
  3481. error= 7;
  3482. return;
  3483. }
  3484. while(ready)
  3485. {
  3486. measure();
  3487. }
  3488. }
  3489. /*:979*//*980:*/
  3490. #line 386 "./dataqsdk.w"
  3491. void DataqSdkDevice::threadFinished()
  3492. {
  3493. if(imp->error)
  3494. {
  3495. /*981:*/
  3496. #line 400 "./dataqsdk.w"
  3497. imp->ready= false;
  3498. QMessageBox warning;
  3499. warning.setStandardButtons(QMessageBox::Cancel);
  3500. warning.setIcon(QMessageBox::Warning);
  3501. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3502. warning.setInformativeText(tr("An error occurred"));
  3503. warning.setWindowTitle(QString(PROGRAM_NAME));
  3504. warning.exec();
  3505. /*:981*/
  3506. #line 391 "./dataqsdk.w"
  3507. }
  3508. }
  3509. /*:980*//*982:*/
  3510. #line 417 "./dataqsdk.w"
  3511. void DataqSdkDevice::start()
  3512. {
  3513. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3514. imp->start();
  3515. }
  3516. /*:982*//*983:*/
  3517. #line 428 "./dataqsdk.w"
  3518. QStringList DataqSdkDevice::detectHardware()
  3519. {
  3520. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3521. QSettings::NativeFormat);
  3522. QStringList keys= deviceLookup.childKeys();
  3523. QStringList devices;
  3524. for(int i= 0;i<keys.size();i++)
  3525. {
  3526. QString value= deviceLookup.value(keys.at(i)).toString();
  3527. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3528. {
  3529. devices.append(value.split("\\").at(2));
  3530. }
  3531. }
  3532. QStringList portList;
  3533. foreach(QString device,devices)
  3534. {
  3535. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3536. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3537. portList.append(deviceEntry.value("FriendlyName").toString());
  3538. }
  3539. return portList;
  3540. }
  3541. QStringList DataqSdkDevice::detectPorts()
  3542. {
  3543. QStringList friendlyNames= detectHardware();
  3544. QStringList portList;
  3545. foreach(QString name,friendlyNames)
  3546. {
  3547. name.remove(0,name.indexOf("COM"));
  3548. name.chop(1);
  3549. portList.append(name);
  3550. }
  3551. return portList;
  3552. }
  3553. /*:983*//*984:*/
  3554. #line 473 "./dataqsdk.w"
  3555. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3556. {
  3557. bool usesAuto= false;
  3558. int autoIndex= device.toInt(&usesAuto);
  3559. QString finalizedPort;
  3560. if(usesAuto)
  3561. {
  3562. QStringList portList= detectPorts();
  3563. if(autoIndex> 0&&autoIndex<=portList.size())
  3564. {
  3565. finalizedPort= portList.at(autoIndex-1);
  3566. }
  3567. else
  3568. {
  3569. imp->error= 8;
  3570. qDebug()<<"Failed to detect port.";
  3571. }
  3572. }
  3573. else
  3574. {
  3575. finalizedPort= device;
  3576. }
  3577. int rstart= finalizedPort.indexOf("COM");
  3578. finalizedPort.remove(0,rstart+3);
  3579. bool chopFinished= false;
  3580. int finalizedPortNumber= 0;
  3581. while(finalizedPort.size()> 0&&!chopFinished)
  3582. {
  3583. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3584. if(!chopFinished)
  3585. {
  3586. finalizedPort.chop(1);
  3587. }
  3588. }
  3589. if(finalizedPortNumber<10)
  3590. {
  3591. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3592. }
  3593. else
  3594. {
  3595. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3596. }
  3597. imp->deviceNumber= 0x12C02D00;
  3598. imp->deviceNumber+= finalizedPortNumber;
  3599. imp->ready= true;
  3600. }
  3601. /*:984*//*985:*/
  3602. #line 523 "./dataqsdk.w"
  3603. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3604. {
  3605. Channel*retval= NULL;
  3606. if(imp->ready)
  3607. {
  3608. retval= new Channel();
  3609. imp->channelMap[imp->channels]= retval;
  3610. imp->unitMap[imp->channels]= scale;
  3611. imp->channels++;
  3612. }
  3613. return retval;
  3614. }
  3615. /*:985*//*986:*/
  3616. #line 547 "./dataqsdk.w"
  3617. void DataqSdkDevice::setClockRate(double Hz)
  3618. {
  3619. imp->sampleRate= Hz;
  3620. }
  3621. /*:986*//*987:*/
  3622. #line 557 "./dataqsdk.w"
  3623. DataqSdkDevice::~DataqSdkDevice()
  3624. {
  3625. if(imp->ready)
  3626. {
  3627. imp->ready= false;
  3628. }
  3629. imp->wait(ULONG_MAX);
  3630. delete imp;
  3631. }
  3632. /*:987*//*988:*/
  3633. #line 575 "./dataqsdk.w"
  3634. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3635. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3636. {
  3637. }
  3638. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3639. {
  3640. if(isOpen)
  3641. {
  3642. di_stop_scan();
  3643. di_close();
  3644. }
  3645. if(driver->isLoaded())
  3646. {
  3647. driver->unload();
  3648. }
  3649. }
  3650. /*:988*/
  3651. #line 541 "./typica.w"
  3652. /*323:*/
  3653. #line 7281 "./typica.w"
  3654. void FakeDAQImplementation::measure()
  3655. {
  3656. msleep((int)(1000/clockRate));
  3657. QTime time= QTime::currentTime();
  3658. for(int i= 0;i<channels;i++)
  3659. {
  3660. Measurement measure(qrand()%500,time);
  3661. channelMap[i]->input(measure);
  3662. }
  3663. }
  3664. /*:323*//*324:*/
  3665. #line 7295 "./typica.w"
  3666. void FakeDAQImplementation::run()
  3667. {
  3668. setPriority(QThread::TimeCriticalPriority);
  3669. while(ready)
  3670. {
  3671. measure();
  3672. }
  3673. }
  3674. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3675. channels(0),ready(false),clockRate(1)
  3676. {
  3677. }
  3678. FakeDAQImplementation::~FakeDAQImplementation()
  3679. {
  3680. }
  3681. /*:324*//*325:*/
  3682. #line 7320 "./typica.w"
  3683. void FakeDAQ::start()
  3684. {
  3685. if(imp->ready)
  3686. {
  3687. imp->start();
  3688. }
  3689. }
  3690. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3691. {
  3692. imp->ready= true;
  3693. }
  3694. Channel*FakeDAQ::newChannel(int,int)
  3695. {
  3696. Channel*retval;
  3697. if(imp->ready)
  3698. {
  3699. retval= new Channel();
  3700. imp->channelMap[imp->channels]= retval;
  3701. imp->channels++;
  3702. }
  3703. else
  3704. {
  3705. return NULL;
  3706. }
  3707. return retval;
  3708. }
  3709. void FakeDAQ::setClockRate(double Hz)
  3710. {
  3711. if(imp->ready)
  3712. {
  3713. imp->clockRate= Hz;
  3714. }
  3715. }
  3716. FakeDAQ::~FakeDAQ()
  3717. {
  3718. imp->ready= false;
  3719. imp->wait(ULONG_MAX);
  3720. delete imp;
  3721. }
  3722. /*:325*/
  3723. #line 542 "./typica.w"
  3724. /*330:*/
  3725. #line 7451 "./typica.w"
  3726. Channel::Channel():QObject(NULL)
  3727. {
  3728. }
  3729. Channel::~Channel()
  3730. {
  3731. }
  3732. void Channel::input(Measurement measurement)
  3733. {
  3734. emit newData(measurement);
  3735. }
  3736. /*:330*/
  3737. #line 543 "./typica.w"
  3738. /*346:*/
  3739. #line 7856 "./typica.w"
  3740. void TemperatureDisplay::setRelativeMode(bool relative)
  3741. {
  3742. r= relative;
  3743. }
  3744. /*:346*//*347:*/
  3745. #line 7873 "./typica.w"
  3746. void TemperatureDisplay::setValue(Measurement temperature)
  3747. {
  3748. QString number;
  3749. switch(unit)
  3750. {
  3751. case Units::Fahrenheit:
  3752. display(QString("%1'F").
  3753. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3754. 2)));
  3755. break;
  3756. case Units::Celsius:
  3757. if(!r){
  3758. display(QString("%1'C").
  3759. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3760. 2)));
  3761. }else{
  3762. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3763. display(QString("%1'C").arg(number));
  3764. }
  3765. break;
  3766. case Units::Kelvin:
  3767. if(!r){
  3768. display(QString("%1").
  3769. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3770. 2)));
  3771. }else{
  3772. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3773. display(QString("%1").arg(number));
  3774. }
  3775. break;
  3776. case Units::Rankine:
  3777. display(QString("%1'r").
  3778. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3779. 2)));
  3780. break;
  3781. case Units::Unitless:
  3782. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3783. break;
  3784. default:
  3785. switch(temperature.scale())
  3786. {
  3787. case Units::Fahrenheit:
  3788. display(QString("%1'F").
  3789. arg(number.setNum(temperature.temperature(),'f',2)));
  3790. break;
  3791. case Units::Celsius:
  3792. display(QString("%1'C").
  3793. arg(number.setNum(temperature.temperature(),'f',2)));
  3794. break;
  3795. case Units::Kelvin:
  3796. display(QString("%1").
  3797. arg(number.setNum(temperature.temperature(),'f',2)));
  3798. break;
  3799. case Units::Rankine:
  3800. display(QString("%1'r").
  3801. arg(number.setNum(temperature.temperature(),'f',2)));
  3802. break;
  3803. case Units::Unitless:
  3804. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3805. break;
  3806. default:
  3807. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  3808. break;
  3809. }
  3810. break;
  3811. }
  3812. }
  3813. /*:347*//*348:*/
  3814. #line 7952 "./typica.w"
  3815. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3816. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3817. {
  3818. setSegmentStyle(Filled);
  3819. display("---.--'F");
  3820. }
  3821. /*:348*//*349:*/
  3822. #line 7968 "./typica.w"
  3823. void TemperatureDisplay::invalidate()
  3824. {
  3825. display("---.--'F");
  3826. }
  3827. /*:349*//*350:*/
  3828. #line 7980 "./typica.w"
  3829. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3830. {
  3831. unit= scale;
  3832. }
  3833. /*:350*//*351:*/
  3834. #line 7988 "./typica.w"
  3835. TemperatureDisplay::~TemperatureDisplay()
  3836. {
  3837. }
  3838. /*:351*/
  3839. #line 544 "./typica.w"
  3840. /*357:*/
  3841. #line 8088 "./typica.w"
  3842. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3843. {
  3844. if(measure.time()<epoch)
  3845. {
  3846. if(hasPrevious)
  3847. {
  3848. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3849. epoch.msec());
  3850. QTime jitComp(epoch.hour(),measure.time().minute(),
  3851. measure.time().second(),measure.time().msec());
  3852. int relTime= jitBase.msecsTo(jitComp);
  3853. /*358:*/
  3854. #line 8122 "./typica.w"
  3855. QTime newTime(0,0,0,0);
  3856. newTime= newTime.addMSecs(relTime);
  3857. if(newTime.hour()> 0)
  3858. {
  3859. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3860. }
  3861. Measurement rel= measure;
  3862. rel.setTime(newTime);
  3863. emit measurement(rel);
  3864. /*:358*/
  3865. #line 8100 "./typica.w"
  3866. }
  3867. else
  3868. {
  3869. Measurement rel= measure;
  3870. rel.setTime(QTime(0,0,0,0));
  3871. emit measurement(rel);
  3872. }
  3873. }
  3874. else
  3875. {
  3876. int relTime= epoch.msecsTo(measure.time());
  3877. /*358:*/
  3878. #line 8122 "./typica.w"
  3879. QTime newTime(0,0,0,0);
  3880. newTime= newTime.addMSecs(relTime);
  3881. if(newTime.hour()> 0)
  3882. {
  3883. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3884. }
  3885. Measurement rel= measure;
  3886. rel.setTime(newTime);
  3887. emit measurement(rel);
  3888. /*:358*/
  3889. #line 8112 "./typica.w"
  3890. }
  3891. hasPrevious= true;
  3892. previous= measure.time();
  3893. }
  3894. /*:357*//*359:*/
  3895. #line 8135 "./typica.w"
  3896. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3897. previous(0,0,0,0),hasPrevious(false)
  3898. {
  3899. }
  3900. QTime MeasurementTimeOffset::zeroTime()
  3901. {
  3902. return epoch;
  3903. }
  3904. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3905. {
  3906. epoch= zero;
  3907. hasPrevious= false;
  3908. }
  3909. /*:359*/
  3910. #line 545 "./typica.w"
  3911. /*369:*/
  3912. #line 8333 "./typica.w"
  3913. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3914. {
  3915. }
  3916. int ZeroEmitter::column()
  3917. {
  3918. return col;
  3919. }
  3920. double ZeroEmitter::lastTemperature()
  3921. {
  3922. return cache.temperature();
  3923. }
  3924. void ZeroEmitter::newMeasurement(Measurement measure)
  3925. {
  3926. cache= measure;
  3927. }
  3928. void ZeroEmitter::setColumn(int column)
  3929. {
  3930. col= column;
  3931. }
  3932. void ZeroEmitter::emitZero()
  3933. {
  3934. cache.setTime(QTime(0,0,0,0));
  3935. emit measurement(cache,col);
  3936. }
  3937. /*:369*/
  3938. #line 546 "./typica.w"
  3939. /*374:*/
  3940. #line 8423 "./typica.w"
  3941. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3942. {
  3943. }
  3944. int MeasurementAdapter::column()
  3945. {
  3946. return col;
  3947. }
  3948. void MeasurementAdapter::newMeasurement(Measurement measure)
  3949. {
  3950. emit measurement(measure,col);
  3951. }
  3952. void MeasurementAdapter::setColumn(int column)
  3953. {
  3954. col= column;
  3955. }
  3956. /*:374*/
  3957. #line 547 "./typica.w"
  3958. /*379:*/
  3959. #line 8545 "./typica.w"
  3960. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  3961. theScene(new QGraphicsScene),
  3962. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  3963. prevPoints(new QMap<int,QPointF> ),
  3964. translations(new QMap<int,double> ),
  3965. gridLinesF(new QList<QGraphicsItem*> ),
  3966. gridLinesC(new QList<QGraphicsItem*> ),
  3967. relativeGridLines(new QList<QGraphicsItem*> ),
  3968. relativeEnabled(false),
  3969. timeIndicatorEnabled(false),
  3970. timeLine(new QGraphicsLineItem),
  3971. relativeAdjuster(new LinearSplineInterpolator)
  3972. {
  3973. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3974. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  3975. setScene(theScene);
  3976. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  3977. QPen timePen;
  3978. timePen.setColor(QColor(160,160,164,127));
  3979. timeLine->setPen(timePen);
  3980. timeLine->setLine(0,0,0,-500);
  3981. timeLine->hide();
  3982. theScene->addItem(timeLine);
  3983. /*380:*/
  3984. #line 8585 "./typica.w"
  3985. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  3986. tempaxis->setLine(-10,-500,-10,0);
  3987. theScene->addItem(tempaxis);
  3988. QGraphicsLineItem*gridLine;
  3989. QGraphicsTextItem*label;
  3990. for(int y= -100;y> -600;y-= 100)
  3991. {
  3992. gridLine= new QGraphicsLineItem;
  3993. gridLine->setLine(0,y,1200,y);
  3994. theScene->addItem(gridLine);
  3995. label= new QGraphicsTextItem;
  3996. label->setHtml(QString("%1&deg;F").arg(-y));
  3997. label->setPos(-55,y-(label->boundingRect().height()/2));
  3998. theScene->addItem(label);
  3999. gridLinesF->append(gridLine);
  4000. gridLinesF->append(label);
  4001. }
  4002. for(int degC= 50;degC<=250;degC+= 50)
  4003. {
  4004. gridLine= new QGraphicsLineItem;
  4005. int y= -(degC*(9.0/5.0)+32);
  4006. gridLine->setLine(0,y,1200,y);
  4007. gridLine->hide();
  4008. theScene->addItem(gridLine);
  4009. gridLinesC->append(gridLine);
  4010. label= new QGraphicsTextItem;
  4011. label->setHtml(QString("%1&deg;C").arg(degC));
  4012. label->setPos(-55,y-(label->boundingRect().height()/2));
  4013. label->hide();
  4014. theScene->addItem(label);
  4015. gridLinesC->append(label);
  4016. }
  4017. /*:380*/
  4018. #line 8569 "./typica.w"
  4019. ;
  4020. /*381:*/
  4021. #line 8626 "./typica.w"
  4022. QSettings settings;
  4023. if(settings.contains("settings/graph/relative/enable"))
  4024. {
  4025. if(settings.value("settings/graph/relative/enable").toBool())
  4026. {
  4027. relativeEnabled= true;
  4028. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4029. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4030. QMap<double,QString> relativeAxisPairs;
  4031. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4032. foreach(QString item,relativeAxisLabels)
  4033. {
  4034. relativeAxisPairs.insert(item.toDouble(),item);
  4035. }
  4036. if(relativeAxisPairs.size()> 1)
  4037. {
  4038. double skip= 500.0/(relativeAxisPairs.size()-1);
  4039. double y= 0;
  4040. foreach(double key,relativeAxisPairs.keys())
  4041. {
  4042. gridLine= new QGraphicsLineItem;
  4043. gridLine->setLine(0,y,1205,y);
  4044. gridLine->setPen(QPen(relativeColor));
  4045. theScene->addItem(gridLine);
  4046. relativeGridLines->append(gridLine);
  4047. label= new QGraphicsTextItem;
  4048. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4049. label->setPos(1210,y-(label->boundingRect().height()/2));
  4050. theScene->addItem(label);
  4051. relativeGridLines->append(label);
  4052. if(unit=="F")
  4053. {
  4054. relativeAdjuster->add_pair(key,-y);
  4055. }
  4056. else
  4057. {
  4058. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4059. }
  4060. y-= skip;
  4061. }
  4062. }
  4063. }
  4064. }
  4065. /*:381*/
  4066. #line 8570 "./typica.w"
  4067. /*383:*/
  4068. #line 8703 "./typica.w"
  4069. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4070. timeaxis->setLine(0,10,1200,10);
  4071. theScene->addItem(timeaxis);
  4072. for(int x= 0;x<1201;x+= 120)
  4073. {
  4074. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4075. tick->setLine(x,0,x,20);
  4076. theScene->addItem(tick);
  4077. QGraphicsTextItem*label= new QGraphicsTextItem;
  4078. label->setPlainText(QString("%1").arg(x/60));
  4079. label->setPos(x-(label->boundingRect().width()/2),20);
  4080. theScene->addItem(label);
  4081. }
  4082. /*:383*/
  4083. #line 8571 "./typica.w"
  4084. ;
  4085. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4086. }
  4087. /*:379*//*382:*/
  4088. #line 8673 "./typica.w"
  4089. void GraphView::showF()
  4090. {
  4091. for(int i= 0;i<gridLinesF->size();i++)
  4092. {
  4093. gridLinesF->at(i)->show();
  4094. }
  4095. for(int i= 0;i<gridLinesC->size();i++)
  4096. {
  4097. gridLinesC->at(i)->hide();
  4098. }
  4099. }
  4100. void GraphView::showC()
  4101. {
  4102. for(int i= 0;i<gridLinesF->size();i++)
  4103. {
  4104. gridLinesF->at(i)->hide();
  4105. }
  4106. for(int i= 0;i<gridLinesC->size();i++)
  4107. {
  4108. gridLinesC->at(i)->show();
  4109. }
  4110. }
  4111. /*:382*//*384:*/
  4112. #line 8722 "./typica.w"
  4113. void GraphView::resizeEvent(QResizeEvent*)
  4114. {
  4115. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4116. }
  4117. /*:384*//*385:*/
  4118. #line 8736 "./typica.w"
  4119. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4120. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4121. {
  4122. double offset= 0;
  4123. if(measure.contains("relative"))
  4124. {
  4125. if(measure.value("relative").toBool())
  4126. {
  4127. if(relativeEnabled)
  4128. {
  4129. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4130. }
  4131. else
  4132. {
  4133. return;
  4134. }
  4135. }
  4136. }
  4137. if(translations->contains(tempcolumn))
  4138. {
  4139. offset= translations->value(tempcolumn);
  4140. }
  4141. if(prevPoints->contains(tempcolumn))
  4142. {
  4143. /*387:*/
  4144. #line 8813 "./typica.w"
  4145. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4146. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4147. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4148. -(prevPoints->value(tempcolumn).y()),
  4149. nextPoint.x()+offset,-(nextPoint.y()));
  4150. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4151. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4152. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4153. Qt::darkYellow};
  4154. segment->setPen(p[tempcolumn%12]);
  4155. theScene->addItem(segment);
  4156. prevPoints->insert(tempcolumn,nextPoint);
  4157. if(timeIndicatorEnabled)
  4158. {
  4159. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4160. }
  4161. /*:387*/
  4162. #line 8762 "./typica.w"
  4163. if(graphLines->contains(tempcolumn))
  4164. {
  4165. graphLines->value(tempcolumn)->append(segment);
  4166. }
  4167. else
  4168. {
  4169. QList<QGraphicsLineItem*> *newLine=
  4170. new QList<QGraphicsLineItem*> ;
  4171. newLine->append(segment);
  4172. graphLines->insert(tempcolumn,newLine);
  4173. }
  4174. }
  4175. else
  4176. {
  4177. /*386:*/
  4178. #line 8798 "./typica.w"
  4179. int x= FULLTIMETOINT(measure.time())/1000;
  4180. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4181. if(timeIndicatorEnabled)
  4182. {
  4183. timeLine->setLine(x,0,x,-500);
  4184. }
  4185. /*:386*/
  4186. #line 8779 "./typica.w"
  4187. }
  4188. }
  4189. /*:385*//*388:*/
  4190. #line 8834 "./typica.w"
  4191. void GraphView::clear()
  4192. {
  4193. int i;
  4194. foreach(i,prevPoints->keys())
  4195. {
  4196. removeSeries(i);
  4197. }
  4198. translations->clear();
  4199. }
  4200. /*:388*//*389:*/
  4201. #line 8848 "./typica.w"
  4202. void GraphView::removeSeries(int column)
  4203. {
  4204. if(graphLines->contains(column))
  4205. {
  4206. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4207. QGraphicsLineItem*segment;
  4208. foreach(segment,*series)
  4209. {
  4210. theScene->removeItem(segment);
  4211. }
  4212. qDeleteAll(*series);
  4213. }
  4214. graphLines->remove(column);
  4215. prevPoints->remove(column);
  4216. }
  4217. /*:389*//*390:*/
  4218. #line 8867 "./typica.w"
  4219. void GraphView::setSeriesTranslation(int column,double offset)
  4220. {
  4221. if(graphLines->contains(column))
  4222. {
  4223. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4224. QGraphicsLineItem*segment;
  4225. foreach(segment,*series)
  4226. {
  4227. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4228. }
  4229. }
  4230. if(translations->contains(column))
  4231. {
  4232. translations->insert(column,offset+translations->value(column));
  4233. }
  4234. else
  4235. {
  4236. translations->insert(column,offset);
  4237. }
  4238. }
  4239. /*:390*//*391:*/
  4240. #line 8894 "./typica.w"
  4241. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4242. {
  4243. timeIndicatorEnabled= enabled;
  4244. if(enabled)
  4245. {
  4246. timeLine->show();
  4247. }
  4248. else
  4249. {
  4250. timeLine->hide();
  4251. }
  4252. }
  4253. /*:391*/
  4254. #line 548 "./typica.w"
  4255. /*397:*/
  4256. #line 9038 "./typica.w"
  4257. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4258. {
  4259. if(measure.time()!=QTime(0,0,0,0))
  4260. {
  4261. /*399:*/
  4262. #line 9112 "./typica.w"
  4263. if(lastMeasurement.contains(tempcolumn))
  4264. {
  4265. if(lastMeasurement[tempcolumn].time()<measure.time())
  4266. {
  4267. QList<QTime> timelist;
  4268. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4269. {
  4270. timelist.append(i);
  4271. }
  4272. for(int i= 0;i<timelist.size();i++)
  4273. {
  4274. Measurement synthesized= measure;
  4275. synthesized.setTime(timelist[i]);
  4276. newMeasurement(synthesized,tempcolumn);
  4277. }
  4278. }
  4279. }
  4280. /*:399*/
  4281. #line 9043 "./typica.w"
  4282. }
  4283. model_ms->newMeasurement(measure,tempcolumn);
  4284. if(lastMeasurement.contains(tempcolumn))
  4285. {
  4286. if(measure.time().second()!=
  4287. lastMeasurement.value(tempcolumn).time().second())
  4288. {
  4289. Measurement adjusted= measure;
  4290. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4291. adjusted.setTime(adjtime);
  4292. model_1s->newMeasurement(adjusted,tempcolumn);
  4293. if(adjusted.time().second()%5==0)
  4294. {
  4295. model_5s->newMeasurement(adjusted,tempcolumn);
  4296. if(adjusted.time().second()%10==0)
  4297. {
  4298. model_10s->newMeasurement(adjusted,tempcolumn);
  4299. }
  4300. if(adjusted.time().second()%15==0)
  4301. {
  4302. model_15s->newMeasurement(adjusted,tempcolumn);
  4303. if(adjusted.time().second()%30==0)
  4304. {
  4305. model_30s->newMeasurement(adjusted,tempcolumn);
  4306. if(adjusted.time().second()==0)
  4307. {
  4308. model_1m->newMeasurement(adjusted,tempcolumn);
  4309. }
  4310. }
  4311. }
  4312. }
  4313. }
  4314. /*401:*/
  4315. #line 9156 "./typica.w"
  4316. if(currentColumnSet.contains(tempcolumn))
  4317. {
  4318. int replicationcolumn;
  4319. foreach(replicationcolumn,currentColumnSet)
  4320. {
  4321. if(replicationcolumn!=tempcolumn)
  4322. {
  4323. if(lastMeasurement.contains(replicationcolumn))
  4324. {
  4325. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4326. {
  4327. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4328. synthetic.setTime(measure.time());
  4329. model_ms->newMeasurement(synthetic,replicationcolumn);
  4330. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4331. {
  4332. Measurement adjusted= synthetic;
  4333. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4334. model_1s->newMeasurement(adjusted,replicationcolumn);
  4335. if(adjusted.time().second()%5==0)
  4336. {
  4337. model_5s->newMeasurement(adjusted,replicationcolumn);
  4338. if(adjusted.time().second()%10==0)
  4339. {
  4340. model_10s->newMeasurement(adjusted,replicationcolumn);
  4341. }
  4342. if(adjusted.time().second()%15==0)
  4343. {
  4344. model_15s->newMeasurement(adjusted,replicationcolumn);
  4345. if(adjusted.time().second()%30==0)
  4346. {
  4347. model_30s->newMeasurement(adjusted,replicationcolumn);
  4348. if(adjusted.time().second()==0)
  4349. {
  4350. model_1m->newMeasurement(adjusted,replicationcolumn);
  4351. }
  4352. }
  4353. }
  4354. }
  4355. }
  4356. lastMeasurement[replicationcolumn]= synthetic;
  4357. }
  4358. }
  4359. }
  4360. }
  4361. }
  4362. /*:401*/
  4363. #line 9076 "./typica.w"
  4364. }
  4365. else
  4366. {
  4367. /*398:*/
  4368. #line 9088 "./typica.w"
  4369. MeasurementModel*m;
  4370. foreach(m,modelSet)
  4371. {
  4372. m->newMeasurement(measure,tempcolumn);
  4373. }
  4374. /*:398*/
  4375. #line 9080 "./typica.w"
  4376. }
  4377. lastMeasurement.insert(tempcolumn,measure);
  4378. }
  4379. /*:397*//*400:*/
  4380. #line 9142 "./typica.w"
  4381. void ZoomLog::addToCurrentColumnSet(int column)
  4382. {
  4383. currentColumnSet.append(column);
  4384. }
  4385. void ZoomLog::clearCurrentColumnSet()
  4386. {
  4387. currentColumnSet.clear();
  4388. }
  4389. /*:400*//*402:*/
  4390. #line 9226 "./typica.w"
  4391. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4392. int annotationcolumn)
  4393. {
  4394. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4395. MeasurementModel*m;
  4396. if(lastMeasurement.contains(tempcolumn))
  4397. {
  4398. foreach(m,modelSet)
  4399. {
  4400. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4401. }
  4402. }
  4403. foreach(m,modelSet)
  4404. {
  4405. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4406. }
  4407. }
  4408. /*:402*//*403:*/
  4409. #line 9250 "./typica.w"
  4410. void ZoomLog::centerOn(int row)
  4411. {
  4412. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4413. }
  4414. /*:403*//*404:*/
  4415. #line 9260 "./typica.w"
  4416. void ZoomLog::clear()
  4417. {
  4418. MeasurementModel*m;
  4419. foreach(m,modelSet)
  4420. {
  4421. m->clear();
  4422. }
  4423. lastMeasurement.clear();
  4424. saveTempCols.clear();
  4425. saveControlCols.clear();
  4426. saveNoteCols.clear();
  4427. }
  4428. /*:404*//*405:*/
  4429. #line 9278 "./typica.w"
  4430. QVariant ZoomLog::data(int row,int column)const
  4431. {
  4432. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4433. Qt::DisplayRole);
  4434. }
  4435. int ZoomLog::rowCount()
  4436. {
  4437. return model_ms->rowCount();
  4438. }
  4439. /*:405*//*406:*/
  4440. #line 9301 "./typica.w"
  4441. bool ZoomLog::saveXML(QIODevice*device)
  4442. {
  4443. Units::Unit prevUnits= model_ms->displayUnits();
  4444. if(prevUnits!=Units::Fahrenheit)
  4445. {
  4446. model_ms->setDisplayUnits(Units::Fahrenheit);
  4447. }
  4448. XMLOutput writer(model_ms,device,0);
  4449. int c;
  4450. foreach(c,saveTempCols)
  4451. {
  4452. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4453. toString(),c);
  4454. }
  4455. foreach(c,saveControlCols)
  4456. {
  4457. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4458. toString(),c);
  4459. }
  4460. foreach(c,saveNoteCols)
  4461. {
  4462. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4463. toString(),c);
  4464. }
  4465. bool retval= writer.output();
  4466. if(prevUnits!=Units::Fahrenheit)
  4467. {
  4468. model_ms->setDisplayUnits(prevUnits);
  4469. }
  4470. return retval;
  4471. }
  4472. /*:406*//*407:*/
  4473. #line 9337 "./typica.w"
  4474. bool ZoomLog::saveCSV(QIODevice*device)
  4475. {
  4476. CSVOutput writer(currentModel,device,0);
  4477. int c;
  4478. foreach(c,saveTempCols)
  4479. {
  4480. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4481. toString(),c);
  4482. }
  4483. foreach(c,saveControlCols)
  4484. {
  4485. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4486. toString(),c);
  4487. }
  4488. foreach(c,saveNoteCols)
  4489. {
  4490. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4491. toString(),c);
  4492. }
  4493. return writer.output();
  4494. }
  4495. /*:407*//*408:*/
  4496. #line 9366 "./typica.w"
  4497. void ZoomLog::switchLOD(MeasurementModel*m)
  4498. {
  4499. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4500. setModel(m);
  4501. currentModel= m;
  4502. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4503. }
  4504. void ZoomLog::LOD_ms()
  4505. {
  4506. switchLOD(model_ms);
  4507. }
  4508. void ZoomLog::LOD_1s()
  4509. {
  4510. switchLOD(model_1s);
  4511. }
  4512. void ZoomLog::LOD_5s()
  4513. {
  4514. switchLOD(model_5s);
  4515. }
  4516. void ZoomLog::LOD_10s()
  4517. {
  4518. switchLOD(model_10s);
  4519. }
  4520. void ZoomLog::LOD_15s()
  4521. {
  4522. switchLOD(model_15s);
  4523. }
  4524. void ZoomLog::LOD_30s()
  4525. {
  4526. switchLOD(model_30s);
  4527. }
  4528. void ZoomLog::LOD_1m()
  4529. {
  4530. switchLOD(model_1m);
  4531. }
  4532. /*:408*//*409:*/
  4533. #line 9414 "./typica.w"
  4534. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4535. {
  4536. model_ms->setDisplayUnits(scale);
  4537. model_1s->setDisplayUnits(scale);
  4538. model_5s->setDisplayUnits(scale);
  4539. model_10s->setDisplayUnits(scale);
  4540. model_15s->setDisplayUnits(scale);
  4541. model_30s->setDisplayUnits(scale);
  4542. model_1m->setDisplayUnits(scale);
  4543. }
  4544. Units::Unit ZoomLog::displayUnits()
  4545. {
  4546. return model_ms->displayUnits();
  4547. }
  4548. /*:409*//*410:*/
  4549. #line 9434 "./typica.w"
  4550. QString ZoomLog::lastTime(int series)
  4551. {
  4552. Measurement measure= lastMeasurement.value(series);
  4553. QTime time= measure.time();
  4554. return time.toString("h:mm:ss.zzz");
  4555. }
  4556. /*:410*//*411:*/
  4557. #line 9444 "./typica.w"
  4558. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4559. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4560. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4561. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4562. {
  4563. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4564. setSelectionMode(QAbstractItemView::NoSelection);
  4565. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4566. model_30s<<model_1m;
  4567. currentModel= model_30s;
  4568. setModel(currentModel);
  4569. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4570. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4571. this,SLOT(persistColumnResize(int,int,int)));
  4572. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4573. this,SLOT(restoreColumnWidths()));
  4574. }
  4575. /*:411*//*412:*/
  4576. #line 9467 "./typica.w"
  4577. void ZoomLog::setHeaderData(int section,QString text)
  4578. {
  4579. MeasurementModel*m;
  4580. foreach(m,modelSet)
  4581. {
  4582. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4583. }
  4584. }
  4585. /*:412*//*413:*/
  4586. #line 9485 "./typica.w"
  4587. void ZoomLog::addOutputTemperatureColumn(int column)
  4588. {
  4589. saveTempCols.append(column);
  4590. }
  4591. void ZoomLog::addOutputControlColumn(int column)
  4592. {
  4593. saveControlCols.append(column);
  4594. }
  4595. void ZoomLog::addOutputAnnotationColumn(int column)
  4596. {
  4597. saveNoteCols.append(column);
  4598. }
  4599. void ZoomLog::clearOutputColumns()
  4600. {
  4601. saveTempCols.clear();
  4602. saveControlCols.clear();
  4603. saveNoteCols.clear();
  4604. }
  4605. /*:413*//*414:*/
  4606. #line 9511 "./typica.w"
  4607. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4608. {
  4609. /*629:*/
  4610. #line 13657 "./typica.w"
  4611. QSettings settings;
  4612. /*630:*/
  4613. #line 13670 "./typica.w"
  4614. QWidget*topLevelWidget= this;
  4615. while(topLevelWidget->parentWidget())
  4616. {
  4617. topLevelWidget= topLevelWidget->parentWidget();
  4618. }
  4619. /*:630*/
  4620. #line 13659 "./typica.w"
  4621. settings.setValue(QString("columnWidths/%1/%2/%3").
  4622. arg(topLevelWidget->objectName()).
  4623. arg(objectName()).arg(column),
  4624. QVariant(newsize));
  4625. /*:629*/
  4626. #line 9514 "./typica.w"
  4627. }
  4628. void ZoomLog::restoreColumnWidths()
  4629. {
  4630. /*632:*/
  4631. #line 13690 "./typica.w"
  4632. QSettings settings;
  4633. /*630:*/
  4634. #line 13670 "./typica.w"
  4635. QWidget*topLevelWidget= this;
  4636. while(topLevelWidget->parentWidget())
  4637. {
  4638. topLevelWidget= topLevelWidget->parentWidget();
  4639. }
  4640. /*:630*/
  4641. #line 13692 "./typica.w"
  4642. QString baseKey=
  4643. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4644. arg(objectName());
  4645. for(int i= 0;i<model()->columnCount();i++)
  4646. {
  4647. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4648. if(settings.contains(key))
  4649. {
  4650. setColumnWidth(i,settings.value(key).toInt());
  4651. }
  4652. }
  4653. /*:632*/
  4654. #line 9519 "./typica.w"
  4655. }
  4656. void ZoomLog::setVisible(bool visibility)
  4657. {
  4658. QTableView::setVisible(visibility);
  4659. }
  4660. void ZoomLog::showEvent(QShowEvent*)
  4661. {
  4662. /*632:*/
  4663. #line 13690 "./typica.w"
  4664. QSettings settings;
  4665. /*630:*/
  4666. #line 13670 "./typica.w"
  4667. QWidget*topLevelWidget= this;
  4668. while(topLevelWidget->parentWidget())
  4669. {
  4670. topLevelWidget= topLevelWidget->parentWidget();
  4671. }
  4672. /*:630*/
  4673. #line 13692 "./typica.w"
  4674. QString baseKey=
  4675. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4676. arg(objectName());
  4677. for(int i= 0;i<model()->columnCount();i++)
  4678. {
  4679. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4680. if(settings.contains(key))
  4681. {
  4682. setColumnWidth(i,settings.value(key).toInt());
  4683. }
  4684. }
  4685. /*:632*/
  4686. #line 9529 "./typica.w"
  4687. }
  4688. /*:414*/
  4689. #line 549 "./typica.w"
  4690. /*423:*/
  4691. #line 9762 "./typica.w"
  4692. bool MeasurementList::operator<(const MeasurementList&other)const
  4693. {
  4694. return this->first().toTime()<other.first().toTime();
  4695. }
  4696. bool MeasurementList::operator==(const MeasurementList&other)const
  4697. {
  4698. return this->first().toTime()==other.first().toTime();
  4699. }
  4700. /*:423*//*424:*/
  4701. #line 9778 "./typica.w"
  4702. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4703. {
  4704. return QModelIndex();
  4705. }
  4706. /*:424*//*425:*/
  4707. #line 9788 "./typica.w"
  4708. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4709. {
  4710. if(measure.scale()==Units::Unitless)
  4711. {
  4712. controlColumns->insert(tempcolumn,true);
  4713. }
  4714. else
  4715. {
  4716. controlColumns->insert(tempcolumn,false);
  4717. }
  4718. MeasurementList*temp;
  4719. temp= new MeasurementList;
  4720. temp->append(QVariant(measure.time()));
  4721. /*426:*/
  4722. #line 9847 "./typica.w"
  4723. /*427:*/
  4724. #line 9892 "./typica.w"
  4725. QList<MeasurementList*> ::iterator i= lastInsertion;
  4726. bool quickscan= false;
  4727. if(entries->size()> 5)
  4728. {
  4729. if(**i<*temp)
  4730. {
  4731. i+= 1;
  4732. for(int j= 10;j> 0;j--)
  4733. {
  4734. if(i!=entries->end())
  4735. {
  4736. if(**i<*temp)
  4737. {
  4738. i+= 1;
  4739. }
  4740. else
  4741. {
  4742. quickscan= true;
  4743. break;
  4744. }
  4745. }
  4746. else
  4747. {
  4748. quickscan= true;
  4749. break;
  4750. }
  4751. }
  4752. }
  4753. else
  4754. {
  4755. if(**i==*temp)
  4756. {
  4757. quickscan= true;
  4758. }
  4759. }
  4760. }
  4761. /*:427*/
  4762. #line 9848 "./typica.w"
  4763. if(quickscan==false)
  4764. {
  4765. i= entries->begin();
  4766. QList<MeasurementList*> ::iterator u= entries->end();
  4767. QList<MeasurementList*> ::iterator midpoint;
  4768. int n= u-i;
  4769. int rA;
  4770. while(n> 0)
  4771. {
  4772. rA= n>>1;
  4773. midpoint= i+rA;
  4774. if(**midpoint<*temp)
  4775. {
  4776. i= midpoint+1;
  4777. n-= rA+1;
  4778. }
  4779. else
  4780. {
  4781. n= rA;
  4782. }
  4783. }
  4784. }
  4785. /*:426*/
  4786. #line 9802 "./typica.w"
  4787. MeasurementList*newEntry;
  4788. int insertion;
  4789. if(i!=entries->end())
  4790. {
  4791. insertion= entries->indexOf(*i);
  4792. if((*i)->first().toTime()==measure.time())
  4793. {
  4794. /*428:*/
  4795. #line 9934 "./typica.w"
  4796. if((*i)->size()<tempcolumn+1)
  4797. {
  4798. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4799. {
  4800. (*i)->append(QVariant());
  4801. }
  4802. }
  4803. (*i)->replace(tempcolumn,measure);
  4804. lastInsertion= i;
  4805. emit dataChanged(createIndex(insertion,tempcolumn),
  4806. createIndex(insertion,tempcolumn));
  4807. lastTemperature->insert(tempcolumn,insertion);
  4808. /*:428*/
  4809. #line 9810 "./typica.w"
  4810. }
  4811. else
  4812. {
  4813. /*429:*/
  4814. #line 9952 "./typica.w"
  4815. beginInsertRows(QModelIndex(),insertion,insertion);
  4816. newEntry= new MeasurementList;
  4817. newEntry->append(QVariant(measure.time()));
  4818. for(int j= 0;j<tempcolumn+1;j++)
  4819. {
  4820. newEntry->append(QVariant());
  4821. }
  4822. newEntry->replace(tempcolumn,measure);
  4823. lastInsertion= entries->insert(i,newEntry);
  4824. endInsertRows();
  4825. lastTemperature->insert(tempcolumn,insertion);
  4826. /*:429*/
  4827. #line 9814 "./typica.w"
  4828. }
  4829. }
  4830. else
  4831. {
  4832. /*430:*/
  4833. #line 9970 "./typica.w"
  4834. insertion= entries->size();
  4835. /*429:*/
  4836. #line 9952 "./typica.w"
  4837. beginInsertRows(QModelIndex(),insertion,insertion);
  4838. newEntry= new MeasurementList;
  4839. newEntry->append(QVariant(measure.time()));
  4840. for(int j= 0;j<tempcolumn+1;j++)
  4841. {
  4842. newEntry->append(QVariant());
  4843. }
  4844. newEntry->replace(tempcolumn,measure);
  4845. lastInsertion= entries->insert(i,newEntry);
  4846. endInsertRows();
  4847. lastTemperature->insert(tempcolumn,insertion);
  4848. /*:429*/
  4849. #line 9972 "./typica.w"
  4850. /*:430*/
  4851. #line 9819 "./typica.w"
  4852. }
  4853. if(tempcolumn>=colcount)
  4854. {
  4855. colcount= tempcolumn+1;
  4856. }
  4857. emit rowChanged(insertion);
  4858. delete temp;
  4859. }
  4860. /*:425*//*431:*/
  4861. #line 9982 "./typica.w"
  4862. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4863. int annotationColumn)
  4864. {
  4865. int r;
  4866. if(lastTemperature->contains(tempcolumn))
  4867. {
  4868. r= lastTemperature->value(tempcolumn);
  4869. }
  4870. else
  4871. {
  4872. r= 0;
  4873. }
  4874. if(r==0&&entries->size()==0)
  4875. {
  4876. /*432:*/
  4877. #line 10020 "./typica.w"
  4878. beginInsertRows(QModelIndex(),0,0);
  4879. MeasurementList*newEntry= new MeasurementList;
  4880. newEntry->append(QVariant(QTime(0,0,0,0)));
  4881. entries->append(newEntry);
  4882. endInsertRows();
  4883. /*:432*/
  4884. #line 9997 "./typica.w"
  4885. }
  4886. MeasurementList*row= entries->at(r);
  4887. if(row->size()<=annotationColumn)
  4888. {
  4889. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4890. {
  4891. row->append(QVariant());
  4892. }
  4893. }
  4894. row->replace(annotationColumn,annotation);
  4895. emit dataChanged(createIndex(r,annotationColumn),
  4896. createIndex(r,annotationColumn));
  4897. emit rowChanged(r);
  4898. if(annotationColumn> colcount-1)
  4899. {
  4900. colcount= annotationColumn+1;
  4901. }
  4902. }
  4903. /*:431*//*433:*/
  4904. #line 10031 "./typica.w"
  4905. void MeasurementModel::clear()
  4906. {
  4907. beginRemoveRows(QModelIndex(),0,entries->size());
  4908. while(entries->size()!=0)
  4909. {
  4910. MeasurementList*row= entries->takeFirst();
  4911. delete row;
  4912. }
  4913. endRemoveRows();
  4914. colcount= hData->size();
  4915. lastTemperature->clear();
  4916. reset();
  4917. }
  4918. /*:433*//*434:*/
  4919. #line 10064 "./typica.w"
  4920. bool MeasurementModel::setData(const QModelIndex&index,
  4921. const QVariant&value,int role)
  4922. {
  4923. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4924. {
  4925. return false;
  4926. }
  4927. /*435:*/
  4928. #line 10096 "./typica.w"
  4929. bool valid= false;
  4930. if(index.isValid())
  4931. {
  4932. if(index.row()<entries->size())
  4933. {
  4934. if(index.column()<colcount)
  4935. {
  4936. valid= true;
  4937. }
  4938. }
  4939. }
  4940. /*:435*/
  4941. #line 10072 "./typica.w"
  4942. if(!valid)
  4943. {
  4944. return false;
  4945. }
  4946. MeasurementList*row= entries->at(index.row());
  4947. if(index.column()>=row->size())
  4948. {
  4949. /*436:*/
  4950. #line 10113 "./typica.w"
  4951. for(int i= row->size()-1;i<index.column();i++)
  4952. {
  4953. row->append(QVariant());
  4954. }
  4955. /*:436*/
  4956. #line 10080 "./typica.w"
  4957. }
  4958. if(index.column()==0)
  4959. {
  4960. /*437:*/
  4961. #line 10128 "./typica.w"
  4962. QTime time;
  4963. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  4964. {
  4965. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  4966. {
  4967. return false;
  4968. }
  4969. }
  4970. row= entries->takeAt(index.row());
  4971. row->replace(index.column(),QVariant(time));
  4972. MeasurementList*temp= row;
  4973. /*426:*/
  4974. #line 9847 "./typica.w"
  4975. /*427:*/
  4976. #line 9892 "./typica.w"
  4977. QList<MeasurementList*> ::iterator i= lastInsertion;
  4978. bool quickscan= false;
  4979. if(entries->size()> 5)
  4980. {
  4981. if(**i<*temp)
  4982. {
  4983. i+= 1;
  4984. for(int j= 10;j> 0;j--)
  4985. {
  4986. if(i!=entries->end())
  4987. {
  4988. if(**i<*temp)
  4989. {
  4990. i+= 1;
  4991. }
  4992. else
  4993. {
  4994. quickscan= true;
  4995. break;
  4996. }
  4997. }
  4998. else
  4999. {
  5000. quickscan= true;
  5001. break;
  5002. }
  5003. }
  5004. }
  5005. else
  5006. {
  5007. if(**i==*temp)
  5008. {
  5009. quickscan= true;
  5010. }
  5011. }
  5012. }
  5013. /*:427*/
  5014. #line 9848 "./typica.w"
  5015. if(quickscan==false)
  5016. {
  5017. i= entries->begin();
  5018. QList<MeasurementList*> ::iterator u= entries->end();
  5019. QList<MeasurementList*> ::iterator midpoint;
  5020. int n= u-i;
  5021. int rA;
  5022. while(n> 0)
  5023. {
  5024. rA= n>>1;
  5025. midpoint= i+rA;
  5026. if(**midpoint<*temp)
  5027. {
  5028. i= midpoint+1;
  5029. n-= rA+1;
  5030. }
  5031. else
  5032. {
  5033. n= rA;
  5034. }
  5035. }
  5036. }
  5037. /*:426*/
  5038. #line 10140 "./typica.w"
  5039. entries->insert(i,row);
  5040. int newRow= entries->indexOf(*i);
  5041. if(newRow<index.row())
  5042. {
  5043. emit dataChanged(createIndex(newRow,index.column()),index);
  5044. }
  5045. else
  5046. {
  5047. emit dataChanged(index,createIndex(newRow,index.column()));
  5048. }
  5049. /*:437*/
  5050. #line 10084 "./typica.w"
  5051. }
  5052. else
  5053. {
  5054. /*438:*/
  5055. #line 10154 "./typica.w"
  5056. row->replace(index.column(),value);
  5057. emit dataChanged(index,index);
  5058. /*:438*/
  5059. #line 10088 "./typica.w"
  5060. }
  5061. return true;
  5062. }
  5063. /*:434*//*439:*/
  5064. #line 10162 "./typica.w"
  5065. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5066. unit(Units::Fahrenheit),hData(new QStringList),
  5067. lastTemperature(new QHash<int,int> ),
  5068. controlColumns(new QHash<int,bool> )
  5069. {
  5070. colcount= 1;
  5071. entries= new QList<MeasurementList*> ;
  5072. lastInsertion= entries->begin();
  5073. hData->append(tr("Time"));
  5074. }
  5075. /*:439*//*440:*/
  5076. #line 10176 "./typica.w"
  5077. MeasurementModel::~MeasurementModel()
  5078. {
  5079. clear();
  5080. delete entries;
  5081. delete hData;
  5082. }
  5083. /*:440*//*441:*/
  5084. #line 10188 "./typica.w"
  5085. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5086. {
  5087. if(parent==QModelIndex())
  5088. {
  5089. return entries->size();
  5090. }
  5091. return 0;
  5092. }
  5093. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5094. {
  5095. if(parent==QModelIndex())
  5096. {
  5097. return colcount;
  5098. }
  5099. return 0;
  5100. }
  5101. /*:441*//*442:*/
  5102. #line 10215 "./typica.w"
  5103. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5104. const QVariant&value,int)
  5105. {
  5106. if(orientation==Qt::Horizontal)
  5107. {
  5108. if(hData->size()<section+1)
  5109. {
  5110. for(int i= hData->size();i<section+1;i++)
  5111. {
  5112. if(colcount<i)
  5113. {
  5114. beginInsertColumns(QModelIndex(),i,i);
  5115. }
  5116. hData->append(QString());
  5117. if(colcount<i)
  5118. {
  5119. endInsertColumns();
  5120. }
  5121. }
  5122. }
  5123. hData->replace(section,value.toString());
  5124. emit headerDataChanged(orientation,section,section);
  5125. if(colcount<section+1)
  5126. {
  5127. colcount= section+1;
  5128. }
  5129. return true;
  5130. }
  5131. return false;
  5132. }
  5133. /*:442*//*443:*/
  5134. #line 10255 "./typica.w"
  5135. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5136. {
  5137. beginResetModel();
  5138. unit= scale;
  5139. endResetModel();
  5140. }
  5141. Units::Unit MeasurementModel::displayUnits()
  5142. {
  5143. return unit;
  5144. }
  5145. /*:443*//*444:*/
  5146. #line 10281 "./typica.w"
  5147. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5148. {
  5149. /*435:*/
  5150. #line 10096 "./typica.w"
  5151. bool valid= false;
  5152. if(index.isValid())
  5153. {
  5154. if(index.row()<entries->size())
  5155. {
  5156. if(index.column()<colcount)
  5157. {
  5158. valid= true;
  5159. }
  5160. }
  5161. }
  5162. /*:435*/
  5163. #line 10284 "./typica.w"
  5164. if(!valid)
  5165. {
  5166. return QVariant();
  5167. }
  5168. MeasurementList*row= entries->at(index.row());
  5169. if(role==Qt::UserRole)
  5170. {
  5171. return QVariant(row->at(index.column()));
  5172. }
  5173. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5174. {
  5175. if(index.column()> row->size())
  5176. {
  5177. return QVariant();
  5178. }
  5179. else
  5180. {
  5181. if(index.column()==0)
  5182. {
  5183. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5184. }
  5185. else if(lastTemperature->contains(index.column()))
  5186. {
  5187. QVariantMap v= row->at(index.column()).toMap();
  5188. if(!v.contains("measurement"))
  5189. {
  5190. return QVariant();
  5191. }
  5192. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5193. {
  5194. return v.value("measurement");
  5195. }
  5196. else
  5197. {
  5198. if(v.contains("relative"))
  5199. {
  5200. if(v.value("relative").toBool())
  5201. {
  5202. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5203. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5204. }
  5205. }
  5206. return QVariant(QString("%1").
  5207. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5208. (Units::Unit)(v.value("unit").toInt()),unit)));
  5209. }
  5210. }
  5211. return QVariant(row->at(index.column()).toString());
  5212. }
  5213. }
  5214. return QVariant();
  5215. }
  5216. /*:444*//*445:*/
  5217. #line 10340 "./typica.w"
  5218. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5219. int role)const
  5220. {
  5221. if(orientation==Qt::Horizontal)
  5222. {
  5223. if(role==Qt::DisplayRole)
  5224. {
  5225. if(section<hData->size())
  5226. {
  5227. return QVariant(hData->at(section));
  5228. }
  5229. }
  5230. }
  5231. return QVariant();
  5232. }
  5233. /*:445*//*446:*/
  5234. #line 10367 "./typica.w"
  5235. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5236. {
  5237. /*435:*/
  5238. #line 10096 "./typica.w"
  5239. bool valid= false;
  5240. if(index.isValid())
  5241. {
  5242. if(index.row()<entries->size())
  5243. {
  5244. if(index.column()<colcount)
  5245. {
  5246. valid= true;
  5247. }
  5248. }
  5249. }
  5250. /*:435*/
  5251. #line 10370 "./typica.w"
  5252. if(valid)
  5253. {
  5254. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5255. }
  5256. return 0;
  5257. }
  5258. /*:446*//*447:*/
  5259. #line 10382 "./typica.w"
  5260. QModelIndex MeasurementModel::index(int row,int column,
  5261. const QModelIndex&parent)const
  5262. {
  5263. if(parent==QModelIndex())
  5264. {
  5265. if(row<entries->size()&&entries->isEmpty()==false)
  5266. {
  5267. if(column<entries->at(row)->size())
  5268. {
  5269. return createIndex(row,column);
  5270. }
  5271. }
  5272. }
  5273. return QModelIndex();
  5274. }
  5275. /*:447*/
  5276. #line 550 "./typica.w"
  5277. /*449:*/
  5278. #line 10433 "./typica.w"
  5279. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5280. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5281. {
  5282. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5283. }
  5284. /*:449*//*450:*/
  5285. #line 10448 "./typica.w"
  5286. void AnnotationButton::annotate()
  5287. {
  5288. if(note.contains("%1"))
  5289. {
  5290. count++;
  5291. emit annotation(note.arg(count),tc,ac);
  5292. }
  5293. else
  5294. {
  5295. emit annotation(note,tc,ac);
  5296. }
  5297. }
  5298. /*:450*//*451:*/
  5299. #line 10466 "./typica.w"
  5300. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5301. {
  5302. tc= tempcolumn;
  5303. }
  5304. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5305. {
  5306. ac= annotationcolumn;
  5307. }
  5308. void AnnotationButton::setAnnotation(const QString&annotation)
  5309. {
  5310. note= annotation;
  5311. }
  5312. /*:451*//*452:*/
  5313. #line 10485 "./typica.w"
  5314. void AnnotationButton::resetCount()
  5315. {
  5316. count= 0;
  5317. }
  5318. /*:452*/
  5319. #line 551 "./typica.w"
  5320. /*457:*/
  5321. #line 10568 "./typica.w"
  5322. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5323. const QString&postt,
  5324. QWidget*parent)
  5325. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5326. {
  5327. resetChange();
  5328. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5329. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5330. }
  5331. /*:457*//*458:*/
  5332. #line 10585 "./typica.w"
  5333. void AnnotationSpinBox::resetChange()
  5334. {
  5335. change= true;
  5336. }
  5337. /*:458*//*459:*/
  5338. #line 10596 "./typica.w"
  5339. void AnnotationSpinBox::annotate()
  5340. {
  5341. if(change)
  5342. {
  5343. change= false;
  5344. emit annotation(QString("%1%2%3").arg(pretext).
  5345. arg(value()).arg(posttext),tc,ac);
  5346. }
  5347. }
  5348. /*:459*//*460:*/
  5349. #line 10609 "./typica.w"
  5350. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5351. {
  5352. tc= tempcolumn;
  5353. }
  5354. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5355. {
  5356. ac= annotationcolumn;
  5357. }
  5358. void AnnotationSpinBox::setPretext(const QString&pret)
  5359. {
  5360. pretext= pret;
  5361. }
  5362. void AnnotationSpinBox::setPosttext(const QString&postt)
  5363. {
  5364. posttext= postt;
  5365. }
  5366. /*:460*/
  5367. #line 552 "./typica.w"
  5368. /*467:*/
  5369. #line 10778 "./typica.w"
  5370. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5371. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5372. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5373. stopAction(new QAction(tr("Stop"),NULL)),
  5374. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5375. relative(QTime::currentTime()),base(QTime(0,0,0))
  5376. {
  5377. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5378. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5379. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5380. clock.setInterval(500);
  5381. clock.setSingleShot(false);
  5382. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5383. setSegmentStyle(Filled);
  5384. updateDisplay();
  5385. }
  5386. /*:467*//*468:*/
  5387. #line 10799 "./typica.w"
  5388. void TimerDisplay::updateTime()
  5389. {
  5390. QTime time;
  5391. int cseconds= 0;
  5392. int oseconds= 0;
  5393. int r= 0;
  5394. QTime nt= QTime(0,0,0);
  5395. int n= 0;
  5396. int bseconds= 0;
  5397. switch(m)
  5398. {
  5399. case TimerDisplay::CountUp:
  5400. /*469:*/
  5401. #line 10831 "./typica.w"
  5402. /*470:*/
  5403. #line 10844 "./typica.w"
  5404. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5405. time= QTime::currentTime();
  5406. cseconds= TIMETOINT(time);
  5407. oseconds= TIMETOINT(relative);
  5408. r= cseconds-oseconds;
  5409. /*:470*/
  5410. #line 10832 "./typica.w"
  5411. nt= nt.addSecs(r);
  5412. if(nt!=s)
  5413. {
  5414. s= nt;
  5415. emit valueChanged(s);
  5416. }
  5417. /*:469*/
  5418. #line 10812 "./typica.w"
  5419. ;
  5420. break;
  5421. case TimerDisplay::CountDown:
  5422. /*471:*/
  5423. #line 10856 "./typica.w"
  5424. if(s> QTime(0,0,0))
  5425. {
  5426. /*470:*/
  5427. #line 10844 "./typica.w"
  5428. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5429. time= QTime::currentTime();
  5430. cseconds= TIMETOINT(time);
  5431. oseconds= TIMETOINT(relative);
  5432. r= cseconds-oseconds;
  5433. /*:470*/
  5434. #line 10859 "./typica.w"
  5435. bseconds= TIMETOINT(base);
  5436. n= bseconds-r;
  5437. nt= nt.addSecs(n);
  5438. if(nt!=s)
  5439. {
  5440. s= nt;
  5441. emit valueChanged(s);
  5442. }
  5443. }else{
  5444. stopTimer();
  5445. }
  5446. /*:471*/
  5447. #line 10815 "./typica.w"
  5448. ;
  5449. break;
  5450. case TimerDisplay::Clock:
  5451. /*472:*/
  5452. #line 10875 "./typica.w"
  5453. time= QTime::currentTime();
  5454. if(time!=s)
  5455. {
  5456. s= time;
  5457. emit valueChanged(s);
  5458. }
  5459. /*:472*/
  5460. #line 10818 "./typica.w"
  5461. ;
  5462. break;
  5463. default:
  5464. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5465. break;
  5466. }
  5467. updateDisplay();
  5468. }
  5469. /*:468*//*473:*/
  5470. #line 10887 "./typica.w"
  5471. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5472. void TimerDisplay::startTimer()
  5473. {
  5474. if(!running)
  5475. {
  5476. relative= QTime::currentTime();
  5477. if(ar)
  5478. {
  5479. reset();
  5480. }
  5481. else
  5482. {
  5483. relative= TIMESUBTRACT(relative,s);
  5484. }
  5485. if(m==Clock)
  5486. {
  5487. updateTime();
  5488. }
  5489. base= s;
  5490. clock.start();
  5491. running= true;
  5492. emit runStateChanged(true);
  5493. }
  5494. }
  5495. /*:473*//*474:*/
  5496. #line 10917 "./typica.w"
  5497. void TimerDisplay::stopTimer()
  5498. {
  5499. if(running)
  5500. {
  5501. clock.stop();
  5502. running= false;
  5503. emit runStateChanged(false);
  5504. }
  5505. }
  5506. /*:474*//*475:*/
  5507. #line 10930 "./typica.w"
  5508. TimerDisplay::~TimerDisplay()
  5509. {
  5510. clock.stop();
  5511. }
  5512. /*:475*//*476:*/
  5513. #line 10939 "./typica.w"
  5514. void TimerDisplay::setCountUpMode()
  5515. {
  5516. m= TimerDisplay::CountUp;
  5517. }
  5518. void TimerDisplay::setCountDownMode()
  5519. {
  5520. m= TimerDisplay::CountDown;
  5521. }
  5522. void TimerDisplay::setClockMode()
  5523. {
  5524. m= TimerDisplay::Clock;
  5525. }
  5526. /*:476*//*477:*/
  5527. #line 10957 "./typica.w"
  5528. QString TimerDisplay::value()
  5529. {
  5530. return s.toString(f);
  5531. }
  5532. QTime TimerDisplay::seconds()
  5533. {
  5534. return s;
  5535. }
  5536. TimerDisplay::TimerMode TimerDisplay::mode()
  5537. {
  5538. return m;
  5539. }
  5540. bool TimerDisplay::isRunning()
  5541. {
  5542. return running;
  5543. }
  5544. QTime TimerDisplay::resetValue()
  5545. {
  5546. return r;
  5547. }
  5548. QString TimerDisplay::displayFormat()
  5549. {
  5550. return f;
  5551. }
  5552. bool TimerDisplay::autoReset()
  5553. {
  5554. return ar;
  5555. }
  5556. /*:477*//*478:*/
  5557. #line 10995 "./typica.w"
  5558. void TimerDisplay::setTimer(QTime value)
  5559. {
  5560. if(value.isValid())
  5561. {
  5562. s= value;
  5563. updateDisplay();
  5564. emit valueChanged(value);
  5565. }
  5566. }
  5567. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5568. {
  5569. m= mode;
  5570. }
  5571. void TimerDisplay::setResetValue(QTime value)
  5572. {
  5573. r= value;
  5574. }
  5575. void TimerDisplay::setDisplayFormat(QString format)
  5576. {
  5577. f= format;
  5578. setNumDigits(format.length());
  5579. }
  5580. void TimerDisplay::setAutoReset(bool reset)
  5581. {
  5582. ar= reset;
  5583. }
  5584. /*:478*//*479:*/
  5585. #line 11030 "./typica.w"
  5586. void TimerDisplay::copyTimer()
  5587. {
  5588. QApplication::clipboard()->setText(value());
  5589. }
  5590. /*:479*//*480:*/
  5591. #line 11039 "./typica.w"
  5592. void TimerDisplay::reset()
  5593. {
  5594. if(!running)
  5595. {
  5596. s= r;
  5597. updateDisplay();
  5598. }
  5599. }
  5600. /*:480*//*481:*/
  5601. #line 11052 "./typica.w"
  5602. void TimerDisplay::updateDisplay()
  5603. {
  5604. display(value());
  5605. }
  5606. /*:481*/
  5607. #line 553 "./typica.w"
  5608. /*488:*/
  5609. #line 11177 "./typica.w"
  5610. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5611. {
  5612. int x= rect.x();
  5613. int y= rect.y();
  5614. QLayoutItem*item;
  5615. if(orientation==Qt::Horizontal)
  5616. {
  5617. /*489:*/
  5618. #line 11201 "./typica.w"
  5619. foreach(item,itemList)
  5620. {
  5621. int nextX= x+item->sizeHint().width()+spacing();
  5622. int right= x+item->sizeHint().width();
  5623. if(item==itemList.last())
  5624. {
  5625. right= rect.right();
  5626. }
  5627. int bottom= rect.bottom();
  5628. if(!testOnly)
  5629. {
  5630. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5631. }
  5632. x= nextX;
  5633. }
  5634. /*:489*/
  5635. #line 11185 "./typica.w"
  5636. }
  5637. else
  5638. {
  5639. /*490:*/
  5640. #line 11220 "./typica.w"
  5641. foreach(item,itemList)
  5642. {
  5643. int nextY= y+item->sizeHint().height()+spacing();
  5644. int bottom= y+item->sizeHint().height();
  5645. if(item==itemList.last())
  5646. {
  5647. bottom= rect.bottom();
  5648. }
  5649. int right= rect.right();
  5650. if(!testOnly)
  5651. {
  5652. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5653. }
  5654. y= nextY;
  5655. }
  5656. /*:490*/
  5657. #line 11189 "./typica.w"
  5658. }
  5659. return y;
  5660. }
  5661. /*:488*//*491:*/
  5662. #line 11244 "./typica.w"
  5663. QSize PackLayout::minimumSize()const
  5664. {
  5665. QSize size;
  5666. QLayoutItem*item;
  5667. foreach(item,itemList)
  5668. {
  5669. if(orientation==Qt::Horizontal)
  5670. {
  5671. size+= QSize(item->minimumSize().width(),0);
  5672. if(size.height()<item->minimumSize().height())
  5673. {
  5674. size.setHeight(item->minimumSize().height());
  5675. }
  5676. }
  5677. else
  5678. {
  5679. size+= QSize(0,item->minimumSize().height());
  5680. if(size.width()<item->minimumSize().width())
  5681. {
  5682. size.setWidth(item->minimumSize().width());
  5683. }
  5684. }
  5685. }
  5686. size+= QSize(2*margin(),2*margin());
  5687. return size;
  5688. }
  5689. /*:491*//*492:*/
  5690. #line 11276 "./typica.w"
  5691. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5692. QLayout(parent)
  5693. {
  5694. setMargin(margin);
  5695. setSpacing(spacing);
  5696. setOrientation(Qt::Horizontal);
  5697. }
  5698. PackLayout::PackLayout(int spacing)
  5699. {
  5700. setSpacing(spacing);
  5701. setOrientation(Qt::Horizontal);
  5702. }
  5703. /*:492*//*493:*/
  5704. #line 11294 "./typica.w"
  5705. PackLayout::~PackLayout()
  5706. {
  5707. QLayoutItem*item;
  5708. while((item= takeAt(0)))
  5709. {
  5710. delete item;
  5711. }
  5712. }
  5713. /*:493*//*494:*/
  5714. #line 11308 "./typica.w"
  5715. QLayoutItem*PackLayout::takeAt(int index)
  5716. {
  5717. if(index>=0&&index<itemList.size())
  5718. {
  5719. return itemList.takeAt(index);
  5720. }
  5721. else
  5722. {
  5723. return NULL;
  5724. }
  5725. }
  5726. /*:494*//*495:*/
  5727. #line 11324 "./typica.w"
  5728. QLayoutItem*PackLayout::itemAt(int index)const
  5729. {
  5730. if(index>=0&&index<itemList.size())
  5731. {
  5732. return itemList.at(index);
  5733. }
  5734. else
  5735. {
  5736. return NULL;
  5737. }
  5738. }
  5739. /*:495*//*496:*/
  5740. #line 11347 "./typica.w"
  5741. void PackLayout::addItem(QLayoutItem*item)
  5742. {
  5743. itemList.append(item);
  5744. }
  5745. /*:496*//*497:*/
  5746. #line 11355 "./typica.w"
  5747. int PackLayout::count()const
  5748. {
  5749. return itemList.size();
  5750. }
  5751. /*:497*//*498:*/
  5752. #line 11367 "./typica.w"
  5753. Qt::Orientations PackLayout::expandingDirections()const
  5754. {
  5755. return Qt::Vertical|Qt::Horizontal;
  5756. }
  5757. bool PackLayout::hasHeightForWidth()const
  5758. {
  5759. return false;
  5760. }
  5761. int PackLayout::heightForWidth(int width)const
  5762. {
  5763. return doLayout(QRect(0,0,width,0),true);
  5764. }
  5765. void PackLayout::setGeometry(const QRect&rect)
  5766. {
  5767. QLayout::setGeometry(rect);
  5768. doLayout(rect,false);
  5769. }
  5770. QSize PackLayout::sizeHint()const
  5771. {
  5772. return minimumSize();
  5773. }
  5774. /*:498*//*499:*/
  5775. #line 11398 "./typica.w"
  5776. void PackLayout::setOrientation(Qt::Orientations direction)
  5777. {
  5778. orientation= direction;
  5779. doLayout(geometry(),false);
  5780. }
  5781. /*:499*/
  5782. #line 554 "./typica.w"
  5783. /*501:*/
  5784. #line 11437 "./typica.w"
  5785. SceneButton::SceneButton():QGraphicsScene()
  5786. {
  5787. }
  5788. SceneButton::~SceneButton()
  5789. {
  5790. }
  5791. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5792. {
  5793. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5794. }
  5795. /*:501*/
  5796. #line 555 "./typica.w"
  5797. /*503:*/
  5798. #line 11483 "./typica.w"
  5799. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5800. Qt::Orientations orientation,
  5801. QWidget*parent,Qt::WindowFlags f):
  5802. QWidget(parent,f),label(new QGraphicsView()),
  5803. scene(new SceneButton())
  5804. {
  5805. layout= new PackLayout(this);
  5806. layout->setOrientation(orientation);
  5807. /*504:*/
  5808. #line 11503 "./typica.w"
  5809. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5810. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5811. label->setFrameShape(QFrame::NoFrame);
  5812. label->setInteractive(true);
  5813. /*:504*/
  5814. #line 11492 "./typica.w"
  5815. /*505:*/
  5816. #line 11514 "./typica.w"
  5817. scene->setBackgroundBrush(Qt::cyan);
  5818. text= scene->addText(labeltext);
  5819. if(orientation==Qt::Horizontal)
  5820. {
  5821. text->rotate(270.0);
  5822. }
  5823. label->setScene(scene);
  5824. /*:505*/
  5825. #line 11493 "./typica.w"
  5826. /*506:*/
  5827. #line 11532 "./typica.w"
  5828. if(orientation==Qt::Horizontal)
  5829. {
  5830. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5831. }
  5832. else
  5833. {
  5834. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5835. }
  5836. label->centerOn(text);
  5837. /*:506*/
  5838. #line 11494 "./typica.w"
  5839. /*507:*/
  5840. #line 11547 "./typica.w"
  5841. layout->addWidget(label);
  5842. layout->addWidget(widget);
  5843. if(orientation==Qt::Horizontal)
  5844. {
  5845. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5846. widget->sizeHint().height());
  5847. }
  5848. else
  5849. {
  5850. setMinimumSize(widget->sizeHint().width(),
  5851. widget->sizeHint().height()+label->sizeHint().height());
  5852. }
  5853. /*:507*/
  5854. #line 11495 "./typica.w"
  5855. }
  5856. /*:503*//*508:*/
  5857. #line 11564 "./typica.w"
  5858. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5859. {
  5860. scene->setBackgroundBrush(background);
  5861. }
  5862. void WidgetDecorator::setTextColor(QColor color)
  5863. {
  5864. text->setDefaultTextColor(color);
  5865. }
  5866. /*:508*//*509:*/
  5867. #line 11577 "./typica.w"
  5868. WidgetDecorator::~WidgetDecorator()
  5869. {
  5870. }
  5871. /*:509*/
  5872. #line 556 "./typica.w"
  5873. /*514:*/
  5874. #line 11676 "./typica.w"
  5875. void LogEditWindow::addTheRows()
  5876. {
  5877. QTime s= startTime->time();
  5878. while(s<endTime->time())
  5879. {
  5880. model->newMeasurement(Measurement(0,s),1);
  5881. s= s.addSecs(interval->value());
  5882. }
  5883. model->newMeasurement(Measurement(0,endTime->time()),1);
  5884. }
  5885. /*:514*//*515:*/
  5886. #line 11690 "./typica.w"
  5887. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5888. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5889. addRowsLayout(new QHBoxLayout(NULL)),
  5890. startTimeLabel(new QLabel("Start Time")),
  5891. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5892. endTimeLabel(new QLabel("End Time")),
  5893. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5894. intervalLabel(new QLabel("Interval (seconds)")),
  5895. interval(new QSpinBox()),
  5896. addRows(new QPushButton("Add Rows")),
  5897. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5898. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5899. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5900. model(new MeasurementModel()),
  5901. log(new QTableView())
  5902. {
  5903. /*516:*/
  5904. #line 11727 "./typica.w"
  5905. QSettings settings;
  5906. resize(settings.value("logSize",QSize(620,400)).toSize());
  5907. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5908. /*:516*/
  5909. #line 11707 "./typica.w"
  5910. /*517:*/
  5911. #line 11740 "./typica.w"
  5912. mainLayout->setOrientation(Qt::Vertical);
  5913. addRowsLayout->addSpacing(10);
  5914. addRowsLayout->addWidget(startTimeLabel);
  5915. addRowsLayout->addWidget(startTime);
  5916. addRowsLayout->addSpacing(10);
  5917. startTime->setDisplayFormat("mm:ss");
  5918. addRowsLayout->addWidget(endTimeLabel);
  5919. addRowsLayout->addWidget(endTime);
  5920. addRowsLayout->addSpacing(10);
  5921. endTime->setDisplayFormat("mm:ss");
  5922. addRowsLayout->addWidget(intervalLabel);
  5923. addRowsLayout->addWidget(interval);
  5924. addRowsLayout->addSpacing(10);
  5925. interval->setRange(0,60);
  5926. interval->setValue(30);
  5927. addRowsLayout->addWidget(addRows);
  5928. addRowsLayout->addSpacing(10);
  5929. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5930. /*:517*/
  5931. #line 11708 "./typica.w"
  5932. /*518:*/
  5933. #line 11763 "./typica.w"
  5934. model->setHeaderData(0,Qt::Horizontal,"Time");
  5935. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5936. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5937. model->clear();
  5938. /*:518*/
  5939. #line 11709 "./typica.w"
  5940. /*519:*/
  5941. #line 11772 "./typica.w"
  5942. log->setModel(model);
  5943. log->setColumnWidth(0,100);
  5944. log->setColumnWidth(1,100);
  5945. log->setColumnWidth(2,100);
  5946. /*:519*/
  5947. #line 11710 "./typica.w"
  5948. mainLayout->addItem(addRowsLayout);
  5949. mainLayout->addWidget(log);
  5950. centralWidget->setLayout(mainLayout);
  5951. setCentralWidget(centralWidget);
  5952. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5953. fileMenu->addAction(openXml);
  5954. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5955. fileMenu->addAction(saveXml);
  5956. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  5957. fileMenu->addAction(saveCsv);
  5958. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  5959. }
  5960. /*:515*//*520:*/
  5961. #line 11783 "./typica.w"
  5962. void LogEditWindow::saveXML()
  5963. {
  5964. QSettings settings;
  5965. QString lastDir= settings.value("lastDirectory").toString();
  5966. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  5967. lastDir,"",0);
  5968. QFile file(filename);
  5969. XMLOutput writer(model,&file,0);
  5970. writer.addTemperatureColumn("Temperature",1);
  5971. writer.addAnnotationColumn("Annotation",2);
  5972. if(writer.output())
  5973. {
  5974. QFileInfo info(filename);
  5975. QDir directory= info.dir();
  5976. lastDir= directory.path();
  5977. settings.setValue("lastDirectory",lastDir);
  5978. }
  5979. }
  5980. void LogEditWindow::saveCSV()
  5981. {
  5982. QSettings settings;
  5983. QString lastDir= settings.value("lastDirectory").toString();
  5984. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  5985. lastDir,"",0);
  5986. QFile file(filename);
  5987. CSVOutput writer(model,&file,0);
  5988. writer.addTemperatureColumn("Temperature",1);
  5989. writer.addAnnotationColumn("Annotation",2);
  5990. if(writer.output())
  5991. {
  5992. QFileInfo info(filename);
  5993. QDir directory= info.dir();
  5994. lastDir= directory.path();
  5995. settings.setValue("lastDirectory",lastDir);
  5996. }
  5997. }
  5998. /*:520*//*521:*/
  5999. #line 11826 "./typica.w"
  6000. void LogEditWindow::openXML()
  6001. {
  6002. QSettings settings;
  6003. QString lastDir= settings.value("lastDirectory").toString();
  6004. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6005. lastDir,"",0);
  6006. if(filename.isNull())
  6007. {
  6008. return;
  6009. }
  6010. QFile file(filename);
  6011. XMLInput reader(&file,1);
  6012. connect(&reader,SIGNAL(measure(Measurement,int)),
  6013. model,SLOT(newMeasurement(Measurement,int)));
  6014. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6015. model,SLOT(newAnnotation(QString,int,int)));
  6016. if(reader.input())
  6017. {
  6018. QFileInfo info(filename);
  6019. setWindowTitle(QString(tr("%1 - %2")).
  6020. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6021. QDir directory= info.dir();
  6022. lastDir= directory.path();
  6023. settings.setValue("lastDirectory",lastDir);
  6024. }
  6025. }
  6026. /*:521*//*522:*/
  6027. #line 11857 "./typica.w"
  6028. void LogEditWindow::closeEvent(QCloseEvent*event)
  6029. {
  6030. QSettings settings;
  6031. settings.setValue("logSize",size());
  6032. settings.setValue("logPos",pos());
  6033. event->accept();
  6034. }
  6035. /*:522*/
  6036. #line 557 "./typica.w"
  6037. /*528:*/
  6038. #line 11972 "./typica.w"
  6039. bool XMLOutput::output()
  6040. {
  6041. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6042. {
  6043. return false;
  6044. }
  6045. QXmlStreamWriter xmlout(out);
  6046. xmlout.writeStartDocument("1.0");
  6047. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6048. xmlout.writeStartElement("roastlog");
  6049. /*529:*/
  6050. #line 12005 "./typica.w"
  6051. foreach(int c,temperatureColumns.keys())
  6052. {
  6053. xmlout.writeStartElement("tempseries");
  6054. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6055. xmlout.writeEndElement();
  6056. }
  6057. foreach(int c,controlColumns.keys())
  6058. {
  6059. xmlout.writeStartElement("controlseries");
  6060. xmlout.writeAttribute("name",controlColumns.value(c));
  6061. xmlout.writeEndElement();
  6062. }
  6063. foreach(int c,annotationColumns.keys())
  6064. {
  6065. xmlout.writeStartElement("noteseries");
  6066. xmlout.writeAttribute("name",annotationColumns.value(c));
  6067. xmlout.writeEndElement();
  6068. }
  6069. /*:529*/
  6070. #line 11983 "./typica.w"
  6071. xmlout.writeStartElement("roast");
  6072. bool oresult;
  6073. for(int i= 0;i<data->rowCount();i++)
  6074. {
  6075. /*530:*/
  6076. #line 12030 "./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. /*:530*/
  6110. #line 11988 "./typica.w"
  6111. if(oresult)
  6112. {
  6113. /*531:*/
  6114. #line 12069 "./typica.w"
  6115. xmlout.writeStartElement("tuple");
  6116. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6117. Qt::DisplayRole).toString());
  6118. foreach(int c,temperatureColumns.keys())
  6119. {
  6120. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6121. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6122. {
  6123. xmlout.writeStartElement("temperature");
  6124. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6125. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6126. {
  6127. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6128. {
  6129. xmlout.writeAttribute("relative","true");
  6130. }
  6131. }
  6132. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6133. toString());
  6134. xmlout.writeEndElement();
  6135. }
  6136. }
  6137. foreach(int c,controlColumns.keys())
  6138. {
  6139. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6140. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6141. {
  6142. xmlout.writeStartElement("control");
  6143. xmlout.writeAttribute("series",controlColumns.value(c));
  6144. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6145. xmlout.writeEndElement();
  6146. }
  6147. }
  6148. foreach(int c,annotationColumns.keys())
  6149. {
  6150. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6151. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6152. {
  6153. xmlout.writeStartElement("annotation");
  6154. xmlout.writeAttribute("series",annotationColumns.value(c));
  6155. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6156. toString());
  6157. xmlout.writeEndElement();
  6158. }
  6159. }
  6160. xmlout.writeEndElement();
  6161. /*:531*/
  6162. #line 11991 "./typica.w"
  6163. }
  6164. }
  6165. xmlout.writeEndElement();
  6166. xmlout.writeEndElement();
  6167. xmlout.writeEndDocument();
  6168. out->close();
  6169. return true;
  6170. }
  6171. /*:528*//*532:*/
  6172. #line 12119 "./typica.w"
  6173. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6174. :QObject(NULL),data(model),out(device),time(timec)
  6175. {
  6176. }
  6177. void XMLOutput::setModel(MeasurementModel*model)
  6178. {
  6179. data= model;
  6180. }
  6181. void XMLOutput::setTimeColumn(int column)
  6182. {
  6183. time= column;
  6184. }
  6185. void XMLOutput::setDevice(QIODevice*device)
  6186. {
  6187. out= device;
  6188. }
  6189. /*:532*//*533:*/
  6190. #line 12148 "./typica.w"
  6191. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6192. {
  6193. temperatureColumns.insert(column,series);
  6194. }
  6195. void XMLOutput::addControlColumn(const QString&series,int column)
  6196. {
  6197. controlColumns.insert(column,series);
  6198. }
  6199. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6200. {
  6201. annotationColumns.insert(column,series);
  6202. }
  6203. /*:533*/
  6204. #line 558 "./typica.w"
  6205. /*535:*/
  6206. #line 12205 "./typica.w"
  6207. bool XMLInput::input()
  6208. {
  6209. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6210. {
  6211. return false;
  6212. }
  6213. QXmlStreamReader xmlin(in);
  6214. QMap<QString,int> temperatureColumns;
  6215. QMap<QString,int> annotationColumns;
  6216. int nextColumn= firstc;
  6217. /*536:*/
  6218. #line 12236 "./typica.w"
  6219. while(!xmlin.isDTD())
  6220. {
  6221. xmlin.readNext();
  6222. }
  6223. if(xmlin.isDTD())
  6224. {
  6225. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6226. {
  6227. /*537:*/
  6228. #line 12258 "./typica.w"
  6229. emit newTemperatureColumn(firstc,"Bean");
  6230. emit newAnnotationColumn(firstc+1,"Note");
  6231. emit lastColumn(firstc+1);
  6232. /*:537*/
  6233. #line 12245 "./typica.w"
  6234. }
  6235. else
  6236. {
  6237. xmlin.readNext();
  6238. /*538:*/
  6239. #line 12267 "./typica.w"
  6240. while(xmlin.name()!="roast")
  6241. {
  6242. if(xmlin.isStartElement())
  6243. {
  6244. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6245. {
  6246. temperatureColumns.insert(xmlin.attributes().value("name").
  6247. toString(),
  6248. nextColumn);
  6249. emit newTemperatureColumn(nextColumn,
  6250. xmlin.attributes().value("name").
  6251. toString());
  6252. nextColumn++;
  6253. }
  6254. else if(xmlin.name()=="noteseries")
  6255. {
  6256. annotationColumns.insert(xmlin.attributes().value("name").
  6257. toString(),nextColumn);
  6258. emit newAnnotationColumn(nextColumn,
  6259. xmlin.attributes().value("name").
  6260. toString());
  6261. nextColumn++;
  6262. }
  6263. }
  6264. xmlin.readNext();
  6265. }
  6266. emit lastColumn(nextColumn-1);
  6267. /*:538*/
  6268. #line 12250 "./typica.w"
  6269. }
  6270. }
  6271. /*:536*/
  6272. #line 12216 "./typica.w"
  6273. QTime timeval= QTime();
  6274. double tempval= 0;
  6275. QString noteval= QString();
  6276. int column;
  6277. int counter= 0;
  6278. while(!xmlin.atEnd())
  6279. {
  6280. /*539:*/
  6281. #line 12308 "./typica.w"
  6282. xmlin.readNext();
  6283. if(xmlin.isStartElement())
  6284. {
  6285. /*540:*/
  6286. #line 12334 "./typica.w"
  6287. if(xmlin.name()=="time")
  6288. {
  6289. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6290. }
  6291. else if(xmlin.name()=="temperature")
  6292. {
  6293. column= xmlin.attributes().hasAttribute("series")?
  6294. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6295. bool relative= (xmlin.attributes().value("relative")=="true");
  6296. tempval= xmlin.readElementText().toDouble();
  6297. Measurement measurement(tempval,timeval);
  6298. if(relative)
  6299. {
  6300. measurement.insert("relative",true);
  6301. }
  6302. emit measure(measurement,column);
  6303. }
  6304. else if(xmlin.name()=="control")
  6305. {
  6306. column= xmlin.attributes().value("series").toString().isEmpty()?
  6307. firstc:temperatureColumns.value(xmlin.attributes().
  6308. value("series").toString());
  6309. tempval= xmlin.readElementText().toDouble();
  6310. Measurement measurement(tempval,timeval,Units::Unitless);
  6311. emit measure(measurement,column);
  6312. }
  6313. else if(xmlin.name()=="annotation")
  6314. {
  6315. column= xmlin.attributes().value("series").toString().isEmpty()?
  6316. firstc+1:annotationColumns.value(xmlin.attributes().
  6317. value("series").toString());
  6318. noteval= xmlin.readElementText();
  6319. if(!noteval.isEmpty())
  6320. {
  6321. emit annotation(noteval,firstc,column);
  6322. }
  6323. }
  6324. /*:540*/
  6325. #line 12312 "./typica.w"
  6326. }
  6327. counter++;
  6328. if(counter%100==0)
  6329. {
  6330. QCoreApplication::processEvents();
  6331. }
  6332. /*:539*/
  6333. #line 12224 "./typica.w"
  6334. }
  6335. return true;
  6336. }
  6337. /*:535*//*541:*/
  6338. #line 12375 "./typica.w"
  6339. XMLInput::XMLInput(QIODevice*input,int c):
  6340. firstc(c),in(input)
  6341. {
  6342. }
  6343. void XMLInput::setFirstColumn(int column)
  6344. {
  6345. firstc= column;
  6346. }
  6347. void XMLInput::setDevice(QIODevice*device)
  6348. {
  6349. in= device;
  6350. }
  6351. /*:541*/
  6352. #line 559 "./typica.w"
  6353. /*546:*/
  6354. #line 12466 "./typica.w"
  6355. bool CSVOutput::output()
  6356. {
  6357. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6358. {
  6359. return false;
  6360. }
  6361. QTextStream output(out);
  6362. /*547:*/
  6363. #line 12490 "./typica.w"
  6364. output<<"Time";
  6365. foreach(int c,temperatureColumns.keys())
  6366. {
  6367. output<<','<<temperatureColumns.value(c);
  6368. }
  6369. foreach(int c,controlColumns.keys())
  6370. {
  6371. output<<','<<controlColumns.value(c);
  6372. }
  6373. foreach(int c,annotationColumns.keys())
  6374. {
  6375. output<<','<<annotationColumns.value(c);
  6376. }
  6377. output<<'\n';
  6378. /*:547*/
  6379. #line 12474 "./typica.w"
  6380. bool oresult;
  6381. for(int i= 0;i<data->rowCount();i++)
  6382. {
  6383. /*530:*/
  6384. #line 12030 "./typica.w"
  6385. oresult= false;
  6386. foreach(int c,temperatureColumns.keys())
  6387. {
  6388. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6389. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6390. {
  6391. oresult= true;
  6392. break;
  6393. }
  6394. }
  6395. foreach(int c,controlColumns.keys())
  6396. {
  6397. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6398. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6399. {
  6400. oresult= true;
  6401. break;
  6402. }
  6403. }
  6404. if(oresult==false)
  6405. {
  6406. foreach(int c,annotationColumns.keys())
  6407. {
  6408. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6409. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6410. isEmpty()))
  6411. {
  6412. oresult= true;
  6413. break;
  6414. }
  6415. }
  6416. }
  6417. /*:530*/
  6418. #line 12478 "./typica.w"
  6419. if(oresult)
  6420. {
  6421. /*548:*/
  6422. #line 12515 "./typica.w"
  6423. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6424. foreach(int c,temperatureColumns.keys())
  6425. {
  6426. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6427. }
  6428. foreach(int c,controlColumns.keys())
  6429. {
  6430. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6431. }
  6432. foreach(int c,annotationColumns.keys())
  6433. {
  6434. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6435. }
  6436. output<<'\n';
  6437. /*:548*/
  6438. #line 12481 "./typica.w"
  6439. }
  6440. }
  6441. out->close();
  6442. return true;
  6443. }
  6444. /*:546*//*549:*/
  6445. #line 12534 "./typica.w"
  6446. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6447. data(model),out(device),time(timec)
  6448. {
  6449. }
  6450. void CSVOutput::setModel(MeasurementModel*model)
  6451. {
  6452. data= model;
  6453. }
  6454. void CSVOutput::setTimeColumn(int column)
  6455. {
  6456. time= column;
  6457. }
  6458. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6459. {
  6460. temperatureColumns.insert(column,series);
  6461. }
  6462. void CSVOutput::addControlColumn(const QString&series,int column)
  6463. {
  6464. controlColumns.insert(column,series);
  6465. }
  6466. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6467. {
  6468. annotationColumns.insert(column,series);
  6469. }
  6470. void CSVOutput::setDevice(QIODevice*device)
  6471. {
  6472. out= device;
  6473. }
  6474. #line 1 "./webview.w"
  6475. /*:549*/
  6476. #line 560 "./typica.w"
  6477. /*584:*/
  6478. #line 12795 "./typica.w"
  6479. QString SaltModel::arrayLiteral(int column,int role)const
  6480. {
  6481. QString literal= "'{";
  6482. for(int i= 0;i<rowCount();i++)
  6483. {
  6484. QString datum= data(index(i,column),role).toString();
  6485. if(!datum.isEmpty())
  6486. {
  6487. literal.append(datum);
  6488. literal.append(", ");
  6489. }
  6490. }
  6491. if(literal.size()> 2)
  6492. {
  6493. literal.chop(2);
  6494. }
  6495. literal.append("}'");
  6496. return literal;
  6497. }
  6498. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6499. {
  6500. QString literal= "'{";
  6501. for(int i= 0;i<rowCount();i++)
  6502. {
  6503. QString datum= data(index(i,column),role).toString();
  6504. if(!datum.isEmpty())
  6505. {
  6506. literal.append("\"");
  6507. literal.append(datum);
  6508. literal.append("\", ");
  6509. }
  6510. }
  6511. if(literal.size()> 2)
  6512. {
  6513. literal.chop(2);
  6514. }
  6515. literal.append("}'");
  6516. return literal;
  6517. }
  6518. /*:584*//*585:*/
  6519. #line 12839 "./typica.w"
  6520. QModelIndex SaltModel::parent(const QModelIndex&)const
  6521. {
  6522. return QModelIndex();
  6523. }
  6524. /*:585*//*586:*/
  6525. #line 12858 "./typica.w"
  6526. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6527. int role)
  6528. {
  6529. /*587:*/
  6530. #line 12889 "./typica.w"
  6531. bool valid= false;
  6532. if(index.isValid())
  6533. {
  6534. if(index.row()<modelData.size())
  6535. {
  6536. if(index.column()<colcount)
  6537. {
  6538. valid= true;
  6539. }
  6540. }
  6541. }
  6542. /*:587*/
  6543. #line 12862 "./typica.w"
  6544. if(!valid)
  6545. {
  6546. return false;
  6547. }
  6548. if(index.row()==modelData.size()-1)
  6549. {
  6550. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6551. /*588:*/
  6552. #line 12905 "./typica.w"
  6553. QList<QMap<int,QVariant> > newRow;
  6554. QMap<int,QVariant> defaults;
  6555. for(int i= 0;i<colcount;i++)
  6556. {
  6557. newRow.append(defaults);
  6558. }
  6559. modelData.append(newRow);
  6560. /*:588*/
  6561. #line 12870 "./typica.w"
  6562. endInsertRows();
  6563. }
  6564. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6565. QMap<int,QVariant> cell= row.at(index.column());
  6566. cell.insert(role,value);
  6567. if(role==Qt::EditRole)
  6568. {
  6569. cell.insert(Qt::DisplayRole,value);
  6570. }
  6571. row.replace(index.column(),cell);
  6572. modelData.replace(index.row(),row);
  6573. emit dataChanged(index,index);
  6574. return true;
  6575. }
  6576. /*:586*//*589:*/
  6577. #line 12916 "./typica.w"
  6578. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6579. {
  6580. for(int i= 0;i<columns;i++)
  6581. {
  6582. hData<<"";
  6583. }
  6584. /*588:*/
  6585. #line 12905 "./typica.w"
  6586. QList<QMap<int,QVariant> > newRow;
  6587. QMap<int,QVariant> defaults;
  6588. for(int i= 0;i<colcount;i++)
  6589. {
  6590. newRow.append(defaults);
  6591. }
  6592. modelData.append(newRow);
  6593. /*:588*/
  6594. #line 12923 "./typica.w"
  6595. }
  6596. /*:589*//*590:*/
  6597. #line 12928 "./typica.w"
  6598. SaltModel::~SaltModel()
  6599. {
  6600. }
  6601. /*:590*//*591:*/
  6602. #line 12938 "./typica.w"
  6603. int SaltModel::rowCount(const QModelIndex&parent)const
  6604. {
  6605. return(parent==QModelIndex()?modelData.size():0);
  6606. }
  6607. int SaltModel::columnCount(const QModelIndex&parent)const
  6608. {
  6609. return(parent==QModelIndex()?colcount:0);
  6610. }
  6611. /*:591*//*592:*/
  6612. #line 12951 "./typica.w"
  6613. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6614. const QVariant&value,int)
  6615. {
  6616. if(orientation==Qt::Horizontal&&section<colcount)
  6617. {
  6618. hData.replace(section,value.toString());
  6619. emit headerDataChanged(orientation,section,section);
  6620. return true;
  6621. }
  6622. return false;
  6623. }
  6624. /*:592*//*593:*/
  6625. #line 12966 "./typica.w"
  6626. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6627. {
  6628. /*587:*/
  6629. #line 12889 "./typica.w"
  6630. bool valid= false;
  6631. if(index.isValid())
  6632. {
  6633. if(index.row()<modelData.size())
  6634. {
  6635. if(index.column()<colcount)
  6636. {
  6637. valid= true;
  6638. }
  6639. }
  6640. }
  6641. /*:587*/
  6642. #line 12969 "./typica.w"
  6643. if(!valid)
  6644. {
  6645. return QVariant();
  6646. }
  6647. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6648. QMap<int,QVariant> cell= row.at(index.column());
  6649. return cell.value(role,QVariant());
  6650. }
  6651. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6652. int role)const
  6653. {
  6654. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6655. section<colcount)
  6656. {
  6657. return QVariant(hData.at(section));
  6658. }
  6659. return QVariant();
  6660. }
  6661. /*:593*//*594:*/
  6662. #line 12993 "./typica.w"
  6663. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6664. {
  6665. /*587:*/
  6666. #line 12889 "./typica.w"
  6667. bool valid= false;
  6668. if(index.isValid())
  6669. {
  6670. if(index.row()<modelData.size())
  6671. {
  6672. if(index.column()<colcount)
  6673. {
  6674. valid= true;
  6675. }
  6676. }
  6677. }
  6678. /*:587*/
  6679. #line 12996 "./typica.w"
  6680. if(valid)
  6681. {
  6682. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6683. }
  6684. return 0;
  6685. }
  6686. /*:594*//*595:*/
  6687. #line 13007 "./typica.w"
  6688. QModelIndex SaltModel::index(int row,int column,
  6689. const QModelIndex&parent)const
  6690. {
  6691. if(parent==QModelIndex())
  6692. {
  6693. if(row<modelData.size()&&column<colcount)
  6694. {
  6695. return createIndex(row,column);
  6696. }
  6697. }
  6698. return QModelIndex();
  6699. }
  6700. /*:595*//*596:*/
  6701. #line 13025 "./typica.w"
  6702. void SaltModel::clear()
  6703. {
  6704. beginResetModel();
  6705. modelData.clear();
  6706. /*588:*/
  6707. #line 12905 "./typica.w"
  6708. QList<QMap<int,QVariant> > newRow;
  6709. QMap<int,QVariant> defaults;
  6710. for(int i= 0;i<colcount;i++)
  6711. {
  6712. newRow.append(defaults);
  6713. }
  6714. modelData.append(newRow);
  6715. /*:588*/
  6716. #line 13030 "./typica.w"
  6717. endResetModel();
  6718. }
  6719. /*:596*//*597:*/
  6720. #line 13039 "./typica.w"
  6721. bool SaltModel::removeRows(int row,int count,
  6722. const QModelIndex&parent)
  6723. {
  6724. if(parent==QModelIndex())
  6725. {
  6726. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6727. {
  6728. beginRemoveRows(parent,row,row+count-1);
  6729. for(int i= 0;i<count;i++)
  6730. {
  6731. modelData.removeAt(row);
  6732. }
  6733. endRemoveRows();
  6734. if(modelData.size()==0)
  6735. {
  6736. beginInsertRows(parent,0,0);
  6737. /*588:*/
  6738. #line 12905 "./typica.w"
  6739. QList<QMap<int,QVariant> > newRow;
  6740. QMap<int,QVariant> defaults;
  6741. for(int i= 0;i<colcount;i++)
  6742. {
  6743. newRow.append(defaults);
  6744. }
  6745. modelData.append(newRow);
  6746. /*:588*/
  6747. #line 13056 "./typica.w"
  6748. endInsertRows();
  6749. }
  6750. return true;
  6751. }
  6752. }
  6753. return false;
  6754. }
  6755. /*:597*//*598:*/
  6756. #line 13070 "./typica.w"
  6757. int SaltModel::findData(const QVariant&value,int column,int role)
  6758. {
  6759. for(int i= 0;i<modelData.size();i++)
  6760. {
  6761. if(modelData.at(i).size()> column)
  6762. {
  6763. if(modelData.at(i).at(column).contains(role))
  6764. {
  6765. if(modelData.at(i).at(column).value(role)==value)
  6766. {
  6767. return i;
  6768. }
  6769. }
  6770. }
  6771. }
  6772. return-1;
  6773. }
  6774. /*:598*/
  6775. #line 561 "./typica.w"
  6776. /*600:*/
  6777. #line 13134 "./typica.w"
  6778. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6779. {
  6780. SqlComboBox*widget= new SqlComboBox();
  6781. widget->setParent(parent);
  6782. for(int i= 0;i<count();i++)
  6783. {
  6784. widget->addItem(itemText(i),itemData(i));
  6785. }
  6786. return widget;
  6787. }
  6788. /*:600*//*601:*/
  6789. #line 13151 "./typica.w"
  6790. void SqlComboBox::showData(bool show)
  6791. {
  6792. dataColumnShown= show;
  6793. }
  6794. /*:601*//*602:*/
  6795. #line 13165 "./typica.w"
  6796. void SqlComboBox::addNullOption()
  6797. {
  6798. addItem(specialNullText,specialNullData);
  6799. }
  6800. void SqlComboBox::setNullText(QString nullText)
  6801. {
  6802. specialNullText= nullText;
  6803. }
  6804. void SqlComboBox::setNullData(QVariant nullData)
  6805. {
  6806. specialNullData= nullData;
  6807. }
  6808. /*:602*//*603:*/
  6809. #line 13188 "./typica.w"
  6810. void SqlComboBox::setDataColumn(int column)
  6811. {
  6812. dataColumn= column;
  6813. }
  6814. void SqlComboBox::setDisplayColumn(int column)
  6815. {
  6816. displayColumn= column;
  6817. }
  6818. /*:603*//*604:*/
  6819. #line 13202 "./typica.w"
  6820. void SqlComboBox::addSqlOptions(QString query)
  6821. {
  6822. SqlQueryConnection h;
  6823. QSqlQuery*dbquery= h.operator->();
  6824. if(!dbquery->exec(query))
  6825. {
  6826. QSqlError error= dbquery->lastError();
  6827. qDebug()<<error.databaseText();
  6828. qDebug()<<error.driverText();
  6829. qDebug()<<error.text();
  6830. qDebug()<<dbquery->lastQuery();
  6831. }
  6832. while(dbquery->next())
  6833. {
  6834. QString displayValue(dbquery->value(displayColumn).toString());
  6835. QString dataValue(dbquery->value(dataColumn).toString());
  6836. if(dataColumnShown)
  6837. {
  6838. displayValue.append(QString(" (%1)").arg(dataValue));
  6839. }
  6840. addItem(displayValue,dataValue);
  6841. }
  6842. }
  6843. /*:604*//*605:*/
  6844. #line 13238 "./typica.w"
  6845. SqlComboBox::SqlComboBox():
  6846. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6847. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6848. {
  6849. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6850. }
  6851. SqlComboBox::~SqlComboBox()
  6852. {
  6853. }
  6854. /*:605*/
  6855. #line 562 "./typica.w"
  6856. /*607:*/
  6857. #line 13277 "./typica.w"
  6858. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6859. {
  6860. delegate= widget;
  6861. }
  6862. /*:607*//*608:*/
  6863. #line 13286 "./typica.w"
  6864. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6865. const QStyleOptionViewItem&,
  6866. const QModelIndex&)const
  6867. {
  6868. return delegate->clone(parent);
  6869. }
  6870. /*:608*//*609:*/
  6871. #line 13297 "./typica.w"
  6872. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6873. const QModelIndex&index)const
  6874. {
  6875. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6876. self->setCurrentIndex(self->findData(
  6877. index.model()->data(index,
  6878. Qt::UserRole).toString()));
  6879. }
  6880. /*:609*//*610:*/
  6881. #line 13310 "./typica.w"
  6882. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6883. QAbstractItemModel*model,
  6884. const QModelIndex&index)const
  6885. {
  6886. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6887. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6888. Qt::UserRole);
  6889. model->setData(index,self->currentText(),Qt::DisplayRole);
  6890. }
  6891. /*:610*//*611:*/
  6892. #line 13323 "./typica.w"
  6893. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6894. const QStyleOptionViewItem&option,
  6895. const QModelIndex&)const
  6896. {
  6897. editor->setGeometry(option.rect);
  6898. }
  6899. /*:611*//*612:*/
  6900. #line 13334 "./typica.w"
  6901. QSize SqlComboBoxDelegate::sizeHint()const
  6902. {
  6903. return delegate->sizeHint();
  6904. }
  6905. /*:612*//*613:*/
  6906. #line 13342 "./typica.w"
  6907. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6908. :QItemDelegate(parent)
  6909. {
  6910. }
  6911. /*:613*/
  6912. #line 563 "./typica.w"
  6913. /*576:*/
  6914. #line 12604 "./typica.w"
  6915. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6916. {
  6917. /*577:*/
  6918. #line 12619 "./typica.w"
  6919. setOrganizationName("Wilson's Coffee & Tea");
  6920. setOrganizationDomain("wilsonscoffee.com");
  6921. setApplicationName(PROGRAM_NAME);
  6922. /*:577*/
  6923. #line 12607 "./typica.w"
  6924. /*578:*/
  6925. #line 12628 "./typica.w"
  6926. QTranslator*base= new QTranslator;
  6927. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6928. {
  6929. installTranslator(base);
  6930. }
  6931. QTranslator*app= new QTranslator;
  6932. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6933. {
  6934. installTranslator(app);
  6935. }
  6936. /*:578*/
  6937. #line 12608 "./typica.w"
  6938. /*295:*/
  6939. #line 123 "./measurement.w"
  6940. qRegisterMetaType<Measurement> ("Measurement");
  6941. /*:295*/
  6942. #line 12609 "./typica.w"
  6943. /*784:*/
  6944. #line 16623 "./typica.w"
  6945. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6946. tr("NI DAQmx Base"),
  6947. "nidaqmxbase",NULL);
  6948. topLevelNodeInserters.append(inserter);
  6949. /*:784*//*792:*/
  6950. #line 16854 "./typica.w"
  6951. #ifdef Q_OS_WIN32
  6952. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6953. topLevelNodeInserters.append(inserter);
  6954. #endif
  6955. /*:792*//*816:*/
  6956. #line 17821 "./typica.w"
  6957. #if 0
  6958. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  6959. topLevelNodeInserters.append(inserter);
  6960. #endif
  6961. /*:816*//*865:*/
  6962. #line 19333 "./typica.w"
  6963. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  6964. topLevelNodeInserters.append(inserter);
  6965. #line 1 "./modbus.w"
  6966. /*:865*//*871:*/
  6967. #line 324 "./modbus.w"
  6968. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  6969. topLevelNodeInserters.append(inserter);
  6970. /*:871*//*887:*/
  6971. #line 272 "./unsupportedserial.w"
  6972. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  6973. "unsupporteddevice",NULL);
  6974. topLevelNodeInserters.append(inserter);
  6975. /*:887*//*921:*/
  6976. #line 190 "./phidgets.w"
  6977. QLibrary phidgetsCheck("phidget21");
  6978. if(phidgetsCheck.load())
  6979. {
  6980. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6981. "phidgets1048",NULL);
  6982. topLevelNodeInserters.append(inserter);
  6983. phidgetsCheck.unload();
  6984. }
  6985. else
  6986. {
  6987. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  6988. if(phidgetsCheck.load())
  6989. {
  6990. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  6991. "phidgets1048",NULL);
  6992. topLevelNodeInserters.append(inserter);
  6993. phidgetsCheck.unload();
  6994. }
  6995. }
  6996. /*:921*//*1012:*/
  6997. #line 1241 "./dataqsdk.w"
  6998. #ifdef Q_OS_WIN32
  6999. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7000. "dataqsdk",NULL);
  7001. topLevelNodeInserters.append(inserter);
  7002. #endif
  7003. #line 19985 "./typica.w"
  7004. #line 1 "./scales.w"
  7005. /*:1012*//*1037:*/
  7006. #line 557 "./scales.w"
  7007. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7008. topLevelNodeInserters.append(inserter);
  7009. #line 19987 "./typica.w"
  7010. #line 1 "./valueannotation.w"
  7011. /*:1037*/
  7012. #line 12610 "./typica.w"
  7013. }
  7014. /*:576*//*580:*/
  7015. #line 12651 "./typica.w"
  7016. QDomDocument*Application::configuration()
  7017. {
  7018. return&conf;
  7019. }
  7020. /*:580*//*581:*/
  7021. #line 12660 "./typica.w"
  7022. QSqlDatabase Application::database()
  7023. {
  7024. QString connectionName;
  7025. QSqlDatabase connection=
  7026. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7027. do
  7028. {
  7029. connectionName= QUuid::createUuid().toString();
  7030. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7031. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7032. }
  7033. /*:581*//*719:*/
  7034. #line 15156 "./typica.w"
  7035. void Application::saveDeviceConfiguration()
  7036. {
  7037. QSettings settings;
  7038. settings.setValue("DeviceConfiguration",
  7039. QVariant(deviceConfigurationDocument.toByteArray()));
  7040. }
  7041. /*:719*//*720:*/
  7042. #line 15168 "./typica.w"
  7043. QDomDocument Application::deviceConfiguration()
  7044. {
  7045. if(deviceConfigurationDocument.isNull())
  7046. {
  7047. /*721:*/
  7048. #line 15182 "./typica.w"
  7049. QSettings settings;
  7050. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7051. QString etext;
  7052. int eline;
  7053. int ecol;
  7054. if(document.length()==0)
  7055. {
  7056. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7057. /*722:*/
  7058. #line 15206 "./typica.w"
  7059. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7060. emptyDocument.open(QIODevice::ReadOnly);
  7061. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7062. &etext,&eline,&ecol))
  7063. {
  7064. /*723:*/
  7065. #line 15223 "./typica.w"
  7066. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7067. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7068. qDebug()<<etext;
  7069. /*:723*/
  7070. #line 15212 "./typica.w"
  7071. }
  7072. else
  7073. {
  7074. saveDeviceConfiguration();
  7075. }
  7076. /*:722*/
  7077. #line 15191 "./typica.w"
  7078. }
  7079. else
  7080. {
  7081. if(!deviceConfigurationDocument.setContent(document,false,
  7082. &etext,&eline,&ecol))
  7083. {
  7084. /*723:*/
  7085. #line 15223 "./typica.w"
  7086. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7087. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7088. qDebug()<<etext;
  7089. /*:723*/
  7090. #line 15198 "./typica.w"
  7091. /*722:*/
  7092. #line 15206 "./typica.w"
  7093. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7094. emptyDocument.open(QIODevice::ReadOnly);
  7095. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7096. &etext,&eline,&ecol))
  7097. {
  7098. /*723:*/
  7099. #line 15223 "./typica.w"
  7100. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7101. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7102. qDebug()<<etext;
  7103. /*:723*/
  7104. #line 15212 "./typica.w"
  7105. }
  7106. else
  7107. {
  7108. saveDeviceConfiguration();
  7109. }
  7110. /*:722*/
  7111. #line 15199 "./typica.w"
  7112. }
  7113. }
  7114. /*:721*/
  7115. #line 15173 "./typica.w"
  7116. }
  7117. return deviceConfigurationDocument;
  7118. }
  7119. /*:720*//*751:*/
  7120. #line 15824 "./typica.w"
  7121. void Application::registerDeviceConfigurationWidget(QString driver,
  7122. QMetaObject widget)
  7123. {
  7124. deviceConfigurationWidgets.insert(driver,widget);
  7125. }
  7126. /*:751*//*752:*/
  7127. #line 15840 "./typica.w"
  7128. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7129. const QModelIndex&index)
  7130. {
  7131. QVariant nodeReference= index.data(Qt::UserRole);
  7132. QDomElement referenceElement= model->referenceElement(
  7133. model->data(index,Qt::UserRole).toString());
  7134. QMetaObject metaObject=
  7135. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7136. QWidget::staticMetaObject);
  7137. QWidget*editor;
  7138. if(metaObject.className()==QWidget::staticMetaObject.className())
  7139. {
  7140. editor= NULL;
  7141. }
  7142. else
  7143. {
  7144. editor= qobject_cast<QWidget*> (
  7145. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7146. Q_ARG(QModelIndex,index)));
  7147. }
  7148. return editor;
  7149. }
  7150. /*:752*/
  7151. #line 564 "./typica.w"
  7152. /*622:*/
  7153. #line 13490 "./typica.w"
  7154. SqlConnectionSetup::SqlConnectionSetup():
  7155. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7156. portnumber(new QLineEdit),
  7157. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7158. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7159. cancelButton(new QPushButton(tr("Cancel"))),
  7160. connectButton(new QPushButton(tr("Connect")))
  7161. {
  7162. driver->addItem("PostgreSQL","QPSQL");
  7163. formLayout->addRow(tr("Database driver:"),driver);
  7164. formLayout->addRow(tr("Host name:"),hostname);
  7165. formLayout->addRow(tr("Port number:"),portnumber);
  7166. portnumber->setText("5432");
  7167. formLayout->addRow(tr("Database name:"),dbname);
  7168. formLayout->addRow(tr("User name:"),user);
  7169. password->setEchoMode(QLineEdit::Password);
  7170. formLayout->addRow(tr("Password:"),password);
  7171. layout->addLayout(formLayout);
  7172. buttons->addStretch(1);
  7173. buttons->addWidget(cancelButton);
  7174. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7175. buttons->addWidget(connectButton);
  7176. layout->addLayout(buttons);
  7177. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7178. connectButton->setDefault(true);
  7179. setLayout(layout);
  7180. setModal(true);
  7181. }
  7182. SqlConnectionSetup::~SqlConnectionSetup()
  7183. {
  7184. }
  7185. /*:622*//*623:*/
  7186. #line 13528 "./typica.w"
  7187. void SqlConnectionSetup::testConnection()
  7188. {
  7189. QSqlDatabase database=
  7190. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7191. toString());
  7192. database.setConnectOptions("application_name=Typica");
  7193. database.setHostName(hostname->text());
  7194. database.setPort(portnumber->text().toInt());
  7195. database.setDatabaseName(dbname->text());
  7196. database.setUserName(user->text());
  7197. database.setPassword(password->text());
  7198. if(database.open())
  7199. {
  7200. QSettings settings;
  7201. settings.setValue("database/exists","true");
  7202. settings.setValue("database/driver",
  7203. driver->itemData(driver->currentIndex()).toString());
  7204. settings.setValue("database/hostname",hostname->text());
  7205. settings.setValue("database/portnumber",portnumber->text());
  7206. settings.setValue("database/dbname",dbname->text());
  7207. settings.setValue("database/user",user->text());
  7208. settings.setValue("database/password",password->text());
  7209. database.close();
  7210. accept();
  7211. }
  7212. else
  7213. {
  7214. QMessageBox::information(this,tr("Database connection failed"),
  7215. tr("Failed to connect to database."));
  7216. }
  7217. }
  7218. /*:623*/
  7219. #line 565 "./typica.w"
  7220. /*627:*/
  7221. #line 13633 "./typica.w"
  7222. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7223. {
  7224. setModel(new QSqlQueryModel);
  7225. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7226. this,SLOT(openRow(QModelIndex)));
  7227. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7228. this,SLOT(persistColumnResize(int,int,int)));
  7229. }
  7230. /*:627*//*628:*/
  7231. #line 13648 "./typica.w"
  7232. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7233. {
  7234. /*629:*/
  7235. #line 13657 "./typica.w"
  7236. QSettings settings;
  7237. /*630:*/
  7238. #line 13670 "./typica.w"
  7239. QWidget*topLevelWidget= this;
  7240. while(topLevelWidget->parentWidget())
  7241. {
  7242. topLevelWidget= topLevelWidget->parentWidget();
  7243. }
  7244. /*:630*/
  7245. #line 13659 "./typica.w"
  7246. settings.setValue(QString("columnWidths/%1/%2/%3").
  7247. arg(topLevelWidget->objectName()).
  7248. arg(objectName()).arg(column),
  7249. QVariant(newsize));
  7250. /*:629*/
  7251. #line 13651 "./typica.w"
  7252. }
  7253. /*:628*//*631:*/
  7254. #line 13680 "./typica.w"
  7255. void SqlQueryView::showEvent(QShowEvent*event)
  7256. {
  7257. /*632:*/
  7258. #line 13690 "./typica.w"
  7259. QSettings settings;
  7260. /*630:*/
  7261. #line 13670 "./typica.w"
  7262. QWidget*topLevelWidget= this;
  7263. while(topLevelWidget->parentWidget())
  7264. {
  7265. topLevelWidget= topLevelWidget->parentWidget();
  7266. }
  7267. /*:630*/
  7268. #line 13692 "./typica.w"
  7269. QString baseKey=
  7270. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7271. arg(objectName());
  7272. for(int i= 0;i<model()->columnCount();i++)
  7273. {
  7274. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7275. if(settings.contains(key))
  7276. {
  7277. setColumnWidth(i,settings.value(key).toInt());
  7278. }
  7279. }
  7280. /*:632*/
  7281. #line 13683 "./typica.w"
  7282. event->accept();
  7283. }
  7284. /*:631*//*633:*/
  7285. #line 13707 "./typica.w"
  7286. void SqlQueryView::openRow(const QModelIndex&index)
  7287. {
  7288. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7289. emit openEntryRow(index.row());
  7290. }
  7291. /*:633*//*634:*/
  7292. #line 13716 "./typica.w"
  7293. void SqlQueryView::setQuery(const QString&query)
  7294. {
  7295. QSqlDatabase database= AppInstance->database();
  7296. database.open();
  7297. QSqlQuery q(query,database);
  7298. ((QSqlQueryModel*)model())->setQuery(q);
  7299. database.close();
  7300. }
  7301. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7302. const QVariant&value,int role)
  7303. {
  7304. return model()->setHeaderData(section,orientation,value,role);
  7305. }
  7306. /*:634*//*635:*/
  7307. #line 13734 "./typica.w"
  7308. QVariant SqlQueryView::data(int row,int column,int role)
  7309. {
  7310. return model()->data(model()->index(row,column),role);
  7311. }
  7312. /*:635*/
  7313. #line 566 "./typica.w"
  7314. /*170:*/
  7315. #line 3937 "./typica.w"
  7316. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7317. {
  7318. QSqlDatabase database= AppInstance->database();
  7319. database.open();
  7320. q= new QSqlQuery(query,database);
  7321. connection= database.connectionName();
  7322. }
  7323. /*:170*//*171:*/
  7324. #line 3950 "./typica.w"
  7325. SqlQueryConnection::~SqlQueryConnection()
  7326. {
  7327. delete q;
  7328. {
  7329. QSqlDatabase database= QSqlDatabase::database(connection);
  7330. database.close();
  7331. }
  7332. QSqlDatabase::removeDatabase(connection);
  7333. }
  7334. /*:171*//*172:*/
  7335. #line 3964 "./typica.w"
  7336. QSqlQuery*SqlQueryConnection::operator->()const
  7337. {
  7338. return q;
  7339. }
  7340. /*:172*/
  7341. #line 567 "./typica.w"
  7342. /*654:*/
  7343. #line 14093 "./typica.w"
  7344. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7345. area(frame),configuration(description)
  7346. {
  7347. refresh();
  7348. }
  7349. ReportTable::~ReportTable()
  7350. {
  7351. }
  7352. /*:654*//*655:*/
  7353. #line 14109 "./typica.w"
  7354. void ReportTable::bind(QString placeholder,QVariant value)
  7355. {
  7356. bindings.insert(placeholder,value);
  7357. }
  7358. /*:655*//*656:*/
  7359. #line 14119 "./typica.w"
  7360. void ReportTable::refresh()
  7361. {
  7362. /*657:*/
  7363. #line 14140 "./typica.w"
  7364. QTextCursor cursor= area->firstCursorPosition();
  7365. while(cursor<area->lastCursorPosition())
  7366. {
  7367. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7368. }
  7369. cursor.removeSelectedText();
  7370. /*:657*/
  7371. #line 14122 "./typica.w"
  7372. int rows= 1;
  7373. int columns= 1;
  7374. int currentRow= 0;
  7375. QTextTable*table= cursor.insertTable(rows,columns);
  7376. /*658:*/
  7377. #line 14153 "./typica.w"
  7378. QTextTableFormat format= table->format();
  7379. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7380. if(configuration.hasAttribute("align"))
  7381. {
  7382. if(configuration.attribute("align")=="center")
  7383. {
  7384. format.setAlignment(Qt::AlignHCenter);
  7385. }
  7386. }
  7387. table->setFormat(format);
  7388. /*:658*/
  7389. #line 14127 "./typica.w"
  7390. /*659:*/
  7391. #line 14167 "./typica.w"
  7392. QDomNodeList children= configuration.childNodes();
  7393. for(int i= 0;i<children.count();i++)
  7394. {
  7395. QDomNode current;
  7396. QDomElement currentElement;
  7397. current= children.at(i);
  7398. if(current.isElement())
  7399. {
  7400. currentElement= current.toElement();
  7401. if(currentElement.tagName()=="query")
  7402. {
  7403. /*660:*/
  7404. #line 14194 "./typica.w"
  7405. SqlQueryConnection h;
  7406. QSqlQuery*query= h.operator->();
  7407. query->prepare(currentElement.text());
  7408. foreach(QString key,bindings.uniqueKeys())
  7409. {
  7410. if(currentElement.text().contains(key))
  7411. {
  7412. query->bindValue(key,bindings.value(key));
  7413. }
  7414. }
  7415. query->exec();
  7416. if(!query->next())
  7417. {
  7418. continue;
  7419. }
  7420. if(query->record().count()> columns)
  7421. {
  7422. table->appendColumns(query->record().count()-columns);
  7423. }
  7424. do
  7425. {
  7426. table->appendRows(1);
  7427. rows++;
  7428. currentRow++;
  7429. for(int j= 0;j<query->record().count();j++)
  7430. {
  7431. QTextTableCell cell= table->cellAt(currentRow,j);
  7432. cursor= cell.firstCursorPosition();
  7433. cursor.insertText(query->value(j).toString());
  7434. }
  7435. }while(query->next());
  7436. /*:660*/
  7437. #line 14179 "./typica.w"
  7438. }
  7439. else if(currentElement.tagName()=="row")
  7440. {
  7441. /*661:*/
  7442. #line 14234 "./typica.w"
  7443. table->appendRows(1);
  7444. currentRow++;
  7445. rows++;
  7446. QDomNodeList rowChildren= currentElement.childNodes();
  7447. int currentColumn= 0;
  7448. for(int j= 0;j<rowChildren.count();j++)
  7449. {
  7450. QDomNode node;
  7451. QDomElement nodeElement;
  7452. node= rowChildren.at(j);
  7453. if(node.isElement())
  7454. {
  7455. nodeElement= node.toElement();
  7456. if(nodeElement.tagName()=="cell")
  7457. {
  7458. if(currentColumn==columns)
  7459. {
  7460. table->appendColumns(1);
  7461. columns++;
  7462. }
  7463. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7464. cursor= cell.firstCursorPosition();
  7465. cursor.insertText(nodeElement.text());
  7466. currentColumn++;
  7467. }
  7468. }
  7469. }
  7470. /*:661*/
  7471. #line 14183 "./typica.w"
  7472. }
  7473. }
  7474. }
  7475. /*:659*/
  7476. #line 14128 "./typica.w"
  7477. if(rows> 1)
  7478. {
  7479. table->removeRows(0,1);
  7480. }
  7481. }
  7482. /*:656*/
  7483. #line 568 "./typica.w"
  7484. /*687:*/
  7485. #line 14338 "./typica.w"
  7486. FormArray::FormArray(QDomElement description):configuration(description),
  7487. maxwidth(-1),maxheight(-1)
  7488. {
  7489. setWidget(&itemContainer);
  7490. itemContainer.setLayout(&itemLayout);
  7491. }
  7492. /*:687*//*688:*/
  7493. #line 14355 "./typica.w"
  7494. void FormArray::addElements(int copies)
  7495. {
  7496. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7497. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7498. QWidget*widget;
  7499. for(int i= 0;i<copies;i++)
  7500. {
  7501. widget= new QWidget;
  7502. if(maxwidth> -1)
  7503. {
  7504. widget->setMaximumWidth(maxwidth);
  7505. }
  7506. if(maxheight> -1)
  7507. {
  7508. widget->setMaximumHeight(maxheight);
  7509. }
  7510. if(configuration.hasChildNodes())
  7511. {
  7512. widgetStack->push(widget);
  7513. populateWidget(configuration,widgetStack,layoutStack);
  7514. widgetStack->pop();
  7515. widget->setMinimumHeight(widget->sizeHint().height());
  7516. itemLayout.addWidget(widget);
  7517. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7518. {
  7519. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7520. }
  7521. else
  7522. {
  7523. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7524. +widget->sizeHint().height());
  7525. }
  7526. if(maxwidth> -1)
  7527. {
  7528. itemContainer.setMinimumWidth(maxwidth+50);
  7529. }
  7530. else
  7531. {
  7532. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7533. }
  7534. }
  7535. }
  7536. }
  7537. /*:688*//*689:*/
  7538. #line 14405 "./typica.w"
  7539. QWidget*FormArray::elementAt(int index)
  7540. {
  7541. if(index<itemLayout.count())
  7542. {
  7543. QLayoutItem*item= itemLayout.itemAt(index);
  7544. return item->widget();
  7545. }
  7546. else
  7547. {
  7548. return NULL;
  7549. }
  7550. }
  7551. /*:689*//*690:*/
  7552. #line 14422 "./typica.w"
  7553. void FormArray::removeAllElements()
  7554. {
  7555. while(itemLayout.count()> 0)
  7556. {
  7557. QLayoutItem*item;
  7558. item= itemLayout.itemAt(0);
  7559. item->widget()->hide();
  7560. itemLayout.removeWidget(item->widget());
  7561. }
  7562. itemContainer.setMinimumHeight(0);
  7563. }
  7564. /*:690*//*691:*/
  7565. #line 14438 "./typica.w"
  7566. int FormArray::elements()
  7567. {
  7568. return itemLayout.count();
  7569. }
  7570. /*:691*//*692:*/
  7571. #line 14449 "./typica.w"
  7572. void FormArray::setMaximumElementWidth(int width)
  7573. {
  7574. maxwidth= width;
  7575. }
  7576. void FormArray::setMaximumElementHeight(int height)
  7577. {
  7578. maxheight= height;
  7579. }
  7580. /*:692*/
  7581. #line 569 "./typica.w"
  7582. /*698:*/
  7583. #line 14580 "./typica.w"
  7584. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7585. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7586. {
  7587. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7588. QPointF(0,5);
  7589. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7590. QPointF(10,5);
  7591. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7592. QPointF(0,0);
  7593. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7594. initialBrush.setColor(QColor(170,170,255));
  7595. initialBrush.setStyle(Qt::SolidPattern);
  7596. finalBrush.setColor(Qt::blue);
  7597. finalBrush.setStyle(Qt::SolidPattern);
  7598. initialDecrement.setPolygon(left);
  7599. initialDecrement.setBrush(initialBrush);
  7600. initialDecrement.setPos(0,0);
  7601. scene.addItem(&initialDecrement);
  7602. initialIncrement.setPolygon(right);
  7603. initialIncrement.setBrush(initialBrush);
  7604. initialIncrement.setPos(122,0);
  7605. scene.addItem(&initialIncrement);
  7606. finalDecrement.setPolygon(left);
  7607. finalDecrement.setBrush(finalBrush);
  7608. finalDecrement.setPos(0,12);
  7609. scene.addItem(&finalDecrement);
  7610. finalIncrement.setPolygon(right);
  7611. finalIncrement.setBrush(finalBrush);
  7612. finalIncrement.setPos(122,12);
  7613. scene.addItem(&finalIncrement);
  7614. scalePath.moveTo(0,10);
  7615. scalePath.lineTo(100,10);
  7616. scalePath.moveTo(0,0);
  7617. scalePath.lineTo(0,20);
  7618. scalePath.moveTo(10,5);
  7619. scalePath.lineTo(10,15);
  7620. scalePath.moveTo(20,5);
  7621. scalePath.lineTo(20,15);
  7622. scalePath.moveTo(30,5);
  7623. scalePath.lineTo(30,15);
  7624. scalePath.moveTo(40,5);
  7625. scalePath.lineTo(40,15);
  7626. scalePath.moveTo(50,0);
  7627. scalePath.lineTo(50,20);
  7628. scalePath.moveTo(60,5);
  7629. scalePath.lineTo(60,15);
  7630. scalePath.moveTo(70,5);
  7631. scalePath.lineTo(70,15);
  7632. scalePath.moveTo(80,5);
  7633. scalePath.lineTo(80,15);
  7634. scalePath.moveTo(90,5);
  7635. scalePath.lineTo(90,15);
  7636. scalePath.moveTo(100,0);
  7637. scalePath.lineTo(100,20);
  7638. scaleLine.setPath(scalePath);
  7639. scaleLine.setPos(16,1);
  7640. scene.addItem(&scaleLine);
  7641. setScene(&scene);
  7642. initialIndicator.setPolygon(down);
  7643. initialIndicator.setBrush(initialBrush);
  7644. finalIndicator.setPolygon(up);
  7645. finalIndicator.setBrush(finalBrush);
  7646. setMinimumSize(sizeHint());
  7647. setMaximumSize(sizeHint());
  7648. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7649. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7650. setMinimumSize(sizeHint());
  7651. }
  7652. /*:698*//*699:*/
  7653. #line 14653 "./typica.w"
  7654. QSize ScaleControl::sizeHint()const
  7655. {
  7656. return QSize(140,30);
  7657. }
  7658. /*:699*//*700:*/
  7659. #line 14662 "./typica.w"
  7660. void ScaleControl::setInitialValue(double value)
  7661. {
  7662. if(value>=0&&value<=10)
  7663. {
  7664. nonScoredValue= value;
  7665. if(!initialSet)
  7666. {
  7667. scene.addItem(&initialIndicator);
  7668. }
  7669. initialSet= true;
  7670. initialIndicator.setPos(value*10+16,10);
  7671. emit initialChanged(value);
  7672. if(!finalSet)
  7673. {
  7674. setFinalValue(value);
  7675. }
  7676. }
  7677. }
  7678. void ScaleControl::setFinalValue(double value)
  7679. {
  7680. if(value>=0&&value<=10)
  7681. {
  7682. scoredValue= value;
  7683. if(!finalSet)
  7684. {
  7685. scene.addItem(&finalIndicator);
  7686. }
  7687. finalSet= true;
  7688. finalIndicator.setPos(value*10+16,11);
  7689. emit finalChanged(value);
  7690. }
  7691. }
  7692. /*:700*//*701:*/
  7693. #line 14699 "./typica.w"
  7694. double ScaleControl::initialValue(void)
  7695. {
  7696. return nonScoredValue;
  7697. }
  7698. double ScaleControl::finalValue(void)
  7699. {
  7700. return scoredValue;
  7701. }
  7702. /*:701*//*702:*/
  7703. #line 14720 "./typica.w"
  7704. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7705. {
  7706. /*703:*/
  7707. #line 14732 "./typica.w"
  7708. if(event->button()!=Qt::LeftButton)
  7709. {
  7710. event->ignore();
  7711. return;
  7712. }
  7713. /*:703*/
  7714. #line 14723 "./typica.w"
  7715. scaleDown= true;
  7716. event->accept();
  7717. }
  7718. /*:702*//*704:*/
  7719. #line 14743 "./typica.w"
  7720. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7721. {
  7722. /*703:*/
  7723. #line 14732 "./typica.w"
  7724. if(event->button()!=Qt::LeftButton)
  7725. {
  7726. event->ignore();
  7727. return;
  7728. }
  7729. /*:703*/
  7730. #line 14746 "./typica.w"
  7731. if(!scaleDown)
  7732. {
  7733. event->ignore();
  7734. return;
  7735. }
  7736. scaleDown= false;
  7737. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7738. /*705:*/
  7739. #line 14768 "./typica.w"
  7740. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7741. {
  7742. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7743. {
  7744. if(initialSet)
  7745. {
  7746. setInitialValue(nonScoredValue-0.05);
  7747. }
  7748. event->accept();
  7749. return;
  7750. }
  7751. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7752. {
  7753. if(finalSet)
  7754. {
  7755. setFinalValue(scoredValue-0.05);
  7756. event->accept();
  7757. return;
  7758. }
  7759. }
  7760. }
  7761. /*:705*/
  7762. #line 14754 "./typica.w"
  7763. /*706:*/
  7764. #line 14794 "./typica.w"
  7765. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7766. {
  7767. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7768. {
  7769. if(initialSet)
  7770. {
  7771. setInitialValue(nonScoredValue+0.05);
  7772. event->accept();
  7773. return;
  7774. }
  7775. }
  7776. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7777. {
  7778. if(finalSet)
  7779. {
  7780. setFinalValue(scoredValue+0.05);
  7781. event->accept();
  7782. return;
  7783. }
  7784. }
  7785. }
  7786. /*:706*/
  7787. #line 14755 "./typica.w"
  7788. /*707:*/
  7789. #line 14820 "./typica.w"
  7790. double relativeX= sceneCoordinate.x()-16;
  7791. if(initialSet)
  7792. {
  7793. if(relativeX>=0&&relativeX<=100)
  7794. {
  7795. setFinalValue(relativeX/10.0);
  7796. event->accept();
  7797. return;
  7798. }
  7799. }
  7800. else
  7801. {
  7802. if(relativeX>=0&&relativeX<=100)
  7803. {
  7804. setInitialValue(relativeX/10.0);
  7805. event->accept();
  7806. return;
  7807. }
  7808. }
  7809. /*:707*/
  7810. #line 14756 "./typica.w"
  7811. event->ignore();
  7812. return;
  7813. }
  7814. /*:704*/
  7815. #line 570 "./typica.w"
  7816. /*709:*/
  7817. #line 14886 "./typica.w"
  7818. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7819. valueSet(false),scaleDown(false)
  7820. {
  7821. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7822. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7823. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7824. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7825. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7826. theBrush.setColor(Qt::blue);
  7827. theBrush.setStyle(Qt::SolidPattern);
  7828. increment.setPolygon(up);
  7829. increment.setBrush(theBrush);
  7830. increment.setPos(0,0);
  7831. scene.addItem(&increment);
  7832. decrement.setPolygon(down);
  7833. decrement.setBrush(theBrush);
  7834. decrement.setPos(0,122);
  7835. scene.addItem(&decrement);
  7836. scalePath.moveTo(5,0);
  7837. scalePath.lineTo(5,100);
  7838. scalePath.moveTo(0,0);
  7839. scalePath.lineTo(10,0);
  7840. scalePath.moveTo(0,10);
  7841. scalePath.lineTo(10,10);
  7842. scalePath.moveTo(0,20);
  7843. scalePath.lineTo(10,20);
  7844. scalePath.moveTo(0,30);
  7845. scalePath.lineTo(10,30);
  7846. scalePath.moveTo(0,40);
  7847. scalePath.lineTo(10,40);
  7848. scalePath.moveTo(0,50);
  7849. scalePath.lineTo(10,50);
  7850. scalePath.moveTo(0,60);
  7851. scalePath.lineTo(10,60);
  7852. scalePath.moveTo(0,70);
  7853. scalePath.lineTo(10,70);
  7854. scalePath.moveTo(0,80);
  7855. scalePath.lineTo(10,80);
  7856. scalePath.moveTo(0,90);
  7857. scalePath.lineTo(10,90);
  7858. scalePath.moveTo(0,100);
  7859. scalePath.lineTo(10,100);
  7860. scaleLine.setPath(scalePath);
  7861. scaleLine.setPos(0,16);
  7862. scene.addItem(&scaleLine);
  7863. setScene(&scene);
  7864. indicator.setPolygon(left);
  7865. indicator.setBrush(theBrush);
  7866. setMinimumSize(sizeHint());
  7867. setMaximumSize(sizeHint());
  7868. }
  7869. /*:709*//*710:*/
  7870. #line 14941 "./typica.w"
  7871. QSize IntensityControl::sizeHint()const
  7872. {
  7873. return QSize(25,160);
  7874. }
  7875. /*:710*//*711:*/
  7876. #line 14956 "./typica.w"
  7877. void IntensityControl::setValue(double val)
  7878. {
  7879. if(val>=0&&val<=10)
  7880. {
  7881. theValue= val;
  7882. if(!valueSet)
  7883. {
  7884. scene.addItem(&indicator);
  7885. }
  7886. valueSet= true;
  7887. indicator.setPos(6,(100-(val*10))+16);
  7888. emit(valueChanged(val));
  7889. }
  7890. else if(val<1)
  7891. {
  7892. setValue(0);
  7893. }
  7894. else
  7895. {
  7896. setValue(10);
  7897. }
  7898. }
  7899. double IntensityControl::value()
  7900. {
  7901. return theValue;
  7902. }
  7903. /*:711*//*712:*/
  7904. #line 14988 "./typica.w"
  7905. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7906. {
  7907. /*703:*/
  7908. #line 14732 "./typica.w"
  7909. if(event->button()!=Qt::LeftButton)
  7910. {
  7911. event->ignore();
  7912. return;
  7913. }
  7914. /*:703*/
  7915. #line 14991 "./typica.w"
  7916. scaleDown= true;
  7917. event->accept();
  7918. }
  7919. /*:712*//*713:*/
  7920. #line 15002 "./typica.w"
  7921. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7922. {
  7923. /*703:*/
  7924. #line 14732 "./typica.w"
  7925. if(event->button()!=Qt::LeftButton)
  7926. {
  7927. event->ignore();
  7928. return;
  7929. }
  7930. /*:703*/
  7931. #line 15005 "./typica.w"
  7932. if(!scaleDown)
  7933. {
  7934. event->ignore();
  7935. return;
  7936. }
  7937. scaleDown= false;
  7938. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7939. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7940. {
  7941. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7942. {
  7943. if(valueSet)
  7944. {
  7945. setValue(theValue+0.05);
  7946. }
  7947. event->accept();
  7948. return;
  7949. }
  7950. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7951. {
  7952. if(valueSet)
  7953. {
  7954. setValue(theValue-0.05);
  7955. }
  7956. event->accept();
  7957. return;
  7958. }
  7959. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  7960. {
  7961. setValue(10-((sceneCoordinate.y()-16)/10.0));
  7962. event->accept();
  7963. return;
  7964. }
  7965. }
  7966. }
  7967. /*:713*/
  7968. #line 571 "./typica.w"
  7969. /*364:*/
  7970. #line 8231 "./typica.w"
  7971. void ThresholdDetector::newMeasurement(Measurement measure)
  7972. {
  7973. if((currentDirection==Ascending&&previousValue<threshold&&
  7974. previousValue>=0)||(currentDirection==Descending&&
  7975. previousValue> threshold&&previousValue>=0))
  7976. {
  7977. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  7978. (currentDirection==Descending&&measure.temperature()<=threshold))
  7979. {
  7980. double offset= measure.time().hour()*60*60;
  7981. offset+= measure.time().minute()*60;
  7982. offset+= measure.time().second();
  7983. offset+= measure.time().msec()/1000;
  7984. emit timeForValue(offset);
  7985. }
  7986. }
  7987. previousValue= measure.temperature();
  7988. }
  7989. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  7990. previousValue(-1),threshold(value),currentDirection(Ascending)
  7991. {
  7992. }
  7993. void ThresholdDetector::setThreshold(double value)
  7994. {
  7995. threshold= value;
  7996. }
  7997. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  7998. {
  7999. currentDirection= direction;
  8000. }
  8001. /*:364*/
  8002. #line 572 "./typica.w"
  8003. /*795:*/
  8004. #line 16894 "./typica.w"
  8005. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8006. lister(new QextSerialEnumerator)
  8007. {
  8008. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8009. QextPortInfo port;
  8010. foreach(port,ports)
  8011. {
  8012. #ifdef Q_OS_WIN32
  8013. addItem(port.portName);
  8014. #else
  8015. addItem(port.physName);
  8016. #endif
  8017. }
  8018. lister->setUpNotifications();
  8019. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8020. this,SLOT(addDevice(QextPortInfo)));
  8021. setEditable(true);
  8022. }
  8023. void PortSelector::addDevice(QextPortInfo port)
  8024. {
  8025. addItem(port.portName);
  8026. }
  8027. /*:795*/
  8028. #line 573 "./typica.w"
  8029. /*797:*/
  8030. #line 16986 "./typica.w"
  8031. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8032. {
  8033. QMetaObject meta= BaudSelector::staticMetaObject;
  8034. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8035. for(int i= 0;i<type.keyCount();i++)
  8036. {
  8037. addItem(QString("%1").arg(type.value(i)));
  8038. }
  8039. }
  8040. /*:797*/
  8041. #line 574 "./typica.w"
  8042. /*799:*/
  8043. #line 17024 "./typica.w"
  8044. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8045. {
  8046. QMetaObject meta= ParitySelector::staticMetaObject;
  8047. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8048. for(int i= 0;i<type.keyCount();i++)
  8049. {
  8050. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8051. }
  8052. }
  8053. /*:799*/
  8054. #line 575 "./typica.w"
  8055. /*801:*/
  8056. #line 17054 "./typica.w"
  8057. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8058. {
  8059. QMetaObject meta= FlowSelector::staticMetaObject;
  8060. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8061. for(int i= 0;i<type.keyCount();i++)
  8062. {
  8063. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8064. }
  8065. }
  8066. /*:801*/
  8067. #line 576 "./typica.w"
  8068. /*803:*/
  8069. #line 17089 "./typica.w"
  8070. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8071. {
  8072. QMetaObject meta= StopSelector::staticMetaObject;
  8073. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8074. for(int i= 0;i<type.keyCount();i++)
  8075. {
  8076. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8077. }
  8078. }
  8079. /*:803*/
  8080. #line 577 "./typica.w"
  8081. /*863:*/
  8082. #line 18874 "./typica.w"
  8083. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8084. :BasicDeviceConfigurationWidget(model,index),
  8085. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8086. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8087. decimalQuery(new QCheckBox(tr("Enable"))),
  8088. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8089. unitQuery(new QCheckBox(tr("Enable"))),
  8090. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8091. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8092. pVAddress(new ShortHexSpinBox),
  8093. sVEnabled(new QCheckBox(tr("Enable"))),
  8094. sVReadAddress(new ShortHexSpinBox),
  8095. deviceLimit(new QCheckBox(tr("Enable"))),
  8096. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8097. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8098. sVWritable(new QCheckBox(tr("Enable"))),
  8099. sVOutputAddr(new ShortHexSpinBox),
  8100. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8101. {
  8102. QHBoxLayout*layout= new QHBoxLayout;
  8103. QWidget*form= new QWidget;
  8104. QHBoxLayout*masterLayout= new QHBoxLayout;
  8105. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8106. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8107. QFormLayout*serialSection= new QFormLayout;
  8108. serialSection->addRow(QString(tr("Port:")),port);
  8109. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8110. serialSection->addRow(QString(tr("Parity:")),parity);
  8111. serialSection->addRow(QString(tr("Flow control:")),flow);
  8112. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8113. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8114. serialSectionBox->setLayout(serialSection);
  8115. portAndDeviceLayout->addWidget(serialSectionBox);
  8116. QFormLayout*deviceSection= new QFormLayout;
  8117. station->setMinimum(1);
  8118. station->setMaximum(255);
  8119. decimalPosition->setMinimum(0);
  8120. decimalPosition->setMaximum(9);
  8121. valueF->setMinimum(0);
  8122. valueF->setMaximum(0xFFFF);
  8123. valueC->setMinimum(0);
  8124. valueC->setMaximum(0xFFFF);
  8125. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8126. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8127. deviceSection->addRow(tr("Station:"),station);
  8128. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8129. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8130. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8131. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8132. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8133. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8134. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8135. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8136. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8137. deviceSectionBox->setLayout(deviceSection);
  8138. portAndDeviceLayout->addWidget(deviceSectionBox);
  8139. QFormLayout*pVSection= new QFormLayout;
  8140. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8141. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8142. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8143. pVSection->addRow(pVHideBox);
  8144. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8145. processValueBox->setLayout(pVSection);
  8146. seriesLayout->addWidget(processValueBox);
  8147. QFormLayout*sVSection= new QFormLayout;
  8148. sVLower->setDecimals(1);
  8149. sVLower->setMinimum(0.0);
  8150. sVLower->setMaximum(999.9);
  8151. sVUpper->setDecimals(1);
  8152. sVUpper->setMinimum(0.0);
  8153. sVUpper->setMaximum(999.9);
  8154. sVSection->addRow(tr("Set value:"),sVEnabled);
  8155. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8156. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8157. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8158. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8159. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8160. sVSection->addRow(tr("Lower limit:"),sVLower);
  8161. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8162. sVSection->addRow(tr("Output set value:"),sVWritable);
  8163. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8164. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8165. sVSection->addRow(sVHideBox);
  8166. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8167. setValueBox->setLayout(sVSection);
  8168. seriesLayout->addWidget(setValueBox);
  8169. masterLayout->addLayout(portAndDeviceLayout);
  8170. masterLayout->addLayout(seriesLayout);
  8171. form->setLayout(masterLayout);
  8172. /*771:*/
  8173. #line 16335 "./typica.w"
  8174. QDomElement referenceElement=
  8175. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8176. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8177. QDomElement node;
  8178. /*:771*/
  8179. #line 18964 "./typica.w"
  8180. for(int i= 0;i<configData.size();i++)
  8181. {
  8182. node= configData.at(i).toElement();
  8183. if(node.attribute("name")=="port")
  8184. {
  8185. QString portname= node.attribute("value");
  8186. int idx= port->findText(portname);
  8187. if(idx>=0)
  8188. {
  8189. port->setCurrentIndex(idx);
  8190. }
  8191. else
  8192. {
  8193. port->addItem(portname);
  8194. }
  8195. }
  8196. else if(node.attribute("name")=="baud")
  8197. {
  8198. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8199. }
  8200. else if(node.attribute("name")=="parity")
  8201. {
  8202. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8203. }
  8204. else if(node.attribute("name")=="flow")
  8205. {
  8206. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8207. }
  8208. else if(node.attribute("name")=="stop")
  8209. {
  8210. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8211. }
  8212. else if(node.attribute("name")=="station")
  8213. {
  8214. station->setValue(node.attribute("value").toInt());
  8215. }
  8216. else if(node.attribute("name")=="decimalQuery")
  8217. {
  8218. if(node.attribute("value")=="true")
  8219. {
  8220. decimalQuery->setChecked(true);
  8221. }
  8222. else
  8223. {
  8224. decimalQuery->setChecked(false);
  8225. }
  8226. }
  8227. else if(node.attribute("name")=="decimalAddress")
  8228. {
  8229. decimalAddress->setValue(node.attribute("value").toInt());
  8230. }
  8231. else if(node.attribute("name")=="decimalPosition")
  8232. {
  8233. decimalPosition->setValue(node.attribute("value").toInt());
  8234. }
  8235. else if(node.attribute("name")=="unitQuery")
  8236. {
  8237. if(node.attribute("value")=="true")
  8238. {
  8239. unitQuery->setChecked(true);
  8240. }
  8241. else
  8242. {
  8243. unitQuery->setChecked(false);
  8244. }
  8245. }
  8246. else if(node.attribute("name")=="unitAddress")
  8247. {
  8248. unitAddress->setValue(node.attribute("value").toInt());
  8249. }
  8250. else if(node.attribute("name")=="valueF")
  8251. {
  8252. valueF->setValue(node.attribute("value").toInt());
  8253. }
  8254. else if(node.attribute("name")=="valueC")
  8255. {
  8256. valueC->setValue(node.attribute("value").toInt());
  8257. }
  8258. else if(node.attribute("name")=="fixedUnit")
  8259. {
  8260. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8261. }
  8262. else if(node.attribute("name")=="pVAddress")
  8263. {
  8264. pVAddress->setValue(node.attribute("value").toInt());
  8265. }
  8266. else if(node.attribute("name")=="sVEnabled")
  8267. {
  8268. if(node.attribute("value")=="true")
  8269. {
  8270. sVEnabled->setChecked(true);
  8271. }
  8272. else
  8273. {
  8274. sVEnabled->setChecked(false);
  8275. }
  8276. }
  8277. else if(node.attribute("name")=="sVReadAddress")
  8278. {
  8279. sVReadAddress->setValue(node.attribute("value").toInt());
  8280. }
  8281. else if(node.attribute("name")=="deviceLimit")
  8282. {
  8283. if(node.attribute("value")=="true")
  8284. {
  8285. deviceLimit->setChecked(true);
  8286. }
  8287. else
  8288. {
  8289. deviceLimit->setChecked(false);
  8290. }
  8291. }
  8292. else if(node.attribute("name")=="sVLowerAddr")
  8293. {
  8294. sVLowerAddr->setValue(node.attribute("value").toInt());
  8295. }
  8296. else if(node.attribute("name")=="sVUpperAddr")
  8297. {
  8298. sVUpperAddr->setValue(node.attribute("value").toInt());
  8299. }
  8300. else if(node.attribute("name")=="sVLower")
  8301. {
  8302. sVLower->setValue(node.attribute("value").toDouble());
  8303. }
  8304. else if(node.attribute("name")=="sVUpper")
  8305. {
  8306. sVUpper->setValue(node.attribute("value").toDouble());
  8307. }
  8308. else if(node.attribute("name")=="sVWritable")
  8309. {
  8310. if(node.attribute("value")=="true")
  8311. {
  8312. sVWritable->setChecked(true);
  8313. }
  8314. else
  8315. {
  8316. sVWritable->setChecked(false);
  8317. }
  8318. }
  8319. else if(node.attribute("name")=="sVOutputAddr")
  8320. {
  8321. sVOutputAddr->setValue(node.attribute("value").toInt());
  8322. }
  8323. else if(node.attribute("name")=="pvcolname")
  8324. {
  8325. pVColumnName->setText(node.attribute("value"));
  8326. }
  8327. else if(node.attribute("name")=="svcolname")
  8328. {
  8329. sVColumnName->setText(node.attribute("value"));
  8330. }
  8331. else if(node.attribute("name")=="pvhidden")
  8332. {
  8333. pVHideBox->setChecked(node.attribute("value")=="true");
  8334. }
  8335. else if(node.attribute("name")=="svhidden")
  8336. {
  8337. sVHideBox->setChecked(node.attribute("value")=="true");
  8338. }
  8339. }
  8340. updatePort(port->currentText());
  8341. updateBaudRate(baud->currentText());
  8342. updateParity(parity->itemData(parity->currentIndex()).toString());
  8343. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8344. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8345. updateStation(station->value());
  8346. updateFixedDecimal(decimalQuery->isChecked());
  8347. updateDecimalAddress(decimalAddress->value());
  8348. updateDecimalPosition(decimalPosition->value());
  8349. updateFixedUnit(unitQuery->isChecked());
  8350. updateUnitAddress(unitAddress->value());
  8351. updateValueForF(valueF->value());
  8352. updateValueForC(valueC->value());
  8353. updateUnit(fixedUnit->currentText());
  8354. updatePVAddress(pVAddress->value());
  8355. updateSVEnabled(sVEnabled->isChecked());
  8356. updateSVReadAddress(sVReadAddress->value());
  8357. updateDeviceLimit(deviceLimit->isChecked());
  8358. updateSVLowerAddress(sVLowerAddr->value());
  8359. updateSVUpperAddress(sVUpperAddr->value());
  8360. updateSVLower(sVLower->value());
  8361. updateSVUpper(sVUpper->value());
  8362. updateSVWritable(sVWritable->isChecked());
  8363. updateSVWriteAddress(sVOutputAddr->value());
  8364. updatePVColumnName(pVColumnName->text());
  8365. updateSVColumnName(sVColumnName->text());
  8366. updatePVHidden(pVHideBox->isChecked());
  8367. updateSVHidden(sVHideBox->isChecked());
  8368. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8369. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8370. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8371. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8372. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8373. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8374. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8375. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8376. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8377. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8378. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8379. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8380. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8381. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8382. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8383. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8384. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8385. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8386. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8387. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8388. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8389. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8390. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8391. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8392. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8393. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8394. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8395. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8396. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8397. layout->addWidget(form);
  8398. setLayout(layout);
  8399. }
  8400. void ModbusConfigurator::updatePort(const QString&newPort)
  8401. {
  8402. updateAttribute("port",newPort);
  8403. }
  8404. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8405. {
  8406. updateAttribute("baud",newRate);
  8407. }
  8408. void ModbusConfigurator::updateParity(const QString&)
  8409. {
  8410. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8411. }
  8412. void ModbusConfigurator::updateFlowControl(const QString&)
  8413. {
  8414. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8415. }
  8416. void ModbusConfigurator::updateStopBits(const QString&)
  8417. {
  8418. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8419. }
  8420. void ModbusConfigurator::updateStation(int station)
  8421. {
  8422. updateAttribute("station",QString("%1").arg(station));
  8423. }
  8424. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8425. {
  8426. updateAttribute("decimalQuery",fixed?"true":"false");
  8427. }
  8428. void ModbusConfigurator::updateDecimalAddress(int address)
  8429. {
  8430. updateAttribute("decimalAddress",QString("%1").arg(address));
  8431. }
  8432. void ModbusConfigurator::updateDecimalPosition(int position)
  8433. {
  8434. updateAttribute("decimalPosition",QString("%1").arg(position));
  8435. }
  8436. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8437. {
  8438. updateAttribute("unitQuery",fixed?"true":"false");
  8439. }
  8440. void ModbusConfigurator::updateUnitAddress(int address)
  8441. {
  8442. updateAttribute("unitAddress",QString("%1").arg(address));
  8443. }
  8444. void ModbusConfigurator::updateValueForF(int value)
  8445. {
  8446. updateAttribute("valueF",QString("%1").arg(value));
  8447. }
  8448. void ModbusConfigurator::updateValueForC(int value)
  8449. {
  8450. updateAttribute("valueC",QString("%1").arg(value));
  8451. }
  8452. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8453. {
  8454. updateAttribute("fixedUnit",newUnit);
  8455. }
  8456. void ModbusConfigurator::updatePVAddress(int address)
  8457. {
  8458. updateAttribute("pVAddress",QString("%1").arg(address));
  8459. }
  8460. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8461. {
  8462. updateAttribute("sVEnabled",enabled?"true":"false");
  8463. }
  8464. void ModbusConfigurator::updateSVReadAddress(int address)
  8465. {
  8466. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8467. }
  8468. void ModbusConfigurator::updateDeviceLimit(bool query)
  8469. {
  8470. updateAttribute("deviceLimit",query?"true":"false");
  8471. }
  8472. void ModbusConfigurator::updateSVLowerAddress(int address)
  8473. {
  8474. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8475. }
  8476. void ModbusConfigurator::updateSVUpperAddress(int address)
  8477. {
  8478. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8479. }
  8480. void ModbusConfigurator::updateSVLower(double value)
  8481. {
  8482. updateAttribute("sVLower",QString("%1").arg(value));
  8483. }
  8484. void ModbusConfigurator::updateSVUpper(double value)
  8485. {
  8486. updateAttribute("sVUpper",QString("%1").arg(value));
  8487. }
  8488. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8489. {
  8490. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8491. }
  8492. void ModbusConfigurator::updateSVWriteAddress(int address)
  8493. {
  8494. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8495. }
  8496. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8497. {
  8498. updateAttribute("pvcolname",name);
  8499. }
  8500. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8501. {
  8502. updateAttribute("svcolname",name);
  8503. }
  8504. void ModbusConfigurator::updatePVHidden(bool hidden)
  8505. {
  8506. updateAttribute("pvhidden",hidden?"true":"false");
  8507. }
  8508. void ModbusConfigurator::updateSVHidden(bool hidden)
  8509. {
  8510. updateAttribute("svhidden",hidden?"true":"false");
  8511. }
  8512. /*:863*/
  8513. #line 578 "./typica.w"
  8514. /*806:*/
  8515. #line 17142 "./typica.w"
  8516. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8517. {
  8518. setMinimum(0);
  8519. setMaximum(0xFFFF);
  8520. setPrefix("0x");
  8521. setMinimumWidth(65);
  8522. }
  8523. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8524. {
  8525. if(input.size()==2)
  8526. {
  8527. return QValidator::Intermediate;
  8528. }
  8529. bool okay;
  8530. input.toInt(&okay,16);
  8531. if(okay)
  8532. {
  8533. return QValidator::Acceptable;
  8534. }
  8535. return QValidator::Invalid;
  8536. }
  8537. int ShortHexSpinBox::valueFromText(const QString&text)const
  8538. {
  8539. return text.toInt(NULL,16);
  8540. }
  8541. QString ShortHexSpinBox::textFromValue(int value)const
  8542. {
  8543. QString retval;
  8544. retval.setNum(value,16);
  8545. while(retval.size()<4)
  8546. {
  8547. retval.prepend("0");
  8548. }
  8549. return retval.toUpper();
  8550. }
  8551. /*:806*/
  8552. #line 579 "./typica.w"
  8553. /*847:*/
  8554. #line 18174 "./typica.w"
  8555. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8556. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8557. waiting(false)
  8558. {
  8559. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8560. Qt::UserRole).toString());
  8561. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8562. QDomElement node;
  8563. QVariantMap attributes;
  8564. for(int i= 0;i<portConfigData.size();i++)
  8565. {
  8566. node= portConfigData.at(i).toElement();
  8567. attributes.insert(node.attribute("name"),node.attribute("value"));
  8568. }
  8569. port= new QextSerialPort(attributes.value("port").toString(),
  8570. QextSerialPort::EventDriven);
  8571. int baudRate= attributes.value("baud").toInt();
  8572. port->setBaudRate((BaudRateType)baudRate);
  8573. double temp= ((double)(1)/(double)(baudRate))*48;
  8574. delayTime= (int)(temp*3000);
  8575. messageDelayTimer->setSingleShot(true);
  8576. commTimeout->setSingleShot(true);
  8577. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8578. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8579. port->setDataBits(DATA_8);
  8580. port->setParity((ParityType)attributes.value("parity").toInt());
  8581. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8582. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8583. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8584. port->open(QIODevice::ReadWrite);
  8585. station= (char)attributes.value("station").toInt();
  8586. if(attributes.value("decimalQuery")=="true")
  8587. {
  8588. decimalPosition= 0;
  8589. QByteArray message;
  8590. message.append(station);
  8591. message.append((char)0x03);
  8592. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8593. char*addressBytes= (char*)&address;
  8594. message.append(addressBytes[1]);
  8595. message.append(addressBytes[0]);
  8596. message.append((char)0x00);
  8597. message.append((char)0x01);
  8598. queueMessage(message,this,"decimalResponse(QByteArray)");
  8599. }
  8600. else
  8601. {
  8602. decimalPosition= attributes.value("decimalPosition").toInt();
  8603. }
  8604. valueF= attributes.value("valueF").toInt();
  8605. valueC= attributes.value("valueC").toInt();
  8606. if(attributes.value("unitQuery")=="true")
  8607. {
  8608. QByteArray message;
  8609. message.append(station);
  8610. message.append((char)0x03);
  8611. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8612. char*addressBytes= (char*)&address;
  8613. message.append(addressBytes[1]);
  8614. message.append(addressBytes[0]);
  8615. message.append((char)0x00);
  8616. message.append((char)0x01);
  8617. queueMessage(message,this,"unitResponse(QByteArray)");
  8618. }
  8619. else
  8620. {
  8621. if(attributes.value("fixedUnit")=="Celsius")
  8622. {
  8623. unitIsF= false;
  8624. }
  8625. }
  8626. if(attributes.value("sVWritable")=="true")
  8627. {
  8628. if(attributes.value("deviceLimit")=="true")
  8629. {
  8630. QByteArray lmessage;
  8631. lmessage.append(station);
  8632. lmessage.append((char)0x03);
  8633. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8634. char*addressBytes= (char*)&laddress;
  8635. lmessage.append(addressBytes[1]);
  8636. lmessage.append(addressBytes[0]);
  8637. lmessage.append((char)0x00);
  8638. lmessage.append((char)0x01);
  8639. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8640. QByteArray umessage;
  8641. umessage.append(station);
  8642. umessage.append((char)0x03);
  8643. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8644. addressBytes= (char*)&uaddress;
  8645. umessage.append(addressBytes[1]);
  8646. umessage.append(addressBytes[0]);
  8647. umessage.append((char)0x00);
  8648. umessage.append((char)0x01);
  8649. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8650. }
  8651. else
  8652. {
  8653. outputSVLower= attributes.value("sVLower").toDouble();
  8654. outputSVUpper= attributes.value("sVUpper").toDouble();
  8655. }
  8656. outputSVStub.append(station);
  8657. outputSVStub.append((char)0x06);
  8658. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8659. char*addressBytes= (char*)&address;
  8660. outputSVStub.append(addressBytes[1]);
  8661. outputSVStub.append(addressBytes[0]);
  8662. }
  8663. Channel*pv= new Channel;
  8664. channels.append(pv);
  8665. pvStub.append(station);
  8666. pvStub.append((char)0x04);
  8667. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8668. char*pvac= (char*)&pvaddress;
  8669. pvStub.append(pvac[1]);
  8670. pvStub.append(pvac[0]);
  8671. pvStub.append((char)0x00);
  8672. pvStub.append((char)0x01);
  8673. svenabled= attributes.value("sVEnabled").toBool();
  8674. if(svenabled)
  8675. {
  8676. Channel*sv= new Channel;
  8677. channels.append(sv);
  8678. svStub.append(station);
  8679. svStub.append((char)0x04);
  8680. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8681. char*svac= (char*)&svaddress;
  8682. svStub.append(svac[1]);
  8683. svStub.append(svac[0]);
  8684. svStub.append((char)0x00);
  8685. svStub.append((char)0x01);
  8686. if(svaddress-pvaddress==1)
  8687. {
  8688. mStub.append(station);
  8689. mStub.append((char)0x04);
  8690. mStub.append(pvac[1]);
  8691. mStub.append(pvac[0]);
  8692. mStub.append((char)0x00);
  8693. mStub.append((char)0x02);
  8694. }
  8695. }
  8696. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8697. requestMeasurement();
  8698. }
  8699. double ModbusRTUDevice::SVLower()
  8700. {
  8701. return outputSVLower;
  8702. }
  8703. double ModbusRTUDevice::SVUpper()
  8704. {
  8705. return outputSVUpper;
  8706. }
  8707. int ModbusRTUDevice::decimals()
  8708. {
  8709. return decimalPosition;
  8710. }
  8711. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8712. {
  8713. quint16 temp;
  8714. char*tchar= (char*)&temp;
  8715. tchar[1]= response.at(3);
  8716. tchar[0]= response.at(4);
  8717. decimalPosition= temp;
  8718. emit SVDecimalChanged(decimalPosition);
  8719. qDebug()<<"Received decimal response";
  8720. }
  8721. void ModbusRTUDevice::unitResponse(QByteArray response)
  8722. {
  8723. quint16 temp;
  8724. char*tchar= (char*)&temp;
  8725. tchar[1]= response.at(3);
  8726. tchar[0]= response.at(4);
  8727. int value= temp;
  8728. if(value==valueF)
  8729. {
  8730. unitIsF= true;
  8731. }
  8732. else
  8733. {
  8734. unitIsF= false;
  8735. }
  8736. qDebug()<<"Received unit response";
  8737. }
  8738. void ModbusRTUDevice::svlResponse(QByteArray response)
  8739. {
  8740. quint16 temp;
  8741. char*tchar= (char*)&temp;
  8742. tchar[1]= response.at(3);
  8743. tchar[0]= response.at(4);
  8744. outputSVLower= (double)temp;
  8745. for(int i= 0;i<decimalPosition;i++)
  8746. {
  8747. outputSVLower/= 10;
  8748. }
  8749. emit SVLowerChanged(outputSVLower);
  8750. qDebug()<<"Received set value lower bound response";
  8751. }
  8752. void ModbusRTUDevice::svuResponse(QByteArray response)
  8753. {
  8754. quint16 temp;
  8755. char*tchar= (char*)&temp;
  8756. tchar[1]= response.at(3);
  8757. tchar[0]= response.at(4);
  8758. outputSVUpper= (double)temp;
  8759. for(int i= 0;i<decimalPosition;i++)
  8760. {
  8761. outputSVUpper/= 10;
  8762. }
  8763. emit SVUpperChanged(outputSVUpper);
  8764. qDebug()<<"Received set value upper bound response";
  8765. }
  8766. void ModbusRTUDevice::requestMeasurement()
  8767. {
  8768. if(mStub.length()> 0)
  8769. {
  8770. queueMessage(mStub,this,"mResponse(QByteArray)");
  8771. }
  8772. else
  8773. {
  8774. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8775. if(svenabled)
  8776. {
  8777. queueMessage(svStub,this,"mResponse(QByteArray)");
  8778. }
  8779. }
  8780. }
  8781. void ModbusRTUDevice::mResponse(QByteArray response)
  8782. {
  8783. QTime time= QTime::currentTime();
  8784. if(response.at(2)==0x04)
  8785. {
  8786. /*848:*/
  8787. #line 18428 "./typica.w"
  8788. quint16 pv;
  8789. quint16 sv;
  8790. char*pvBytes= (char*)&pv;
  8791. char*svBytes= (char*)&sv;
  8792. pvBytes[1]= response.at(3);
  8793. pvBytes[0]= response.at(4);
  8794. svBytes[1]= response.at(5);
  8795. svBytes[0]= response.at(6);
  8796. double pvOut= (double)pv;
  8797. double svOut= (double)sv;
  8798. for(int i= 0;i<decimalPosition;i++)
  8799. {
  8800. pvOut/= 10;
  8801. svOut/= 10;
  8802. }
  8803. if(!unitIsF)
  8804. {
  8805. pvOut= pvOut*9/5+32;
  8806. svOut= svOut*9/5+32;
  8807. }
  8808. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8809. Measurement svm(svOut,time,Units::Fahrenheit);
  8810. channels.at(0)->input(pvm);
  8811. channels.at(1)->input(svm);
  8812. /*:848*/
  8813. #line 18415 "./typica.w"
  8814. }
  8815. else
  8816. {
  8817. /*849:*/
  8818. #line 18458 "./typica.w"
  8819. quint16 value;
  8820. char*valueBytes= (char*)&value;
  8821. valueBytes[1]= response.at(3);
  8822. valueBytes[0]= response.at(4);
  8823. double valueOut= (double)value;
  8824. for(int i= 0;i<decimalPosition;i++)
  8825. {
  8826. valueOut/= 10;
  8827. }
  8828. if(!unitIsF)
  8829. {
  8830. valueOut= valueOut*9/5+32;
  8831. }
  8832. if(!svenabled)
  8833. {
  8834. Measurement vm(valueOut,time,Units::Fahrenheit);
  8835. channels.at(0)->input(vm);
  8836. }
  8837. else
  8838. {
  8839. if(readingsv)
  8840. {
  8841. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8842. Measurement svm(valueOut,time,Units::Fahrenheit);
  8843. channels.at(0)->input(pvm);
  8844. channels.at(1)->input(svm);
  8845. readingsv= false;
  8846. }
  8847. else
  8848. {
  8849. savedpv= valueOut;
  8850. readingsv= true;
  8851. }
  8852. }
  8853. /*:849*/
  8854. #line 18419 "./typica.w"
  8855. }
  8856. }
  8857. /*:847*//*850:*/
  8858. #line 18496 "./typica.w"
  8859. ModbusRTUDevice::~ModbusRTUDevice()
  8860. {
  8861. commTimeout->stop();
  8862. messageDelayTimer->stop();
  8863. port->close();
  8864. }
  8865. /*:850*//*851:*/
  8866. #line 18523 "./typica.w"
  8867. void ModbusRTUDevice::dataAvailable()
  8868. {
  8869. if(messageDelayTimer->isActive())
  8870. {
  8871. messageDelayTimer->stop();
  8872. }
  8873. responseBuffer.append(port->readAll());
  8874. /*852:*/
  8875. #line 18569 "./typica.w"
  8876. if(responseBuffer.size()<5)
  8877. {
  8878. return;
  8879. }
  8880. switch(responseBuffer.at(1))
  8881. {
  8882. case 0x01:
  8883. case 0x02:
  8884. if(responseBuffer.size()<6)
  8885. {
  8886. return;
  8887. }
  8888. responseBuffer= responseBuffer.left(6);
  8889. break;
  8890. case 0x03:
  8891. case 0x04:
  8892. if(responseBuffer.size()<5+responseBuffer.at(2))
  8893. {
  8894. return;
  8895. }
  8896. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8897. break;
  8898. case 0x05:
  8899. case 0x06:
  8900. case 0x10:
  8901. if(responseBuffer.size()<8)
  8902. {
  8903. return;
  8904. }
  8905. responseBuffer= responseBuffer.left(8);
  8906. break;
  8907. }
  8908. /*:852*/
  8909. #line 18531 "./typica.w"
  8910. commTimeout->stop();
  8911. if(calculateCRC(responseBuffer)==0)
  8912. {
  8913. QObject*object= retObjQueue.at(0);
  8914. char*method= callbackQueue.at(0);
  8915. QMetaMethod metamethod= object->metaObject()->
  8916. method(object->metaObject()->
  8917. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8918. metamethod.invoke(object,Qt::QueuedConnection,
  8919. Q_ARG(QByteArray,responseBuffer));
  8920. messageQueue.removeAt(0);
  8921. retObjQueue.removeAt(0);
  8922. callbackQueue.removeAt(0);
  8923. }
  8924. else
  8925. {
  8926. qDebug()<<"CRC failed";
  8927. }
  8928. messageDelayTimer->start(delayTime);
  8929. waiting= false;
  8930. responseBuffer.clear();
  8931. }
  8932. /*:851*//*853:*/
  8933. #line 18611 "./typica.w"
  8934. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8935. {
  8936. quint16 retval= 0xFFFF;
  8937. int i= 0;
  8938. while(i<data.size())
  8939. {
  8940. retval^= 0x00FF&(quint16)data.at(i);
  8941. for(int j= 0;j<8;j++)
  8942. {
  8943. if(retval&1)
  8944. {
  8945. retval= (retval>>1)^0xA001;
  8946. }
  8947. else
  8948. {
  8949. retval>>= 1;
  8950. }
  8951. }
  8952. i++;
  8953. }
  8954. return retval;
  8955. }
  8956. /*:853*//*854:*/
  8957. #line 18642 "./typica.w"
  8958. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  8959. const char*callback)
  8960. {
  8961. messageQueue.append(request);
  8962. retObjQueue.append(object);
  8963. callbackQueue.append(const_cast<char*> (callback));
  8964. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  8965. {
  8966. sendNextMessage();
  8967. }
  8968. }
  8969. void ModbusRTUDevice::sendNextMessage()
  8970. {
  8971. if(messageQueue.size()> 0&&!waiting)
  8972. {
  8973. QByteArray message= messageQueue.at(0);
  8974. quint16 crc= calculateCRC(message);
  8975. char*check= (char*)&crc;
  8976. message.append(check[0]);
  8977. message.append(check[1]);
  8978. port->write(message);
  8979. commTimeout->start(2000);
  8980. messageDelayTimer->start(delayTime);
  8981. waiting= true;
  8982. }
  8983. else
  8984. {
  8985. emit queueEmpty();
  8986. }
  8987. }
  8988. void ModbusRTUDevice::outputSV(double value)
  8989. {
  8990. for(int i= 0;i<decimalPosition;i++)
  8991. {
  8992. value*= 10;
  8993. }
  8994. quint16 outval= (quint16)value;
  8995. QByteArray message(outputSVStub);
  8996. char*valBytes= (char*)&outval;
  8997. message.append(valBytes[1]);
  8998. message.append(valBytes[0]);
  8999. queueMessage(message,this,"ignore(QByteArray)");
  9000. }
  9001. /*:854*//*855:*/
  9002. #line 18691 "./typica.w"
  9003. void ModbusRTUDevice::ignore(QByteArray)
  9004. {
  9005. return;
  9006. }
  9007. /*:855*//*856:*/
  9008. #line 18704 "./typica.w"
  9009. void ModbusRTUDevice::timeout()
  9010. {
  9011. qDebug()<<"Communications timeout.";
  9012. responseBuffer.clear();
  9013. waiting= false;
  9014. messageDelayTimer->start();
  9015. }
  9016. /*:856*/
  9017. #line 580 "./typica.w"
  9018. /*725:*/
  9019. #line 15260 "./typica.w"
  9020. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9021. DeviceTreeModelNode*parent)
  9022. :domNode(node),rowNumber(row),parentItem(parent)
  9023. {
  9024. }
  9025. DeviceTreeModelNode::~DeviceTreeModelNode()
  9026. {
  9027. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9028. for(i= children.begin();i!=children.end();i++)
  9029. {
  9030. delete i.value();
  9031. }
  9032. }
  9033. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9034. {
  9035. return parentItem;
  9036. }
  9037. int DeviceTreeModelNode::row()
  9038. {
  9039. return rowNumber;
  9040. }
  9041. QDomNode DeviceTreeModelNode::node()const
  9042. {
  9043. return domNode;
  9044. }
  9045. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9046. {
  9047. if(children.contains(index))
  9048. {
  9049. return children[index];
  9050. }
  9051. if(index>=0&&index<domNode.childNodes().count())
  9052. {
  9053. QDomNode childNode= domNode.childNodes().item(index);
  9054. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9055. index,this);
  9056. children[index]= childItem;
  9057. return childItem;
  9058. }
  9059. return NULL;
  9060. }
  9061. /*:725*/
  9062. #line 581 "./typica.w"
  9063. /*727:*/
  9064. #line 15349 "./typica.w"
  9065. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9066. :QAbstractItemModel(parent)
  9067. {
  9068. document= AppInstance->deviceConfiguration();
  9069. QDomNodeList elements= document.elementsByTagName("devices");
  9070. if(elements.size()!=1)
  9071. {
  9072. qDebug()<<"Unexpected result when loading device map.";
  9073. }
  9074. treeRoot= elements.at(0);
  9075. root= new DeviceTreeModelNode(treeRoot,0);
  9076. elements= document.elementsByTagName("references");
  9077. if(elements.size()!=1)
  9078. {
  9079. qDebug()<<"No references section. Creating.";
  9080. referenceSection= document.createElement("references");
  9081. document.appendChild(referenceSection);
  9082. }
  9083. else
  9084. {
  9085. referenceSection= elements.at(0);
  9086. }
  9087. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9088. AppInstance,SLOT(saveDeviceConfiguration()));
  9089. connect(this,SIGNAL(modelReset()),
  9090. AppInstance,SLOT(saveDeviceConfiguration()));
  9091. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9092. AppInstance,SLOT(saveDeviceConfiguration()));
  9093. }
  9094. /*:727*//*728:*/
  9095. #line 15384 "./typica.w"
  9096. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9097. {
  9098. return 1;
  9099. }
  9100. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9101. {
  9102. if(parent.column()> 0)
  9103. {
  9104. return 0;
  9105. }
  9106. /*729:*/
  9107. #line 15403 "./typica.w"
  9108. DeviceTreeModelNode*parentItem;
  9109. if(!parent.isValid())
  9110. {
  9111. parentItem= root;
  9112. }
  9113. else
  9114. {
  9115. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9116. }
  9117. /*:729*/
  9118. #line 15396 "./typica.w"
  9119. return parentItem->node().childNodes().count();
  9120. }
  9121. /*:728*//*730:*/
  9122. #line 15417 "./typica.w"
  9123. QModelIndex DeviceTreeModel::index(int row,int column,
  9124. const QModelIndex&parent)const
  9125. {
  9126. if(!hasIndex(row,column,parent))
  9127. {
  9128. return QModelIndex();
  9129. }
  9130. /*729:*/
  9131. #line 15403 "./typica.w"
  9132. DeviceTreeModelNode*parentItem;
  9133. if(!parent.isValid())
  9134. {
  9135. parentItem= root;
  9136. }
  9137. else
  9138. {
  9139. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9140. }
  9141. /*:729*/
  9142. #line 15425 "./typica.w"
  9143. DeviceTreeModelNode*childItem= parentItem->child(row);
  9144. if(childItem)
  9145. {
  9146. return createIndex(row,column,childItem);
  9147. }
  9148. return QModelIndex();
  9149. }
  9150. /*:730*//*731:*/
  9151. #line 15436 "./typica.w"
  9152. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9153. {
  9154. if(!child.isValid())
  9155. {
  9156. return QModelIndex();
  9157. }
  9158. DeviceTreeModelNode*childItem=
  9159. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9160. DeviceTreeModelNode*parentItem= childItem->parent();
  9161. if(!parentItem||parentItem==root)
  9162. {
  9163. return QModelIndex();
  9164. }
  9165. return createIndex(parentItem->row(),0,parentItem);
  9166. }
  9167. /*:731*//*732:*/
  9168. #line 15455 "./typica.w"
  9169. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9170. {
  9171. if(!index.isValid())
  9172. {
  9173. return 0;
  9174. }
  9175. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9176. }
  9177. /*:732*//*733:*/
  9178. #line 15470 "./typica.w"
  9179. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9180. {
  9181. if(!index.isValid())
  9182. {
  9183. return QVariant();
  9184. }
  9185. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9186. {
  9187. return QVariant();
  9188. }
  9189. DeviceTreeModelNode*item=
  9190. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9191. QDomNode node= item->node();
  9192. QDomElement element= node.toElement();
  9193. switch(role)
  9194. {
  9195. case Qt::DisplayRole:
  9196. case Qt::EditRole:
  9197. return QVariant(element.attribute("name"));
  9198. case Qt::UserRole:
  9199. return QVariant(element.attribute("reference"));
  9200. default:
  9201. return QVariant();
  9202. }
  9203. return QVariant();
  9204. }
  9205. /*:733*//*734:*/
  9206. #line 15502 "./typica.w"
  9207. bool DeviceTreeModel::setData(const QModelIndex&index,
  9208. const QVariant&value,int)
  9209. {
  9210. if(!index.isValid())
  9211. {
  9212. return false;
  9213. }
  9214. DeviceTreeModelNode*item=
  9215. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9216. QDomNode node= item->node();
  9217. QDomElement element= node.toElement();
  9218. element.setAttribute("name",value.toString());
  9219. emit dataChanged(index,index);
  9220. return true;
  9221. }
  9222. /*:734*//*735:*/
  9223. #line 15525 "./typica.w"
  9224. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9225. const QModelIndex&parent)
  9226. {
  9227. QString referenceID= QUuid::createUuid().toString();
  9228. /*729:*/
  9229. #line 15403 "./typica.w"
  9230. DeviceTreeModelNode*parentItem;
  9231. if(!parent.isValid())
  9232. {
  9233. parentItem= root;
  9234. }
  9235. else
  9236. {
  9237. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9238. }
  9239. /*:729*/
  9240. #line 15530 "./typica.w"
  9241. QDomNode parentNode= parentItem->node();
  9242. int newRowNumber= rowCount(parent);
  9243. beginInsertRows(parent,newRowNumber,newRowNumber);
  9244. QDomElement deviceElement= document.createElement("node");
  9245. deviceElement.setAttribute("name",name);
  9246. deviceElement.setAttribute("reference",referenceID);
  9247. parentNode.appendChild(deviceElement);
  9248. QDomElement referenceElement= document.createElement("reference");
  9249. referenceElement.setAttribute("id",referenceID);
  9250. referenceElement.setAttribute("driver",driver);
  9251. referenceSection.appendChild(referenceElement);
  9252. endInsertRows();
  9253. }
  9254. /*:735*//*736:*/
  9255. #line 15548 "./typica.w"
  9256. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9257. {
  9258. /*729:*/
  9259. #line 15403 "./typica.w"
  9260. DeviceTreeModelNode*parentItem;
  9261. if(!parent.isValid())
  9262. {
  9263. parentItem= root;
  9264. }
  9265. else
  9266. {
  9267. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9268. }
  9269. /*:729*/
  9270. #line 15551 "./typica.w"
  9271. QDomNode parentNode= parentItem->node();
  9272. QDomNodeList childNodes= parentNode.childNodes();
  9273. if(childNodes.size()<row+count)
  9274. {
  9275. return false;
  9276. }
  9277. beginRemoveRows(parent,row,row+count-1);
  9278. QList<QDomElement> removalList;
  9279. for(int i= row;i<row+count;i++)
  9280. {
  9281. removalList.append(childNodes.at(i).toElement());
  9282. }
  9283. QDomElement element;
  9284. QDomElement reference;
  9285. for(int i= 0;i<count;i++)
  9286. {
  9287. element= removalList.at(i);
  9288. if(element.hasAttribute("reference"))
  9289. {
  9290. reference= referenceElement(element.attribute("reference"));
  9291. if(!reference.isNull())
  9292. {
  9293. referenceSection.removeChild(reference);
  9294. }
  9295. }
  9296. parentNode.removeChild(element);
  9297. }
  9298. endRemoveRows();
  9299. beginResetModel();
  9300. delete root;
  9301. root= new DeviceTreeModelNode(treeRoot,0);
  9302. endResetModel();
  9303. return true;
  9304. }
  9305. /*:736*//*737:*/
  9306. #line 15590 "./typica.w"
  9307. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9308. {
  9309. QDomNodeList childNodes= referenceSection.childNodes();
  9310. QDomElement element;
  9311. for(int i= 0;i<childNodes.size();i++)
  9312. {
  9313. element= childNodes.at(i).toElement();
  9314. if(element.hasAttribute("id"))
  9315. {
  9316. if(element.attribute("id")==id)
  9317. {
  9318. return element;
  9319. }
  9320. }
  9321. }
  9322. return QDomElement();
  9323. }
  9324. /*:737*//*738:*/
  9325. #line 15611 "./typica.w"
  9326. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9327. {
  9328. return QVariant();
  9329. }
  9330. /*:738*//*739:*/
  9331. #line 15620 "./typica.w"
  9332. DeviceTreeModel::~DeviceTreeModel()
  9333. {
  9334. delete root;
  9335. }
  9336. /*:739*/
  9337. #line 582 "./typica.w"
  9338. /*766:*/
  9339. #line 16120 "./typica.w"
  9340. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9341. DeviceTreeModel*model,const QModelIndex&index)
  9342. :QWidget(NULL),deviceModel(model),currentNode(index)
  9343. {
  9344. }
  9345. /*:766*//*767:*/
  9346. #line 16132 "./typica.w"
  9347. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9348. const QString&value)
  9349. {
  9350. QDomElement referenceElement= deviceModel->referenceElement(
  9351. deviceModel->data(currentNode,Qt::UserRole).toString());
  9352. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9353. QDomElement node;
  9354. bool found= false;
  9355. for(int i= 0;i<configData.size();i++)
  9356. {
  9357. node= configData.at(i).toElement();
  9358. if(node.attribute("name")==name)
  9359. {
  9360. node.setAttribute("value",value);
  9361. found= true;
  9362. break;
  9363. }
  9364. }
  9365. if(!found)
  9366. {
  9367. node= AppInstance->deviceConfiguration().createElement("attribute");
  9368. node.setAttribute("name",name);
  9369. node.setAttribute("value",value);
  9370. referenceElement.appendChild(node);
  9371. }
  9372. AppInstance->saveDeviceConfiguration();
  9373. }
  9374. /*:767*//*768:*/
  9375. #line 16166 "./typica.w"
  9376. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9377. const QString&driver)
  9378. {
  9379. deviceModel->newNode(name,driver,currentNode);
  9380. }
  9381. /*:768*/
  9382. #line 583 "./typica.w"
  9383. /*757:*/
  9384. #line 15964 "./typica.w"
  9385. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9386. view(new QTreeView),configArea(new QScrollArea)
  9387. {
  9388. QSplitter*splitter= new QSplitter;
  9389. QWidget*leftWidget= new QWidget;
  9390. leftWidget->setMinimumWidth(200);
  9391. QVBoxLayout*left= new QVBoxLayout;
  9392. view->setAnimated(true);
  9393. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9394. document= AppInstance->deviceConfiguration();
  9395. model= new DeviceTreeModel;
  9396. view->setModel(model);
  9397. view->setTextElideMode(Qt::ElideNone);
  9398. view->expandAll();
  9399. view->resizeColumnToContents(0);
  9400. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9401. QHBoxLayout*treeButtons= new QHBoxLayout;
  9402. QToolButton*addDeviceButton= new QToolButton;
  9403. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9404. addDeviceButton->setToolTip(tr("New Roaster"));
  9405. connect(addDeviceButton,SIGNAL(clicked()),
  9406. this,SLOT(addDevice()));
  9407. QToolButton*removeNodeButton= new QToolButton;
  9408. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9409. removeNodeButton->setToolTip(tr("Delete Selection"));
  9410. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9411. treeButtons->addWidget(addDeviceButton);
  9412. treeButtons->addWidget(removeNodeButton);
  9413. left->addWidget(view);
  9414. left->addLayout(treeButtons);
  9415. leftWidget->setLayout(left);
  9416. splitter->addWidget(leftWidget);
  9417. configArea->setMinimumWidth(580);
  9418. configArea->setMinimumHeight(460);
  9419. configArea->setWidgetResizable(true);
  9420. splitter->addWidget(configArea);
  9421. QVBoxLayout*centralLayout= new QVBoxLayout;
  9422. centralLayout->addWidget(splitter);
  9423. setLayout(centralLayout);
  9424. connect(view,SIGNAL(activated(QModelIndex)),
  9425. this,SLOT(newSelection(QModelIndex)));
  9426. connect(view,SIGNAL(clicked(QModelIndex)),
  9427. this,SLOT(newSelection(QModelIndex)));
  9428. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9429. view,SLOT(expand(QModelIndex)));
  9430. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9431. this,SLOT(resizeColumn()));
  9432. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9433. this,SLOT(resizeColumn()));
  9434. }
  9435. /*:757*//*758:*/
  9436. #line 16019 "./typica.w"
  9437. void DeviceConfigurationWindow::addDevice()
  9438. {
  9439. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9440. }
  9441. /*:758*//*759:*/
  9442. #line 16027 "./typica.w"
  9443. void DeviceConfigurationWindow::removeNode()
  9444. {
  9445. QModelIndex index= view->currentIndex();
  9446. if(index.isValid())
  9447. {
  9448. int row= index.row();
  9449. QModelIndex parent= index.parent();
  9450. model->removeRow(row,parent);
  9451. }
  9452. }
  9453. /*:759*//*760:*/
  9454. #line 16043 "./typica.w"
  9455. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9456. {
  9457. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9458. if(editor)
  9459. {
  9460. configArea->setWidget(editor);
  9461. editor->show();
  9462. }
  9463. }
  9464. /*:760*//*761:*/
  9465. #line 16060 "./typica.w"
  9466. void DeviceConfigurationWindow::resizeColumn()
  9467. {
  9468. view->resizeColumnToContents(0);
  9469. }
  9470. /*:761*/
  9471. #line 584 "./typica.w"
  9472. /*781:*/
  9473. #line 16541 "./typica.w"
  9474. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9475. const QModelIndex&index):
  9476. BasicDeviceConfigurationWidget(model,index)
  9477. {
  9478. QFormLayout*layout= new QFormLayout;
  9479. QLineEdit*columnName= new QLineEdit;
  9480. layout->addRow(tr("Column Name:"),columnName);
  9481. QComboBox*typeSelector= new QComboBox;
  9482. typeSelector->addItem("J");
  9483. typeSelector->addItem("K");
  9484. typeSelector->addItem("T");
  9485. typeSelector->addItem("B");
  9486. typeSelector->addItem("E");
  9487. typeSelector->addItem("N");
  9488. typeSelector->addItem("R");
  9489. typeSelector->addItem("S");
  9490. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9491. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9492. layout->addRow(hideSeries);
  9493. setLayout(layout);
  9494. /*771:*/
  9495. #line 16335 "./typica.w"
  9496. QDomElement referenceElement=
  9497. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9498. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9499. QDomElement node;
  9500. /*:771*/
  9501. #line 16562 "./typica.w"
  9502. for(int i= 0;i<configData.size();i++)
  9503. {
  9504. node= configData.at(i).toElement();
  9505. if(node.attribute("name")=="type")
  9506. {
  9507. typeSelector->setCurrentIndex(
  9508. typeSelector->findText(node.attribute("value")));
  9509. }
  9510. else if(node.attribute("name")=="columnname")
  9511. {
  9512. columnName->setText(node.attribute("value"));
  9513. }
  9514. else if(node.attribute("name")=="hidden")
  9515. {
  9516. hideSeries->setChecked(node.attribute("value")=="true");
  9517. }
  9518. }
  9519. updateThermocoupleType(typeSelector->currentText());
  9520. updateColumnName(columnName->text());
  9521. updateHidden(hideSeries->isChecked());
  9522. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9523. this,SLOT(updateThermocoupleType(QString)));
  9524. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9525. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9526. }
  9527. /*:781*//*782:*/
  9528. #line 16592 "./typica.w"
  9529. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9530. {
  9531. updateAttribute("type",type);
  9532. }
  9533. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9534. {
  9535. updateAttribute("columnname",name);
  9536. }
  9537. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9538. {
  9539. updateAttribute("hidden",hidden?"true":"false");
  9540. }
  9541. /*:782*/
  9542. #line 585 "./typica.w"
  9543. /*777:*/
  9544. #line 16455 "./typica.w"
  9545. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9546. const QModelIndex&index)
  9547. :BasicDeviceConfigurationWidget(model,index)
  9548. {
  9549. QVBoxLayout*layout= new QVBoxLayout;
  9550. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9551. QLabel*label= new QLabel(tr("Device ID:"));
  9552. QLineEdit*deviceId= new QLineEdit;
  9553. deviceIdLayout->addWidget(label);
  9554. deviceIdLayout->addWidget(deviceId);
  9555. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9556. layout->addLayout(deviceIdLayout);
  9557. layout->addWidget(addChannelButton);
  9558. /*771:*/
  9559. #line 16335 "./typica.w"
  9560. QDomElement referenceElement=
  9561. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9562. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9563. QDomElement node;
  9564. /*:771*/
  9565. #line 16469 "./typica.w"
  9566. for(int i= 0;i<configData.size();i++)
  9567. {
  9568. node= configData.at(i).toElement();
  9569. if(node.attribute("name")=="deviceID")
  9570. {
  9571. deviceId->setText(node.attribute("value","Dev1"));
  9572. break;
  9573. }
  9574. }
  9575. updateDeviceId(deviceId->text());
  9576. connect(addChannelButton,SIGNAL(clicked()),
  9577. this,SLOT(addChannel()));
  9578. connect(deviceId,SIGNAL(textEdited(QString)),
  9579. this,SLOT(updateDeviceId(QString)));
  9580. setLayout(layout);
  9581. }
  9582. /*:777*//*778:*/
  9583. #line 16491 "./typica.w"
  9584. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9585. {
  9586. updateAttribute("deviceID",newId);
  9587. }
  9588. /*:778*//*779:*/
  9589. #line 16499 "./typica.w"
  9590. void NiDaqMxBase9211ConfWidget::addChannel()
  9591. {
  9592. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9593. }
  9594. /*:779*/
  9595. #line 586 "./typica.w"
  9596. /*775:*/
  9597. #line 16406 "./typica.w"
  9598. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9599. DeviceTreeModel*model,const QModelIndex&index):
  9600. BasicDeviceConfigurationWidget(model,index)
  9601. {
  9602. QHBoxLayout*layout= new QHBoxLayout;
  9603. QToolButton*addDeviceButton= new QToolButton;
  9604. addDeviceButton->setText(tr("Add Device"));
  9605. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9606. "nidaqmxbase9211series");
  9607. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9608. "nidaqmxbase9211series");
  9609. connect(add9211,SIGNAL(triggered(QString,QString)),
  9610. this,SLOT(insertChildNode(QString,QString)));
  9611. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9612. this,SLOT(insertChildNode(QString,QString)));
  9613. QMenu*deviceMenu= new QMenu;
  9614. deviceMenu->addAction(add9211);
  9615. deviceMenu->addAction(add9211a);
  9616. addDeviceButton->setMenu(deviceMenu);
  9617. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9618. layout->addWidget(addDeviceButton);
  9619. setLayout(layout);
  9620. }
  9621. /*:775*/
  9622. #line 587 "./typica.w"
  9623. /*642:*/
  9624. #line 13880 "./typica.w"
  9625. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9626. QObject*parent):
  9627. QAction(reportName,parent),reportFile(fileName)
  9628. {
  9629. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9630. }
  9631. /*:642*//*643:*/
  9632. #line 13896 "./typica.w"
  9633. void ReportAction::createReport()
  9634. {
  9635. QFile file(reportFile);
  9636. QDomDocument document;
  9637. if(file.open(QIODevice::ReadOnly))
  9638. {
  9639. document.setContent(&file,true);
  9640. QDomElement element= document.documentElement();
  9641. QScriptEngine*engine= AppInstance->engine;
  9642. QScriptContext*context= engine->pushContext();
  9643. QScriptValue object;
  9644. QString targetID= reportFile;
  9645. /*198:*/
  9646. #line 4630 "./typica.w"
  9647. ScriptQMainWindow*window= new ScriptQMainWindow;
  9648. window->setObjectName(targetID);
  9649. object= engine->newQObject(window);
  9650. setQMainWindowProperties(object,engine);
  9651. QWidget*central= new(QWidget);
  9652. central->setParent(window);
  9653. central->setObjectName("centralWidget");
  9654. window->setCentralWidget(central);
  9655. if(element.hasChildNodes())
  9656. {
  9657. /*199:*/
  9658. #line 4665 "./typica.w"
  9659. QStack<QWidget*> widgetStack;
  9660. QStack<QLayout*> layoutStack;
  9661. QString windowScript;
  9662. widgetStack.push(central);
  9663. QDomNodeList windowChildren= element.childNodes();
  9664. int i= 0;
  9665. while(i<windowChildren.count())
  9666. {
  9667. QDomNode current;
  9668. QDomElement element;
  9669. current= windowChildren.at(i);
  9670. if(current.isElement())
  9671. {
  9672. element= current.toElement();
  9673. if(element.tagName()=="program")
  9674. {
  9675. windowScript.append(element.text());
  9676. }
  9677. else if(element.tagName()=="layout")
  9678. {
  9679. element.setAttribute("trcontext","configuration");
  9680. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9681. }
  9682. else if(element.tagName()=="menu")
  9683. {
  9684. /*200:*/
  9685. #line 4713 "./typica.w"
  9686. QMenuBar*bar= window->menuBar();
  9687. bar->setParent(window);
  9688. bar->setObjectName("menuBar");
  9689. if(element.hasAttribute("name"))
  9690. {
  9691. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  9692. element.attribute("name").toUtf8().data()));
  9693. menu->setParent(bar);
  9694. if(element.hasAttribute("type"))
  9695. {
  9696. if(element.attribute("type")=="reports")
  9697. {
  9698. if(element.hasAttribute("src"))
  9699. {
  9700. /*640:*/
  9701. #line 13840 "./typica.w"
  9702. QSettings settings;
  9703. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9704. toString()).
  9705. arg(element.attribute("src"));
  9706. QDir::addSearchPath("reports",reportDirectory);
  9707. QDir directory(reportDirectory);
  9708. directory.setFilter(QDir::Files);
  9709. directory.setSorting(QDir::Name);
  9710. QStringList nameFilter;
  9711. nameFilter<<"*.xml";
  9712. directory.setNameFilters(nameFilter);
  9713. QFileInfoList reportFiles= directory.entryInfoList();
  9714. for(int i= 0;i<reportFiles.size();i++)
  9715. {
  9716. QFileInfo reportFile= reportFiles.at(i);
  9717. /*644:*/
  9718. #line 13920 "./typica.w"
  9719. QString path= reportFile.absoluteFilePath();
  9720. QFile file(path);
  9721. if(file.open(QIODevice::ReadOnly))
  9722. {
  9723. QDomDocument document;
  9724. document.setContent(&file,true);
  9725. QDomElement root= document.documentElement();
  9726. QString translationContext= root.attribute("id");
  9727. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9728. if(!titleNode.isNull())
  9729. {
  9730. QDomElement titleElement= titleNode.toElement();
  9731. QString title= QCoreApplication::translate("configuration",
  9732. titleElement.text().toUtf8().data());
  9733. if(!title.isEmpty())
  9734. {
  9735. QStringList hierarchy= title.split(":->");
  9736. QMenu*insertionPoint= menu;
  9737. /*645:*/
  9738. #line 13949 "./typica.w"
  9739. for(int j= 0;j<hierarchy.size()-1;j++)
  9740. {
  9741. QObjectList menuList= insertionPoint->children();
  9742. bool menuFound= false;
  9743. for(int k= 0;k<menuList.size();k++)
  9744. {
  9745. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9746. if(currentItem)
  9747. {
  9748. if(currentItem->title()==hierarchy.at(j))
  9749. {
  9750. menuFound= true;
  9751. insertionPoint= currentItem;
  9752. break;
  9753. }
  9754. }
  9755. }
  9756. if(!menuFound)
  9757. {
  9758. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9759. }
  9760. }
  9761. /*:645*/
  9762. #line 13939 "./typica.w"
  9763. ReportAction*action= new ReportAction(path,hierarchy.last());
  9764. insertionPoint->addAction(action);
  9765. }
  9766. }
  9767. }
  9768. /*:644*/
  9769. #line 13856 "./typica.w"
  9770. }
  9771. /*:640*/
  9772. #line 4728 "./typica.w"
  9773. }
  9774. }
  9775. }
  9776. if(element.hasChildNodes())
  9777. {
  9778. /*201:*/
  9779. #line 4741 "./typica.w"
  9780. QDomNodeList menuItems= element.childNodes();
  9781. int j= 0;
  9782. while(j<menuItems.count())
  9783. {
  9784. QDomNode item= menuItems.at(j);
  9785. if(item.isElement())
  9786. {
  9787. QDomElement itemElement= item.toElement();
  9788. if(itemElement.tagName()=="item")
  9789. {
  9790. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  9791. itemElement.text().toUtf8().data()),menu);
  9792. if(itemElement.hasAttribute("id"))
  9793. {
  9794. itemAction->setObjectName(itemElement.attribute("id"));
  9795. }
  9796. if(itemElement.hasAttribute("shortcut"))
  9797. {
  9798. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9799. }
  9800. menu->addAction(itemAction);
  9801. }
  9802. else if(itemElement.tagName()=="separator")
  9803. {
  9804. menu->addSeparator();
  9805. }
  9806. }
  9807. j++;
  9808. }
  9809. #line 1 "./helpmenu.w"
  9810. /*:201*/
  9811. #line 4734 "./typica.w"
  9812. }
  9813. }
  9814. /*:200*/
  9815. #line 4691 "./typica.w"
  9816. }
  9817. }
  9818. i++;
  9819. }
  9820. QScriptValue oldThis= context->thisObject();
  9821. context->setThisObject(object);
  9822. QScriptValue result= engine->evaluate(windowScript);
  9823. /*192:*/
  9824. #line 4447 "./typica.w"
  9825. if(engine->hasUncaughtException())
  9826. {
  9827. int line= engine->uncaughtExceptionLineNumber();
  9828. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9829. result.toString();
  9830. QString trace;
  9831. foreach(trace,engine->uncaughtExceptionBacktrace())
  9832. {
  9833. qDebug()<<trace;
  9834. }
  9835. }
  9836. /*:192*/
  9837. #line 4699 "./typica.w"
  9838. context->setThisObject(oldThis);
  9839. /*:199*/
  9840. #line 4641 "./typica.w"
  9841. }
  9842. /*202:*/
  9843. #line 9 "./helpmenu.w"
  9844. HelpMenu*helpMenu= new HelpMenu();
  9845. window->menuBar()->addMenu(helpMenu);
  9846. /*:202*/
  9847. #line 4643 "./typica.w"
  9848. window->show();
  9849. /*:198*/
  9850. #line 13909 "./typica.w"
  9851. file.close();
  9852. engine->popContext();
  9853. }
  9854. }
  9855. /*:643*/
  9856. #line 588 "./typica.w"
  9857. /*241:*/
  9858. #line 5827 "./typica.w"
  9859. NumericDelegate::NumericDelegate(QObject*parent):
  9860. QItemDelegate(parent)
  9861. {
  9862. }
  9863. /*:241*//*242:*/
  9864. #line 5839 "./typica.w"
  9865. void NumericDelegate::setEditorData(QWidget*editor,
  9866. const QModelIndex&index)const
  9867. {
  9868. QString value= index.model()->data(index,Qt::EditRole).toString();
  9869. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9870. line->setText(value);
  9871. }
  9872. /*:242*//*243:*/
  9873. #line 5854 "./typica.w"
  9874. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9875. const QModelIndex&index)const
  9876. {
  9877. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9878. model->setData(index,line->text(),Qt::EditRole);
  9879. QScriptEngine*engine= AppInstance->engine;
  9880. engine->pushContext();
  9881. QString script= QString("Number(%1)").arg(line->text());
  9882. QScriptValue result= engine->evaluate(line->text());
  9883. if(result.isNumber())
  9884. {
  9885. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9886. }
  9887. else
  9888. {
  9889. model->setData(index,QVariant(),Qt::DisplayRole);
  9890. }
  9891. engine->popContext();
  9892. }
  9893. /*:243*//*244:*/
  9894. #line 5877 "./typica.w"
  9895. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9896. const QStyleOptionViewItem&,
  9897. const QModelIndex&)const
  9898. {
  9899. return(new QLineEdit(parent));
  9900. }
  9901. /*:244*//*245:*/
  9902. #line 5888 "./typica.w"
  9903. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9904. const QStyleOptionViewItem&option,
  9905. const QModelIndex&)const
  9906. {
  9907. editor->setGeometry(option.rect);
  9908. }
  9909. /*:245*/
  9910. #line 589 "./typica.w"
  9911. /*786:*/
  9912. #line 16651 "./typica.w"
  9913. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9914. const QModelIndex&index)
  9915. :BasicDeviceConfigurationWidget(model,index)
  9916. {
  9917. QHBoxLayout*layout= new QHBoxLayout;
  9918. QToolButton*addDeviceButton= new QToolButton;
  9919. addDeviceButton->setText(tr("Add Device"));
  9920. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9921. "nidaqmx9211series");
  9922. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9923. "nidaqmxtc01");
  9924. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9925. this,SLOT(insertChildNode(QString,QString)));
  9926. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9927. this,SLOT(insertChildNode(QString,QString)));
  9928. QMenu*deviceMenu= new QMenu;
  9929. deviceMenu->addAction(add9211a);
  9930. deviceMenu->addAction(addtc01);
  9931. addDeviceButton->setMenu(deviceMenu);
  9932. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9933. layout->addWidget(addDeviceButton);
  9934. setLayout(layout);
  9935. }
  9936. /*:786*/
  9937. #line 590 "./typica.w"
  9938. /*788:*/
  9939. #line 16700 "./typica.w"
  9940. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9941. const QModelIndex&index)
  9942. :BasicDeviceConfigurationWidget(model,index)
  9943. {
  9944. QVBoxLayout*layout= new QVBoxLayout;
  9945. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9946. QLabel*label= new QLabel(tr("Device ID:"));
  9947. QLineEdit*deviceId= new QLineEdit;
  9948. deviceIdLayout->addWidget(label);
  9949. deviceIdLayout->addWidget(deviceId);
  9950. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9951. layout->addLayout(deviceIdLayout);
  9952. layout->addWidget(addChannelButton);
  9953. /*771:*/
  9954. #line 16335 "./typica.w"
  9955. QDomElement referenceElement=
  9956. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9957. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9958. QDomElement node;
  9959. /*:771*/
  9960. #line 16714 "./typica.w"
  9961. for(int i= 0;i<configData.size();i++)
  9962. {
  9963. node= configData.at(i).toElement();
  9964. if(node.attribute("name")=="deviceID")
  9965. {
  9966. deviceId->setText(node.attribute("value","Dev1"));
  9967. break;
  9968. }
  9969. }
  9970. updateDeviceId(deviceId->text());
  9971. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  9972. connect(deviceId,SIGNAL(textEdited(QString)),
  9973. this,SLOT(updateDeviceId(QString)));
  9974. setLayout(layout);
  9975. }
  9976. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  9977. {
  9978. updateAttribute("deviceID",newId);
  9979. }
  9980. void NiDaqMx9211ConfWidget::addChannel()
  9981. {
  9982. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9983. }
  9984. /*:788*/
  9985. #line 591 "./typica.w"
  9986. /*790:*/
  9987. #line 16765 "./typica.w"
  9988. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  9989. const QModelIndex&index)
  9990. :BasicDeviceConfigurationWidget(model,index)
  9991. {
  9992. QFormLayout*layout= new QFormLayout;
  9993. QLineEdit*deviceId= new QLineEdit;
  9994. layout->addRow(tr("Device ID:"),deviceId);
  9995. QLineEdit*columnName= new QLineEdit;
  9996. layout->addRow(tr("Column Name:"),columnName);
  9997. QComboBox*typeSelector= new QComboBox;
  9998. typeSelector->addItem("J");
  9999. typeSelector->addItem("K");
  10000. typeSelector->addItem("T");
  10001. typeSelector->addItem("B");
  10002. typeSelector->addItem("E");
  10003. typeSelector->addItem("N");
  10004. typeSelector->addItem("R");
  10005. typeSelector->addItem("S");
  10006. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10007. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10008. layout->addRow(hideSeries);
  10009. /*771:*/
  10010. #line 16335 "./typica.w"
  10011. QDomElement referenceElement=
  10012. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10013. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10014. QDomElement node;
  10015. /*:771*/
  10016. #line 16787 "./typica.w"
  10017. for(int i= 0;i<configData.size();i++)
  10018. {
  10019. node= configData.at(i).toElement();
  10020. if(node.attribute("name")=="deviceID")
  10021. {
  10022. deviceId->setText(node.attribute("value"));
  10023. }
  10024. else if(node.attribute("name")=="type")
  10025. {
  10026. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10027. }
  10028. else if(node.attribute("name")=="columnname")
  10029. {
  10030. columnName->setText(node.attribute("value"));
  10031. }
  10032. else if(node.attribute("name")=="hidden")
  10033. {
  10034. hideSeries->setChecked(node.attribute("value")=="true");
  10035. }
  10036. }
  10037. updateDeviceId(deviceId->text());
  10038. updateThermocoupleType(typeSelector->currentText());
  10039. updateColumnName(columnName->text());
  10040. updateHidden(hideSeries->isChecked());
  10041. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10042. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10043. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10044. setLayout(layout);
  10045. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10046. }
  10047. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10048. {
  10049. updateAttribute("deviceID",newId);
  10050. }
  10051. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10052. {
  10053. updateAttribute("type",type);
  10054. }
  10055. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10056. {
  10057. updateAttribute("columnname",name);
  10058. }
  10059. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10060. {
  10061. updateAttribute("hidden",hidden?"true":"false");
  10062. }
  10063. /*:790*/
  10064. #line 592 "./typica.w"
  10065. /*808:*/
  10066. #line 17207 "./typica.w"
  10067. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10068. const QModelIndex&index)
  10069. :BasicDeviceConfigurationWidget(model,index)
  10070. {
  10071. QFormLayout*layout= new QFormLayout;
  10072. QToolButton*addDeviceButton= new QToolButton;
  10073. addDeviceButton->setText(tr("Add Device"));
  10074. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10075. "Modbus RTU Device",
  10076. "modbusrtudevice");
  10077. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10078. this,SLOT(insertChildNode(QString,QString)));
  10079. QMenu*deviceMenu= new QMenu;
  10080. deviceMenu->addAction(addModbusRtuDevice);
  10081. addDeviceButton->setMenu(deviceMenu);
  10082. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10083. layout->addRow(QString(),addDeviceButton);
  10084. PortSelector*port= new PortSelector;
  10085. layout->addRow(tr("Port:"),port);
  10086. connect(port,SIGNAL(currentIndexChanged(QString)),
  10087. this,SLOT(updatePort(QString)));
  10088. connect(port,SIGNAL(editTextChanged(QString)),
  10089. this,SLOT(updatePort(QString)));
  10090. BaudSelector*rate= new BaudSelector;
  10091. layout->addRow(tr("Baud:"),rate);
  10092. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10093. this,SLOT(updateBaudRate(QString)));
  10094. ParitySelector*parity= new ParitySelector;
  10095. layout->addRow(tr("Parity:"),parity);
  10096. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10097. this,SLOT(updateParity(QString)));
  10098. FlowSelector*flow= new FlowSelector;
  10099. layout->addRow(tr("Flow Control:"),flow);
  10100. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10101. this,SLOT(updateFlowControl(QString)));
  10102. StopSelector*stop= new StopSelector;
  10103. layout->addRow(tr("Stop Bits:"),stop);
  10104. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10105. this,SLOT(updateStopBits(QString)));
  10106. /*771:*/
  10107. #line 16335 "./typica.w"
  10108. QDomElement referenceElement=
  10109. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10110. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10111. QDomElement node;
  10112. /*:771*/
  10113. #line 17247 "./typica.w"
  10114. for(int i= 0;i<configData.size();i++)
  10115. {
  10116. node= configData.at(i).toElement();
  10117. if(node.attribute("name")=="port")
  10118. {
  10119. int j= port->findText(node.attribute("value"));
  10120. if(j>=0)
  10121. {
  10122. port->setCurrentIndex(j);
  10123. }
  10124. else
  10125. {
  10126. port->insertItem(0,node.attribute("value"));
  10127. port->setCurrentIndex(0);
  10128. }
  10129. }
  10130. else if(node.attribute("name")=="baudrate")
  10131. {
  10132. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10133. }
  10134. else if(node.attribute("name")=="parity")
  10135. {
  10136. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10137. }
  10138. else if(node.attribute("name")=="flowcontrol")
  10139. {
  10140. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10141. }
  10142. else if(node.attribute("name")=="stopbits")
  10143. {
  10144. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10145. }
  10146. }
  10147. updatePort(port->currentText());
  10148. updateBaudRate(rate->currentText());
  10149. updateParity(parity->currentText());
  10150. updateFlowControl(flow->currentText());
  10151. updateStopBits(stop->currentText());
  10152. setLayout(layout);
  10153. }
  10154. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10155. {
  10156. updateAttribute("port",newPort);
  10157. }
  10158. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10159. {
  10160. updateAttribute("baudrate",newRate);
  10161. }
  10162. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10163. {
  10164. updateAttribute("parity",newParity);
  10165. }
  10166. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10167. {
  10168. updateAttribute("flowcontrol",newFlow);
  10169. }
  10170. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10171. {
  10172. updateAttribute("stopbits",newStopBits);
  10173. }
  10174. /*:808*/
  10175. #line 593 "./typica.w"
  10176. /*810:*/
  10177. #line 17370 "./typica.w"
  10178. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10179. const QModelIndex&index)
  10180. :BasicDeviceConfigurationWidget(model,index),
  10181. unitSpecificationLayout(new QStackedLayout),
  10182. decimalSpecificationLayout(new QStackedLayout)
  10183. {
  10184. QVBoxLayout*layout= new QVBoxLayout;
  10185. QToolButton*addChannelButton= new QToolButton;
  10186. addChannelButton->setText(tr("Add Channel"));
  10187. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10188. "Temperature Process Value",
  10189. "modbustemperaturepv");
  10190. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10191. "Temperature Set Value",
  10192. "modbustemperaturesv");
  10193. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10194. this,SLOT(insertChildNode(QString,QString)));
  10195. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10196. this,SLOT(insertChildNode(QString,QString)));
  10197. QMenu*channelMenu= new QMenu;
  10198. channelMenu->addAction(addTemperaturePV);
  10199. channelMenu->addAction(addTemperatureSV);
  10200. addChannelButton->setMenu(channelMenu);
  10201. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10202. layout->addWidget(addChannelButton);
  10203. QHBoxLayout*stationLayout= new QHBoxLayout;
  10204. QLabel*stationLabel= new QLabel(tr("Station:"));
  10205. QSpinBox*stationNumber= new QSpinBox;
  10206. stationNumber->setMinimum(0);
  10207. stationNumber->setMaximum(255);
  10208. stationLayout->addWidget(stationLabel);
  10209. stationLayout->addWidget(stationNumber);
  10210. layout->addLayout(stationLayout);
  10211. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10212. layout->addWidget(fixedUnit);
  10213. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10214. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10215. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10216. QComboBox*fixedUnitSelector= new QComboBox;
  10217. fixedUnitSelector->addItem("Fahrenheit");
  10218. fixedUnitSelector->addItem("Celsius");
  10219. fixedUnitLayout->addWidget(fixedUnitLabel);
  10220. fixedUnitLayout->addWidget(fixedUnitSelector);
  10221. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10222. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10223. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10224. QFormLayout*queriedUnitLayout= new QFormLayout;
  10225. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10226. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10227. QSpinBox*valueF= new QSpinBox;
  10228. valueF->setMinimum(0);
  10229. valueF->setMaximum(65535);
  10230. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10231. QSpinBox*valueC= new QSpinBox;
  10232. valueC->setMinimum(0);
  10233. valueC->setMaximum(65535);
  10234. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10235. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10236. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10237. layout->addLayout(unitSpecificationLayout);
  10238. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10239. layout->addWidget(fixedPrecision);
  10240. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10241. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10242. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10243. fixedPrecisionValue->setMinimum(0);
  10244. fixedPrecisionValue->setMaximum(9);
  10245. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10246. fixedPrecisionValue);
  10247. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10248. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10249. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10250. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10251. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10252. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10253. precisionAddress);
  10254. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10255. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10256. layout->addLayout(decimalSpecificationLayout);
  10257. /*771:*/
  10258. #line 16335 "./typica.w"
  10259. QDomElement referenceElement=
  10260. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10261. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10262. QDomElement node;
  10263. /*:771*/
  10264. #line 17450 "./typica.w"
  10265. for(int i= 0;i<configData.size();i++)
  10266. {
  10267. node= configData.at(i).toElement();
  10268. if(node.attribute("name")=="station")
  10269. {
  10270. stationNumber->setValue(node.attribute("value").toInt());
  10271. }
  10272. else if(node.attribute("name")=="fixedunit")
  10273. {
  10274. if(node.attribute("value")=="true")
  10275. {
  10276. fixedUnit->setCheckState(Qt::Checked);
  10277. }
  10278. else if(node.attribute("value")=="false")
  10279. {
  10280. fixedUnit->setCheckState(Qt::Unchecked);
  10281. }
  10282. }
  10283. else if(node.attribute("name")=="fixedprecision")
  10284. {
  10285. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10286. }
  10287. else if(node.attribute("name")=="unit")
  10288. {
  10289. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10290. }
  10291. else if(node.attribute("name")=="unitaddress")
  10292. {
  10293. unitAddress->setValue(node.attribute("value").toInt());
  10294. }
  10295. else if(node.attribute("name")=="fvalue")
  10296. {
  10297. valueF->setValue(node.attribute("value").toInt());
  10298. }
  10299. else if(node.attribute("name")=="cvalue")
  10300. {
  10301. valueC->setValue(node.attribute("value").toInt());
  10302. }
  10303. else if(node.attribute("name")=="precisionaddress")
  10304. {
  10305. precisionAddress->setValue(node.attribute("value").toInt());
  10306. }
  10307. else if(node.attribute("name")=="precision")
  10308. {
  10309. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10310. }
  10311. }
  10312. updateStationNumber(stationNumber->value());
  10313. updateFixedUnit(fixedUnit->isChecked());
  10314. updateFixedDecimal(fixedPrecision->isChecked());
  10315. updateUnit(fixedUnitSelector->currentText());
  10316. updateUnitAddress(unitAddress->value());
  10317. updateValueF(valueF->value());
  10318. updateValueC(valueC->value());
  10319. updatePrecisionAddress(precisionAddress->value());
  10320. updatePrecisionValue(fixedPrecisionValue->value());
  10321. connect(stationNumber,SIGNAL(valueChanged(int)),
  10322. this,SLOT(updateStationNumber(int)));
  10323. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10324. this,SLOT(updateUnit(QString)));
  10325. connect(unitAddress,SIGNAL(valueChanged(int)),
  10326. this,SLOT(updateUnitAddress(int)));
  10327. connect(valueF,SIGNAL(valueChanged(int)),
  10328. this,SLOT(updateValueF(int)));
  10329. connect(valueC,SIGNAL(valueChanged(int)),
  10330. this,SLOT(updateValueC(int)));
  10331. connect(fixedUnit,SIGNAL(toggled(bool)),
  10332. this,SLOT(updateFixedUnit(bool)));
  10333. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10334. this,SLOT(updateFixedDecimal(bool)));
  10335. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10336. this,SLOT(updatePrecisionValue(int)));
  10337. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10338. this,SLOT(updatePrecisionAddress(int)));
  10339. setLayout(layout);
  10340. }
  10341. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10342. {
  10343. updateAttribute("station",QString("%1").arg(newStation));
  10344. }
  10345. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10346. {
  10347. if(newFixed)
  10348. {
  10349. unitSpecificationLayout->setCurrentIndex(0);
  10350. updateAttribute("fixedunit","true");
  10351. }
  10352. else
  10353. {
  10354. unitSpecificationLayout->setCurrentIndex(1);
  10355. updateAttribute("fixedunit","false");
  10356. }
  10357. }
  10358. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10359. {
  10360. if(newFixed)
  10361. {
  10362. decimalSpecificationLayout->setCurrentIndex(0);
  10363. updateAttribute("fixedprecision","true");
  10364. }
  10365. else
  10366. {
  10367. decimalSpecificationLayout->setCurrentIndex(1);
  10368. updateAttribute("fixedprecision","false");
  10369. }
  10370. }
  10371. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10372. {
  10373. updateAttribute("unit",newUnit);
  10374. }
  10375. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10376. {
  10377. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10378. }
  10379. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10380. {
  10381. updateAttribute("fvalue",QString("%1").arg(newValue));
  10382. }
  10383. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10384. {
  10385. updateAttribute("cvalue",QString("%1").arg(newValue));
  10386. }
  10387. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10388. {
  10389. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10390. }
  10391. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10392. {
  10393. updateAttribute("precision",QString("%1").arg(newValue));
  10394. }
  10395. /*:810*/
  10396. #line 594 "./typica.w"
  10397. /*812:*/
  10398. #line 17613 "./typica.w"
  10399. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10400. const QModelIndex&index)
  10401. :BasicDeviceConfigurationWidget(model,index)
  10402. {
  10403. QFormLayout*layout= new QFormLayout;
  10404. ShortHexSpinBox*address= new ShortHexSpinBox;
  10405. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10406. /*771:*/
  10407. #line 16335 "./typica.w"
  10408. QDomElement referenceElement=
  10409. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10410. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10411. QDomElement node;
  10412. /*:771*/
  10413. #line 17621 "./typica.w"
  10414. for(int i= 0;i<configData.size();i++)
  10415. {
  10416. node= configData.at(i).toElement();
  10417. if(node.attribute("name")=="address")
  10418. {
  10419. address->setValue(node.attribute("value").toInt());
  10420. break;
  10421. }
  10422. }
  10423. updateAddress(address->value());
  10424. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10425. setLayout(layout);
  10426. }
  10427. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10428. {
  10429. updateAttribute("address",QString("%1").arg(newAddress));
  10430. }
  10431. /*:812*/
  10432. #line 595 "./typica.w"
  10433. /*814:*/
  10434. #line 17669 "./typica.w"
  10435. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10436. const QModelIndex&index)
  10437. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10438. {
  10439. QVBoxLayout*layout= new QVBoxLayout;
  10440. QFormLayout*addressLayout= new QFormLayout;
  10441. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10442. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10443. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10444. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10445. layout->addLayout(addressLayout);
  10446. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10447. layout->addWidget(fixedRange);
  10448. QWidget*queriedRangePlaceholder= new QWidget(this);
  10449. QFormLayout*queriedRangeLayout= new QFormLayout;
  10450. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10451. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10452. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10453. lowerAddress);
  10454. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10455. upperAddress);
  10456. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10457. boundsLayout->addWidget(queriedRangePlaceholder);
  10458. QWidget*fixedRangePlaceholder= new QWidget(this);
  10459. QFormLayout*fixedRangeLayout= new QFormLayout;
  10460. QLineEdit*fixedLower= new QLineEdit;
  10461. QLineEdit*fixedUpper= new QLineEdit;
  10462. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10463. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10464. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10465. boundsLayout->addWidget(fixedRangePlaceholder);
  10466. layout->addLayout(boundsLayout);
  10467. /*771:*/
  10468. #line 16335 "./typica.w"
  10469. QDomElement referenceElement=
  10470. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10471. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10472. QDomElement node;
  10473. /*:771*/
  10474. #line 17702 "./typica.w"
  10475. for(int i= 0;i<configData.size();i++)
  10476. {
  10477. node= configData.at(i).toElement();
  10478. if(node.attribute("name")=="readaddress")
  10479. {
  10480. readAddress->setValue(node.attribute("value").toInt());
  10481. }
  10482. else if(node.attribute("name")=="writeaddress")
  10483. {
  10484. writeAddress->setValue(node.attribute("value").toInt());
  10485. }
  10486. else if(node.attribute("name")=="fixedrange")
  10487. {
  10488. if(node.attribute("value")=="true")
  10489. {
  10490. fixedRange->setCheckState(Qt::Checked);
  10491. }
  10492. else if(node.attribute("value")=="false")
  10493. {
  10494. fixedRange->setCheckState(Qt::Unchecked);
  10495. }
  10496. }
  10497. else if(node.attribute("name")=="fixedlower")
  10498. {
  10499. fixedLower->setText(node.attribute("value"));
  10500. }
  10501. else if(node.attribute("name")=="fixedupper")
  10502. {
  10503. fixedUpper->setText(node.attribute("value"));
  10504. }
  10505. else if(node.attribute("name")=="loweraddress")
  10506. {
  10507. lowerAddress->setValue(node.attribute("value").toInt());
  10508. }
  10509. else if(node.attribute("name")=="upperaddress")
  10510. {
  10511. upperAddress->setValue(node.attribute("value").toInt());
  10512. }
  10513. }
  10514. updateReadAddress(readAddress->value());
  10515. updateWriteAddress(writeAddress->value());
  10516. updateFixedRange(fixedRange->isChecked());
  10517. updateLower(fixedLower->text());
  10518. updateUpper(fixedUpper->text());
  10519. updateLowerAddress(lowerAddress->value());
  10520. updateUpperAddress(upperAddress->value());
  10521. connect(readAddress,SIGNAL(valueChanged(int)),
  10522. this,SLOT(updateReadAddress(int)));
  10523. connect(writeAddress,SIGNAL(valueChanged(int)),
  10524. this,SLOT(updateWriteAddress(int)));
  10525. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10526. connect(fixedLower,SIGNAL(textChanged(QString)),
  10527. this,SLOT(updateLower(QString)));
  10528. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10529. this,SLOT(updateUpper(QString)));
  10530. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10531. this,SLOT(updateLowerAddress(int)));
  10532. connect(upperAddress,SIGNAL(valueChanged(int)),
  10533. this,SLOT(updateUpperAddress(int)));
  10534. setLayout(layout);
  10535. }
  10536. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10537. {
  10538. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10539. }
  10540. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10541. {
  10542. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10543. }
  10544. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10545. {
  10546. if(fixed)
  10547. {
  10548. updateAttribute("fixedrange","true");
  10549. boundsLayout->setCurrentIndex(1);
  10550. }
  10551. else
  10552. {
  10553. updateAttribute("fixedrange","false");
  10554. boundsLayout->setCurrentIndex(0);
  10555. }
  10556. }
  10557. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10558. {
  10559. updateAttribute("fixedlower",lower);
  10560. }
  10561. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10562. {
  10563. updateAttribute("fixedupper",upper);
  10564. }
  10565. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10566. {
  10567. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10568. }
  10569. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10570. {
  10571. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10572. }
  10573. /*:814*/
  10574. #line 596 "./typica.w"
  10575. /*770:*/
  10576. #line 16205 "./typica.w"
  10577. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10578. :BasicDeviceConfigurationWidget(model,index)
  10579. {
  10580. QVBoxLayout*layout= new QVBoxLayout;
  10581. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10582. QMenu*deviceMenu= new QMenu;
  10583. NodeInserter*insertAction;
  10584. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10585. {
  10586. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10587. this,SLOT(insertChildNode(QString,QString)));
  10588. deviceMenu->addAction(insertAction);
  10589. }
  10590. addDeviceButton->setMenu(deviceMenu);
  10591. layout->addWidget(addDeviceButton);
  10592. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10593. QMenu*annotationMenu= new QMenu;
  10594. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10595. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10596. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10597. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10598. tr("Free Text"),
  10599. "freeannotation");
  10600. annotationMenu->addAction(basicButtonInserter);
  10601. annotationMenu->addAction(countingButtonInserter);
  10602. annotationMenu->addAction(spinBoxInserter);
  10603. annotationMenu->addAction(freeAnnotationInserter);
  10604. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10605. this,SLOT(insertChildNode(QString,QString)));
  10606. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10607. this,SLOT(insertChildNode(QString,QString)));
  10608. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10609. this,SLOT(insertChildNode(QString,QString)));
  10610. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10611. this,SLOT(insertChildNode(QString,QString)));
  10612. /*1045:*/
  10613. #line 144 "./valueannotation.w"
  10614. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10615. tr("Value Annotation"),
  10616. "valueannotation");
  10617. annotationMenu->addAction(valueAnnotationInserter);
  10618. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10619. this,SLOT(insertChildNode(QString,QString)));
  10620. /*:1045*/
  10621. #line 16241 "./typica.w"
  10622. addAnnotationControlButton->setMenu(annotationMenu);
  10623. layout->addWidget(addAnnotationControlButton);
  10624. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10625. QMenu*timersMenu= new QMenu;
  10626. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10627. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10628. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10629. timersMenu->addAction(coolingTimerInserter);
  10630. timersMenu->addAction(rangeTimerInserter);
  10631. timersMenu->addAction(multirangeTimerInserter);
  10632. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10633. this,SLOT(insertChildNode(QString,QString)));
  10634. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10635. this,SLOT(insertChildNode(QString,QString)));
  10636. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10637. this,SLOT(insertChildNode(QString,QString)));
  10638. timersButton->setMenu(timersMenu);
  10639. layout->addWidget(timersButton);
  10640. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10641. QMenu*advancedMenu= new QMenu;
  10642. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10643. advancedMenu->addAction(linearsplineinserter);
  10644. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10645. advancedMenu->addAction(translationinserter);
  10646. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10647. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10648. /*971:*/
  10649. #line 258 "./rate.w"
  10650. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10651. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10652. advancedMenu->addAction(rateOfChangeInserter);
  10653. /*:971*/
  10654. #line 16270 "./typica.w"
  10655. advancedButton->setMenu(advancedMenu);
  10656. layout->addWidget(advancedButton);
  10657. QHBoxLayout*idLayout= new QHBoxLayout;
  10658. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10659. idLayout->addWidget(idLabel);
  10660. QSpinBox*id= new QSpinBox;
  10661. idLayout->addWidget(id);
  10662. idLayout->addStretch();
  10663. layout->addLayout(idLayout);
  10664. QHBoxLayout*capacityLayout= new QHBoxLayout;
  10665. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  10666. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  10667. capacity->setMinimum(0.0);
  10668. capacity->setDecimals(3);
  10669. capacity->setMaximum(999999.999);
  10670. QComboBox*capacityUnit= new QComboBox;
  10671. capacityUnit->addItem("g");
  10672. capacityUnit->addItem("Kg");
  10673. capacityUnit->addItem("oz");
  10674. capacityUnit->addItem("Lb");
  10675. capacityUnit->setCurrentIndex(3);
  10676. capacityLayout->addWidget(capacityCheckEnabled);
  10677. capacityLayout->addWidget(capacity);
  10678. capacityLayout->addWidget(capacityUnit);
  10679. capacityLayout->addStretch();
  10680. layout->addLayout(capacityLayout);
  10681. layout->addStretch();
  10682. /*771:*/
  10683. #line 16335 "./typica.w"
  10684. QDomElement referenceElement=
  10685. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10686. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10687. QDomElement node;
  10688. /*:771*/
  10689. #line 16299 "./typica.w"
  10690. for(int i= 0;i<configData.size();i++)
  10691. {
  10692. node= configData.at(i).toElement();
  10693. if(node.attribute("name")=="databaseid")
  10694. {
  10695. id->setValue(node.attribute("value").toInt());
  10696. }
  10697. else if(node.attribute("name")=="checkcapacity")
  10698. {
  10699. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  10700. }
  10701. else if(node.attribute("name")=="capacity")
  10702. {
  10703. capacity->setValue(node.attribute("value").toDouble());
  10704. }
  10705. else if(node.attribute("name")=="capacityunit")
  10706. {
  10707. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  10708. }
  10709. }
  10710. updateRoasterId(id->value());
  10711. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10712. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  10713. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  10714. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  10715. setLayout(layout);
  10716. }
  10717. /*:770*//*772:*/
  10718. #line 16345 "./typica.w"
  10719. void RoasterConfWidget::updateRoasterId(int id)
  10720. {
  10721. updateAttribute("databaseid",QString("%1").arg(id));
  10722. }
  10723. void RoasterConfWidget::updateCapacityCheck(int value)
  10724. {
  10725. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  10726. }
  10727. void RoasterConfWidget::updateCapacity(const QString&value)
  10728. {
  10729. updateAttribute("capacity",value);
  10730. }
  10731. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  10732. {
  10733. updateAttribute("capacityunit",value);
  10734. }
  10735. /*:772*/
  10736. #line 597 "./typica.w"
  10737. /*818:*/
  10738. #line 17852 "./typica.w"
  10739. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10740. :BasicDeviceConfigurationWidget(model,index)
  10741. {
  10742. QFormLayout*layout= new QFormLayout;
  10743. QLineEdit*buttonTextEdit= new QLineEdit;
  10744. QLineEdit*annotationTextEdit= new QLineEdit;
  10745. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10746. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10747. /*771:*/
  10748. #line 16335 "./typica.w"
  10749. QDomElement referenceElement=
  10750. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10751. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10752. QDomElement node;
  10753. /*:771*/
  10754. #line 17861 "./typica.w"
  10755. for(int i= 0;i<configData.size();i++)
  10756. {
  10757. node= configData.at(i).toElement();
  10758. if(node.attribute("name")=="buttontext")
  10759. {
  10760. buttonTextEdit->setText(node.attribute("value"));
  10761. }
  10762. else if(node.attribute("name")=="annotationtext")
  10763. {
  10764. annotationTextEdit->setText(node.attribute("value"));
  10765. }
  10766. }
  10767. updateButtonText(buttonTextEdit->text());
  10768. updateAnnotationText(annotationTextEdit->text());
  10769. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10770. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10771. setLayout(layout);
  10772. }
  10773. /*:818*//*819:*/
  10774. #line 17883 "./typica.w"
  10775. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10776. {
  10777. updateAttribute("buttontext",text);
  10778. }
  10779. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10780. {
  10781. updateAttribute("annotationtext",text);
  10782. }
  10783. /*:819*//*822:*/
  10784. #line 17921 "./typica.w"
  10785. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10786. :BasicDeviceConfigurationWidget(model,index)
  10787. {
  10788. QFormLayout*layout= new QFormLayout;
  10789. QLineEdit*buttonTextEdit= new QLineEdit;
  10790. QLineEdit*annotationTextEdit= new QLineEdit;
  10791. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10792. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10793. /*771:*/
  10794. #line 16335 "./typica.w"
  10795. QDomElement referenceElement=
  10796. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10797. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10798. QDomElement node;
  10799. /*:771*/
  10800. #line 17930 "./typica.w"
  10801. for(int i= 0;i<configData.size();i++)
  10802. {
  10803. node= configData.at(i).toElement();
  10804. if(node.attribute("name")=="buttontext")
  10805. {
  10806. buttonTextEdit->setText(node.attribute("value"));
  10807. }
  10808. else if(node.attribute("name")=="annotationtext")
  10809. {
  10810. annotationTextEdit->setText(node.attribute("value"));
  10811. }
  10812. }
  10813. updateButtonText(buttonTextEdit->text());
  10814. updateAnnotationText(annotationTextEdit->text());
  10815. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10816. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10817. QTextEdit*documentation= new QTextEdit;
  10818. 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."));
  10819. documentation->setReadOnly(true);
  10820. layout->addRow("",documentation);
  10821. setLayout(layout);
  10822. }
  10823. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10824. {
  10825. updateAttribute("buttontext",text);
  10826. }
  10827. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10828. {
  10829. updateAttribute("annotationtext",text);
  10830. }
  10831. /*:822*/
  10832. #line 598 "./typica.w"
  10833. /*825:*/
  10834. #line 17998 "./typica.w"
  10835. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10836. :BasicDeviceConfigurationWidget(model,index)
  10837. {
  10838. QFormLayout*layout= new QFormLayout;
  10839. QLineEdit*labelEdit= new QLineEdit;
  10840. layout->addRow(tr("Control Label: "),labelEdit);
  10841. QLineEdit*minimumEdit= new QLineEdit;
  10842. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10843. QLineEdit*maximumEdit= new QLineEdit;
  10844. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10845. QSpinBox*precisionEdit= new QSpinBox;
  10846. precisionEdit->setMinimum(0);
  10847. precisionEdit->setMaximum(9);
  10848. layout->addRow(tr("Precision"),precisionEdit);
  10849. QLineEdit*pretext= new QLineEdit;
  10850. layout->addRow(tr("Prefix text"),pretext);
  10851. QLineEdit*posttext= new QLineEdit;
  10852. layout->addRow(tr("Suffix text"),posttext);
  10853. /*771:*/
  10854. #line 16335 "./typica.w"
  10855. QDomElement referenceElement=
  10856. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10857. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10858. QDomElement node;
  10859. /*:771*/
  10860. #line 18017 "./typica.w"
  10861. for(int i= 0;i<configData.size();i++)
  10862. {
  10863. node= configData.at(i).toElement();
  10864. if(node.attribute("name")=="label")
  10865. {
  10866. labelEdit->setText(node.attribute("value"));
  10867. }
  10868. else if(node.attribute("name")=="minimum")
  10869. {
  10870. minimumEdit->setText(node.attribute("value"));
  10871. }
  10872. else if(node.attribute("name")=="maximum")
  10873. {
  10874. maximumEdit->setText(node.attribute("value"));
  10875. }
  10876. else if(node.attribute("name")=="precision")
  10877. {
  10878. precisionEdit->setValue(node.attribute("value").toInt());
  10879. }
  10880. else if(node.attribute("name")=="pretext")
  10881. {
  10882. pretext->setText(node.attribute("value"));
  10883. }
  10884. else if(node.attribute("name")=="posttext")
  10885. {
  10886. posttext->setText(node.attribute("value"));
  10887. }
  10888. }
  10889. updateLabel(labelEdit->text());
  10890. updateMinimum(minimumEdit->text());
  10891. updateMaximum(maximumEdit->text());
  10892. updatePrecision(precisionEdit->value());
  10893. updatePretext(pretext->text());
  10894. updatePosttext(posttext->text());
  10895. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10896. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10897. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10898. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10899. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10900. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10901. setLayout(layout);
  10902. }
  10903. void NoteSpinConfWidget::updateLabel(const QString&text)
  10904. {
  10905. updateAttribute("label",text);
  10906. }
  10907. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10908. {
  10909. updateAttribute("minimum",minimum);
  10910. }
  10911. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10912. {
  10913. updateAttribute("maximum",maximum);
  10914. }
  10915. void NoteSpinConfWidget::updatePrecision(int precision)
  10916. {
  10917. updateAttribute("precision",QString("%1").arg(precision));
  10918. }
  10919. void NoteSpinConfWidget::updatePretext(const QString&text)
  10920. {
  10921. updateAttribute("pretext",text);
  10922. }
  10923. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10924. {
  10925. updateAttribute("posttext",text);
  10926. }
  10927. /*:825*/
  10928. #line 599 "./typica.w"
  10929. /*334:*/
  10930. #line 7547 "./typica.w"
  10931. LinearCalibrator::LinearCalibrator(QObject*parent):
  10932. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10933. {
  10934. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10935. }
  10936. /*:334*//*335:*/
  10937. #line 7561 "./typica.w"
  10938. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10939. {
  10940. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10941. if(clamp)
  10942. {
  10943. if(outval<Lo1)
  10944. {
  10945. outval= Lo1;
  10946. }
  10947. else if(outval> Up1)
  10948. {
  10949. outval= Up1;
  10950. }
  10951. }
  10952. if(sensitivitySetting>=0.05)
  10953. {
  10954. int temp= qRound(outval/sensitivitySetting);
  10955. outval= temp*sensitivitySetting;
  10956. }
  10957. Measurement adjusted(outval,measure.time(),measure.scale());
  10958. emit measurement(adjusted);
  10959. return adjusted;
  10960. }
  10961. /*:335*//*336:*/
  10962. #line 7588 "./typica.w"
  10963. double LinearCalibrator::measuredLower()
  10964. {
  10965. return Lo2;
  10966. }
  10967. double LinearCalibrator::measuredUpper()
  10968. {
  10969. return Up2;
  10970. }
  10971. double LinearCalibrator::mappedLower()
  10972. {
  10973. return Lo1;
  10974. }
  10975. double LinearCalibrator::mappedUpper()
  10976. {
  10977. return Up1;
  10978. }
  10979. bool LinearCalibrator::isClosedRange()
  10980. {
  10981. return clamp;
  10982. }
  10983. void LinearCalibrator::setMeasuredLower(double lower)
  10984. {
  10985. Lo2= lower;
  10986. }
  10987. void LinearCalibrator::setMeasuredUpper(double upper)
  10988. {
  10989. Up2= upper;
  10990. }
  10991. void LinearCalibrator::setMappedLower(double lower)
  10992. {
  10993. Lo1= lower;
  10994. }
  10995. void LinearCalibrator::setMappedUpper(double upper)
  10996. {
  10997. Up1= upper;
  10998. }
  10999. void LinearCalibrator::setClosedRange(bool closed)
  11000. {
  11001. clamp= closed;
  11002. }
  11003. void LinearCalibrator::setSensitivity(double sensitivity)
  11004. {
  11005. sensitivitySetting= sensitivity;
  11006. }
  11007. double LinearCalibrator::sensitivity()
  11008. {
  11009. return sensitivitySetting;
  11010. }
  11011. /*:336*/
  11012. #line 600 "./typica.w"
  11013. /*341:*/
  11014. #line 7721 "./typica.w"
  11015. void LinearSplineInterpolator::add_pair(double source,double destination)
  11016. {
  11017. pairs->insert(source,destination);
  11018. make_interpolators();
  11019. }
  11020. void LinearSplineInterpolator::make_interpolators()
  11021. {
  11022. if(pairs->size()> 1)
  11023. {
  11024. while(interpolators->size()> 0)
  11025. {
  11026. LinearCalibrator*removed= interpolators->takeFirst();
  11027. removed->deleteLater();
  11028. }
  11029. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11030. QMap<double,double> ::const_iterator j= i+1;
  11031. while(j!=pairs->constEnd())
  11032. {
  11033. LinearCalibrator*segment= new LinearCalibrator();
  11034. segment->setMeasuredLower(i.key());
  11035. segment->setMappedLower(i.value());
  11036. segment->setMeasuredUpper(j.key());
  11037. segment->setMappedUpper(j.value());
  11038. segment->setClosedRange(false);
  11039. interpolators->append(segment);
  11040. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11041. i++;
  11042. j++;
  11043. }
  11044. }
  11045. }
  11046. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11047. QObject(parent),pairs(new QMap<double,double> ),
  11048. interpolators(new QList<LinearCalibrator*> )
  11049. {
  11050. }
  11051. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11052. {
  11053. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11054. int index= -1;
  11055. while(i!=pairs->constEnd())
  11056. {
  11057. if(measure.temperature()<=i.key())
  11058. {
  11059. break;
  11060. }
  11061. i++;
  11062. index++;
  11063. }
  11064. if(index<0)
  11065. {
  11066. index= 0;
  11067. }
  11068. if(index>=interpolators->size())
  11069. {
  11070. index= interpolators->size()-1;
  11071. }
  11072. if(interpolators->at(index)!=NULL)
  11073. {
  11074. return interpolators->at(index)->newMeasurement(measure);
  11075. }
  11076. return Measurement();
  11077. }
  11078. /*:341*/
  11079. #line 601 "./typica.w"
  11080. /*936:*/
  11081. #line 19367 "./typica.w"
  11082. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11083. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11084. {
  11085. QFormLayout*layout= new QFormLayout;
  11086. QLineEdit*source= new QLineEdit;
  11087. layout->addRow(tr("Source column name:"),source);
  11088. QLineEdit*destination= new QLineEdit;
  11089. layout->addRow(tr("Destination column name:"),destination);
  11090. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11091. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11092. QTableView*mappingTable= new QTableView;
  11093. mappingTable->setModel(tablemodel);
  11094. NumericDelegate*delegate= new NumericDelegate;
  11095. mappingTable->setItemDelegate(delegate);
  11096. layout->addRow(tr("Mapping data:"),mappingTable);
  11097. /*771:*/
  11098. #line 16335 "./typica.w"
  11099. QDomElement referenceElement=
  11100. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11101. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11102. QDomElement node;
  11103. /*:771*/
  11104. #line 19383 "./typica.w"
  11105. for(int i= 0;i<configData.size();i++)
  11106. {
  11107. node= configData.at(i).toElement();
  11108. if(node.attribute("name")=="source")
  11109. {
  11110. source->setText(node.attribute("value"));
  11111. }
  11112. else if(node.attribute("name")=="destination")
  11113. {
  11114. destination->setText(node.attribute("value"));
  11115. }
  11116. else if(node.attribute("name")=="sourcevalues")
  11117. {
  11118. /*937:*/
  11119. #line 19422 "./typica.w"
  11120. QString data= node.attribute("value");
  11121. if(data.length()> 3)
  11122. {
  11123. data.chop(2);
  11124. data= data.remove(0,2);
  11125. }
  11126. QStringList itemList= data.split(",");
  11127. /*:937*/
  11128. #line 19397 "./typica.w"
  11129. int column= 0;
  11130. /*938:*/
  11131. #line 19434 "./typica.w"
  11132. for(int j= 0;j<itemList.size();j++)
  11133. {
  11134. tablemodel->setData(tablemodel->index(j,column),
  11135. QVariant(itemList.at(j).toDouble()),
  11136. Qt::DisplayRole);
  11137. }
  11138. /*:938*/
  11139. #line 19399 "./typica.w"
  11140. }
  11141. else if(node.attribute("name")=="destinationvalues")
  11142. {
  11143. /*937:*/
  11144. #line 19422 "./typica.w"
  11145. QString data= node.attribute("value");
  11146. if(data.length()> 3)
  11147. {
  11148. data.chop(2);
  11149. data= data.remove(0,2);
  11150. }
  11151. QStringList itemList= data.split(",");
  11152. /*:937*/
  11153. #line 19404 "./typica.w"
  11154. int column= 1;
  11155. /*938:*/
  11156. #line 19434 "./typica.w"
  11157. for(int j= 0;j<itemList.size();j++)
  11158. {
  11159. tablemodel->setData(tablemodel->index(j,column),
  11160. QVariant(itemList.at(j).toDouble()),
  11161. Qt::DisplayRole);
  11162. }
  11163. /*:938*/
  11164. #line 19406 "./typica.w"
  11165. }
  11166. }
  11167. updateSourceColumn(source->text());
  11168. updateDestinationColumn(destination->text());
  11169. updateKnots();
  11170. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11171. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11172. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11173. setLayout(layout);
  11174. }
  11175. /*:936*//*939:*/
  11176. #line 19445 "./typica.w"
  11177. void LinearSplineInterpolationConfWidget::updateKnots()
  11178. {
  11179. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11180. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11181. }
  11182. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11183. {
  11184. updateAttribute("source",source);
  11185. }
  11186. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11187. {
  11188. updateAttribute("destination",dest);
  11189. }
  11190. /*:939*/
  11191. #line 602 "./typica.w"
  11192. /*956:*/
  11193. #line 19914 "./typica.w"
  11194. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11195. :BasicDeviceConfigurationWidget(model,index),
  11196. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  11197. {
  11198. unitSelector->addItem("Fahrenheit");
  11199. unitSelector->addItem("Celsius");
  11200. temperatureValue->setMinimum(0);
  11201. temperatureValue->setMaximum(1000);
  11202. QFormLayout*layout= new QFormLayout;
  11203. QLineEdit*column= new QLineEdit;
  11204. layout->addRow(tr("Column to match:"),column);
  11205. layout->addRow(tr("Unit:"),unitSelector);
  11206. layout->addRow(tr("Value:"),temperatureValue);
  11207. /*771:*/
  11208. #line 16335 "./typica.w"
  11209. QDomElement referenceElement=
  11210. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11211. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11212. QDomElement node;
  11213. /*:771*/
  11214. #line 19928 "./typica.w"
  11215. for(int i= 0;i<configData.size();i++)
  11216. {
  11217. node= configData.at(i).toElement();
  11218. if(node.attribute("name")=="column")
  11219. {
  11220. column->setText(node.attribute("value"));
  11221. }
  11222. else if(node.attribute("name")=="unit")
  11223. {
  11224. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11225. }
  11226. else if(node.attribute("name")=="value")
  11227. {
  11228. temperatureValue->setValue(node.attribute("value").toDouble());
  11229. }
  11230. }
  11231. updateMatchingColumn(column->text());
  11232. updateTemperature();
  11233. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11234. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11235. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11236. setLayout(layout);
  11237. }
  11238. /*:956*//*957:*/
  11239. #line 19957 "./typica.w"
  11240. void TranslationConfWidget::updateTemperature()
  11241. {
  11242. updateAttribute("unit",unitSelector->currentText());
  11243. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11244. if(unitSelector->currentText()=="Fahrenheit")
  11245. {
  11246. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11247. }
  11248. else
  11249. {
  11250. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11251. }
  11252. }
  11253. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11254. {
  11255. updateAttribute("column",column);
  11256. }
  11257. /*:957*/
  11258. #line 603 "./typica.w"
  11259. /*828:*/
  11260. #line 24 "./freeannotation.w"
  11261. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11262. const QModelIndex&index)
  11263. :BasicDeviceConfigurationWidget(model,index)
  11264. {
  11265. QFormLayout*layout= new QFormLayout;
  11266. QLineEdit*labelEdit= new QLineEdit;
  11267. layout->addRow(tr("Label Text:"),labelEdit);
  11268. /*771:*/
  11269. #line 16335 "./typica.w"
  11270. QDomElement referenceElement=
  11271. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11272. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11273. QDomElement node;
  11274. /*:771*/
  11275. #line 32 "./freeannotation.w"
  11276. for(int i= 0;i<configData.size();i++)
  11277. {
  11278. node= configData.at(i).toElement();
  11279. if(node.attribute("name")=="labeltext")
  11280. {
  11281. labelEdit->setText(node.attribute("value"));
  11282. }
  11283. }
  11284. updateLabel(labelEdit->text());
  11285. connect(labelEdit,SIGNAL(textEdited(QString)),
  11286. this,SLOT(updateLabel(QString)));
  11287. setLayout(layout);
  11288. }
  11289. /*:828*//*829:*/
  11290. #line 49 "./freeannotation.w"
  11291. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11292. {
  11293. updateAttribute("labeltext",text);
  11294. }
  11295. /*:829*/
  11296. #line 604 "./typica.w"
  11297. /*960:*/
  11298. #line 39 "./rate.w"
  11299. void RateOfChange::newMeasurement(Measurement measure)
  11300. {
  11301. cache.append(measure);
  11302. /*961:*/
  11303. #line 64 "./rate.w"
  11304. if(cache.size()> 2)
  11305. {
  11306. bool done= false;
  11307. while(!done)
  11308. {
  11309. if(cache.front().time().secsTo(cache.back().time())> ct)
  11310. {
  11311. cache.removeFirst();
  11312. }
  11313. else if(cache.back().time()<cache.front().time())
  11314. {
  11315. cache.removeFirst();
  11316. done= true;
  11317. }
  11318. else
  11319. {
  11320. done= true;
  11321. }
  11322. if(cache.size()<3)
  11323. {
  11324. done= true;
  11325. }
  11326. }
  11327. }
  11328. /*:961*/
  11329. #line 43 "./rate.w"
  11330. if(cache.size()>=2)
  11331. {
  11332. /*962:*/
  11333. #line 96 "./rate.w"
  11334. int N= cache.size();
  11335. double SXY= 0;
  11336. double SX= 0;
  11337. double SXX= 0;
  11338. double SY= 0;
  11339. double y;
  11340. double x;
  11341. for(int i= 0;i<N;i++)
  11342. {
  11343. y= cache.at(i).temperature();
  11344. SY+= y;
  11345. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11346. SX+= x;
  11347. SXX+= (x*x);
  11348. SXY+= (x*y);
  11349. }
  11350. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11351. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11352. value.insert("relative",true);
  11353. emit newData(value);
  11354. /*:962*/
  11355. #line 46 "./rate.w"
  11356. }
  11357. }
  11358. /*:960*//*963:*/
  11359. #line 120 "./rate.w"
  11360. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11361. {
  11362. setScaleTime(scaletime);
  11363. }
  11364. void RateOfChange::setCacheTime(int seconds)
  11365. {
  11366. ct= seconds;
  11367. }
  11368. void RateOfChange::setScaleTime(int seconds)
  11369. {
  11370. st= (seconds> 0?seconds:1);
  11371. }
  11372. /*:963*/
  11373. #line 605 "./typica.w"
  11374. /*832:*/
  11375. #line 26 "./settings.w"
  11376. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11377. {
  11378. QTabWidget*settingsTab= new QTabWidget;
  11379. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11380. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11381. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11382. settingsTab->addTab(graphSettings,tr("Graph"));
  11383. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11384. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11385. setCentralWidget(settingsTab);
  11386. }
  11387. /*:832*/
  11388. #line 606 "./typica.w"
  11389. /*837:*/
  11390. #line 27 "./graphsettings.w"
  11391. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11392. {
  11393. QTabWidget*graphCategories= new QTabWidget;
  11394. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11395. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11396. QVBoxLayout*layout= new QVBoxLayout;
  11397. layout->addWidget(graphCategories);
  11398. setLayout(layout);
  11399. }
  11400. /*:837*//*839:*/
  11401. #line 65 "./graphsettings.w"
  11402. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11403. colorEdit(new QLineEdit)
  11404. {
  11405. QSettings settings;
  11406. QVBoxLayout*layout= new QVBoxLayout;
  11407. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11408. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11409. updateEnableSetting(enable->isChecked());
  11410. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11411. layout->addWidget(enable);
  11412. QHBoxLayout*colorLayout= new QHBoxLayout;
  11413. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11414. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11415. updateColorSetting(colorEdit->text());
  11416. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11417. QToolButton*colorPickerButton= new QToolButton();
  11418. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11419. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11420. colorLayout->addWidget(colorLabel);
  11421. colorLayout->addWidget(colorEdit);
  11422. colorLayout->addWidget(colorPickerButton);
  11423. colorLayout->addStretch();
  11424. layout->addLayout(colorLayout);
  11425. QHBoxLayout*unitLayout= new QHBoxLayout;
  11426. QLabel*unitLabel= new QLabel(tr("Unit"));
  11427. QComboBox*unitSelector= new QComboBox;
  11428. unitSelector->addItem(tr("Fahrenheit"));
  11429. unitSelector->addItem(tr("Celsius"));
  11430. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11431. updateUnit(unitSelector->currentIndex());
  11432. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11433. unitLayout->addWidget(unitLabel);
  11434. unitLayout->addWidget(unitSelector);
  11435. unitLayout->addStretch();
  11436. layout->addLayout(unitLayout);
  11437. QHBoxLayout*axisLayout= new QHBoxLayout;
  11438. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11439. QLineEdit*axisEdit= new QLineEdit;
  11440. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11441. updateAxisSetting(axisEdit->text());
  11442. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11443. axisLayout->addWidget(axisLabel);
  11444. axisLayout->addWidget(axisEdit);
  11445. layout->addLayout(axisLayout);
  11446. layout->addStretch();
  11447. setLayout(layout);
  11448. }
  11449. /*:839*//*840:*/
  11450. #line 116 "./graphsettings.w"
  11451. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11452. {
  11453. QSettings settings;
  11454. settings.setValue("settings/graph/relative/enable",enabled);
  11455. }
  11456. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11457. {
  11458. QSettings settings;
  11459. settings.setValue("settings/graph/relative/color",color);
  11460. }
  11461. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11462. {
  11463. QSettings settings;
  11464. QString settingValue;
  11465. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11466. QStringList numbers;
  11467. foreach(QString text,points)
  11468. {
  11469. bool okay= false;
  11470. text.toDouble(&okay);
  11471. if(okay)
  11472. {
  11473. numbers.append(text);
  11474. }
  11475. }
  11476. numbers.removeDuplicates();
  11477. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11478. }
  11479. void GraphSettingsRelativeTab::updateUnit(int unit)
  11480. {
  11481. QSettings settings;
  11482. settings.setValue("settings/graph/relative/unit",unit);
  11483. }
  11484. /*:840*//*841:*/
  11485. #line 159 "./graphsettings.w"
  11486. void GraphSettingsRelativeTab::showColorPicker()
  11487. {
  11488. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11489. colorEdit->setText(color.name());
  11490. }
  11491. #line 62 "./settings.w"
  11492. #line 1 "./advancedsettings.w"
  11493. /*:841*/
  11494. #line 607 "./typica.w"
  11495. /*995:*/
  11496. #line 682 "./dataqsdk.w"
  11497. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11498. const QModelIndex&index)
  11499. :BasicDeviceConfigurationWidget(model,index),
  11500. deviceIdStack(new QStackedWidget)
  11501. {
  11502. QVBoxLayout*layout= new QVBoxLayout;
  11503. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11504. layout->addWidget(autoDetect);
  11505. QWidget*autoLayerWidget= new QWidget;
  11506. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11507. QLabel*autoLabel= new QLabel(tr("Device number"));
  11508. QSpinBox*autoNumber= new QSpinBox;
  11509. autoNumber->setMinimum(1);
  11510. autoNumber->setMaximum(99);
  11511. autoLayerLayout->addWidget(autoLabel);
  11512. autoLayerLayout->addWidget(autoNumber);
  11513. autoLayerWidget->setLayout(autoLayerLayout);
  11514. QWidget*fixedLayerWidget= new QWidget;
  11515. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11516. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11517. QComboBox*portSelection= new QComboBox;
  11518. portSelection->setEditable(true);
  11519. portSelection->addItems(DataqSdkDevice::detectHardware());
  11520. fixedLayerLayout->addWidget(fixedLabel);
  11521. fixedLayerLayout->addWidget(portSelection);
  11522. fixedLayerWidget->setLayout(fixedLayerLayout);
  11523. deviceIdStack->addWidget(autoLayerWidget);
  11524. deviceIdStack->addWidget(fixedLayerWidget);
  11525. layout->addWidget(deviceIdStack);
  11526. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11527. layout->addWidget(addChannelButton);
  11528. /*771:*/
  11529. #line 16335 "./typica.w"
  11530. QDomElement referenceElement=
  11531. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11532. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11533. QDomElement node;
  11534. /*:771*/
  11535. #line 714 "./dataqsdk.w"
  11536. for(int i= 0;i<configData.size();i++)
  11537. {
  11538. node= configData.at(i).toElement();
  11539. if(node.attribute("name")=="autoSelect")
  11540. {
  11541. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11542. }
  11543. else if(node.attribute("name")=="deviceNumber")
  11544. {
  11545. autoNumber->setValue(node.attribute("value").toInt());
  11546. }
  11547. else if(node.attribute("name")=="port")
  11548. {
  11549. int index= portSelection->findText(node.attribute("value"));
  11550. if(index> -1)
  11551. {
  11552. portSelection->setCurrentIndex(index);
  11553. }
  11554. else
  11555. {
  11556. portSelection->setEditText(node.attribute("value"));
  11557. }
  11558. }
  11559. }
  11560. updateAutoSelect(autoDetect->isChecked());
  11561. updateDeviceNumber(autoNumber->value());
  11562. updatePort(portSelection->currentText());
  11563. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11564. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11565. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11566. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11567. setLayout(layout);
  11568. }
  11569. /*:995*//*996:*/
  11570. #line 758 "./dataqsdk.w"
  11571. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11572. {
  11573. if(automatic)
  11574. {
  11575. updateAttribute("autoSelect","true");
  11576. deviceIdStack->setCurrentIndex(0);
  11577. }
  11578. else
  11579. {
  11580. updateAttribute("autoSelect","false");
  11581. deviceIdStack->setCurrentIndex(1);
  11582. }
  11583. }
  11584. /*:996*//*997:*/
  11585. #line 775 "./dataqsdk.w"
  11586. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11587. {
  11588. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11589. }
  11590. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11591. {
  11592. updateAttribute("port",portId);
  11593. }
  11594. /*:997*//*998:*/
  11595. #line 788 "./dataqsdk.w"
  11596. void DataqSdkDeviceConfWidget::addChannel()
  11597. {
  11598. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11599. }
  11600. /*:998*//*1001:*/
  11601. #line 868 "./dataqsdk.w"
  11602. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11603. const QModelIndex&index)
  11604. :BasicDeviceConfigurationWidget(model,index),
  11605. startButton(new QPushButton(tr("Start"))),
  11606. resetButton(new QPushButton(tr("Reset"))),
  11607. stopButton(new QPushButton(tr("Stop"))),
  11608. calibrator(new LinearCalibrator),
  11609. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11610. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11611. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11612. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11613. rmCount(0),cmCount(0),
  11614. rmin(std::numeric_limits<double> ::max()),
  11615. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11616. cmin(std::numeric_limits<double> ::max()),
  11617. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11618. {
  11619. /*1005:*/
  11620. #line 1107 "./dataqsdk.w"
  11621. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11622. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11623. QDomElement deviceNode;
  11624. QString configPort;
  11625. QString configAuto;
  11626. for(int i= 0;i<deviceConfigData.size();i++)
  11627. {
  11628. deviceNode= deviceConfigData.at(i).toElement();
  11629. if(deviceNode.attribute("name")=="autoSelect")
  11630. {
  11631. autoSelect= (deviceNode.attribute("value")=="true");
  11632. }
  11633. else if(deviceNode.attribute("name")=="deviceNumber")
  11634. {
  11635. configAuto= deviceNode.attribute("value");
  11636. }
  11637. else if(deviceNode.attribute("name")=="port")
  11638. {
  11639. configPort= deviceNode.attribute("value");
  11640. }
  11641. }
  11642. deviceID= autoSelect?configAuto:configPort;
  11643. channelOfInterest= index.row();
  11644. /*:1005*/
  11645. #line 886 "./dataqsdk.w"
  11646. resetButton->setEnabled(false);
  11647. stopButton->setEnabled(false);
  11648. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11649. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11650. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11651. QVBoxLayout*layout= new QVBoxLayout;
  11652. QFormLayout*topLayout= new QFormLayout;
  11653. QLineEdit*columnEdit= new QLineEdit;
  11654. topLayout->addRow(tr("Column name"),columnEdit);
  11655. QComboBox*unitSelector= new QComboBox;
  11656. unitSelector->addItem(tr("Temperature"));
  11657. unitSelector->addItem(tr("Control"));
  11658. topLayout->addRow(tr("Measurement type"),unitSelector);
  11659. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11660. topLayout->addRow(smoothingBox);
  11661. layout->addLayout(topLayout);
  11662. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11663. topLayout->addRow(hideSeries);
  11664. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11665. layout->addWidget(calibrationLabel);
  11666. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11667. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11668. QLineEdit*measuredLowerEdit= new QLineEdit;
  11669. measuredLowerEdit->setText("0");
  11670. QLineEdit*measuredUpperEdit= new QLineEdit;
  11671. measuredUpperEdit->setText("10");
  11672. QLineEdit*mappedLowerEdit= new QLineEdit;
  11673. mappedLowerEdit->setText("0");
  11674. QLineEdit*mappedUpperEdit= new QLineEdit;
  11675. mappedUpperEdit->setText("10");
  11676. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11677. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11678. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11679. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11680. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11681. calibrationControlsLayout->addRow(closedBox);
  11682. QLineEdit*sensitivityEdit= new QLineEdit;
  11683. sensitivityEdit->setText("0");
  11684. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11685. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11686. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11687. deviceControlLayout->addWidget(startButton);
  11688. deviceControlLayout->addWidget(resetButton);
  11689. deviceControlLayout->addWidget(stopButton);
  11690. QFormLayout*indicatorLayout= new QFormLayout;
  11691. currentMeasurement->setReadOnly(true);
  11692. minimumMeasurement->setReadOnly(true);
  11693. maximumMeasurement->setReadOnly(true);
  11694. averageMeasurement->setReadOnly(true);
  11695. currentMapped->setReadOnly(true);
  11696. minimumMapped->setReadOnly(true);
  11697. maximumMapped->setReadOnly(true);
  11698. averageMapped->setReadOnly(true);
  11699. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11700. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11701. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11702. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11703. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11704. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11705. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11706. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11707. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11708. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11709. calibrationTestLayout->addLayout(deviceControlLayout);
  11710. calibrationTestLayout->addLayout(indicatorLayout);
  11711. calibrationLayout->addLayout(calibrationControlsLayout);
  11712. calibrationLayout->addLayout(calibrationTestLayout);
  11713. layout->addLayout(calibrationLayout);
  11714. /*771:*/
  11715. #line 16335 "./typica.w"
  11716. QDomElement referenceElement=
  11717. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11718. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11719. QDomElement node;
  11720. /*:771*/
  11721. #line 955 "./dataqsdk.w"
  11722. for(int i= 0;i<configData.size();i++)
  11723. {
  11724. node= configData.at(i).toElement();
  11725. if(node.attribute("name")=="column")
  11726. {
  11727. columnEdit->setText(node.attribute("value"));
  11728. }
  11729. else if(node.attribute("name")=="type")
  11730. {
  11731. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11732. }
  11733. else if(node.attribute("name")=="smoothing")
  11734. {
  11735. smoothingBox->setChecked(node.attribute("value")=="true");
  11736. }
  11737. else if(node.attribute("name")=="calibrationMeasuredLower")
  11738. {
  11739. measuredLowerEdit->setText(node.attribute("value"));
  11740. }
  11741. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11742. {
  11743. measuredUpperEdit->setText(node.attribute("value"));
  11744. }
  11745. else if(node.attribute("name")=="calibrationMappedLower")
  11746. {
  11747. mappedLowerEdit->setText(node.attribute("value"));
  11748. }
  11749. else if(node.attribute("name")=="calibrationMappedUpper")
  11750. {
  11751. mappedUpperEdit->setText(node.attribute("value"));
  11752. }
  11753. else if(node.attribute("name")=="calibrationClosedInterval")
  11754. {
  11755. closedBox->setChecked(node.attribute("value")=="true");
  11756. }
  11757. else if(node.attribute("name")=="calibrationSensitivity")
  11758. {
  11759. sensitivityEdit->setText(node.attribute("value"));
  11760. }
  11761. else if(node.attribute("name")=="hidden")
  11762. {
  11763. hideSeries->setChecked(node.attribute("value")=="true");
  11764. }
  11765. }
  11766. updateColumnName(columnEdit->text());
  11767. updateUnits(unitSelector->currentText());
  11768. updateSmoothingEnabled(smoothingBox->isChecked());
  11769. updateMeasuredLower(measuredLowerEdit->text());
  11770. updateMeasuredUpper(measuredUpperEdit->text());
  11771. updateMappedLower(mappedLowerEdit->text());
  11772. updateMappedUpper(mappedUpperEdit->text());
  11773. updateClosedInterval(closedBox->isChecked());
  11774. updateSensitivity(sensitivityEdit->text());
  11775. updateHidden(hideSeries->isChecked());
  11776. connect(columnEdit,SIGNAL(textChanged(QString)),
  11777. this,SLOT(updateColumnName(QString)));
  11778. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11779. this,SLOT(updateUnits(QString)));
  11780. connect(smoothingBox,SIGNAL(toggled(bool)),
  11781. this,SLOT(updateSmoothingEnabled(bool)));
  11782. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11783. this,SLOT(updateMeasuredLower(QString)));
  11784. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11785. this,SLOT(updateMappedLower(QString)));
  11786. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11787. this,SLOT(updateMeasuredUpper(QString)));
  11788. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11789. this,SLOT(updateMappedUpper(QString)));
  11790. connect(closedBox,SIGNAL(toggled(bool)),
  11791. this,SLOT(updateClosedInterval(bool)));
  11792. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11793. this,SLOT(updateSensitivity(QString)));
  11794. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11795. setLayout(layout);
  11796. }
  11797. /*:1001*//*1002:*/
  11798. #line 1038 "./dataqsdk.w"
  11799. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11800. {
  11801. updateAttribute("type",unit);
  11802. }
  11803. /*:1002*//*1003:*/
  11804. #line 1047 "./dataqsdk.w"
  11805. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11806. {
  11807. updateAttribute("calibrationMeasuredLower",value);
  11808. calibrator->setMeasuredLower(value.toDouble());
  11809. }
  11810. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11811. {
  11812. updateAttribute("calibrationMeasuredUpper",value);
  11813. calibrator->setMeasuredUpper(value.toDouble());
  11814. }
  11815. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11816. {
  11817. updateAttribute("calibrationMappedLower",value);
  11818. calibrator->setMappedLower(value.toDouble());
  11819. }
  11820. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11821. {
  11822. updateAttribute("calibrationMappedUpper",value);
  11823. calibrator->setMappedUpper(value.toDouble());
  11824. }
  11825. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11826. {
  11827. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11828. calibrator->setClosedRange(closed);
  11829. }
  11830. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11831. {
  11832. updateAttribute("smoothing",enabled?"true":"false");
  11833. }
  11834. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11835. {
  11836. updateAttribute("calibrationSensitivity",value);
  11837. calibrator->setSensitivity(value.toDouble());
  11838. }
  11839. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11840. {
  11841. updateAttribute("hidden",hidden?"true":"false");
  11842. }
  11843. /*:1003*//*1006:*/
  11844. #line 1136 "./dataqsdk.w"
  11845. void DataqSdkChannelConfWidget::startCalibration()
  11846. {
  11847. startButton->setEnabled(false);
  11848. stopButton->setEnabled(true);
  11849. resetButton->setEnabled(true);
  11850. calibrationDevice= new DataqSdkDevice(deviceID);
  11851. Channel*channel;
  11852. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11853. {
  11854. channel= calibrationDevice->newChannel(Units::Unitless);
  11855. }
  11856. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11857. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11858. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11859. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11860. calibrationDevice->start();
  11861. }
  11862. void DataqSdkChannelConfWidget::stopCalibration()
  11863. {
  11864. startButton->setEnabled(true);
  11865. stopButton->setEnabled(false);
  11866. resetButton->setEnabled(false);
  11867. calibrationDevice->deleteLater();
  11868. /*1008:*/
  11869. #line 1181 "./dataqsdk.w"
  11870. rmCount= 0;
  11871. cmCount= 0;
  11872. rmin= std::numeric_limits<double> ::max();
  11873. rmax= std::numeric_limits<double> ::min();
  11874. rmean= 0;
  11875. cmin= std::numeric_limits<double> ::max();
  11876. cmax= std::numeric_limits<double> ::min();
  11877. cmean= 0;
  11878. /*:1008*/
  11879. #line 1161 "./dataqsdk.w"
  11880. }
  11881. /*:1006*//*1007:*/
  11882. #line 1172 "./dataqsdk.w"
  11883. void DataqSdkChannelConfWidget::resetCalibration()
  11884. {
  11885. /*1008:*/
  11886. #line 1181 "./dataqsdk.w"
  11887. rmCount= 0;
  11888. cmCount= 0;
  11889. rmin= std::numeric_limits<double> ::max();
  11890. rmax= std::numeric_limits<double> ::min();
  11891. rmean= 0;
  11892. cmin= std::numeric_limits<double> ::max();
  11893. cmax= std::numeric_limits<double> ::min();
  11894. cmean= 0;
  11895. /*:1008*/
  11896. #line 1175 "./dataqsdk.w"
  11897. }
  11898. /*:1007*//*1009:*/
  11899. #line 1195 "./dataqsdk.w"
  11900. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11901. {
  11902. double nv= measure.temperature();
  11903. currentMeasurement->setText(QString("%1").arg(nv));
  11904. rmin= qMin(nv,rmin);
  11905. minimumMeasurement->setText(QString("%1").arg(rmin));
  11906. rmax= qMax(nv,rmax);
  11907. maximumMeasurement->setText(QString("%1").arg(rmax));
  11908. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11909. rmCount++;
  11910. averageMeasurement->setText(QString("%1").arg(rmean));
  11911. }
  11912. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11913. {
  11914. double nv= measure.temperature();
  11915. currentMapped->setText(QString("%1").arg(nv));
  11916. cmin= qMin(nv,cmin);
  11917. minimumMapped->setText(QString("%1").arg(cmin));
  11918. cmax= qMax(nv,cmax);
  11919. maximumMapped->setText(QString("%1").arg(cmax));
  11920. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11921. cmCount++;
  11922. averageMapped->setText(QString("%1").arg(cmean));
  11923. }
  11924. /*:1009*//*1010:*/
  11925. #line 1224 "./dataqsdk.w"
  11926. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11927. {
  11928. updateAttribute("column",value);
  11929. }
  11930. /*:1010*/
  11931. #line 608 "./typica.w"
  11932. /*1034:*/
  11933. #line 423 "./scales.w"
  11934. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11935. const QModelIndex&index)
  11936. :BasicDeviceConfigurationWidget(model,index),
  11937. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11938. flow(new FlowSelector),stop(new StopSelector),
  11939. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  11940. {
  11941. QFormLayout*layout= new QFormLayout;
  11942. layout->addRow(tr("Port:"),port);
  11943. connect(port,SIGNAL(currentIndexChanged(QString)),
  11944. this,SLOT(updatePort(QString)));
  11945. connect(port,SIGNAL(editTextChanged(QString)),
  11946. this,SLOT(updatePort(QString)));
  11947. layout->addRow(tr("Baud:"),baud);
  11948. connect(baud,SIGNAL(currentIndexChanged(QString)),
  11949. this,SLOT(updateBaudRate(QString)));
  11950. layout->addRow(tr("Parity:"),parity);
  11951. connect(parity,SIGNAL(currentIndexChanged(int)),
  11952. this,SLOT(updateParity(int)));
  11953. layout->addRow(tr("Flow Control:"),flow);
  11954. connect(flow,SIGNAL(currentIndexChanged(int)),
  11955. this,SLOT(updateFlowControl(int)));
  11956. layout->addRow(tr("Stop Bits:"),stop);
  11957. connect(stop,SIGNAL(currentIndexChanged(int)),
  11958. this,SLOT(updateStopBits(int)));
  11959. layout->addRow(tr("Weigh Command:"),weighcommand);
  11960. connect(weighcommand,SIGNAL(textChanged(QString)),
  11961. this,SLOT(updateWeighCommand(QString)));
  11962. commandterminator->addItem("CRLF");
  11963. commandterminator->addItem("CR");
  11964. commandterminator->addItem("LF");
  11965. layout->addRow(tr("Command Terminator:"),commandterminator);
  11966. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  11967. this,SLOT(updateCommandTerminator(QString)));
  11968. /*771:*/
  11969. #line 16335 "./typica.w"
  11970. QDomElement referenceElement=
  11971. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11972. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11973. QDomElement node;
  11974. /*:771*/
  11975. #line 459 "./scales.w"
  11976. for(int i= 0;i<configData.size();i++)
  11977. {
  11978. node= configData.at(i).toElement();
  11979. if(node.attribute("name")=="port")
  11980. {
  11981. int j= port->findText(node.attribute("value"));
  11982. if(j>=0)
  11983. {
  11984. port->setCurrentIndex(j);
  11985. }
  11986. else
  11987. {
  11988. port->insertItem(0,node.attribute("value"));
  11989. port->setCurrentIndex(0);
  11990. }
  11991. }
  11992. else if(node.attribute("name")=="baudrate")
  11993. {
  11994. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  11995. }
  11996. else if(node.attribute("name")=="parity")
  11997. {
  11998. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  11999. }
  12000. else if(node.attribute("name")=="flowcontrol")
  12001. {
  12002. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12003. }
  12004. else if(node.attribute("name")=="stopbits")
  12005. {
  12006. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12007. }
  12008. else if(node.attribute("name")=="weighcommand")
  12009. {
  12010. weighcommand->setText(node.attribute("value"));
  12011. }
  12012. else if(node.attribute("name")=="commandterminator")
  12013. {
  12014. commandterminator->setCurrentIndex(
  12015. commandterminator->findText(node.attribute("value")));
  12016. }
  12017. }
  12018. updatePort(port->currentText());
  12019. updateBaudRate(baud->currentText());
  12020. updateParity(parity->currentIndex());
  12021. updateFlowControl(flow->currentIndex());
  12022. updateStopBits(stop->currentIndex());
  12023. updateWeighCommand(weighcommand->text());
  12024. updateCommandTerminator(commandterminator->currentText());
  12025. setLayout(layout);
  12026. }
  12027. /*:1034*//*1035:*/
  12028. #line 514 "./scales.w"
  12029. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12030. {
  12031. updateAttribute("port",newPort);
  12032. }
  12033. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12034. {
  12035. updateAttribute("baudrate",rate);
  12036. }
  12037. void SerialScaleConfWidget::updateParity(int index)
  12038. {
  12039. updateAttribute("parity",parity->itemData(index).toString());
  12040. }
  12041. void SerialScaleConfWidget::updateFlowControl(int index)
  12042. {
  12043. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12044. }
  12045. void SerialScaleConfWidget::updateStopBits(int index)
  12046. {
  12047. updateAttribute("stopbits",stop->itemData(index).toString());
  12048. }
  12049. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12050. {
  12051. updateAttribute("weighcommand",command);
  12052. }
  12053. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12054. {
  12055. updateAttribute("commandterminator",terminator);
  12056. }
  12057. /*:1035*/
  12058. #line 609 "./typica.w"
  12059. /*1047:*/
  12060. #line 195 "./valueannotation.w"
  12061. void ValueAnnotation::newMeasurement(Measurement measure)
  12062. {
  12063. for(int i= 0;i<values.size();i++)
  12064. {
  12065. if(measure.temperature()> values.at(i)-tolerance&&
  12066. measure.temperature()<values.at(i)+tolerance)
  12067. {
  12068. if(i!=lastIndex)
  12069. {
  12070. lastIndex= i;
  12071. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12072. }
  12073. }
  12074. }
  12075. }
  12076. /*:1047*//*1048:*/
  12077. #line 216 "./valueannotation.w"
  12078. void ValueAnnotation::annotate()
  12079. {
  12080. if(lastIndex> -1)
  12081. {
  12082. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12083. }
  12084. }
  12085. /*:1048*//*1049:*/
  12086. #line 228 "./valueannotation.w"
  12087. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12088. {
  12089. values.append(value);
  12090. annotations.append(annotation);
  12091. }
  12092. /*:1049*//*1050:*/
  12093. #line 237 "./valueannotation.w"
  12094. void ValueAnnotation::setAnnotationColumn(int column)
  12095. {
  12096. annotationColumn= column;
  12097. }
  12098. void ValueAnnotation::setTemperatureColumn(int column)
  12099. {
  12100. measurementColumn= column;
  12101. }
  12102. void ValueAnnotation::setTolerance(double epsilon)
  12103. {
  12104. tolerance= epsilon;
  12105. }
  12106. /*:1050*//*1051:*/
  12107. #line 255 "./valueannotation.w"
  12108. ValueAnnotation::ValueAnnotation():QObject(),
  12109. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12110. {
  12111. }
  12112. /*:1051*/
  12113. #line 610 "./typica.w"
  12114. /*1039:*/
  12115. #line 33 "./valueannotation.w"
  12116. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12117. const QModelIndex&index)
  12118. :BasicDeviceConfigurationWidget(model,index),
  12119. tablemodel(new SaltModel(2))
  12120. {
  12121. QFormLayout*layout= new QFormLayout;
  12122. QLineEdit*source= new QLineEdit;
  12123. layout->addRow(tr("Source column name:"),source);
  12124. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12125. noteOnStart->setChecked(true);
  12126. layout->addRow(noteOnStart);
  12127. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12128. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12129. QTableView*annotationTable= new QTableView;
  12130. annotationTable->setModel(tablemodel);
  12131. NumericDelegate*delegate= new NumericDelegate;
  12132. annotationTable->setItemDelegateForColumn(0,delegate);
  12133. layout->addRow(tr("Annotations for values:"),annotationTable);
  12134. /*771:*/
  12135. #line 16335 "./typica.w"
  12136. QDomElement referenceElement=
  12137. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12138. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12139. QDomElement node;
  12140. /*:771*/
  12141. #line 52 "./valueannotation.w"
  12142. for(int i= 0;i<configData.size();i++)
  12143. {
  12144. node= configData.at(i).toElement();
  12145. if(node.attribute("name")=="source")
  12146. {
  12147. source->setText(node.attribute("value"));
  12148. }
  12149. else if(node.attribute("name")=="emitOnStart")
  12150. {
  12151. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12152. }
  12153. else if(node.attribute("name")=="measuredValues")
  12154. {
  12155. /*937:*/
  12156. #line 19422 "./typica.w"
  12157. QString data= node.attribute("value");
  12158. if(data.length()> 3)
  12159. {
  12160. data.chop(2);
  12161. data= data.remove(0,2);
  12162. }
  12163. QStringList itemList= data.split(",");
  12164. /*:937*/
  12165. #line 66 "./valueannotation.w"
  12166. int column= 0;
  12167. /*938:*/
  12168. #line 19434 "./typica.w"
  12169. for(int j= 0;j<itemList.size();j++)
  12170. {
  12171. tablemodel->setData(tablemodel->index(j,column),
  12172. QVariant(itemList.at(j).toDouble()),
  12173. Qt::DisplayRole);
  12174. }
  12175. /*:938*/
  12176. #line 68 "./valueannotation.w"
  12177. }
  12178. else if(node.attribute("name")=="annotations")
  12179. {
  12180. /*1040:*/
  12181. #line 89 "./valueannotation.w"
  12182. QString data= node.attribute("value");
  12183. if(data.length()> 3)
  12184. {
  12185. data.chop(2);
  12186. data= data.remove(0,2);
  12187. }
  12188. QStringList itemList= data.split(",");
  12189. for(int i= 0;i<itemList.size();i++)
  12190. {
  12191. itemList[i]= itemList[i].simplified();
  12192. }
  12193. /*:1040*/
  12194. #line 72 "./valueannotation.w"
  12195. int column= 1;
  12196. /*1041:*/
  12197. #line 104 "./valueannotation.w"
  12198. for(int i= 0;i<itemList.size();i++)
  12199. {
  12200. tablemodel->setData(tablemodel->index(i,column),
  12201. QVariant(itemList.at(i)),
  12202. Qt::DisplayRole);
  12203. }
  12204. /*:1041*/
  12205. #line 74 "./valueannotation.w"
  12206. }
  12207. }
  12208. updateSourceColumn(source->text());
  12209. updateStart(noteOnStart->isChecked());
  12210. updateAnnotations();
  12211. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12212. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12213. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12214. setLayout(layout);
  12215. }
  12216. /*:1039*//*1042:*/
  12217. #line 115 "./valueannotation.w"
  12218. void ValueAnnotationConfWidget::updateAnnotations()
  12219. {
  12220. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12221. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12222. }
  12223. /*:1042*//*1043:*/
  12224. #line 125 "./valueannotation.w"
  12225. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12226. {
  12227. updateAttribute("source",source);
  12228. }
  12229. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12230. {
  12231. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12232. }
  12233. /*:1043*/
  12234. #line 611 "./typica.w"
  12235. /*867:*/
  12236. #line 44 "./modbus.w"
  12237. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12238. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12239. m_flow(new FlowSelector),m_stop(new StopSelector)
  12240. {
  12241. QFormLayout*layout= new QFormLayout;
  12242. PortSelector*port= new PortSelector;
  12243. BaudSelector*baud= new BaudSelector;
  12244. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12245. layout->addRow(QString(tr("Port:")),port);
  12246. layout->addRow(QString(tr("Baud rate:")),baud);
  12247. layout->addRow(QString(tr("Parity:")),m_parity);
  12248. layout->addRow(QString(tr("Flow control:")),m_flow);
  12249. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12250. layout->addRow(newInput);
  12251. /*771:*/
  12252. #line 16335 "./typica.w"
  12253. QDomElement referenceElement=
  12254. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12255. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12256. QDomElement node;
  12257. /*:771*/
  12258. #line 60 "./modbus.w"
  12259. for(int i= 0;i<configData.size();i++)
  12260. {
  12261. node= configData.at(i).toElement();
  12262. if(node.attribute("name")=="port")
  12263. {
  12264. int idx= port->findText(node.attribute("value"));
  12265. if(idx>=0)
  12266. {
  12267. port->setCurrentIndex(idx);
  12268. }
  12269. else
  12270. {
  12271. port->addItem(node.attribute("value"));
  12272. }
  12273. }
  12274. else if(node.attribute("name")=="baud")
  12275. {
  12276. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12277. }
  12278. else if(node.attribute("name")=="parity")
  12279. {
  12280. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12281. }
  12282. else if(node.attribute("name")=="flow")
  12283. {
  12284. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12285. }
  12286. else if(node.attribute("name")=="stop")
  12287. {
  12288. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12289. }
  12290. }
  12291. updatePort(port->currentText());
  12292. updateBaudRate(baud->currentText());
  12293. updateParity(m_parity->currentIndex());
  12294. updateFlowControl(m_flow->currentIndex());
  12295. updateStopBits(m_stop->currentIndex());
  12296. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12297. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12298. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12299. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12300. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12301. this,SLOT(updateFlowControl(int)));
  12302. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12303. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12304. setLayout(layout);
  12305. }
  12306. void ModbusNGConfWidget::updatePort(const QString&value)
  12307. {
  12308. updateAttribute("port",value);
  12309. }
  12310. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12311. {
  12312. updateAttribute("baud",value);
  12313. }
  12314. void ModbusNGConfWidget::updateParity(int value)
  12315. {
  12316. updateAttribute("parity",m_parity->itemData(value).toString());
  12317. }
  12318. void ModbusNGConfWidget::updateFlowControl(int value)
  12319. {
  12320. updateAttribute("flow",m_flow->itemData(value).toString());
  12321. }
  12322. void ModbusNGConfWidget::updateStopBits(int value)
  12323. {
  12324. updateAttribute("stop",m_stop->itemData(value).toString());
  12325. }
  12326. void ModbusNGConfWidget::addInput()
  12327. {
  12328. insertChildNode(tr("Input"),"modbusnginput");
  12329. }
  12330. /*:867*//*869:*/
  12331. #line 164 "./modbus.w"
  12332. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12333. {
  12334. QFormLayout*layout= new QFormLayout;
  12335. QSpinBox*station= new QSpinBox;
  12336. station->setMinimum(1);
  12337. station->setMaximum(247);
  12338. layout->addRow(tr("Station ID"),station);
  12339. QComboBox*function= new QComboBox;
  12340. function->addItem("3","3");
  12341. function->addItem("4","4");
  12342. function->setCurrentIndex(1);
  12343. layout->addRow(tr("Function"),function);
  12344. ShortHexSpinBox*address= new ShortHexSpinBox;
  12345. layout->addRow(tr("Address"),address);
  12346. QComboBox*format= new QComboBox;
  12347. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12348. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12349. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12350. layout->addRow(tr("Data format"),format);
  12351. QSpinBox*decimals= new QSpinBox;
  12352. decimals->setMinimum(0);
  12353. decimals->setMaximum(9);
  12354. layout->addRow(tr("Decimal places"),decimals);
  12355. QComboBox*unit= new QComboBox;
  12356. unit->addItem("Celsius","C");
  12357. unit->addItem("Fahrenheit","F");
  12358. unit->setCurrentIndex(1);
  12359. layout->addRow(tr("Unit"),unit);
  12360. QLineEdit*column= new QLineEdit;
  12361. layout->addRow(tr("Column name"),column);
  12362. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12363. layout->addRow(hidden);
  12364. /*771:*/
  12365. #line 16335 "./typica.w"
  12366. QDomElement referenceElement=
  12367. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12368. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12369. QDomElement node;
  12370. /*:771*/
  12371. #line 198 "./modbus.w"
  12372. for(int i= 0;i<configData.size();i++)
  12373. {
  12374. node= configData.at(i).toElement();
  12375. if(node.attribute("name")=="station")
  12376. {
  12377. station->setValue(node.attribute("value").toInt());
  12378. }
  12379. else if(node.attribute("name")=="function")
  12380. {
  12381. function->setCurrentIndex(function->findText(node.attribute("value")));
  12382. }
  12383. else if(node.attribute("name")=="address")
  12384. {
  12385. address->setValue(node.attribute("value").toInt());
  12386. }
  12387. else if(node.attribute("name")=="format")
  12388. {
  12389. format->setCurrentIndex(format->findData(node.attribute("value")));
  12390. }
  12391. else if(node.attribute("name")=="decimals")
  12392. {
  12393. decimals->setValue(node.attribute("value").toInt());
  12394. }
  12395. else if(node.attribute("name")=="unit")
  12396. {
  12397. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12398. }
  12399. else if(node.attribute("name")=="column")
  12400. {
  12401. column->setText(node.attribute("value"));
  12402. }
  12403. else if(node.attribute("name")=="hidden")
  12404. {
  12405. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12406. }
  12407. }
  12408. updateStation(station->value());
  12409. updateFunction(function->currentIndex());
  12410. updateAddress(address->value());
  12411. updateFormat(format->currentIndex());
  12412. updateDecimals(decimals->value());
  12413. updateUnit(unit->currentIndex());
  12414. updateColumnName(column->text());
  12415. updateHidden(hidden->isChecked());
  12416. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12417. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12418. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12419. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12420. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12421. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12422. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12423. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12424. setLayout(layout);
  12425. }
  12426. void ModbusNGInputConfWidget::updateStation(int value)
  12427. {
  12428. updateAttribute("station",QString("%1").arg(value));
  12429. }
  12430. void ModbusNGInputConfWidget::updateFunction(int value)
  12431. {
  12432. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12433. }
  12434. void ModbusNGInputConfWidget::updateAddress(int value)
  12435. {
  12436. updateAttribute("address",QString("%1").arg(value));
  12437. }
  12438. void ModbusNGInputConfWidget::updateFormat(int value)
  12439. {
  12440. switch(value)
  12441. {
  12442. case 0:
  12443. updateAttribute("format","16fixedint");
  12444. break;
  12445. case 1:
  12446. updateAttribute("format","32floathl");
  12447. break;
  12448. case 2:
  12449. updateAttribute("format","32floatlh");
  12450. break;
  12451. }
  12452. }
  12453. void ModbusNGInputConfWidget::updateDecimals(int value)
  12454. {
  12455. updateAttribute("decimals",QString("%1").arg(value));
  12456. }
  12457. void ModbusNGInputConfWidget::updateUnit(int value)
  12458. {
  12459. switch(value)
  12460. {
  12461. case 0:
  12462. updateAttribute("unit","C");
  12463. break;
  12464. case 1:
  12465. updateAttribute("unit","F");
  12466. break;
  12467. }
  12468. }
  12469. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  12470. {
  12471. updateAttribute("column",value);
  12472. }
  12473. void ModbusNGInputConfWidget::updateHidden(bool value)
  12474. {
  12475. updateAttribute("hidden",value?"true":"false");
  12476. }
  12477. /*:869*//*874:*/
  12478. #line 393 "./modbus.w"
  12479. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  12480. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  12481. scanPosition(0)
  12482. {
  12483. QDomElement portReferenceElement=
  12484. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12485. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  12486. QDomElement node;
  12487. QVariantMap attributes;
  12488. for(int i= 0;i<portConfigData.size();i++)
  12489. {
  12490. node= portConfigData.at(i).toElement();
  12491. attributes.insert(node.attribute("name"),node.attribute("value"));
  12492. }
  12493. port= new QextSerialPort(attributes.value("port").toString(),
  12494. QextSerialPort::EventDriven);
  12495. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  12496. port->setDataBits(DATA_8);
  12497. port->setParity((ParityType)attributes.value("parity").toInt());
  12498. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  12499. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  12500. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  12501. messageDelayTimer->setSingleShot(true);
  12502. commTimeout->setSingleShot(true);
  12503. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  12504. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  12505. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  12506. port->open(QIODevice::ReadWrite);
  12507. for(int i= 0;i<model->rowCount(index);i++)
  12508. {
  12509. QModelIndex channelIndex= model->index(i,0,index);
  12510. QDomElement channelReferenceElement=
  12511. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12512. QDomNodeList channelConfigData=
  12513. channelReferenceElement.elementsByTagName("attribute");
  12514. QDomElement channelNode;
  12515. QVariantMap channelAttributes;
  12516. for(int j= 0;j<channelConfigData.size();j++)
  12517. {
  12518. channelNode= channelConfigData.at(j).toElement();
  12519. channelAttributes.insert(channelNode.attribute("name"),
  12520. channelNode.attribute("value"));
  12521. }
  12522. ModbusScanItem scanItem;
  12523. QString format= channelAttributes.value("format").toString();
  12524. if(format=="16fixedint")
  12525. {
  12526. scanItem.format= Int16;
  12527. }
  12528. else if(format=="32floathl")
  12529. {
  12530. scanItem.format= FloatHL;
  12531. }
  12532. else if(format=="32floatlh")
  12533. {
  12534. scanItem.format= FloatLH;
  12535. }
  12536. scanItem.request.append((char)channelAttributes.value("station").toInt());
  12537. scanItem.request.append((char)channelAttributes.value("function").toInt());
  12538. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  12539. char*startAddressBytes= (char*)&startAddress;
  12540. scanItem.request.append(startAddressBytes[1]);
  12541. scanItem.request.append(startAddressBytes[0]);
  12542. scanItem.request.append((char)0x00);
  12543. if(scanItem.format==Int16)
  12544. {
  12545. scanItem.request.append((char)0x01);
  12546. }
  12547. else
  12548. {
  12549. scanItem.request.append((char)0x02);
  12550. }
  12551. quint16 crc= calculateCRC(scanItem.request);
  12552. char*crcBytes= (char*)&crc;
  12553. scanItem.request.append(crcBytes[0]);
  12554. scanItem.request.append(crcBytes[1]);
  12555. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  12556. if(channelAttributes.value("unit").toString()=="C")
  12557. {
  12558. scanItem.unit= Units::Celsius;
  12559. }
  12560. else
  12561. {
  12562. scanItem.unit= Units::Fahrenheit;
  12563. }
  12564. scanList.append(scanItem);
  12565. channels.append(new Channel);
  12566. channelNames.append(channelAttributes.value("column").toString());
  12567. hiddenStates.append(
  12568. channelAttributes.value("hidden").toString()=="true"?true:false);
  12569. channelLabels.append(model->data(channelIndex,0).toString());
  12570. }
  12571. messageDelayTimer->start();
  12572. }
  12573. ModbusNG::~ModbusNG()
  12574. {
  12575. commTimeout->stop();
  12576. messageDelayTimer->stop();
  12577. port->close();
  12578. }
  12579. void ModbusNG::sendNextMessage()
  12580. {
  12581. if(scanList.length()> 0)
  12582. {
  12583. port->write(scanList.at(scanPosition).request);
  12584. commTimeout->start(2000);
  12585. messageDelayTimer->start(delayTime);
  12586. }
  12587. }
  12588. void ModbusNG::timeout()
  12589. {
  12590. qDebug()<<"Communications timeout.";
  12591. messageDelayTimer->start();
  12592. }
  12593. void ModbusNG::dataAvailable()
  12594. {
  12595. if(messageDelayTimer->isActive())
  12596. {
  12597. messageDelayTimer->stop();
  12598. }
  12599. responseBuffer.append(port->readAll());
  12600. if(responseBuffer.size()<5)
  12601. {
  12602. return;
  12603. }
  12604. if(responseBuffer.size()<5+responseBuffer.at(2))
  12605. {
  12606. return;
  12607. }
  12608. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  12609. commTimeout->stop();
  12610. if(calculateCRC(responseBuffer)==0)
  12611. {
  12612. quint16 intresponse;
  12613. float floatresponse;
  12614. char*ibytes= (char*)&intresponse;
  12615. char*fbytes= (char*)&floatresponse;
  12616. double output;
  12617. switch(scanList.at(scanPosition).format)
  12618. {
  12619. case Int16:
  12620. ibytes[0]= responseBuffer.at(4);
  12621. ibytes[1]= responseBuffer.at(3);
  12622. output= intresponse;
  12623. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  12624. {
  12625. output/= 10;
  12626. }
  12627. break;
  12628. case FloatHL:
  12629. fbytes[0]= responseBuffer.at(4);
  12630. fbytes[1]= responseBuffer.at(3);
  12631. fbytes[2]= responseBuffer.at(6);
  12632. fbytes[3]= responseBuffer.at(5);
  12633. output= floatresponse;
  12634. break;
  12635. case FloatLH:
  12636. fbytes[0]= responseBuffer.at(6);
  12637. fbytes[1]= responseBuffer.at(5);
  12638. fbytes[2]= responseBuffer.at(4);
  12639. fbytes[3]= responseBuffer.at(3);
  12640. output= floatresponse;
  12641. break;
  12642. }
  12643. if(scanList.at(scanPosition).unit==Units::Celsius)
  12644. {
  12645. output= output*9.0/5.0+32.0;
  12646. }
  12647. scanList.at(scanPosition).lastValue= output;
  12648. }
  12649. else
  12650. {
  12651. qDebug()<<"CRC failed";
  12652. }
  12653. scanPosition= (scanPosition+1)%scanList.size();
  12654. if(scanPosition==0)
  12655. {
  12656. QTime time= QTime::currentTime();
  12657. for(int i= 0;i<scanList.size();i++)
  12658. {
  12659. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  12660. }
  12661. }
  12662. responseBuffer.clear();
  12663. messageDelayTimer->start(delayTime);
  12664. }
  12665. quint16 ModbusNG::calculateCRC(QByteArray data)
  12666. {
  12667. quint16 retval= 0xFFFF;
  12668. int i= 0;
  12669. while(i<data.size())
  12670. {
  12671. retval^= 0x00FF&(quint16)data.at(i);
  12672. for(int j= 0;j<8;j++)
  12673. {
  12674. if(retval&1)
  12675. {
  12676. retval= (retval>>1)^0xA001;
  12677. }
  12678. else
  12679. {
  12680. retval>>= 1;
  12681. }
  12682. }
  12683. i++;
  12684. }
  12685. return retval;
  12686. }
  12687. int ModbusNG::channelCount()
  12688. {
  12689. return channels.size();
  12690. }
  12691. Channel*ModbusNG::getChannel(int channel)
  12692. {
  12693. return channels.at(channel);
  12694. }
  12695. QString ModbusNG::channelColumnName(int channel)
  12696. {
  12697. return channelNames.at(channel);
  12698. }
  12699. QString ModbusNG::channelIndicatorText(int channel)
  12700. {
  12701. return channelLabels.at(channel);
  12702. }
  12703. bool ModbusNG::isChannelHidden(int channel)
  12704. {
  12705. return hiddenStates.at(channel);
  12706. }
  12707. /*:874*/
  12708. #line 612 "./typica.w"
  12709. /*:4*//*250:*/
  12710. #line 5953 "./typica.w"
  12711. /*247:*/
  12712. #line 5916 "./typica.w"
  12713. void ScriptValidator::fixup(QString&input)const
  12714. {
  12715. QScriptEngine*engine= AppInstance->engine;
  12716. engine->pushContext();
  12717. input= engine->evaluate(input).toString();
  12718. engine->popContext();
  12719. }
  12720. /*:247*//*248:*/
  12721. #line 5929 "./typica.w"
  12722. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  12723. {
  12724. if(v)
  12725. {
  12726. if(v->validate(input,pos)==QValidator::Acceptable)
  12727. {
  12728. return QValidator::Acceptable;
  12729. }
  12730. }
  12731. return QValidator::Intermediate;
  12732. }
  12733. /*:248*//*249:*/
  12734. #line 5944 "./typica.w"
  12735. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  12736. :QValidator(parent),v(validator)
  12737. {
  12738. }
  12739. /*:249*/
  12740. #line 5954 "./typica.w"
  12741. /*:250*//*845:*/
  12742. #line 60 "./advancedsettings.w"
  12743. /*843:*/
  12744. #line 26 "./advancedsettings.w"
  12745. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  12746. {
  12747. QSettings settings;
  12748. QFormLayout*layout= new QFormLayout;
  12749. QCheckBox*logDiagnostics= new QCheckBox;
  12750. logDiagnostics->setCheckState(
  12751. settings.value("settings/advanced/logging",false).toBool()?
  12752. Qt::Checked:Qt::Unchecked);
  12753. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  12754. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  12755. setLayout(layout);
  12756. }
  12757. /*:843*//*844:*/
  12758. #line 43 "./advancedsettings.w"
  12759. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  12760. {
  12761. QSettings settings;
  12762. settings.setValue("settings/advanced/logging",enabled);
  12763. if(enabled)
  12764. {
  12765. qInstallMsgHandler(messageFileOutput);
  12766. }
  12767. else
  12768. {
  12769. qInstallMsgHandler(0);
  12770. }
  12771. }
  12772. /*:844*/
  12773. #line 61 "./advancedsettings.w"
  12774. #line 18099 "./typica.w"
  12775. /*:845*//*904:*/
  12776. #line 639 "./unsupportedserial.w"
  12777. /*879:*/
  12778. #line 58 "./unsupportedserial.w"
  12779. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  12780. const QModelIndex&index)
  12781. :BasicDeviceConfigurationWidget(model,index),
  12782. deviceSettingsModel(new SaltModel(2)),
  12783. scriptEditor(new QTextEdit)
  12784. {
  12785. scriptEditor->setTabStopWidth(20);
  12786. QVBoxLayout*dummyLayout= new QVBoxLayout;
  12787. QTabWidget*central= new QTabWidget;
  12788. QWidget*deviceConfigurationWidget= new QWidget;
  12789. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  12790. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12791. deviceConfigurationLayout->addWidget(addChannelButton);
  12792. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12793. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  12794. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  12795. QTableView*deviceSettingsView= new QTableView;
  12796. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  12797. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  12798. deviceSettingsView->setModel(deviceSettingsModel);
  12799. deviceConfigurationLayout->addWidget(deviceSettingsView);
  12800. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  12801. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  12802. central->addTab(scriptEditor,tr("Script"));
  12803. dummyLayout->addWidget(central);
  12804. /*771:*/
  12805. #line 16335 "./typica.w"
  12806. QDomElement referenceElement=
  12807. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12808. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12809. QDomElement node;
  12810. /*:771*/
  12811. #line 86 "./unsupportedserial.w"
  12812. for(int i= 0;i<configData.size();i++)
  12813. {
  12814. node= configData.at(i).toElement();
  12815. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12816. {
  12817. int column= 0;
  12818. if(node.attribute("name")=="values")
  12819. {
  12820. column= 1;
  12821. }
  12822. QString data= node.attribute("value");
  12823. if(data.length()> 3)
  12824. {
  12825. data.chop(2);
  12826. data= data.remove(0,2);
  12827. }
  12828. QStringList keyList= data.split(", ");
  12829. for(int j= 0;j<keyList.size();j++)
  12830. {
  12831. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12832. QVariant(keyList.at(j)),
  12833. Qt::EditRole);
  12834. }
  12835. }
  12836. else if(node.attribute("name")=="script")
  12837. {
  12838. scriptEditor->setPlainText(node.attribute("value"));
  12839. }
  12840. }
  12841. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12842. this,SLOT(updateConfiguration()));
  12843. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  12844. setLayout(dummyLayout);
  12845. }
  12846. /*:879*//*880:*/
  12847. #line 131 "./unsupportedserial.w"
  12848. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  12849. {
  12850. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12851. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12852. }
  12853. /*:880*//*881:*/
  12854. #line 144 "./unsupportedserial.w"
  12855. void UnsupportedSerialDeviceConfWidget::saveScript()
  12856. {
  12857. updateAttribute("script",scriptEditor->toPlainText());
  12858. }
  12859. /*:881*//*882:*/
  12860. #line 155 "./unsupportedserial.w"
  12861. void UnsupportedSerialDeviceConfWidget::addChannel()
  12862. {
  12863. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  12864. }
  12865. /*:882*//*884:*/
  12866. #line 183 "./unsupportedserial.w"
  12867. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  12868. const QModelIndex&index)
  12869. :BasicDeviceConfigurationWidget(model,index),
  12870. channelSettingsModel(new SaltModel(2))
  12871. {
  12872. QFormLayout*layout= new QFormLayout;
  12873. QLineEdit*columnName= new QLineEdit;
  12874. layout->addRow(tr("Column Name:"),columnName);
  12875. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  12876. layout->addRow(hideSeries);
  12877. QTableView*channelSettings= new QTableView;
  12878. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  12879. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  12880. channelSettings->setModel(channelSettingsModel);
  12881. layout->addRow(channelSettings);
  12882. setLayout(layout);
  12883. /*771:*/
  12884. #line 16335 "./typica.w"
  12885. QDomElement referenceElement=
  12886. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12887. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12888. QDomElement node;
  12889. /*:771*/
  12890. #line 200 "./unsupportedserial.w"
  12891. for(int i= 0;i<configData.size();i++)
  12892. {
  12893. node= configData.at(i).toElement();
  12894. if(node.attribute("name")=="columnname")
  12895. {
  12896. columnName->setText(node.attribute("value"));
  12897. }
  12898. else if(node.attribute("name")=="hidden")
  12899. {
  12900. hideSeries->setChecked(node.attribute("value")=="true");
  12901. }
  12902. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12903. {
  12904. int column= 0;
  12905. if(node.attribute("name")=="values")
  12906. {
  12907. column= 1;
  12908. }
  12909. QString data= node.attribute("value");
  12910. if(data.length()> 3)
  12911. {
  12912. data.chop(2);
  12913. data= data.remove(0,2);
  12914. }
  12915. QStringList keyList= data.split(", ");
  12916. for(int j= 0;j<keyList.size();j++)
  12917. {
  12918. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  12919. QVariant(keyList.at(j)),
  12920. Qt::EditRole);
  12921. }
  12922. }
  12923. }
  12924. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12925. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12926. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  12927. this,SLOT(updateConfiguration()));
  12928. }
  12929. /*:884*//*885:*/
  12930. #line 244 "./unsupportedserial.w"
  12931. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  12932. {
  12933. updateAttribute("columnname",value);
  12934. }
  12935. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  12936. {
  12937. updateAttribute("hidden",hidden?"true":"false");
  12938. }
  12939. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  12940. {
  12941. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  12942. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  12943. }
  12944. /*:885*/
  12945. #line 640 "./unsupportedserial.w"
  12946. /*892:*/
  12947. #line 371 "./unsupportedserial.w"
  12948. void JavaScriptDevice::start()
  12949. {
  12950. QScriptValue object= scriptengine->newQObject(this);
  12951. /*893:*/
  12952. #line 390 "./unsupportedserial.w"
  12953. QScriptValue settingsObject= scriptengine->newObject();
  12954. QVariantMap::const_iterator i= deviceSettings.constBegin();
  12955. while(i!=deviceSettings.constEnd())
  12956. {
  12957. settingsObject.setProperty(i.key(),i.value().toString());
  12958. i++;
  12959. }
  12960. object.setProperty("settings",settingsObject);
  12961. /*:893*/
  12962. #line 375 "./unsupportedserial.w"
  12963. /*894:*/
  12964. #line 405 "./unsupportedserial.w"
  12965. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  12966. for(int i= 0;i<channelCount();i++)
  12967. {
  12968. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  12969. QScriptValue channelSettingsObject= scriptengine->newObject();
  12970. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  12971. while(j!=channelSettings.at(i).constEnd())
  12972. {
  12973. channelSettingsObject.setProperty(j.key(),j.value().toString());
  12974. j++;
  12975. }
  12976. channelObject.setProperty("settings",channelSettingsObject);
  12977. channelsArray.setProperty(i,channelObject);
  12978. }
  12979. object.setProperty("channels",channelsArray);
  12980. /*:894*/
  12981. #line 376 "./unsupportedserial.w"
  12982. QScriptContext*context= scriptengine->currentContext();
  12983. QScriptValue oldThis= context->thisObject();
  12984. context->setThisObject(object);
  12985. QScriptValue result= scriptengine->evaluate(deviceScript);
  12986. QScriptEngine*engine= scriptengine;
  12987. /*192:*/
  12988. #line 4447 "./typica.w"
  12989. if(engine->hasUncaughtException())
  12990. {
  12991. int line= engine->uncaughtExceptionLineNumber();
  12992. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  12993. result.toString();
  12994. QString trace;
  12995. foreach(trace,engine->uncaughtExceptionBacktrace())
  12996. {
  12997. qDebug()<<trace;
  12998. }
  12999. }
  13000. /*:192*/
  13001. #line 382 "./unsupportedserial.w"
  13002. context->setThisObject(oldThis);
  13003. }
  13004. /*:892*//*897:*/
  13005. #line 446 "./unsupportedserial.w"
  13006. void JavaScriptDevice::stop()
  13007. {
  13008. emit deviceStopRequested();
  13009. }
  13010. /*:897*//*898:*/
  13011. #line 459 "./unsupportedserial.w"
  13012. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13013. QScriptEngine*engine):
  13014. QObject(NULL),scriptengine(engine)
  13015. {
  13016. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13017. QDomElement deviceReferenceElement=
  13018. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13019. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13020. QDomElement node;
  13021. QStringList deviceKeys;
  13022. QStringList deviceValues;
  13023. for(int i= 0;i<deviceConfigData.size();i++)
  13024. {
  13025. node= deviceConfigData.at(i).toElement();
  13026. if(node.attribute("name")=="keys")
  13027. {
  13028. QString data= node.attribute("value");
  13029. if(data.length()> 3)
  13030. {
  13031. data.chop(2);
  13032. data= data.remove(0,2);
  13033. }
  13034. deviceKeys= data.split(", ");
  13035. }
  13036. else if(node.attribute("name")=="values")
  13037. {
  13038. QString data= node.attribute("value");
  13039. if(data.length()> 3)
  13040. {
  13041. data.chop(2);
  13042. data= data.remove(0,2);
  13043. }
  13044. deviceValues= data.split(", ");
  13045. }
  13046. else if(node.attribute("name")=="script")
  13047. {
  13048. deviceScript= node.attribute("value");
  13049. }
  13050. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13051. }
  13052. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13053. {
  13054. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13055. }
  13056. if(model->hasChildren(index))
  13057. {
  13058. for(int i= 0;i<model->rowCount(index);i++)
  13059. {
  13060. QModelIndex channelIndex= model->index(i,0,index);
  13061. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13062. channelList.append(new Channel);
  13063. QDomElement channelReferenceElement=
  13064. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13065. QDomNodeList channelConfigData=
  13066. channelReferenceElement.elementsByTagName("attribute");
  13067. QStringList channelKeys;
  13068. QStringList channelValues;
  13069. for(int j= 0;j<channelConfigData.size();j++)
  13070. {
  13071. node= channelConfigData.at(j).toElement();
  13072. if(node.attribute("name")=="keys")
  13073. {
  13074. QString data= node.attribute("value");
  13075. if(data.length()> 3)
  13076. {
  13077. data.chop(2);
  13078. data= data.remove(0,2);
  13079. }
  13080. channelKeys= data.split(", ");
  13081. }
  13082. else if(node.attribute("name")=="values")
  13083. {
  13084. QString data= node.attribute("value");
  13085. if(data.length()> 3)
  13086. {
  13087. data.chop(2);
  13088. data= data.remove(0,2);
  13089. }
  13090. channelValues= data.split(", ");
  13091. }
  13092. else if(node.attribute("name")=="hidden")
  13093. {
  13094. hiddenState.append(node.attribute("value")=="true");
  13095. }
  13096. else if(node.attribute("name")=="columnname")
  13097. {
  13098. columnNames.append(node.attribute("value"));
  13099. }
  13100. }
  13101. QVariantMap cs;
  13102. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13103. {
  13104. cs.insert(channelKeys[j],channelValues[j]);
  13105. }
  13106. channelSettings.append(cs);
  13107. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13108. channelUnits.append(Units::Fahrenheit);
  13109. }
  13110. }
  13111. }
  13112. /*:898*//*899:*/
  13113. #line 564 "./unsupportedserial.w"
  13114. int JavaScriptDevice::channelCount()
  13115. {
  13116. return channelList.length();
  13117. }
  13118. Channel*JavaScriptDevice::getChannel(int channel)
  13119. {
  13120. return channelList.at(channel);
  13121. }
  13122. bool JavaScriptDevice::isChannelHidden(int channel)
  13123. {
  13124. return hiddenState.at(channel);
  13125. }
  13126. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13127. {
  13128. return channelUnits.at(channel);
  13129. }
  13130. QString JavaScriptDevice::channelColumnName(int channel)
  13131. {
  13132. if(channel>=0&&channel<columnNames.length())
  13133. {
  13134. return columnNames.at(channel);
  13135. }
  13136. return QString();
  13137. }
  13138. QString JavaScriptDevice::channelIndicatorText(int channel)
  13139. {
  13140. return indicatorTexts.at(channel);
  13141. }
  13142. /*:899*//*900:*/
  13143. #line 601 "./unsupportedserial.w"
  13144. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13145. {
  13146. annotationTemperatureColumn= tcol;
  13147. }
  13148. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13149. {
  13150. annotationNoteColumn= ncol;
  13151. }
  13152. /*:900*/
  13153. #line 641 "./unsupportedserial.w"
  13154. /*:904*//*930:*/
  13155. #line 444 "./phidgets.w"
  13156. /*914:*/
  13157. #line 31 "./phidgets.w"
  13158. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13159. const QModelIndex&index)
  13160. :BasicDeviceConfigurationWidget(model,index)
  13161. {
  13162. QFormLayout*layout= new QFormLayout;
  13163. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13164. QSpinBox*sampleRate= new QSpinBox;
  13165. sampleRate->setMinimum(40);
  13166. sampleRate->setMaximum(600);
  13167. sampleRate->setSingleStep(40);
  13168. sampleRate->setValue(360);
  13169. /*771:*/
  13170. #line 16335 "./typica.w"
  13171. QDomElement referenceElement=
  13172. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13173. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13174. QDomElement node;
  13175. /*:771*/
  13176. #line 44 "./phidgets.w"
  13177. for(int i= 0;i<configData.size();i++)
  13178. {
  13179. node= configData.at(i).toElement();
  13180. if(node.attribute("name")=="sampleRate")
  13181. {
  13182. sampleRate->setValue(node.attribute("value").toInt());
  13183. }
  13184. }
  13185. updateRate(sampleRate->value());
  13186. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13187. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13188. layout->addRow(addChannelButton);
  13189. layout->addRow(tr("Sample rate:"),sampleRate);
  13190. setLayout(layout);
  13191. }
  13192. /*:914*//*915:*/
  13193. #line 66 "./phidgets.w"
  13194. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13195. {
  13196. insertChildNode(tr("Channel"),"phidgets1048channel");
  13197. }
  13198. /*:915*//*916:*/
  13199. #line 74 "./phidgets.w"
  13200. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13201. {
  13202. updateAttribute("sampleRate",QString("%1").arg(ms));
  13203. }
  13204. /*:916*//*918:*/
  13205. #line 103 "./phidgets.w"
  13206. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13207. DeviceTreeModel*model,const QModelIndex&index)
  13208. :BasicDeviceConfigurationWidget(model,index),
  13209. tcType(new QComboBox)
  13210. {
  13211. QFormLayout*layout= new QFormLayout;
  13212. QLineEdit*columnName= new QLineEdit;
  13213. layout->addRow(tr("Column Name:"),columnName);
  13214. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13215. layout->addRow(hideSeries);
  13216. layout->addRow(tr("Thermocouple Type:"),tcType);
  13217. tcType->addItem("Type K","1");
  13218. tcType->addItem("Type J","2");
  13219. tcType->addItem("Type E","3");
  13220. tcType->addItem("Type T","4");
  13221. QSpinBox*channel= new QSpinBox;
  13222. layout->addRow(tr("Channel:"),channel);
  13223. channel->setMinimum(0);
  13224. channel->setMaximum(3);
  13225. setLayout(layout);
  13226. /*771:*/
  13227. #line 16335 "./typica.w"
  13228. QDomElement referenceElement=
  13229. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13230. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13231. QDomElement node;
  13232. /*:771*/
  13233. #line 124 "./phidgets.w"
  13234. for(int i= 0;i<configData.size();i++)
  13235. {
  13236. node= configData.at(i).toElement();
  13237. if(node.attribute("name")=="columnname")
  13238. {
  13239. columnName->setText(node.attribute("value"));
  13240. }
  13241. else if(node.attribute("name")=="hidden")
  13242. {
  13243. hideSeries->setChecked(node.attribute("value")=="true");
  13244. }
  13245. else if(node.attribute("name")=="tctype")
  13246. {
  13247. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  13248. }
  13249. else if(node.attribute("name")=="channel")
  13250. {
  13251. channel->setValue(node.attribute("value").toInt());
  13252. }
  13253. }
  13254. updateColumnName(columnName->text());
  13255. updateHidden(hideSeries->isChecked());
  13256. updateTC(tcType->currentIndex());
  13257. updateChannel(channel->value());
  13258. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13259. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13260. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  13261. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  13262. }
  13263. /*:918*//*919:*/
  13264. #line 157 "./phidgets.w"
  13265. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  13266. {
  13267. updateAttribute("columnname",value);
  13268. }
  13269. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  13270. {
  13271. updateAttribute("hidden",hidden?"true":"false");
  13272. }
  13273. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  13274. {
  13275. updateAttribute("tctype",tcType->itemData(index).toString());
  13276. }
  13277. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  13278. {
  13279. updateAttribute("channel",QString("%1").arg(channel));
  13280. }
  13281. /*:919*//*923:*/
  13282. #line 246 "./phidgets.w"
  13283. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  13284. :QObject(NULL),driver("phidget21"),device(NULL)
  13285. {
  13286. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13287. QDomElement deviceReferenceElement=
  13288. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13289. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13290. QDomElement node;
  13291. for(int i= 0;i<deviceConfigData.size();i++)
  13292. {
  13293. node= deviceConfigData.at(i).toElement();
  13294. if(node.attribute("name")=="sampleRate")
  13295. {
  13296. sampleTimer.setInterval(node.attribute("value").toInt());
  13297. }
  13298. }
  13299. if(model->hasChildren(index))
  13300. {
  13301. for(int i= 0;i<model->rowCount(index);i++)
  13302. {
  13303. QModelIndex channelIndex= model->index(i,0,index);
  13304. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13305. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13306. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  13307. for(int j= 0;j<channelConfigData.size();j++)
  13308. {
  13309. node= channelConfigData.at(j).toElement();
  13310. if(node.attribute("name")=="channel")
  13311. {
  13312. int channelID= node.attribute("value").toInt();
  13313. channelIndices.append(channelID);
  13314. Channel*channel= new Channel;
  13315. channelList.append(channel);
  13316. channelMap.insert(channelID,channel);
  13317. }
  13318. else if(node.attribute("name")=="hidden")
  13319. {
  13320. hiddenState.append(node.attribute("value")=="true");
  13321. }
  13322. else if(node.attribute("name")=="columnname")
  13323. {
  13324. columnNames.append(node.attribute("value"));
  13325. }
  13326. else if(node.attribute("name")=="tctype")
  13327. {
  13328. tctypes.append(node.attribute("value").toInt());
  13329. }
  13330. }
  13331. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13332. }
  13333. }
  13334. }
  13335. /*:923*//*924:*/
  13336. #line 306 "./phidgets.w"
  13337. int PhidgetsTemperatureSensor::channelCount()
  13338. {
  13339. return channelList.length();
  13340. }
  13341. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  13342. {
  13343. return channelList.at(channel);
  13344. }
  13345. /*:924*//*925:*/
  13346. #line 319 "./phidgets.w"
  13347. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  13348. {
  13349. return hiddenState.at(channel);
  13350. }
  13351. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  13352. {
  13353. if(channel>=0&&channel<columnNames.length())
  13354. {
  13355. return columnNames.at(channel);
  13356. }
  13357. return QString();
  13358. }
  13359. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  13360. {
  13361. if(channel>=0&&channel<indicatorTexts.length())
  13362. {
  13363. return indicatorTexts.at(channel);
  13364. }
  13365. return QString();
  13366. }
  13367. /*:925*//*927:*/
  13368. #line 371 "./phidgets.w"
  13369. void PhidgetsTemperatureSensor::start()
  13370. {
  13371. if(!driver.load())
  13372. {
  13373. driver.setFileName("Phidget21.framework/Phidget21");
  13374. if(!driver.load())
  13375. {
  13376. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  13377. tr("Failed to find phidget21. Please install it."));
  13378. return;
  13379. }
  13380. }
  13381. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  13382. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  13383. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  13384. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  13385. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  13386. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  13387. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  13388. {
  13389. QMessageBox::critical(NULL,tr("Typica: Link error"),
  13390. tr("Failed to link a required symbol in phidget21."));
  13391. return;
  13392. }
  13393. createDevice(&device);
  13394. openDevice(device,-1);
  13395. int error;
  13396. if((error= waitForOpen(device,10000)))
  13397. {
  13398. closeDevice(device);
  13399. deleteDevice(device);
  13400. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  13401. tr("CPhidget_waitForAttachment returns error %n",0,error));
  13402. return;
  13403. }
  13404. for(int i= 0;i<channelIndices.length();i++)
  13405. {
  13406. setTCType(device,channelIndices.at(i),tctypes.at(i));
  13407. }
  13408. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  13409. sampleTimer.start();
  13410. }
  13411. /*:927*//*928:*/
  13412. #line 418 "./phidgets.w"
  13413. void PhidgetsTemperatureSensor::getMeasurements()
  13414. {
  13415. double value= 0.0;
  13416. QTime time= QTime::currentTime();
  13417. foreach(int i,channelIndices)
  13418. {
  13419. getTemperature(device,i,&value);
  13420. Measurement measure(value*9.0/5.0+32.0,time);
  13421. channelMap[i]->input(measure);
  13422. }
  13423. }
  13424. /*:928*//*929:*/
  13425. #line 433 "./phidgets.w"
  13426. void PhidgetsTemperatureSensor::stop()
  13427. {
  13428. sampleTimer.stop();
  13429. closeDevice(device);
  13430. deleteDevice(device);
  13431. driver.unload();
  13432. }
  13433. /*:929*/
  13434. #line 445 "./phidgets.w"
  13435. /*:930*//*944:*/
  13436. #line 19530 "./typica.w"
  13437. /*942:*/
  13438. #line 19492 "./typica.w"
  13439. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  13440. const QModelIndex&index)
  13441. :BasicDeviceConfigurationWidget(model,index)
  13442. {
  13443. QHBoxLayout*layout= new QHBoxLayout;
  13444. QLabel*label= new QLabel(tr("Cooling Time: "));
  13445. QTimeEdit*editor= new QTimeEdit;
  13446. editor->setDisplayFormat("mm:ss");
  13447. /*771:*/
  13448. #line 16335 "./typica.w"
  13449. QDomElement referenceElement=
  13450. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13451. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13452. QDomElement node;
  13453. /*:771*/
  13454. #line 19501 "./typica.w"
  13455. for(int i= 0;i<configData.size();i++)
  13456. {
  13457. node= configData.at(i).toElement();
  13458. if(node.attribute("name")=="reset")
  13459. {
  13460. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  13461. }
  13462. }
  13463. updateResetTime(editor->time());
  13464. connect(editor,SIGNAL(timeChanged(QTime)),
  13465. this,SLOT(updateResetTime(QTime)));
  13466. layout->addWidget(label);
  13467. layout->addWidget(editor);
  13468. setLayout(layout);
  13469. }
  13470. void CoolingTimerConfWidget::updateResetTime(QTime time)
  13471. {
  13472. updateAttribute("reset",time.toString("mm:ss"));
  13473. }
  13474. /*:942*/
  13475. #line 19531 "./typica.w"
  13476. /*:944*//*949:*/
  13477. #line 19789 "./typica.w"
  13478. /*946:*/
  13479. #line 19563 "./typica.w"
  13480. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13481. :BasicDeviceConfigurationWidget(model,index)
  13482. {
  13483. QVBoxLayout*layout= new QVBoxLayout;
  13484. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  13485. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  13486. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  13487. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  13488. QButtonGroup*startOptionGroup= new QButtonGroup;
  13489. startOptionGroup->addButton(startBatchOption,1);
  13490. startOptionGroup->addButton(buttonOption,2);
  13491. startOptionGroup->addButton(thresholdOption,3);
  13492. startBatchOption->setChecked(true);
  13493. QGridLayout*startOptions= new QGridLayout;
  13494. startOptions->addWidget(startBatchOption,0,0);
  13495. startOptions->addWidget(buttonOption,1,0);
  13496. startOptions->addWidget(thresholdOption,2,0);
  13497. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  13498. QLineEdit*buttonTextEdit= new QLineEdit;
  13499. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  13500. buttonTextOptions->addWidget(buttonTextLabel);
  13501. buttonTextOptions->addWidget(buttonTextEdit);
  13502. startOptions->addLayout(buttonTextOptions,1,1);
  13503. QFormLayout*thresholdOptions= new QFormLayout;
  13504. QLineEdit*startColumnName= new QLineEdit;
  13505. QLineEdit*startValue= new QLineEdit;
  13506. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  13507. thresholdOptions->addRow(tr("Value: "),startValue);
  13508. startOptions->addLayout(thresholdOptions,2,1);
  13509. startConfigurationGroup->setLayout(startOptions);
  13510. layout->addWidget(startConfigurationGroup);
  13511. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  13512. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  13513. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  13514. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  13515. QButtonGroup*stopOptionGroup= new QButtonGroup;
  13516. stopOptionGroup->addButton(stopBatchOption,1);
  13517. stopOptionGroup->addButton(stopButtonOption,2);
  13518. stopOptionGroup->addButton(stopThresholdOption,3);
  13519. stopBatchOption->setChecked(true);
  13520. QGridLayout*stopOptions= new QGridLayout;
  13521. stopOptions->addWidget(stopBatchOption,0,0);
  13522. stopOptions->addWidget(stopButtonOption,1,0);
  13523. stopOptions->addWidget(stopThresholdOption,2,0);
  13524. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  13525. QLineEdit*stopButtonEdit= new QLineEdit;
  13526. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  13527. stopButtonTextOptions->addWidget(stopButtonLabel);
  13528. stopButtonTextOptions->addWidget(stopButtonEdit);
  13529. stopOptions->addLayout(stopButtonTextOptions,1,1);
  13530. QLineEdit*stopColumnName= new QLineEdit;
  13531. QLineEdit*stopValue= new QLineEdit;
  13532. QFormLayout*stopThresholdOptions= new QFormLayout;
  13533. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  13534. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  13535. stopOptions->addLayout(stopThresholdOptions,2,1);
  13536. stopConfigurationGroup->setLayout(stopOptions);
  13537. layout->addWidget(stopConfigurationGroup);
  13538. /*771:*/
  13539. #line 16335 "./typica.w"
  13540. QDomElement referenceElement=
  13541. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13542. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13543. QDomElement node;
  13544. /*:771*/
  13545. #line 19625 "./typica.w"
  13546. for(int i= 0;i<configData.size();i++)
  13547. {
  13548. node= configData.at(i).toElement();
  13549. if(node.attribute("name")=="startbuttontext")
  13550. {
  13551. buttonTextEdit->setText(node.attribute("value"));
  13552. }
  13553. else if(node.attribute("name")=="stopbuttontext")
  13554. {
  13555. stopButtonEdit->setText(node.attribute("value"));
  13556. }
  13557. else if(node.attribute("name")=="startcolumnname")
  13558. {
  13559. startColumnName->setText(node.attribute("value"));
  13560. }
  13561. else if(node.attribute("name")=="stopcolumnname")
  13562. {
  13563. stopColumnName->setText(node.attribute("value"));
  13564. }
  13565. else if(node.attribute("name")=="startvalue")
  13566. {
  13567. startValue->setText(node.attribute("value"));
  13568. }
  13569. else if(node.attribute("name")=="stopvalue")
  13570. {
  13571. stopValue->setText(node.attribute("value"));
  13572. }
  13573. else if(node.attribute("name")=="starttrigger")
  13574. {
  13575. if(node.attribute("value")=="batch")
  13576. {
  13577. startBatchOption->setChecked(true);
  13578. }
  13579. else if(node.attribute("value")=="manual")
  13580. {
  13581. buttonOption->setChecked(true);
  13582. }
  13583. else if(node.attribute("value")=="value")
  13584. {
  13585. thresholdOption->setChecked(true);
  13586. }
  13587. }
  13588. else if(node.attribute("name")=="stoptrigger")
  13589. {
  13590. if(node.attribute("value")=="batch")
  13591. {
  13592. stopBatchOption->setChecked(true);
  13593. }
  13594. else if(node.attribute("value")=="manual")
  13595. {
  13596. stopButtonOption->setChecked(true);
  13597. }
  13598. else if(node.attribute("value")=="value")
  13599. {
  13600. stopThresholdOption->setChecked(true);
  13601. }
  13602. }
  13603. }
  13604. updateStartButtonText(buttonTextEdit->text());
  13605. updateStopButtonText(stopButtonEdit->text());
  13606. updateStartColumnName(startColumnName->text());
  13607. updateStopColumnName(stopColumnName->text());
  13608. updateStartValue(startValue->text());
  13609. updateStopValue(stopValue->text());
  13610. updateStartTrigger(startOptionGroup->checkedId());
  13611. updateStopTrigger(stopOptionGroup->checkedId());
  13612. setLayout(layout);
  13613. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  13614. this,SLOT(updateStartButtonText(QString)));
  13615. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  13616. this,SLOT(updateStopButtonText(QString)));
  13617. connect(startColumnName,SIGNAL(textChanged(QString)),
  13618. this,SLOT(updateStartColumnName(QString)));
  13619. connect(stopColumnName,SIGNAL(textChanged(QString)),
  13620. this,SLOT(updateStopColumnName(QString)));
  13621. connect(startValue,SIGNAL(textChanged(QString)),
  13622. this,SLOT(updateStartValue(QString)));
  13623. connect(stopValue,SIGNAL(textChanged(QString)),
  13624. this,SLOT(updateStopValue(QString)));
  13625. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  13626. this,SLOT(updateStartTrigger(int)));
  13627. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  13628. this,SLOT(updateStopTrigger(int)));
  13629. }
  13630. /*:946*//*947:*/
  13631. #line 19715 "./typica.w"
  13632. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  13633. {
  13634. updateAttribute("startbuttontext",text);
  13635. }
  13636. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  13637. {
  13638. updateAttribute("stopbuttontext",text);
  13639. }
  13640. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  13641. {
  13642. updateAttribute("startcolumnname",text);
  13643. }
  13644. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  13645. {
  13646. updateAttribute("stopcolumnname",text);
  13647. }
  13648. void RangeTimerConfWidget::updateStartValue(const QString&text)
  13649. {
  13650. updateAttribute("startvalue",text);
  13651. }
  13652. void RangeTimerConfWidget::updateStopValue(const QString&text)
  13653. {
  13654. updateAttribute("stopvalue",text);
  13655. }
  13656. void RangeTimerConfWidget::updateStartTrigger(int option)
  13657. {
  13658. switch(option)
  13659. {
  13660. case 1:
  13661. updateAttribute("starttrigger","batch");
  13662. break;
  13663. case 2:
  13664. updateAttribute("starttrigger","manual");
  13665. break;
  13666. case 3:
  13667. updateAttribute("starttrigger","value");
  13668. break;
  13669. default:
  13670. break;
  13671. }
  13672. }
  13673. void RangeTimerConfWidget::updateStopTrigger(int option)
  13674. {
  13675. switch(option)
  13676. {
  13677. case 1:
  13678. updateAttribute("stoptrigger","batch");
  13679. break;
  13680. case 2:
  13681. updateAttribute("stoptrigger","manual");
  13682. break;
  13683. case 3:
  13684. updateAttribute("stoptrigger","value");
  13685. break;
  13686. default:
  13687. break;
  13688. }
  13689. }
  13690. /*:947*/
  13691. #line 19790 "./typica.w"
  13692. /*:949*//*954:*/
  13693. #line 19890 "./typica.w"
  13694. /*951:*/
  13695. #line 19814 "./typica.w"
  13696. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  13697. const QModelIndex&index)
  13698. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  13699. {
  13700. QFormLayout*layout= new QFormLayout;
  13701. QLineEdit*trigger= new QLineEdit;
  13702. layout->addRow(tr("Trigger column name:"),trigger);
  13703. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  13704. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  13705. QTableView*rangeTable= new QTableView;
  13706. rangeTable->setModel(tablemodel);
  13707. layout->addRow(tr("Range data:"),rangeTable);
  13708. /*771:*/
  13709. #line 16335 "./typica.w"
  13710. QDomElement referenceElement=
  13711. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13712. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13713. QDomElement node;
  13714. /*:771*/
  13715. #line 19827 "./typica.w"
  13716. for(int i= 0;i<configData.size();i++)
  13717. {
  13718. node= configData.at(i).toElement();
  13719. if(node.attribute("name")=="trigger")
  13720. {
  13721. trigger->setText(node.attribute("value"));
  13722. }
  13723. else if(node.attribute("name")=="rangenames")
  13724. {
  13725. QString data= node.attribute("value");
  13726. if(data.length()> 3)
  13727. {
  13728. data.chop(2);
  13729. data= data.remove(0,2);
  13730. }
  13731. QStringList itemList= data.split(", ");
  13732. for(int j= 0;j<itemList.size();j++)
  13733. {
  13734. QString item= itemList.at(j);
  13735. item.chop(1);
  13736. item= item.remove(0,1);
  13737. tablemodel->setData(tablemodel->index(j,0),
  13738. QVariant(item),Qt::DisplayRole);
  13739. }
  13740. }
  13741. else if(node.attribute("name")=="endtemps")
  13742. {
  13743. /*937:*/
  13744. #line 19422 "./typica.w"
  13745. QString data= node.attribute("value");
  13746. if(data.length()> 3)
  13747. {
  13748. data.chop(2);
  13749. data= data.remove(0,2);
  13750. }
  13751. QStringList itemList= data.split(",");
  13752. /*:937*/
  13753. #line 19855 "./typica.w"
  13754. int column= 1;
  13755. /*938:*/
  13756. #line 19434 "./typica.w"
  13757. for(int j= 0;j<itemList.size();j++)
  13758. {
  13759. tablemodel->setData(tablemodel->index(j,column),
  13760. QVariant(itemList.at(j).toDouble()),
  13761. Qt::DisplayRole);
  13762. }
  13763. /*:938*/
  13764. #line 19857 "./typica.w"
  13765. }
  13766. }
  13767. updateColumnName(trigger->text());
  13768. updateRangeData();
  13769. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13770. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  13771. setLayout(layout);
  13772. }
  13773. /*:951*//*952:*/
  13774. #line 19871 "./typica.w"
  13775. void MultiRangeTimerConfWidget::updateRangeData()
  13776. {
  13777. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  13778. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  13779. }
  13780. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  13781. {
  13782. updateAttribute("trigger",text);
  13783. }
  13784. /*:952*/
  13785. #line 19891 "./typica.w"
  13786. /*:954*//*972:*/
  13787. #line 265 "./rate.w"
  13788. /*968:*/
  13789. #line 191 "./rate.w"
  13790. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13791. :BasicDeviceConfigurationWidget(model,index)
  13792. {
  13793. QFormLayout*layout= new QFormLayout;
  13794. QLineEdit*column= new QLineEdit;
  13795. layout->addRow(tr("Primary series column name:"),column);
  13796. QSpinBox*cacheTime= new QSpinBox;
  13797. cacheTime->setMinimum(0);
  13798. cacheTime->setMaximum(300);
  13799. layout->addRow(tr("Cache time:"),cacheTime);
  13800. QSpinBox*scaleTime= new QSpinBox;
  13801. scaleTime->setMinimum(1);
  13802. scaleTime->setMaximum(300);
  13803. layout->addRow(tr("Scale time:"),scaleTime);
  13804. /*771:*/
  13805. #line 16335 "./typica.w"
  13806. QDomElement referenceElement=
  13807. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13808. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13809. QDomElement node;
  13810. /*:771*/
  13811. #line 206 "./rate.w"
  13812. for(int i= 0;i<configData.size();i++)
  13813. {
  13814. node= configData.at(i).toElement();
  13815. if(node.attribute("name")=="column")
  13816. {
  13817. column->setText(node.attribute("value"));
  13818. }
  13819. else if(node.attribute("name")=="cache")
  13820. {
  13821. cacheTime->setValue(node.attribute("value").toInt());
  13822. }
  13823. else if(node.attribute("name")=="scale")
  13824. {
  13825. scaleTime->setValue(node.attribute("value").toInt());
  13826. }
  13827. }
  13828. updateColumn(column->text());
  13829. updateCacheTime(cacheTime->text());
  13830. updateScaleTime(scaleTime->text());
  13831. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  13832. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  13833. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  13834. setLayout(layout);
  13835. }
  13836. /*:968*//*969:*/
  13837. #line 235 "./rate.w"
  13838. void RateOfChangeConfWidget::updateColumn(const QString&column)
  13839. {
  13840. updateAttribute("column",column);
  13841. }
  13842. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  13843. {
  13844. updateAttribute("cache",seconds);
  13845. }
  13846. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  13847. {
  13848. updateAttribute("scale",seconds);
  13849. }
  13850. /*:969*/
  13851. #line 266 "./rate.w"
  13852. #line 19983 "./typica.w"
  13853. #line 1 "./dataqsdk.w"
  13854. /*:972*/
  13855. #line 529 "./typica.w"
  13856. /*8:*/
  13857. #line 673 "./typica.w"
  13858. template<class TYPE> TYPE getself(QScriptContext*context)
  13859. {
  13860. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  13861. return self;
  13862. }
  13863. template<> QTime getself(QScriptContext*context)
  13864. {
  13865. QTime self= context->thisObject().toVariant().toTime();
  13866. return self;
  13867. }
  13868. template<> QByteArray getself(QScriptContext*context)
  13869. {
  13870. QByteArray self= context->thisObject().toVariant().toByteArray();
  13871. return self;
  13872. }
  13873. template<> SqlQueryConnection*getself(QScriptContext*context)
  13874. {
  13875. SqlQueryConnection*self=
  13876. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  13877. return self;
  13878. }
  13879. template<> QXmlQuery*getself(QScriptContext*context)
  13880. {
  13881. QXmlQuery*self=
  13882. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  13883. return self;
  13884. }
  13885. template<> QXmlStreamWriter*getself(QScriptContext*context)
  13886. {
  13887. QXmlStreamWriter*self=
  13888. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  13889. return self;
  13890. }
  13891. template<> QXmlStreamReader*getself(QScriptContext*context)
  13892. {
  13893. QXmlStreamReader*self=
  13894. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  13895. return self;
  13896. }
  13897. /*:8*//*9:*/
  13898. #line 724 "./typica.w"
  13899. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  13900. {
  13901. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  13902. return argument;
  13903. }
  13904. template<> QString argument(int arg,QScriptContext*context)
  13905. {
  13906. return context->argument(arg).toString();
  13907. }
  13908. template<> QVariant argument(int arg,QScriptContext*context)
  13909. {
  13910. return context->argument(arg).toVariant();
  13911. }
  13912. template<> int argument(int arg,QScriptContext*context)
  13913. {
  13914. return context->argument(arg).toInt32();
  13915. }
  13916. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  13917. {
  13918. return(SqlQueryConnection*)
  13919. qscriptvalue_cast<void*> (context->argument(arg));
  13920. }
  13921. template<> QModelIndex argument(int arg,QScriptContext*context)
  13922. {
  13923. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  13924. }
  13925. template<> double argument(int arg,QScriptContext*context)
  13926. {
  13927. return(double)(context->argument(arg).toNumber());
  13928. }
  13929. template<> Units::Unit argument(int arg,QScriptContext*context)
  13930. {
  13931. return(Units::Unit)(context->argument(arg).toInt32());
  13932. }
  13933. template<> QByteArray argument(int arg,QScriptContext*context)
  13934. {
  13935. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  13936. }
  13937. /*:9*//*13:*/
  13938. #line 816 "./typica.w"
  13939. void setQObjectProperties(QScriptValue,QScriptEngine*)
  13940. {
  13941. }
  13942. /*:13*//*15:*/
  13943. #line 830 "./typica.w"
  13944. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  13945. {
  13946. }
  13947. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  13948. {
  13949. }
  13950. /*:15*//*18:*/
  13951. #line 869 "./typica.w"
  13952. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  13953. {
  13954. QScriptValue object= engine->newQObject(new QWidget);
  13955. setQWidgetProperties(object,engine);
  13956. return object;
  13957. }
  13958. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  13959. {
  13960. setQObjectProperties(value,engine);
  13961. setQPaintDeviceProperties(value,engine);
  13962. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  13963. value.setProperty("activateWindow",
  13964. engine->newFunction(QWidget_activateWindow));
  13965. }
  13966. /*:18*//*19:*/
  13967. #line 891 "./typica.w"
  13968. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  13969. {
  13970. if(context->argumentCount()==1)
  13971. {
  13972. QWidget*self= getself<QWidget*> (context);
  13973. QLayout*layout= argument<QLayout*> (0,context);
  13974. if(layout)
  13975. {
  13976. self->setLayout(layout);
  13977. }
  13978. else
  13979. {
  13980. context->throwError("Incorrect argument type passed to "
  13981. "QWidget::setLayout(). This method requires "
  13982. "a QLayout.");
  13983. }
  13984. }
  13985. else
  13986. {
  13987. context->throwError("Incorrect number of arguments passed to "
  13988. "QWidget::setLayout(). This method takes one "
  13989. "QLayout as an argument.");
  13990. }
  13991. return QScriptValue();
  13992. }
  13993. QScriptValue QWidget_activateWindow(QScriptContext*context,
  13994. QScriptEngine*)
  13995. {
  13996. QWidget*self= getself<QWidget*> (context);
  13997. self->activateWindow();
  13998. return QScriptValue();
  13999. }
  14000. /*:19*//*22:*/
  14001. #line 953 "./typica.w"
  14002. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  14003. {
  14004. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  14005. argument<QString> (0,context),
  14006. argument<QString> (1,context),
  14007. QMessageBox::Ok|QMessageBox::Cancel);
  14008. if(selection==QMessageBox::Ok){
  14009. return QScriptValue(true);
  14010. }
  14011. return QScriptValue(false);
  14012. }
  14013. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  14014. {
  14015. QMessageBox::critical(NULL,argument<QString> (0,context),
  14016. argument<QString> (1,context));
  14017. return QScriptValue();
  14018. }
  14019. /*:22*//*24:*/
  14020. #line 1020 "./typica.w"
  14021. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  14022. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  14023. {
  14024. }
  14025. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  14026. {
  14027. QSettings settings;
  14028. settings.beginGroup(key);
  14029. settings.setValue("pos",pos());
  14030. settings.setValue("size",size());
  14031. settings.endGroup();
  14032. }
  14033. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  14034. {
  14035. QSettings settings;
  14036. settings.beginGroup(key);
  14037. if(settings.contains("size"))
  14038. {
  14039. resize(settings.value("size").toSize());
  14040. }
  14041. if(settings.contains("pos"))
  14042. {
  14043. move(settings.value("pos").toPoint());
  14044. }
  14045. settings.endGroup();
  14046. }
  14047. void ScriptQMainWindow::displayStatus(const QString&message)
  14048. {
  14049. statusBar()->showMessage(message);
  14050. }
  14051. void ScriptQMainWindow::showEvent(QShowEvent*event)
  14052. {
  14053. if(!event->spontaneous())
  14054. {
  14055. /*29:*/
  14056. #line 1132 "./typica.w"
  14057. QSettings settings;
  14058. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  14059. toByteArray());
  14060. /*:29*/
  14061. #line 1060 "./typica.w"
  14062. event->accept();
  14063. }
  14064. else
  14065. {
  14066. event->ignore();
  14067. }
  14068. }
  14069. void ScriptQMainWindow::show()
  14070. {
  14071. QMainWindow::show();
  14072. }
  14073. /*:24*//*25:*/
  14074. #line 1081 "./typica.w"
  14075. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  14076. {
  14077. if(isWindowModified()){
  14078. /*26:*/
  14079. #line 1095 "./typica.w"
  14080. QMessageBox::StandardButton result;
  14081. result= QMessageBox::warning(this,"Typica",closePrompt(),
  14082. QMessageBox::Ok|QMessageBox::Cancel);
  14083. if(result==QMessageBox::Cancel)
  14084. {
  14085. event->ignore();
  14086. return;
  14087. }
  14088. /*:26*/
  14089. #line 1085 "./typica.w"
  14090. }
  14091. emit aboutToClose();
  14092. /*28:*/
  14093. #line 1126 "./typica.w"
  14094. QSettings settings;
  14095. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  14096. /*:28*/
  14097. #line 1088 "./typica.w"
  14098. event->accept();
  14099. }
  14100. /*:25*//*27:*/
  14101. #line 1107 "./typica.w"
  14102. QString ScriptQMainWindow::closePrompt()
  14103. {
  14104. return cprompt;
  14105. }
  14106. void ScriptQMainWindow::setClosePrompt(QString prompt)
  14107. {
  14108. cprompt= prompt;
  14109. }
  14110. /*:27*//*32:*/
  14111. #line 1160 "./typica.w"
  14112. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  14113. {
  14114. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  14115. setQMainWindowProperties(object,engine);
  14116. return object;
  14117. }
  14118. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  14119. {
  14120. setQWidgetProperties(value,engine);
  14121. value.setProperty("setCentralWidget",
  14122. engine->newFunction(QMainWindow_setCentralWidget));
  14123. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  14124. }
  14125. /*:32*//*33:*/
  14126. #line 1182 "./typica.w"
  14127. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  14128. QScriptEngine*)
  14129. {
  14130. if(context->argumentCount()==1)
  14131. {
  14132. QMainWindow*self= getself<QMainWindow*> (context);
  14133. QWidget*widget= argument<QWidget*> (0,context);
  14134. if(widget)
  14135. {
  14136. self->setCentralWidget(widget);
  14137. }
  14138. else
  14139. {
  14140. context->throwError("Incorrect argument type passed to "
  14141. "QMainWindow::setCentralWidget(). This "
  14142. "method requires a QWidget.");
  14143. }
  14144. }
  14145. else
  14146. {
  14147. context->throwError("Incorrect number of arguments passed to "
  14148. "QMainWindow::setCentralWidget(). This method "
  14149. "takes one QWidget as an argument.");
  14150. }
  14151. return QScriptValue();
  14152. }
  14153. /*:33*//*34:*/
  14154. #line 1216 "./typica.w"
  14155. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  14156. {
  14157. QScriptValue object;
  14158. if(context->argumentCount()==0)
  14159. {
  14160. QMainWindow*self= getself<QMainWindow*> (context);
  14161. QMenuBar*bar= self->menuBar();
  14162. object= engine->newQObject(bar);
  14163. setQMenuBarProperties(object,engine);
  14164. }
  14165. else
  14166. {
  14167. context->throwError("Incorrect number of arguments passed to "
  14168. "QMainWindow::menuBar(). This method takes no "
  14169. "arguments.");
  14170. }
  14171. return object;
  14172. }
  14173. /*:34*//*36:*/
  14174. #line 1246 "./typica.w"
  14175. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  14176. {
  14177. setQWidgetProperties(value,engine);
  14178. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  14179. }
  14180. /*:36*//*37:*/
  14181. #line 1261 "./typica.w"
  14182. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  14183. {
  14184. QScriptValue object;
  14185. if(context->argumentCount()==1)
  14186. {
  14187. QMenuBar*self= getself<QMenuBar*> (context);
  14188. QString title= argument<QString> (0,context);
  14189. object= engine->newQObject(self->addMenu(title));
  14190. setQMenuProperties(object,engine);
  14191. }
  14192. else
  14193. {
  14194. context->throwError("Incorrect number of arguments passed to "
  14195. "QMenuBar::addMenu(). This method takes one "
  14196. "string as an argument.");
  14197. }
  14198. return object;
  14199. }
  14200. /*:37*//*39:*/
  14201. #line 1291 "./typica.w"
  14202. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  14203. {
  14204. setQWidgetProperties(value,engine);
  14205. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  14206. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  14207. }
  14208. /*:39*//*40:*/
  14209. #line 1301 "./typica.w"
  14210. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  14211. {
  14212. if(context->argumentCount()==1)
  14213. {
  14214. QMenu*self= getself<QMenu*> (context);
  14215. QAction*action= argument<QAction*> (0,context);
  14216. if(action)
  14217. {
  14218. self->addAction(action);
  14219. }
  14220. else
  14221. {
  14222. context->throwError("Incorrect argument type passed to "
  14223. "QMenu::addAction(). This method requires a "
  14224. "QAction.");
  14225. }
  14226. }
  14227. else
  14228. {
  14229. context->throwError("Incorrect number of arguments passed to "
  14230. "QMenu::addAction(). This method takes one "
  14231. "QAction as an argument.");
  14232. }
  14233. return QScriptValue();
  14234. }
  14235. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  14236. {
  14237. if(context->argumentCount()==0)
  14238. {
  14239. QMenu*self= getself<QMenu*> (context);
  14240. self->addSeparator();
  14241. }
  14242. else
  14243. {
  14244. context->throwError("Incorrect number of arguments passed to "
  14245. "QMenu::addSeparator(). This method takes no "
  14246. "arguments.");
  14247. }
  14248. return QScriptValue();
  14249. }
  14250. /*:40*//*43:*/
  14251. #line 1363 "./typica.w"
  14252. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  14253. {
  14254. QScriptValue object= engine->newQObject(new QFrame);
  14255. setQFrameProperties(object,engine);
  14256. return object;
  14257. }
  14258. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  14259. {
  14260. setQWidgetProperties(value,engine);
  14261. }
  14262. /*:43*//*46:*/
  14263. #line 1397 "./typica.w"
  14264. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  14265. {
  14266. QString text;
  14267. if(context->argumentCount()==1)
  14268. {
  14269. text= argument<QString> (0,context);
  14270. }
  14271. QScriptValue object= engine->newQObject(new QLabel(text));
  14272. setQLabelProperties(object,engine);
  14273. return object;
  14274. }
  14275. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  14276. {
  14277. setQFrameProperties(value,engine);
  14278. }
  14279. /*:46*//*49:*/
  14280. #line 1439 "./typica.w"
  14281. QScriptValue constructQSvgWidget(QScriptContext*,
  14282. QScriptEngine*engine)
  14283. {
  14284. QScriptValue object= engine->newQObject(new QSvgWidget);
  14285. setQSvgWidgetProperties(object,engine);
  14286. return object;
  14287. }
  14288. /*:49*//*50:*/
  14289. #line 1450 "./typica.w"
  14290. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14291. {
  14292. setQWidgetProperties(value,engine);
  14293. value.setProperty("loadDevice",
  14294. engine->newFunction(QSvgWidget_loadDevice));
  14295. }
  14296. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  14297. {
  14298. if(context->argumentCount()==1)
  14299. {
  14300. QSvgWidget*self= getself<QSvgWidget*> (context);
  14301. QIODevice*device= argument<QIODevice*> (0,context);
  14302. device->reset();
  14303. QByteArray data= device->readAll();
  14304. self->load(data);
  14305. }
  14306. else
  14307. {
  14308. context->throwError("Incorrect number of arguments passed to "
  14309. "QSvgWidget::loadData(). This method takes one "
  14310. "QIODevice as an argument.");
  14311. }
  14312. return QScriptValue();
  14313. }
  14314. /*:50*//*52:*/
  14315. #line 1488 "./typica.w"
  14316. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  14317. QStack<QLayout*> *layoutStack)
  14318. {
  14319. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14320. QSvgWidget*widget= new QSvgWidget;
  14321. layout->addWidget(widget);
  14322. QString id= element.attribute("id");
  14323. if(!id.isEmpty())
  14324. {
  14325. widget->setObjectName(id);
  14326. }
  14327. }
  14328. /*:52*//*55:*/
  14329. #line 1521 "./typica.w"
  14330. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  14331. {
  14332. QScriptValue object= engine->newQObject(new QLineEdit());
  14333. setQLineEditProperties(object,engine);
  14334. return object;
  14335. }
  14336. /*:55*//*56:*/
  14337. #line 1532 "./typica.w"
  14338. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  14339. {
  14340. setQWidgetProperties(value,engine);
  14341. }
  14342. /*:56*//*59:*/
  14343. #line 1568 "./typica.w"
  14344. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  14345. {
  14346. QScriptValue object= engine->newQObject(new QSplitter);
  14347. setQSplitterProperties(object,engine);
  14348. return object;
  14349. }
  14350. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  14351. {
  14352. setQFrameProperties(value,engine);
  14353. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  14354. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  14355. value.setProperty("restoreState",
  14356. engine->newFunction(QSplitter_restoreState));
  14357. value.setProperty("count",engine->newFunction(QSplitter_count));
  14358. }
  14359. /*:59*//*60:*/
  14360. #line 1589 "./typica.w"
  14361. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  14362. {
  14363. if(context->argumentCount()==1)
  14364. {
  14365. QSplitter*self= getself<QSplitter*> (context);
  14366. QWidget*widget= argument<QWidget*> (0,context);
  14367. if(widget)
  14368. {
  14369. self->addWidget(widget);
  14370. }
  14371. else
  14372. {
  14373. context->throwError("Incorrect argument type passed to "
  14374. "QSplitter::addWidget(). This method "
  14375. "requires a QWidget.");
  14376. }
  14377. }
  14378. else
  14379. {
  14380. context->throwError("Incorrect number of arguments passed to "
  14381. "QSplitter::addWidget(). This method takes one "
  14382. "QWidget as an argument.");
  14383. }
  14384. return QScriptValue();
  14385. }
  14386. /*:60*//*61:*/
  14387. #line 1626 "./typica.w"
  14388. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  14389. {
  14390. QSplitter*self= getself<QSplitter*> (context);
  14391. return QScriptValue(self->count());
  14392. }
  14393. /*:61*//*62:*/
  14394. #line 1639 "./typica.w"
  14395. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  14396. {
  14397. if(context->argumentCount()==1)
  14398. {
  14399. QSplitter*self= getself<QSplitter*> (context);
  14400. QString key= argument<QString> (0,context);
  14401. QSettings settings;
  14402. settings.setValue(key,self->saveState());
  14403. }
  14404. else
  14405. {
  14406. context->throwError("Incorrect number of arguments passed to "
  14407. "QSplitter::saveState(). This method takes one "
  14408. "string as an argument.");
  14409. }
  14410. return QScriptValue();
  14411. }
  14412. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  14413. {
  14414. if(context->argumentCount()==1)
  14415. {
  14416. QSplitter*self= getself<QSplitter*> (context);
  14417. QString key= argument<QString> (0,context);
  14418. QSettings settings;
  14419. self->restoreState(settings.value(key).toByteArray());
  14420. }
  14421. else
  14422. {
  14423. context->throwError("Incorrect number of arguments passed to "
  14424. "QSplitter::restoreState(). This method takes "
  14425. "one string as an argument.");
  14426. }
  14427. return QScriptValue();
  14428. }
  14429. /*:62*//*64:*/
  14430. #line 1692 "./typica.w"
  14431. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14432. {
  14433. setQLayoutItemProperties(value,engine);
  14434. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  14435. }
  14436. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14437. {
  14438. if(context->argumentCount()==1)
  14439. {
  14440. QLayout*self= getself<QLayout*> (context);
  14441. QWidget*widget= argument<QWidget*> (0,context);
  14442. if(widget)
  14443. {
  14444. self->addWidget(widget);
  14445. }
  14446. else
  14447. {
  14448. context->throwError("Incorrect argument type passed to "
  14449. "QLayout::addWidget(). This method requires "
  14450. "a QWidget.");
  14451. }
  14452. }
  14453. else
  14454. {
  14455. context->throwError("Incorrect number of arguments passed to "
  14456. "QLayout::addWidget(). This method takes one "
  14457. "QWidget as an argument.");
  14458. }
  14459. return QScriptValue();
  14460. }
  14461. /*:64*//*67:*/
  14462. #line 1759 "./typica.w"
  14463. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  14464. {
  14465. QScriptValue object=
  14466. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  14467. setQBoxLayoutProperties(object,engine);
  14468. return object;
  14469. }
  14470. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14471. {
  14472. setQLayoutProperties(value,engine);
  14473. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  14474. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  14475. }
  14476. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  14477. {
  14478. if(context->argumentCount()> 0&&context->argumentCount()<3)
  14479. {
  14480. QBoxLayout*self= getself<QBoxLayout*> (context);
  14481. QLayout*layout= argument<QLayout*> (0,context);
  14482. int stretch= 0;
  14483. if(context->argumentCount()==2)
  14484. {
  14485. stretch= argument<int> (1,context);
  14486. }
  14487. if(layout)
  14488. {
  14489. self->addLayout(layout,stretch);
  14490. }
  14491. else
  14492. {
  14493. context->throwError("Incorrect argument type passed to "
  14494. "QLayout::addLayout(). This method requires "
  14495. "a QLayout.");
  14496. }
  14497. }
  14498. else
  14499. {
  14500. context->throwError("Incorrect number of arguments passed to "
  14501. "QLayout::addLayout(). This method takes one "
  14502. "QLayout as an argument and optionally one integer.");
  14503. }
  14504. return QScriptValue();
  14505. }
  14506. /*:67*//*68:*/
  14507. #line 1810 "./typica.w"
  14508. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14509. {
  14510. if(context->argumentCount()> 0&&context->argumentCount()<4)
  14511. {
  14512. QBoxLayout*self= getself<QBoxLayout*> (context);
  14513. QWidget*widget= argument<QWidget*> (0,context);
  14514. int stretch= 0;
  14515. Qt::Alignment alignment= 0;
  14516. if(context->argumentCount()> 1)
  14517. {
  14518. stretch= argument<int> (1,context);
  14519. }
  14520. if(context->argumentCount()> 2)
  14521. {
  14522. alignment= (Qt::Alignment)(argument<int> (2,context));
  14523. }
  14524. if(widget)
  14525. {
  14526. self->addWidget(widget,stretch,alignment);
  14527. }
  14528. else
  14529. {
  14530. context->throwError("Incorrect argument type passed to "
  14531. "QBoxLayout::addWidget(). This method requires "
  14532. "a QWidget.");
  14533. }
  14534. }
  14535. else
  14536. {
  14537. context->throwError("Incorrect number of arguments passed to "
  14538. "QBoxLayout::addWidget(). This method takes one "
  14539. "QWidget and optionally up to two integers as "
  14540. "arguments.");
  14541. }
  14542. return QScriptValue();
  14543. }
  14544. /*:68*//*71:*/
  14545. #line 1874 "./typica.w"
  14546. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  14547. {
  14548. QScriptValue object= engine->newQObject(new QAction(NULL));
  14549. setQActionProperties(object,engine);
  14550. return object;
  14551. }
  14552. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  14553. {
  14554. setQObjectProperties(value,engine);
  14555. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  14556. }
  14557. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  14558. {
  14559. if(context->argumentCount()==1)
  14560. {
  14561. QAction*self= getself<QAction*> (context);
  14562. self->setShortcut(argument<QString> (0,context));
  14563. }
  14564. else
  14565. {
  14566. context->throwError("Incorrect number of arguments passed to "
  14567. "QAction::setShortcut(). This method takes one "
  14568. "string as an argument.");
  14569. }
  14570. return QScriptValue();
  14571. }
  14572. /*:71*//*74:*/
  14573. #line 1932 "./typica.w"
  14574. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  14575. QScriptEngine*engine)
  14576. {
  14577. QScriptValue retval;
  14578. if(context->argumentCount()==3)
  14579. {
  14580. QWidget*widget= argument<QWidget*> (0,context);
  14581. if(widget)
  14582. {
  14583. QString caption= argument<QString> (1,context);
  14584. QString dir= argument<QString> (2,context);
  14585. retval= QScriptValue(engine,
  14586. QFileDialog::getOpenFileName(widget,caption,
  14587. dir,"",0,0));
  14588. setQFileDialogProperties(retval,engine);
  14589. }
  14590. else
  14591. {
  14592. context->throwError("Incorrect argument type passed to "
  14593. "QFileDialog::getOpenFileName(). The first "
  14594. "argument to this method must be a QWidget.");
  14595. }
  14596. }
  14597. else
  14598. {
  14599. context->throwError("Incorrect number of arguments passed to "
  14600. "QFileDialog::getOpenFileName(). This method "
  14601. "takes one QWidget followed by two strings for a "
  14602. "total of three arguments.");
  14603. }
  14604. return retval;
  14605. }
  14606. /*:74*//*75:*/
  14607. #line 1968 "./typica.w"
  14608. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  14609. QScriptEngine*engine)
  14610. {
  14611. QScriptValue retval;
  14612. if(context->argumentCount()==3)
  14613. {
  14614. QWidget*widget= argument<QWidget*> (0,context);
  14615. if(widget)
  14616. {
  14617. QString caption= argument<QString> (1,context);
  14618. QString dir= argument<QString> (2,context);
  14619. retval= QScriptValue(engine,
  14620. QFileDialog::getSaveFileName(widget,caption,
  14621. dir,"",0,0));
  14622. setQFileDialogProperties(retval,engine);
  14623. }
  14624. else
  14625. {
  14626. context->throwError("Incorrect argument type passed to "
  14627. "QFileDialog::getSaveFileName(). The first "
  14628. "argument to this method must be a QWidget.");
  14629. }
  14630. }
  14631. else
  14632. {
  14633. context->throwError("Incorrect number of arguments passed to "
  14634. "QFileDialog::getSaveFileName(). This method "
  14635. "takes one QWidget followed by two strings for a "
  14636. "total of three arguments.");
  14637. }
  14638. return retval;
  14639. }
  14640. /*:75*//*76:*/
  14641. #line 2005 "./typica.w"
  14642. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  14643. {
  14644. setQDialogProperties(value,engine);
  14645. }
  14646. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  14647. {
  14648. setQWidgetProperties(value,engine);
  14649. }
  14650. /*:76*//*79:*/
  14651. #line 2046 "./typica.w"
  14652. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  14653. {
  14654. QScriptValue object=
  14655. engine->newQObject(new QFile(argument<QString> (0,context)));
  14656. setQFileProperties(object,engine);
  14657. return object;
  14658. }
  14659. /*:79*//*80:*/
  14660. #line 2057 "./typica.w"
  14661. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  14662. {
  14663. setQIODeviceProperties(value,engine);
  14664. value.setProperty("remove",engine->newFunction(QFile_remove));
  14665. }
  14666. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  14667. {
  14668. QFile*self= getself<QFile*> (context);
  14669. bool retval= self->remove();
  14670. return QScriptValue(engine,retval);
  14671. }
  14672. /*:80*//*81:*/
  14673. #line 2079 "./typica.w"
  14674. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  14675. {
  14676. setQObjectProperties(value,engine);
  14677. value.setProperty("open",engine->newFunction(QIODevice_open));
  14678. value.setProperty("close",engine->newFunction(QIODevice_close));
  14679. value.setProperty("readToString",
  14680. engine->newFunction(QIODevice_readToString));
  14681. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  14682. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  14683. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  14684. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  14685. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  14686. value.setProperty("read",engine->newFunction(QIODevice_read));
  14687. }
  14688. /*:81*//*82:*/
  14689. #line 2100 "./typica.w"
  14690. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  14691. {
  14692. QIODevice*self= getself<QIODevice*> (context);
  14693. bool retval= false;
  14694. if(context->argumentCount()==1)
  14695. {
  14696. switch(argument<int> (0,context))
  14697. {
  14698. case 1:
  14699. retval= self->open(QIODevice::ReadOnly);
  14700. break;
  14701. case 2:
  14702. retval= self->open(QIODevice::WriteOnly);
  14703. break;
  14704. case 3:
  14705. retval= self->open(QIODevice::ReadWrite);
  14706. break;
  14707. default:
  14708. break;
  14709. }
  14710. }
  14711. else
  14712. {
  14713. retval= self->open(QIODevice::ReadWrite);
  14714. }
  14715. return QScriptValue(retval);
  14716. }
  14717. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  14718. {
  14719. QIODevice*self= getself<QIODevice*> (context);
  14720. self->close();
  14721. return QScriptValue();
  14722. }
  14723. /*:82*//*83:*/
  14724. #line 2140 "./typica.w"
  14725. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  14726. {
  14727. QIODevice*self= getself<QIODevice*> (context);
  14728. self->reset();
  14729. return QScriptValue(QString(self->readAll()));
  14730. }
  14731. /*:83*//*84:*/
  14732. #line 2156 "./typica.w"
  14733. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  14734. {
  14735. QIODevice*self= getself<QIODevice*> (context);
  14736. if(context->argumentCount()==1)
  14737. {
  14738. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  14739. }
  14740. context->throwError("Incorrect number of arguments passed to "
  14741. "QIODevice::putChar()");
  14742. return QScriptValue();
  14743. }
  14744. /*:84*//*85:*/
  14745. #line 2174 "./typica.w"
  14746. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  14747. {
  14748. QIODevice*self= getself<QIODevice*> (context);
  14749. if(context->argumentCount()==1)
  14750. {
  14751. self->write(argument<QString> (0,context).toUtf8());
  14752. }
  14753. else
  14754. {
  14755. context->throwError("Incorrect number of arguments passed to "
  14756. "QIODevice::writeString()");
  14757. }
  14758. return QScriptValue();
  14759. }
  14760. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  14761. {
  14762. QIODevice*self= getself<QIODevice*> (context);
  14763. if(context->argumentCount()==1)
  14764. {
  14765. self->write(argument<QByteArray> (0,context));
  14766. }
  14767. else
  14768. {
  14769. context->throwError("Incorrect number of arguments passed to "
  14770. "QIODevice::writeBytes()");
  14771. }
  14772. return QScriptValue();
  14773. }
  14774. /*:85*//*86:*/
  14775. #line 2208 "./typica.w"
  14776. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  14777. {
  14778. QIODevice*self= getself<QIODevice*> (context);
  14779. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  14780. setQByteArrayProperties(value,engine);
  14781. return value;
  14782. }
  14783. /*:86*//*87:*/
  14784. #line 2219 "./typica.w"
  14785. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  14786. {
  14787. QIODevice*self= getself<QIODevice*> (context);
  14788. QScriptValue value= engine->toScriptValue<QByteArray> (
  14789. self->peek(argument<int> (0,context)));
  14790. setQByteArrayProperties(value,engine);
  14791. return value;
  14792. }
  14793. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  14794. {
  14795. QIODevice*self= getself<QIODevice*> (context);
  14796. QScriptValue value= engine->toScriptValue<QByteArray> (
  14797. self->read(argument<int> (0,context)));
  14798. setQByteArrayProperties(value,engine);
  14799. return value;
  14800. }
  14801. /*:87*//*90:*/
  14802. #line 2264 "./typica.w"
  14803. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  14804. {
  14805. QScriptValue object= engine->newQObject(new QProcess);
  14806. setQProcessProperties(object,engine);
  14807. return object;
  14808. }
  14809. /*:90*//*91:*/
  14810. #line 2275 "./typica.w"
  14811. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  14812. {
  14813. setQIODeviceProperties(value,engine);
  14814. value.setProperty("execute",engine->newFunction(QProcess_execute));
  14815. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  14816. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  14817. value.setProperty("start",engine->newFunction(QProcess_start));
  14818. }
  14819. /*:91*//*92:*/
  14820. #line 2289 "./typica.w"
  14821. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  14822. {
  14823. QProcess*self= getself<QProcess*> (context);
  14824. QString program= argument<QString> (0,context);
  14825. QStringList arguments= QStringList();
  14826. if(context->argumentCount()> 1){
  14827. arguments= argument<QVariant> (1,context).toStringList();
  14828. }
  14829. int retval= self->execute(program,arguments);
  14830. return QScriptValue(retval);
  14831. }
  14832. /*:92*//*93:*/
  14833. #line 2304 "./typica.w"
  14834. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  14835. {
  14836. QProcess*self= getself<QProcess*> (context);
  14837. QString program= argument<QString> (0,context);
  14838. QStringList arguments= QStringList();
  14839. if(context->argumentCount()> 1){
  14840. arguments= argument<QVariant> (1,context).toStringList();
  14841. }
  14842. QString workingDirectory= "";
  14843. if(context->argumentCount()> 2){
  14844. workingDirectory= argument<QString> (2,context);
  14845. }
  14846. bool retval;
  14847. switch(context->argumentCount())
  14848. {
  14849. case 1:
  14850. retval= self->startDetached(program);
  14851. break;
  14852. case 2:
  14853. retval= self->startDetached(program,arguments);
  14854. break;
  14855. case 3:
  14856. retval= self->startDetached(program,arguments,workingDirectory);
  14857. break;
  14858. default:
  14859. retval= false;
  14860. }
  14861. return QScriptValue(retval);
  14862. }
  14863. /*:93*//*94:*/
  14864. #line 2337 "./typica.w"
  14865. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  14866. {
  14867. QProcess*self= getself<QProcess*> (context);
  14868. QString directory= argument<QString> (0,context);
  14869. self->setWorkingDirectory(directory);
  14870. return QScriptValue();
  14871. }
  14872. /*:94*//*95:*/
  14873. #line 2349 "./typica.w"
  14874. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  14875. {
  14876. QProcess*self= getself<QProcess*> (context);
  14877. QString program= argument<QString> (0,context);
  14878. QStringList arguments= QStringList();
  14879. if(context->argumentCount()> 1){
  14880. arguments= argument<QVariant> (1,context).toStringList();
  14881. }
  14882. self->start(program,arguments);
  14883. return QScriptValue();
  14884. }
  14885. /*:95*//*97:*/
  14886. #line 2390 "./typica.w"
  14887. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  14888. {
  14889. QScriptValue object= engine->newVariant(QVariant(bytes));
  14890. setQByteArrayProperties(object,engine);
  14891. return object;
  14892. }
  14893. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  14894. {
  14895. bytes= value.toVariant().toByteArray();
  14896. }
  14897. /*:97*//*99:*/
  14898. #line 2413 "./typica.w"
  14899. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  14900. {
  14901. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  14902. setQByteArrayProperties(object,engine);
  14903. return object;
  14904. }
  14905. /*:99*//*100:*/
  14906. #line 2424 "./typica.w"
  14907. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  14908. {
  14909. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  14910. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  14911. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  14912. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  14913. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  14914. value.setProperty("size",engine->newFunction(QByteArray_size));
  14915. value.setProperty("left",engine->newFunction(QByteArray_left));
  14916. value.setProperty("right",engine->newFunction(QByteArray_right));
  14917. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  14918. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  14919. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  14920. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  14921. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  14922. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  14923. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  14924. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  14925. }
  14926. /*:100*//*101:*/
  14927. #line 2448 "./typica.w"
  14928. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  14929. {
  14930. QByteArray self= getself<QByteArray> (context);
  14931. QByteArray retval;
  14932. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  14933. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  14934. setQByteArrayProperties(value,engine);
  14935. return value;
  14936. }
  14937. /*:101*//*102:*/
  14938. #line 2462 "./typica.w"
  14939. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  14940. {
  14941. QByteArray self= getself<QByteArray> (context);
  14942. return QScriptValue((int)(self.at(argument<int> (0,context))));
  14943. }
  14944. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  14945. {
  14946. QByteArray self= getself<QByteArray> (context);
  14947. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  14948. return QScriptValue();
  14949. }
  14950. /*:102*//*103:*/
  14951. #line 2480 "./typica.w"
  14952. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  14953. {
  14954. QByteArray self= getself<QByteArray> (context);
  14955. QScriptValue value=
  14956. engine->toScriptValue<QByteArray> (
  14957. self.append(argument<QByteArray> (0,context)));
  14958. setQByteArrayProperties(value,engine);
  14959. return value;
  14960. }
  14961. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  14962. {
  14963. QByteArray self= getself<QByteArray> (context);
  14964. QScriptValue value= engine->toScriptValue<QByteArray> (
  14965. self.append(argument<QString> (0,context)));
  14966. setQByteArrayProperties(value,engine);
  14967. return value;
  14968. }
  14969. /*:103*//*104:*/
  14970. #line 2502 "./typica.w"
  14971. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  14972. {
  14973. QByteArray self= getself<QByteArray> (context);
  14974. return QScriptValue(self.size());
  14975. }
  14976. /*:104*//*105:*/
  14977. #line 2512 "./typica.w"
  14978. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  14979. {
  14980. QByteArray self= getself<QByteArray> (context);
  14981. QScriptValue value= engine->toScriptValue<QByteArray> (
  14982. self.left(argument<int> (0,context)));
  14983. setQByteArrayProperties(value,engine);
  14984. return value;
  14985. }
  14986. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  14987. {
  14988. QByteArray self= getself<QByteArray> (context);
  14989. QScriptValue value= engine->toScriptValue<QByteArray> (
  14990. self.right(argument<int> (0,context)));
  14991. setQByteArrayProperties(value,engine);
  14992. return value;
  14993. }
  14994. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  14995. {
  14996. QByteArray self= getself<QByteArray> (context);
  14997. int length= -1;
  14998. if(context->argumentCount()> 1)
  14999. {
  15000. length= argument<int> (1,context);
  15001. }
  15002. QScriptValue value= engine->toScriptValue<QByteArray> (
  15003. self.mid(argument<int> (0,context),length));
  15004. setQByteArrayProperties(value,engine);
  15005. return value;
  15006. }
  15007. /*:105*//*106:*/
  15008. #line 2547 "./typica.w"
  15009. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  15010. {
  15011. QByteArray self= getself<QByteArray> (context);
  15012. self.chop(argument<int> (0,context));
  15013. return QScriptValue();
  15014. }
  15015. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  15016. {
  15017. QByteArray self= getself<QByteArray> (context);
  15018. QScriptValue value= engine->toScriptValue<QByteArray> (
  15019. self.remove(argument<int> (0,context),argument<int> (1,context)));
  15020. setQByteArrayProperties(value,engine);
  15021. return value;
  15022. }
  15023. /*:106*//*107:*/
  15024. #line 2570 "./typica.w"
  15025. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  15026. {
  15027. QByteArray self= getself<QByteArray> (context);
  15028. int value= 0;
  15029. char*bytes= (char*)&value;
  15030. bytes[0]= self[0];
  15031. return QScriptValue(value);
  15032. }
  15033. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  15034. {
  15035. QByteArray self= getself<QByteArray> (context);
  15036. int value= 0;
  15037. char*bytes= (char*)&value;
  15038. bytes[0]= self[0];
  15039. bytes[1]= self[1];
  15040. return QScriptValue(value);
  15041. }
  15042. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  15043. {
  15044. QByteArray self= getself<QByteArray> (context);
  15045. int value= 0;
  15046. char*bytes= (char*)&value;
  15047. bytes[0]= self[0];
  15048. bytes[1]= self[1];
  15049. bytes[2]= self[2];
  15050. bytes[3]= self[3];
  15051. return QScriptValue(value);
  15052. }
  15053. /*:107*//*108:*/
  15054. #line 2606 "./typica.w"
  15055. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  15056. {
  15057. QByteArray self= getself<QByteArray> (context);
  15058. float value= 0.0;
  15059. char*bytes= (char*)&value;
  15060. bytes[0]= self[0];
  15061. bytes[1]= self[1];
  15062. bytes[2]= self[2];
  15063. bytes[3]= self[3];
  15064. return QScriptValue(value);
  15065. }
  15066. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  15067. {
  15068. QByteArray self= getself<QByteArray> (context);
  15069. double value= 0.0;
  15070. char*bytes= (char*)&value;
  15071. bytes[0]= self[0];
  15072. bytes[1]= self[1];
  15073. bytes[2]= self[2];
  15074. bytes[3]= self[3];
  15075. bytes[4]= self[4];
  15076. bytes[5]= self[5];
  15077. bytes[6]= self[6];
  15078. bytes[7]= self[7];
  15079. return QScriptValue(value);
  15080. }
  15081. /*:108*//*111:*/
  15082. #line 2661 "./typica.w"
  15083. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  15084. {
  15085. qint8 value= (qint8)(argument<int> (0,context));
  15086. char*bytes= (char*)&value;
  15087. QByteArray retval;
  15088. retval.resize(1);
  15089. retval[0]= bytes[0];
  15090. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15091. setQByteArrayProperties(v,engine);
  15092. return v;
  15093. }
  15094. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  15095. {
  15096. qint16 value= (qint16)(argument<int> (0,context));
  15097. char*bytes= (char*)&value;
  15098. QByteArray retval;
  15099. retval.resize(2);
  15100. retval[0]= bytes[0];
  15101. retval[1]= bytes[1];
  15102. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15103. setQByteArrayProperties(v,engine);
  15104. return v;
  15105. }
  15106. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  15107. {
  15108. qint32 value= (qint32)(argument<int> (0,context));
  15109. char*bytes= (char*)&value;
  15110. QByteArray retval;
  15111. retval.resize(4);
  15112. retval[0]= bytes[0];
  15113. retval[1]= bytes[1];
  15114. retval[2]= bytes[2];
  15115. retval[3]= bytes[3];
  15116. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15117. setQByteArrayProperties(v,engine);
  15118. return v;
  15119. }
  15120. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  15121. {
  15122. float value= (float)(argument<double> (0,context));
  15123. char*bytes= (char*)&value;
  15124. QByteArray retval;
  15125. retval.resize(4);
  15126. retval[0]= bytes[0];
  15127. retval[1]= bytes[1];
  15128. retval[2]= bytes[2];
  15129. retval[3]= bytes[3];
  15130. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15131. setQByteArrayProperties(v,engine);
  15132. return v;
  15133. }
  15134. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  15135. {
  15136. double value= (double)(argument<double> (0,context));
  15137. char*bytes= (char*)&value;
  15138. QByteArray retval;
  15139. retval.resize(8);
  15140. retval[0]= bytes[0];
  15141. retval[1]= bytes[1];
  15142. retval[2]= bytes[2];
  15143. retval[3]= bytes[3];
  15144. retval[4]= bytes[4];
  15145. retval[5]= bytes[5];
  15146. retval[6]= bytes[6];
  15147. retval[7]= bytes[7];
  15148. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15149. setQByteArrayProperties(v,engine);
  15150. return v;
  15151. }
  15152. /*:111*//*114:*/
  15153. #line 2758 "./typica.w"
  15154. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  15155. {
  15156. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  15157. QScriptValue object= engine->newQObject(new QBuffer(array));
  15158. setQBufferProperties(object,engine);
  15159. return object;
  15160. }
  15161. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  15162. {
  15163. setQIODeviceProperties(value,engine);
  15164. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  15165. }
  15166. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  15167. {
  15168. QBuffer*self= getself<QBuffer*> (context);
  15169. self->setData(argument<QString> (0,context).toAscii());
  15170. return QScriptValue();
  15171. }
  15172. /*:114*//*117:*/
  15173. #line 2807 "./typica.w"
  15174. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  15175. {
  15176. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  15177. setXQueryProperties(object,engine);
  15178. return object;
  15179. }
  15180. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  15181. {
  15182. QXmlQuery*self= getself<QXmlQuery*> (context);
  15183. delete self;
  15184. return QScriptValue();
  15185. }
  15186. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  15187. {
  15188. value.setProperty("bind",engine->newFunction(XQuery_bind));
  15189. value.setProperty("exec",engine->newFunction(XQuery_exec));
  15190. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  15191. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  15192. }
  15193. /*:117*//*118:*/
  15194. #line 2833 "./typica.w"
  15195. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  15196. {
  15197. QXmlQuery*self= getself<QXmlQuery*> (context);
  15198. QIODevice*buffer= argument<QIODevice*> (1,context);
  15199. self->bindVariable(argument<QString> (0,context),buffer);
  15200. return QScriptValue();
  15201. }
  15202. /*:118*//*119:*/
  15203. #line 2844 "./typica.w"
  15204. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  15205. {
  15206. QXmlQuery*self= getself<QXmlQuery*> (context);
  15207. self->setQuery(argument<QString> (0,context));
  15208. return QScriptValue();
  15209. }
  15210. /*:119*//*120:*/
  15211. #line 2854 "./typica.w"
  15212. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  15213. {
  15214. QXmlQuery*self= getself<QXmlQuery*> (context);
  15215. QString result;
  15216. self->evaluateTo(&result);
  15217. return QScriptValue(result);
  15218. }
  15219. /*:120*//*123:*/
  15220. #line 2909 "./typica.w"
  15221. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  15222. {
  15223. QXmlStreamWriter*retval;
  15224. if(context->argumentCount()==1)
  15225. {
  15226. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  15227. }
  15228. else
  15229. {
  15230. retval= new QXmlStreamWriter;
  15231. }
  15232. QScriptValue object= engine->toScriptValue<void*> (retval);
  15233. setXmlWriterProperties(object,engine);
  15234. return object;
  15235. }
  15236. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  15237. {
  15238. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  15239. value.setProperty("writeAttribute",
  15240. engine->newFunction(XmlWriter_writeAttribute));
  15241. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  15242. value.setProperty("writeCharacters",
  15243. engine->newFunction(XmlWriter_writeCharacters));
  15244. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  15245. value.setProperty("writeEmptyElement",
  15246. engine->newFunction(XmlWriter_writeEmptyElement));
  15247. value.setProperty("writeEndDocument",
  15248. engine->newFunction(XmlWriter_writeEndDocument));
  15249. value.setProperty("writeEndElement",
  15250. engine->newFunction(XmlWriter_writeEndElement));
  15251. value.setProperty("writeEntityReference",
  15252. engine->newFunction(XmlWriter_writeEntityReference));
  15253. value.setProperty("writeProcessingInstruction",
  15254. engine->newFunction(XmlWriter_writeProcessingInstruction));
  15255. value.setProperty("writeStartDocument",
  15256. engine->newFunction(XmlWriter_writeStartDocument));
  15257. value.setProperty("writeStartElement",
  15258. engine->newFunction(XmlWriter_writeStartElement));
  15259. value.setProperty("writeTextElement",
  15260. engine->newFunction(XmlWriter_writeTextElement));
  15261. }
  15262. /*:123*//*124:*/
  15263. #line 2956 "./typica.w"
  15264. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  15265. {
  15266. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15267. QIODevice*device= argument<QIODevice*> (0,context);
  15268. self->setDevice(device);
  15269. return QScriptValue();
  15270. }
  15271. /*:124*//*125:*/
  15272. #line 2970 "./typica.w"
  15273. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  15274. QScriptEngine*)
  15275. {
  15276. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15277. self->writeStartDocument(argument<QString> (0,context));
  15278. return QScriptValue();
  15279. }
  15280. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  15281. QScriptEngine*)
  15282. {
  15283. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15284. self->writeEndDocument();
  15285. return QScriptValue();
  15286. }
  15287. /*:125*//*126:*/
  15288. #line 2989 "./typica.w"
  15289. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  15290. {
  15291. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15292. self->writeDTD(argument<QString> (0,context));
  15293. return QScriptValue();
  15294. }
  15295. /*:126*//*127:*/
  15296. #line 3000 "./typica.w"
  15297. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  15298. QScriptEngine*)
  15299. {
  15300. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15301. self->writeStartElement(argument<QString> (0,context));
  15302. return QScriptValue();
  15303. }
  15304. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  15305. {
  15306. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15307. self->writeAttribute(argument<QString> (0,context),
  15308. argument<QString> (1,context));
  15309. return QScriptValue();
  15310. }
  15311. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  15312. {
  15313. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15314. self->writeCharacters(argument<QString> (0,context));
  15315. return QScriptValue();
  15316. }
  15317. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  15318. {
  15319. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15320. self->writeEndElement();
  15321. return QScriptValue();
  15322. }
  15323. /*:127*//*128:*/
  15324. #line 3036 "./typica.w"
  15325. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  15326. QScriptEngine*)
  15327. {
  15328. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15329. self->writeEmptyElement(argument<QString> (0,context));
  15330. return QScriptValue();
  15331. }
  15332. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  15333. QScriptEngine*)
  15334. {
  15335. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15336. self->writeTextElement(argument<QString> (0,context),
  15337. argument<QString> (1,context));
  15338. return QScriptValue();
  15339. }
  15340. /*:128*//*129:*/
  15341. #line 3057 "./typica.w"
  15342. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  15343. {
  15344. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15345. self->writeCDATA(argument<QString> (0,context));
  15346. return QScriptValue();
  15347. }
  15348. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  15349. QScriptEngine*)
  15350. {
  15351. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15352. self->writeEntityReference(argument<QString> (0,context));
  15353. return QScriptValue();
  15354. }
  15355. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  15356. QScriptEngine*)
  15357. {
  15358. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15359. self->writeProcessingInstruction(argument<QString> (0,context),
  15360. argument<QString> (1,context));
  15361. return QScriptValue();
  15362. }
  15363. /*:129*//*132:*/
  15364. #line 3116 "./typica.w"
  15365. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  15366. {
  15367. QXmlStreamReader*retval=
  15368. new QXmlStreamReader(argument<QIODevice*> (0,context));
  15369. QScriptValue object= engine->toScriptValue<void*> (retval);
  15370. setXmlReaderProperties(object,engine);
  15371. return object;
  15372. }
  15373. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  15374. {
  15375. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  15376. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  15377. value.setProperty("hasAttribute",
  15378. engine->newFunction(XmlReader_hasAttribute));
  15379. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  15380. value.setProperty("isStartElement",
  15381. engine->newFunction(XmlReader_isStartElement));
  15382. value.setProperty("name",engine->newFunction(XmlReader_name));
  15383. value.setProperty("readElementText",
  15384. engine->newFunction(XmlReader_readElementText));
  15385. value.setProperty("readNext",
  15386. engine->newFunction(XmlReader_readNext));
  15387. value.setProperty("text",engine->newFunction(XmlReader_text));
  15388. }
  15389. /*:132*//*133:*/
  15390. #line 3146 "./typica.w"
  15391. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  15392. {
  15393. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15394. QString retval=
  15395. self->attributes().value(argument<QString> (0,context)).toString();
  15396. return QScriptValue(retval);
  15397. }
  15398. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  15399. {
  15400. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15401. bool retval=
  15402. self->attributes().hasAttribute(argument<QString> (0,context));
  15403. return QScriptValue(retval);
  15404. }
  15405. /*:133*//*134:*/
  15406. #line 3166 "./typica.w"
  15407. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  15408. {
  15409. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15410. return QScriptValue(self->atEnd());
  15411. }
  15412. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  15413. {
  15414. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15415. return QScriptValue(self->isDTD());
  15416. }
  15417. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  15418. {
  15419. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15420. return QScriptValue(self->isStartElement());
  15421. }
  15422. /*:134*//*135:*/
  15423. #line 3187 "./typica.w"
  15424. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  15425. {
  15426. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15427. self->readNext();
  15428. return QScriptValue();
  15429. }
  15430. /*:135*//*136:*/
  15431. #line 3197 "./typica.w"
  15432. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  15433. {
  15434. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15435. return QScriptValue(self->name().toString());
  15436. }
  15437. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  15438. {
  15439. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15440. return QScriptValue(self->readElementText());
  15441. }
  15442. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  15443. {
  15444. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15445. return QScriptValue(self->text().toString());
  15446. }
  15447. /*:136*//*139:*/
  15448. #line 3239 "./typica.w"
  15449. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  15450. {
  15451. setQObjectProperties(value,engine);
  15452. value.setProperty("value",engine->newFunction(QSettings_value));
  15453. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  15454. }
  15455. /*:139*//*140:*/
  15456. #line 3251 "./typica.w"
  15457. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  15458. {
  15459. QScriptValue object;
  15460. if(context->argumentCount()==1||context->argumentCount()==2)
  15461. {
  15462. QSettings settings;
  15463. QString key= argument<QString> (0,context);
  15464. QVariant value;
  15465. QVariant retval;
  15466. if(context->argumentCount()> 1)
  15467. {
  15468. value= argument<QVariant> (1,context);
  15469. retval= settings.value(key,value);
  15470. }
  15471. else
  15472. {
  15473. retval= settings.value(key);
  15474. }
  15475. object= engine->newVariant(retval);
  15476. }
  15477. else
  15478. {
  15479. context->throwError("Incorrect number of arguments passed to "
  15480. "QSettings::value(). This method takes one "
  15481. "string and one optional variant type.");
  15482. }
  15483. return object;
  15484. }
  15485. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  15486. {
  15487. if(context->argumentCount()==2)
  15488. {
  15489. QSettings settings;
  15490. QString key= argument<QString> (0,context);
  15491. QVariant value= argument<QVariant> (1,context);
  15492. settings.setValue(key,value);
  15493. }
  15494. else
  15495. {
  15496. context->throwError("Incorrect number of arguments passed to "
  15497. "QSettings::setValue(). This method takes one "
  15498. "string and one variant type for a total of two "
  15499. "arguments.");
  15500. }
  15501. return QScriptValue();
  15502. }
  15503. /*:140*//*143:*/
  15504. #line 3320 "./typica.w"
  15505. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  15506. {
  15507. QScriptValue object= engine->newQObject(new QLCDNumber());
  15508. setQLCDNumberProperties(object,engine);
  15509. return object;
  15510. }
  15511. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  15512. {
  15513. setQFrameProperties(value,engine);
  15514. }
  15515. /*:143*//*146:*/
  15516. #line 3378 "./typica.w"
  15517. QScriptValue constructQTime(QScriptContext*context,
  15518. QScriptEngine*engine)
  15519. {
  15520. QScriptValue object;
  15521. if(context->argumentCount()==0||
  15522. (context->argumentCount()>=2&&context->argumentCount()<=4))
  15523. {
  15524. int arg1= 0;
  15525. int arg2= 0;
  15526. int arg3= 0;
  15527. int arg4= 0;
  15528. switch(context->argumentCount())
  15529. {
  15530. case 4:
  15531. arg4= argument<int> (3,context);
  15532. case 3:
  15533. arg3= argument<int> (2,context);
  15534. case 2:
  15535. arg2= argument<int> (1,context);
  15536. arg1= argument<int> (0,context);
  15537. default:
  15538. break;
  15539. }
  15540. if(context->argumentCount())
  15541. {
  15542. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  15543. arg4));
  15544. }
  15545. else
  15546. {
  15547. object= engine->toScriptValue<QTime> (QTime());
  15548. }
  15549. setQTimeProperties(object,engine);
  15550. }
  15551. else
  15552. {
  15553. context->throwError("Incorrect number of arguments passed to "
  15554. "QTime::QTime(). This method takes zero, two, "
  15555. "three, or four integer arguments.");
  15556. }
  15557. return object;
  15558. }
  15559. /*:146*//*147:*/
  15560. #line 3426 "./typica.w"
  15561. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  15562. {
  15563. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  15564. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  15565. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  15566. value.setProperty("hour",engine->newFunction(QTime_hour));
  15567. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  15568. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  15569. value.setProperty("minute",engine->newFunction(QTime_minute));
  15570. value.setProperty("msec",engine->newFunction(QTime_msec));
  15571. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  15572. value.setProperty("restart",engine->newFunction(QTime_restart));
  15573. value.setProperty("second",engine->newFunction(QTime_second));
  15574. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  15575. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  15576. value.setProperty("start",engine->newFunction(QTime_start));
  15577. value.setProperty("toString",engine->newFunction(QTime_toString));
  15578. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  15579. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  15580. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  15581. }
  15582. /*:147*//*148:*/
  15583. #line 3455 "./typica.w"
  15584. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  15585. {
  15586. QTime self= getself<QTime> (context);
  15587. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  15588. (self.second()*1000)+self.msec();
  15589. return QScriptValue(retval);
  15590. }
  15591. /*:148*//*149:*/
  15592. #line 3469 "./typica.w"
  15593. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  15594. {
  15595. QTime time;
  15596. QScriptValue retval;
  15597. if(context->argumentCount()==1)
  15598. {
  15599. QTime self= getself<QTime> (context);
  15600. time= self.addMSecs(argument<int> (0,context));
  15601. retval= engine->toScriptValue<QTime> (time);
  15602. setQTimeProperties(retval,engine);
  15603. }
  15604. else
  15605. {
  15606. context->throwError("Incorrect number of arguments passed to "
  15607. "QTime::addMSecs(). This method takes one "
  15608. "integer as an argument.");
  15609. }
  15610. return retval;
  15611. }
  15612. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  15613. {
  15614. QTime time;
  15615. QScriptValue retval;
  15616. if(context->argumentCount()==1)
  15617. {
  15618. QTime self= getself<QTime> (context);
  15619. time= self.addSecs(argument<int> (0,context));
  15620. retval= engine->toScriptValue<QTime> (time);
  15621. setQTimeProperties(retval,engine);
  15622. }
  15623. else
  15624. {
  15625. context->throwError("Incorrect number of arguments passed to "
  15626. "QTime::addSecs(). This method takes one "
  15627. "integer as an argument.");
  15628. }
  15629. return retval;
  15630. }
  15631. /*:149*//*150:*/
  15632. #line 3512 "./typica.w"
  15633. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  15634. {
  15635. QScriptValue retval;
  15636. if(context->argumentCount()==0)
  15637. {
  15638. QTime self= getself<QTime> (context);
  15639. retval= QScriptValue(engine,self.elapsed());
  15640. }
  15641. else
  15642. {
  15643. context->throwError("Incorrect number of arguments passed to "
  15644. "QTime::elapsed(). This method takes no "
  15645. "arguments.");
  15646. }
  15647. return retval;
  15648. }
  15649. /*:150*//*151:*/
  15650. #line 3533 "./typica.w"
  15651. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  15652. {
  15653. QScriptValue retval;
  15654. if(context->argumentCount()==0)
  15655. {
  15656. QTime self= getself<QTime> (context);
  15657. retval= QScriptValue(engine,self.hour());
  15658. }
  15659. else
  15660. {
  15661. context->throwError("Incorrect number of arguments passed to "
  15662. "QTime::hour(). This method takes no "
  15663. "arguments.");
  15664. }
  15665. return retval;
  15666. }
  15667. /*:151*//*152:*/
  15668. #line 3553 "./typica.w"
  15669. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  15670. {
  15671. QScriptValue retval;
  15672. if(context->argumentCount()==0)
  15673. {
  15674. QTime self= getself<QTime> (context);
  15675. retval= QScriptValue(engine,self.minute());
  15676. }
  15677. else
  15678. {
  15679. context->throwError("Incorrect number of arguments passed to "
  15680. "QTime::minute(). This method takes no "
  15681. "arguments.");
  15682. }
  15683. return retval;
  15684. }
  15685. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  15686. {
  15687. QScriptValue retval;
  15688. if(context->argumentCount()==0)
  15689. {
  15690. QTime self= getself<QTime> (context);
  15691. retval= QScriptValue(engine,self.second());
  15692. }
  15693. else
  15694. {
  15695. context->throwError("Incorrect number of arguments passed to "
  15696. "QTime::second(). This method takes no "
  15697. "arguments.");
  15698. }
  15699. return retval;
  15700. }
  15701. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  15702. {
  15703. QScriptValue retval;
  15704. if(context->argumentCount()==0)
  15705. {
  15706. QTime self= getself<QTime> (context);
  15707. retval= QScriptValue(engine,self.msec());
  15708. }
  15709. else
  15710. {
  15711. context->throwError("Incorrect number of arguments passed to "
  15712. "QTime::msec(). This method takes no "
  15713. "arguments.");
  15714. }
  15715. return retval;
  15716. }
  15717. /*:152*//*153:*/
  15718. #line 3609 "./typica.w"
  15719. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  15720. {
  15721. QScriptValue retval;
  15722. if(context->argumentCount()==0)
  15723. {
  15724. QTime self= getself<QTime> (context);
  15725. retval= QScriptValue(engine,self.isNull());
  15726. }
  15727. else
  15728. {
  15729. context->throwError("Incorrect number of arguments passed to "
  15730. "QTime::isNull(). This method takes no "
  15731. "arguments.");
  15732. }
  15733. return retval;
  15734. }
  15735. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  15736. {
  15737. QScriptValue retval;
  15738. if(context->argumentCount()==0)
  15739. {
  15740. QTime self= getself<QTime> (context);
  15741. retval= QScriptValue(engine,self.isValid());
  15742. }
  15743. else
  15744. {
  15745. context->throwError("Incorrect number of arguments passed to "
  15746. "QTime::isValid(). This method takes no "
  15747. "arguments.");
  15748. }
  15749. return retval;
  15750. }
  15751. /*:153*//*154:*/
  15752. #line 3647 "./typica.w"
  15753. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  15754. {
  15755. QScriptValue retval;
  15756. if(context->argumentCount()==1)
  15757. {
  15758. QTime self= getself<QTime> (context);
  15759. QTime arg= argument<QVariant> (0,context).toTime();
  15760. retval= QScriptValue(engine,self.msecsTo(arg));
  15761. }
  15762. else
  15763. {
  15764. context->throwError("Incorrect number of arguments passed to "
  15765. "QTime::msecsTo(). This method takes one QTime.");
  15766. }
  15767. return retval;
  15768. }
  15769. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  15770. {
  15771. QScriptValue retval;
  15772. if(context->argumentCount()==1)
  15773. {
  15774. QTime self= getself<QTime> (context);
  15775. QTime arg= argument<QVariant> (0,context).toTime();
  15776. retval= QScriptValue(engine,self.secsTo(arg));
  15777. }
  15778. else
  15779. {
  15780. context->throwError("Incorrect number of arguments passed to "
  15781. "QTime::secsTo(). This method takes one QTime.");
  15782. }
  15783. return retval;
  15784. }
  15785. /*:154*//*155:*/
  15786. #line 3686 "./typica.w"
  15787. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  15788. {
  15789. QScriptValue retval;
  15790. if(context->argumentCount()==0)
  15791. {
  15792. QTime self= getself<QTime> (context);
  15793. retval= QScriptValue(engine,self.restart());
  15794. }
  15795. else
  15796. {
  15797. context->throwError("Incorrect number of arguments passed to "
  15798. "QTime::restart(). This method takes no "
  15799. "arguments.");
  15800. }
  15801. return retval;
  15802. }
  15803. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  15804. {
  15805. if(context->argumentCount()==0)
  15806. {
  15807. QTime self= getself<QTime> (context);
  15808. self.start();
  15809. }
  15810. else
  15811. {
  15812. context->throwError("Incorrect number of arguments passed to "
  15813. "QTime::start(). This method takes no arguments.");
  15814. }
  15815. return QScriptValue();
  15816. }
  15817. /*:155*//*156:*/
  15818. #line 3722 "./typica.w"
  15819. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  15820. {
  15821. QScriptValue retval;
  15822. if(context->argumentCount()==3||context->argumentCount()==4)
  15823. {
  15824. QTime self= getself<QTime> (context);
  15825. int arg1= 0;
  15826. int arg2= 0;
  15827. int arg3= 0;
  15828. int arg4= 0;
  15829. switch(context->argumentCount())
  15830. {
  15831. case 4:
  15832. arg4= argument<int> (3,context);
  15833. case 3:
  15834. arg3= argument<int> (2,context);
  15835. arg2= argument<int> (1,context);
  15836. arg1= argument<int> (0,context);
  15837. default:
  15838. break;
  15839. }
  15840. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  15841. }
  15842. else
  15843. {
  15844. context->throwError("Incorrect number of arguments passed to "
  15845. "QTime::setHMS(). This method takes three or "
  15846. "four integer arguments.");
  15847. }
  15848. return retval;
  15849. }
  15850. /*:156*//*157:*/
  15851. #line 3758 "./typica.w"
  15852. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  15853. {
  15854. QScriptValue retval;
  15855. if(context->argumentCount()==1)
  15856. {
  15857. QTime self= getself<QTime> (context);
  15858. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  15859. }
  15860. else
  15861. {
  15862. context->throwError("Incorrect number of arguments passed to "
  15863. "QTime::toString(). This method takes one QString "
  15864. "as an argument.");
  15865. }
  15866. return retval;
  15867. }
  15868. /*:157*//*158:*/
  15869. #line 3779 "./typica.w"
  15870. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  15871. {
  15872. QScriptValue object;
  15873. object= engine->toScriptValue<QTime> (QTime::currentTime());
  15874. setQTimeProperties(object,engine);
  15875. return object;
  15876. }
  15877. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  15878. {
  15879. QScriptValue object;
  15880. if(context->argumentCount()==2)
  15881. {
  15882. QString time= argument<QString> (0,context);
  15883. QString format= argument<QString> (1,context);
  15884. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  15885. setQTimeProperties(object,engine);
  15886. }
  15887. else
  15888. {
  15889. context->throwError("Incorrect number of arguments passed to "
  15890. "QTime::fromString(). This method takes two "
  15891. "string arguments.");
  15892. }
  15893. return object;
  15894. }
  15895. /*:158*//*159:*/
  15896. #line 3810 "./typica.w"
  15897. template<> QTime argument(int arg,QScriptContext*context)
  15898. {
  15899. return qscriptvalue_cast<QTime> (context->argument(arg));
  15900. }
  15901. /*:159*//*161:*/
  15902. #line 3828 "./typica.w"
  15903. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  15904. {
  15905. setQFrameProperties(value,engine);
  15906. }
  15907. /*:161*//*163:*/
  15908. #line 3842 "./typica.w"
  15909. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  15910. {
  15911. setQAbstractScrollAreaProperties(value,engine);
  15912. }
  15913. /*:163*//*165:*/
  15914. #line 3856 "./typica.w"
  15915. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  15916. {
  15917. setQAbstractScrollAreaProperties(value,engine);
  15918. }
  15919. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  15920. {
  15921. setQAbstractItemViewProperties(value,engine);
  15922. }
  15923. /*:165*//*168:*/
  15924. #line 3889 "./typica.w"
  15925. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  15926. {
  15927. QScriptValue object= engine->newQObject(new QPushButton());
  15928. setQPushButtonProperties(object,engine);
  15929. return object;
  15930. }
  15931. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  15932. {
  15933. setQAbstractButtonProperties(value,engine);
  15934. }
  15935. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  15936. {
  15937. setQWidgetProperties(value,engine);
  15938. }
  15939. /*:168*//*175:*/
  15940. #line 4001 "./typica.w"
  15941. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  15942. {
  15943. SqlQueryConnection*obj= new SqlQueryConnection();
  15944. QScriptValue object=
  15945. engine->toScriptValue<void*> (obj);
  15946. setQSqlQueryProperties(object,engine);
  15947. return object;
  15948. }
  15949. /*:175*//*176:*/
  15950. #line 4014 "./typica.w"
  15951. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  15952. {
  15953. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  15954. value.setProperty("bindFileData",
  15955. engine->newFunction(QSqlQuery_bindFileData));
  15956. value.setProperty("bindDeviceData",
  15957. engine->newFunction(QSqlQuery_bindDeviceData));
  15958. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  15959. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  15960. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  15961. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  15962. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  15963. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  15964. }
  15965. /*:176*//*177:*/
  15966. #line 4032 "./typica.w"
  15967. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  15968. {
  15969. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  15970. QScriptValue retval;
  15971. if(context->argumentCount()==1)
  15972. {
  15973. retval= QScriptValue(engine,
  15974. q->exec(argument<QString> (0,context)));
  15975. }
  15976. else
  15977. {
  15978. retval= QScriptValue(engine,q->exec());
  15979. }
  15980. if(q->lastError().isValid())
  15981. {
  15982. qDebug()<<q->lastQuery();
  15983. qDebug()<<q->lastError().text();
  15984. }
  15985. return retval;
  15986. }
  15987. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  15988. {
  15989. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15990. return QScriptValue(query->lastQuery());
  15991. }
  15992. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  15993. {
  15994. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  15995. return QScriptValue(engine,query->next());
  15996. }
  15997. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  15998. {
  15999. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16000. return QScriptValue(engine,
  16001. query->value(argument<int> (0,context)).toString());
  16002. }
  16003. /*:177*//*178:*/
  16004. #line 4076 "./typica.w"
  16005. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  16006. {
  16007. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16008. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  16009. }
  16010. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  16011. {
  16012. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16013. query->bindValue(argument<QString> (0,context),
  16014. argument<QVariant> (1,context));
  16015. return QScriptValue();
  16016. }
  16017. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  16018. QScriptEngine*)
  16019. {
  16020. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16021. QString placeholder= argument<QString> (0,context);
  16022. QString filename= argument<QString> (1,context);
  16023. QFile file(filename);
  16024. QByteArray data;
  16025. if(file.open(QIODevice::ReadOnly))
  16026. {
  16027. data= file.readAll();
  16028. file.close();
  16029. }
  16030. query->bindValue(placeholder,data);
  16031. return QScriptValue();
  16032. }
  16033. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  16034. QScriptEngine*)
  16035. {
  16036. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16037. QString placeholder= argument<QString> (0,context);
  16038. QIODevice*device= argument<QIODevice*> (1,context);
  16039. device->reset();
  16040. QByteArray data;
  16041. data= device->readAll();
  16042. query->bindValue(placeholder,data);
  16043. return QScriptValue();
  16044. }
  16045. /*:178*//*179:*/
  16046. #line 4128 "./typica.w"
  16047. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16048. {
  16049. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  16050. delete query;
  16051. return QScriptValue::UndefinedValue;
  16052. }
  16053. /*:179*//*182:*/
  16054. #line 4175 "./typica.w"
  16055. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  16056. {
  16057. QFileInfo info(argument<QString> (0,context));
  16058. QScriptValue retval(engine,info.baseName());
  16059. return retval;
  16060. }
  16061. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  16062. {
  16063. QFileInfo info(argument<QString> (0,context));
  16064. QDir dir= info.dir();
  16065. QScriptValue retval(engine,dir.path());
  16066. return retval;
  16067. }
  16068. /*:182*//*183:*/
  16069. #line 4194 "./typica.w"
  16070. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  16071. {
  16072. SqlQueryConnection h;
  16073. QSqlQuery*query= h.operator->();
  16074. QString q= "SELECT file FROM files WHERE id = :file";
  16075. query->prepare(q);
  16076. query->bindValue(":file",argument<int> (0,context));
  16077. query->exec();
  16078. query->next();
  16079. QByteArray array= query->value(0).toByteArray();
  16080. QFile file(argument<QString> (1,context));
  16081. file.open(QIODevice::WriteOnly);
  16082. file.write(array);
  16083. file.close();
  16084. return QScriptValue();
  16085. }
  16086. /*:183*//*184:*/
  16087. #line 4215 "./typica.w"
  16088. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  16089. {
  16090. QString source= argument<QString> (0,context);
  16091. source.remove(0,1);
  16092. source.chop(1);
  16093. QStringList elements= source.split(",");
  16094. QString element;
  16095. QScriptValue dest= engine->newArray(elements.size());
  16096. int i= 0;
  16097. foreach(element,elements)
  16098. {
  16099. if(element.startsWith("\"")&&element.endsWith("\""))
  16100. {
  16101. element.chop(1);
  16102. element= element.remove(0,1);
  16103. }
  16104. dest.setProperty(i,QScriptValue(engine,element));
  16105. i++;
  16106. }
  16107. return dest;
  16108. }
  16109. /*:184*//*185:*/
  16110. #line 4241 "./typica.w"
  16111. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  16112. {
  16113. QString font= argument<QString> (0,context);
  16114. QString classname;
  16115. if(context->argumentCount()> 1)
  16116. {
  16117. classname= argument<QString> (1,context);
  16118. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  16119. }
  16120. else
  16121. {
  16122. QApplication::setFont(QFont(font));
  16123. }
  16124. return QScriptValue();
  16125. }
  16126. /*:185*//*186:*/
  16127. #line 4261 "./typica.w"
  16128. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  16129. {
  16130. SqlQueryConnection h;
  16131. QSqlQuery*query= h.operator->();
  16132. QString q= "SELECT file FROM files WHERE id = :file";
  16133. query->prepare(q);
  16134. query->bindValue(":file",argument<int> (0,context));
  16135. query->exec();
  16136. query->next();
  16137. QByteArray array= query->value(0).toByteArray();
  16138. QBuffer buffer(&array);
  16139. buffer.open(QIODevice::ReadOnly);
  16140. QXmlQuery xquery;
  16141. xquery.bindVariable("profile",&buffer);
  16142. QString xq;
  16143. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  16144. xquery.setQuery(xq);
  16145. QString result;
  16146. xquery.evaluateTo(&result);
  16147. return QScriptValue(result);
  16148. }
  16149. /*:186*//*187:*/
  16150. #line 4288 "./typica.w"
  16151. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  16152. {
  16153. QWidget::setTabOrder(argument<QWidget*> (0,context),
  16154. argument<QWidget*> (1,context));
  16155. return QScriptValue();
  16156. }
  16157. /*:187*//*188:*/
  16158. #line 4299 "./typica.w"
  16159. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  16160. {
  16161. return QScriptValue(QCoreApplication::translate(
  16162. "configuration",
  16163. argument<QString> (1,context).toUtf8().data()));
  16164. }
  16165. /*:188*//*195:*/
  16166. #line 4551 "./typica.w"
  16167. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  16168. {
  16169. QString targetID= argument<QString> (0,context);
  16170. QDomNode element;
  16171. QScriptValue object;
  16172. /*197:*/
  16173. #line 4598 "./typica.w"
  16174. QDomNodeList windows=
  16175. AppInstance->configuration()->documentElement().elementsByTagName("window");
  16176. QDomNode nullNode;
  16177. int i= 0;
  16178. element= nullNode;
  16179. while(i<windows.count())
  16180. {
  16181. element= windows.at(i);
  16182. QDomNamedNodeMap attributes= element.attributes();
  16183. if(attributes.contains("id"))
  16184. {
  16185. if(attributes.namedItem("id").toAttr().value()==targetID)
  16186. {
  16187. break;
  16188. }
  16189. }
  16190. element= nullNode;
  16191. i++;
  16192. }
  16193. /*:197*/
  16194. #line 4557 "./typica.w"
  16195. if(!element.isNull())
  16196. {
  16197. /*198:*/
  16198. #line 4630 "./typica.w"
  16199. ScriptQMainWindow*window= new ScriptQMainWindow;
  16200. window->setObjectName(targetID);
  16201. object= engine->newQObject(window);
  16202. setQMainWindowProperties(object,engine);
  16203. QWidget*central= new(QWidget);
  16204. central->setParent(window);
  16205. central->setObjectName("centralWidget");
  16206. window->setCentralWidget(central);
  16207. if(element.hasChildNodes())
  16208. {
  16209. /*199:*/
  16210. #line 4665 "./typica.w"
  16211. QStack<QWidget*> widgetStack;
  16212. QStack<QLayout*> layoutStack;
  16213. QString windowScript;
  16214. widgetStack.push(central);
  16215. QDomNodeList windowChildren= element.childNodes();
  16216. int i= 0;
  16217. while(i<windowChildren.count())
  16218. {
  16219. QDomNode current;
  16220. QDomElement element;
  16221. current= windowChildren.at(i);
  16222. if(current.isElement())
  16223. {
  16224. element= current.toElement();
  16225. if(element.tagName()=="program")
  16226. {
  16227. windowScript.append(element.text());
  16228. }
  16229. else if(element.tagName()=="layout")
  16230. {
  16231. element.setAttribute("trcontext","configuration");
  16232. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16233. }
  16234. else if(element.tagName()=="menu")
  16235. {
  16236. /*200:*/
  16237. #line 4713 "./typica.w"
  16238. QMenuBar*bar= window->menuBar();
  16239. bar->setParent(window);
  16240. bar->setObjectName("menuBar");
  16241. if(element.hasAttribute("name"))
  16242. {
  16243. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16244. element.attribute("name").toUtf8().data()));
  16245. menu->setParent(bar);
  16246. if(element.hasAttribute("type"))
  16247. {
  16248. if(element.attribute("type")=="reports")
  16249. {
  16250. if(element.hasAttribute("src"))
  16251. {
  16252. /*640:*/
  16253. #line 13840 "./typica.w"
  16254. QSettings settings;
  16255. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16256. toString()).
  16257. arg(element.attribute("src"));
  16258. QDir::addSearchPath("reports",reportDirectory);
  16259. QDir directory(reportDirectory);
  16260. directory.setFilter(QDir::Files);
  16261. directory.setSorting(QDir::Name);
  16262. QStringList nameFilter;
  16263. nameFilter<<"*.xml";
  16264. directory.setNameFilters(nameFilter);
  16265. QFileInfoList reportFiles= directory.entryInfoList();
  16266. for(int i= 0;i<reportFiles.size();i++)
  16267. {
  16268. QFileInfo reportFile= reportFiles.at(i);
  16269. /*644:*/
  16270. #line 13920 "./typica.w"
  16271. QString path= reportFile.absoluteFilePath();
  16272. QFile file(path);
  16273. if(file.open(QIODevice::ReadOnly))
  16274. {
  16275. QDomDocument document;
  16276. document.setContent(&file,true);
  16277. QDomElement root= document.documentElement();
  16278. QString translationContext= root.attribute("id");
  16279. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16280. if(!titleNode.isNull())
  16281. {
  16282. QDomElement titleElement= titleNode.toElement();
  16283. QString title= QCoreApplication::translate("configuration",
  16284. titleElement.text().toUtf8().data());
  16285. if(!title.isEmpty())
  16286. {
  16287. QStringList hierarchy= title.split(":->");
  16288. QMenu*insertionPoint= menu;
  16289. /*645:*/
  16290. #line 13949 "./typica.w"
  16291. for(int j= 0;j<hierarchy.size()-1;j++)
  16292. {
  16293. QObjectList menuList= insertionPoint->children();
  16294. bool menuFound= false;
  16295. for(int k= 0;k<menuList.size();k++)
  16296. {
  16297. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16298. if(currentItem)
  16299. {
  16300. if(currentItem->title()==hierarchy.at(j))
  16301. {
  16302. menuFound= true;
  16303. insertionPoint= currentItem;
  16304. break;
  16305. }
  16306. }
  16307. }
  16308. if(!menuFound)
  16309. {
  16310. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16311. }
  16312. }
  16313. /*:645*/
  16314. #line 13939 "./typica.w"
  16315. ReportAction*action= new ReportAction(path,hierarchy.last());
  16316. insertionPoint->addAction(action);
  16317. }
  16318. }
  16319. }
  16320. /*:644*/
  16321. #line 13856 "./typica.w"
  16322. }
  16323. /*:640*/
  16324. #line 4728 "./typica.w"
  16325. }
  16326. }
  16327. }
  16328. if(element.hasChildNodes())
  16329. {
  16330. /*201:*/
  16331. #line 4741 "./typica.w"
  16332. QDomNodeList menuItems= element.childNodes();
  16333. int j= 0;
  16334. while(j<menuItems.count())
  16335. {
  16336. QDomNode item= menuItems.at(j);
  16337. if(item.isElement())
  16338. {
  16339. QDomElement itemElement= item.toElement();
  16340. if(itemElement.tagName()=="item")
  16341. {
  16342. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16343. itemElement.text().toUtf8().data()),menu);
  16344. if(itemElement.hasAttribute("id"))
  16345. {
  16346. itemAction->setObjectName(itemElement.attribute("id"));
  16347. }
  16348. if(itemElement.hasAttribute("shortcut"))
  16349. {
  16350. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16351. }
  16352. menu->addAction(itemAction);
  16353. }
  16354. else if(itemElement.tagName()=="separator")
  16355. {
  16356. menu->addSeparator();
  16357. }
  16358. }
  16359. j++;
  16360. }
  16361. #line 1 "./helpmenu.w"
  16362. /*:201*/
  16363. #line 4734 "./typica.w"
  16364. }
  16365. }
  16366. /*:200*/
  16367. #line 4691 "./typica.w"
  16368. }
  16369. }
  16370. i++;
  16371. }
  16372. QScriptValue oldThis= context->thisObject();
  16373. context->setThisObject(object);
  16374. QScriptValue result= engine->evaluate(windowScript);
  16375. /*192:*/
  16376. #line 4447 "./typica.w"
  16377. if(engine->hasUncaughtException())
  16378. {
  16379. int line= engine->uncaughtExceptionLineNumber();
  16380. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16381. result.toString();
  16382. QString trace;
  16383. foreach(trace,engine->uncaughtExceptionBacktrace())
  16384. {
  16385. qDebug()<<trace;
  16386. }
  16387. }
  16388. /*:192*/
  16389. #line 4699 "./typica.w"
  16390. context->setThisObject(oldThis);
  16391. /*:199*/
  16392. #line 4641 "./typica.w"
  16393. }
  16394. /*202:*/
  16395. #line 9 "./helpmenu.w"
  16396. HelpMenu*helpMenu= new HelpMenu();
  16397. window->menuBar()->addMenu(helpMenu);
  16398. /*:202*/
  16399. #line 4643 "./typica.w"
  16400. window->show();
  16401. /*:198*/
  16402. #line 4560 "./typica.w"
  16403. }
  16404. return object;
  16405. }
  16406. /*:195*//*196:*/
  16407. #line 4571 "./typica.w"
  16408. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  16409. {
  16410. QString targetID= argument<QString> (0,context);
  16411. QFile file(QString("reports:%1").arg(targetID));
  16412. QScriptValue object;
  16413. if(file.open(QIODevice::ReadOnly))
  16414. {
  16415. QDomDocument document;
  16416. document.setContent(&file,true);
  16417. QDomElement element= document.documentElement();
  16418. if(!element.isNull())
  16419. {
  16420. /*198:*/
  16421. #line 4630 "./typica.w"
  16422. ScriptQMainWindow*window= new ScriptQMainWindow;
  16423. window->setObjectName(targetID);
  16424. object= engine->newQObject(window);
  16425. setQMainWindowProperties(object,engine);
  16426. QWidget*central= new(QWidget);
  16427. central->setParent(window);
  16428. central->setObjectName("centralWidget");
  16429. window->setCentralWidget(central);
  16430. if(element.hasChildNodes())
  16431. {
  16432. /*199:*/
  16433. #line 4665 "./typica.w"
  16434. QStack<QWidget*> widgetStack;
  16435. QStack<QLayout*> layoutStack;
  16436. QString windowScript;
  16437. widgetStack.push(central);
  16438. QDomNodeList windowChildren= element.childNodes();
  16439. int i= 0;
  16440. while(i<windowChildren.count())
  16441. {
  16442. QDomNode current;
  16443. QDomElement element;
  16444. current= windowChildren.at(i);
  16445. if(current.isElement())
  16446. {
  16447. element= current.toElement();
  16448. if(element.tagName()=="program")
  16449. {
  16450. windowScript.append(element.text());
  16451. }
  16452. else if(element.tagName()=="layout")
  16453. {
  16454. element.setAttribute("trcontext","configuration");
  16455. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16456. }
  16457. else if(element.tagName()=="menu")
  16458. {
  16459. /*200:*/
  16460. #line 4713 "./typica.w"
  16461. QMenuBar*bar= window->menuBar();
  16462. bar->setParent(window);
  16463. bar->setObjectName("menuBar");
  16464. if(element.hasAttribute("name"))
  16465. {
  16466. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16467. element.attribute("name").toUtf8().data()));
  16468. menu->setParent(bar);
  16469. if(element.hasAttribute("type"))
  16470. {
  16471. if(element.attribute("type")=="reports")
  16472. {
  16473. if(element.hasAttribute("src"))
  16474. {
  16475. /*640:*/
  16476. #line 13840 "./typica.w"
  16477. QSettings settings;
  16478. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16479. toString()).
  16480. arg(element.attribute("src"));
  16481. QDir::addSearchPath("reports",reportDirectory);
  16482. QDir directory(reportDirectory);
  16483. directory.setFilter(QDir::Files);
  16484. directory.setSorting(QDir::Name);
  16485. QStringList nameFilter;
  16486. nameFilter<<"*.xml";
  16487. directory.setNameFilters(nameFilter);
  16488. QFileInfoList reportFiles= directory.entryInfoList();
  16489. for(int i= 0;i<reportFiles.size();i++)
  16490. {
  16491. QFileInfo reportFile= reportFiles.at(i);
  16492. /*644:*/
  16493. #line 13920 "./typica.w"
  16494. QString path= reportFile.absoluteFilePath();
  16495. QFile file(path);
  16496. if(file.open(QIODevice::ReadOnly))
  16497. {
  16498. QDomDocument document;
  16499. document.setContent(&file,true);
  16500. QDomElement root= document.documentElement();
  16501. QString translationContext= root.attribute("id");
  16502. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16503. if(!titleNode.isNull())
  16504. {
  16505. QDomElement titleElement= titleNode.toElement();
  16506. QString title= QCoreApplication::translate("configuration",
  16507. titleElement.text().toUtf8().data());
  16508. if(!title.isEmpty())
  16509. {
  16510. QStringList hierarchy= title.split(":->");
  16511. QMenu*insertionPoint= menu;
  16512. /*645:*/
  16513. #line 13949 "./typica.w"
  16514. for(int j= 0;j<hierarchy.size()-1;j++)
  16515. {
  16516. QObjectList menuList= insertionPoint->children();
  16517. bool menuFound= false;
  16518. for(int k= 0;k<menuList.size();k++)
  16519. {
  16520. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16521. if(currentItem)
  16522. {
  16523. if(currentItem->title()==hierarchy.at(j))
  16524. {
  16525. menuFound= true;
  16526. insertionPoint= currentItem;
  16527. break;
  16528. }
  16529. }
  16530. }
  16531. if(!menuFound)
  16532. {
  16533. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16534. }
  16535. }
  16536. /*:645*/
  16537. #line 13939 "./typica.w"
  16538. ReportAction*action= new ReportAction(path,hierarchy.last());
  16539. insertionPoint->addAction(action);
  16540. }
  16541. }
  16542. }
  16543. /*:644*/
  16544. #line 13856 "./typica.w"
  16545. }
  16546. /*:640*/
  16547. #line 4728 "./typica.w"
  16548. }
  16549. }
  16550. }
  16551. if(element.hasChildNodes())
  16552. {
  16553. /*201:*/
  16554. #line 4741 "./typica.w"
  16555. QDomNodeList menuItems= element.childNodes();
  16556. int j= 0;
  16557. while(j<menuItems.count())
  16558. {
  16559. QDomNode item= menuItems.at(j);
  16560. if(item.isElement())
  16561. {
  16562. QDomElement itemElement= item.toElement();
  16563. if(itemElement.tagName()=="item")
  16564. {
  16565. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16566. itemElement.text().toUtf8().data()),menu);
  16567. if(itemElement.hasAttribute("id"))
  16568. {
  16569. itemAction->setObjectName(itemElement.attribute("id"));
  16570. }
  16571. if(itemElement.hasAttribute("shortcut"))
  16572. {
  16573. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16574. }
  16575. menu->addAction(itemAction);
  16576. }
  16577. else if(itemElement.tagName()=="separator")
  16578. {
  16579. menu->addSeparator();
  16580. }
  16581. }
  16582. j++;
  16583. }
  16584. #line 1 "./helpmenu.w"
  16585. /*:201*/
  16586. #line 4734 "./typica.w"
  16587. }
  16588. }
  16589. /*:200*/
  16590. #line 4691 "./typica.w"
  16591. }
  16592. }
  16593. i++;
  16594. }
  16595. QScriptValue oldThis= context->thisObject();
  16596. context->setThisObject(object);
  16597. QScriptValue result= engine->evaluate(windowScript);
  16598. /*192:*/
  16599. #line 4447 "./typica.w"
  16600. if(engine->hasUncaughtException())
  16601. {
  16602. int line= engine->uncaughtExceptionLineNumber();
  16603. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16604. result.toString();
  16605. QString trace;
  16606. foreach(trace,engine->uncaughtExceptionBacktrace())
  16607. {
  16608. qDebug()<<trace;
  16609. }
  16610. }
  16611. /*:192*/
  16612. #line 4699 "./typica.w"
  16613. context->setThisObject(oldThis);
  16614. /*:199*/
  16615. #line 4641 "./typica.w"
  16616. }
  16617. /*202:*/
  16618. #line 9 "./helpmenu.w"
  16619. HelpMenu*helpMenu= new HelpMenu();
  16620. window->menuBar()->addMenu(helpMenu);
  16621. /*:202*/
  16622. #line 4643 "./typica.w"
  16623. window->show();
  16624. /*:198*/
  16625. #line 4584 "./typica.w"
  16626. }
  16627. file.close();
  16628. }
  16629. return object;
  16630. }
  16631. /*:196*//*214:*/
  16632. #line 4786 "./typica.w"
  16633. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16634. QStack<QLayout*> *layoutStack)
  16635. {
  16636. if(element.hasAttribute("type"))
  16637. {
  16638. /*215:*/
  16639. #line 4807 "./typica.w"
  16640. QLayout*layout;
  16641. QString layoutType= element.attribute("type");
  16642. if(layoutType=="horizontal")
  16643. {
  16644. layout= new QHBoxLayout;
  16645. layoutStack->push(layout);
  16646. populateBoxLayout(element,widgetStack,layoutStack);
  16647. }
  16648. else if(layoutType=="vertical")
  16649. {
  16650. layout= new QVBoxLayout;
  16651. layoutStack->push(layout);
  16652. populateBoxLayout(element,widgetStack,layoutStack);
  16653. }
  16654. else if(layoutType=="grid")
  16655. {
  16656. layout= new QGridLayout;
  16657. layoutStack->push(layout);
  16658. populateGridLayout(element,widgetStack,layoutStack);
  16659. }
  16660. else if(layoutType=="stack")
  16661. {
  16662. layout= new QStackedLayout;
  16663. layoutStack->push(layout);
  16664. populateStackedLayout(element,widgetStack,layoutStack);
  16665. }
  16666. if(element.hasAttribute("id"))
  16667. {
  16668. layout->setObjectName(element.attribute("id"));
  16669. }
  16670. if(element.hasAttribute("spacing"))
  16671. {
  16672. layout->setSpacing(element.attribute("spacing").toInt());
  16673. }
  16674. if(element.hasAttribute("margin"))
  16675. {
  16676. int m= element.attribute("margin").toInt();
  16677. layout->setContentsMargins(m,m,m,m);
  16678. }
  16679. /*:215*/
  16680. #line 4792 "./typica.w"
  16681. QWidget*widget= widgetStack->top();
  16682. if(layout)
  16683. {
  16684. widget->setLayout(layout);
  16685. }
  16686. layoutStack->pop();
  16687. }
  16688. }
  16689. /*:214*//*216:*/
  16690. #line 4854 "./typica.w"
  16691. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16692. QStack<QLayout*> *layoutStack)
  16693. {
  16694. QDomNodeList children= element.childNodes();
  16695. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  16696. for(int i= 0;i<children.count();i++)
  16697. {
  16698. QDomNode current;
  16699. QDomElement currentElement;
  16700. current= children.at(i);
  16701. if(current.isElement())
  16702. {
  16703. currentElement= current.toElement();
  16704. if(currentElement.tagName()=="page")
  16705. {
  16706. QWidget*widget= new QWidget;
  16707. layout->addWidget(widget);
  16708. widgetStack->push(widget);
  16709. currentElement.setAttribute("trcontext","configuration");
  16710. populateWidget(currentElement,widgetStack,layoutStack);
  16711. widgetStack->pop();
  16712. }
  16713. }
  16714. }
  16715. }
  16716. /*:216*//*217:*/
  16717. #line 4887 "./typica.w"
  16718. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16719. QStack<QLayout*> *layoutStack)
  16720. {
  16721. QDomNodeList children= element.childNodes();
  16722. int row= -1;
  16723. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  16724. for(int i= 0;i<children.count();i++)
  16725. {
  16726. QDomNode current;
  16727. QDomElement currentElement;
  16728. current= children.at(i);
  16729. if(current.isElement())
  16730. {
  16731. currentElement= current.toElement();
  16732. if(currentElement.tagName()=="row")
  16733. {
  16734. row++;
  16735. if(currentElement.hasAttribute("height"))
  16736. {
  16737. layout->setRowMinimumHeight(row,
  16738. currentElement.attribute("height").toInt());
  16739. }
  16740. if(currentElement.hasAttribute("stretch"))
  16741. {
  16742. layout->setRowStretch(row,
  16743. currentElement.attribute("stretch").toInt());
  16744. }
  16745. /*218:*/
  16746. #line 4943 "./typica.w"
  16747. int column= -1;
  16748. QDomNodeList rowChildren= currentElement.childNodes();
  16749. for(int j= 0;j<rowChildren.count();j++)
  16750. {
  16751. QDomNode columnNode;
  16752. QDomElement columnElement;
  16753. columnNode= rowChildren.at(j);
  16754. if(columnNode.isElement())
  16755. {
  16756. columnElement= columnNode.toElement();
  16757. if(columnElement.tagName()=="column")
  16758. {
  16759. column++;
  16760. if(columnElement.hasAttribute("column"))
  16761. {
  16762. column= columnElement.attribute("column").toInt();
  16763. }
  16764. if(columnElement.hasAttribute("width"))
  16765. {
  16766. layout->setColumnMinimumWidth(column,
  16767. columnElement.attribute("width").toInt());
  16768. }
  16769. if(columnElement.hasAttribute("stretch"))
  16770. {
  16771. layout->setColumnStretch(column,
  16772. columnElement.attribute("stretch").toInt());
  16773. }
  16774. int hspan= 1;
  16775. int vspan= 1;
  16776. if(columnElement.hasAttribute("rowspan"))
  16777. {
  16778. vspan= columnElement.attribute("rowspan").toInt();
  16779. }
  16780. if(columnElement.hasAttribute("colspan"))
  16781. {
  16782. hspan= columnElement.attribute("colspan").toInt();
  16783. }
  16784. QHBoxLayout*cell= new QHBoxLayout;
  16785. layout->addLayout(cell,row,column,vspan,hspan);
  16786. layoutStack->push(cell);
  16787. columnElement.setAttribute("trcontext","configuration");
  16788. populateBoxLayout(columnElement,widgetStack,layoutStack);
  16789. layoutStack->pop();
  16790. }
  16791. }
  16792. }
  16793. /*:218*/
  16794. #line 4915 "./typica.w"
  16795. }
  16796. }
  16797. }
  16798. }
  16799. /*:217*//*219:*/
  16800. #line 4994 "./typica.w"
  16801. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16802. QStack<QLayout*> *layoutStack)
  16803. {
  16804. QDomNodeList children= element.childNodes();
  16805. for(int i= 0;i<children.count();i++)
  16806. {
  16807. QDomNode current;
  16808. QDomElement currentElement;
  16809. current= children.at(i);
  16810. if(current.isElement())
  16811. {
  16812. currentElement= current.toElement();
  16813. currentElement.setAttribute("trcontext","configuration");
  16814. if(currentElement.tagName()=="button")
  16815. {
  16816. addButtonToLayout(currentElement,widgetStack,layoutStack);
  16817. }
  16818. else if(currentElement.tagName()=="calendar")
  16819. {
  16820. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  16821. }
  16822. else if(currentElement.tagName()=="decoration")
  16823. {
  16824. addDecorationToLayout(currentElement,widgetStack,
  16825. layoutStack);
  16826. }
  16827. else if(currentElement.tagName()=="layout")
  16828. {
  16829. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  16830. }
  16831. else if(currentElement.tagName()=="splitter")
  16832. {
  16833. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  16834. }
  16835. else if(currentElement.tagName()=="label")
  16836. {
  16837. QBoxLayout*layout=
  16838. qobject_cast<QBoxLayout*> (layoutStack->top());
  16839. QLabel*label= new QLabel(QCoreApplication::translate(
  16840. "configuration",
  16841. currentElement.text().toUtf8().data()));
  16842. layout->addWidget(label);
  16843. }
  16844. else if(currentElement.tagName()=="lcdtemperature")
  16845. {
  16846. addTemperatureDisplayToLayout(currentElement,widgetStack,
  16847. layoutStack);
  16848. }
  16849. else if(currentElement.tagName()=="lcdtimer")
  16850. {
  16851. addTimerDisplayToLayout(currentElement,widgetStack,
  16852. layoutStack);
  16853. }
  16854. else if(currentElement.tagName()=="line")
  16855. {
  16856. addLineToLayout(currentElement,widgetStack,layoutStack);
  16857. }
  16858. else if(currentElement.tagName()=="report")
  16859. {
  16860. addReportToLayout(currentElement,widgetStack,layoutStack);
  16861. }
  16862. else if(currentElement.tagName()=="sqldrop")
  16863. {
  16864. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  16865. }
  16866. else if(currentElement.tagName()=="sqltablearray")
  16867. {
  16868. addSaltToLayout(currentElement,widgetStack,layoutStack);
  16869. }
  16870. else if(currentElement.tagName()=="sqlview")
  16871. {
  16872. addSqlQueryViewToLayout(currentElement,widgetStack,
  16873. layoutStack);
  16874. }
  16875. else if(currentElement.tagName()=="textarea")
  16876. {
  16877. addTextToLayout(currentElement,widgetStack,layoutStack);
  16878. }
  16879. else if(currentElement.tagName()=="spinbox")
  16880. {
  16881. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  16882. }
  16883. else if(currentElement.tagName()=="formarray")
  16884. {
  16885. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  16886. }
  16887. else if(currentElement.tagName()=="hscale")
  16888. {
  16889. addScaleControlToLayout(currentElement,widgetStack,
  16890. layoutStack);
  16891. }
  16892. else if(currentElement.tagName()=="vscale")
  16893. {
  16894. addIntensityControlToLayout(currentElement,widgetStack,
  16895. layoutStack);
  16896. }
  16897. else if(currentElement.tagName()=="webview")
  16898. {
  16899. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  16900. }
  16901. else if(currentElement.tagName()=="stretch")
  16902. {
  16903. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16904. layout->addStretch();
  16905. }
  16906. /*51:*/
  16907. #line 1480 "./typica.w"
  16908. else if(currentElement.tagName()=="svgwidget")
  16909. {
  16910. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  16911. }
  16912. /*:51*//*682:*/
  16913. #line 453 "./daterangeselector.w"
  16914. else if(currentElement.tagName()=="daterange")
  16915. {
  16916. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  16917. }
  16918. /*:682*/
  16919. #line 5100 "./typica.w"
  16920. }
  16921. }
  16922. }
  16923. /*:219*//*220:*/
  16924. #line 5108 "./typica.w"
  16925. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16926. QStack<QLayout*> *layoutStack)
  16927. {
  16928. QLayout*targetLayout= layoutStack->pop();
  16929. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  16930. if(element.hasAttribute("type"))
  16931. {
  16932. /*215:*/
  16933. #line 4807 "./typica.w"
  16934. QLayout*layout;
  16935. QString layoutType= element.attribute("type");
  16936. if(layoutType=="horizontal")
  16937. {
  16938. layout= new QHBoxLayout;
  16939. layoutStack->push(layout);
  16940. populateBoxLayout(element,widgetStack,layoutStack);
  16941. }
  16942. else if(layoutType=="vertical")
  16943. {
  16944. layout= new QVBoxLayout;
  16945. layoutStack->push(layout);
  16946. populateBoxLayout(element,widgetStack,layoutStack);
  16947. }
  16948. else if(layoutType=="grid")
  16949. {
  16950. layout= new QGridLayout;
  16951. layoutStack->push(layout);
  16952. populateGridLayout(element,widgetStack,layoutStack);
  16953. }
  16954. else if(layoutType=="stack")
  16955. {
  16956. layout= new QStackedLayout;
  16957. layoutStack->push(layout);
  16958. populateStackedLayout(element,widgetStack,layoutStack);
  16959. }
  16960. if(element.hasAttribute("id"))
  16961. {
  16962. layout->setObjectName(element.attribute("id"));
  16963. }
  16964. if(element.hasAttribute("spacing"))
  16965. {
  16966. layout->setSpacing(element.attribute("spacing").toInt());
  16967. }
  16968. if(element.hasAttribute("margin"))
  16969. {
  16970. int m= element.attribute("margin").toInt();
  16971. layout->setContentsMargins(m,m,m,m);
  16972. }
  16973. /*:215*/
  16974. #line 5116 "./typica.w"
  16975. boxLayout->addLayout(layout);
  16976. layoutStack->pop();
  16977. }
  16978. layoutStack->push(targetLayout);
  16979. }
  16980. /*:220*//*221:*/
  16981. #line 5127 "./typica.w"
  16982. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16983. QStack<QLayout*> *layoutStack)
  16984. {
  16985. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  16986. QSplitter*splitter= new(QSplitter);
  16987. layout->addWidget(splitter);
  16988. /*222:*/
  16989. #line 5140 "./typica.w"
  16990. QString orientation= element.attribute("type");
  16991. if(orientation=="horizontal")
  16992. {
  16993. splitter->setOrientation(Qt::Horizontal);
  16994. }
  16995. else if(orientation=="vertical")
  16996. {
  16997. splitter->setOrientation(Qt::Vertical);
  16998. }
  16999. QString id= element.attribute("id");
  17000. if(!id.isEmpty())
  17001. {
  17002. splitter->setObjectName(id);
  17003. }
  17004. if(element.hasChildNodes())
  17005. {
  17006. widgetStack->push(splitter);
  17007. populateSplitter(element,widgetStack,layoutStack);
  17008. widgetStack->pop();
  17009. }
  17010. /*:222*/
  17011. #line 5134 "./typica.w"
  17012. }
  17013. /*:221*//*223:*/
  17014. #line 5166 "./typica.w"
  17015. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17016. QStack<QLayout*> *layoutStack)
  17017. {
  17018. QDomNodeList children= element.childNodes();
  17019. for(int i= 0;i<children.count();i++)
  17020. {
  17021. QDomNode current;
  17022. QDomElement currentElement;
  17023. current= children.at(i);
  17024. if(current.isElement())
  17025. {
  17026. currentElement= current.toElement();
  17027. currentElement.setAttribute("trcontext","configuration");
  17028. if(currentElement.tagName()=="decoration")
  17029. {
  17030. addDecorationToSplitter(currentElement,widgetStack,
  17031. layoutStack);
  17032. }
  17033. else if(currentElement.tagName()=="graph")
  17034. {
  17035. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  17036. }
  17037. else if(currentElement.tagName()=="splitter")
  17038. {
  17039. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  17040. }
  17041. else if(currentElement.tagName()=="lcdtemperature")
  17042. {
  17043. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  17044. layoutStack);
  17045. }
  17046. else if(currentElement.tagName()=="lcdtimer")
  17047. {
  17048. addTimerDisplayToSplitter(currentElement,widgetStack,
  17049. layoutStack);
  17050. }
  17051. else if(currentElement.tagName()=="measurementtable")
  17052. {
  17053. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  17054. }
  17055. else if(currentElement.tagName()=="widget")
  17056. {
  17057. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  17058. }
  17059. }
  17060. }
  17061. }
  17062. /*:223*//*224:*/
  17063. #line 5217 "./typica.w"
  17064. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17065. QStack<QLayout*> *layoutStack)
  17066. {
  17067. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  17068. QSplitter*splitter= new(QSplitter);
  17069. splitter->setParent(parent);
  17070. parent->addWidget(splitter);
  17071. /*222:*/
  17072. #line 5140 "./typica.w"
  17073. QString orientation= element.attribute("type");
  17074. if(orientation=="horizontal")
  17075. {
  17076. splitter->setOrientation(Qt::Horizontal);
  17077. }
  17078. else if(orientation=="vertical")
  17079. {
  17080. splitter->setOrientation(Qt::Vertical);
  17081. }
  17082. QString id= element.attribute("id");
  17083. if(!id.isEmpty())
  17084. {
  17085. splitter->setObjectName(id);
  17086. }
  17087. if(element.hasChildNodes())
  17088. {
  17089. widgetStack->push(splitter);
  17090. populateSplitter(element,widgetStack,layoutStack);
  17091. widgetStack->pop();
  17092. }
  17093. /*:222*/
  17094. #line 5225 "./typica.w"
  17095. }
  17096. /*:224*//*225:*/
  17097. #line 5234 "./typica.w"
  17098. void addTemperatureDisplayToSplitter(QDomElement element,
  17099. QStack<QWidget*> *widgetStack,
  17100. QStack<QLayout*> *)
  17101. {
  17102. TemperatureDisplay*display= new(TemperatureDisplay);
  17103. if(element.hasAttribute("id"))
  17104. {
  17105. display->setObjectName(element.attribute("id"));
  17106. }
  17107. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17108. splitter->addWidget(display);
  17109. }
  17110. void addTemperatureDisplayToLayout(QDomElement element,
  17111. QStack<QWidget*> *,
  17112. QStack<QLayout*> *layoutStack)
  17113. {
  17114. TemperatureDisplay*display= new(TemperatureDisplay);
  17115. if(element.hasAttribute("id"))
  17116. {
  17117. display->setObjectName(element.attribute("id"));
  17118. }
  17119. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17120. layout->addWidget(display);
  17121. }
  17122. /*:225*//*226:*/
  17123. #line 5265 "./typica.w"
  17124. void addTimerDisplayToSplitter(QDomElement element,
  17125. QStack<QWidget*> *widgetStack,
  17126. QStack<QLayout*> *)
  17127. {
  17128. TimerDisplay*display= new(TimerDisplay);
  17129. if(element.hasAttribute("id"))
  17130. {
  17131. display->setObjectName(element.attribute("id"));
  17132. }
  17133. if(element.hasAttribute("format"))
  17134. {
  17135. display->setDisplayFormat(element.attribute("format"));
  17136. }
  17137. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17138. splitter->addWidget(display);
  17139. }
  17140. void addTimerDisplayToLayout(QDomElement element,
  17141. QStack<QWidget*> *,
  17142. QStack<QLayout*> *layoutStack)
  17143. {
  17144. TimerDisplay*display= new(TimerDisplay);
  17145. if(element.hasAttribute("id"))
  17146. {
  17147. display->setObjectName(element.attribute("id"));
  17148. }
  17149. if(element.hasAttribute("format"))
  17150. {
  17151. display->setDisplayFormat(element.attribute("format"));
  17152. }
  17153. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17154. layout->addWidget(display);
  17155. }
  17156. /*:226*//*227:*/
  17157. #line 5303 "./typica.w"
  17158. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  17159. QStack<QLayout*> *layoutStack)
  17160. {
  17161. /*228:*/
  17162. #line 5324 "./typica.w"
  17163. QString labelText=
  17164. QCoreApplication::translate("configuration",
  17165. element.attribute("name").toUtf8().data());
  17166. Qt::Orientations orientation= Qt::Horizontal;
  17167. if(element.hasAttribute("type"))
  17168. {
  17169. if(element.attribute("type")=="horizontal")
  17170. {
  17171. orientation= Qt::Horizontal;
  17172. }
  17173. else if(element.attribute("type")=="vertical")
  17174. {
  17175. orientation= Qt::Vertical;
  17176. }
  17177. }
  17178. /*229:*/
  17179. #line 5351 "./typica.w"
  17180. QWidget*theWidget= NULL;
  17181. QDomNodeList children= element.childNodes();
  17182. for(int i= 0;i<children.count();i++)
  17183. {
  17184. QDomNode item= children.at(i);
  17185. if(item.isElement())
  17186. {
  17187. QDomElement itemElement= item.toElement();
  17188. if(itemElement.tagName()=="lcdtemperature")
  17189. {
  17190. TemperatureDisplay*display= new TemperatureDisplay;
  17191. if(itemElement.hasAttribute("id"))
  17192. {
  17193. display->setObjectName(itemElement.attribute("id"));
  17194. }
  17195. theWidget= display;
  17196. }
  17197. else if(itemElement.tagName()=="lcdtimer")
  17198. {
  17199. TimerDisplay*display= new TimerDisplay;
  17200. if(itemElement.hasAttribute("id"))
  17201. {
  17202. display->setObjectName(itemElement.attribute("id"));
  17203. }
  17204. if(itemElement.hasAttribute("format"))
  17205. {
  17206. display->setDisplayFormat(itemElement.attribute("format"));
  17207. }
  17208. theWidget= display;
  17209. }
  17210. }
  17211. }
  17212. /*:229*/
  17213. #line 5340 "./typica.w"
  17214. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17215. orientation);
  17216. if(element.hasAttribute("id"))
  17217. {
  17218. decoration->setObjectName(element.attribute("id"));
  17219. }
  17220. /*:228*/
  17221. #line 5307 "./typica.w"
  17222. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17223. layout->addWidget(decoration);
  17224. }
  17225. void addDecorationToSplitter(QDomElement element,
  17226. QStack<QWidget*> *widgetStack,
  17227. QStack<QLayout*> *)
  17228. {
  17229. /*228:*/
  17230. #line 5324 "./typica.w"
  17231. QString labelText=
  17232. QCoreApplication::translate("configuration",
  17233. element.attribute("name").toUtf8().data());
  17234. Qt::Orientations orientation= Qt::Horizontal;
  17235. if(element.hasAttribute("type"))
  17236. {
  17237. if(element.attribute("type")=="horizontal")
  17238. {
  17239. orientation= Qt::Horizontal;
  17240. }
  17241. else if(element.attribute("type")=="vertical")
  17242. {
  17243. orientation= Qt::Vertical;
  17244. }
  17245. }
  17246. /*229:*/
  17247. #line 5351 "./typica.w"
  17248. QWidget*theWidget= NULL;
  17249. QDomNodeList children= element.childNodes();
  17250. for(int i= 0;i<children.count();i++)
  17251. {
  17252. QDomNode item= children.at(i);
  17253. if(item.isElement())
  17254. {
  17255. QDomElement itemElement= item.toElement();
  17256. if(itemElement.tagName()=="lcdtemperature")
  17257. {
  17258. TemperatureDisplay*display= new TemperatureDisplay;
  17259. if(itemElement.hasAttribute("id"))
  17260. {
  17261. display->setObjectName(itemElement.attribute("id"));
  17262. }
  17263. theWidget= display;
  17264. }
  17265. else if(itemElement.tagName()=="lcdtimer")
  17266. {
  17267. TimerDisplay*display= new TimerDisplay;
  17268. if(itemElement.hasAttribute("id"))
  17269. {
  17270. display->setObjectName(itemElement.attribute("id"));
  17271. }
  17272. if(itemElement.hasAttribute("format"))
  17273. {
  17274. display->setDisplayFormat(itemElement.attribute("format"));
  17275. }
  17276. theWidget= display;
  17277. }
  17278. }
  17279. }
  17280. /*:229*/
  17281. #line 5340 "./typica.w"
  17282. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17283. orientation);
  17284. if(element.hasAttribute("id"))
  17285. {
  17286. decoration->setObjectName(element.attribute("id"));
  17287. }
  17288. /*:228*/
  17289. #line 5316 "./typica.w"
  17290. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17291. splitter->addWidget(decoration);
  17292. }
  17293. /*:227*//*230:*/
  17294. #line 5390 "./typica.w"
  17295. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17296. QStack<QLayout*> *layoutStack)
  17297. {
  17298. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17299. QWidget*widget= new QWidget;
  17300. if(element.hasAttribute("id"))
  17301. {
  17302. widget->setObjectName(element.attribute("id"));
  17303. }
  17304. splitter->addWidget(widget);
  17305. if(element.hasChildNodes())
  17306. {
  17307. widgetStack->push(widget);
  17308. populateWidget(element,widgetStack,layoutStack);
  17309. widgetStack->pop();
  17310. }
  17311. }
  17312. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17313. QStack<QLayout*> *layoutStack)
  17314. {
  17315. QDomNodeList children= element.childNodes();
  17316. for(int i= 0;i<children.count();i++)
  17317. {
  17318. QDomNode current;
  17319. QDomElement currentElement;
  17320. current= children.at(i);
  17321. if(current.isElement())
  17322. {
  17323. currentElement= current.toElement();
  17324. if(currentElement.tagName()=="layout")
  17325. {
  17326. currentElement.setAttribute("trcontext","configuration");
  17327. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  17328. }
  17329. }
  17330. }
  17331. }
  17332. /*:230*//*231:*/
  17333. #line 5434 "./typica.w"
  17334. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  17335. QStack<QLayout*> *layoutStack)
  17336. {
  17337. QAbstractButton*button= NULL;
  17338. QString text=
  17339. QCoreApplication::translate("configuration",
  17340. element.attribute("name").toUtf8().data());
  17341. if(element.hasAttribute("type"))
  17342. {
  17343. QString type= element.attribute("type");
  17344. if(type=="annotation")
  17345. {
  17346. AnnotationButton*abutton= new AnnotationButton(text);
  17347. if(element.hasAttribute("annotation"))
  17348. {
  17349. abutton->setAnnotation(element.attribute("annotation"));
  17350. }
  17351. if(element.hasAttribute("series"))
  17352. {
  17353. abutton->setTemperatureColumn(element.attribute("series").
  17354. toInt());
  17355. }
  17356. if(element.hasAttribute("column"))
  17357. {
  17358. abutton->setAnnotationColumn(element.attribute("column").
  17359. toInt());
  17360. }
  17361. button= abutton;
  17362. }
  17363. else if(type=="check")
  17364. {
  17365. button= new QCheckBox(text);
  17366. }
  17367. else if(type=="push")
  17368. {
  17369. button= new QPushButton(text);
  17370. }
  17371. }
  17372. if(element.hasAttribute("id"))
  17373. {
  17374. button->setObjectName(element.attribute("id"));
  17375. }
  17376. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17377. layout->addWidget(button);
  17378. }
  17379. /*:231*//*232:*/
  17380. #line 5488 "./typica.w"
  17381. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  17382. QStack<QLayout*> *layoutStack)
  17383. {
  17384. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  17385. if(element.hasAttribute("pretext"))
  17386. {
  17387. box->setPretext(QCoreApplication::translate(
  17388. "configuration",
  17389. element.attribute("pretext").toUtf8().data()));
  17390. }
  17391. if(element.hasAttribute("posttext"))
  17392. {
  17393. box->setPosttext(QCoreApplication::translate(
  17394. "configuration",
  17395. element.attribute("posttext").toUtf8().data()));
  17396. }
  17397. if(element.hasAttribute("series"))
  17398. {
  17399. box->setTemperatureColumn(element.attribute("series").toInt());
  17400. }
  17401. if(element.hasAttribute("column"))
  17402. {
  17403. box->setAnnotationColumn(element.attribute("column").toInt());
  17404. }
  17405. if(element.hasAttribute("min"))
  17406. {
  17407. box->setMinimum(element.attribute("min").toDouble());
  17408. }
  17409. if(element.hasAttribute("max"))
  17410. {
  17411. box->setMaximum(element.attribute("max").toDouble());
  17412. }
  17413. if(element.hasAttribute("decimals"))
  17414. {
  17415. box->setDecimals(element.attribute("decimals").toInt());
  17416. }
  17417. if(element.hasAttribute("step"))
  17418. {
  17419. box->setSingleStep(element.attribute("step").toDouble());
  17420. }
  17421. if(element.hasAttribute("id"))
  17422. {
  17423. box->setObjectName(element.attribute("id"));
  17424. }
  17425. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17426. layout->addWidget(box);
  17427. }
  17428. /*:232*//*233:*/
  17429. #line 5548 "./typica.w"
  17430. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17431. QStack<QLayout*> *)
  17432. {
  17433. ZoomLog*widget= new ZoomLog;
  17434. if(element.hasAttribute("id"))
  17435. {
  17436. widget->setObjectName(element.attribute("id"));
  17437. }
  17438. if(element.hasChildNodes())
  17439. {
  17440. QDomNodeList children= element.childNodes();
  17441. int column= 0;
  17442. for(int i= 0;i<children.count();i++)
  17443. {
  17444. QDomNode current;
  17445. QDomElement currentElement;
  17446. current= children.at(i);
  17447. if(current.isElement())
  17448. {
  17449. currentElement= current.toElement();
  17450. if(currentElement.tagName()=="column")
  17451. {
  17452. QString text=
  17453. QCoreApplication::translate(
  17454. "configuration",
  17455. currentElement.text().toUtf8().data());
  17456. widget->setHeaderData(column,text);
  17457. column++;
  17458. }
  17459. }
  17460. }
  17461. }
  17462. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17463. if(splitter)
  17464. {
  17465. splitter->addWidget(widget);
  17466. }
  17467. else
  17468. {
  17469. qDebug()<<"Splitter not found at top of widget stack!";
  17470. }
  17471. }
  17472. /*:233*//*234:*/
  17473. #line 5595 "./typica.w"
  17474. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17475. QStack<QLayout*> *)
  17476. {
  17477. GraphView*view= new GraphView;
  17478. if(element.hasAttribute("id"))
  17479. {
  17480. view->setObjectName(element.attribute("id"));
  17481. }
  17482. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17483. splitter->addWidget(view);
  17484. }
  17485. /*:234*//*235:*/
  17486. #line 5612 "./typica.w"
  17487. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  17488. QStack<QLayout*> *layoutStack)
  17489. {
  17490. SqlComboBox*box= new SqlComboBox();
  17491. if(element.hasAttribute("data"))
  17492. {
  17493. box->setDataColumn(element.attribute("data").toInt());
  17494. }
  17495. if(element.hasAttribute("display"))
  17496. {
  17497. box->setDisplayColumn(element.attribute("display").toInt());
  17498. }
  17499. if(element.hasAttribute("showdata"))
  17500. {
  17501. if(element.attribute("showdata")=="true")
  17502. {
  17503. box->showData(true);
  17504. }
  17505. }
  17506. if(element.hasAttribute("editable"))
  17507. {
  17508. if(element.attribute("editable")=="true")
  17509. {
  17510. box->setEditable(true);
  17511. }
  17512. }
  17513. if(element.hasChildNodes())
  17514. {
  17515. QDomNodeList children= element.childNodes();
  17516. for(int i= 0;i<children.count();i++)
  17517. {
  17518. QDomNode current;
  17519. QDomElement currentElement;
  17520. current= children.at(i);
  17521. if(current.isElement())
  17522. {
  17523. currentElement= current.toElement();
  17524. if(currentElement.tagName()=="null")
  17525. {
  17526. box->addNullOption();
  17527. }
  17528. else if(currentElement.tagName()=="query")
  17529. {
  17530. box->addSqlOptions(currentElement.text());
  17531. }
  17532. }
  17533. }
  17534. }
  17535. if(element.hasAttribute("id"))
  17536. {
  17537. box->setObjectName(element.attribute("id"));
  17538. }
  17539. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17540. layout->addWidget(box);
  17541. }
  17542. /*:235*//*236:*/
  17543. #line 5691 "./typica.w"
  17544. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  17545. QStack<QLayout*> *layoutStack)
  17546. {
  17547. QTableView*view= new QTableView;
  17548. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  17549. SaltModel*model= new SaltModel(element.childNodes().count());
  17550. if(element.hasAttribute("id"))
  17551. {
  17552. view->setObjectName(element.attribute("id"));
  17553. }
  17554. if(element.hasChildNodes())
  17555. {
  17556. QDomNodeList children= element.childNodes();
  17557. int currentColumn= 0;
  17558. for(int i= 0;i<children.count();i++)
  17559. {
  17560. QDomNode current;
  17561. QDomElement currentElement;
  17562. current= children.at(i);
  17563. if(current.isElement())
  17564. {
  17565. currentElement= current.toElement();
  17566. if(currentElement.tagName()=="column")
  17567. {
  17568. if(currentElement.hasAttribute("name"))
  17569. {
  17570. model->setHeaderData(currentColumn,
  17571. Qt::Horizontal,
  17572. QCoreApplication::translate(
  17573. "configuration",
  17574. currentElement.attribute("name").toUtf8().data()));
  17575. }
  17576. if(currentElement.hasAttribute("delegate"))
  17577. {
  17578. /*237:*/
  17579. #line 5742 "./typica.w"
  17580. if(currentElement.attribute("delegate")=="sql")
  17581. {
  17582. /*238:*/
  17583. #line 5758 "./typica.w"
  17584. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  17585. SqlComboBox*widget= new SqlComboBox();
  17586. if(currentElement.hasAttribute("nulltext"))
  17587. {
  17588. widget->setNullText(currentElement.attribute("nulltext"));
  17589. }
  17590. if(currentElement.hasAttribute("nulldata"))
  17591. {
  17592. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  17593. }
  17594. if(currentElement.hasAttribute("null"))
  17595. {
  17596. if(currentElement.attribute("null")=="true")
  17597. {
  17598. widget->addNullOption();
  17599. }
  17600. }
  17601. if(currentElement.hasAttribute("showdata"))
  17602. {
  17603. if(currentElement.attribute("showdata")=="true")
  17604. {
  17605. widget->showData(true);
  17606. }
  17607. }
  17608. if(currentElement.hasAttribute("data"))
  17609. {
  17610. widget->setDataColumn(currentElement.attribute("data").toInt());
  17611. }
  17612. if(currentElement.hasAttribute("display"))
  17613. {
  17614. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  17615. }
  17616. widget->addSqlOptions(currentElement.text());
  17617. delegate->setWidget(widget);
  17618. view->setItemDelegateForColumn(currentColumn,delegate);
  17619. /*:238*/
  17620. #line 5745 "./typica.w"
  17621. }
  17622. else if(currentElement.attribute("delegate")=="numeric")
  17623. {
  17624. /*239:*/
  17625. #line 5799 "./typica.w"
  17626. NumericDelegate*delegate= new NumericDelegate;
  17627. view->setItemDelegateForColumn(currentColumn,delegate);
  17628. /*:239*/
  17629. #line 5749 "./typica.w"
  17630. }
  17631. /*:237*/
  17632. #line 5726 "./typica.w"
  17633. }
  17634. currentColumn++;
  17635. }
  17636. }
  17637. }
  17638. }
  17639. view->setModel(model);
  17640. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17641. layout->addWidget(view);
  17642. }
  17643. /*:236*//*251:*/
  17644. #line 5972 "./typica.w"
  17645. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  17646. QStack<QLayout*> *layoutStack)
  17647. {
  17648. QLineEdit*widget= new QLineEdit(element.text());
  17649. if(element.hasAttribute("id"))
  17650. {
  17651. widget->setObjectName(element.attribute("id"));
  17652. }
  17653. if(element.hasAttribute("writable"))
  17654. {
  17655. if(element.attribute("writable")=="false")
  17656. {
  17657. widget->setReadOnly(true);
  17658. }
  17659. }
  17660. if(element.hasAttribute("validator"))
  17661. {
  17662. if(element.attribute("validator")=="numeric")
  17663. {
  17664. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  17665. }
  17666. else if(element.attribute("validator")=="integer")
  17667. {
  17668. widget->setValidator(new ScriptValidator(new QIntValidator));
  17669. }
  17670. else if(element.attribute("validator")=="expression"&&
  17671. element.hasAttribute("expression"))
  17672. {
  17673. widget->setValidator(new QRegExpValidator(
  17674. QRegExp(element.attribute("expression")),
  17675. NULL));
  17676. }
  17677. }
  17678. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17679. layout->addWidget(widget);
  17680. }
  17681. /*:251*//*252:*/
  17682. #line 6013 "./typica.w"
  17683. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  17684. QStack<QLayout*> *layoutStack)
  17685. {
  17686. QTextEdit*widget= new QTextEdit;
  17687. if(element.hasAttribute("id"))
  17688. {
  17689. widget->setObjectName(element.attribute("id"));
  17690. }
  17691. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17692. layout->addWidget(widget);
  17693. }
  17694. /*:252*//*253:*/
  17695. #line 6030 "./typica.w"
  17696. void addSqlQueryViewToLayout(QDomElement element,
  17697. QStack<QWidget*> *,
  17698. QStack<QLayout*> *layoutStack)
  17699. {
  17700. SqlQueryView*view= new SqlQueryView;
  17701. if(element.hasAttribute("id"))
  17702. {
  17703. view->setObjectName(element.attribute("id"));
  17704. }
  17705. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17706. layout->addWidget(view);
  17707. }
  17708. /*:253*//*254:*/
  17709. #line 6047 "./typica.w"
  17710. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  17711. QStack<QLayout*> *layoutStack)
  17712. {
  17713. QWidget*widget;
  17714. if(element.hasAttribute("time"))
  17715. {
  17716. if(element.attribute("time")=="true")
  17717. {
  17718. QDateTimeEdit*edit= new QDateTimeEdit;
  17719. edit->setDateTime(QDateTime::currentDateTime());
  17720. edit->setCalendarPopup(true);
  17721. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  17722. widget= qobject_cast<QWidget*> (edit);
  17723. }
  17724. else
  17725. {
  17726. QDateEdit*edit= new QDateEdit;
  17727. edit->setDate(QDate::currentDate());
  17728. edit->setCalendarPopup(true);
  17729. edit->setDisplayFormat("yyyy-MM-dd");
  17730. widget= qobject_cast<QWidget*> (edit);
  17731. }
  17732. }
  17733. else
  17734. {
  17735. QDateEdit*edit= new QDateEdit;
  17736. edit->setDate(QDate::currentDate());
  17737. edit->setCalendarPopup(true);
  17738. edit->setDisplayFormat("yyyy-MM-dd");
  17739. widget= qobject_cast<QWidget*> (edit);
  17740. }
  17741. if(element.hasAttribute("id"))
  17742. {
  17743. widget->setObjectName(element.attribute("id"));
  17744. }
  17745. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17746. layout->addWidget(widget);
  17747. }
  17748. /*:254*//*255:*/
  17749. #line 6090 "./typica.w"
  17750. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  17751. {
  17752. setQDateTimeEditProperties(value,engine);
  17753. }
  17754. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  17755. {
  17756. setQAbstractSpinBoxProperties(value,engine);
  17757. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  17758. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  17759. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  17760. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  17761. value.setProperty("setToCurrentTime",
  17762. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  17763. }
  17764. /*:255*//*256:*/
  17765. #line 6112 "./typica.w"
  17766. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  17767. {
  17768. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17769. if(context->argumentCount()==3)
  17770. {
  17771. self->setDate(QDate(argument<int> (0,context),
  17772. argument<int> (1,context),
  17773. argument<int> (2,context)));
  17774. }
  17775. else
  17776. {
  17777. context->throwError("Incorrect number of arguments passed to "
  17778. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  17779. "specifying the year, month, and day.");
  17780. }
  17781. return QScriptValue();
  17782. }
  17783. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  17784. {
  17785. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17786. return QScriptValue(self->date().day());
  17787. }
  17788. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  17789. {
  17790. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17791. return QScriptValue(self->date().month());
  17792. }
  17793. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  17794. {
  17795. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17796. return QScriptValue(self->date().year());
  17797. }
  17798. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  17799. {
  17800. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17801. self->setDateTime(QDateTime::currentDateTime());
  17802. return QScriptValue();
  17803. }
  17804. /*:256*//*260:*/
  17805. #line 6187 "./typica.w"
  17806. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  17807. {
  17808. QObject*parent= argument<QObject*> (0,context);
  17809. QString name= argument<QString> (1,context);
  17810. QObject*object= parent->findChild<QObject*> (name);
  17811. QScriptValue value;
  17812. if(object)
  17813. {
  17814. value= engine->newQObject(object);
  17815. QString className= object->metaObject()->className();
  17816. /*261:*/
  17817. #line 6205 "./typica.w"
  17818. if(className=="TemperatureDisplay")
  17819. {
  17820. setTemperatureDisplayProperties(value,engine);
  17821. }
  17822. else if(className=="TimerDisplay")
  17823. {
  17824. setTimerDisplayProperties(value,engine);
  17825. }
  17826. else if(className=="QAction")
  17827. {
  17828. setQActionProperties(value,engine);
  17829. }
  17830. else if(className=="QBoxLayout")
  17831. {
  17832. setQBoxLayoutProperties(value,engine);
  17833. }
  17834. else if(className=="QDateEdit")
  17835. {
  17836. setQDateEditProperties(value,engine);
  17837. }
  17838. else if(className=="QDateTimeEdit")
  17839. {
  17840. setQDateTimeEditProperties(value,engine);
  17841. }
  17842. else if(className=="QFrame")
  17843. {
  17844. setQFrameProperties(value,engine);
  17845. }
  17846. else if(className=="QHBoxLayout")
  17847. {
  17848. setQBoxLayoutProperties(value,engine);
  17849. }
  17850. else if(className=="QLCDNumber")
  17851. {
  17852. setQLCDNumberProperties(value,engine);
  17853. }
  17854. else if(className=="QMenu")
  17855. {
  17856. setQMenuProperties(value,engine);
  17857. }
  17858. else if(className=="QMenuBar")
  17859. {
  17860. setQMenuBarProperties(value,engine);
  17861. }
  17862. else if(className=="QPushButton")
  17863. {
  17864. setQPushButtonProperties(value,engine);
  17865. }
  17866. else if(className=="QSplitter")
  17867. {
  17868. setQSplitterProperties(value,engine);
  17869. }
  17870. else if(className=="QTableView")
  17871. {
  17872. if(object->property("tabletype").isValid())
  17873. {
  17874. if(object->property("tabletype").toString()=="SaltTable")
  17875. {
  17876. setSaltTableProperties(value,engine);
  17877. }
  17878. }
  17879. }
  17880. else if(className=="QVBoxLayout")
  17881. {
  17882. setQBoxLayoutProperties(value,engine);
  17883. }
  17884. else if(className=="QWidget")
  17885. {
  17886. setQWidgetProperties(value,engine);
  17887. }
  17888. else if(className=="ScriptQMainWindow")
  17889. {
  17890. setQMainWindowProperties(value,engine);
  17891. }
  17892. else if(className=="SqlComboBox")
  17893. {
  17894. setSqlComboBoxProperties(value,engine);
  17895. }
  17896. else if(className=="SqlQueryView")
  17897. {
  17898. setSqlQueryViewProperties(value,engine);
  17899. }
  17900. else if(className=="ZoomLog")
  17901. {
  17902. setZoomLogProperties(value,engine);
  17903. }
  17904. else if(className=="QTextEdit")
  17905. {
  17906. setQTextEditProperties(value,engine);
  17907. }
  17908. else if(className=="QWebView")
  17909. {
  17910. setQWebViewProperties(value,engine);
  17911. }
  17912. else if(className=="QLineEdit")
  17913. {
  17914. setQLineEditProperties(value,engine);
  17915. }
  17916. else if(className=="QSvgWidget")
  17917. {
  17918. setQSvgWidgetProperties(value,engine);
  17919. }
  17920. /*:261*/
  17921. #line 6198 "./typica.w"
  17922. }
  17923. return value;
  17924. }
  17925. /*:260*//*263:*/
  17926. #line 6338 "./typica.w"
  17927. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  17928. {
  17929. QTableView*self= getself<QTableView*> (context);
  17930. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17931. QString datum;
  17932. double total= 0.0;
  17933. int column= argument<int> (0,context);
  17934. int role= argument<int> (1,context);
  17935. for(int i= 0;i<model->rowCount();i++)
  17936. {
  17937. datum= model->data(model->index(i,column),role).toString();
  17938. if(!datum.isEmpty())
  17939. {
  17940. total+= datum.toDouble();
  17941. }
  17942. }
  17943. return QScriptValue(engine,total);
  17944. }
  17945. /*:263*//*264:*/
  17946. #line 6362 "./typica.w"
  17947. QScriptValue SaltTable_columnArray(QScriptContext*context,
  17948. QScriptEngine*engine)
  17949. {
  17950. QTableView*self= getself<QTableView*> (context);
  17951. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17952. int column= argument<int> (0,context);
  17953. int role= argument<int> (1,context);
  17954. QString literal= model->arrayLiteral(column,role);
  17955. return QScriptValue(engine,literal);
  17956. }
  17957. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  17958. QScriptEngine*engine)
  17959. {
  17960. QTableView*self= getself<QTableView*> (context);
  17961. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17962. int column= argument<int> (0,context);
  17963. int role= argument<int> (1,context);
  17964. QString literal= model->quotedArrayLiteral(column,role);
  17965. return QScriptValue(engine,literal);
  17966. }
  17967. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  17968. QScriptEngine*engine)
  17969. {
  17970. QTableView*self= getself<QTableView*> (context);
  17971. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17972. int column= argument<int> (0,context);
  17973. int role= argument<int> (1,context);
  17974. QString literal= model->arrayLiteral(column,role);
  17975. literal.chop(1);
  17976. literal= literal.remove(0,1);
  17977. return QScriptValue(engine,literal);
  17978. }
  17979. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  17980. QScriptEngine*engine)
  17981. {
  17982. QTableView*self= getself<QTableView*> (context);
  17983. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  17984. int column= argument<int> (0,context);
  17985. int role= argument<int> (1,context);
  17986. QString literal= model->quotedArrayLiteral(column,role);
  17987. literal.chop(1);
  17988. literal= literal.remove(0,1);
  17989. return QScriptValue(engine,literal);
  17990. }
  17991. /*:264*//*265:*/
  17992. #line 6414 "./typica.w"
  17993. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  17994. {
  17995. QTableView*self= getself<QTableView*> (context);
  17996. QScriptValue value= engine->newQObject(self->model());
  17997. return value;
  17998. }
  17999. /*:265*//*266:*/
  18000. #line 6428 "./typica.w"
  18001. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  18002. {
  18003. QTableView*self= getself<QTableView*> (context);
  18004. int row= argument<int> (0,context);
  18005. int column= argument<int> (1,context);
  18006. QVariant value= argument<QVariant> (2,context);
  18007. int role= argument<int> (3,context);
  18008. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18009. QModelIndex cell= model->index(row,column);
  18010. model->setData(cell,value,role);
  18011. self->update(cell);
  18012. return QScriptValue();
  18013. }
  18014. /*:266*//*267:*/
  18015. #line 6446 "./typica.w"
  18016. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  18017. {
  18018. QTableView*self= getself<QTableView*> (context);
  18019. int row= argument<int> (0,context);
  18020. int column= argument<int> (1,context);
  18021. int role= argument<int> (2,context);
  18022. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18023. QModelIndex cell= model->index(row,column);
  18024. QVariant value= model->data(cell,role);
  18025. QScriptValue retval= engine->newVariant(value);
  18026. retval.setProperty("value",QScriptValue(value.toString()));
  18027. return retval;
  18028. }
  18029. /*:267*//*268:*/
  18030. #line 6466 "./typica.w"
  18031. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  18032. {
  18033. QTableView*self= getself<QTableView*> (context);
  18034. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18035. model->clear();
  18036. return QScriptValue();
  18037. }
  18038. /*:268*//*269:*/
  18039. #line 6478 "./typica.w"
  18040. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  18041. {
  18042. QTableView*self= getself<QTableView*> (context);
  18043. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18044. int row= argument<int> (0,context);
  18045. return engine->newVariant(model->removeRow(row));
  18046. }
  18047. /*:269*//*270:*/
  18048. #line 6491 "./typica.w"
  18049. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  18050. {
  18051. QTableView*self= getself<QTableView*> (context);
  18052. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18053. QVariant value= argument<QVariant> (0,context);
  18054. int column= argument<int> (1,context);
  18055. return engine->newVariant(model->findData(value,column));
  18056. }
  18057. /*:270*//*271:*/
  18058. #line 6504 "./typica.w"
  18059. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  18060. {
  18061. setQWidgetProperties(value,engine);
  18062. value.setProperty("columnArray",
  18063. engine->newFunction(SaltTable_columnArray));
  18064. value.setProperty("quotedColumnArray",
  18065. engine->newFunction(SaltTable_quotedColumnArray));
  18066. value.setProperty("bindableColumnArray",
  18067. engine->newFunction(SaltTable_bindableColumnArray));
  18068. value.setProperty("bindableQuotedColumnArray",
  18069. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  18070. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  18071. value.setProperty("data",engine->newFunction(SaltTable_data));
  18072. value.setProperty("model",engine->newFunction(SaltTable_model));
  18073. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  18074. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  18075. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  18076. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  18077. }
  18078. /*:271*//*273:*/
  18079. #line 6541 "./typica.w"
  18080. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18081. {
  18082. setQComboBoxProperties(value,engine);
  18083. }
  18084. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18085. {
  18086. setQWidgetProperties(value,engine);
  18087. value.setProperty("currentData",
  18088. engine->newFunction(QComboBox_currentData));
  18089. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  18090. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  18091. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  18092. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  18093. }
  18094. QScriptValue QComboBox_currentData(QScriptContext*context,
  18095. QScriptEngine*engine)
  18096. {
  18097. QComboBox*self= getself<QComboBox*> (context);
  18098. return QScriptValue(engine,
  18099. self->itemData(self->currentIndex()).toString());
  18100. }
  18101. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  18102. {
  18103. QComboBox*self= getself<QComboBox*> (context);
  18104. self->addItem(argument<QString> (0,context));
  18105. return QScriptValue();
  18106. }
  18107. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  18108. {
  18109. QComboBox*self= getself<QComboBox*> (context);
  18110. self->setModel(argument<QAbstractItemModel*> (0,context));
  18111. return QScriptValue();
  18112. }
  18113. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  18114. {
  18115. QComboBox*self= getself<QComboBox*> (context);
  18116. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  18117. }
  18118. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  18119. {
  18120. QComboBox*self= getself<QComboBox*> (context);
  18121. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  18122. }
  18123. #line 1 "./abouttypica.w"
  18124. /*:273*//*286:*/
  18125. #line 401 "./units.w"
  18126. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  18127. {
  18128. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  18129. argument<Units::Unit> (1,context),
  18130. argument<Units::Unit> (2,context)));
  18131. }
  18132. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  18133. QScriptEngine*)
  18134. {
  18135. return QScriptValue(Units::convertRelativeTemperature(
  18136. argument<double> (0,context),
  18137. argument<Units::Unit> (1,context),
  18138. argument<Units::Unit> (2,context)));
  18139. }
  18140. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  18141. {
  18142. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  18143. }
  18144. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  18145. {
  18146. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  18147. argument<Units::Unit> (1,context),
  18148. argument<Units::Unit> (2,context)));
  18149. }
  18150. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  18151. {
  18152. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  18153. }
  18154. /*:286*//*289:*/
  18155. #line 449 "./units.w"
  18156. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  18157. {
  18158. return engine->newVariant(QVariant(value));
  18159. }
  18160. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  18161. {
  18162. value= sv.toVariant().value<Units::Unit> ();
  18163. }
  18164. /*:289*//*299:*/
  18165. #line 149 "./measurement.w"
  18166. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  18167. {
  18168. QScriptValue object;
  18169. if(context->argumentCount()==2||context->argumentCount()==3)
  18170. {
  18171. double measurement= argument<double> (0,context);
  18172. QTime timestamp= argument<QTime> (1,context);
  18173. Units::Unit unit= Units::Fahrenheit;
  18174. if(context->argumentCount()==3)
  18175. {
  18176. unit= argument<Units::Unit> (2,context);
  18177. }
  18178. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  18179. setMeasurementProperties(object,engine);
  18180. }
  18181. else
  18182. {
  18183. context->throwError("Incorrect number of arguments passed to "
  18184. "Measurement::Measurement(). This method takes two "
  18185. "or three arguments.");
  18186. }
  18187. return object;
  18188. }
  18189. /*:299*//*300:*/
  18190. #line 176 "./measurement.w"
  18191. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  18192. {
  18193. }
  18194. /*:300*//*301:*/
  18195. #line 184 "./measurement.w"
  18196. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  18197. {
  18198. QVariant var;
  18199. var.setValue(measurement);
  18200. return engine->newVariant(var);
  18201. }
  18202. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  18203. {
  18204. measurement= value.toVariant().value<Measurement> ();
  18205. }
  18206. #line 6610 "./typica.w"
  18207. /*:301*//*319:*/
  18208. #line 7188 "./typica.w"
  18209. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  18210. {
  18211. QScriptValue object;
  18212. if(context->argumentCount()==1)
  18213. {
  18214. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  18215. QScriptEngine::ScriptOwnership);
  18216. setDAQProperties(object,engine);
  18217. }
  18218. else if(context->argumentCount()==2)
  18219. {
  18220. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  18221. argument<QString> (1,context)),
  18222. QScriptEngine::ScriptOwnership);
  18223. setDAQProperties(object,engine);
  18224. }
  18225. else
  18226. {
  18227. context->throwError("Incorrect number of arguments passed to DAQ"
  18228. "constructor. The DAQ constructor takes one"
  18229. "string as an argument specifying a device name."
  18230. "Example: Dev1");
  18231. }
  18232. return object;
  18233. }
  18234. /*:319*//*320:*/
  18235. #line 7218 "./typica.w"
  18236. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  18237. {
  18238. setQObjectProperties(value,engine);
  18239. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  18240. }
  18241. /*:320*//*321:*/
  18242. #line 7228 "./typica.w"
  18243. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18244. {
  18245. DAQ*self= getself<DAQ*> (context);
  18246. QScriptValue object;
  18247. if(self)
  18248. {
  18249. object=
  18250. engine->newQObject(self->newChannel(argument<int> (0,context),
  18251. argument<int> (1,context)));
  18252. setChannelProperties(object,engine);
  18253. }
  18254. return object;
  18255. }
  18256. /*:321*//*328:*/
  18257. #line 7384 "./typica.w"
  18258. QScriptValue constructFakeDAQ(QScriptContext*context,
  18259. QScriptEngine*engine)
  18260. {
  18261. QScriptValue object;
  18262. if(context->argumentCount()==1)
  18263. {
  18264. object=
  18265. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  18266. QScriptEngine::ScriptOwnership);
  18267. setFakeDAQProperties(object,engine);
  18268. }
  18269. else
  18270. {
  18271. context->throwError("Incorrect number of arguments passed to DAQ"
  18272. "constructor. The DAQ constructor takes one"
  18273. "string as an argument specifying a device name."
  18274. "Example: Dev1");
  18275. }
  18276. return object;
  18277. }
  18278. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  18279. {
  18280. setQObjectProperties(value,engine);
  18281. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  18282. }
  18283. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18284. {
  18285. FakeDAQ*self= getself<FakeDAQ*> (context);
  18286. QScriptValue object;
  18287. if(self)
  18288. {
  18289. object=
  18290. engine->newQObject(self->newChannel(argument<int> (0,context),
  18291. argument<int> (1,context)));
  18292. setChannelProperties(object,engine);
  18293. }
  18294. return object;
  18295. }
  18296. /*:328*//*332:*/
  18297. #line 7475 "./typica.w"
  18298. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  18299. {
  18300. setQObjectProperties(value,engine);
  18301. }
  18302. /*:332*//*339:*/
  18303. #line 7667 "./typica.w"
  18304. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  18305. {
  18306. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  18307. setLinearCalibratorProperties(object,engine);
  18308. return object;
  18309. }
  18310. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  18311. {
  18312. setQObjectProperties(value,engine);
  18313. }
  18314. /*:339*//*344:*/
  18315. #line 7805 "./typica.w"
  18316. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  18317. {
  18318. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  18319. setLinearSplineInterpolatorProperties(object,engine);
  18320. return object;
  18321. }
  18322. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  18323. {
  18324. setQObjectProperties(value,engine);
  18325. }
  18326. /*:344*//*354:*/
  18327. #line 8014 "./typica.w"
  18328. QScriptValue constructTemperatureDisplay(QScriptContext*,
  18329. QScriptEngine*engine)
  18330. {
  18331. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  18332. setTemperatureDisplayProperties(object,engine);
  18333. return object;
  18334. }
  18335. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18336. {
  18337. setQLCDNumberProperties(value,engine);
  18338. value.setProperty("setDisplayUnits",
  18339. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  18340. }
  18341. /*:354*//*355:*/
  18342. #line 8038 "./typica.w"
  18343. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18344. {
  18345. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  18346. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18347. return QScriptValue();
  18348. }
  18349. /*:355*//*362:*/
  18350. #line 8175 "./typica.w"
  18351. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  18352. QScriptEngine*engine)
  18353. {
  18354. QScriptValue object=
  18355. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  18356. setMeasurementTimeOffsetProperties(object,engine);
  18357. return object;
  18358. }
  18359. void setMeasurementTimeOffsetProperties(QScriptValue value,
  18360. QScriptEngine*engine)
  18361. {
  18362. setQObjectProperties(value,engine);
  18363. }
  18364. /*:362*//*367:*/
  18365. #line 8284 "./typica.w"
  18366. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  18367. {
  18368. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  18369. return object;
  18370. }
  18371. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  18372. {
  18373. setQObjectProperties(value,engine);
  18374. }
  18375. /*:367*//*372:*/
  18376. #line 8381 "./typica.w"
  18377. QScriptValue constructZeroEmitter(QScriptContext*context,
  18378. QScriptEngine*engine)
  18379. {
  18380. QScriptValue object=
  18381. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  18382. setZeroEmitterProperties(object,engine);
  18383. return object;
  18384. }
  18385. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  18386. {
  18387. setQObjectProperties(value,engine);
  18388. }
  18389. /*:372*//*377:*/
  18390. #line 8461 "./typica.w"
  18391. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  18392. QScriptEngine*engine)
  18393. {
  18394. QScriptValue object=
  18395. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  18396. setMeasurementAdapterProperties(object,engine);
  18397. return object;
  18398. }
  18399. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  18400. {
  18401. setQObjectProperties(value,engine);
  18402. }
  18403. /*:377*//*394:*/
  18404. #line 8923 "./typica.w"
  18405. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  18406. {
  18407. QScriptValue object= engine->newQObject(new GraphView);
  18408. setGraphViewProperties(object,engine);
  18409. return object;
  18410. }
  18411. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  18412. {
  18413. setQGraphicsViewProperties(value,engine);
  18414. }
  18415. /*:394*//*417:*/
  18416. #line 9561 "./typica.w"
  18417. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  18418. {
  18419. QScriptValue object= engine->newQObject(new ZoomLog);
  18420. setZoomLogProperties(object,engine);
  18421. return object;
  18422. }
  18423. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  18424. {
  18425. setQTableViewProperties(value,engine);
  18426. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  18427. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  18428. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  18429. value.setProperty("restoreState",
  18430. engine->newFunction(ZoomLog_restoreState));
  18431. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  18432. value.setProperty("saveTemporary",
  18433. engine->newFunction(ZoomLog_saveTemporary));
  18434. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  18435. }
  18436. /*:417*//*418:*/
  18437. #line 9588 "./typica.w"
  18438. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  18439. {
  18440. ZoomLog*self= getself<ZoomLog*> (context);
  18441. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  18442. return QScriptValue(engine,retval);
  18443. }
  18444. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  18445. {
  18446. ZoomLog*self= getself<ZoomLog*> (context);
  18447. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  18448. return QScriptValue(engine,retval);
  18449. }
  18450. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  18451. QScriptEngine*engine)
  18452. {
  18453. ZoomLog*self= getself<ZoomLog*> (context);
  18454. QString filename= QDir::tempPath();
  18455. filename.append("/");
  18456. filename.append(QUuid::createUuid().toString());
  18457. filename.append(".xml");
  18458. QFile*file= new QFile(filename);
  18459. self->saveXML(file);
  18460. file->close();
  18461. delete file;
  18462. return QScriptValue(engine,filename);
  18463. }
  18464. /*:418*//*419:*/
  18465. #line 9636 "./typica.w"
  18466. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  18467. {
  18468. ZoomLog*self= getself<ZoomLog*> (context);
  18469. QString key= argument<QString> (0,context);
  18470. int columns= argument<int> (1,context);
  18471. QSettings settings;
  18472. for(int i= 0;i<columns;i++)
  18473. {
  18474. if(self->columnWidth(i))
  18475. {
  18476. settings.beginGroup(key);
  18477. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  18478. settings.endGroup();
  18479. }
  18480. }
  18481. return QScriptValue();
  18482. }
  18483. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  18484. {
  18485. ZoomLog*self= getself<ZoomLog*> (context);
  18486. QString key= argument<QString> (0,context);
  18487. int columns= argument<int> (1,context);
  18488. QSettings settings;
  18489. for(int i= 0;i<columns;i++)
  18490. {
  18491. settings.beginGroup(key);
  18492. self->setColumnWidth(i,
  18493. settings.value(QString("%1").arg(i),80).toInt());
  18494. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  18495. {
  18496. self->setColumnWidth(i,80);
  18497. }
  18498. settings.endGroup();
  18499. }
  18500. return QScriptValue();
  18501. }
  18502. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  18503. {
  18504. ZoomLog*self= getself<ZoomLog*> (context);
  18505. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  18506. }
  18507. /*:419*//*420:*/
  18508. #line 9689 "./typica.w"
  18509. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18510. {
  18511. ZoomLog*self= getself<ZoomLog*> (context);
  18512. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18513. return QScriptValue();
  18514. }
  18515. /*:420*//*455:*/
  18516. #line 10509 "./typica.w"
  18517. QScriptValue constructAnnotationButton(QScriptContext*context,
  18518. QScriptEngine*engine)
  18519. {
  18520. QScriptValue object=
  18521. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  18522. setAnnotationButtonProperties(object,engine);
  18523. return object;
  18524. }
  18525. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  18526. {
  18527. setQPushButtonProperties(value,engine);
  18528. }
  18529. /*:455*//*463:*/
  18530. #line 10652 "./typica.w"
  18531. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  18532. QScriptEngine*engine)
  18533. {
  18534. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  18535. argument<QString> (0,context),argument<QString> (1,context)));
  18536. setAnnotationSpinBoxProperties(object,engine);
  18537. return object;
  18538. }
  18539. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18540. {
  18541. setQDoubleSpinBoxProperties(value,engine);
  18542. }
  18543. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18544. {
  18545. setQAbstractSpinBoxProperties(value,engine);
  18546. }
  18547. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18548. {
  18549. setQWidgetProperties(value,engine);
  18550. }
  18551. /*:463*//*484:*/
  18552. #line 11075 "./typica.w"
  18553. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  18554. {
  18555. QScriptValue object= engine->newQObject(new TimerDisplay);
  18556. setTimerDisplayProperties(object,engine);
  18557. return object;
  18558. }
  18559. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18560. {
  18561. setQLCDNumberProperties(value,engine);
  18562. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  18563. }
  18564. /*:484*//*485:*/
  18565. #line 11094 "./typica.w"
  18566. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  18567. {
  18568. TimerDisplay*self= getself<TimerDisplay*> (context);
  18569. if(self)
  18570. {
  18571. switch(argument<int> (0,context))
  18572. {
  18573. case 0:
  18574. self->setMode(TimerDisplay::CountUp);
  18575. break;
  18576. case 1:
  18577. self->setMode(TimerDisplay::CountDown);
  18578. break;
  18579. case 2:
  18580. self->setMode(TimerDisplay::Clock);
  18581. break;
  18582. default:
  18583. break;
  18584. }
  18585. }
  18586. return QScriptValue();
  18587. }
  18588. /*:485*//*512:*/
  18589. #line 11600 "./typica.w"
  18590. QScriptValue constructWidgetDecorator(QScriptContext*context,
  18591. QScriptEngine*engine)
  18592. {
  18593. QWidget*widget= argument<QWidget*> (0,context);
  18594. QString text= argument<QString> (1,context);
  18595. Qt::Orientations orientation;
  18596. switch(argument<int> (2,context))
  18597. {
  18598. case 2:
  18599. orientation= Qt::Vertical;
  18600. break;
  18601. default:
  18602. orientation= Qt::Horizontal;
  18603. break;
  18604. }
  18605. QScriptValue object=
  18606. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  18607. setWidgetDecoratorProperties(object,engine);
  18608. return object;
  18609. }
  18610. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  18611. {
  18612. setQWidgetProperties(value,engine);
  18613. }
  18614. /*:512*//*525:*/
  18615. #line 11881 "./typica.w"
  18616. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  18617. {
  18618. QScriptValue object= engine->newQObject(new LogEditWindow);
  18619. return object;
  18620. }
  18621. /*:525*//*544:*/
  18622. #line 12408 "./typica.w"
  18623. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  18624. {
  18625. QIODevice*device= argument<QIODevice*> (0,context);
  18626. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  18627. argument<int> (1,context)));
  18628. object.setProperty("input",engine->newFunction(XMLInput_input));
  18629. return object;
  18630. }
  18631. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  18632. {
  18633. XMLInput*self= getself<XMLInput*> (context);
  18634. self->input();
  18635. return QScriptValue();
  18636. }
  18637. /*:544*//*558:*/
  18638. #line 157 "./webview.w"
  18639. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  18640. {
  18641. QScriptValue object= engine->newQObject(new TypicaWebView);
  18642. setQWebViewProperties(object,engine);
  18643. return object;
  18644. }
  18645. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  18646. {
  18647. setQWidgetProperties(value,engine);
  18648. }
  18649. /*:558*//*559:*/
  18650. #line 174 "./webview.w"
  18651. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  18652. QStack<QLayout*> *layoutStack)
  18653. {
  18654. TypicaWebView*view= new TypicaWebView;
  18655. if(element.hasAttribute("id"))
  18656. {
  18657. view->setObjectName(element.attribute("id"));
  18658. }
  18659. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18660. layout->addWidget(view);
  18661. }
  18662. /*:559*//*564:*/
  18663. #line 225 "./webview.w"
  18664. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  18665. {
  18666. QVariant var;
  18667. var.setValue(element);
  18668. QScriptValue object= engine->newVariant(var);
  18669. return object;
  18670. }
  18671. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  18672. {
  18673. element= value.toVariant().value<QWebElement> ();
  18674. }
  18675. /*:564*//*569:*/
  18676. #line 290 "./webview.w"
  18677. template<> QWebElement argument(int arg,QScriptContext*context)
  18678. {
  18679. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  18680. }
  18681. /*:569*//*570:*/
  18682. #line 299 "./webview.w"
  18683. QScriptValue constructWebElement(QScriptContext*context,
  18684. QScriptEngine*engine)
  18685. {
  18686. QWebElement element= argument<QWebElement> (0,context);
  18687. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  18688. return object;
  18689. }
  18690. /*:570*//*638:*/
  18691. #line 13761 "./typica.w"
  18692. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  18693. {
  18694. QScriptValue object= engine->newQObject(new SqlQueryView);
  18695. setSqlQueryViewProperties(object,engine);
  18696. return object;
  18697. }
  18698. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  18699. {
  18700. setQTableViewProperties(value,engine);
  18701. value.setProperty("setHeaderData",
  18702. engine->newFunction(SqlQueryView_setHeaderData));
  18703. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  18704. }
  18705. /*:638*//*639:*/
  18706. #line 13779 "./typica.w"
  18707. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  18708. {
  18709. SqlQueryView*self= getself<SqlQueryView*> (context);
  18710. QString query= argument<QString> (0,context);
  18711. self->setQuery(query);
  18712. self->reset();
  18713. return QScriptValue();
  18714. }
  18715. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  18716. QScriptEngine*)
  18717. {
  18718. SqlQueryView*self= getself<SqlQueryView*> (context);
  18719. int section= argument<int> (0,context);
  18720. QString data= argument<QString> (1,context);
  18721. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  18722. return QScriptValue();
  18723. }
  18724. /*:639*//*647:*/
  18725. #line 13988 "./typica.w"
  18726. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  18727. QStack<QLayout*> *layoutStack)
  18728. {
  18729. QTextEdit*widget= new QTextEdit;
  18730. if(element.hasAttribute("id"))
  18731. {
  18732. widget->setObjectName(element.attribute("id"));
  18733. }
  18734. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18735. layout->addWidget(widget);
  18736. QTextDocument*document= new QTextDocument;
  18737. QFont defaultFont;
  18738. defaultFont.setPointSize(11);
  18739. document->setDefaultFont(defaultFont);
  18740. QTextCursor cursor(document);
  18741. /*648:*/
  18742. #line 14011 "./typica.w"
  18743. QDomNodeList children= element.childNodes();
  18744. for(int i= 0;i<children.count();i++)
  18745. {
  18746. QDomNode current;
  18747. QDomElement currentElement;
  18748. current= children.at(i);
  18749. if(current.isElement())
  18750. {
  18751. currentElement= current.toElement();
  18752. /*649:*/
  18753. #line 14028 "./typica.w"
  18754. if(currentElement.tagName()=="style")
  18755. {
  18756. document->setDefaultStyleSheet(currentElement.text());
  18757. }
  18758. /*:649*//*650:*/
  18759. #line 14039 "./typica.w"
  18760. if(currentElement.tagName()=="html")
  18761. {
  18762. cursor.insertHtml(currentElement.text());
  18763. }
  18764. /*:650*//*651:*/
  18765. #line 14049 "./typica.w"
  18766. if(currentElement.tagName()=="text")
  18767. {
  18768. cursor.insertText(currentElement.text());
  18769. }
  18770. /*:651*//*652:*/
  18771. #line 14059 "./typica.w"
  18772. if(currentElement.tagName()=="table")
  18773. {
  18774. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  18775. ReportTable*table= new ReportTable(frame,currentElement);
  18776. table->setParent(widget);
  18777. if(currentElement.hasAttribute("id"))
  18778. {
  18779. table->setObjectName(currentElement.attribute("id"));
  18780. }
  18781. }
  18782. /*:652*/
  18783. #line 14021 "./typica.w"
  18784. }
  18785. }
  18786. /*:648*/
  18787. #line 14004 "./typica.w"
  18788. widget->setDocument(document);
  18789. }
  18790. /*:647*//*663:*/
  18791. #line 14272 "./typica.w"
  18792. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  18793. {
  18794. QTextEdit*self= getself<QTextEdit*> (context);
  18795. QTextDocument*document= self->document();
  18796. QPrinter printer;
  18797. QPrintDialog printwindow(&printer,self);
  18798. if(printwindow.exec()!=QDialog::Accepted)
  18799. {
  18800. return QScriptValue();
  18801. }
  18802. document->print(&printer);
  18803. return QScriptValue();
  18804. }
  18805. /*:663*//*664:*/
  18806. #line 14290 "./typica.w"
  18807. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  18808. {
  18809. setQAbstractScrollAreaProperties(value,engine);
  18810. value.setProperty("print",engine->newFunction(QTextEdit_print));
  18811. }
  18812. #line 1 "./daterangeselector.w"
  18813. /*:664*//*683:*/
  18814. #line 463 "./daterangeselector.w"
  18815. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  18816. QStack<QLayout*> *layoutStack)
  18817. {
  18818. DateRangeSelector*widget= new DateRangeSelector;
  18819. if(element.hasAttribute("id"))
  18820. {
  18821. widget->setObjectName(element.attribute("id"));
  18822. }
  18823. if(element.hasAttribute("initial"))
  18824. {
  18825. widget->setCurrentIndex(element.attribute("initial").toInt());
  18826. }
  18827. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18828. layout->addWidget(widget);
  18829. }
  18830. /*:683*//*694:*/
  18831. #line 14470 "./typica.w"
  18832. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  18833. QStack<QLayout*> *layoutStack)
  18834. {
  18835. FormArray*widget= new FormArray(element);
  18836. if(element.hasAttribute("id"))
  18837. {
  18838. widget->setObjectName(element.attribute("id"));
  18839. }
  18840. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18841. layout->addWidget(widget);
  18842. }
  18843. /*:694*//*715:*/
  18844. #line 15057 "./typica.w"
  18845. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  18846. QStack<QLayout*> *layoutStack)
  18847. {
  18848. ScaleControl*scale= new ScaleControl;
  18849. if(element.hasAttribute("id"))
  18850. {
  18851. scale->setObjectName(element.attribute("id"));
  18852. }
  18853. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18854. layout->addWidget(scale);
  18855. }
  18856. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  18857. QStack<QLayout*> *layoutStack)
  18858. {
  18859. IntensityControl*scale= new IntensityControl;
  18860. if(element.hasAttribute("id"))
  18861. {
  18862. scale->setObjectName(element.attribute("id"));
  18863. }
  18864. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18865. layout->addWidget(scale);
  18866. }
  18867. /*:715*//*741:*/
  18868. #line 15647 "./typica.w"
  18869. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  18870. {
  18871. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  18872. setDeviceTreeModelProperties(object,engine);
  18873. return object;
  18874. }
  18875. /*:741*//*743:*/
  18876. #line 15670 "./typica.w"
  18877. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  18878. {
  18879. setQAbstractItemModelProperties(value,engine);
  18880. value.setProperty("referenceElement",
  18881. engine->newFunction(DeviceTreeModel_referenceElement));
  18882. }
  18883. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  18884. {
  18885. setQObjectProperties(value,engine);
  18886. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  18887. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  18888. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  18889. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  18890. }
  18891. /*:743*//*744:*/
  18892. #line 15697 "./typica.w"
  18893. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  18894. QScriptEngine*engine)
  18895. {
  18896. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  18897. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  18898. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  18899. QDomElement node;
  18900. QVariantMap retval;
  18901. retval.insert("driver",referenceElement.attribute("driver"));
  18902. for(int i= 0;i<configData.size();i++)
  18903. {
  18904. node= configData.at(i).toElement();
  18905. retval.insert(node.attribute("name"),node.attribute("value"));
  18906. }
  18907. return engine->toScriptValue(retval);
  18908. }
  18909. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  18910. {
  18911. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18912. QModelIndex index= argument<QModelIndex> (0,context);
  18913. int role= argument<int> (1,context);
  18914. return engine->toScriptValue(model->data(index,role));
  18915. }
  18916. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  18917. {
  18918. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18919. int row= 0;
  18920. int column= 0;
  18921. QModelIndex index;
  18922. if(context->argumentCount()> 1)
  18923. {
  18924. row= argument<int> (0,context);
  18925. column= argument<int> (1,context);
  18926. }
  18927. if(context->argumentCount()> 2)
  18928. {
  18929. index= argument<QModelIndex> (2,context);
  18930. }
  18931. QModelIndex retval= model->index(row,column,index);
  18932. return engine->toScriptValue(retval);
  18933. }
  18934. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  18935. QScriptEngine*)
  18936. {
  18937. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18938. QModelIndex index;
  18939. if(context->argumentCount()==1)
  18940. {
  18941. index= argument<QModelIndex> (0,context);
  18942. }
  18943. return QScriptValue(model->rowCount(index));
  18944. }
  18945. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  18946. QScriptEngine*engine)
  18947. {
  18948. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  18949. QModelIndex index;
  18950. if(context->argumentCount()==1)
  18951. {
  18952. index= argument<QModelIndex> (0,context);
  18953. }
  18954. return QScriptValue(engine,model->hasChildren(index));
  18955. }
  18956. /*:744*//*747:*/
  18957. #line 15781 "./typica.w"
  18958. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  18959. {
  18960. QVariant var;
  18961. var.setValue(index);
  18962. QScriptValue object= engine->newVariant(var);
  18963. return object;
  18964. }
  18965. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  18966. {
  18967. index= value.toVariant().value<QModelIndex> ();
  18968. }
  18969. /*:747*//*763:*/
  18970. #line 16079 "./typica.w"
  18971. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  18972. QScriptEngine*engine)
  18973. {
  18974. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  18975. return object;
  18976. }
  18977. /*:763*//*834:*/
  18978. #line 47 "./settings.w"
  18979. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  18980. {
  18981. QScriptValue object= engine->newQObject(new SettingsWindow);
  18982. return object;
  18983. }
  18984. /*:834*//*859:*/
  18985. #line 18732 "./typica.w"
  18986. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  18987. {
  18988. QScriptValue object;
  18989. if(context->argumentCount()==2)
  18990. {
  18991. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  18992. argument<QModelIndex> (1,context)),
  18993. QScriptEngine::ScriptOwnership);
  18994. setModbusRTUDeviceProperties(object,engine);
  18995. }
  18996. else
  18997. {
  18998. context->throwError("Incorrect number of arguments passed to "
  18999. "ModbusRTUDevice constructor. This takes the configuration model "
  19000. "and an index.");
  19001. }
  19002. return object;
  19003. }
  19004. /*:859*//*860:*/
  19005. #line 18754 "./typica.w"
  19006. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  19007. {
  19008. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19009. QScriptValue object;
  19010. if(self)
  19011. {
  19012. if(self->channels.size()> 0)
  19013. {
  19014. object= engine->newQObject(self->channels.at(0));
  19015. setChannelProperties(object,engine);
  19016. }
  19017. }
  19018. return object;
  19019. }
  19020. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  19021. {
  19022. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19023. QScriptValue object;
  19024. if(self)
  19025. {
  19026. if(self->channels.size()> 1)
  19027. {
  19028. object= engine->newQObject(self->channels.at(1));
  19029. setChannelProperties(object,engine);
  19030. }
  19031. }
  19032. return object;
  19033. }
  19034. /*:860*//*861:*/
  19035. #line 18787 "./typica.w"
  19036. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19037. {
  19038. setQObjectProperties(value,engine);
  19039. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  19040. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  19041. }
  19042. /*:861*//*877:*/
  19043. #line 650 "./modbus.w"
  19044. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  19045. {
  19046. QScriptValue object;
  19047. if(context->argumentCount()==2)
  19048. {
  19049. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  19050. argument<QModelIndex> (1,context)),
  19051. QScriptEngine::ScriptOwnership);
  19052. setModbusNGProperties(object,engine);
  19053. }
  19054. else
  19055. {
  19056. context->throwError("Incorrect number of arguments passed to "
  19057. "ModbusNG constructor.");
  19058. }
  19059. return object;
  19060. }
  19061. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  19062. {
  19063. setQObjectProperties(value,engine);
  19064. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  19065. }
  19066. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  19067. {
  19068. ModbusNG*self= getself<ModbusNG*> (context);
  19069. QScriptValue object;
  19070. if(self)
  19071. {
  19072. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19073. setChannelProperties(object,engine);
  19074. }
  19075. return object;
  19076. }
  19077. #line 19338 "./typica.w"
  19078. #line 1 "./unsupportedserial.w"
  19079. /*:877*//*891:*/
  19080. #line 357 "./unsupportedserial.w"
  19081. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  19082. {
  19083. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  19084. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  19085. QScriptValue object= engine->newQObject(device);
  19086. setQObjectProperties(object,engine);
  19087. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  19088. return object;
  19089. }
  19090. /*:891*//*896:*/
  19091. #line 430 "./unsupportedserial.w"
  19092. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  19093. {
  19094. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  19095. QScriptValue object;
  19096. if(self)
  19097. {
  19098. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19099. setChannelProperties(object,engine);
  19100. }
  19101. return object;
  19102. }
  19103. /*:896*//*903:*/
  19104. #line 630 "./unsupportedserial.w"
  19105. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  19106. {
  19107. return engine->toScriptValue<QTime> (QTime::currentTime());
  19108. }
  19109. /*:903*//*907:*/
  19110. #line 667 "./unsupportedserial.w"
  19111. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  19112. {
  19113. QScriptValue object= engine->newQObject(new QextSerialPort());
  19114. setSerialPortProperties(object,engine);
  19115. return object;
  19116. }
  19117. /*:907*//*908:*/
  19118. #line 678 "./unsupportedserial.w"
  19119. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  19120. {
  19121. setQIODeviceProperties(value,engine);
  19122. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  19123. }
  19124. /*:908*//*909:*/
  19125. #line 687 "./unsupportedserial.w"
  19126. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  19127. {
  19128. QextSerialPort*self= getself<QextSerialPort*> (context);
  19129. self->flush();
  19130. return QScriptValue();
  19131. }
  19132. /*:909*//*912:*/
  19133. #line 721 "./unsupportedserial.w"
  19134. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  19135. {
  19136. setQObjectProperties(value,engine);
  19137. }
  19138. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  19139. {
  19140. QScriptValue object= engine->newQObject(new QTimer);
  19141. setQTimerProperties(object,engine);
  19142. return object;
  19143. }
  19144. #line 19340 "./typica.w"
  19145. #line 1 "./phidgets.w"
  19146. /*:912*//*933:*/
  19147. #line 463 "./phidgets.w"
  19148. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  19149. {
  19150. if(context->argumentCount()!=1)
  19151. {
  19152. context->throwError("Incorrect number of arguments passed to "
  19153. "PhidgetsTemperatureSensor constructor. This takes "
  19154. "a QModelIndex.");
  19155. }
  19156. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  19157. setQObjectProperties(object,engine);
  19158. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  19159. return object;
  19160. }
  19161. /*:933*//*934:*/
  19162. #line 480 "./phidgets.w"
  19163. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  19164. {
  19165. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  19166. QScriptValue object;
  19167. if(self)
  19168. {
  19169. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19170. setChannelProperties(object,engine);
  19171. }
  19172. return object;
  19173. }
  19174. #line 19342 "./typica.w"
  19175. /*:934*//*966:*/
  19176. #line 151 "./rate.w"
  19177. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  19178. {
  19179. int cachetime= 1;
  19180. int scaletime= 1;
  19181. if(context->argumentCount()> 0)
  19182. {
  19183. cachetime= argument<int> (0,context);
  19184. if(context->argumentCount()> 1)
  19185. {
  19186. scaletime= argument<int> (1,context);
  19187. }
  19188. }
  19189. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  19190. setRateOfChangeProperties(object,engine);
  19191. return object;
  19192. }
  19193. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  19194. {
  19195. setQObjectProperties(value,engine);
  19196. }
  19197. /*:966*//*991:*/
  19198. #line 614 "./dataqsdk.w"
  19199. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  19200. {
  19201. QScriptValue object;
  19202. if(context->argumentCount()==1)
  19203. {
  19204. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  19205. QScriptEngine::ScriptOwnership);
  19206. setDataqSdkDeviceProperties(object,engine);
  19207. }
  19208. else
  19209. {
  19210. context->throwError("Incorrect number of arguments passed to "
  19211. "DataqSdkDevice. The constructor takes one string "
  19212. "as an argument specifying a device name. "
  19213. "Example: Dev1");
  19214. }
  19215. return object;
  19216. }
  19217. /*:991*//*992:*/
  19218. #line 637 "./dataqsdk.w"
  19219. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19220. {
  19221. setQObjectProperties(value,engine);
  19222. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  19223. }
  19224. /*:992*//*993:*/
  19225. #line 647 "./dataqsdk.w"
  19226. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  19227. {
  19228. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  19229. QScriptValue object;
  19230. if(self)
  19231. {
  19232. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  19233. setChannelProperties(object,engine);
  19234. }
  19235. return object;
  19236. }
  19237. /*:993*//*1018:*/
  19238. #line 80 "./scales.w"
  19239. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  19240. {
  19241. QScriptValue object;
  19242. QString labelText= "";
  19243. if(context->argumentCount()==1)
  19244. {
  19245. labelText= argument<QString> (0,context);
  19246. }
  19247. object= engine->newQObject(new DragLabel(labelText));
  19248. setDragLabelProperties(object,engine);
  19249. return object;
  19250. }
  19251. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  19252. {
  19253. setQLabelProperties(value,engine);
  19254. }
  19255. /*:1018*//*1028:*/
  19256. #line 298 "./scales.w"
  19257. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  19258. {
  19259. return engine->newVariant(QVariant((int)(value)));
  19260. }
  19261. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  19262. {
  19263. value= (BaudRateType)(sv.toVariant().toInt());
  19264. }
  19265. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  19266. {
  19267. return engine->newVariant(QVariant((int)(value)));
  19268. }
  19269. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  19270. {
  19271. value= (DataBitsType)(sv.toVariant().toInt());
  19272. }
  19273. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  19274. {
  19275. return engine->newVariant(QVariant((int)(value)));
  19276. }
  19277. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  19278. {
  19279. value= (ParityType)(sv.toVariant().toInt());
  19280. }
  19281. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  19282. {
  19283. return engine->newVariant(QVariant((int)(value)));
  19284. }
  19285. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  19286. {
  19287. value= (StopBitsType)(sv.toVariant().toInt());
  19288. }
  19289. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  19290. {
  19291. return engine->newVariant(QVariant((int)(value)));
  19292. }
  19293. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  19294. {
  19295. value= (FlowType)(sv.toVariant().toInt());
  19296. }
  19297. /*:1028*//*1031:*/
  19298. #line 367 "./scales.w"
  19299. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  19300. {
  19301. setQIODeviceProperties(value,engine);
  19302. }
  19303. /*:1031*//*1032:*/
  19304. #line 375 "./scales.w"
  19305. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  19306. {
  19307. QScriptValue object;
  19308. if(context->argumentCount()==1)
  19309. {
  19310. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  19311. setSerialScaleProperties(object,engine);
  19312. }
  19313. else
  19314. {
  19315. context->throwError("Incorrect number of arguments passed to "
  19316. "SerialScale. The constructor takes one string "
  19317. "as an argument specifying a port name.");
  19318. }
  19319. return object;
  19320. }
  19321. /*:1032*//*1054:*/
  19322. #line 278 "./valueannotation.w"
  19323. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  19324. {
  19325. QScriptValue object= engine->newQObject(new ValueAnnotation);
  19326. setValueAnnotationProperties(object,engine);
  19327. return object;
  19328. }
  19329. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  19330. {
  19331. setQObjectProperties(value,engine);
  19332. }
  19333. #line 19989 "./typica.w"
  19334. /*:1054*/
  19335. #line 530 "./typica.w"
  19336. /*617:*/
  19337. #line 13396 "./typica.w"
  19338. void messageFileOutput(QtMsgType,const char*msg)
  19339. {
  19340. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  19341. output.open(QIODevice::WriteOnly|QIODevice::Append);
  19342. QTextStream outstream(&output);
  19343. outstream<<msg<<"\r\n";
  19344. }
  19345. /*:617*/
  19346. #line 531 "./typica.w"
  19347. /*614:*/
  19348. #line 13357 "./typica.w"
  19349. int main(int argc,char**argv)
  19350. {
  19351. int*c= &argc;
  19352. Application app(*c,argv);
  19353. QSettings settings;
  19354. /*615:*/
  19355. #line 13383 "./typica.w"
  19356. if(settings.value("settings/advanced/logging",false).toBool())
  19357. {
  19358. qInstallMsgHandler(messageFileOutput);
  19359. }
  19360. /*:615*/
  19361. #line 13363 "./typica.w"
  19362. /*618:*/
  19363. #line 13409 "./typica.w"
  19364. QStringList themeSearchPath= QIcon::themeSearchPaths();
  19365. themeSearchPath.append(":/resources/icons/tango");
  19366. QIcon::setThemeSearchPaths(themeSearchPath);
  19367. QIcon::setThemeName(":/resources/icons/tango");
  19368. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  19369. /*:618*/
  19370. #line 13364 "./typica.w"
  19371. /*619:*/
  19372. #line 13429 "./typica.w"
  19373. QFile entypo(":/resources/fonts/entypo.ttf");
  19374. entypo.open(QIODevice::ReadOnly);
  19375. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  19376. entypo.close();
  19377. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  19378. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  19379. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  19380. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  19381. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  19382. /*:619*/
  19383. #line 13365 "./typica.w"
  19384. /*773:*/
  19385. #line 16369 "./typica.w"
  19386. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  19387. /*:773*//*783:*/
  19388. #line 16611 "./typica.w"
  19389. app.registerDeviceConfigurationWidget("nidaqmxbase",
  19390. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  19391. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  19392. NiDaqMxBase9211ConfWidget::staticMetaObject);
  19393. app.registerDeviceConfigurationWidget("ni9211seriestc",
  19394. Ni9211TcConfWidget::staticMetaObject);
  19395. /*:783*//*791:*/
  19396. #line 16842 "./typica.w"
  19397. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  19398. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  19399. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  19400. /*:791*//*815:*/
  19401. #line 17811 "./typica.w"
  19402. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  19403. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  19404. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  19405. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  19406. /*:815*//*820:*/
  19407. #line 17896 "./typica.w"
  19408. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  19409. /*:820*//*823:*/
  19410. #line 17966 "./typica.w"
  19411. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  19412. /*:823*//*826:*/
  19413. #line 18093 "./typica.w"
  19414. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  19415. #line 1 "./freeannotation.w"
  19416. /*:826*//*830:*/
  19417. #line 57 "./freeannotation.w"
  19418. app.registerDeviceConfigurationWidget("freeannotation",
  19419. FreeAnnotationConfWidget::staticMetaObject);
  19420. #line 18097 "./typica.w"
  19421. #line 1 "./settings.w"
  19422. /*:830*//*864:*/
  19423. #line 19328 "./typica.w"
  19424. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  19425. /*:864*//*870:*/
  19426. #line 317 "./modbus.w"
  19427. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  19428. app.registerDeviceConfigurationWidget("modbusnginput",
  19429. ModbusNGInputConfWidget::staticMetaObject);
  19430. /*:870*//*886:*/
  19431. #line 264 "./unsupportedserial.w"
  19432. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  19433. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  19434. app.registerDeviceConfigurationWidget("unsupporteddevice",
  19435. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  19436. /*:886*//*920:*/
  19437. #line 181 "./phidgets.w"
  19438. app.registerDeviceConfigurationWidget("phidgets1048",
  19439. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  19440. app.registerDeviceConfigurationWidget("phidgets1048channel",
  19441. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  19442. /*:920*//*940:*/
  19443. #line 19464 "./typica.w"
  19444. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  19445. /*:940*//*943:*/
  19446. #line 19524 "./typica.w"
  19447. app.registerDeviceConfigurationWidget("coolingtimer",
  19448. CoolingTimerConfWidget::staticMetaObject);
  19449. /*:943*//*948:*/
  19450. #line 19783 "./typica.w"
  19451. app.registerDeviceConfigurationWidget("rangetimer",
  19452. RangeTimerConfWidget::staticMetaObject);
  19453. /*:948*//*953:*/
  19454. #line 19884 "./typica.w"
  19455. app.registerDeviceConfigurationWidget("multirangetimer",
  19456. MultiRangeTimerConfWidget::staticMetaObject);
  19457. /*:953*//*958:*/
  19458. #line 19979 "./typica.w"
  19459. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  19460. #line 1 "./rate.w"
  19461. /*:958*//*970:*/
  19462. #line 253 "./rate.w"
  19463. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  19464. /*:970*//*1011:*/
  19465. #line 1233 "./dataqsdk.w"
  19466. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  19467. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  19468. DataqSdkChannelConfWidget::staticMetaObject);
  19469. /*:1011*//*1036:*/
  19470. #line 552 "./scales.w"
  19471. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  19472. /*:1036*//*1044:*/
  19473. #line 138 "./valueannotation.w"
  19474. app.registerDeviceConfigurationWidget("valueannotation",
  19475. ValueAnnotationConfWidget::staticMetaObject);
  19476. /*:1044*/
  19477. #line 13367 "./typica.w"
  19478. /*620:*/
  19479. #line 13446 "./typica.w"
  19480. if(settings.value("database/exists","false").toString()=="true")
  19481. {
  19482. /*625:*/
  19483. #line 13575 "./typica.w"
  19484. QSqlDatabase database=
  19485. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  19486. database.setConnectOptions("application_name=Typica");
  19487. database.setHostName(settings.value("database/hostname").toString());
  19488. database.setPort(settings.value("database/portnumber",5432).toInt());
  19489. database.setDatabaseName(settings.value("database/dbname").toString());
  19490. database.setUserName(settings.value("database/user").toString());
  19491. database.setPassword(settings.value("database/password").toString());
  19492. if(!database.open())
  19493. {
  19494. settings.setValue("database/exists","false");
  19495. }
  19496. else
  19497. {
  19498. database.close();
  19499. }
  19500. /*:625*/
  19501. #line 13449 "./typica.w"
  19502. }
  19503. if(settings.value("database/exists","false").toString()=="false")
  19504. {
  19505. /*624:*/
  19506. #line 13566 "./typica.w"
  19507. SqlConnectionSetup dialog;
  19508. dialog.exec();
  19509. /*:624*/
  19510. #line 13453 "./typica.w"
  19511. }
  19512. /*:620*/
  19513. #line 13368 "./typica.w"
  19514. /*189:*/
  19515. #line 4333 "./typica.w"
  19516. QStringList arguments= QCoreApplication::arguments();
  19517. int position= arguments.indexOf("-c");
  19518. QString filename= QString();
  19519. if(position!=-1)
  19520. {
  19521. if(arguments.size()>=position+1)
  19522. {
  19523. filename= arguments.at(position+1);
  19524. }
  19525. }
  19526. if(filename.isEmpty())
  19527. {
  19528. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  19529. settings.value("config","").toString());
  19530. }
  19531. QDir directory;
  19532. if(!filename.isEmpty())
  19533. {
  19534. QFile file(filename);
  19535. QFileInfo info(filename);
  19536. directory= info.dir();
  19537. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  19538. QTranslator*configtr= new QTranslator;
  19539. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  19540. QString("%1/Translations").arg(directory.canonicalPath())))
  19541. {
  19542. QCoreApplication::installTranslator(configtr);
  19543. }
  19544. settings.setValue("config",directory.path());
  19545. if(file.open(QIODevice::ReadOnly))
  19546. {
  19547. app.configuration()->setContent(&file,true);
  19548. }
  19549. }
  19550. /*190:*/
  19551. #line 4374 "./typica.w"
  19552. QDomElement root= app.configuration()->documentElement();
  19553. QDomNodeList children= root.childNodes();
  19554. QString replacementDoc;
  19555. QDomDocument includedDoc;
  19556. QDomDocumentFragment fragment;
  19557. for(int i= 0;i<children.size();i++)
  19558. {
  19559. QDomNode currentNode= children.at(i);
  19560. QDomElement currentElement;
  19561. if(currentNode.nodeName()=="include")
  19562. {
  19563. currentElement= currentNode.toElement();
  19564. if(currentElement.hasAttribute("src"))
  19565. {
  19566. replacementDoc= directory.path();
  19567. replacementDoc.append('/');
  19568. replacementDoc.append(currentElement.attribute("src"));
  19569. QFile doc(replacementDoc);
  19570. if(doc.open(QIODevice::ReadOnly))
  19571. {
  19572. includedDoc.setContent(&doc,true);
  19573. fragment= includedDoc.createDocumentFragment();
  19574. fragment.appendChild(includedDoc.documentElement());
  19575. root.replaceChild(fragment,currentNode);
  19576. doc.close();
  19577. }
  19578. }
  19579. }
  19580. }
  19581. /*:190*/
  19582. #line 4368 "./typica.w"
  19583. /*:189*/
  19584. #line 13369 "./typica.w"
  19585. /*7:*/
  19586. #line 661 "./typica.w"
  19587. QScriptEngine*engine= new QScriptEngine;
  19588. QScriptValue constructor;
  19589. QScriptValue value;
  19590. /*:7*//*17:*/
  19591. #line 858 "./typica.w"
  19592. constructor= engine->newFunction(constructQWidget);
  19593. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  19594. engine->globalObject().setProperty("QWidget",value);
  19595. /*:17*//*21:*/
  19596. #line 945 "./typica.w"
  19597. constructor= engine->newFunction(displayWarning);
  19598. engine->globalObject().setProperty("displayWarning",constructor);
  19599. constructor= engine->newFunction(displayError);
  19600. engine->globalObject().setProperty("displayError",constructor);
  19601. /*:21*//*31:*/
  19602. #line 1151 "./typica.w"
  19603. constructor= engine->newFunction(constructQMainWindow);
  19604. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  19605. constructor);
  19606. engine->globalObject().setProperty("QMainWindow",value);
  19607. /*:31*//*42:*/
  19608. #line 1356 "./typica.w"
  19609. constructor= engine->newFunction(constructQFrame);
  19610. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  19611. engine->globalObject().setProperty("QFrame",value);
  19612. /*:42*//*45:*/
  19613. #line 1389 "./typica.w"
  19614. constructor= engine->newFunction(constructQLabel);
  19615. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  19616. engine->globalObject().setProperty("QLabel",value);
  19617. /*:45*//*48:*/
  19618. #line 1432 "./typica.w"
  19619. constructor= engine->newFunction(constructQSvgWidget);
  19620. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  19621. engine->globalObject().setProperty("QSvgWidget",value);
  19622. /*:48*//*54:*/
  19623. #line 1514 "./typica.w"
  19624. constructor= engine->newFunction(constructQLineEdit);
  19625. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  19626. engine->globalObject().setProperty("QLineEdit",value);
  19627. /*:54*//*58:*/
  19628. #line 1561 "./typica.w"
  19629. constructor= engine->newFunction(constructQSplitter);
  19630. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  19631. engine->globalObject().setProperty("QSplitter",value);
  19632. /*:58*//*66:*/
  19633. #line 1750 "./typica.w"
  19634. constructor= engine->newFunction(constructQBoxLayout);
  19635. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  19636. engine->globalObject().setProperty("QBoxLayout",value);
  19637. /*:66*//*70:*/
  19638. #line 1862 "./typica.w"
  19639. constructor= engine->newFunction(constructQAction);
  19640. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  19641. engine->globalObject().setProperty("QAction",value);
  19642. /*:70*//*73:*/
  19643. #line 1921 "./typica.w"
  19644. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  19645. value.setProperty("getOpenFileName",
  19646. engine->newFunction(QFileDialog_getOpenFileName));
  19647. value.setProperty("getSaveFileName",
  19648. engine->newFunction(QFileDialog_getSaveFileName));
  19649. engine->globalObject().setProperty("QFileDialog",value);
  19650. /*:73*//*78:*/
  19651. #line 2039 "./typica.w"
  19652. constructor= engine->newFunction(constructQFile);
  19653. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  19654. engine->globalObject().setProperty("QFile",value);
  19655. /*:78*//*89:*/
  19656. #line 2257 "./typica.w"
  19657. constructor= engine->newFunction(constructQProcess);
  19658. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  19659. engine->globalObject().setProperty("QProcess",value);
  19660. /*:89*//*98:*/
  19661. #line 2406 "./typica.w"
  19662. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  19663. constructor= engine->newFunction(constructQByteArray);
  19664. engine->globalObject().setProperty("QByteArray",constructor);
  19665. /*:98*//*110:*/
  19666. #line 2648 "./typica.w"
  19667. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  19668. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  19669. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  19670. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  19671. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  19672. /*:110*//*113:*/
  19673. #line 2751 "./typica.w"
  19674. constructor= engine->newFunction(constructQBuffer);
  19675. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  19676. engine->globalObject().setProperty("QBuffer",value);
  19677. /*:113*//*116:*/
  19678. #line 2800 "./typica.w"
  19679. constructor= engine->newFunction(constructXQuery);
  19680. engine->globalObject().setProperty("XQuery",constructor);
  19681. /*:116*//*122:*/
  19682. #line 2902 "./typica.w"
  19683. constructor= engine->newFunction(constructXmlWriter);
  19684. engine->globalObject().setProperty("XmlWriter",constructor);
  19685. /*:122*//*131:*/
  19686. #line 3108 "./typica.w"
  19687. constructor= engine->newFunction(constructXmlReader);
  19688. engine->globalObject().setProperty("XmlReader",constructor);
  19689. /*:131*//*138:*/
  19690. #line 3232 "./typica.w"
  19691. value= engine->newQObject(&settings);
  19692. setQSettingsProperties(value,engine);
  19693. engine->globalObject().setProperty("QSettings",value);
  19694. /*:138*//*142:*/
  19695. #line 3313 "./typica.w"
  19696. constructor= engine->newFunction(constructQLCDNumber);
  19697. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  19698. engine->globalObject().setProperty("QLCDNumber",value);
  19699. /*:142*//*145:*/
  19700. #line 3369 "./typica.w"
  19701. constructor= engine->newFunction(constructQTime);
  19702. engine->globalObject().setProperty("QTime",constructor);
  19703. /*:145*//*167:*/
  19704. #line 3882 "./typica.w"
  19705. constructor= engine->newFunction(constructQPushButton);
  19706. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  19707. engine->globalObject().setProperty("QPushButton",value);
  19708. /*:167*//*174:*/
  19709. #line 3993 "./typica.w"
  19710. constructor= engine->newFunction(constructQSqlQuery);
  19711. engine->globalObject().setProperty("QSqlQuery",constructor);
  19712. /*:174*//*181:*/
  19713. #line 4157 "./typica.w"
  19714. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  19715. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  19716. engine->globalObject().setProperty("sqlToArray",
  19717. engine->newFunction(sqlToArray));
  19718. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  19719. engine->globalObject().setProperty("annotationFromRecord",
  19720. engine->newFunction(annotationFromRecord));
  19721. engine->globalObject().setProperty("setTabOrder",
  19722. engine->newFunction(setTabOrder));
  19723. engine->globalObject().setProperty("saveFileFromDatabase",
  19724. engine->newFunction(saveFileFromDatabase));
  19725. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  19726. /*:181*//*194:*/
  19727. #line 4541 "./typica.w"
  19728. engine->globalObject().setProperty("createWindow",
  19729. engine->newFunction(createWindow));
  19730. engine->globalObject().setProperty("createReport",
  19731. engine->newFunction(createReport));
  19732. /*:194*//*259:*/
  19733. #line 6179 "./typica.w"
  19734. engine->globalObject().setProperty("findChildObject",
  19735. engine->newFunction(findChildObject));
  19736. /*:259*//*285:*/
  19737. #line 389 "./units.w"
  19738. value= engine->newQMetaObject(&Units::staticMetaObject);
  19739. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  19740. value.setProperty("convertRelativeTemperature",
  19741. engine->newFunction(Units_convertRelativeTemperature));
  19742. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  19743. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  19744. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  19745. engine->globalObject().setProperty("Units",value);
  19746. /*:285*//*290:*/
  19747. #line 462 "./units.w"
  19748. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  19749. #line 6603 "./typica.w"
  19750. /*:290*//*298:*/
  19751. #line 141 "./measurement.w"
  19752. constructor= engine->newFunction(constructMeasurement);
  19753. engine->globalObject().setProperty("Measurement",constructor);
  19754. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  19755. /*:298*//*318:*/
  19756. #line 7174 "./typica.w"
  19757. constructor= engine->newFunction(constructDAQ);
  19758. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  19759. value.setProperty("Fahrenheit",Units::Fahrenheit);
  19760. value.setProperty("Celsius",Units::Celsius);
  19761. value.setProperty("Kelvin",Units::Kelvin);
  19762. value.setProperty("Rankine",Units::Rankine);
  19763. engine->globalObject().setProperty("DAQ",value);
  19764. /*:318*//*327:*/
  19765. #line 7376 "./typica.w"
  19766. constructor= engine->newFunction(constructFakeDAQ);
  19767. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  19768. engine->globalObject().setProperty("FakeDAQ",value);
  19769. /*:327*//*338:*/
  19770. #line 7659 "./typica.w"
  19771. constructor= engine->newFunction(constructLinearCalibrator);
  19772. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  19773. constructor);
  19774. engine->globalObject().setProperty("LinearCalibrator",value);
  19775. /*:338*//*343:*/
  19776. #line 7798 "./typica.w"
  19777. constructor= engine->newFunction(constructLinearSplineInterpolator);
  19778. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  19779. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  19780. /*:343*//*353:*/
  19781. #line 8006 "./typica.w"
  19782. constructor= engine->newFunction(constructTemperatureDisplay);
  19783. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  19784. constructor);
  19785. engine->globalObject().setProperty("TemperatureDisplay",value);
  19786. /*:353*//*361:*/
  19787. #line 8164 "./typica.w"
  19788. constructor= engine->newFunction(constructMeasurementTimeOffset);
  19789. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  19790. constructor);
  19791. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  19792. /*:361*//*366:*/
  19793. #line 8275 "./typica.w"
  19794. constructor= engine->newFunction(constructThresholdDetector);
  19795. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  19796. engine->globalObject().setProperty("ThresholdDetector",value);
  19797. /*:366*//*371:*/
  19798. #line 8374 "./typica.w"
  19799. constructor= engine->newFunction(constructZeroEmitter);
  19800. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  19801. engine->globalObject().setProperty("ZeroEmitter",value);
  19802. /*:371*//*376:*/
  19803. #line 8453 "./typica.w"
  19804. constructor= engine->newFunction(constructMeasurementAdapter);
  19805. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  19806. constructor);
  19807. engine->globalObject().setProperty("MeasurementAdapter",value);
  19808. /*:376*//*393:*/
  19809. #line 8916 "./typica.w"
  19810. constructor= engine->newFunction(constructGraphView);
  19811. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  19812. engine->globalObject().setProperty("GraphView",value);
  19813. /*:393*//*416:*/
  19814. #line 9553 "./typica.w"
  19815. constructor= engine->newFunction(constructZoomLog);
  19816. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  19817. engine->globalObject().setProperty("ZoomLog",value);
  19818. /*:416*//*454:*/
  19819. #line 10501 "./typica.w"
  19820. constructor= engine->newFunction(constructAnnotationButton);
  19821. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  19822. constructor);
  19823. engine->globalObject().setProperty("AnnotationButton",value);
  19824. /*:454*//*462:*/
  19825. #line 10643 "./typica.w"
  19826. constructor= engine->newFunction(constructAnnotationSpinBox);
  19827. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  19828. constructor);
  19829. engine->globalObject().setProperty("AnnotationSpinBox",value);
  19830. /*:462*//*483:*/
  19831. #line 11068 "./typica.w"
  19832. constructor= engine->newFunction(constructTimerDisplay);
  19833. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  19834. engine->globalObject().setProperty("TimerDisplay",value);
  19835. /*:483*//*511:*/
  19836. #line 11592 "./typica.w"
  19837. constructor= engine->newFunction(constructWidgetDecorator);
  19838. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  19839. engine->globalObject().setProperty("WidgetDecorator",value);
  19840. /*:511*//*524:*/
  19841. #line 11874 "./typica.w"
  19842. constructor= engine->newFunction(constructLogEditWindow);
  19843. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  19844. engine->globalObject().setProperty("LogEditWindow",value);
  19845. /*:524*//*543:*/
  19846. #line 12401 "./typica.w"
  19847. constructor= engine->newFunction(constructXMLInput);
  19848. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  19849. engine->globalObject().setProperty("XMLInput",value);
  19850. /*:543*//*557:*/
  19851. #line 149 "./webview.w"
  19852. constructor= engine->newFunction(constructWebView);
  19853. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  19854. engine->globalObject().setProperty("WebView",value);
  19855. /*:557*//*565:*/
  19856. #line 241 "./webview.w"
  19857. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  19858. /*:565*//*568:*/
  19859. #line 283 "./webview.w"
  19860. constructor= engine->newFunction(constructWebElement);
  19861. engine->globalObject().setProperty("WebElement",constructor);
  19862. /*:568*//*579:*/
  19863. #line 12644 "./typica.w"
  19864. value= engine->newQObject(AppInstance);
  19865. engine->globalObject().setProperty("Application",value);
  19866. /*:579*//*637:*/
  19867. #line 13753 "./typica.w"
  19868. constructor= engine->newFunction(constructSqlQueryView);
  19869. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  19870. engine->globalObject().setProperty("SqlQueryView",value);
  19871. /*:637*//*742:*/
  19872. #line 15657 "./typica.w"
  19873. constructor= engine->newFunction(constructDeviceTreeModel);
  19874. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  19875. constructor);
  19876. engine->globalObject().setProperty("DeviceTreeModel",value);
  19877. /*:742*//*748:*/
  19878. #line 15797 "./typica.w"
  19879. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  19880. /*:748*//*764:*/
  19881. #line 16089 "./typica.w"
  19882. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  19883. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  19884. constructor);
  19885. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  19886. /*:764*//*835:*/
  19887. #line 56 "./settings.w"
  19888. constructor= engine->newFunction(constructSettingsWindow);
  19889. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  19890. engine->globalObject().setProperty("SettingsWindow",value);
  19891. #line 1 "./graphsettings.w"
  19892. /*:835*//*858:*/
  19893. #line 18723 "./typica.w"
  19894. constructor= engine->newFunction(constructModbusRTUDevice);
  19895. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  19896. engine->globalObject().setProperty("ModbusRTUDevice",value);
  19897. /*:858*//*876:*/
  19898. #line 642 "./modbus.w"
  19899. constructor= engine->newFunction(constructModbusNG);
  19900. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  19901. engine->globalObject().setProperty("ModbusNG",value);
  19902. /*:876*//*890:*/
  19903. #line 350 "./unsupportedserial.w"
  19904. engine->globalObject().setProperty("createDevice",
  19905. engine->newFunction(createDevice));
  19906. /*:890*//*902:*/
  19907. #line 622 "./unsupportedserial.w"
  19908. engine->globalObject().setProperty("getMeasurementTimestamp",
  19909. engine->newFunction(getMeasurementTimestamp));
  19910. /*:902*//*906:*/
  19911. #line 658 "./unsupportedserial.w"
  19912. constructor= engine->newFunction(constructSerialPort);
  19913. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  19914. engine->globalObject().setProperty("SerialPort",value);
  19915. /*:906*//*911:*/
  19916. #line 713 "./unsupportedserial.w"
  19917. constructor= engine->newFunction(constructQTimer);
  19918. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  19919. engine->globalObject().setProperty("Timer",value);
  19920. /*:911*//*931:*/
  19921. #line 450 "./phidgets.w"
  19922. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  19923. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  19924. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  19925. /*:931*//*965:*/
  19926. #line 144 "./rate.w"
  19927. constructor= engine->newFunction(constructRateOfChange);
  19928. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  19929. engine->globalObject().setProperty("RateOfChange",value);
  19930. /*:965*//*990:*/
  19931. #line 604 "./dataqsdk.w"
  19932. constructor= engine->newFunction(constructDataqSdkDevice);
  19933. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  19934. engine->globalObject().setProperty("DataqSdkDevice",value);
  19935. /*:990*//*1017:*/
  19936. #line 73 "./scales.w"
  19937. constructor= engine->newFunction(constructDragLabel);
  19938. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  19939. engine->globalObject().setProperty("DragLabel",value);
  19940. /*:1017*//*1025:*/
  19941. #line 265 "./scales.w"
  19942. constructor= engine->newFunction(constructSerialScale);
  19943. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  19944. engine->globalObject().setProperty("SerialScale",value);
  19945. /*:1025*//*1029:*/
  19946. #line 351 "./scales.w"
  19947. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  19948. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  19949. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  19950. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  19951. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  19952. /*:1029*//*1053:*/
  19953. #line 271 "./valueannotation.w"
  19954. constructor= engine->newFunction(constructValueAnnotation);
  19955. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  19956. engine->globalObject().setProperty("ValueAnnotation",value);
  19957. /*:1053*/
  19958. #line 13370 "./typica.w"
  19959. app.engine= engine;
  19960. /*191:*/
  19961. #line 4422 "./typica.w"
  19962. QString styleText;
  19963. QString programText;
  19964. QDomElement currentElement;
  19965. for(int i= 0;i<children.size();i++)
  19966. {
  19967. QDomNode currentNode= children.at(i);
  19968. if(currentNode.nodeName()=="style")
  19969. {
  19970. currentElement= currentNode.toElement();
  19971. styleText.append(currentElement.text());
  19972. }
  19973. else if(currentNode.nodeName()=="program")
  19974. {
  19975. currentElement= currentNode.toElement();
  19976. programText.append(currentElement.text());
  19977. }
  19978. }
  19979. app.setStyleSheet(styleText);
  19980. QScriptValue result= engine->evaluate(programText);
  19981. /*192:*/
  19982. #line 4447 "./typica.w"
  19983. if(engine->hasUncaughtException())
  19984. {
  19985. int line= engine->uncaughtExceptionLineNumber();
  19986. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  19987. result.toString();
  19988. QString trace;
  19989. foreach(trace,engine->uncaughtExceptionBacktrace())
  19990. {
  19991. qDebug()<<trace;
  19992. }
  19993. }
  19994. /*:192*/
  19995. #line 4442 "./typica.w"
  19996. /*:191*/
  19997. #line 13372 "./typica.w"
  19998. int retval= app.exec();
  19999. delete engine;
  20000. return retval;
  20001. }
  20002. /*:614*/
  20003. #line 532 "./typica.w"
  20004. #include "moc_typica.cpp"
  20005. /*:3*/