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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 619 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. #include <QtSvg>
  16. /*:5*//*6:*/
  17. #line 635 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*291:*/
  20. #line 6608 "./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 12574 "./typica.w"
  30. /*:574*//*685:*/
  31. #line 489 "./daterangeselector.w"
  32. #include "daterangeselector.h"
  33. #line 14300 "./typica.w"
  34. /*:685*//*793:*/
  35. #line 16871 "./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*//*1057:*/
  55. #line 49 "./thresholdannotation.w"
  56. #include <limits>
  57. /*:1057*/
  58. #line 525 "./typica.w"
  59. /*23:*/
  60. #line 997 "./typica.w"
  61. class ScriptQMainWindow:public QMainWindow
  62. {
  63. Q_OBJECT
  64. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  65. public:
  66. ScriptQMainWindow();
  67. QString closePrompt();
  68. public slots:
  69. void show();
  70. void saveSizeAndPosition(const QString&key);
  71. void restoreSizeAndPosition(const QString&key);
  72. void displayStatus(const QString&message= QString());
  73. void setClosePrompt(QString prompt);
  74. protected:
  75. void closeEvent(QCloseEvent*event);
  76. void showEvent(QShowEvent*event);
  77. signals:
  78. void aboutToClose(void);
  79. private:
  80. QString cprompt;
  81. };
  82. /*:23*//*169:*/
  83. #line 3921 "./typica.w"
  84. class SqlQueryConnection:public QSqlQuery
  85. {
  86. public:
  87. SqlQueryConnection(const QString&query= QString());
  88. ~SqlQueryConnection();
  89. QSqlQuery*operator->()const;
  90. private:
  91. QString connection;
  92. QSqlQuery*q;
  93. };
  94. /*:169*//*240:*/
  95. #line 5810 "./typica.w"
  96. class NumericDelegate:public QItemDelegate
  97. {
  98. Q_OBJECT
  99. public:
  100. NumericDelegate(QObject*parent= NULL);
  101. QWidget*createEditor(QWidget*parent,
  102. const QStyleOptionViewItem&option,
  103. const QModelIndex&index)const;
  104. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  105. void setModelData(QWidget*editor,QAbstractItemModel*model,
  106. const QModelIndex&index)const;
  107. void updateEditorGeometry(QWidget*editor,
  108. const QStyleOptionViewItem&option,
  109. const QModelIndex&index)const;
  110. };
  111. /*:240*//*246:*/
  112. #line 5903 "./typica.w"
  113. class ScriptValidator:public QValidator
  114. {
  115. Q_OBJECT
  116. public:
  117. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  118. void fixup(QString&input)const;
  119. QValidator::State validate(QString&input,int&pos)const;
  120. private:
  121. QValidator*v;
  122. };
  123. /*:246*//*287:*/
  124. #line 438 "./units.w"
  125. Q_DECLARE_METATYPE(Units::Unit)
  126. /*:287*//*292:*/
  127. #line 19 "./measurement.w"
  128. class Measurement:public QVariantMap
  129. {
  130. public:
  131. Measurement(double temperature= 0,QTime time= QTime(),
  132. Units::Unit sc= Units::Fahrenheit);
  133. Measurement(double temperature);
  134. double temperature()const;
  135. QTime time()const;
  136. void setTemperature(double temperature);
  137. void setTime(QTime time);
  138. void setUnit(Units::Unit scale);
  139. Units::Unit scale()const;
  140. Measurement toFahrenheit();
  141. Measurement toCelsius();
  142. Measurement toKelvin();
  143. Measurement toRankine();
  144. };
  145. /*:292*//*296:*/
  146. #line 128 "./measurement.w"
  147. Q_DECLARE_METATYPE(Measurement)
  148. /*:296*//*303:*/
  149. #line 6672 "./typica.w"
  150. class Channel;
  151. class DAQImplementation;
  152. class DAQ:public QObject
  153. {
  154. Q_OBJECT
  155. Q_ENUMS(ThermocoupleType)
  156. DAQImplementation*imp;
  157. private slots:
  158. void threadFinished();
  159. public:
  160. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  161. ~DAQ();
  162. Channel*newChannel(int units,int thermocouple);
  163. Q_INVOKABLE void setClockRate(double Hz);
  164. Q_INVOKABLE void start();
  165. Q_INVOKABLE void stop();
  166. enum ThermocoupleType
  167. {
  168. TypeJ= 10072,
  169. TypeK= 10073,
  170. TypeN= 10077,
  171. TypeR= 10082,
  172. TypeS= 10085,
  173. TypeT= 10086,
  174. TypeB= 10047,
  175. TypeE= 10055
  176. };
  177. };
  178. /*:303*//*304:*/
  179. #line 6710 "./typica.w"
  180. class DAQImplementation:public QThread
  181. {
  182. Q_OBJECT
  183. public:
  184. DAQImplementation(const QString&driverinfo);
  185. ~DAQImplementation();
  186. void run();
  187. void measure();
  188. /*305:*/
  189. #line 6730 "./typica.w"
  190. typedef int(*daqfp)(...);
  191. daqfp read;
  192. daqfp errorInfo;
  193. daqfp startTask;
  194. daqfp createTask;
  195. daqfp createChannel;
  196. daqfp setClock;
  197. daqfp stopTask;
  198. daqfp clearTask;
  199. daqfp resetDevice;
  200. daqfp waitForMeasurement;
  201. /*:305*/
  202. #line 6719 "./typica.w"
  203. /*306:*/
  204. #line 6746 "./typica.w"
  205. bool useBase;
  206. QString device;
  207. QVector<Channel*> channelMap;
  208. unsigned int handle;
  209. int error;
  210. int channels;
  211. bool ready;
  212. QLibrary driver;
  213. QVector<Units::Unit> unitMap;
  214. /*:306*/
  215. #line 6720 "./typica.w"
  216. };
  217. /*:304*//*322:*/
  218. #line 7251 "./typica.w"
  219. class FakeDAQImplementation:public QThread
  220. {
  221. Q_OBJECT
  222. public:
  223. FakeDAQImplementation();
  224. ~FakeDAQImplementation();
  225. void run();
  226. void measure();
  227. QVector<Channel*> channelMap;
  228. int channels;
  229. bool ready;
  230. double clockRate;
  231. };
  232. class FakeDAQ:public QObject
  233. {
  234. Q_OBJECT
  235. FakeDAQImplementation*imp;
  236. public:
  237. FakeDAQ(QString device);
  238. ~FakeDAQ();
  239. Channel*newChannel(int units,int thermocouple);
  240. Q_INVOKABLE void setClockRate(double Hz);
  241. Q_INVOKABLE void start();
  242. };
  243. /*:322*//*329:*/
  244. #line 7438 "./typica.w"
  245. class Channel:public QObject
  246. {
  247. Q_OBJECT
  248. public:
  249. Channel();
  250. ~Channel();
  251. public slots:
  252. void input(Measurement measurement);
  253. signals:
  254. void newData(Measurement);
  255. };
  256. /*:329*//*333:*/
  257. #line 7505 "./typica.w"
  258. class LinearCalibrator:public QObject
  259. {
  260. Q_OBJECT
  261. Q_PROPERTY(double measuredLower READ measuredLower
  262. WRITE setMeasuredLower)
  263. Q_PROPERTY(double measuredUpper READ measuredUpper
  264. WRITE setMeasuredUpper)
  265. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  266. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  267. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  268. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  269. public:
  270. LinearCalibrator(QObject*parent= NULL);
  271. double measuredLower();
  272. double measuredUpper();
  273. double mappedLower();
  274. double mappedUpper();
  275. bool isClosedRange();
  276. double sensitivity();
  277. public slots:
  278. void setMeasuredLower(double lower);
  279. void setMeasuredUpper(double upper);
  280. void setMappedLower(double lower);
  281. void setMappedUpper(double upper);
  282. void setClosedRange(bool closed);
  283. void setSensitivity(double sensitivity);
  284. Measurement newMeasurement(Measurement measure);
  285. signals:
  286. void measurement(Measurement measure);
  287. void newData(Measurement measure);
  288. private:
  289. double Lo1;
  290. double Lo2;
  291. double Up1;
  292. double Up2;
  293. double sensitivitySetting;
  294. bool clamp;
  295. };
  296. /*:333*//*340:*/
  297. #line 7701 "./typica.w"
  298. class LinearSplineInterpolator:public QObject
  299. {
  300. Q_OBJECT
  301. public:
  302. LinearSplineInterpolator(QObject*parent= NULL);
  303. Q_INVOKABLE void add_pair(double source,double destination);
  304. public slots:
  305. Measurement newMeasurement(Measurement measure);
  306. signals:
  307. void newData(Measurement measure);
  308. private:
  309. void make_interpolators();
  310. QMap<double,double> *pairs;
  311. QList<LinearCalibrator*> *interpolators;
  312. };
  313. /*:340*//*345:*/
  314. #line 7837 "./typica.w"
  315. class TemperatureDisplay:public QLCDNumber
  316. {
  317. Q_OBJECT
  318. int unit;
  319. bool r;
  320. public:
  321. TemperatureDisplay(QWidget*parent= NULL);
  322. ~TemperatureDisplay();
  323. public slots:
  324. void setValue(Measurement temperature);
  325. void invalidate();
  326. void setDisplayUnits(Units::Unit scale);
  327. void setRelativeMode(bool relative);
  328. };
  329. /*:345*//*356:*/
  330. #line 8056 "./typica.w"
  331. class MeasurementTimeOffset:public QObject
  332. {
  333. Q_OBJECT
  334. QTime epoch;
  335. QTime previous;
  336. bool hasPrevious;
  337. public:
  338. MeasurementTimeOffset(QTime zero);
  339. QTime zeroTime();
  340. public slots:
  341. void newMeasurement(Measurement measure);
  342. void setZeroTime(QTime zero);
  343. signals:
  344. void measurement(Measurement measure);
  345. };
  346. /*:356*//*363:*/
  347. #line 8208 "./typica.w"
  348. class ThresholdDetector:public QObject
  349. {
  350. Q_OBJECT
  351. Q_ENUMS(EdgeDirection)
  352. public:
  353. enum EdgeDirection{
  354. Ascending,Descending
  355. };
  356. ThresholdDetector(double value);
  357. public slots:
  358. void newMeasurement(Measurement measure);
  359. void setThreshold(double value);
  360. void setEdgeDirection(EdgeDirection direction);
  361. signals:
  362. void timeForValue(double);
  363. private:
  364. double previousValue;
  365. double threshold;
  366. EdgeDirection currentDirection;
  367. };
  368. /*:363*//*368:*/
  369. #line 8314 "./typica.w"
  370. class ZeroEmitter:public QObject
  371. {
  372. Q_OBJECT
  373. Q_PROPERTY(int column READ column WRITE setColumn)
  374. Measurement cache;
  375. int col;
  376. public:
  377. ZeroEmitter(int tempcolumn= 1);
  378. int column();
  379. double lastTemperature();
  380. public slots:
  381. void newMeasurement(Measurement measure);
  382. void setColumn(int column);
  383. void emitZero();
  384. signals:
  385. void measurement(Measurement measure,int tempcolumn);
  386. };
  387. /*:368*//*373:*/
  388. #line 8408 "./typica.w"
  389. class MeasurementAdapter:public QObject
  390. {
  391. Q_OBJECT
  392. int col;
  393. public:
  394. MeasurementAdapter(int tempcolumn);
  395. int column();
  396. public slots:
  397. void newMeasurement(Measurement measure);
  398. void setColumn(int column);
  399. signals:
  400. void measurement(Measurement measure,int tempcolumn);
  401. };
  402. /*:373*//*378:*/
  403. #line 8497 "./typica.w"
  404. class GraphView:public QGraphicsView
  405. {
  406. Q_OBJECT
  407. QGraphicsScene*theScene;
  408. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  409. QMap<int,QPointF> *prevPoints;
  410. QMap<int,double> *translations;
  411. QList<QGraphicsItem*> *gridLinesF;
  412. QList<QGraphicsItem*> *gridLinesC;
  413. QList<QGraphicsItem*> *relativeGridLines;
  414. bool relativeEnabled;
  415. bool timeIndicatorEnabled;
  416. QGraphicsLineItem*timeLine;
  417. LinearSplineInterpolator*relativeAdjuster;
  418. public:
  419. GraphView(QWidget*parent= NULL);
  420. void removeSeries(int column);
  421. protected:
  422. void resizeEvent(QResizeEvent*event);
  423. public slots:
  424. void newMeasurement(Measurement measure,int tempcolumn);
  425. void setSeriesTranslation(int column,double offset);
  426. void setTimeIndicatorEnabled(bool enabled);
  427. void clear();
  428. void showF();
  429. void showC();
  430. };
  431. /*:378*//*395:*/
  432. #line 8962 "./typica.w"
  433. class MeasurementModel;
  434. class ZoomLog:public QTableView
  435. {
  436. Q_OBJECT
  437. /*396:*/
  438. #line 9011 "./typica.w"
  439. MeasurementModel*model_ms;
  440. MeasurementModel*model_1s;
  441. MeasurementModel*model_5s;
  442. MeasurementModel*model_10s;
  443. MeasurementModel*model_15s;
  444. MeasurementModel*model_30s;
  445. MeasurementModel*model_1m;
  446. QList<MeasurementModel*> modelSet;
  447. QHash<int,Measurement> lastMeasurement;
  448. MeasurementModel*currentModel;
  449. QList<int> saveTempCols;
  450. QList<int> saveControlCols;
  451. QList<int> saveNoteCols;
  452. QList<int> currentColumnSet;
  453. /*:396*/
  454. #line 8967 "./typica.w"
  455. void switchLOD(MeasurementModel*m);
  456. private slots:
  457. void centerOn(int row);
  458. void persistColumnResize(int column,int oldsize,int newsize);
  459. void restoreColumnWidths();
  460. public:
  461. ZoomLog();
  462. QVariant data(int row,int column)const;
  463. int rowCount();
  464. bool saveXML(QIODevice*device);
  465. bool saveCSV(QIODevice*device);
  466. QString lastTime(int series);
  467. Q_INVOKABLE Units::Unit displayUnits();
  468. public slots:
  469. void setVisible(bool visibility);
  470. void setHeaderData(int section,QString text);
  471. void LOD_ms();
  472. void LOD_1s();
  473. void LOD_5s();
  474. void LOD_10s();
  475. void LOD_15s();
  476. void LOD_30s();
  477. void LOD_1m();
  478. void newMeasurement(Measurement measure,int tempcolumn);
  479. void newAnnotation(QString annotation,int tempcolumn,
  480. int annotationcolumn);
  481. void clear();
  482. void addOutputTemperatureColumn(int column);
  483. void addOutputControlColumn(int column);
  484. void addOutputAnnotationColumn(int column);
  485. void clearOutputColumns();
  486. void setDisplayUnits(Units::Unit scale);
  487. void addToCurrentColumnSet(int column);
  488. void clearCurrentColumnSet();
  489. protected:
  490. virtual void showEvent(QShowEvent*event);
  491. };
  492. /*:395*//*421:*/
  493. #line 9707 "./typica.w"
  494. class MeasurementList;
  495. class MeasurementModel:public QAbstractItemModel
  496. {
  497. Q_OBJECT
  498. Units::Unit unit;
  499. QList<MeasurementList*> *entries;
  500. QStringList*hData;
  501. int colcount;
  502. QHash<int,int> *lastTemperature;
  503. QList<MeasurementList*> ::iterator lastInsertion;
  504. QHash<int,bool> *controlColumns;
  505. public:
  506. MeasurementModel(QObject*parent= NULL);
  507. ~MeasurementModel();
  508. int rowCount(const QModelIndex&parent= QModelIndex())const;
  509. int columnCount(const QModelIndex&parent= QModelIndex())const;
  510. bool setHeaderData(int section,Qt::Orientation orientation,
  511. const QVariant&value,int role= Qt::DisplayRole);
  512. QVariant data(const QModelIndex&index,int role)const;
  513. bool setData(const QModelIndex&index,const QVariant&value,
  514. int role= Qt::EditRole);
  515. Qt::ItemFlags flags(const QModelIndex&index)const;
  516. QVariant headerData(int section,Qt::Orientation orientation,
  517. int role= Qt::DisplayRole)const;
  518. QModelIndex index(int row,int column,
  519. const QModelIndex&parent= QModelIndex())const;
  520. QModelIndex parent(const QModelIndex&index)const;
  521. Units::Unit displayUnits();
  522. public slots:
  523. void newMeasurement(Measurement measure,int tempcolumn);
  524. void newAnnotation(QString annotation,int tempcolumn,
  525. int annotationColumn);
  526. void clear();
  527. void setDisplayUnits(Units::Unit scale);
  528. signals:
  529. void rowChanged(int);
  530. };
  531. /*:421*//*422:*/
  532. #line 9751 "./typica.w"
  533. class MeasurementList:public QVariantList
  534. {
  535. public:
  536. bool operator<(const MeasurementList&other)const;
  537. bool operator==(const MeasurementList&other)const;
  538. };
  539. /*:422*//*448:*/
  540. #line 10409 "./typica.w"
  541. class AnnotationButton:public QPushButton
  542. {
  543. Q_OBJECT
  544. QString note;
  545. int tc;
  546. int ac;
  547. int count;
  548. public:
  549. AnnotationButton(const QString&text,QWidget*parent= NULL);
  550. public slots:
  551. void setAnnotation(const QString&annotation);
  552. void setTemperatureColumn(int tempcolumn);
  553. void setAnnotationColumn(int annotationcolumn);
  554. void annotate();
  555. void resetCount();
  556. signals:
  557. void annotation(QString annotation,int tempcolumn,
  558. int notecolumn);
  559. };
  560. /*:448*//*456:*/
  561. #line 10534 "./typica.w"
  562. class AnnotationSpinBox:public QDoubleSpinBox
  563. {
  564. Q_OBJECT
  565. QString pretext;
  566. QString posttext;
  567. int tc;
  568. int ac;
  569. bool change;
  570. public:
  571. AnnotationSpinBox(const QString&pret,const QString&postt,
  572. QWidget*parent= NULL);
  573. public slots:
  574. void setPretext(const QString&pret);
  575. void setPosttext(const QString&postt);
  576. void setTemperatureColumn(int tempcolumn);
  577. void setAnnotationColumn(int annotationcolumn);
  578. void annotate();
  579. void resetChange();
  580. signals:
  581. void annotation(QString annotation,int tempcolumn,
  582. int notecolumn);
  583. };
  584. /*:456*//*464:*/
  585. #line 10693 "./typica.w"
  586. class TimerDisplay:public QLCDNumber
  587. {
  588. Q_OBJECT
  589. /*465:*/
  590. #line 10743 "./typica.w"
  591. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  592. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  593. Q_PROPERTY(bool running READ isRunning)
  594. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  595. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  596. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  597. Q_PROPERTY(QString value READ value)
  598. /*:465*/
  599. #line 10697 "./typica.w"
  600. private slots:
  601. void updateTime();
  602. void setCountUpMode();
  603. void setCountDownMode();
  604. void setClockMode();
  605. public:
  606. TimerDisplay(QWidget*parent= NULL);
  607. ~TimerDisplay();
  608. enum TimerMode
  609. {
  610. CountUp,
  611. CountDown,
  612. Clock
  613. };
  614. QString value();
  615. QTime seconds();
  616. TimerMode mode();
  617. bool isRunning();
  618. QTime resetValue();
  619. QString displayFormat();
  620. bool autoReset();
  621. public slots:
  622. void setTimer(QTime value= QTime(0,0,0));
  623. void setMode(TimerMode mode);
  624. void startTimer();
  625. void stopTimer();
  626. void copyTimer();
  627. void setResetValue(QTime value= QTime(0,0,0));
  628. void reset();
  629. void setDisplayFormat(QString format);
  630. void setAutoReset(bool reset);
  631. void updateDisplay();
  632. signals:
  633. void valueChanged(QTime);
  634. void runStateChanged(bool);
  635. private:
  636. /*466:*/
  637. #line 10754 "./typica.w"
  638. QTime s;
  639. QTime r;
  640. QTimer clock;
  641. TimerDisplay::TimerMode m;
  642. bool running;
  643. bool ar;
  644. QAction*startAction;
  645. QAction*stopAction;
  646. QAction*resetAction;
  647. QString f;
  648. QTime relative;
  649. QTime base;
  650. /*:466*/
  651. #line 10734 "./typica.w"
  652. };
  653. /*:464*//*487:*/
  654. #line 11146 "./typica.w"
  655. class PackLayout:public QLayout
  656. {
  657. int doLayout(const QRect&rect,bool testOnly)const;
  658. QList<QLayoutItem*> itemList;
  659. Qt::Orientations orientation;
  660. public:
  661. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  662. PackLayout(int spacing= -1);
  663. ~PackLayout();
  664. void addItem(QLayoutItem*item);
  665. Qt::Orientations expandingDirections()const;
  666. bool hasHeightForWidth()const;
  667. int heightForWidth(int width)const;
  668. int count()const;
  669. QLayoutItem*itemAt(int index)const;
  670. QSize minimumSize()const;
  671. void setGeometry(const QRect&rect);
  672. void setOrientation(Qt::Orientations direction);
  673. QSize sizeHint()const;
  674. QLayoutItem*takeAt(int index);
  675. };
  676. /*:487*//*500:*/
  677. #line 11424 "./typica.w"
  678. class SceneButton:public QGraphicsScene
  679. {
  680. Q_OBJECT
  681. public:
  682. SceneButton();
  683. ~SceneButton();
  684. protected:
  685. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  686. signals:
  687. void clicked(QPoint pos);
  688. };
  689. /*:500*//*502:*/
  690. #line 11466 "./typica.w"
  691. class WidgetDecorator:public QWidget
  692. {
  693. Q_OBJECT
  694. PackLayout*layout;
  695. QGraphicsView*label;
  696. QGraphicsTextItem*text;
  697. SceneButton*scene;
  698. public:
  699. WidgetDecorator(QWidget*widget,const QString&labeltext,
  700. Qt::Orientations orientation= Qt::Horizontal,
  701. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  702. ~WidgetDecorator();
  703. void setBackgroundBrush(QBrush background);
  704. void setTextColor(QColor color);
  705. };
  706. /*:502*//*513:*/
  707. #line 11641 "./typica.w"
  708. class LogEditWindow:public QMainWindow
  709. {
  710. Q_OBJECT
  711. QWidget*centralWidget;
  712. PackLayout*mainLayout;
  713. QHBoxLayout*addRowsLayout;
  714. QLabel*startTimeLabel;
  715. QTimeEdit*startTime;
  716. QLabel*endTimeLabel;
  717. QTimeEdit*endTime;
  718. QLabel*intervalLabel;
  719. QSpinBox*interval;
  720. QPushButton*addRows;
  721. QAction*saveXml;
  722. QAction*saveCsv;
  723. QAction*openXml;
  724. MeasurementModel*model;
  725. QTableView*log;
  726. private slots:
  727. void addTheRows();
  728. void saveXML();
  729. void saveCSV();
  730. void openXML();
  731. protected:
  732. void closeEvent(QCloseEvent*event);
  733. public:
  734. LogEditWindow();
  735. };
  736. /*:513*//*527:*/
  737. #line 11949 "./typica.w"
  738. class XMLOutput:public QObject
  739. {
  740. Q_OBJECT
  741. MeasurementModel*data;
  742. QIODevice*out;
  743. int time;
  744. QMap<int,QString> temperatureColumns;
  745. QMap<int,QString> controlColumns;
  746. QMap<int,QString> annotationColumns;
  747. public:
  748. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  749. void addTemperatureColumn(const QString&series,int column);
  750. void addControlColumn(const QString&series,int column);
  751. void addAnnotationColumn(const QString&series,int column);
  752. void setModel(MeasurementModel*model);
  753. void setTimeColumn(int column);
  754. void setDevice(QIODevice*device);
  755. bool output();
  756. };
  757. /*:527*//*534:*/
  758. #line 12185 "./typica.w"
  759. class XMLInput:public QObject
  760. {
  761. Q_OBJECT
  762. int firstc;
  763. QIODevice*in;
  764. public:
  765. XMLInput(QIODevice*input,int c);
  766. void setFirstColumn(int column);
  767. void setDevice(QIODevice*device);
  768. bool input();
  769. signals:
  770. void measure(Measurement,int);
  771. void annotation(QString,int,int);
  772. void newTemperatureColumn(int,QString);
  773. void newAnnotationColumn(int,QString);
  774. void lastColumn(int);
  775. };
  776. /*:534*//*545:*/
  777. #line 12439 "./typica.w"
  778. class CSVOutput
  779. {
  780. MeasurementModel*data;
  781. QIODevice*out;
  782. int time;
  783. QMap<int,QString> temperatureColumns;
  784. QMap<int,QString> controlColumns;
  785. QMap<int,QString> annotationColumns;
  786. public:
  787. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  788. void addTemperatureColumn(const QString&series,int column);
  789. void addControlColumn(const QString&series,int column);
  790. void addAnnotationColumn(const QString&series,int column);
  791. void setModel(MeasurementModel*model);
  792. void setTimeColumn(int column);
  793. void setDevice(QIODevice*device);
  794. bool output();
  795. };
  796. /*:545*//*575:*/
  797. #line 12582 "./typica.w"
  798. #define AppInstance (qobject_cast<Application *> (qApp))
  799. class NodeInserter;
  800. class DeviceTreeModel;
  801. class Application:public QApplication
  802. {
  803. Q_OBJECT
  804. public:
  805. Application(int&argc,char**argv);
  806. QDomDocument*configuration();
  807. /*717:*/
  808. #line 15146 "./typica.w"
  809. QDomDocument deviceConfiguration();
  810. /*:717*//*750:*/
  811. #line 15819 "./typica.w"
  812. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  813. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  814. const QModelIndex&index);
  815. /*:750*//*755:*/
  816. #line 15923 "./typica.w"
  817. QList<NodeInserter*> topLevelNodeInserters;
  818. /*:755*/
  819. #line 12593 "./typica.w"
  820. QSqlDatabase database();
  821. QScriptEngine*engine;
  822. public slots:
  823. /*718:*/
  824. #line 15153 "./typica.w"
  825. void saveDeviceConfiguration();
  826. /*:718*/
  827. #line 12597 "./typica.w"
  828. private:
  829. /*716:*/
  830. #line 15137 "./typica.w"
  831. QDomDocument deviceConfigurationDocument;
  832. /*:716*//*749:*/
  833. #line 15813 "./typica.w"
  834. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  835. /*:749*/
  836. #line 12599 "./typica.w"
  837. QDomDocument conf;
  838. };
  839. /*:575*//*583:*/
  840. #line 12724 "./typica.w"
  841. class SaltModel:public QAbstractItemModel
  842. {
  843. Q_OBJECT
  844. QList<QList<QMap<int,QVariant> > > modelData;
  845. QStringList hData;
  846. int colcount;
  847. public:
  848. SaltModel(int columns);
  849. ~SaltModel();
  850. int rowCount(const QModelIndex&parent= QModelIndex())const;
  851. int columnCount(const QModelIndex&parent= QModelIndex())const;
  852. bool setHeaderData(int section,Qt::Orientation orientation,
  853. const QVariant&value,int role= Qt::DisplayRole);
  854. QVariant data(const QModelIndex&index,int role)const;
  855. bool setData(const QModelIndex&index,const QVariant&value,
  856. int role= Qt::EditRole);
  857. Qt::ItemFlags flags(const QModelIndex&index)const;
  858. QVariant headerData(int section,Qt::Orientation orientation,
  859. int role= Qt::DisplayRole)const;
  860. QModelIndex index(int row,int column,
  861. const QModelIndex&parent= QModelIndex())const;
  862. QModelIndex parent(const QModelIndex&index)const;
  863. QString arrayLiteral(int column,int role)const;
  864. QString quotedArrayLiteral(int column,int role)const;
  865. void clear();
  866. bool removeRows(int row,int count,
  867. const QModelIndex&parent= QModelIndex());
  868. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  869. };
  870. /*:583*//*599:*/
  871. #line 13109 "./typica.w"
  872. class SqlComboBox:public QComboBox
  873. {
  874. Q_OBJECT
  875. int dataColumn;
  876. int displayColumn;
  877. bool dataColumnShown;
  878. QString specialNullText;
  879. QVariant specialNullData;
  880. public:
  881. SqlComboBox();
  882. ~SqlComboBox();
  883. SqlComboBox*clone(QWidget*parent);
  884. public slots:
  885. void addNullOption();
  886. void addSqlOptions(QString query);
  887. void setDataColumn(int column);
  888. void setDisplayColumn(int column);
  889. void showData(bool show);
  890. void setNullText(QString nullText);
  891. void setNullData(QVariant nullData);
  892. };
  893. /*:599*//*606:*/
  894. #line 13256 "./typica.w"
  895. class SqlComboBoxDelegate:public QItemDelegate
  896. {
  897. Q_OBJECT
  898. SqlComboBox*delegate;
  899. public:
  900. SqlComboBoxDelegate(QObject*parent= NULL);
  901. QWidget*createEditor(QWidget*parent,
  902. const QStyleOptionViewItem&option,
  903. const QModelIndex&index)const;
  904. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  905. void setModelData(QWidget*editor,QAbstractItemModel*model,
  906. const QModelIndex&index)const;
  907. void setWidget(SqlComboBox*widget);
  908. virtual QSize sizeHint()const;
  909. void updateEditorGeometry(QWidget*editor,
  910. const QStyleOptionViewItem&option,
  911. const QModelIndex&index)const;
  912. };
  913. /*:606*//*621:*/
  914. #line 13467 "./typica.w"
  915. class SqlConnectionSetup:public QDialog
  916. {
  917. Q_OBJECT
  918. public:
  919. SqlConnectionSetup();
  920. ~SqlConnectionSetup();
  921. public slots:
  922. void testConnection();
  923. private:
  924. QFormLayout*formLayout;
  925. QComboBox*driver;
  926. QLineEdit*hostname;
  927. QLineEdit*portnumber;
  928. QLineEdit*dbname;
  929. QLineEdit*user;
  930. QLineEdit*password;
  931. QVBoxLayout*layout;
  932. QHBoxLayout*buttons;
  933. QPushButton*cancelButton;
  934. QPushButton*connectButton;
  935. };
  936. /*:621*//*626:*/
  937. #line 13610 "./typica.w"
  938. class SqlQueryView:public QTableView
  939. {
  940. Q_OBJECT
  941. public:
  942. SqlQueryView(QWidget*parent= NULL);
  943. void setQuery(const QString&query);
  944. bool setHeaderData(int section,Qt::Orientation orientation,
  945. const QVariant&value,int role);
  946. Q_INVOKABLE QVariant data(int row,int column,
  947. int role= Qt::DisplayRole);
  948. signals:
  949. void openEntry(QString key);
  950. void openEntryRow(int row);
  951. protected:
  952. virtual void showEvent(QShowEvent*event);
  953. private slots:
  954. void openRow(const QModelIndex&index);
  955. void persistColumnResize(int column,int oldsize,int newsize);
  956. };
  957. /*:626*//*641:*/
  958. #line 13865 "./typica.w"
  959. class ReportAction:public QAction
  960. {
  961. Q_OBJECT
  962. public:
  963. ReportAction(const QString&fileName,const QString&reportName,
  964. QObject*parent= NULL);
  965. private slots:
  966. void createReport();
  967. private:
  968. QString reportFile;
  969. };
  970. /*:641*//*653:*/
  971. #line 14076 "./typica.w"
  972. class ReportTable:public QObject
  973. {
  974. Q_OBJECT
  975. QTextFrame*area;
  976. QDomElement configuration;
  977. QMap<QString,QVariant> bindings;
  978. public:
  979. ReportTable(QTextFrame*frame,QDomElement description);
  980. ~ReportTable();
  981. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  982. public slots:
  983. void refresh();
  984. };
  985. /*:653*//*686:*/
  986. #line 14315 "./typica.w"
  987. class FormArray:public QScrollArea
  988. {
  989. Q_OBJECT
  990. QDomElement configuration;
  991. QWidget itemContainer;
  992. QVBoxLayout itemLayout;
  993. int maxwidth;
  994. int maxheight;
  995. public:
  996. FormArray(QDomElement description);
  997. Q_INVOKABLE QWidget*elementAt(int index);
  998. Q_INVOKABLE int elements();
  999. public slots:
  1000. void addElements(int copies= 1);
  1001. void removeAllElements();
  1002. void setMaximumElementWidth(int width);
  1003. void setMaximumElementHeight(int height);
  1004. };
  1005. /*:686*//*696:*/
  1006. #line 14531 "./typica.w"
  1007. class ScaleControl:public QGraphicsView
  1008. {
  1009. Q_OBJECT
  1010. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1011. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1012. /*697:*/
  1013. #line 14557 "./typica.w"
  1014. QGraphicsScene scene;
  1015. QGraphicsPolygonItem initialDecrement;
  1016. QGraphicsPolygonItem initialIncrement;
  1017. QGraphicsPolygonItem finalDecrement;
  1018. QGraphicsPolygonItem finalIncrement;
  1019. QGraphicsPolygonItem initialIndicator;
  1020. QGraphicsPolygonItem finalIndicator;
  1021. QGraphicsPathItem scaleLine;
  1022. QPolygonF left;
  1023. QPolygonF right;
  1024. QPolygonF down;
  1025. QPolygonF up;
  1026. QPainterPath scalePath;
  1027. QBrush initialBrush;
  1028. QBrush finalBrush;
  1029. double nonScoredValue;
  1030. double scoredValue;
  1031. bool initialSet;
  1032. bool finalSet;
  1033. bool scaleDown;
  1034. /*:697*/
  1035. #line 14537 "./typica.w"
  1036. public:
  1037. ScaleControl();
  1038. double initialValue(void);
  1039. double finalValue(void);
  1040. virtual QSize sizeHint()const;
  1041. public slots:
  1042. void setInitialValue(double value);
  1043. void setFinalValue(double value);
  1044. signals:
  1045. void initialChanged(double);
  1046. void finalChanged(double);
  1047. protected:
  1048. virtual void mousePressEvent(QMouseEvent*event);
  1049. virtual void mouseReleaseEvent(QMouseEvent*event);
  1050. };
  1051. /*:696*//*708:*/
  1052. #line 14854 "./typica.w"
  1053. class IntensityControl:public QGraphicsView
  1054. {
  1055. Q_OBJECT
  1056. Q_PROPERTY(double value READ value WRITE setValue)
  1057. QGraphicsScene scene;
  1058. QGraphicsPolygonItem decrement;
  1059. QGraphicsPolygonItem increment;
  1060. QGraphicsPolygonItem indicator;
  1061. QGraphicsPathItem scaleLine;
  1062. QPolygonF left;
  1063. QPolygonF up;
  1064. QPolygonF down;
  1065. QPainterPath scalePath;
  1066. QBrush theBrush;
  1067. double theValue;
  1068. bool valueSet;
  1069. bool scaleDown;
  1070. public:
  1071. IntensityControl();
  1072. double value();
  1073. virtual QSize sizeHint()const;
  1074. public slots:
  1075. void setValue(double val);
  1076. signals:
  1077. void valueChanged(double);
  1078. protected:
  1079. virtual void mousePressEvent(QMouseEvent*event);
  1080. virtual void mouseReleaseEvent(QMouseEvent*event);
  1081. };
  1082. /*:708*//*724:*/
  1083. #line 15242 "./typica.w"
  1084. class DeviceTreeModelNode
  1085. {
  1086. public:
  1087. DeviceTreeModelNode(QDomNode&node,int row,
  1088. DeviceTreeModelNode*parent= NULL);
  1089. ~DeviceTreeModelNode();
  1090. DeviceTreeModelNode*child(int index);
  1091. DeviceTreeModelNode*parent();
  1092. QDomNode node()const;
  1093. int row();
  1094. private:
  1095. QDomNode domNode;
  1096. QHash<int,DeviceTreeModelNode*> children;
  1097. int rowNumber;
  1098. DeviceTreeModelNode*parentItem;
  1099. };
  1100. /*:724*//*726:*/
  1101. #line 15317 "./typica.w"
  1102. class DeviceTreeModel:public QAbstractItemModel
  1103. {
  1104. Q_OBJECT
  1105. public:
  1106. DeviceTreeModel(QObject*parent= NULL);
  1107. ~DeviceTreeModel();
  1108. QVariant data(const QModelIndex&index,int role)const;
  1109. Qt::ItemFlags flags(const QModelIndex&index)const;
  1110. QVariant headerData(int section,Qt::Orientation orientation,
  1111. int role= Qt::DisplayRole)const;
  1112. QModelIndex index(int row,int column,
  1113. const QModelIndex&parent= QModelIndex())const;
  1114. QModelIndex parent(const QModelIndex&child)const;
  1115. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1116. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1117. bool setData(const QModelIndex&index,const QVariant&value,
  1118. int role);
  1119. bool removeRows(int row,int count,const QModelIndex&parent);
  1120. QDomElement referenceElement(const QString&id);
  1121. public slots:
  1122. void newNode(const QString&name,const QString&driver,
  1123. const QModelIndex&parent);
  1124. private:
  1125. QDomDocument document;
  1126. DeviceTreeModelNode*root;
  1127. QDomNode referenceSection;
  1128. QDomNode treeRoot;
  1129. };
  1130. /*:726*//*745:*/
  1131. #line 15771 "./typica.w"
  1132. Q_DECLARE_METATYPE(QModelIndex)
  1133. /*:745*//*753:*/
  1134. #line 15878 "./typica.w"
  1135. class NodeInserter:public QAction
  1136. {
  1137. Q_OBJECT
  1138. public:
  1139. NodeInserter(const QString&title,const QString&name,
  1140. const QString&driver,QObject*parent= NULL);
  1141. signals:
  1142. void triggered(QString name,QString driver);
  1143. private slots:
  1144. void onTriggered();
  1145. private:
  1146. QString defaultNodeName;
  1147. QString driverString;
  1148. };
  1149. /*:753*//*756:*/
  1150. #line 15933 "./typica.w"
  1151. class DeviceConfigurationWindow:public QWidget
  1152. {
  1153. Q_OBJECT
  1154. public:
  1155. DeviceConfigurationWindow();
  1156. public slots:
  1157. void addDevice();
  1158. void removeNode();
  1159. void newSelection(const QModelIndex&index);
  1160. private slots:
  1161. void resizeColumn();
  1162. private:
  1163. QDomDocument document;
  1164. DeviceTreeModel*model;
  1165. QTreeView*view;
  1166. QScrollArea*configArea;
  1167. };
  1168. /*:756*//*765:*/
  1169. #line 16103 "./typica.w"
  1170. class BasicDeviceConfigurationWidget:public QWidget
  1171. {
  1172. Q_OBJECT
  1173. public:
  1174. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1175. const QModelIndex&index);
  1176. public slots:
  1177. void insertChildNode(const QString&name,const QString&driver);
  1178. void updateAttribute(const QString&name,const QString&value);
  1179. protected:
  1180. DeviceTreeModel*deviceModel;
  1181. QModelIndex currentNode;
  1182. };
  1183. /*:765*//*769:*/
  1184. #line 16188 "./typica.w"
  1185. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1186. {
  1187. Q_OBJECT
  1188. public:
  1189. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1190. const QModelIndex&index);
  1191. private slots:
  1192. void updateRoasterId(int id);
  1193. void updateCapacityCheck(int value);
  1194. void updateCapacity(const QString&value);
  1195. void updateCapacityUnit(const QString&value);
  1196. };
  1197. /*:769*//*774:*/
  1198. #line 16393 "./typica.w"
  1199. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1200. {
  1201. Q_OBJECT
  1202. public:
  1203. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1204. const QModelIndex&index);
  1205. };
  1206. /*:774*//*776:*/
  1207. #line 16439 "./typica.w"
  1208. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1209. {
  1210. Q_OBJECT
  1211. public:
  1212. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1213. const QModelIndex&index);
  1214. private slots:
  1215. void addChannel();
  1216. void updateDeviceId(const QString&newId);
  1217. };
  1218. /*:776*//*780:*/
  1219. #line 16525 "./typica.w"
  1220. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1221. {
  1222. Q_OBJECT
  1223. public:
  1224. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1225. const QModelIndex&index);
  1226. private slots:
  1227. void updateThermocoupleType(const QString&type);
  1228. void updateColumnName(const QString&name);
  1229. void updateHidden(bool hidden);
  1230. };
  1231. /*:780*//*785:*/
  1232. #line 16641 "./typica.w"
  1233. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1234. {
  1235. Q_OBJECT
  1236. public:
  1237. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1238. const QModelIndex&index);
  1239. };
  1240. /*:785*//*787:*/
  1241. #line 16682 "./typica.w"
  1242. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1243. {
  1244. Q_OBJECT
  1245. public:
  1246. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1247. const QModelIndex&index);
  1248. private slots:
  1249. void addChannel();
  1250. void updateDeviceId(const QString&newId);
  1251. };
  1252. /*:787*//*789:*/
  1253. #line 16751 "./typica.w"
  1254. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1255. {
  1256. Q_OBJECT
  1257. public:
  1258. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1259. const QModelIndex&index);
  1260. private slots:
  1261. void updateDeviceId(const QString&newId);
  1262. void updateThermocoupleType(const QString&type);
  1263. void updateColumnName(const QString&name);
  1264. void updateHidden(bool hidden);
  1265. };
  1266. /*:789*//*794:*/
  1267. #line 16882 "./typica.w"
  1268. class PortSelector:public QComboBox
  1269. {
  1270. Q_OBJECT
  1271. public:
  1272. PortSelector(QWidget*parent= NULL);
  1273. private slots:
  1274. void addDevice(QextPortInfo port);
  1275. private:
  1276. QextSerialEnumerator*lister;
  1277. };
  1278. /*:794*//*796:*/
  1279. #line 16930 "./typica.w"
  1280. class BaudSelector:public QComboBox
  1281. {
  1282. Q_OBJECT
  1283. Q_ENUMS(BaudRateType)
  1284. public:
  1285. BaudSelector(QWidget*parent= NULL);
  1286. enum BaudRateType
  1287. {
  1288. #if defined(Q_OS_UNIX) || defined(qdoc)
  1289. BAUD50= 50,
  1290. BAUD75= 75,
  1291. BAUD134= 134,
  1292. BAUD150= 150,
  1293. BAUD200= 200,
  1294. BAUD1800= 1800,
  1295. #if defined(B76800) || defined(qdoc)
  1296. BAUD76800= 76800,
  1297. #endif
  1298. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1299. BAUD230400= 230400,
  1300. BAUD460800= 460800,
  1301. BAUD500000= 500000,
  1302. BAUD576000= 576000,
  1303. BAUD921600= 921600,
  1304. BAUD1000000= 1000000,
  1305. BAUD1152000= 1152000,
  1306. BAUD1500000= 1500000,
  1307. BAUD2000000= 2000000,
  1308. BAUD2500000= 2500000,
  1309. BAUD3000000= 3000000,
  1310. BAUD3500000= 3500000,
  1311. BAUD4000000= 4000000,
  1312. #endif
  1313. #endif
  1314. #if defined(Q_OS_WIN) || defined(qdoc)
  1315. BAUD14400= 14400,
  1316. BAUD56000= 56000,
  1317. BAUD128000= 128000,
  1318. BAUD256000= 256000,
  1319. #endif
  1320. BAUD110= 110,
  1321. BAUD300= 300,
  1322. BAUD600= 600,
  1323. BAUD1200= 1200,
  1324. BAUD2400= 2400,
  1325. BAUD4800= 4800,
  1326. BAUD9600= 9600,
  1327. BAUD19200= 19200,
  1328. BAUD38400= 38400,
  1329. BAUD57600= 57600,
  1330. BAUD115200= 115200
  1331. };
  1332. };
  1333. /*:796*//*798:*/
  1334. #line 17001 "./typica.w"
  1335. class ParitySelector:public QComboBox
  1336. {
  1337. Q_OBJECT
  1338. Q_ENUMS(ParityType)
  1339. public:
  1340. ParitySelector(QWidget*parent= NULL);
  1341. enum ParityType
  1342. {
  1343. PAR_NONE,
  1344. PAR_ODD,
  1345. PAR_EVEN,
  1346. #if defined(Q_OS_WIN) || defined(qdoc)
  1347. PAR_MARK,
  1348. #endif
  1349. PAR_SPACE
  1350. };
  1351. };
  1352. /*:798*//*800:*/
  1353. #line 17039 "./typica.w"
  1354. class FlowSelector:public QComboBox
  1355. {
  1356. Q_OBJECT
  1357. Q_ENUMS(FlowType)
  1358. public:
  1359. FlowSelector(QWidget*parent= NULL);
  1360. enum FlowType
  1361. {
  1362. FLOW_OFF,
  1363. FLOW_HARDWARE,
  1364. FLOW_XONXOFF
  1365. };
  1366. };
  1367. /*:800*//*802:*/
  1368. #line 17072 "./typica.w"
  1369. class StopSelector:public QComboBox
  1370. {
  1371. Q_OBJECT
  1372. Q_ENUMS(StopBitsType)
  1373. public:
  1374. StopSelector(QWidget*parent= NULL);
  1375. enum StopBitsType
  1376. {
  1377. STOP_1,
  1378. #if defined(Q_OS_WIN) || defined(qdoc)
  1379. STOP_1_5,
  1380. #endif
  1381. STOP_2
  1382. };
  1383. };
  1384. /*:802*//*805:*/
  1385. #line 17129 "./typica.w"
  1386. class ShortHexSpinBox:public QSpinBox
  1387. {
  1388. Q_OBJECT
  1389. public:
  1390. ShortHexSpinBox(QWidget*parent= NULL);
  1391. virtual QValidator::State validate(QString&input,int&pos)const;
  1392. protected:
  1393. virtual int valueFromText(const QString&text)const;
  1394. virtual QString textFromValue(int value)const;
  1395. };
  1396. /*:805*//*807:*/
  1397. #line 17191 "./typica.w"
  1398. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1399. {
  1400. Q_OBJECT
  1401. public:
  1402. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1403. const QModelIndex&index);
  1404. private slots:
  1405. void updatePort(const QString&newPort);
  1406. void updateBaudRate(const QString&newRate);
  1407. void updateParity(const QString&newParity);
  1408. void updateFlowControl(const QString&newFlow);
  1409. void updateStopBits(const QString&newStopBits);
  1410. };
  1411. /*:807*//*809:*/
  1412. #line 17342 "./typica.w"
  1413. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1414. {
  1415. Q_OBJECT
  1416. public:
  1417. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1418. const QModelIndex&index);
  1419. private slots:
  1420. void updateStationNumber(int newStation);
  1421. void updateFixedUnit(bool newFixed);
  1422. void updateFixedDecimal(bool newFixed);
  1423. void updateUnit(const QString&newUnit);
  1424. void updateUnitAddress(int newAddress);
  1425. void updateValueF(int newValue);
  1426. void updateValueC(int newValue);
  1427. void updatePrecisionAddress(int newAddress);
  1428. void updatePrecisionValue(int newValue);
  1429. private:
  1430. QStackedLayout*unitSpecificationLayout;
  1431. QStackedLayout*decimalSpecificationLayout;
  1432. };
  1433. /*:809*//*811:*/
  1434. #line 17601 "./typica.w"
  1435. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1436. {
  1437. Q_OBJECT
  1438. public:
  1439. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1440. const QModelIndex&index);
  1441. private slots:
  1442. void updateAddress(int newAddress);
  1443. };
  1444. /*:811*//*813:*/
  1445. #line 17647 "./typica.w"
  1446. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1447. {
  1448. Q_OBJECT
  1449. public:
  1450. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1451. const QModelIndex&index);
  1452. private slots:
  1453. void updateReadAddress(int newAddress);
  1454. void updateWriteAddress(int newAddress);
  1455. void updateFixedRange(bool fixed);
  1456. void updateLower(const QString&lower);
  1457. void updateUpper(const QString&upper);
  1458. void updateLowerAddress(int newAddress);
  1459. void updateUpperAddress(int newAddress);
  1460. private:
  1461. QStackedLayout*boundsLayout;
  1462. };
  1463. /*:813*//*817:*/
  1464. #line 17841 "./typica.w"
  1465. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1466. {
  1467. Q_OBJECT
  1468. public:
  1469. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1470. private slots:
  1471. void updateButtonText(const QString&text);
  1472. void updateAnnotationText(const QString&text);
  1473. };
  1474. /*:817*//*821:*/
  1475. #line 17909 "./typica.w"
  1476. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1477. {
  1478. Q_OBJECT
  1479. public:
  1480. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1481. private slots:
  1482. void updateButtonText(const QString&text);
  1483. void updateAnnotationText(const QString&text);
  1484. };
  1485. /*:821*//*824:*/
  1486. #line 17983 "./typica.w"
  1487. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1488. {
  1489. Q_OBJECT
  1490. public:
  1491. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1492. private slots:
  1493. void updateLabel(const QString&text);
  1494. void updateMinimum(const QString&minimum);
  1495. void updateMaximum(const QString&maximum);
  1496. void updatePrecision(int precision);
  1497. void updatePretext(const QString&text);
  1498. void updatePosttext(const QString&text);
  1499. };
  1500. /*:824*//*827:*/
  1501. #line 12 "./freeannotation.w"
  1502. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1503. {
  1504. Q_OBJECT
  1505. public:
  1506. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1507. private slots:
  1508. void updateLabel(const QString&text);
  1509. };
  1510. /*:827*//*831:*/
  1511. #line 11 "./settings.w"
  1512. class SettingsWindow:public QMainWindow
  1513. {
  1514. Q_OBJECT
  1515. public:
  1516. SettingsWindow();
  1517. };
  1518. /*:831*//*836:*/
  1519. #line 8 "./graphsettings.w"
  1520. class GraphSettingsWidget:public QWidget
  1521. {
  1522. Q_OBJECT
  1523. public:
  1524. GraphSettingsWidget();
  1525. };
  1526. /*:836*//*838:*/
  1527. #line 46 "./graphsettings.w"
  1528. class GraphSettingsRelativeTab:public QWidget
  1529. {
  1530. Q_OBJECT
  1531. public:
  1532. GraphSettingsRelativeTab();
  1533. public slots:
  1534. void updateEnableSetting(bool enable);
  1535. void updateColorSetting(const QString&color);
  1536. void updateAxisSetting(const QString&gridList);
  1537. void updateUnit(int unit);
  1538. void showColorPicker();
  1539. private:
  1540. QLineEdit*colorEdit;
  1541. };
  1542. /*:838*//*842:*/
  1543. #line 7 "./advancedsettings.w"
  1544. class AdvancedSettingsWidget:public QWidget
  1545. {
  1546. Q_OBJECT
  1547. public:
  1548. AdvancedSettingsWidget();
  1549. public slots:
  1550. void enableDiagnosticLogging(bool enabled);
  1551. };
  1552. /*:842*//*846:*/
  1553. #line 18108 "./typica.w"
  1554. class ModbusRTUDevice:public QObject
  1555. {
  1556. Q_OBJECT
  1557. public:
  1558. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1559. ~ModbusRTUDevice();
  1560. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1561. Q_INVOKABLE double SVLower();
  1562. Q_INVOKABLE double SVUpper();
  1563. Q_INVOKABLE int decimals();
  1564. QList<Channel*> channels;
  1565. public slots:
  1566. void outputSV(double sv);
  1567. signals:
  1568. void SVLowerChanged(double);
  1569. void SVUpperChanged(double);
  1570. void SVDecimalChanged(int);
  1571. void queueEmpty();
  1572. private slots:
  1573. void dataAvailable();
  1574. void sendNextMessage();
  1575. void decimalResponse(QByteArray response);
  1576. void unitResponse(QByteArray response);
  1577. void svlResponse(QByteArray response);
  1578. void svuResponse(QByteArray response);
  1579. void requestMeasurement();
  1580. void mResponse(QByteArray response);
  1581. void ignore(QByteArray response);
  1582. void timeout();
  1583. private:
  1584. QextSerialPort*port;
  1585. QByteArray responseBuffer;
  1586. QList<QByteArray> messageQueue;
  1587. QList<QObject*> retObjQueue;
  1588. QList<char*> callbackQueue;
  1589. quint16 calculateCRC(QByteArray data);
  1590. QTimer*messageDelayTimer;
  1591. QTimer*commTimeout;
  1592. int delayTime;
  1593. char station;
  1594. int decimalPosition;
  1595. int valueF;
  1596. int valueC;
  1597. bool unitIsF;
  1598. double outputSVLower;
  1599. double outputSVUpper;
  1600. QByteArray outputSVStub;
  1601. QByteArray pvStub;
  1602. QByteArray svStub;
  1603. QByteArray mStub;
  1604. quint16 pvaddress;
  1605. quint16 svaddress;
  1606. bool svenabled;
  1607. bool readingsv;
  1608. double savedpv;
  1609. bool waiting;
  1610. };
  1611. /*:846*//*862:*/
  1612. #line 18811 "./typica.w"
  1613. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1614. {
  1615. Q_OBJECT
  1616. public:
  1617. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1618. private slots:
  1619. void updatePort(const QString&newPort);
  1620. void updateBaudRate(const QString&newRate);
  1621. void updateParity(const QString&newParity);
  1622. void updateFlowControl(const QString&newFlow);
  1623. void updateStopBits(const QString&newStopBits);
  1624. void updateStation(int station);
  1625. void updateFixedDecimal(bool fixed);
  1626. void updateDecimalAddress(int address);
  1627. void updateDecimalPosition(int position);
  1628. void updateFixedUnit(bool fixed);
  1629. void updateUnitAddress(int address);
  1630. void updateValueForF(int value);
  1631. void updateValueForC(int value);
  1632. void updateUnit(const QString&newUnit);
  1633. void updatePVAddress(int address);
  1634. void updateSVEnabled(bool enabled);
  1635. void updateSVReadAddress(int address);
  1636. void updateDeviceLimit(bool query);
  1637. void updateSVLowerAddress(int address);
  1638. void updateSVUpperAddress(int address);
  1639. void updateSVLower(double value);
  1640. void updateSVUpper(double value);
  1641. void updateSVWritable(bool canWriteSV);
  1642. void updateSVWriteAddress(int address);
  1643. void updatePVColumnName(const QString&name);
  1644. void updateSVColumnName(const QString&name);
  1645. void updatePVHidden(bool hidden);
  1646. void updateSVHidden(bool hidden);
  1647. private:
  1648. PortSelector*port;
  1649. BaudSelector*baud;
  1650. ParitySelector*parity;
  1651. FlowSelector*flow;
  1652. StopSelector*stop;
  1653. QSpinBox*station;
  1654. QCheckBox*decimalQuery;
  1655. ShortHexSpinBox*decimalAddress;
  1656. QSpinBox*decimalPosition;
  1657. QCheckBox*unitQuery;
  1658. ShortHexSpinBox*unitAddress;
  1659. QSpinBox*valueF;
  1660. QSpinBox*valueC;
  1661. QComboBox*fixedUnit;
  1662. ShortHexSpinBox*pVAddress;
  1663. QCheckBox*sVEnabled;
  1664. ShortHexSpinBox*sVReadAddress;
  1665. QCheckBox*deviceLimit;
  1666. ShortHexSpinBox*sVLowerAddr;
  1667. ShortHexSpinBox*sVUpperAddr;
  1668. QDoubleSpinBox*sVLower;
  1669. QDoubleSpinBox*sVUpper;
  1670. QCheckBox*sVWritable;
  1671. ShortHexSpinBox*sVOutputAddr;
  1672. QLineEdit*pVColumnName;
  1673. QLineEdit*sVColumnName;
  1674. };
  1675. /*:862*//*866:*/
  1676. #line 22 "./modbus.w"
  1677. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1678. {
  1679. Q_OBJECT
  1680. public:
  1681. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1682. private slots:
  1683. void updatePort(const QString&value);
  1684. void updateBaudRate(const QString&value);
  1685. void updateParity(int value);
  1686. void updateFlowControl(int value);
  1687. void updateStopBits(int value);
  1688. void addInput();
  1689. private:
  1690. ParitySelector*m_parity;
  1691. FlowSelector*m_flow;
  1692. StopSelector*m_stop;
  1693. };
  1694. /*:866*//*868:*/
  1695. #line 144 "./modbus.w"
  1696. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1697. {
  1698. Q_OBJECT
  1699. public:
  1700. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1701. private slots:
  1702. void updateStation(int value);
  1703. void updateAddress(int value);
  1704. void updateFunction(int value);
  1705. void updateFormat(int value);
  1706. void updateDecimals(int value);
  1707. void updateUnit(int value);
  1708. void updateColumnName(const QString&value);
  1709. void updateHidden(bool value);
  1710. };
  1711. /*:868*//*872:*/
  1712. #line 338 "./modbus.w"
  1713. enum ModbusDataFormat
  1714. {
  1715. Int16,
  1716. FloatHL,
  1717. FloatLH
  1718. };
  1719. struct ModbusScanItem
  1720. {
  1721. QByteArray request;
  1722. ModbusDataFormat format;
  1723. int decimalPosition;
  1724. Units::Unit unit;
  1725. mutable double lastValue;
  1726. };
  1727. /*:872*//*873:*/
  1728. #line 358 "./modbus.w"
  1729. class ModbusNG:public QObject
  1730. {
  1731. Q_OBJECT
  1732. public:
  1733. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1734. ~ModbusNG();
  1735. Q_INVOKABLE int channelCount();
  1736. Channel*getChannel(int);
  1737. Q_INVOKABLE QString channelColumnName(int);
  1738. Q_INVOKABLE QString channelIndicatorText(int);
  1739. Q_INVOKABLE bool isChannelHidden(int);
  1740. private slots:
  1741. void sendNextMessage();
  1742. void timeout();
  1743. void dataAvailable();
  1744. private:
  1745. quint16 calculateCRC(QByteArray data);
  1746. QextSerialPort*port;
  1747. int delayTime;
  1748. QTimer*messageDelayTimer;
  1749. QTimer*commTimeout;
  1750. int scanPosition;
  1751. bool waiting;
  1752. QByteArray responseBuffer;
  1753. QList<Channel*> channels;
  1754. QList<ModbusScanItem> scanList;
  1755. QList<QString> channelNames;
  1756. QList<QString> channelLabels;
  1757. QList<bool> hiddenStates;
  1758. };
  1759. /*:873*//*878:*/
  1760. #line 36 "./unsupportedserial.w"
  1761. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1762. {
  1763. Q_OBJECT
  1764. public:
  1765. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1766. const QModelIndex&index);
  1767. private slots:
  1768. void updateConfiguration();
  1769. void saveScript();
  1770. void addChannel();
  1771. private:
  1772. SaltModel*deviceSettingsModel;
  1773. QTextEdit*scriptEditor;
  1774. };
  1775. /*:878*//*883:*/
  1776. #line 166 "./unsupportedserial.w"
  1777. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1778. {
  1779. Q_OBJECT
  1780. public:
  1781. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1782. const QModelIndex&index);
  1783. private slots:
  1784. void updateColumnName(const QString&value);
  1785. void updateHidden(bool hidden);
  1786. void updateConfiguration();
  1787. private:
  1788. SaltModel*channelSettingsModel;
  1789. };
  1790. /*:883*//*888:*/
  1791. #line 298 "./unsupportedserial.w"
  1792. class JavaScriptDevice:public QObject
  1793. {
  1794. Q_OBJECT
  1795. public:
  1796. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1797. QScriptEngine*engine);
  1798. Q_INVOKABLE int channelCount();
  1799. Channel*getChannel(int channel);
  1800. Q_INVOKABLE bool isChannelHidden(int channel);
  1801. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1802. Q_INVOKABLE QString channelColumnName(int channel);
  1803. Q_INVOKABLE QString channelIndicatorText(int channel);
  1804. public slots:
  1805. void setTemperatureColumn(int tcol);
  1806. void setAnnotationColumn(int ncol);
  1807. void start();
  1808. void stop();
  1809. signals:
  1810. void annotation(QString note,int tcol,int ncol);
  1811. void triggerStartBatch();
  1812. void triggerStopBatch();
  1813. void deviceStopRequested();
  1814. private:
  1815. QVariantMap deviceSettings;
  1816. QString deviceScript;
  1817. QList<Channel*> channelList;
  1818. QList<bool> hiddenState;
  1819. QList<Units::Unit> channelUnits;
  1820. QList<QString> columnNames;
  1821. QList<QString> indicatorTexts;
  1822. QList<QVariantMap> channelSettings;
  1823. int annotationTemperatureColumn;
  1824. int annotationNoteColumn;
  1825. QScriptEngine*scriptengine;
  1826. };
  1827. /*:888*//*913:*/
  1828. #line 11 "./phidgets.w"
  1829. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1830. {
  1831. Q_OBJECT
  1832. public:
  1833. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1834. const QModelIndex&index);
  1835. private slots:
  1836. void addChannel();
  1837. void updateRate(int ms);
  1838. };
  1839. /*:913*//*917:*/
  1840. #line 82 "./phidgets.w"
  1841. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1842. {
  1843. Q_OBJECT
  1844. public:
  1845. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1846. const QModelIndex&index);
  1847. private slots:
  1848. void updateColumnName(const QString&value);
  1849. void updateHidden(bool hidden);
  1850. void updateTC(int index);
  1851. void updateChannel(int channel);
  1852. private:
  1853. QComboBox*tcType;
  1854. };
  1855. /*:917*//*922:*/
  1856. #line 213 "./phidgets.w"
  1857. class PhidgetsTemperatureSensor:public QObject
  1858. {
  1859. Q_OBJECT
  1860. public:
  1861. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1862. Q_INVOKABLE int channelCount();
  1863. Channel*getChannel(int channel);
  1864. Q_INVOKABLE bool isChannelHidden(int channel);
  1865. Q_INVOKABLE QString channelColumnName(int channel);
  1866. Q_INVOKABLE QString channelIndicatorText(int channel);
  1867. public slots:
  1868. void start();
  1869. void stop();
  1870. private slots:
  1871. void getMeasurements();
  1872. private:
  1873. QList<int> channelIndices;
  1874. QList<int> tctypes;
  1875. QList<Channel*> channelList;
  1876. QMap<int,Channel*> channelMap;
  1877. QList<bool> hiddenState;
  1878. QList<QString> columnNames;
  1879. QList<QString> indicatorTexts;
  1880. QLibrary driver;
  1881. QTimer sampleTimer;
  1882. void*device;
  1883. /*926:*/
  1884. #line 349 "./phidgets.w"
  1885. #ifdef _WIN32
  1886. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1887. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1888. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1889. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1890. #else
  1891. typedef int(*PhidgetHandleOnly)(void*);
  1892. typedef int(*PhidgetHandleInt)(void*,int);
  1893. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1894. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1895. #endif
  1896. PhidgetHandleOnly createDevice;
  1897. PhidgetHandleInt openDevice;
  1898. PhidgetHandleInt waitForOpen;
  1899. PhidgetHandleIntInt setTCType;
  1900. PhidgetHandleIntDoubleOut getTemperature;
  1901. PhidgetHandleOnly closeDevice;
  1902. PhidgetHandleOnly deleteDevice;
  1903. /*:926*/
  1904. #line 240 "./phidgets.w"
  1905. };
  1906. /*:922*//*935:*/
  1907. #line 19351 "./typica.w"
  1908. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1909. {
  1910. Q_OBJECT
  1911. public:
  1912. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1913. const QModelIndex&index);
  1914. private slots:
  1915. void updateSourceColumn(const QString&source);
  1916. void updateDestinationColumn(const QString&dest);
  1917. void updateKnots();
  1918. private:
  1919. SaltModel*tablemodel;
  1920. };
  1921. /*:935*//*941:*/
  1922. #line 19481 "./typica.w"
  1923. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  1924. {
  1925. Q_OBJECT
  1926. public:
  1927. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  1928. const QModelIndex&index);
  1929. private slots:
  1930. void updateResetTime(QTime time);
  1931. };
  1932. /*:941*//*945:*/
  1933. #line 19547 "./typica.w"
  1934. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1935. {
  1936. Q_OBJECT
  1937. public:
  1938. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1939. private slots:
  1940. void updateStartButtonText(const QString&text);
  1941. void updateStopButtonText(const QString&text);
  1942. void updateStartColumnName(const QString&text);
  1943. void updateStopColumnName(const QString&text);
  1944. void updateStartValue(const QString&text);
  1945. void updateStopValue(const QString&text);
  1946. void updateStartTrigger(int option);
  1947. void updateStopTrigger(int option);
  1948. };
  1949. /*:945*//*950:*/
  1950. #line 19799 "./typica.w"
  1951. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  1952. {
  1953. Q_OBJECT
  1954. public:
  1955. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  1956. const QModelIndex&index);
  1957. private slots:
  1958. void updateColumnName(const QString&text);
  1959. void updateRangeData();
  1960. private:
  1961. SaltModel*tablemodel;
  1962. };
  1963. /*:950*//*955:*/
  1964. #line 19901 "./typica.w"
  1965. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1966. {
  1967. Q_OBJECT
  1968. public:
  1969. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1970. private slots:
  1971. void updateMatchingColumn(const QString&column);
  1972. void updateTemperature();
  1973. private:
  1974. QDoubleSpinBox*temperatureValue;
  1975. QComboBox*unitSelector;
  1976. };
  1977. /*:955*//*959:*/
  1978. #line 16 "./rate.w"
  1979. class RateOfChange:public QObject
  1980. {
  1981. Q_OBJECT
  1982. public:
  1983. RateOfChange(int cachetime= 1,int scaletime= 1);
  1984. public slots:
  1985. void newMeasurement(Measurement measure);
  1986. void setCacheTime(int seconds);
  1987. void setScaleTime(int seconds);
  1988. signals:
  1989. void newData(Measurement measure);
  1990. private:
  1991. int ct;
  1992. int st;
  1993. QList<Measurement> cache;
  1994. };
  1995. /*:959*//*967:*/
  1996. #line 177 "./rate.w"
  1997. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  1998. {
  1999. Q_OBJECT
  2000. public:
  2001. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2002. private slots:
  2003. void updateColumn(const QString&column);
  2004. void updateCacheTime(const QString&seconds);
  2005. void updateScaleTime(const QString&seconds);
  2006. };
  2007. /*:967*//*973:*/
  2008. #line 19 "./dataqsdk.w"
  2009. class DataqSdkDeviceImplementation;
  2010. class DataqSdkDevice:public QObject
  2011. {
  2012. Q_OBJECT
  2013. DataqSdkDeviceImplementation*imp;
  2014. private slots:
  2015. void threadFinished();
  2016. public:
  2017. DataqSdkDevice(QString device);
  2018. ~DataqSdkDevice();
  2019. Channel*newChannel(Units::Unit scale);
  2020. Q_INVOKABLE void setClockRate(double Hz);
  2021. Q_INVOKABLE void start();
  2022. static QStringList detectPorts();
  2023. static QStringList detectHardware();
  2024. };
  2025. /*:973*//*974:*/
  2026. #line 49 "./dataqsdk.w"
  2027. class DataqSdkDeviceImplementation:public QThread
  2028. {
  2029. Q_OBJECT
  2030. public:
  2031. DataqSdkDeviceImplementation();
  2032. ~DataqSdkDeviceImplementation();
  2033. void run();
  2034. /*975:*/
  2035. #line 70 "./dataqsdk.w"
  2036. typedef struct di_inlist_struct{
  2037. unsigned short chan;
  2038. unsigned short diff;
  2039. unsigned short gain;
  2040. unsigned short unipolar;
  2041. unsigned short dig_out_enable;
  2042. unsigned short dig_out;
  2043. unsigned short ave;
  2044. unsigned short counter;
  2045. }DI_INLIST_STRUCT;
  2046. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2047. typedef int(PASCAL*FPDICLOSE)(void);
  2048. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2049. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2050. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2051. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2052. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2053. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2054. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2055. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2056. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2057. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2058. FPDIOPEN di_open;
  2059. FPDICLOSE di_close;
  2060. FPDISAMPLERATE di_sample_rate;
  2061. FPDIMAXIMUMRATE di_maximum_rate;
  2062. FPDILISTLENGTH di_list_length;
  2063. FPDIINLIST di_inlist;
  2064. FPDIBUFFERALLOC di_buffer_alloc;
  2065. FPDISTARTSCAN di_start_scan;
  2066. FPDISTATUSREAD di_status_read;
  2067. FPDIBUFFERSTATUS di_buffer_status;
  2068. FPDIBURSTRATE di_burst_rate;
  2069. FPDISTOPSCAN di_stop_scan;
  2070. /*:975*/
  2071. #line 57 "./dataqsdk.w"
  2072. /*977:*/
  2073. #line 134 "./dataqsdk.w"
  2074. bool isOpen;
  2075. double sampleRate;
  2076. long oversample;
  2077. long burstDivisor;
  2078. QString device;
  2079. unsigned deviceNumber;
  2080. QVector<Channel*> channelMap;
  2081. int error;
  2082. int channels;
  2083. bool ready;
  2084. QLibrary*driver;
  2085. QVector<Units::Unit> unitMap;
  2086. int*input_buffer;
  2087. QTimer*eventClock;
  2088. QMultiMap<int,double> smoother;
  2089. /*:977*/
  2090. #line 58 "./dataqsdk.w"
  2091. public slots:
  2092. void measure();
  2093. private:
  2094. qint16*buffer;
  2095. };
  2096. /*:974*//*994:*/
  2097. #line 663 "./dataqsdk.w"
  2098. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2099. {
  2100. Q_OBJECT
  2101. public:
  2102. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2103. const QModelIndex&index);
  2104. private slots:
  2105. void updateAutoSelect(bool automatic);
  2106. void updateDeviceNumber(int deviceNumber);
  2107. void updatePort(QString portId);
  2108. void addChannel();
  2109. private:
  2110. QStackedWidget*deviceIdStack;
  2111. };
  2112. /*:994*//*999:*/
  2113. #line 808 "./dataqsdk.w"
  2114. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2115. {
  2116. Q_OBJECT
  2117. public:
  2118. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2119. const QModelIndex&index);
  2120. private slots:
  2121. void updateUnits(const QString&unit);
  2122. void updateColumnName(const QString&value);
  2123. void updateMeasuredLower(const QString&value);
  2124. void updateMeasuredUpper(const QString&value);
  2125. void updateMappedLower(const QString&value);
  2126. void updateMappedUpper(const QString&value);
  2127. void updateClosedInterval(bool closed);
  2128. void updateSmoothingEnabled(bool enabled);
  2129. void updateSensitivity(const QString&value);
  2130. void startCalibration();
  2131. void stopCalibration();
  2132. void resetCalibration();
  2133. void updateInput(Measurement measure);
  2134. void updateOutput(Measurement measure);
  2135. void updateHidden(bool hidden);
  2136. private:
  2137. QPushButton*startButton;
  2138. QPushButton*resetButton;
  2139. QPushButton*stopButton;
  2140. /*1004:*/
  2141. #line 1098 "./dataqsdk.w"
  2142. bool autoSelect;
  2143. QString deviceID;
  2144. unsigned int channelOfInterest;
  2145. /*:1004*/
  2146. #line 835 "./dataqsdk.w"
  2147. DataqSdkDevice*calibrationDevice;
  2148. LinearCalibrator*calibrator;
  2149. QLineEdit*currentMeasurement;
  2150. QLineEdit*minimumMeasurement;
  2151. QLineEdit*maximumMeasurement;
  2152. QLineEdit*averageMeasurement;
  2153. QLineEdit*currentMapped;
  2154. QLineEdit*minimumMapped;
  2155. QLineEdit*maximumMapped;
  2156. QLineEdit*averageMapped;
  2157. int rmCount;
  2158. int cmCount;
  2159. double rmin;
  2160. double rmax;
  2161. double rmean;
  2162. double cmin;
  2163. double cmax;
  2164. double cmean;
  2165. };
  2166. /*:999*//*1026:*/
  2167. #line 273 "./scales.w"
  2168. Q_DECLARE_METATYPE(BaudRateType)
  2169. Q_DECLARE_METATYPE(DataBitsType)
  2170. Q_DECLARE_METATYPE(ParityType)
  2171. Q_DECLARE_METATYPE(StopBitsType)
  2172. Q_DECLARE_METATYPE(FlowType)
  2173. /*:1026*//*1033:*/
  2174. #line 396 "./scales.w"
  2175. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2176. {
  2177. Q_OBJECT
  2178. public:
  2179. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2180. const QModelIndex&index);
  2181. private slots:
  2182. void updatePort(const QString&newPort);
  2183. void updateBaudRate(const QString&rate);
  2184. void updateParity(int index);
  2185. void updateFlowControl(int index);
  2186. void updateStopBits(int index);
  2187. void updateWeighCommand(const QString&command);
  2188. void updateCommandTerminator(const QString&terminator);
  2189. private:
  2190. PortSelector*port;
  2191. BaudSelector*baud;
  2192. ParitySelector*parity;
  2193. FlowSelector*flow;
  2194. StopSelector*stop;
  2195. QLineEdit*weighcommand;
  2196. QComboBox*commandterminator;
  2197. };
  2198. /*:1033*//*1038:*/
  2199. #line 14 "./valueannotation.w"
  2200. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2201. {
  2202. Q_OBJECT
  2203. public:
  2204. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2205. const QModelIndex&index);
  2206. private slots:
  2207. void updateSourceColumn(const QString&source);
  2208. void updateAnnotations();
  2209. void updateStart(bool noteOnStart);
  2210. private:
  2211. SaltModel*tablemodel;
  2212. };
  2213. /*:1038*//*1046:*/
  2214. #line 165 "./valueannotation.w"
  2215. class ValueAnnotation:public QObject
  2216. {
  2217. Q_OBJECT
  2218. public:
  2219. ValueAnnotation();
  2220. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2221. public slots:
  2222. void newMeasurement(Measurement measure);
  2223. void annotate();
  2224. void setAnnotationColumn(int column);
  2225. void setTemperatureColumn(int column);
  2226. void setTolerance(double epsilon);
  2227. signals:
  2228. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2229. private:
  2230. int lastIndex;
  2231. int annotationColumn;
  2232. int measurementColumn;
  2233. QList<double> values;
  2234. QStringList annotations;
  2235. double tolerance;
  2236. };
  2237. /*:1046*//*1055:*/
  2238. #line 14 "./thresholdannotation.w"
  2239. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2240. {
  2241. Q_OBJECT
  2242. public:
  2243. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2244. const QModelIndex&index);
  2245. private slots:
  2246. void updateSourceColumn(const QString&source);
  2247. void updateThreshold(double value);
  2248. void updateDirection(int index);
  2249. void updateAnnotation(const QString&note);
  2250. };
  2251. /*:1055*//*1062:*/
  2252. #line 142 "./thresholdannotation.w"
  2253. class Annotator:public QObject
  2254. {
  2255. Q_OBJECT
  2256. QString note;
  2257. int tc;
  2258. int ac;
  2259. QTimer t;
  2260. public:
  2261. Annotator(const QString&text);
  2262. public slots:
  2263. void setAnnotation(const QString&annotation);
  2264. void setTemperatureColumn(int tempcolumn);
  2265. void setAnnotationColumn(int annotationcolumn);
  2266. void annotate();
  2267. private slots:
  2268. void catchTimer();
  2269. signals:
  2270. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2271. };
  2272. /*:1062*/
  2273. #line 526 "./typica.w"
  2274. /*12:*/
  2275. #line 811 "./typica.w"
  2276. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2277. /*:12*//*14:*/
  2278. #line 826 "./typica.w"
  2279. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2280. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2281. /*:14*//*16:*/
  2282. #line 851 "./typica.w"
  2283. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2284. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2285. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2286. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2287. QScriptEngine*engine);
  2288. /*:16*//*20:*/
  2289. #line 941 "./typica.w"
  2290. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2291. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2292. /*:20*//*30:*/
  2293. #line 1142 "./typica.w"
  2294. QScriptValue constructQMainWindow(QScriptContext*context,
  2295. QScriptEngine*engine);
  2296. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2297. QScriptEngine*engine);
  2298. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2299. QScriptEngine*engine);
  2300. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2301. /*:30*//*35:*/
  2302. #line 1241 "./typica.w"
  2303. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2304. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2305. /*:35*//*38:*/
  2306. #line 1286 "./typica.w"
  2307. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2308. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2309. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2310. /*:38*//*41:*/
  2311. #line 1352 "./typica.w"
  2312. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2313. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2314. /*:41*//*44:*/
  2315. #line 1385 "./typica.w"
  2316. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2317. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2318. /*:44*//*47:*/
  2319. #line 1423 "./typica.w"
  2320. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2321. QScriptValue constructQSvgWidget(QScriptContext*context,
  2322. QScriptEngine*engine);
  2323. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2324. QScriptEngine*engine);
  2325. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2326. QStack<QLayout*> *layoutStack);
  2327. /*:47*//*53:*/
  2328. #line 1510 "./typica.w"
  2329. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2330. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2331. /*:53*//*57:*/
  2332. #line 1549 "./typica.w"
  2333. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2334. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2335. QScriptEngine*engine);
  2336. QScriptValue QSplitter_saveState(QScriptContext*context,
  2337. QScriptEngine*engine);
  2338. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2339. QScriptEngine*engine);
  2340. QScriptValue QSplitter_count(QScriptContext*context,
  2341. QScriptEngine*engine);
  2342. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2343. /*:57*//*63:*/
  2344. #line 1688 "./typica.w"
  2345. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2346. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2347. /*:63*//*65:*/
  2348. #line 1743 "./typica.w"
  2349. QScriptValue constructQBoxLayout(QScriptContext*context,
  2350. QScriptEngine*engine);
  2351. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2352. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2353. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2354. /*:65*//*69:*/
  2355. #line 1856 "./typica.w"
  2356. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2357. QScriptValue QAction_setShortcut(QScriptContext*context,
  2358. QScriptEngine*engine);
  2359. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2360. /*:69*//*72:*/
  2361. #line 1912 "./typica.w"
  2362. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2363. QScriptEngine*engine);
  2364. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2365. QScriptEngine*engine);
  2366. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2367. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2368. /*:72*//*77:*/
  2369. #line 2023 "./typica.w"
  2370. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2371. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2372. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2373. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2374. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2375. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2376. QScriptValue QIODevice_readToString(QScriptContext*context,
  2377. QScriptEngine*engine);
  2378. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2379. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2380. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2381. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2382. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2383. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2384. /*:77*//*88:*/
  2385. #line 2249 "./typica.w"
  2386. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2387. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2388. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2389. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2390. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2391. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2392. /*:88*//*96:*/
  2393. #line 2367 "./typica.w"
  2394. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2395. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2396. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2397. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2398. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2399. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2400. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2401. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2402. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2403. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2404. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2405. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2406. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2407. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2408. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2409. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2410. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2411. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2412. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2413. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2414. /*:96*//*109:*/
  2415. #line 2641 "./typica.w"
  2416. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2417. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2418. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2419. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2420. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2421. /*:109*//*112:*/
  2422. #line 2746 "./typica.w"
  2423. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2424. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2425. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2426. /*:112*//*115:*/
  2427. #line 2791 "./typica.w"
  2428. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2429. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2430. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2431. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2432. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2433. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2434. /*:115*//*121:*/
  2435. #line 2873 "./typica.w"
  2436. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2437. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2438. QScriptEngine*engine);
  2439. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2440. QScriptEngine*engine);
  2441. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2442. QScriptEngine*engine);
  2443. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2444. QScriptEngine*engine);
  2445. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2446. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2447. QScriptEngine*engine);
  2448. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2449. QScriptEngine*engine);
  2450. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2451. QScriptEngine*engine);
  2452. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2453. QScriptEngine*engine);
  2454. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2455. QScriptEngine*engine);
  2456. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2457. QScriptEngine*engine);
  2458. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2459. QScriptEngine*engine);
  2460. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2461. QScriptEngine*engine);
  2462. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2463. /*:121*//*130:*/
  2464. #line 3091 "./typica.w"
  2465. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2466. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2467. QScriptValue XmlReader_attribute(QScriptContext*context,
  2468. QScriptEngine*engine);
  2469. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2470. QScriptEngine*engine);
  2471. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2472. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2473. QScriptEngine*engine);
  2474. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2475. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2476. QScriptEngine*engine);
  2477. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2478. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2479. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2480. /*:130*//*137:*/
  2481. #line 3226 "./typica.w"
  2482. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2483. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2484. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2485. /*:137*//*141:*/
  2486. #line 3308 "./typica.w"
  2487. QScriptValue constructQLCDNumber(QScriptContext*context,
  2488. QScriptEngine*engine);
  2489. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2490. /*:141*//*144:*/
  2491. #line 3346 "./typica.w"
  2492. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2493. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2494. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2495. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2496. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2497. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2498. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2499. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2500. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2501. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2502. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2503. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2504. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2505. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2506. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2507. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2508. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2509. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2510. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2511. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2512. /*:144*//*160:*/
  2513. #line 3824 "./typica.w"
  2514. void setQAbstractScrollAreaProperties(QScriptValue value,
  2515. QScriptEngine*engine);
  2516. /*:160*//*162:*/
  2517. #line 3839 "./typica.w"
  2518. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2519. /*:162*//*164:*/
  2520. #line 3852 "./typica.w"
  2521. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2522. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2523. /*:164*//*166:*/
  2524. #line 3876 "./typica.w"
  2525. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2526. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2527. QScriptValue constructQPushButton(QScriptContext*context,
  2528. QScriptEngine*engine);
  2529. /*:166*//*173:*/
  2530. #line 3975 "./typica.w"
  2531. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2532. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2533. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2534. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2535. QScriptEngine*engine);
  2536. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2537. QScriptEngine*engine);
  2538. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2539. QScriptEngine*engine);
  2540. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2541. QScriptEngine*engine);
  2542. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2543. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2544. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2545. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2546. /*:173*//*180:*/
  2547. #line 4146 "./typica.w"
  2548. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2549. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2550. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2551. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2552. QScriptValue annotationFromRecord(QScriptContext*context,
  2553. QScriptEngine*engine);
  2554. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2555. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2556. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2557. /*:180*//*193:*/
  2558. #line 4478 "./typica.w"
  2559. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2560. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2561. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2562. QStack<QLayout*> *layoutStack);
  2563. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2564. QStack<QLayout*> *layoutStack);
  2565. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2566. QStack<QLayout*> *layoutStack);
  2567. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2568. QStack<QLayout*> *layoutStack);
  2569. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2570. QStack<QLayout*> *layoutStack);
  2571. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2572. QStack<QLayout*> *layoutStack);
  2573. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2574. QStack<QLayout*> *layoutStack);
  2575. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2576. QStack<QLayout*> *layoutStack);
  2577. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2578. QStack<QLayout*> *layoutStack);
  2579. void addTemperatureDisplayToSplitter(QDomElement element,
  2580. QStack<QWidget*> *widgetStack,
  2581. QStack<QLayout*> *layoutStack);
  2582. void addTemperatureDisplayToLayout(QDomElement element,
  2583. QStack<QWidget*> *widgetStack,
  2584. QStack<QLayout*> *layoutStack);
  2585. void addTimerDisplayToSplitter(QDomElement element,
  2586. QStack<QWidget*> *widgetStack,
  2587. QStack<QLayout*> *layoutStack);
  2588. void addTimerDisplayToLayout(QDomElement element,
  2589. QStack<QWidget*> *widgetStack,
  2590. QStack<QLayout*> *layoutStack);
  2591. void addDecorationToSplitter(QDomElement element,
  2592. QStack<QWidget*> *widgetStack,
  2593. QStack<QLayout*> *layoutStack);
  2594. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2595. QStack<QLayout*> *layoutStack);
  2596. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2597. QStack<QLayout*> *layoutStack);
  2598. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2599. QStack<QLayout*> *layoutStack);
  2600. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2601. QStack<QLayout*> *layoutStack);
  2602. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2603. QStack<QLayout*> *layoutStack);
  2604. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2605. QStack<QLayout*> *layoutStack);
  2606. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2607. QStack<QLayout*> *layoutStack);
  2608. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2609. QStack<QLayout*> *layoutStack);
  2610. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2611. QStack<QLayout*> *layoutStack);
  2612. void addSqlQueryViewToLayout(QDomElement element,
  2613. QStack<QWidget*> *widgetStack,
  2614. QStack<QLayout*> *layoutStack);
  2615. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2616. QStack<QLayout*> *layoutStack);
  2617. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2618. QStack<QLayout*> *layoutStack);
  2619. /*:193*//*257:*/
  2620. #line 6160 "./typica.w"
  2621. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2622. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2623. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2624. QScriptEngine*engine);
  2625. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2626. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2627. QScriptEngine*engine);
  2628. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2629. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2630. /*:257*//*258:*/
  2631. #line 6176 "./typica.w"
  2632. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2633. /*:258*//*262:*/
  2634. #line 6315 "./typica.w"
  2635. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2636. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2637. QScriptEngine*engine);
  2638. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2639. QScriptEngine*engine);
  2640. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2641. QScriptEngine*engine);
  2642. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2643. QScriptEngine*engine);
  2644. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2645. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2646. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2647. QScriptEngine*engine);
  2648. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2649. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2650. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2651. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2652. /*:262*//*272:*/
  2653. #line 6531 "./typica.w"
  2654. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2655. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2656. QScriptValue QComboBox_currentData(QScriptContext*context,
  2657. QScriptEngine*engine);
  2658. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2659. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2660. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2661. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2662. /*:272*//*284:*/
  2663. #line 379 "./units.w"
  2664. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2665. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  2666. QScriptEngine*engine);
  2667. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  2668. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  2669. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  2670. /*:284*//*288:*/
  2671. #line 443 "./units.w"
  2672. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  2673. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  2674. /*:288*//*297:*/
  2675. #line 133 "./measurement.w"
  2676. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  2677. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  2678. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  2679. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  2680. /*:297*//*317:*/
  2681. #line 7166 "./typica.w"
  2682. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  2683. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2684. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  2685. /*:317*//*326:*/
  2686. #line 7371 "./typica.w"
  2687. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  2688. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  2689. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  2690. /*:326*//*331:*/
  2691. #line 7472 "./typica.w"
  2692. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  2693. /*:331*//*337:*/
  2694. #line 7654 "./typica.w"
  2695. QScriptValue constructLinearCalibrator(QScriptContext*context,
  2696. QScriptEngine*engine);
  2697. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  2698. /*:337*//*342:*/
  2699. #line 7794 "./typica.w"
  2700. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  2701. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  2702. /*:342*//*352:*/
  2703. #line 7999 "./typica.w"
  2704. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  2705. QScriptEngine*engine);
  2706. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2707. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  2708. QScriptEngine*engine);
  2709. /*:352*//*360:*/
  2710. #line 8158 "./typica.w"
  2711. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  2712. QScriptEngine*engine);
  2713. void setMeasurementTimeOffsetProperties(QScriptValue value,
  2714. QScriptEngine*engine);
  2715. /*:360*//*365:*/
  2716. #line 8271 "./typica.w"
  2717. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  2718. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  2719. /*:365*//*370:*/
  2720. #line 8369 "./typica.w"
  2721. QScriptValue constructZeroEmitter(QScriptContext*context,
  2722. QScriptEngine*engine);
  2723. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  2724. /*:370*//*375:*/
  2725. #line 8448 "./typica.w"
  2726. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  2727. QScriptEngine*engine);
  2728. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  2729. /*:375*//*392:*/
  2730. #line 8912 "./typica.w"
  2731. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  2732. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  2733. /*:392*//*415:*/
  2734. #line 9539 "./typica.w"
  2735. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  2736. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  2737. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  2738. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  2739. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  2740. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  2741. QScriptEngine*engine);
  2742. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  2743. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  2744. QScriptEngine*engnie);
  2745. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  2746. QScriptEngine*engine);
  2747. /*:415*//*453:*/
  2748. #line 10496 "./typica.w"
  2749. QScriptValue constructAnnotationButton(QScriptContext*context,
  2750. QScriptEngine*engine);
  2751. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  2752. /*:453*//*461:*/
  2753. #line 10636 "./typica.w"
  2754. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  2755. QScriptEngine*engine);
  2756. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2757. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2758. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  2759. /*:461*//*482:*/
  2760. #line 11062 "./typica.w"
  2761. QScriptValue constructTimerDisplay(QScriptContext*context,
  2762. QScriptEngine*engine);
  2763. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  2764. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  2765. /*:482*//*510:*/
  2766. #line 11587 "./typica.w"
  2767. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2768. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2769. QScriptEngine*engine);
  2770. /*:510*//*523:*/
  2771. #line 11870 "./typica.w"
  2772. QScriptValue constructLogEditWindow(QScriptContext*context,
  2773. QScriptEngine*engine);
  2774. /*:523*//*542:*/
  2775. #line 12397 "./typica.w"
  2776. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2777. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2778. /*:542*//*560:*/
  2779. #line 189 "./webview.w"
  2780. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2781. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2782. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2783. QStack<QLayout*> *layoutStack);
  2784. /*:560*//*563:*/
  2785. #line 219 "./webview.w"
  2786. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  2787. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  2788. /*:563*//*567:*/
  2789. #line 277 "./webview.w"
  2790. QScriptValue constructWebElement(QScriptContext*context,
  2791. QScriptEngine*engine);
  2792. /*:567*//*636:*/
  2793. #line 13744 "./typica.w"
  2794. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2795. QScriptValue constructSqlQueryView(QScriptContext*context,
  2796. QScriptEngine*engine);
  2797. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2798. QScriptEngine*engine);
  2799. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2800. QScriptEngine*engine);
  2801. /*:636*//*646:*/
  2802. #line 13983 "./typica.w"
  2803. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2804. QStack<QLayout*> *layoutStack);
  2805. /*:646*//*662:*/
  2806. #line 14268 "./typica.w"
  2807. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2808. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2809. /*:662*//*684:*/
  2810. #line 482 "./daterangeselector.w"
  2811. void addDateRangeToLayout(QDomElement element,
  2812. QStack<QWidget*> *widgetStack,
  2813. QStack<QLayout*> *layoutStack);
  2814. /*:684*//*693:*/
  2815. #line 14465 "./typica.w"
  2816. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2817. QStack<QLayout*> *layoutStack);
  2818. /*:693*//*714:*/
  2819. #line 15049 "./typica.w"
  2820. void addScaleControlToLayout(QDomElement element,
  2821. QStack<QWidget*> *widgetStack,
  2822. QStack<QLayout*> *layoutStack);
  2823. void addIntensityControlToLayout(QDomElement element,
  2824. QStack<QWidget*> *widgetStack,
  2825. QStack<QLayout*> *layoutStack);
  2826. /*:714*//*740:*/
  2827. #line 15635 "./typica.w"
  2828. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2829. QScriptEngine*engine);
  2830. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2831. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2832. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2833. QScriptEngine*engine);
  2834. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2835. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2836. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2837. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2838. /*:740*//*746:*/
  2839. #line 15777 "./typica.w"
  2840. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2841. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2842. /*:746*//*762:*/
  2843. #line 16075 "./typica.w"
  2844. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2845. QScriptEngine*engine);
  2846. /*:762*//*833:*/
  2847. #line 42 "./settings.w"
  2848. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  2849. /*:833*//*857:*/
  2850. #line 18718 "./typica.w"
  2851. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2852. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2853. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2854. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2855. /*:857*//*875:*/
  2856. #line 638 "./modbus.w"
  2857. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  2858. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  2859. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  2860. /*:875*//*889:*/
  2861. #line 345 "./unsupportedserial.w"
  2862. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  2863. /*:889*//*895:*/
  2864. #line 425 "./unsupportedserial.w"
  2865. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  2866. /*:895*//*901:*/
  2867. #line 617 "./unsupportedserial.w"
  2868. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  2869. /*:901*//*905:*/
  2870. #line 651 "./unsupportedserial.w"
  2871. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  2872. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  2873. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  2874. /*:905*//*932:*/
  2875. #line 457 "./phidgets.w"
  2876. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  2877. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  2878. /*:932*//*964:*/
  2879. #line 138 "./rate.w"
  2880. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  2881. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  2882. /*:964*//*989:*/
  2883. #line 597 "./dataqsdk.w"
  2884. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  2885. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  2886. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2887. /*:989*//*1016:*/
  2888. #line 67 "./scales.w"
  2889. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  2890. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  2891. /*:1016*//*1024:*/
  2892. #line 259 "./scales.w"
  2893. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  2894. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  2895. /*:1024*//*1027:*/
  2896. #line 284 "./scales.w"
  2897. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  2898. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  2899. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  2900. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  2901. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  2902. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  2903. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  2904. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  2905. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  2906. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  2907. /*:1027*//*1052:*/
  2908. #line 265 "./valueannotation.w"
  2909. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  2910. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  2911. /*:1052*//*1065:*/
  2912. #line 209 "./thresholdannotation.w"
  2913. QScriptValue constructAnnotator(QScriptContext*context,
  2914. QScriptEngine*engine);
  2915. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  2916. /*:1065*/
  2917. #line 527 "./typica.w"
  2918. /*616:*/
  2919. #line 13393 "./typica.w"
  2920. void messageFileOutput(QtMsgType type,const char*msg);
  2921. /*:616*/
  2922. #line 528 "./typica.w"
  2923. /*4:*/
  2924. #line 537 "./typica.w"
  2925. /*754:*/
  2926. #line 15898 "./typica.w"
  2927. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2928. const QString&driver,QObject*parent):
  2929. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2930. {
  2931. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2932. }
  2933. void NodeInserter::onTriggered()
  2934. {
  2935. emit triggered(defaultNodeName,driverString);
  2936. }
  2937. /*:754*/
  2938. #line 538 "./typica.w"
  2939. /*293:*/
  2940. #line 40 "./measurement.w"
  2941. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  2942. {
  2943. insert("measurement",temperature);
  2944. insert("time",time);
  2945. insert("unit",sc);
  2946. }
  2947. Measurement::Measurement(double temperature)
  2948. {
  2949. insert("measurement",temperature);
  2950. insert("time",QTime::currentTime());
  2951. insert("unit",Units::Fahrenheit);
  2952. }
  2953. void Measurement::setTemperature(double temperature)
  2954. {
  2955. insert("measurement",temperature);
  2956. }
  2957. void Measurement::setTime(QTime time)
  2958. {
  2959. insert("time",time);
  2960. }
  2961. void Measurement::setUnit(Units::Unit scale)
  2962. {
  2963. insert("unit",scale);
  2964. }
  2965. double Measurement::temperature()const
  2966. {
  2967. return value("measurement").toDouble();
  2968. }
  2969. QTime Measurement::time()const
  2970. {
  2971. return value("time").toTime();
  2972. }
  2973. Units::Unit Measurement::scale()const
  2974. {
  2975. return(Units::Unit)(value("unit").toInt());
  2976. }
  2977. /*:293*//*294:*/
  2978. #line 88 "./measurement.w"
  2979. Measurement Measurement::toFahrenheit()
  2980. {
  2981. return Measurement(Units::convertTemperature(this->temperature(),
  2982. this->scale(),Units::Fahrenheit),
  2983. this->time(),Units::Fahrenheit);
  2984. }
  2985. Measurement Measurement::toCelsius()
  2986. {
  2987. return Measurement(Units::convertTemperature(this->temperature(),
  2988. this->scale(),Units::Celsius),
  2989. this->time(),Units::Celsius);
  2990. }
  2991. Measurement Measurement::toKelvin()
  2992. {
  2993. return Measurement(Units::convertTemperature(this->temperature(),
  2994. this->scale(),Units::Kelvin),
  2995. this->time(),Units::Kelvin);
  2996. }
  2997. Measurement Measurement::toRankine()
  2998. {
  2999. return Measurement(Units::convertTemperature(this->temperature(),
  3000. this->scale(),Units::Rankine),
  3001. this->time(),Units::Rankine);
  3002. }
  3003. /*:294*/
  3004. #line 539 "./typica.w"
  3005. /*307:*/
  3006. #line 6771 "./typica.w"
  3007. void DAQImplementation::measure()
  3008. {
  3009. int samplesRead= 0;
  3010. double buffer[channels];
  3011. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3012. (unsigned long)(0),buffer,(unsigned long)(channels),
  3013. &samplesRead,(signed long)(0));
  3014. if(error)
  3015. {
  3016. ready= false;
  3017. }
  3018. else
  3019. {
  3020. if(samplesRead)
  3021. {
  3022. QTime time= QTime::currentTime();
  3023. for(int i= 0;i<samplesRead;i++)
  3024. {
  3025. for(int j= 0;j<channels;j++)
  3026. {
  3027. double measuredValue= buffer[j+(i*channels)];
  3028. Measurement measure(measuredValue,time,
  3029. unitMap[j]);
  3030. channelMap[j]->input(measure);
  3031. }
  3032. }
  3033. }
  3034. }
  3035. }
  3036. /*:307*//*308:*/
  3037. #line 6814 "./typica.w"
  3038. void DAQImplementation::run()
  3039. {
  3040. setPriority(QThread::TimeCriticalPriority);
  3041. while(ready)
  3042. {
  3043. measure();
  3044. }
  3045. }
  3046. /*:308*//*309:*/
  3047. #line 6830 "./typica.w"
  3048. void DAQ::threadFinished()
  3049. {
  3050. if(imp->error)
  3051. {
  3052. /*310:*/
  3053. #line 6881 "./typica.w"
  3054. imp->ready= false;
  3055. QMessageBox warning;
  3056. warning.setStandardButtons(QMessageBox::Cancel);
  3057. warning.setIcon(QMessageBox::Warning);
  3058. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3059. unsigned long bytes= imp->errorInfo(NULL,0);
  3060. char string[bytes];
  3061. imp->errorInfo(string,bytes);
  3062. warning.setInformativeText(QString(string));
  3063. warning.setWindowTitle(QString(PROGRAM_NAME));
  3064. warning.exec();
  3065. /*:310*/
  3066. #line 6835 "./typica.w"
  3067. }
  3068. }
  3069. /*:309*//*311:*/
  3070. #line 6906 "./typica.w"
  3071. void DAQ::start()
  3072. {
  3073. if(imp->ready)
  3074. {
  3075. imp->error= imp->startTask(imp->handle);
  3076. if(imp->error)
  3077. {
  3078. /*310:*/
  3079. #line 6881 "./typica.w"
  3080. imp->ready= false;
  3081. QMessageBox warning;
  3082. warning.setStandardButtons(QMessageBox::Cancel);
  3083. warning.setIcon(QMessageBox::Warning);
  3084. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3085. unsigned long bytes= imp->errorInfo(NULL,0);
  3086. char string[bytes];
  3087. imp->errorInfo(string,bytes);
  3088. warning.setInformativeText(QString(string));
  3089. warning.setWindowTitle(QString(PROGRAM_NAME));
  3090. warning.exec();
  3091. /*:310*/
  3092. #line 6914 "./typica.w"
  3093. }
  3094. else
  3095. {
  3096. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3097. imp->start();
  3098. }
  3099. }
  3100. }
  3101. void DAQ::stop()
  3102. {
  3103. if(imp->useBase)
  3104. {
  3105. imp->ready= false;
  3106. imp->wait(ULONG_MAX);
  3107. imp->stopTask(imp->handle);
  3108. }
  3109. else
  3110. {
  3111. imp->ready= false;
  3112. imp->error= imp->stopTask(imp->handle);
  3113. if(imp->error)
  3114. {
  3115. /*310:*/
  3116. #line 6881 "./typica.w"
  3117. imp->ready= false;
  3118. QMessageBox warning;
  3119. warning.setStandardButtons(QMessageBox::Cancel);
  3120. warning.setIcon(QMessageBox::Warning);
  3121. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3122. unsigned long bytes= imp->errorInfo(NULL,0);
  3123. char string[bytes];
  3124. imp->errorInfo(string,bytes);
  3125. warning.setInformativeText(QString(string));
  3126. warning.setWindowTitle(QString(PROGRAM_NAME));
  3127. warning.exec();
  3128. /*:310*/
  3129. #line 6938 "./typica.w"
  3130. }
  3131. imp->error= imp->clearTask(imp->handle);
  3132. if(imp->error)
  3133. {
  3134. /*310:*/
  3135. #line 6881 "./typica.w"
  3136. imp->ready= false;
  3137. QMessageBox warning;
  3138. warning.setStandardButtons(QMessageBox::Cancel);
  3139. warning.setIcon(QMessageBox::Warning);
  3140. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3141. unsigned long bytes= imp->errorInfo(NULL,0);
  3142. char string[bytes];
  3143. imp->errorInfo(string,bytes);
  3144. warning.setInformativeText(QString(string));
  3145. warning.setWindowTitle(QString(PROGRAM_NAME));
  3146. warning.exec();
  3147. /*:310*/
  3148. #line 6943 "./typica.w"
  3149. }
  3150. }
  3151. }
  3152. /*:311*//*312:*/
  3153. #line 6953 "./typica.w"
  3154. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3155. {
  3156. imp->device= device;
  3157. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3158. if(imp->error)
  3159. {
  3160. /*310:*/
  3161. #line 6881 "./typica.w"
  3162. imp->ready= false;
  3163. QMessageBox warning;
  3164. warning.setStandardButtons(QMessageBox::Cancel);
  3165. warning.setIcon(QMessageBox::Warning);
  3166. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3167. unsigned long bytes= imp->errorInfo(NULL,0);
  3168. char string[bytes];
  3169. imp->errorInfo(string,bytes);
  3170. warning.setInformativeText(QString(string));
  3171. warning.setWindowTitle(QString(PROGRAM_NAME));
  3172. warning.exec();
  3173. /*:310*/
  3174. #line 6960 "./typica.w"
  3175. }
  3176. else
  3177. {
  3178. imp->ready= true;
  3179. }
  3180. }
  3181. /*:312*//*313:*/
  3182. #line 6974 "./typica.w"
  3183. Channel*DAQ::newChannel(int units,int thermocouple)
  3184. {
  3185. Channel*retval= new Channel();
  3186. imp->channelMap[imp->channels]= retval;
  3187. imp->unitMap[imp->channels]= (Units::Unit)units;
  3188. imp->channels++;
  3189. if(imp->ready)
  3190. {
  3191. if(imp->useBase)
  3192. {
  3193. imp->error= imp->createChannel(imp->handle,
  3194. QString("%1/ai%2").arg(imp->device).
  3195. arg(imp->channels-1).
  3196. toAscii().data(),
  3197. "",(double)(-1.0),(double)(100.0),
  3198. (signed long)(units),
  3199. (signed long)(thermocouple),
  3200. (signed long)(10200),(double)(0),
  3201. "");
  3202. }
  3203. else
  3204. {
  3205. imp->error= imp->createChannel(imp->handle,
  3206. QString("%1/ai%2").arg(imp->device).
  3207. arg(imp->channels-1).
  3208. toAscii().data(),
  3209. "",(double)(50.0),(double)(500.0),
  3210. (signed long)(units),
  3211. (signed long)(thermocouple),
  3212. (signed long)(10200),(double)(0),
  3213. "");
  3214. }
  3215. if(imp->error)
  3216. {
  3217. /*310:*/
  3218. #line 6881 "./typica.w"
  3219. imp->ready= false;
  3220. QMessageBox warning;
  3221. warning.setStandardButtons(QMessageBox::Cancel);
  3222. warning.setIcon(QMessageBox::Warning);
  3223. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3224. unsigned long bytes= imp->errorInfo(NULL,0);
  3225. char string[bytes];
  3226. imp->errorInfo(string,bytes);
  3227. warning.setInformativeText(QString(string));
  3228. warning.setWindowTitle(QString(PROGRAM_NAME));
  3229. warning.exec();
  3230. /*:310*/
  3231. #line 7009 "./typica.w"
  3232. }
  3233. }
  3234. return retval;
  3235. }
  3236. /*:313*//*314:*/
  3237. #line 7023 "./typica.w"
  3238. void DAQ::setClockRate(double Hz)
  3239. {
  3240. if(imp->ready)
  3241. {
  3242. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3243. (signed long)(10280),(signed long)(10123),
  3244. (unsigned long long)(1));
  3245. if(imp->error)
  3246. {
  3247. /*310:*/
  3248. #line 6881 "./typica.w"
  3249. imp->ready= false;
  3250. QMessageBox warning;
  3251. warning.setStandardButtons(QMessageBox::Cancel);
  3252. warning.setIcon(QMessageBox::Warning);
  3253. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3254. unsigned long bytes= imp->errorInfo(NULL,0);
  3255. char string[bytes];
  3256. imp->errorInfo(string,bytes);
  3257. warning.setInformativeText(QString(string));
  3258. warning.setWindowTitle(QString(PROGRAM_NAME));
  3259. warning.exec();
  3260. /*:310*/
  3261. #line 7033 "./typica.w"
  3262. }
  3263. }
  3264. }
  3265. /*:314*//*315:*/
  3266. #line 7043 "./typica.w"
  3267. DAQ::~DAQ()
  3268. {
  3269. if(imp->useBase)
  3270. {
  3271. imp->resetDevice(imp->device.toAscii().data());
  3272. imp->clearTask(imp->handle);
  3273. }
  3274. else
  3275. {
  3276. if(imp->ready)
  3277. {
  3278. imp->ready= false;
  3279. imp->wait(ULONG_MAX);
  3280. imp->stopTask(imp->handle);
  3281. imp->resetDevice(imp->device.toAscii().data());
  3282. imp->clearTask(imp->handle);
  3283. }
  3284. }
  3285. delete imp;
  3286. }
  3287. /*:315*//*316:*/
  3288. #line 7074 "./typica.w"
  3289. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3290. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3291. unitMap(4)
  3292. {
  3293. if(driverinfo=="nidaqmxbase")
  3294. {
  3295. useBase= true;
  3296. }
  3297. else
  3298. {
  3299. useBase= false;
  3300. }
  3301. if(useBase)
  3302. {
  3303. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3304. if(!driver.load())
  3305. {
  3306. driver.setFileName("nidaqmxbase");
  3307. if(!driver.load())
  3308. {
  3309. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3310. tr("Failed to find nidaqmxbase. Please install it."));
  3311. QApplication::quit();
  3312. }
  3313. }
  3314. }
  3315. else
  3316. {
  3317. driver.setFileName("nicaiu");
  3318. if(!driver.load())
  3319. {
  3320. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3321. tr("Failed to find nidaqmx. Please install it."));
  3322. QApplication::quit();
  3323. }
  3324. }
  3325. if(useBase)
  3326. {
  3327. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3328. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3329. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3330. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3331. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3332. ==0||
  3333. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3334. 0||
  3335. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3336. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3337. 0||
  3338. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3339. {
  3340. waitForMeasurement= NULL;
  3341. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3342. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3343. QApplication::quit();
  3344. }
  3345. }
  3346. else
  3347. {
  3348. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3349. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3350. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3351. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3352. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3353. ==0||
  3354. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3355. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3356. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3357. 0||
  3358. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3359. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3360. {
  3361. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3362. tr("Failed to link a required symbol in NI-DAQmx."));
  3363. QApplication::quit();
  3364. }
  3365. }
  3366. }
  3367. DAQImplementation::~DAQImplementation()
  3368. {
  3369. driver.unload();
  3370. }
  3371. /*:316*/
  3372. #line 540 "./typica.w"
  3373. /*978:*/
  3374. #line 197 "./dataqsdk.w"
  3375. void DataqSdkDeviceImplementation::measure()
  3376. {
  3377. unsigned count= channels*40;
  3378. di_status_read(buffer,count);
  3379. QTime time= QTime::currentTime();
  3380. for(unsigned int i= 0;i<count;i++)
  3381. {
  3382. buffer[i]= buffer[i]&0xFFFC;
  3383. }
  3384. QList<int> countList;
  3385. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3386. {
  3387. QList<double> channelBuffer;
  3388. for(unsigned int j= 0;j<40;j++)
  3389. {
  3390. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3391. if(i==0)
  3392. {
  3393. countList<<buffer[i+(channels*j)];
  3394. }
  3395. }
  3396. double value= 0.0;
  3397. for(unsigned int j= 0;j<40;j++)
  3398. {
  3399. value+= channelBuffer[j];
  3400. }
  3401. value/= 40.0;
  3402. if(i==0)
  3403. {
  3404. QList<double> smoothingList;
  3405. smoothingList<<value;
  3406. QList<int> smoothingKeys= smoother.uniqueKeys();
  3407. for(int j= 0;j<smoothingKeys.size();j++)
  3408. {
  3409. if(countList.contains(smoothingKeys[j]))
  3410. {
  3411. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3412. for(int k= 0;k<keyValues.size();k++)
  3413. {
  3414. smoothingList<<keyValues[k];
  3415. }
  3416. }
  3417. else
  3418. {
  3419. smoother.remove(smoothingKeys[j]);
  3420. }
  3421. }
  3422. qSort(countList);
  3423. int lastCount= 0;
  3424. for(int j= 0;j<countList.size();j++)
  3425. {
  3426. if(j==0||countList[j]!=lastCount)
  3427. {
  3428. smoother.insert(countList[j],value);
  3429. lastCount= countList[j];
  3430. }
  3431. }
  3432. value= 0.0;
  3433. for(int j= 0;j<smoothingList.size();j++)
  3434. {
  3435. value+= smoothingList[j];
  3436. }
  3437. value/= smoothingList.size();
  3438. }
  3439. Measurement measure(value,time,unitMap[i]);
  3440. channelMap[i]->input(measure);
  3441. }
  3442. }
  3443. /*:978*//*979:*/
  3444. #line 290 "./dataqsdk.w"
  3445. void DataqSdkDeviceImplementation::run()
  3446. {
  3447. if(!ready)
  3448. {
  3449. error= 9;
  3450. return;
  3451. }
  3452. driver= new QLibrary(device);
  3453. if(!driver->load())
  3454. {
  3455. error= 1;
  3456. qDebug()<<"Failed to load driver: "<<device;
  3457. return;
  3458. }
  3459. di_open= (FPDIOPEN)driver->resolve("di_open");
  3460. di_close= (FPDICLOSE)driver->resolve("di_close");
  3461. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3462. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3463. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3464. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3465. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3466. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3467. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3468. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3469. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3470. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3471. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3472. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3473. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3474. (!di_burst_rate)||(!di_stop_scan))
  3475. {
  3476. error= 2;
  3477. return;
  3478. }
  3479. error= di_open(deviceNumber);
  3480. if(error)
  3481. {
  3482. di_close();
  3483. error= di_open(deviceNumber);
  3484. if(error)
  3485. {
  3486. error= 3;
  3487. di_close();
  3488. return;
  3489. }
  3490. }
  3491. isOpen= true;
  3492. di_maximum_rate(240.0);
  3493. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3494. &burstDivisor);
  3495. buffer= new qint16[(int)sampleRate];
  3496. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3497. for(unsigned short i= 0;i<channels;i++)
  3498. {
  3499. inlist[i].chan= i;
  3500. inlist[i].gain= 0;
  3501. inlist[i].ave= 1;
  3502. inlist[i].counter= (oversample-1);
  3503. }
  3504. error= di_list_length(channels,0);
  3505. if(error)
  3506. {
  3507. error= 4;
  3508. return;
  3509. }
  3510. error= di_inlist(inlist);
  3511. if(error)
  3512. {
  3513. error= 5;
  3514. return;
  3515. }
  3516. input_buffer= di_buffer_alloc(0,4096);
  3517. if(input_buffer==NULL)
  3518. {
  3519. error= 6;
  3520. return;
  3521. }
  3522. error= di_start_scan();
  3523. if(error)
  3524. {
  3525. error= 7;
  3526. return;
  3527. }
  3528. while(ready)
  3529. {
  3530. measure();
  3531. }
  3532. }
  3533. /*:979*//*980:*/
  3534. #line 386 "./dataqsdk.w"
  3535. void DataqSdkDevice::threadFinished()
  3536. {
  3537. if(imp->error)
  3538. {
  3539. /*981:*/
  3540. #line 400 "./dataqsdk.w"
  3541. imp->ready= false;
  3542. QMessageBox warning;
  3543. warning.setStandardButtons(QMessageBox::Cancel);
  3544. warning.setIcon(QMessageBox::Warning);
  3545. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3546. warning.setInformativeText(tr("An error occurred"));
  3547. warning.setWindowTitle(QString(PROGRAM_NAME));
  3548. warning.exec();
  3549. /*:981*/
  3550. #line 391 "./dataqsdk.w"
  3551. }
  3552. }
  3553. /*:980*//*982:*/
  3554. #line 417 "./dataqsdk.w"
  3555. void DataqSdkDevice::start()
  3556. {
  3557. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3558. imp->start();
  3559. }
  3560. /*:982*//*983:*/
  3561. #line 428 "./dataqsdk.w"
  3562. QStringList DataqSdkDevice::detectHardware()
  3563. {
  3564. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3565. QSettings::NativeFormat);
  3566. QStringList keys= deviceLookup.childKeys();
  3567. QStringList devices;
  3568. for(int i= 0;i<keys.size();i++)
  3569. {
  3570. QString value= deviceLookup.value(keys.at(i)).toString();
  3571. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3572. {
  3573. devices.append(value.split("\\").at(2));
  3574. }
  3575. }
  3576. QStringList portList;
  3577. foreach(QString device,devices)
  3578. {
  3579. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3580. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3581. portList.append(deviceEntry.value("FriendlyName").toString());
  3582. }
  3583. return portList;
  3584. }
  3585. QStringList DataqSdkDevice::detectPorts()
  3586. {
  3587. QStringList friendlyNames= detectHardware();
  3588. QStringList portList;
  3589. foreach(QString name,friendlyNames)
  3590. {
  3591. name.remove(0,name.indexOf("COM"));
  3592. name.chop(1);
  3593. portList.append(name);
  3594. }
  3595. return portList;
  3596. }
  3597. /*:983*//*984:*/
  3598. #line 473 "./dataqsdk.w"
  3599. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3600. {
  3601. bool usesAuto= false;
  3602. int autoIndex= device.toInt(&usesAuto);
  3603. QString finalizedPort;
  3604. if(usesAuto)
  3605. {
  3606. QStringList portList= detectPorts();
  3607. if(autoIndex> 0&&autoIndex<=portList.size())
  3608. {
  3609. finalizedPort= portList.at(autoIndex-1);
  3610. }
  3611. else
  3612. {
  3613. imp->error= 8;
  3614. qDebug()<<"Failed to detect port.";
  3615. }
  3616. }
  3617. else
  3618. {
  3619. finalizedPort= device;
  3620. }
  3621. int rstart= finalizedPort.indexOf("COM");
  3622. finalizedPort.remove(0,rstart+3);
  3623. bool chopFinished= false;
  3624. int finalizedPortNumber= 0;
  3625. while(finalizedPort.size()> 0&&!chopFinished)
  3626. {
  3627. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3628. if(!chopFinished)
  3629. {
  3630. finalizedPort.chop(1);
  3631. }
  3632. }
  3633. if(finalizedPortNumber<10)
  3634. {
  3635. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3636. }
  3637. else
  3638. {
  3639. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3640. }
  3641. imp->deviceNumber= 0x12C02D00;
  3642. imp->deviceNumber+= finalizedPortNumber;
  3643. imp->ready= true;
  3644. }
  3645. /*:984*//*985:*/
  3646. #line 523 "./dataqsdk.w"
  3647. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  3648. {
  3649. Channel*retval= NULL;
  3650. if(imp->ready)
  3651. {
  3652. retval= new Channel();
  3653. imp->channelMap[imp->channels]= retval;
  3654. imp->unitMap[imp->channels]= scale;
  3655. imp->channels++;
  3656. }
  3657. return retval;
  3658. }
  3659. /*:985*//*986:*/
  3660. #line 547 "./dataqsdk.w"
  3661. void DataqSdkDevice::setClockRate(double Hz)
  3662. {
  3663. imp->sampleRate= Hz;
  3664. }
  3665. /*:986*//*987:*/
  3666. #line 557 "./dataqsdk.w"
  3667. DataqSdkDevice::~DataqSdkDevice()
  3668. {
  3669. if(imp->ready)
  3670. {
  3671. imp->ready= false;
  3672. }
  3673. imp->wait(ULONG_MAX);
  3674. delete imp;
  3675. }
  3676. /*:987*//*988:*/
  3677. #line 575 "./dataqsdk.w"
  3678. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  3679. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  3680. {
  3681. }
  3682. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  3683. {
  3684. if(isOpen)
  3685. {
  3686. di_stop_scan();
  3687. di_close();
  3688. }
  3689. if(driver->isLoaded())
  3690. {
  3691. driver->unload();
  3692. }
  3693. }
  3694. /*:988*/
  3695. #line 541 "./typica.w"
  3696. /*323:*/
  3697. #line 7283 "./typica.w"
  3698. void FakeDAQImplementation::measure()
  3699. {
  3700. msleep((int)(1000/clockRate));
  3701. QTime time= QTime::currentTime();
  3702. for(int i= 0;i<channels;i++)
  3703. {
  3704. Measurement measure(qrand()%500,time);
  3705. channelMap[i]->input(measure);
  3706. }
  3707. }
  3708. /*:323*//*324:*/
  3709. #line 7297 "./typica.w"
  3710. void FakeDAQImplementation::run()
  3711. {
  3712. setPriority(QThread::TimeCriticalPriority);
  3713. while(ready)
  3714. {
  3715. measure();
  3716. }
  3717. }
  3718. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  3719. channels(0),ready(false),clockRate(1)
  3720. {
  3721. }
  3722. FakeDAQImplementation::~FakeDAQImplementation()
  3723. {
  3724. }
  3725. /*:324*//*325:*/
  3726. #line 7322 "./typica.w"
  3727. void FakeDAQ::start()
  3728. {
  3729. if(imp->ready)
  3730. {
  3731. imp->start();
  3732. }
  3733. }
  3734. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  3735. {
  3736. imp->ready= true;
  3737. }
  3738. Channel*FakeDAQ::newChannel(int,int)
  3739. {
  3740. Channel*retval;
  3741. if(imp->ready)
  3742. {
  3743. retval= new Channel();
  3744. imp->channelMap[imp->channels]= retval;
  3745. imp->channels++;
  3746. }
  3747. else
  3748. {
  3749. return NULL;
  3750. }
  3751. return retval;
  3752. }
  3753. void FakeDAQ::setClockRate(double Hz)
  3754. {
  3755. if(imp->ready)
  3756. {
  3757. imp->clockRate= Hz;
  3758. }
  3759. }
  3760. FakeDAQ::~FakeDAQ()
  3761. {
  3762. imp->ready= false;
  3763. imp->wait(ULONG_MAX);
  3764. delete imp;
  3765. }
  3766. /*:325*/
  3767. #line 542 "./typica.w"
  3768. /*330:*/
  3769. #line 7453 "./typica.w"
  3770. Channel::Channel():QObject(NULL)
  3771. {
  3772. }
  3773. Channel::~Channel()
  3774. {
  3775. }
  3776. void Channel::input(Measurement measurement)
  3777. {
  3778. emit newData(measurement);
  3779. }
  3780. /*:330*/
  3781. #line 543 "./typica.w"
  3782. /*346:*/
  3783. #line 7858 "./typica.w"
  3784. void TemperatureDisplay::setRelativeMode(bool relative)
  3785. {
  3786. r= relative;
  3787. }
  3788. /*:346*//*347:*/
  3789. #line 7875 "./typica.w"
  3790. void TemperatureDisplay::setValue(Measurement temperature)
  3791. {
  3792. QString number;
  3793. switch(unit)
  3794. {
  3795. case Units::Fahrenheit:
  3796. display(QString("%1'F").
  3797. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  3798. 2)));
  3799. break;
  3800. case Units::Celsius:
  3801. if(!r){
  3802. display(QString("%1'C").
  3803. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  3804. 2)));
  3805. }else{
  3806. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3807. display(QString("%1'C").arg(number));
  3808. }
  3809. break;
  3810. case Units::Kelvin:
  3811. if(!r){
  3812. display(QString("%1").
  3813. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  3814. 2)));
  3815. }else{
  3816. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  3817. display(QString("%1").arg(number));
  3818. }
  3819. break;
  3820. case Units::Rankine:
  3821. display(QString("%1'r").
  3822. arg(number.setNum(temperature.toRankine().temperature(),'f',
  3823. 2)));
  3824. break;
  3825. case Units::Unitless:
  3826. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3827. break;
  3828. default:
  3829. switch(temperature.scale())
  3830. {
  3831. case Units::Fahrenheit:
  3832. display(QString("%1'F").
  3833. arg(number.setNum(temperature.temperature(),'f',2)));
  3834. break;
  3835. case Units::Celsius:
  3836. display(QString("%1'C").
  3837. arg(number.setNum(temperature.temperature(),'f',2)));
  3838. break;
  3839. case Units::Kelvin:
  3840. display(QString("%1").
  3841. arg(number.setNum(temperature.temperature(),'f',2)));
  3842. break;
  3843. case Units::Rankine:
  3844. display(QString("%1'r").
  3845. arg(number.setNum(temperature.temperature(),'f',2)));
  3846. break;
  3847. case Units::Unitless:
  3848. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  3849. break;
  3850. default:
  3851. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  3852. break;
  3853. }
  3854. break;
  3855. }
  3856. }
  3857. /*:347*//*348:*/
  3858. #line 7954 "./typica.w"
  3859. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  3860. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  3861. {
  3862. setSegmentStyle(Filled);
  3863. display("---.--'F");
  3864. }
  3865. /*:348*//*349:*/
  3866. #line 7970 "./typica.w"
  3867. void TemperatureDisplay::invalidate()
  3868. {
  3869. display("---.--'F");
  3870. }
  3871. /*:349*//*350:*/
  3872. #line 7982 "./typica.w"
  3873. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  3874. {
  3875. unit= scale;
  3876. }
  3877. /*:350*//*351:*/
  3878. #line 7990 "./typica.w"
  3879. TemperatureDisplay::~TemperatureDisplay()
  3880. {
  3881. }
  3882. /*:351*/
  3883. #line 544 "./typica.w"
  3884. /*357:*/
  3885. #line 8090 "./typica.w"
  3886. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  3887. {
  3888. if(measure.time()<epoch)
  3889. {
  3890. if(hasPrevious)
  3891. {
  3892. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  3893. epoch.msec());
  3894. QTime jitComp(epoch.hour(),measure.time().minute(),
  3895. measure.time().second(),measure.time().msec());
  3896. int relTime= jitBase.msecsTo(jitComp);
  3897. /*358:*/
  3898. #line 8124 "./typica.w"
  3899. QTime newTime(0,0,0,0);
  3900. newTime= newTime.addMSecs(relTime);
  3901. if(newTime.hour()> 0)
  3902. {
  3903. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3904. }
  3905. Measurement rel= measure;
  3906. rel.setTime(newTime);
  3907. emit measurement(rel);
  3908. /*:358*/
  3909. #line 8102 "./typica.w"
  3910. }
  3911. else
  3912. {
  3913. Measurement rel= measure;
  3914. rel.setTime(QTime(0,0,0,0));
  3915. emit measurement(rel);
  3916. }
  3917. }
  3918. else
  3919. {
  3920. int relTime= epoch.msecsTo(measure.time());
  3921. /*358:*/
  3922. #line 8124 "./typica.w"
  3923. QTime newTime(0,0,0,0);
  3924. newTime= newTime.addMSecs(relTime);
  3925. if(newTime.hour()> 0)
  3926. {
  3927. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  3928. }
  3929. Measurement rel= measure;
  3930. rel.setTime(newTime);
  3931. emit measurement(rel);
  3932. /*:358*/
  3933. #line 8114 "./typica.w"
  3934. }
  3935. hasPrevious= true;
  3936. previous= measure.time();
  3937. }
  3938. /*:357*//*359:*/
  3939. #line 8137 "./typica.w"
  3940. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  3941. previous(0,0,0,0),hasPrevious(false)
  3942. {
  3943. }
  3944. QTime MeasurementTimeOffset::zeroTime()
  3945. {
  3946. return epoch;
  3947. }
  3948. void MeasurementTimeOffset::setZeroTime(QTime zero)
  3949. {
  3950. epoch= zero;
  3951. hasPrevious= false;
  3952. }
  3953. /*:359*/
  3954. #line 545 "./typica.w"
  3955. /*369:*/
  3956. #line 8335 "./typica.w"
  3957. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  3958. {
  3959. }
  3960. int ZeroEmitter::column()
  3961. {
  3962. return col;
  3963. }
  3964. double ZeroEmitter::lastTemperature()
  3965. {
  3966. return cache.temperature();
  3967. }
  3968. void ZeroEmitter::newMeasurement(Measurement measure)
  3969. {
  3970. cache= measure;
  3971. }
  3972. void ZeroEmitter::setColumn(int column)
  3973. {
  3974. col= column;
  3975. }
  3976. void ZeroEmitter::emitZero()
  3977. {
  3978. cache.setTime(QTime(0,0,0,0));
  3979. emit measurement(cache,col);
  3980. }
  3981. /*:369*/
  3982. #line 546 "./typica.w"
  3983. /*374:*/
  3984. #line 8425 "./typica.w"
  3985. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  3986. {
  3987. }
  3988. int MeasurementAdapter::column()
  3989. {
  3990. return col;
  3991. }
  3992. void MeasurementAdapter::newMeasurement(Measurement measure)
  3993. {
  3994. emit measurement(measure,col);
  3995. }
  3996. void MeasurementAdapter::setColumn(int column)
  3997. {
  3998. col= column;
  3999. }
  4000. /*:374*/
  4001. #line 547 "./typica.w"
  4002. /*379:*/
  4003. #line 8547 "./typica.w"
  4004. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4005. theScene(new QGraphicsScene),
  4006. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4007. prevPoints(new QMap<int,QPointF> ),
  4008. translations(new QMap<int,double> ),
  4009. gridLinesF(new QList<QGraphicsItem*> ),
  4010. gridLinesC(new QList<QGraphicsItem*> ),
  4011. relativeGridLines(new QList<QGraphicsItem*> ),
  4012. relativeEnabled(false),
  4013. timeIndicatorEnabled(false),
  4014. timeLine(new QGraphicsLineItem),
  4015. relativeAdjuster(new LinearSplineInterpolator)
  4016. {
  4017. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4018. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4019. setScene(theScene);
  4020. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4021. QPen timePen;
  4022. timePen.setColor(QColor(160,160,164,127));
  4023. timeLine->setPen(timePen);
  4024. timeLine->setLine(0,0,0,-500);
  4025. timeLine->hide();
  4026. theScene->addItem(timeLine);
  4027. /*380:*/
  4028. #line 8587 "./typica.w"
  4029. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4030. tempaxis->setLine(-10,-500,-10,0);
  4031. theScene->addItem(tempaxis);
  4032. QGraphicsLineItem*gridLine;
  4033. QGraphicsTextItem*label;
  4034. for(int y= -100;y> -600;y-= 100)
  4035. {
  4036. gridLine= new QGraphicsLineItem;
  4037. gridLine->setLine(0,y,1200,y);
  4038. theScene->addItem(gridLine);
  4039. label= new QGraphicsTextItem;
  4040. label->setHtml(QString("%1&deg;F").arg(-y));
  4041. label->setPos(-55,y-(label->boundingRect().height()/2));
  4042. theScene->addItem(label);
  4043. gridLinesF->append(gridLine);
  4044. gridLinesF->append(label);
  4045. }
  4046. for(int degC= 50;degC<=250;degC+= 50)
  4047. {
  4048. gridLine= new QGraphicsLineItem;
  4049. int y= -(degC*(9.0/5.0)+32);
  4050. gridLine->setLine(0,y,1200,y);
  4051. gridLine->hide();
  4052. theScene->addItem(gridLine);
  4053. gridLinesC->append(gridLine);
  4054. label= new QGraphicsTextItem;
  4055. label->setHtml(QString("%1&deg;C").arg(degC));
  4056. label->setPos(-55,y-(label->boundingRect().height()/2));
  4057. label->hide();
  4058. theScene->addItem(label);
  4059. gridLinesC->append(label);
  4060. }
  4061. /*:380*/
  4062. #line 8571 "./typica.w"
  4063. ;
  4064. /*381:*/
  4065. #line 8628 "./typica.w"
  4066. QSettings settings;
  4067. if(settings.contains("settings/graph/relative/enable"))
  4068. {
  4069. if(settings.value("settings/graph/relative/enable").toBool())
  4070. {
  4071. relativeEnabled= true;
  4072. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4073. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4074. QMap<double,QString> relativeAxisPairs;
  4075. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4076. foreach(QString item,relativeAxisLabels)
  4077. {
  4078. relativeAxisPairs.insert(item.toDouble(),item);
  4079. }
  4080. if(relativeAxisPairs.size()> 1)
  4081. {
  4082. double skip= 500.0/(relativeAxisPairs.size()-1);
  4083. double y= 0;
  4084. foreach(double key,relativeAxisPairs.keys())
  4085. {
  4086. gridLine= new QGraphicsLineItem;
  4087. gridLine->setLine(0,y,1205,y);
  4088. gridLine->setPen(QPen(relativeColor));
  4089. theScene->addItem(gridLine);
  4090. relativeGridLines->append(gridLine);
  4091. label= new QGraphicsTextItem;
  4092. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4093. label->setPos(1210,y-(label->boundingRect().height()/2));
  4094. theScene->addItem(label);
  4095. relativeGridLines->append(label);
  4096. if(unit=="F")
  4097. {
  4098. relativeAdjuster->add_pair(key,-y);
  4099. }
  4100. else
  4101. {
  4102. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4103. }
  4104. y-= skip;
  4105. }
  4106. }
  4107. }
  4108. }
  4109. /*:381*/
  4110. #line 8572 "./typica.w"
  4111. /*383:*/
  4112. #line 8705 "./typica.w"
  4113. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4114. timeaxis->setLine(0,10,1200,10);
  4115. theScene->addItem(timeaxis);
  4116. for(int x= 0;x<1201;x+= 120)
  4117. {
  4118. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4119. tick->setLine(x,0,x,20);
  4120. theScene->addItem(tick);
  4121. QGraphicsTextItem*label= new QGraphicsTextItem;
  4122. label->setPlainText(QString("%1").arg(x/60));
  4123. label->setPos(x-(label->boundingRect().width()/2),20);
  4124. theScene->addItem(label);
  4125. }
  4126. /*:383*/
  4127. #line 8573 "./typica.w"
  4128. ;
  4129. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4130. }
  4131. /*:379*//*382:*/
  4132. #line 8675 "./typica.w"
  4133. void GraphView::showF()
  4134. {
  4135. for(int i= 0;i<gridLinesF->size();i++)
  4136. {
  4137. gridLinesF->at(i)->show();
  4138. }
  4139. for(int i= 0;i<gridLinesC->size();i++)
  4140. {
  4141. gridLinesC->at(i)->hide();
  4142. }
  4143. }
  4144. void GraphView::showC()
  4145. {
  4146. for(int i= 0;i<gridLinesF->size();i++)
  4147. {
  4148. gridLinesF->at(i)->hide();
  4149. }
  4150. for(int i= 0;i<gridLinesC->size();i++)
  4151. {
  4152. gridLinesC->at(i)->show();
  4153. }
  4154. }
  4155. /*:382*//*384:*/
  4156. #line 8724 "./typica.w"
  4157. void GraphView::resizeEvent(QResizeEvent*)
  4158. {
  4159. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4160. }
  4161. /*:384*//*385:*/
  4162. #line 8738 "./typica.w"
  4163. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4164. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4165. {
  4166. double offset= 0;
  4167. if(measure.contains("relative"))
  4168. {
  4169. if(measure.value("relative").toBool())
  4170. {
  4171. if(relativeEnabled)
  4172. {
  4173. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4174. }
  4175. else
  4176. {
  4177. return;
  4178. }
  4179. }
  4180. }
  4181. if(translations->contains(tempcolumn))
  4182. {
  4183. offset= translations->value(tempcolumn);
  4184. }
  4185. if(prevPoints->contains(tempcolumn))
  4186. {
  4187. /*387:*/
  4188. #line 8815 "./typica.w"
  4189. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4190. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4191. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4192. -(prevPoints->value(tempcolumn).y()),
  4193. nextPoint.x()+offset,-(nextPoint.y()));
  4194. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4195. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4196. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4197. Qt::darkYellow};
  4198. segment->setPen(p[tempcolumn%12]);
  4199. theScene->addItem(segment);
  4200. prevPoints->insert(tempcolumn,nextPoint);
  4201. if(timeIndicatorEnabled)
  4202. {
  4203. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4204. }
  4205. /*:387*/
  4206. #line 8764 "./typica.w"
  4207. if(graphLines->contains(tempcolumn))
  4208. {
  4209. graphLines->value(tempcolumn)->append(segment);
  4210. }
  4211. else
  4212. {
  4213. QList<QGraphicsLineItem*> *newLine=
  4214. new QList<QGraphicsLineItem*> ;
  4215. newLine->append(segment);
  4216. graphLines->insert(tempcolumn,newLine);
  4217. }
  4218. }
  4219. else
  4220. {
  4221. /*386:*/
  4222. #line 8800 "./typica.w"
  4223. int x= FULLTIMETOINT(measure.time())/1000;
  4224. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4225. if(timeIndicatorEnabled)
  4226. {
  4227. timeLine->setLine(x,0,x,-500);
  4228. }
  4229. /*:386*/
  4230. #line 8781 "./typica.w"
  4231. }
  4232. }
  4233. /*:385*//*388:*/
  4234. #line 8836 "./typica.w"
  4235. void GraphView::clear()
  4236. {
  4237. int i;
  4238. foreach(i,prevPoints->keys())
  4239. {
  4240. removeSeries(i);
  4241. }
  4242. translations->clear();
  4243. }
  4244. /*:388*//*389:*/
  4245. #line 8850 "./typica.w"
  4246. void GraphView::removeSeries(int column)
  4247. {
  4248. if(graphLines->contains(column))
  4249. {
  4250. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4251. QGraphicsLineItem*segment;
  4252. foreach(segment,*series)
  4253. {
  4254. theScene->removeItem(segment);
  4255. }
  4256. qDeleteAll(*series);
  4257. }
  4258. graphLines->remove(column);
  4259. prevPoints->remove(column);
  4260. }
  4261. /*:389*//*390:*/
  4262. #line 8869 "./typica.w"
  4263. void GraphView::setSeriesTranslation(int column,double offset)
  4264. {
  4265. if(graphLines->contains(column))
  4266. {
  4267. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4268. QGraphicsLineItem*segment;
  4269. foreach(segment,*series)
  4270. {
  4271. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4272. }
  4273. }
  4274. if(translations->contains(column))
  4275. {
  4276. translations->insert(column,offset+translations->value(column));
  4277. }
  4278. else
  4279. {
  4280. translations->insert(column,offset);
  4281. }
  4282. }
  4283. /*:390*//*391:*/
  4284. #line 8896 "./typica.w"
  4285. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4286. {
  4287. timeIndicatorEnabled= enabled;
  4288. if(enabled)
  4289. {
  4290. timeLine->show();
  4291. }
  4292. else
  4293. {
  4294. timeLine->hide();
  4295. }
  4296. }
  4297. /*:391*/
  4298. #line 548 "./typica.w"
  4299. /*397:*/
  4300. #line 9040 "./typica.w"
  4301. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4302. {
  4303. if(measure.time()!=QTime(0,0,0,0))
  4304. {
  4305. /*399:*/
  4306. #line 9114 "./typica.w"
  4307. if(lastMeasurement.contains(tempcolumn))
  4308. {
  4309. if(lastMeasurement[tempcolumn].time()<measure.time())
  4310. {
  4311. QList<QTime> timelist;
  4312. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4313. {
  4314. timelist.append(i);
  4315. }
  4316. for(int i= 0;i<timelist.size();i++)
  4317. {
  4318. Measurement synthesized= measure;
  4319. synthesized.setTime(timelist[i]);
  4320. newMeasurement(synthesized,tempcolumn);
  4321. }
  4322. }
  4323. }
  4324. /*:399*/
  4325. #line 9045 "./typica.w"
  4326. }
  4327. model_ms->newMeasurement(measure,tempcolumn);
  4328. if(lastMeasurement.contains(tempcolumn))
  4329. {
  4330. if(measure.time().second()!=
  4331. lastMeasurement.value(tempcolumn).time().second())
  4332. {
  4333. Measurement adjusted= measure;
  4334. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4335. adjusted.setTime(adjtime);
  4336. model_1s->newMeasurement(adjusted,tempcolumn);
  4337. if(adjusted.time().second()%5==0)
  4338. {
  4339. model_5s->newMeasurement(adjusted,tempcolumn);
  4340. if(adjusted.time().second()%10==0)
  4341. {
  4342. model_10s->newMeasurement(adjusted,tempcolumn);
  4343. }
  4344. if(adjusted.time().second()%15==0)
  4345. {
  4346. model_15s->newMeasurement(adjusted,tempcolumn);
  4347. if(adjusted.time().second()%30==0)
  4348. {
  4349. model_30s->newMeasurement(adjusted,tempcolumn);
  4350. if(adjusted.time().second()==0)
  4351. {
  4352. model_1m->newMeasurement(adjusted,tempcolumn);
  4353. }
  4354. }
  4355. }
  4356. }
  4357. }
  4358. /*401:*/
  4359. #line 9158 "./typica.w"
  4360. if(currentColumnSet.contains(tempcolumn))
  4361. {
  4362. int replicationcolumn;
  4363. foreach(replicationcolumn,currentColumnSet)
  4364. {
  4365. if(replicationcolumn!=tempcolumn)
  4366. {
  4367. if(lastMeasurement.contains(replicationcolumn))
  4368. {
  4369. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4370. {
  4371. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4372. synthetic.setTime(measure.time());
  4373. model_ms->newMeasurement(synthetic,replicationcolumn);
  4374. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4375. {
  4376. Measurement adjusted= synthetic;
  4377. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4378. model_1s->newMeasurement(adjusted,replicationcolumn);
  4379. if(adjusted.time().second()%5==0)
  4380. {
  4381. model_5s->newMeasurement(adjusted,replicationcolumn);
  4382. if(adjusted.time().second()%10==0)
  4383. {
  4384. model_10s->newMeasurement(adjusted,replicationcolumn);
  4385. }
  4386. if(adjusted.time().second()%15==0)
  4387. {
  4388. model_15s->newMeasurement(adjusted,replicationcolumn);
  4389. if(adjusted.time().second()%30==0)
  4390. {
  4391. model_30s->newMeasurement(adjusted,replicationcolumn);
  4392. if(adjusted.time().second()==0)
  4393. {
  4394. model_1m->newMeasurement(adjusted,replicationcolumn);
  4395. }
  4396. }
  4397. }
  4398. }
  4399. }
  4400. lastMeasurement[replicationcolumn]= synthetic;
  4401. }
  4402. }
  4403. }
  4404. }
  4405. }
  4406. /*:401*/
  4407. #line 9078 "./typica.w"
  4408. }
  4409. else
  4410. {
  4411. /*398:*/
  4412. #line 9090 "./typica.w"
  4413. MeasurementModel*m;
  4414. foreach(m,modelSet)
  4415. {
  4416. m->newMeasurement(measure,tempcolumn);
  4417. }
  4418. /*:398*/
  4419. #line 9082 "./typica.w"
  4420. }
  4421. lastMeasurement.insert(tempcolumn,measure);
  4422. }
  4423. /*:397*//*400:*/
  4424. #line 9144 "./typica.w"
  4425. void ZoomLog::addToCurrentColumnSet(int column)
  4426. {
  4427. currentColumnSet.append(column);
  4428. }
  4429. void ZoomLog::clearCurrentColumnSet()
  4430. {
  4431. currentColumnSet.clear();
  4432. }
  4433. /*:400*//*402:*/
  4434. #line 9228 "./typica.w"
  4435. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4436. int annotationcolumn)
  4437. {
  4438. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4439. MeasurementModel*m;
  4440. if(lastMeasurement.contains(tempcolumn))
  4441. {
  4442. foreach(m,modelSet)
  4443. {
  4444. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4445. }
  4446. }
  4447. foreach(m,modelSet)
  4448. {
  4449. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4450. }
  4451. }
  4452. /*:402*//*403:*/
  4453. #line 9252 "./typica.w"
  4454. void ZoomLog::centerOn(int row)
  4455. {
  4456. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4457. }
  4458. /*:403*//*404:*/
  4459. #line 9262 "./typica.w"
  4460. void ZoomLog::clear()
  4461. {
  4462. MeasurementModel*m;
  4463. foreach(m,modelSet)
  4464. {
  4465. m->clear();
  4466. }
  4467. lastMeasurement.clear();
  4468. saveTempCols.clear();
  4469. saveControlCols.clear();
  4470. saveNoteCols.clear();
  4471. }
  4472. /*:404*//*405:*/
  4473. #line 9280 "./typica.w"
  4474. QVariant ZoomLog::data(int row,int column)const
  4475. {
  4476. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4477. Qt::DisplayRole);
  4478. }
  4479. int ZoomLog::rowCount()
  4480. {
  4481. return model_ms->rowCount();
  4482. }
  4483. /*:405*//*406:*/
  4484. #line 9303 "./typica.w"
  4485. bool ZoomLog::saveXML(QIODevice*device)
  4486. {
  4487. Units::Unit prevUnits= model_ms->displayUnits();
  4488. if(prevUnits!=Units::Fahrenheit)
  4489. {
  4490. model_ms->setDisplayUnits(Units::Fahrenheit);
  4491. }
  4492. XMLOutput writer(model_ms,device,0);
  4493. int c;
  4494. foreach(c,saveTempCols)
  4495. {
  4496. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4497. toString(),c);
  4498. }
  4499. foreach(c,saveControlCols)
  4500. {
  4501. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4502. toString(),c);
  4503. }
  4504. foreach(c,saveNoteCols)
  4505. {
  4506. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4507. toString(),c);
  4508. }
  4509. bool retval= writer.output();
  4510. if(prevUnits!=Units::Fahrenheit)
  4511. {
  4512. model_ms->setDisplayUnits(prevUnits);
  4513. }
  4514. return retval;
  4515. }
  4516. /*:406*//*407:*/
  4517. #line 9339 "./typica.w"
  4518. bool ZoomLog::saveCSV(QIODevice*device)
  4519. {
  4520. CSVOutput writer(currentModel,device,0);
  4521. int c;
  4522. foreach(c,saveTempCols)
  4523. {
  4524. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4525. toString(),c);
  4526. }
  4527. foreach(c,saveControlCols)
  4528. {
  4529. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4530. toString(),c);
  4531. }
  4532. foreach(c,saveNoteCols)
  4533. {
  4534. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4535. toString(),c);
  4536. }
  4537. return writer.output();
  4538. }
  4539. /*:407*//*408:*/
  4540. #line 9368 "./typica.w"
  4541. void ZoomLog::switchLOD(MeasurementModel*m)
  4542. {
  4543. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4544. setModel(m);
  4545. currentModel= m;
  4546. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4547. }
  4548. void ZoomLog::LOD_ms()
  4549. {
  4550. switchLOD(model_ms);
  4551. }
  4552. void ZoomLog::LOD_1s()
  4553. {
  4554. switchLOD(model_1s);
  4555. }
  4556. void ZoomLog::LOD_5s()
  4557. {
  4558. switchLOD(model_5s);
  4559. }
  4560. void ZoomLog::LOD_10s()
  4561. {
  4562. switchLOD(model_10s);
  4563. }
  4564. void ZoomLog::LOD_15s()
  4565. {
  4566. switchLOD(model_15s);
  4567. }
  4568. void ZoomLog::LOD_30s()
  4569. {
  4570. switchLOD(model_30s);
  4571. }
  4572. void ZoomLog::LOD_1m()
  4573. {
  4574. switchLOD(model_1m);
  4575. }
  4576. /*:408*//*409:*/
  4577. #line 9416 "./typica.w"
  4578. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4579. {
  4580. model_ms->setDisplayUnits(scale);
  4581. model_1s->setDisplayUnits(scale);
  4582. model_5s->setDisplayUnits(scale);
  4583. model_10s->setDisplayUnits(scale);
  4584. model_15s->setDisplayUnits(scale);
  4585. model_30s->setDisplayUnits(scale);
  4586. model_1m->setDisplayUnits(scale);
  4587. }
  4588. Units::Unit ZoomLog::displayUnits()
  4589. {
  4590. return model_ms->displayUnits();
  4591. }
  4592. /*:409*//*410:*/
  4593. #line 9436 "./typica.w"
  4594. QString ZoomLog::lastTime(int series)
  4595. {
  4596. Measurement measure= lastMeasurement.value(series);
  4597. QTime time= measure.time();
  4598. return time.toString("h:mm:ss.zzz");
  4599. }
  4600. /*:410*//*411:*/
  4601. #line 9446 "./typica.w"
  4602. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4603. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4604. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4605. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4606. {
  4607. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4608. setSelectionMode(QAbstractItemView::NoSelection);
  4609. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4610. model_30s<<model_1m;
  4611. currentModel= model_30s;
  4612. setModel(currentModel);
  4613. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4614. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4615. this,SLOT(persistColumnResize(int,int,int)));
  4616. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4617. this,SLOT(restoreColumnWidths()));
  4618. }
  4619. /*:411*//*412:*/
  4620. #line 9469 "./typica.w"
  4621. void ZoomLog::setHeaderData(int section,QString text)
  4622. {
  4623. MeasurementModel*m;
  4624. foreach(m,modelSet)
  4625. {
  4626. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4627. }
  4628. }
  4629. /*:412*//*413:*/
  4630. #line 9487 "./typica.w"
  4631. void ZoomLog::addOutputTemperatureColumn(int column)
  4632. {
  4633. saveTempCols.append(column);
  4634. }
  4635. void ZoomLog::addOutputControlColumn(int column)
  4636. {
  4637. saveControlCols.append(column);
  4638. }
  4639. void ZoomLog::addOutputAnnotationColumn(int column)
  4640. {
  4641. saveNoteCols.append(column);
  4642. }
  4643. void ZoomLog::clearOutputColumns()
  4644. {
  4645. saveTempCols.clear();
  4646. saveControlCols.clear();
  4647. saveNoteCols.clear();
  4648. }
  4649. /*:413*//*414:*/
  4650. #line 9513 "./typica.w"
  4651. void ZoomLog::persistColumnResize(int column,int,int newsize)
  4652. {
  4653. /*629:*/
  4654. #line 13659 "./typica.w"
  4655. QSettings settings;
  4656. /*630:*/
  4657. #line 13672 "./typica.w"
  4658. QWidget*topLevelWidget= this;
  4659. while(topLevelWidget->parentWidget())
  4660. {
  4661. topLevelWidget= topLevelWidget->parentWidget();
  4662. }
  4663. /*:630*/
  4664. #line 13661 "./typica.w"
  4665. settings.setValue(QString("columnWidths/%1/%2/%3").
  4666. arg(topLevelWidget->objectName()).
  4667. arg(objectName()).arg(column),
  4668. QVariant(newsize));
  4669. /*:629*/
  4670. #line 9516 "./typica.w"
  4671. }
  4672. void ZoomLog::restoreColumnWidths()
  4673. {
  4674. /*632:*/
  4675. #line 13692 "./typica.w"
  4676. QSettings settings;
  4677. /*630:*/
  4678. #line 13672 "./typica.w"
  4679. QWidget*topLevelWidget= this;
  4680. while(topLevelWidget->parentWidget())
  4681. {
  4682. topLevelWidget= topLevelWidget->parentWidget();
  4683. }
  4684. /*:630*/
  4685. #line 13694 "./typica.w"
  4686. QString baseKey=
  4687. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4688. arg(objectName());
  4689. for(int i= 0;i<model()->columnCount();i++)
  4690. {
  4691. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4692. if(settings.contains(key))
  4693. {
  4694. setColumnWidth(i,settings.value(key).toInt());
  4695. }
  4696. }
  4697. /*:632*/
  4698. #line 9521 "./typica.w"
  4699. }
  4700. void ZoomLog::setVisible(bool visibility)
  4701. {
  4702. QTableView::setVisible(visibility);
  4703. }
  4704. void ZoomLog::showEvent(QShowEvent*)
  4705. {
  4706. /*632:*/
  4707. #line 13692 "./typica.w"
  4708. QSettings settings;
  4709. /*630:*/
  4710. #line 13672 "./typica.w"
  4711. QWidget*topLevelWidget= this;
  4712. while(topLevelWidget->parentWidget())
  4713. {
  4714. topLevelWidget= topLevelWidget->parentWidget();
  4715. }
  4716. /*:630*/
  4717. #line 13694 "./typica.w"
  4718. QString baseKey=
  4719. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  4720. arg(objectName());
  4721. for(int i= 0;i<model()->columnCount();i++)
  4722. {
  4723. QString key= QString("%1/%2").arg(baseKey).arg(i);
  4724. if(settings.contains(key))
  4725. {
  4726. setColumnWidth(i,settings.value(key).toInt());
  4727. }
  4728. }
  4729. /*:632*/
  4730. #line 9531 "./typica.w"
  4731. }
  4732. /*:414*/
  4733. #line 549 "./typica.w"
  4734. /*423:*/
  4735. #line 9764 "./typica.w"
  4736. bool MeasurementList::operator<(const MeasurementList&other)const
  4737. {
  4738. return this->first().toTime()<other.first().toTime();
  4739. }
  4740. bool MeasurementList::operator==(const MeasurementList&other)const
  4741. {
  4742. return this->first().toTime()==other.first().toTime();
  4743. }
  4744. /*:423*//*424:*/
  4745. #line 9780 "./typica.w"
  4746. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  4747. {
  4748. return QModelIndex();
  4749. }
  4750. /*:424*//*425:*/
  4751. #line 9790 "./typica.w"
  4752. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  4753. {
  4754. if(measure.scale()==Units::Unitless)
  4755. {
  4756. controlColumns->insert(tempcolumn,true);
  4757. }
  4758. else
  4759. {
  4760. controlColumns->insert(tempcolumn,false);
  4761. }
  4762. MeasurementList*temp;
  4763. temp= new MeasurementList;
  4764. temp->append(QVariant(measure.time()));
  4765. /*426:*/
  4766. #line 9849 "./typica.w"
  4767. /*427:*/
  4768. #line 9894 "./typica.w"
  4769. QList<MeasurementList*> ::iterator i= lastInsertion;
  4770. bool quickscan= false;
  4771. if(entries->size()> 5)
  4772. {
  4773. if(**i<*temp)
  4774. {
  4775. i+= 1;
  4776. for(int j= 10;j> 0;j--)
  4777. {
  4778. if(i!=entries->end())
  4779. {
  4780. if(**i<*temp)
  4781. {
  4782. i+= 1;
  4783. }
  4784. else
  4785. {
  4786. quickscan= true;
  4787. break;
  4788. }
  4789. }
  4790. else
  4791. {
  4792. quickscan= true;
  4793. break;
  4794. }
  4795. }
  4796. }
  4797. else
  4798. {
  4799. if(**i==*temp)
  4800. {
  4801. quickscan= true;
  4802. }
  4803. }
  4804. }
  4805. /*:427*/
  4806. #line 9850 "./typica.w"
  4807. if(quickscan==false)
  4808. {
  4809. i= entries->begin();
  4810. QList<MeasurementList*> ::iterator u= entries->end();
  4811. QList<MeasurementList*> ::iterator midpoint;
  4812. int n= u-i;
  4813. int rA;
  4814. while(n> 0)
  4815. {
  4816. rA= n>>1;
  4817. midpoint= i+rA;
  4818. if(**midpoint<*temp)
  4819. {
  4820. i= midpoint+1;
  4821. n-= rA+1;
  4822. }
  4823. else
  4824. {
  4825. n= rA;
  4826. }
  4827. }
  4828. }
  4829. /*:426*/
  4830. #line 9804 "./typica.w"
  4831. MeasurementList*newEntry;
  4832. int insertion;
  4833. if(i!=entries->end())
  4834. {
  4835. insertion= entries->indexOf(*i);
  4836. if((*i)->first().toTime()==measure.time())
  4837. {
  4838. /*428:*/
  4839. #line 9936 "./typica.w"
  4840. if((*i)->size()<tempcolumn+1)
  4841. {
  4842. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  4843. {
  4844. (*i)->append(QVariant());
  4845. }
  4846. }
  4847. (*i)->replace(tempcolumn,measure);
  4848. lastInsertion= i;
  4849. emit dataChanged(createIndex(insertion,tempcolumn),
  4850. createIndex(insertion,tempcolumn));
  4851. lastTemperature->insert(tempcolumn,insertion);
  4852. /*:428*/
  4853. #line 9812 "./typica.w"
  4854. }
  4855. else
  4856. {
  4857. /*429:*/
  4858. #line 9954 "./typica.w"
  4859. beginInsertRows(QModelIndex(),insertion,insertion);
  4860. newEntry= new MeasurementList;
  4861. newEntry->append(QVariant(measure.time()));
  4862. for(int j= 0;j<tempcolumn+1;j++)
  4863. {
  4864. newEntry->append(QVariant());
  4865. }
  4866. newEntry->replace(tempcolumn,measure);
  4867. lastInsertion= entries->insert(i,newEntry);
  4868. endInsertRows();
  4869. lastTemperature->insert(tempcolumn,insertion);
  4870. /*:429*/
  4871. #line 9816 "./typica.w"
  4872. }
  4873. }
  4874. else
  4875. {
  4876. /*430:*/
  4877. #line 9972 "./typica.w"
  4878. insertion= entries->size();
  4879. /*429:*/
  4880. #line 9954 "./typica.w"
  4881. beginInsertRows(QModelIndex(),insertion,insertion);
  4882. newEntry= new MeasurementList;
  4883. newEntry->append(QVariant(measure.time()));
  4884. for(int j= 0;j<tempcolumn+1;j++)
  4885. {
  4886. newEntry->append(QVariant());
  4887. }
  4888. newEntry->replace(tempcolumn,measure);
  4889. lastInsertion= entries->insert(i,newEntry);
  4890. endInsertRows();
  4891. lastTemperature->insert(tempcolumn,insertion);
  4892. /*:429*/
  4893. #line 9974 "./typica.w"
  4894. /*:430*/
  4895. #line 9821 "./typica.w"
  4896. }
  4897. if(tempcolumn>=colcount)
  4898. {
  4899. colcount= tempcolumn+1;
  4900. }
  4901. emit rowChanged(insertion);
  4902. delete temp;
  4903. }
  4904. /*:425*//*431:*/
  4905. #line 9984 "./typica.w"
  4906. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  4907. int annotationColumn)
  4908. {
  4909. int r;
  4910. if(lastTemperature->contains(tempcolumn))
  4911. {
  4912. r= lastTemperature->value(tempcolumn);
  4913. }
  4914. else
  4915. {
  4916. r= 0;
  4917. }
  4918. if(r==0&&entries->size()==0)
  4919. {
  4920. /*432:*/
  4921. #line 10022 "./typica.w"
  4922. beginInsertRows(QModelIndex(),0,0);
  4923. MeasurementList*newEntry= new MeasurementList;
  4924. newEntry->append(QVariant(QTime(0,0,0,0)));
  4925. entries->append(newEntry);
  4926. endInsertRows();
  4927. /*:432*/
  4928. #line 9999 "./typica.w"
  4929. }
  4930. MeasurementList*row= entries->at(r);
  4931. if(row->size()<=annotationColumn)
  4932. {
  4933. for(int i= row->size()-1;i<annotationColumn+1;i++)
  4934. {
  4935. row->append(QVariant());
  4936. }
  4937. }
  4938. row->replace(annotationColumn,annotation);
  4939. emit dataChanged(createIndex(r,annotationColumn),
  4940. createIndex(r,annotationColumn));
  4941. emit rowChanged(r);
  4942. if(annotationColumn> colcount-1)
  4943. {
  4944. colcount= annotationColumn+1;
  4945. }
  4946. }
  4947. /*:431*//*433:*/
  4948. #line 10033 "./typica.w"
  4949. void MeasurementModel::clear()
  4950. {
  4951. beginRemoveRows(QModelIndex(),0,entries->size());
  4952. while(entries->size()!=0)
  4953. {
  4954. MeasurementList*row= entries->takeFirst();
  4955. delete row;
  4956. }
  4957. endRemoveRows();
  4958. colcount= hData->size();
  4959. lastTemperature->clear();
  4960. reset();
  4961. }
  4962. /*:433*//*434:*/
  4963. #line 10066 "./typica.w"
  4964. bool MeasurementModel::setData(const QModelIndex&index,
  4965. const QVariant&value,int role)
  4966. {
  4967. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  4968. {
  4969. return false;
  4970. }
  4971. /*435:*/
  4972. #line 10098 "./typica.w"
  4973. bool valid= false;
  4974. if(index.isValid())
  4975. {
  4976. if(index.row()<entries->size())
  4977. {
  4978. if(index.column()<colcount)
  4979. {
  4980. valid= true;
  4981. }
  4982. }
  4983. }
  4984. /*:435*/
  4985. #line 10074 "./typica.w"
  4986. if(!valid)
  4987. {
  4988. return false;
  4989. }
  4990. MeasurementList*row= entries->at(index.row());
  4991. if(index.column()>=row->size())
  4992. {
  4993. /*436:*/
  4994. #line 10115 "./typica.w"
  4995. for(int i= row->size()-1;i<index.column();i++)
  4996. {
  4997. row->append(QVariant());
  4998. }
  4999. /*:436*/
  5000. #line 10082 "./typica.w"
  5001. }
  5002. if(index.column()==0)
  5003. {
  5004. /*437:*/
  5005. #line 10130 "./typica.w"
  5006. QTime time;
  5007. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5008. {
  5009. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5010. {
  5011. return false;
  5012. }
  5013. }
  5014. row= entries->takeAt(index.row());
  5015. row->replace(index.column(),QVariant(time));
  5016. MeasurementList*temp= row;
  5017. /*426:*/
  5018. #line 9849 "./typica.w"
  5019. /*427:*/
  5020. #line 9894 "./typica.w"
  5021. QList<MeasurementList*> ::iterator i= lastInsertion;
  5022. bool quickscan= false;
  5023. if(entries->size()> 5)
  5024. {
  5025. if(**i<*temp)
  5026. {
  5027. i+= 1;
  5028. for(int j= 10;j> 0;j--)
  5029. {
  5030. if(i!=entries->end())
  5031. {
  5032. if(**i<*temp)
  5033. {
  5034. i+= 1;
  5035. }
  5036. else
  5037. {
  5038. quickscan= true;
  5039. break;
  5040. }
  5041. }
  5042. else
  5043. {
  5044. quickscan= true;
  5045. break;
  5046. }
  5047. }
  5048. }
  5049. else
  5050. {
  5051. if(**i==*temp)
  5052. {
  5053. quickscan= true;
  5054. }
  5055. }
  5056. }
  5057. /*:427*/
  5058. #line 9850 "./typica.w"
  5059. if(quickscan==false)
  5060. {
  5061. i= entries->begin();
  5062. QList<MeasurementList*> ::iterator u= entries->end();
  5063. QList<MeasurementList*> ::iterator midpoint;
  5064. int n= u-i;
  5065. int rA;
  5066. while(n> 0)
  5067. {
  5068. rA= n>>1;
  5069. midpoint= i+rA;
  5070. if(**midpoint<*temp)
  5071. {
  5072. i= midpoint+1;
  5073. n-= rA+1;
  5074. }
  5075. else
  5076. {
  5077. n= rA;
  5078. }
  5079. }
  5080. }
  5081. /*:426*/
  5082. #line 10142 "./typica.w"
  5083. entries->insert(i,row);
  5084. int newRow= entries->indexOf(*i);
  5085. if(newRow<index.row())
  5086. {
  5087. emit dataChanged(createIndex(newRow,index.column()),index);
  5088. }
  5089. else
  5090. {
  5091. emit dataChanged(index,createIndex(newRow,index.column()));
  5092. }
  5093. /*:437*/
  5094. #line 10086 "./typica.w"
  5095. }
  5096. else
  5097. {
  5098. /*438:*/
  5099. #line 10156 "./typica.w"
  5100. row->replace(index.column(),value);
  5101. emit dataChanged(index,index);
  5102. /*:438*/
  5103. #line 10090 "./typica.w"
  5104. }
  5105. return true;
  5106. }
  5107. /*:434*//*439:*/
  5108. #line 10164 "./typica.w"
  5109. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5110. unit(Units::Fahrenheit),hData(new QStringList),
  5111. lastTemperature(new QHash<int,int> ),
  5112. controlColumns(new QHash<int,bool> )
  5113. {
  5114. colcount= 1;
  5115. entries= new QList<MeasurementList*> ;
  5116. lastInsertion= entries->begin();
  5117. hData->append(tr("Time"));
  5118. }
  5119. /*:439*//*440:*/
  5120. #line 10178 "./typica.w"
  5121. MeasurementModel::~MeasurementModel()
  5122. {
  5123. clear();
  5124. delete entries;
  5125. delete hData;
  5126. }
  5127. /*:440*//*441:*/
  5128. #line 10190 "./typica.w"
  5129. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5130. {
  5131. if(parent==QModelIndex())
  5132. {
  5133. return entries->size();
  5134. }
  5135. return 0;
  5136. }
  5137. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5138. {
  5139. if(parent==QModelIndex())
  5140. {
  5141. return colcount;
  5142. }
  5143. return 0;
  5144. }
  5145. /*:441*//*442:*/
  5146. #line 10217 "./typica.w"
  5147. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5148. const QVariant&value,int)
  5149. {
  5150. if(orientation==Qt::Horizontal)
  5151. {
  5152. if(hData->size()<section+1)
  5153. {
  5154. for(int i= hData->size();i<section+1;i++)
  5155. {
  5156. if(colcount<i)
  5157. {
  5158. beginInsertColumns(QModelIndex(),i,i);
  5159. }
  5160. hData->append(QString());
  5161. if(colcount<i)
  5162. {
  5163. endInsertColumns();
  5164. }
  5165. }
  5166. }
  5167. hData->replace(section,value.toString());
  5168. emit headerDataChanged(orientation,section,section);
  5169. if(colcount<section+1)
  5170. {
  5171. colcount= section+1;
  5172. }
  5173. return true;
  5174. }
  5175. return false;
  5176. }
  5177. /*:442*//*443:*/
  5178. #line 10257 "./typica.w"
  5179. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5180. {
  5181. beginResetModel();
  5182. unit= scale;
  5183. endResetModel();
  5184. }
  5185. Units::Unit MeasurementModel::displayUnits()
  5186. {
  5187. return unit;
  5188. }
  5189. /*:443*//*444:*/
  5190. #line 10283 "./typica.w"
  5191. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5192. {
  5193. /*435:*/
  5194. #line 10098 "./typica.w"
  5195. bool valid= false;
  5196. if(index.isValid())
  5197. {
  5198. if(index.row()<entries->size())
  5199. {
  5200. if(index.column()<colcount)
  5201. {
  5202. valid= true;
  5203. }
  5204. }
  5205. }
  5206. /*:435*/
  5207. #line 10286 "./typica.w"
  5208. if(!valid)
  5209. {
  5210. return QVariant();
  5211. }
  5212. MeasurementList*row= entries->at(index.row());
  5213. if(role==Qt::UserRole)
  5214. {
  5215. return QVariant(row->at(index.column()));
  5216. }
  5217. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5218. {
  5219. if(index.column()> row->size())
  5220. {
  5221. return QVariant();
  5222. }
  5223. else
  5224. {
  5225. if(index.column()==0)
  5226. {
  5227. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5228. }
  5229. else if(lastTemperature->contains(index.column()))
  5230. {
  5231. QVariantMap v= row->at(index.column()).toMap();
  5232. if(!v.contains("measurement"))
  5233. {
  5234. return QVariant();
  5235. }
  5236. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5237. {
  5238. return v.value("measurement");
  5239. }
  5240. else
  5241. {
  5242. if(v.contains("relative"))
  5243. {
  5244. if(v.value("relative").toBool())
  5245. {
  5246. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5247. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5248. }
  5249. }
  5250. return QVariant(QString("%1").
  5251. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5252. (Units::Unit)(v.value("unit").toInt()),unit)));
  5253. }
  5254. }
  5255. return QVariant(row->at(index.column()).toString());
  5256. }
  5257. }
  5258. return QVariant();
  5259. }
  5260. /*:444*//*445:*/
  5261. #line 10342 "./typica.w"
  5262. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5263. int role)const
  5264. {
  5265. if(orientation==Qt::Horizontal)
  5266. {
  5267. if(role==Qt::DisplayRole)
  5268. {
  5269. if(section<hData->size())
  5270. {
  5271. return QVariant(hData->at(section));
  5272. }
  5273. }
  5274. }
  5275. return QVariant();
  5276. }
  5277. /*:445*//*446:*/
  5278. #line 10369 "./typica.w"
  5279. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5280. {
  5281. /*435:*/
  5282. #line 10098 "./typica.w"
  5283. bool valid= false;
  5284. if(index.isValid())
  5285. {
  5286. if(index.row()<entries->size())
  5287. {
  5288. if(index.column()<colcount)
  5289. {
  5290. valid= true;
  5291. }
  5292. }
  5293. }
  5294. /*:435*/
  5295. #line 10372 "./typica.w"
  5296. if(valid)
  5297. {
  5298. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5299. }
  5300. return 0;
  5301. }
  5302. /*:446*//*447:*/
  5303. #line 10384 "./typica.w"
  5304. QModelIndex MeasurementModel::index(int row,int column,
  5305. const QModelIndex&parent)const
  5306. {
  5307. if(parent==QModelIndex())
  5308. {
  5309. if(row<entries->size()&&entries->isEmpty()==false)
  5310. {
  5311. if(column<entries->at(row)->size())
  5312. {
  5313. return createIndex(row,column);
  5314. }
  5315. }
  5316. }
  5317. return QModelIndex();
  5318. }
  5319. /*:447*/
  5320. #line 550 "./typica.w"
  5321. /*449:*/
  5322. #line 10435 "./typica.w"
  5323. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5324. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5325. {
  5326. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5327. }
  5328. /*:449*//*450:*/
  5329. #line 10450 "./typica.w"
  5330. void AnnotationButton::annotate()
  5331. {
  5332. if(note.contains("%1"))
  5333. {
  5334. count++;
  5335. emit annotation(note.arg(count),tc,ac);
  5336. }
  5337. else
  5338. {
  5339. emit annotation(note,tc,ac);
  5340. }
  5341. }
  5342. /*:450*//*451:*/
  5343. #line 10468 "./typica.w"
  5344. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5345. {
  5346. tc= tempcolumn;
  5347. }
  5348. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5349. {
  5350. ac= annotationcolumn;
  5351. }
  5352. void AnnotationButton::setAnnotation(const QString&annotation)
  5353. {
  5354. note= annotation;
  5355. }
  5356. /*:451*//*452:*/
  5357. #line 10487 "./typica.w"
  5358. void AnnotationButton::resetCount()
  5359. {
  5360. count= 0;
  5361. }
  5362. /*:452*/
  5363. #line 551 "./typica.w"
  5364. /*457:*/
  5365. #line 10570 "./typica.w"
  5366. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5367. const QString&postt,
  5368. QWidget*parent)
  5369. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5370. {
  5371. resetChange();
  5372. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5373. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5374. }
  5375. /*:457*//*458:*/
  5376. #line 10587 "./typica.w"
  5377. void AnnotationSpinBox::resetChange()
  5378. {
  5379. change= true;
  5380. }
  5381. /*:458*//*459:*/
  5382. #line 10598 "./typica.w"
  5383. void AnnotationSpinBox::annotate()
  5384. {
  5385. if(change)
  5386. {
  5387. change= false;
  5388. emit annotation(QString("%1%2%3").arg(pretext).
  5389. arg(value()).arg(posttext),tc,ac);
  5390. }
  5391. }
  5392. /*:459*//*460:*/
  5393. #line 10611 "./typica.w"
  5394. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5395. {
  5396. tc= tempcolumn;
  5397. }
  5398. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5399. {
  5400. ac= annotationcolumn;
  5401. }
  5402. void AnnotationSpinBox::setPretext(const QString&pret)
  5403. {
  5404. pretext= pret;
  5405. }
  5406. void AnnotationSpinBox::setPosttext(const QString&postt)
  5407. {
  5408. posttext= postt;
  5409. }
  5410. /*:460*/
  5411. #line 552 "./typica.w"
  5412. /*467:*/
  5413. #line 10780 "./typica.w"
  5414. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5415. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5416. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5417. stopAction(new QAction(tr("Stop"),NULL)),
  5418. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5419. relative(QTime::currentTime()),base(QTime(0,0,0))
  5420. {
  5421. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5422. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5423. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5424. clock.setInterval(500);
  5425. clock.setSingleShot(false);
  5426. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5427. setSegmentStyle(Filled);
  5428. updateDisplay();
  5429. }
  5430. /*:467*//*468:*/
  5431. #line 10801 "./typica.w"
  5432. void TimerDisplay::updateTime()
  5433. {
  5434. QTime time;
  5435. int cseconds= 0;
  5436. int oseconds= 0;
  5437. int r= 0;
  5438. QTime nt= QTime(0,0,0);
  5439. int n= 0;
  5440. int bseconds= 0;
  5441. switch(m)
  5442. {
  5443. case TimerDisplay::CountUp:
  5444. /*469:*/
  5445. #line 10833 "./typica.w"
  5446. /*470:*/
  5447. #line 10846 "./typica.w"
  5448. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5449. time= QTime::currentTime();
  5450. cseconds= TIMETOINT(time);
  5451. oseconds= TIMETOINT(relative);
  5452. r= cseconds-oseconds;
  5453. /*:470*/
  5454. #line 10834 "./typica.w"
  5455. nt= nt.addSecs(r);
  5456. if(nt!=s)
  5457. {
  5458. s= nt;
  5459. emit valueChanged(s);
  5460. }
  5461. /*:469*/
  5462. #line 10814 "./typica.w"
  5463. ;
  5464. break;
  5465. case TimerDisplay::CountDown:
  5466. /*471:*/
  5467. #line 10858 "./typica.w"
  5468. if(s> QTime(0,0,0))
  5469. {
  5470. /*470:*/
  5471. #line 10846 "./typica.w"
  5472. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5473. time= QTime::currentTime();
  5474. cseconds= TIMETOINT(time);
  5475. oseconds= TIMETOINT(relative);
  5476. r= cseconds-oseconds;
  5477. /*:470*/
  5478. #line 10861 "./typica.w"
  5479. bseconds= TIMETOINT(base);
  5480. n= bseconds-r;
  5481. nt= nt.addSecs(n);
  5482. if(nt!=s)
  5483. {
  5484. s= nt;
  5485. emit valueChanged(s);
  5486. }
  5487. }else{
  5488. stopTimer();
  5489. }
  5490. /*:471*/
  5491. #line 10817 "./typica.w"
  5492. ;
  5493. break;
  5494. case TimerDisplay::Clock:
  5495. /*472:*/
  5496. #line 10877 "./typica.w"
  5497. time= QTime::currentTime();
  5498. if(time!=s)
  5499. {
  5500. s= time;
  5501. emit valueChanged(s);
  5502. }
  5503. /*:472*/
  5504. #line 10820 "./typica.w"
  5505. ;
  5506. break;
  5507. default:
  5508. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5509. break;
  5510. }
  5511. updateDisplay();
  5512. }
  5513. /*:468*//*473:*/
  5514. #line 10889 "./typica.w"
  5515. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5516. void TimerDisplay::startTimer()
  5517. {
  5518. if(!running)
  5519. {
  5520. relative= QTime::currentTime();
  5521. if(ar)
  5522. {
  5523. reset();
  5524. }
  5525. else
  5526. {
  5527. relative= TIMESUBTRACT(relative,s);
  5528. }
  5529. if(m==Clock)
  5530. {
  5531. updateTime();
  5532. }
  5533. base= s;
  5534. clock.start();
  5535. running= true;
  5536. emit runStateChanged(true);
  5537. }
  5538. }
  5539. /*:473*//*474:*/
  5540. #line 10919 "./typica.w"
  5541. void TimerDisplay::stopTimer()
  5542. {
  5543. if(running)
  5544. {
  5545. clock.stop();
  5546. running= false;
  5547. emit runStateChanged(false);
  5548. }
  5549. }
  5550. /*:474*//*475:*/
  5551. #line 10932 "./typica.w"
  5552. TimerDisplay::~TimerDisplay()
  5553. {
  5554. clock.stop();
  5555. }
  5556. /*:475*//*476:*/
  5557. #line 10941 "./typica.w"
  5558. void TimerDisplay::setCountUpMode()
  5559. {
  5560. m= TimerDisplay::CountUp;
  5561. }
  5562. void TimerDisplay::setCountDownMode()
  5563. {
  5564. m= TimerDisplay::CountDown;
  5565. }
  5566. void TimerDisplay::setClockMode()
  5567. {
  5568. m= TimerDisplay::Clock;
  5569. }
  5570. /*:476*//*477:*/
  5571. #line 10959 "./typica.w"
  5572. QString TimerDisplay::value()
  5573. {
  5574. return s.toString(f);
  5575. }
  5576. QTime TimerDisplay::seconds()
  5577. {
  5578. return s;
  5579. }
  5580. TimerDisplay::TimerMode TimerDisplay::mode()
  5581. {
  5582. return m;
  5583. }
  5584. bool TimerDisplay::isRunning()
  5585. {
  5586. return running;
  5587. }
  5588. QTime TimerDisplay::resetValue()
  5589. {
  5590. return r;
  5591. }
  5592. QString TimerDisplay::displayFormat()
  5593. {
  5594. return f;
  5595. }
  5596. bool TimerDisplay::autoReset()
  5597. {
  5598. return ar;
  5599. }
  5600. /*:477*//*478:*/
  5601. #line 10997 "./typica.w"
  5602. void TimerDisplay::setTimer(QTime value)
  5603. {
  5604. if(value.isValid())
  5605. {
  5606. s= value;
  5607. updateDisplay();
  5608. emit valueChanged(value);
  5609. }
  5610. }
  5611. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5612. {
  5613. m= mode;
  5614. }
  5615. void TimerDisplay::setResetValue(QTime value)
  5616. {
  5617. r= value;
  5618. }
  5619. void TimerDisplay::setDisplayFormat(QString format)
  5620. {
  5621. f= format;
  5622. setNumDigits(format.length());
  5623. }
  5624. void TimerDisplay::setAutoReset(bool reset)
  5625. {
  5626. ar= reset;
  5627. }
  5628. /*:478*//*479:*/
  5629. #line 11032 "./typica.w"
  5630. void TimerDisplay::copyTimer()
  5631. {
  5632. QApplication::clipboard()->setText(value());
  5633. }
  5634. /*:479*//*480:*/
  5635. #line 11041 "./typica.w"
  5636. void TimerDisplay::reset()
  5637. {
  5638. if(!running)
  5639. {
  5640. s= r;
  5641. updateDisplay();
  5642. }
  5643. }
  5644. /*:480*//*481:*/
  5645. #line 11054 "./typica.w"
  5646. void TimerDisplay::updateDisplay()
  5647. {
  5648. display(value());
  5649. }
  5650. /*:481*/
  5651. #line 553 "./typica.w"
  5652. /*488:*/
  5653. #line 11179 "./typica.w"
  5654. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  5655. {
  5656. int x= rect.x();
  5657. int y= rect.y();
  5658. QLayoutItem*item;
  5659. if(orientation==Qt::Horizontal)
  5660. {
  5661. /*489:*/
  5662. #line 11203 "./typica.w"
  5663. foreach(item,itemList)
  5664. {
  5665. int nextX= x+item->sizeHint().width()+spacing();
  5666. int right= x+item->sizeHint().width();
  5667. if(item==itemList.last())
  5668. {
  5669. right= rect.right();
  5670. }
  5671. int bottom= rect.bottom();
  5672. if(!testOnly)
  5673. {
  5674. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5675. }
  5676. x= nextX;
  5677. }
  5678. /*:489*/
  5679. #line 11187 "./typica.w"
  5680. }
  5681. else
  5682. {
  5683. /*490:*/
  5684. #line 11222 "./typica.w"
  5685. foreach(item,itemList)
  5686. {
  5687. int nextY= y+item->sizeHint().height()+spacing();
  5688. int bottom= y+item->sizeHint().height();
  5689. if(item==itemList.last())
  5690. {
  5691. bottom= rect.bottom();
  5692. }
  5693. int right= rect.right();
  5694. if(!testOnly)
  5695. {
  5696. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  5697. }
  5698. y= nextY;
  5699. }
  5700. /*:490*/
  5701. #line 11191 "./typica.w"
  5702. }
  5703. return y;
  5704. }
  5705. /*:488*//*491:*/
  5706. #line 11246 "./typica.w"
  5707. QSize PackLayout::minimumSize()const
  5708. {
  5709. QSize size;
  5710. QLayoutItem*item;
  5711. foreach(item,itemList)
  5712. {
  5713. if(orientation==Qt::Horizontal)
  5714. {
  5715. size+= QSize(item->minimumSize().width(),0);
  5716. if(size.height()<item->minimumSize().height())
  5717. {
  5718. size.setHeight(item->minimumSize().height());
  5719. }
  5720. }
  5721. else
  5722. {
  5723. size+= QSize(0,item->minimumSize().height());
  5724. if(size.width()<item->minimumSize().width())
  5725. {
  5726. size.setWidth(item->minimumSize().width());
  5727. }
  5728. }
  5729. }
  5730. size+= QSize(2*margin(),2*margin());
  5731. return size;
  5732. }
  5733. /*:491*//*492:*/
  5734. #line 11278 "./typica.w"
  5735. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  5736. QLayout(parent)
  5737. {
  5738. setMargin(margin);
  5739. setSpacing(spacing);
  5740. setOrientation(Qt::Horizontal);
  5741. }
  5742. PackLayout::PackLayout(int spacing)
  5743. {
  5744. setSpacing(spacing);
  5745. setOrientation(Qt::Horizontal);
  5746. }
  5747. /*:492*//*493:*/
  5748. #line 11296 "./typica.w"
  5749. PackLayout::~PackLayout()
  5750. {
  5751. QLayoutItem*item;
  5752. while((item= takeAt(0)))
  5753. {
  5754. delete item;
  5755. }
  5756. }
  5757. /*:493*//*494:*/
  5758. #line 11310 "./typica.w"
  5759. QLayoutItem*PackLayout::takeAt(int index)
  5760. {
  5761. if(index>=0&&index<itemList.size())
  5762. {
  5763. return itemList.takeAt(index);
  5764. }
  5765. else
  5766. {
  5767. return NULL;
  5768. }
  5769. }
  5770. /*:494*//*495:*/
  5771. #line 11326 "./typica.w"
  5772. QLayoutItem*PackLayout::itemAt(int index)const
  5773. {
  5774. if(index>=0&&index<itemList.size())
  5775. {
  5776. return itemList.at(index);
  5777. }
  5778. else
  5779. {
  5780. return NULL;
  5781. }
  5782. }
  5783. /*:495*//*496:*/
  5784. #line 11349 "./typica.w"
  5785. void PackLayout::addItem(QLayoutItem*item)
  5786. {
  5787. itemList.append(item);
  5788. }
  5789. /*:496*//*497:*/
  5790. #line 11357 "./typica.w"
  5791. int PackLayout::count()const
  5792. {
  5793. return itemList.size();
  5794. }
  5795. /*:497*//*498:*/
  5796. #line 11369 "./typica.w"
  5797. Qt::Orientations PackLayout::expandingDirections()const
  5798. {
  5799. return Qt::Vertical|Qt::Horizontal;
  5800. }
  5801. bool PackLayout::hasHeightForWidth()const
  5802. {
  5803. return false;
  5804. }
  5805. int PackLayout::heightForWidth(int width)const
  5806. {
  5807. return doLayout(QRect(0,0,width,0),true);
  5808. }
  5809. void PackLayout::setGeometry(const QRect&rect)
  5810. {
  5811. QLayout::setGeometry(rect);
  5812. doLayout(rect,false);
  5813. }
  5814. QSize PackLayout::sizeHint()const
  5815. {
  5816. return minimumSize();
  5817. }
  5818. /*:498*//*499:*/
  5819. #line 11400 "./typica.w"
  5820. void PackLayout::setOrientation(Qt::Orientations direction)
  5821. {
  5822. orientation= direction;
  5823. doLayout(geometry(),false);
  5824. }
  5825. /*:499*/
  5826. #line 554 "./typica.w"
  5827. /*501:*/
  5828. #line 11439 "./typica.w"
  5829. SceneButton::SceneButton():QGraphicsScene()
  5830. {
  5831. }
  5832. SceneButton::~SceneButton()
  5833. {
  5834. }
  5835. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  5836. {
  5837. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  5838. }
  5839. /*:501*/
  5840. #line 555 "./typica.w"
  5841. /*503:*/
  5842. #line 11485 "./typica.w"
  5843. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  5844. Qt::Orientations orientation,
  5845. QWidget*parent,Qt::WindowFlags f):
  5846. QWidget(parent,f),label(new QGraphicsView()),
  5847. scene(new SceneButton())
  5848. {
  5849. layout= new PackLayout(this);
  5850. layout->setOrientation(orientation);
  5851. /*504:*/
  5852. #line 11505 "./typica.w"
  5853. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5854. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  5855. label->setFrameShape(QFrame::NoFrame);
  5856. label->setInteractive(true);
  5857. /*:504*/
  5858. #line 11494 "./typica.w"
  5859. /*505:*/
  5860. #line 11516 "./typica.w"
  5861. scene->setBackgroundBrush(Qt::cyan);
  5862. text= scene->addText(labeltext);
  5863. if(orientation==Qt::Horizontal)
  5864. {
  5865. text->rotate(270.0);
  5866. }
  5867. label->setScene(scene);
  5868. /*:505*/
  5869. #line 11495 "./typica.w"
  5870. /*506:*/
  5871. #line 11534 "./typica.w"
  5872. if(orientation==Qt::Horizontal)
  5873. {
  5874. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  5875. }
  5876. else
  5877. {
  5878. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  5879. }
  5880. label->centerOn(text);
  5881. /*:506*/
  5882. #line 11496 "./typica.w"
  5883. /*507:*/
  5884. #line 11549 "./typica.w"
  5885. layout->addWidget(label);
  5886. layout->addWidget(widget);
  5887. if(orientation==Qt::Horizontal)
  5888. {
  5889. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  5890. widget->sizeHint().height());
  5891. }
  5892. else
  5893. {
  5894. setMinimumSize(widget->sizeHint().width(),
  5895. widget->sizeHint().height()+label->sizeHint().height());
  5896. }
  5897. /*:507*/
  5898. #line 11497 "./typica.w"
  5899. }
  5900. /*:503*//*508:*/
  5901. #line 11566 "./typica.w"
  5902. void WidgetDecorator::setBackgroundBrush(QBrush background)
  5903. {
  5904. scene->setBackgroundBrush(background);
  5905. }
  5906. void WidgetDecorator::setTextColor(QColor color)
  5907. {
  5908. text->setDefaultTextColor(color);
  5909. }
  5910. /*:508*//*509:*/
  5911. #line 11579 "./typica.w"
  5912. WidgetDecorator::~WidgetDecorator()
  5913. {
  5914. }
  5915. /*:509*/
  5916. #line 556 "./typica.w"
  5917. /*514:*/
  5918. #line 11678 "./typica.w"
  5919. void LogEditWindow::addTheRows()
  5920. {
  5921. QTime s= startTime->time();
  5922. while(s<endTime->time())
  5923. {
  5924. model->newMeasurement(Measurement(0,s),1);
  5925. s= s.addSecs(interval->value());
  5926. }
  5927. model->newMeasurement(Measurement(0,endTime->time()),1);
  5928. }
  5929. /*:514*//*515:*/
  5930. #line 11692 "./typica.w"
  5931. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  5932. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  5933. addRowsLayout(new QHBoxLayout(NULL)),
  5934. startTimeLabel(new QLabel("Start Time")),
  5935. startTime(new QTimeEdit(QTime(0,0,0,0))),
  5936. endTimeLabel(new QLabel("End Time")),
  5937. endTime(new QTimeEdit(QTime(0,20,0,0))),
  5938. intervalLabel(new QLabel("Interval (seconds)")),
  5939. interval(new QSpinBox()),
  5940. addRows(new QPushButton("Add Rows")),
  5941. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  5942. saveCsv(new QAction(tr("Export CSV"),NULL)),
  5943. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  5944. model(new MeasurementModel()),
  5945. log(new QTableView())
  5946. {
  5947. /*516:*/
  5948. #line 11729 "./typica.w"
  5949. QSettings settings;
  5950. resize(settings.value("logSize",QSize(620,400)).toSize());
  5951. move(settings.value("logPos",QPoint(200,60)).toPoint());
  5952. /*:516*/
  5953. #line 11709 "./typica.w"
  5954. /*517:*/
  5955. #line 11742 "./typica.w"
  5956. mainLayout->setOrientation(Qt::Vertical);
  5957. addRowsLayout->addSpacing(10);
  5958. addRowsLayout->addWidget(startTimeLabel);
  5959. addRowsLayout->addWidget(startTime);
  5960. addRowsLayout->addSpacing(10);
  5961. startTime->setDisplayFormat("mm:ss");
  5962. addRowsLayout->addWidget(endTimeLabel);
  5963. addRowsLayout->addWidget(endTime);
  5964. addRowsLayout->addSpacing(10);
  5965. endTime->setDisplayFormat("mm:ss");
  5966. addRowsLayout->addWidget(intervalLabel);
  5967. addRowsLayout->addWidget(interval);
  5968. addRowsLayout->addSpacing(10);
  5969. interval->setRange(0,60);
  5970. interval->setValue(30);
  5971. addRowsLayout->addWidget(addRows);
  5972. addRowsLayout->addSpacing(10);
  5973. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  5974. /*:517*/
  5975. #line 11710 "./typica.w"
  5976. /*518:*/
  5977. #line 11765 "./typica.w"
  5978. model->setHeaderData(0,Qt::Horizontal,"Time");
  5979. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  5980. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  5981. model->clear();
  5982. /*:518*/
  5983. #line 11711 "./typica.w"
  5984. /*519:*/
  5985. #line 11774 "./typica.w"
  5986. log->setModel(model);
  5987. log->setColumnWidth(0,100);
  5988. log->setColumnWidth(1,100);
  5989. log->setColumnWidth(2,100);
  5990. /*:519*/
  5991. #line 11712 "./typica.w"
  5992. mainLayout->addItem(addRowsLayout);
  5993. mainLayout->addWidget(log);
  5994. centralWidget->setLayout(mainLayout);
  5995. setCentralWidget(centralWidget);
  5996. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  5997. fileMenu->addAction(openXml);
  5998. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  5999. fileMenu->addAction(saveXml);
  6000. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6001. fileMenu->addAction(saveCsv);
  6002. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6003. }
  6004. /*:515*//*520:*/
  6005. #line 11785 "./typica.w"
  6006. void LogEditWindow::saveXML()
  6007. {
  6008. QSettings settings;
  6009. QString lastDir= settings.value("lastDirectory").toString();
  6010. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6011. lastDir,"",0);
  6012. QFile file(filename);
  6013. XMLOutput writer(model,&file,0);
  6014. writer.addTemperatureColumn("Temperature",1);
  6015. writer.addAnnotationColumn("Annotation",2);
  6016. if(writer.output())
  6017. {
  6018. QFileInfo info(filename);
  6019. QDir directory= info.dir();
  6020. lastDir= directory.path();
  6021. settings.setValue("lastDirectory",lastDir);
  6022. }
  6023. }
  6024. void LogEditWindow::saveCSV()
  6025. {
  6026. QSettings settings;
  6027. QString lastDir= settings.value("lastDirectory").toString();
  6028. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6029. lastDir,"",0);
  6030. QFile file(filename);
  6031. CSVOutput writer(model,&file,0);
  6032. writer.addTemperatureColumn("Temperature",1);
  6033. writer.addAnnotationColumn("Annotation",2);
  6034. if(writer.output())
  6035. {
  6036. QFileInfo info(filename);
  6037. QDir directory= info.dir();
  6038. lastDir= directory.path();
  6039. settings.setValue("lastDirectory",lastDir);
  6040. }
  6041. }
  6042. /*:520*//*521:*/
  6043. #line 11828 "./typica.w"
  6044. void LogEditWindow::openXML()
  6045. {
  6046. QSettings settings;
  6047. QString lastDir= settings.value("lastDirectory").toString();
  6048. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6049. lastDir,"",0);
  6050. if(filename.isNull())
  6051. {
  6052. return;
  6053. }
  6054. QFile file(filename);
  6055. XMLInput reader(&file,1);
  6056. connect(&reader,SIGNAL(measure(Measurement,int)),
  6057. model,SLOT(newMeasurement(Measurement,int)));
  6058. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6059. model,SLOT(newAnnotation(QString,int,int)));
  6060. if(reader.input())
  6061. {
  6062. QFileInfo info(filename);
  6063. setWindowTitle(QString(tr("%1 - %2")).
  6064. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6065. QDir directory= info.dir();
  6066. lastDir= directory.path();
  6067. settings.setValue("lastDirectory",lastDir);
  6068. }
  6069. }
  6070. /*:521*//*522:*/
  6071. #line 11859 "./typica.w"
  6072. void LogEditWindow::closeEvent(QCloseEvent*event)
  6073. {
  6074. QSettings settings;
  6075. settings.setValue("logSize",size());
  6076. settings.setValue("logPos",pos());
  6077. event->accept();
  6078. }
  6079. /*:522*/
  6080. #line 557 "./typica.w"
  6081. /*528:*/
  6082. #line 11974 "./typica.w"
  6083. bool XMLOutput::output()
  6084. {
  6085. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6086. {
  6087. return false;
  6088. }
  6089. QXmlStreamWriter xmlout(out);
  6090. xmlout.writeStartDocument("1.0");
  6091. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6092. xmlout.writeStartElement("roastlog");
  6093. /*529:*/
  6094. #line 12007 "./typica.w"
  6095. foreach(int c,temperatureColumns.keys())
  6096. {
  6097. xmlout.writeStartElement("tempseries");
  6098. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6099. xmlout.writeEndElement();
  6100. }
  6101. foreach(int c,controlColumns.keys())
  6102. {
  6103. xmlout.writeStartElement("controlseries");
  6104. xmlout.writeAttribute("name",controlColumns.value(c));
  6105. xmlout.writeEndElement();
  6106. }
  6107. foreach(int c,annotationColumns.keys())
  6108. {
  6109. xmlout.writeStartElement("noteseries");
  6110. xmlout.writeAttribute("name",annotationColumns.value(c));
  6111. xmlout.writeEndElement();
  6112. }
  6113. /*:529*/
  6114. #line 11985 "./typica.w"
  6115. xmlout.writeStartElement("roast");
  6116. bool oresult;
  6117. for(int i= 0;i<data->rowCount();i++)
  6118. {
  6119. /*530:*/
  6120. #line 12032 "./typica.w"
  6121. oresult= false;
  6122. foreach(int c,temperatureColumns.keys())
  6123. {
  6124. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6125. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6126. {
  6127. oresult= true;
  6128. break;
  6129. }
  6130. }
  6131. foreach(int c,controlColumns.keys())
  6132. {
  6133. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6134. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6135. {
  6136. oresult= true;
  6137. break;
  6138. }
  6139. }
  6140. if(oresult==false)
  6141. {
  6142. foreach(int c,annotationColumns.keys())
  6143. {
  6144. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6145. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6146. isEmpty()))
  6147. {
  6148. oresult= true;
  6149. break;
  6150. }
  6151. }
  6152. }
  6153. /*:530*/
  6154. #line 11990 "./typica.w"
  6155. if(oresult)
  6156. {
  6157. /*531:*/
  6158. #line 12071 "./typica.w"
  6159. xmlout.writeStartElement("tuple");
  6160. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6161. Qt::DisplayRole).toString());
  6162. foreach(int c,temperatureColumns.keys())
  6163. {
  6164. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6165. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6166. {
  6167. xmlout.writeStartElement("temperature");
  6168. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6169. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6170. {
  6171. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6172. {
  6173. xmlout.writeAttribute("relative","true");
  6174. }
  6175. }
  6176. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6177. toString());
  6178. xmlout.writeEndElement();
  6179. }
  6180. }
  6181. foreach(int c,controlColumns.keys())
  6182. {
  6183. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6184. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6185. {
  6186. xmlout.writeStartElement("control");
  6187. xmlout.writeAttribute("series",controlColumns.value(c));
  6188. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6189. xmlout.writeEndElement();
  6190. }
  6191. }
  6192. foreach(int c,annotationColumns.keys())
  6193. {
  6194. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6195. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6196. {
  6197. xmlout.writeStartElement("annotation");
  6198. xmlout.writeAttribute("series",annotationColumns.value(c));
  6199. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6200. toString());
  6201. xmlout.writeEndElement();
  6202. }
  6203. }
  6204. xmlout.writeEndElement();
  6205. /*:531*/
  6206. #line 11993 "./typica.w"
  6207. }
  6208. }
  6209. xmlout.writeEndElement();
  6210. xmlout.writeEndElement();
  6211. xmlout.writeEndDocument();
  6212. out->close();
  6213. return true;
  6214. }
  6215. /*:528*//*532:*/
  6216. #line 12121 "./typica.w"
  6217. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6218. :QObject(NULL),data(model),out(device),time(timec)
  6219. {
  6220. }
  6221. void XMLOutput::setModel(MeasurementModel*model)
  6222. {
  6223. data= model;
  6224. }
  6225. void XMLOutput::setTimeColumn(int column)
  6226. {
  6227. time= column;
  6228. }
  6229. void XMLOutput::setDevice(QIODevice*device)
  6230. {
  6231. out= device;
  6232. }
  6233. /*:532*//*533:*/
  6234. #line 12150 "./typica.w"
  6235. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6236. {
  6237. temperatureColumns.insert(column,series);
  6238. }
  6239. void XMLOutput::addControlColumn(const QString&series,int column)
  6240. {
  6241. controlColumns.insert(column,series);
  6242. }
  6243. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6244. {
  6245. annotationColumns.insert(column,series);
  6246. }
  6247. /*:533*/
  6248. #line 558 "./typica.w"
  6249. /*535:*/
  6250. #line 12207 "./typica.w"
  6251. bool XMLInput::input()
  6252. {
  6253. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6254. {
  6255. return false;
  6256. }
  6257. QXmlStreamReader xmlin(in);
  6258. QMap<QString,int> temperatureColumns;
  6259. QMap<QString,int> annotationColumns;
  6260. int nextColumn= firstc;
  6261. /*536:*/
  6262. #line 12238 "./typica.w"
  6263. while(!xmlin.isDTD())
  6264. {
  6265. xmlin.readNext();
  6266. }
  6267. if(xmlin.isDTD())
  6268. {
  6269. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6270. {
  6271. /*537:*/
  6272. #line 12260 "./typica.w"
  6273. emit newTemperatureColumn(firstc,"Bean");
  6274. emit newAnnotationColumn(firstc+1,"Note");
  6275. emit lastColumn(firstc+1);
  6276. /*:537*/
  6277. #line 12247 "./typica.w"
  6278. }
  6279. else
  6280. {
  6281. xmlin.readNext();
  6282. /*538:*/
  6283. #line 12269 "./typica.w"
  6284. while(xmlin.name()!="roast")
  6285. {
  6286. if(xmlin.isStartElement())
  6287. {
  6288. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6289. {
  6290. temperatureColumns.insert(xmlin.attributes().value("name").
  6291. toString(),
  6292. nextColumn);
  6293. emit newTemperatureColumn(nextColumn,
  6294. xmlin.attributes().value("name").
  6295. toString());
  6296. nextColumn++;
  6297. }
  6298. else if(xmlin.name()=="noteseries")
  6299. {
  6300. annotationColumns.insert(xmlin.attributes().value("name").
  6301. toString(),nextColumn);
  6302. emit newAnnotationColumn(nextColumn,
  6303. xmlin.attributes().value("name").
  6304. toString());
  6305. nextColumn++;
  6306. }
  6307. }
  6308. xmlin.readNext();
  6309. }
  6310. emit lastColumn(nextColumn-1);
  6311. /*:538*/
  6312. #line 12252 "./typica.w"
  6313. }
  6314. }
  6315. /*:536*/
  6316. #line 12218 "./typica.w"
  6317. QTime timeval= QTime();
  6318. double tempval= 0;
  6319. QString noteval= QString();
  6320. int column;
  6321. int counter= 0;
  6322. while(!xmlin.atEnd())
  6323. {
  6324. /*539:*/
  6325. #line 12310 "./typica.w"
  6326. xmlin.readNext();
  6327. if(xmlin.isStartElement())
  6328. {
  6329. /*540:*/
  6330. #line 12336 "./typica.w"
  6331. if(xmlin.name()=="time")
  6332. {
  6333. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6334. }
  6335. else if(xmlin.name()=="temperature")
  6336. {
  6337. column= xmlin.attributes().hasAttribute("series")?
  6338. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6339. bool relative= (xmlin.attributes().value("relative")=="true");
  6340. tempval= xmlin.readElementText().toDouble();
  6341. Measurement measurement(tempval,timeval);
  6342. if(relative)
  6343. {
  6344. measurement.insert("relative",true);
  6345. }
  6346. emit measure(measurement,column);
  6347. }
  6348. else if(xmlin.name()=="control")
  6349. {
  6350. column= xmlin.attributes().value("series").toString().isEmpty()?
  6351. firstc:temperatureColumns.value(xmlin.attributes().
  6352. value("series").toString());
  6353. tempval= xmlin.readElementText().toDouble();
  6354. Measurement measurement(tempval,timeval,Units::Unitless);
  6355. emit measure(measurement,column);
  6356. }
  6357. else if(xmlin.name()=="annotation")
  6358. {
  6359. column= xmlin.attributes().value("series").toString().isEmpty()?
  6360. firstc+1:annotationColumns.value(xmlin.attributes().
  6361. value("series").toString());
  6362. noteval= xmlin.readElementText();
  6363. if(!noteval.isEmpty())
  6364. {
  6365. emit annotation(noteval,firstc,column);
  6366. }
  6367. }
  6368. /*:540*/
  6369. #line 12314 "./typica.w"
  6370. }
  6371. counter++;
  6372. if(counter%100==0)
  6373. {
  6374. QCoreApplication::processEvents();
  6375. }
  6376. /*:539*/
  6377. #line 12226 "./typica.w"
  6378. }
  6379. return true;
  6380. }
  6381. /*:535*//*541:*/
  6382. #line 12377 "./typica.w"
  6383. XMLInput::XMLInput(QIODevice*input,int c):
  6384. firstc(c),in(input)
  6385. {
  6386. }
  6387. void XMLInput::setFirstColumn(int column)
  6388. {
  6389. firstc= column;
  6390. }
  6391. void XMLInput::setDevice(QIODevice*device)
  6392. {
  6393. in= device;
  6394. }
  6395. /*:541*/
  6396. #line 559 "./typica.w"
  6397. /*546:*/
  6398. #line 12468 "./typica.w"
  6399. bool CSVOutput::output()
  6400. {
  6401. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6402. {
  6403. return false;
  6404. }
  6405. QTextStream output(out);
  6406. /*547:*/
  6407. #line 12492 "./typica.w"
  6408. output<<"Time";
  6409. foreach(int c,temperatureColumns.keys())
  6410. {
  6411. output<<','<<temperatureColumns.value(c);
  6412. }
  6413. foreach(int c,controlColumns.keys())
  6414. {
  6415. output<<','<<controlColumns.value(c);
  6416. }
  6417. foreach(int c,annotationColumns.keys())
  6418. {
  6419. output<<','<<annotationColumns.value(c);
  6420. }
  6421. output<<'\n';
  6422. /*:547*/
  6423. #line 12476 "./typica.w"
  6424. bool oresult;
  6425. for(int i= 0;i<data->rowCount();i++)
  6426. {
  6427. /*530:*/
  6428. #line 12032 "./typica.w"
  6429. oresult= false;
  6430. foreach(int c,temperatureColumns.keys())
  6431. {
  6432. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6433. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6434. {
  6435. oresult= true;
  6436. break;
  6437. }
  6438. }
  6439. foreach(int c,controlColumns.keys())
  6440. {
  6441. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6442. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6443. {
  6444. oresult= true;
  6445. break;
  6446. }
  6447. }
  6448. if(oresult==false)
  6449. {
  6450. foreach(int c,annotationColumns.keys())
  6451. {
  6452. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6453. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6454. isEmpty()))
  6455. {
  6456. oresult= true;
  6457. break;
  6458. }
  6459. }
  6460. }
  6461. /*:530*/
  6462. #line 12480 "./typica.w"
  6463. if(oresult)
  6464. {
  6465. /*548:*/
  6466. #line 12517 "./typica.w"
  6467. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6468. foreach(int c,temperatureColumns.keys())
  6469. {
  6470. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6471. }
  6472. foreach(int c,controlColumns.keys())
  6473. {
  6474. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6475. }
  6476. foreach(int c,annotationColumns.keys())
  6477. {
  6478. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6479. }
  6480. output<<'\n';
  6481. /*:548*/
  6482. #line 12483 "./typica.w"
  6483. }
  6484. }
  6485. out->close();
  6486. return true;
  6487. }
  6488. /*:546*//*549:*/
  6489. #line 12536 "./typica.w"
  6490. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6491. data(model),out(device),time(timec)
  6492. {
  6493. }
  6494. void CSVOutput::setModel(MeasurementModel*model)
  6495. {
  6496. data= model;
  6497. }
  6498. void CSVOutput::setTimeColumn(int column)
  6499. {
  6500. time= column;
  6501. }
  6502. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6503. {
  6504. temperatureColumns.insert(column,series);
  6505. }
  6506. void CSVOutput::addControlColumn(const QString&series,int column)
  6507. {
  6508. controlColumns.insert(column,series);
  6509. }
  6510. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6511. {
  6512. annotationColumns.insert(column,series);
  6513. }
  6514. void CSVOutput::setDevice(QIODevice*device)
  6515. {
  6516. out= device;
  6517. }
  6518. #line 1 "./webview.w"
  6519. /*:549*/
  6520. #line 560 "./typica.w"
  6521. /*584:*/
  6522. #line 12797 "./typica.w"
  6523. QString SaltModel::arrayLiteral(int column,int role)const
  6524. {
  6525. QString literal= "'{";
  6526. for(int i= 0;i<rowCount();i++)
  6527. {
  6528. QString datum= data(index(i,column),role).toString();
  6529. if(!datum.isEmpty())
  6530. {
  6531. literal.append(datum);
  6532. literal.append(", ");
  6533. }
  6534. }
  6535. if(literal.size()> 2)
  6536. {
  6537. literal.chop(2);
  6538. }
  6539. literal.append("}'");
  6540. return literal;
  6541. }
  6542. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6543. {
  6544. QString literal= "'{";
  6545. for(int i= 0;i<rowCount();i++)
  6546. {
  6547. QString datum= data(index(i,column),role).toString();
  6548. if(!datum.isEmpty())
  6549. {
  6550. literal.append("\"");
  6551. literal.append(datum);
  6552. literal.append("\", ");
  6553. }
  6554. }
  6555. if(literal.size()> 2)
  6556. {
  6557. literal.chop(2);
  6558. }
  6559. literal.append("}'");
  6560. return literal;
  6561. }
  6562. /*:584*//*585:*/
  6563. #line 12841 "./typica.w"
  6564. QModelIndex SaltModel::parent(const QModelIndex&)const
  6565. {
  6566. return QModelIndex();
  6567. }
  6568. /*:585*//*586:*/
  6569. #line 12860 "./typica.w"
  6570. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6571. int role)
  6572. {
  6573. /*587:*/
  6574. #line 12891 "./typica.w"
  6575. bool valid= false;
  6576. if(index.isValid())
  6577. {
  6578. if(index.row()<modelData.size())
  6579. {
  6580. if(index.column()<colcount)
  6581. {
  6582. valid= true;
  6583. }
  6584. }
  6585. }
  6586. /*:587*/
  6587. #line 12864 "./typica.w"
  6588. if(!valid)
  6589. {
  6590. return false;
  6591. }
  6592. if(index.row()==modelData.size()-1)
  6593. {
  6594. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6595. /*588:*/
  6596. #line 12907 "./typica.w"
  6597. QList<QMap<int,QVariant> > newRow;
  6598. QMap<int,QVariant> defaults;
  6599. for(int i= 0;i<colcount;i++)
  6600. {
  6601. newRow.append(defaults);
  6602. }
  6603. modelData.append(newRow);
  6604. /*:588*/
  6605. #line 12872 "./typica.w"
  6606. endInsertRows();
  6607. }
  6608. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6609. QMap<int,QVariant> cell= row.at(index.column());
  6610. cell.insert(role,value);
  6611. if(role==Qt::EditRole)
  6612. {
  6613. cell.insert(Qt::DisplayRole,value);
  6614. }
  6615. row.replace(index.column(),cell);
  6616. modelData.replace(index.row(),row);
  6617. emit dataChanged(index,index);
  6618. return true;
  6619. }
  6620. /*:586*//*589:*/
  6621. #line 12918 "./typica.w"
  6622. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6623. {
  6624. for(int i= 0;i<columns;i++)
  6625. {
  6626. hData<<"";
  6627. }
  6628. /*588:*/
  6629. #line 12907 "./typica.w"
  6630. QList<QMap<int,QVariant> > newRow;
  6631. QMap<int,QVariant> defaults;
  6632. for(int i= 0;i<colcount;i++)
  6633. {
  6634. newRow.append(defaults);
  6635. }
  6636. modelData.append(newRow);
  6637. /*:588*/
  6638. #line 12925 "./typica.w"
  6639. }
  6640. /*:589*//*590:*/
  6641. #line 12930 "./typica.w"
  6642. SaltModel::~SaltModel()
  6643. {
  6644. }
  6645. /*:590*//*591:*/
  6646. #line 12940 "./typica.w"
  6647. int SaltModel::rowCount(const QModelIndex&parent)const
  6648. {
  6649. return(parent==QModelIndex()?modelData.size():0);
  6650. }
  6651. int SaltModel::columnCount(const QModelIndex&parent)const
  6652. {
  6653. return(parent==QModelIndex()?colcount:0);
  6654. }
  6655. /*:591*//*592:*/
  6656. #line 12953 "./typica.w"
  6657. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  6658. const QVariant&value,int)
  6659. {
  6660. if(orientation==Qt::Horizontal&&section<colcount)
  6661. {
  6662. hData.replace(section,value.toString());
  6663. emit headerDataChanged(orientation,section,section);
  6664. return true;
  6665. }
  6666. return false;
  6667. }
  6668. /*:592*//*593:*/
  6669. #line 12968 "./typica.w"
  6670. QVariant SaltModel::data(const QModelIndex&index,int role)const
  6671. {
  6672. /*587:*/
  6673. #line 12891 "./typica.w"
  6674. bool valid= false;
  6675. if(index.isValid())
  6676. {
  6677. if(index.row()<modelData.size())
  6678. {
  6679. if(index.column()<colcount)
  6680. {
  6681. valid= true;
  6682. }
  6683. }
  6684. }
  6685. /*:587*/
  6686. #line 12971 "./typica.w"
  6687. if(!valid)
  6688. {
  6689. return QVariant();
  6690. }
  6691. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6692. QMap<int,QVariant> cell= row.at(index.column());
  6693. return cell.value(role,QVariant());
  6694. }
  6695. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  6696. int role)const
  6697. {
  6698. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  6699. section<colcount)
  6700. {
  6701. return QVariant(hData.at(section));
  6702. }
  6703. return QVariant();
  6704. }
  6705. /*:593*//*594:*/
  6706. #line 12995 "./typica.w"
  6707. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  6708. {
  6709. /*587:*/
  6710. #line 12891 "./typica.w"
  6711. bool valid= false;
  6712. if(index.isValid())
  6713. {
  6714. if(index.row()<modelData.size())
  6715. {
  6716. if(index.column()<colcount)
  6717. {
  6718. valid= true;
  6719. }
  6720. }
  6721. }
  6722. /*:587*/
  6723. #line 12998 "./typica.w"
  6724. if(valid)
  6725. {
  6726. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  6727. }
  6728. return 0;
  6729. }
  6730. /*:594*//*595:*/
  6731. #line 13009 "./typica.w"
  6732. QModelIndex SaltModel::index(int row,int column,
  6733. const QModelIndex&parent)const
  6734. {
  6735. if(parent==QModelIndex())
  6736. {
  6737. if(row<modelData.size()&&column<colcount)
  6738. {
  6739. return createIndex(row,column);
  6740. }
  6741. }
  6742. return QModelIndex();
  6743. }
  6744. /*:595*//*596:*/
  6745. #line 13027 "./typica.w"
  6746. void SaltModel::clear()
  6747. {
  6748. beginResetModel();
  6749. modelData.clear();
  6750. /*588:*/
  6751. #line 12907 "./typica.w"
  6752. QList<QMap<int,QVariant> > newRow;
  6753. QMap<int,QVariant> defaults;
  6754. for(int i= 0;i<colcount;i++)
  6755. {
  6756. newRow.append(defaults);
  6757. }
  6758. modelData.append(newRow);
  6759. /*:588*/
  6760. #line 13032 "./typica.w"
  6761. endResetModel();
  6762. }
  6763. /*:596*//*597:*/
  6764. #line 13041 "./typica.w"
  6765. bool SaltModel::removeRows(int row,int count,
  6766. const QModelIndex&parent)
  6767. {
  6768. if(parent==QModelIndex())
  6769. {
  6770. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  6771. {
  6772. beginRemoveRows(parent,row,row+count-1);
  6773. for(int i= 0;i<count;i++)
  6774. {
  6775. modelData.removeAt(row);
  6776. }
  6777. endRemoveRows();
  6778. if(modelData.size()==0)
  6779. {
  6780. beginInsertRows(parent,0,0);
  6781. /*588:*/
  6782. #line 12907 "./typica.w"
  6783. QList<QMap<int,QVariant> > newRow;
  6784. QMap<int,QVariant> defaults;
  6785. for(int i= 0;i<colcount;i++)
  6786. {
  6787. newRow.append(defaults);
  6788. }
  6789. modelData.append(newRow);
  6790. /*:588*/
  6791. #line 13058 "./typica.w"
  6792. endInsertRows();
  6793. }
  6794. return true;
  6795. }
  6796. }
  6797. return false;
  6798. }
  6799. /*:597*//*598:*/
  6800. #line 13072 "./typica.w"
  6801. int SaltModel::findData(const QVariant&value,int column,int role)
  6802. {
  6803. for(int i= 0;i<modelData.size();i++)
  6804. {
  6805. if(modelData.at(i).size()> column)
  6806. {
  6807. if(modelData.at(i).at(column).contains(role))
  6808. {
  6809. if(modelData.at(i).at(column).value(role)==value)
  6810. {
  6811. return i;
  6812. }
  6813. }
  6814. }
  6815. }
  6816. return-1;
  6817. }
  6818. /*:598*/
  6819. #line 561 "./typica.w"
  6820. /*600:*/
  6821. #line 13136 "./typica.w"
  6822. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  6823. {
  6824. SqlComboBox*widget= new SqlComboBox();
  6825. widget->setParent(parent);
  6826. for(int i= 0;i<count();i++)
  6827. {
  6828. widget->addItem(itemText(i),itemData(i));
  6829. }
  6830. return widget;
  6831. }
  6832. /*:600*//*601:*/
  6833. #line 13153 "./typica.w"
  6834. void SqlComboBox::showData(bool show)
  6835. {
  6836. dataColumnShown= show;
  6837. }
  6838. /*:601*//*602:*/
  6839. #line 13167 "./typica.w"
  6840. void SqlComboBox::addNullOption()
  6841. {
  6842. addItem(specialNullText,specialNullData);
  6843. }
  6844. void SqlComboBox::setNullText(QString nullText)
  6845. {
  6846. specialNullText= nullText;
  6847. }
  6848. void SqlComboBox::setNullData(QVariant nullData)
  6849. {
  6850. specialNullData= nullData;
  6851. }
  6852. /*:602*//*603:*/
  6853. #line 13190 "./typica.w"
  6854. void SqlComboBox::setDataColumn(int column)
  6855. {
  6856. dataColumn= column;
  6857. }
  6858. void SqlComboBox::setDisplayColumn(int column)
  6859. {
  6860. displayColumn= column;
  6861. }
  6862. /*:603*//*604:*/
  6863. #line 13204 "./typica.w"
  6864. void SqlComboBox::addSqlOptions(QString query)
  6865. {
  6866. SqlQueryConnection h;
  6867. QSqlQuery*dbquery= h.operator->();
  6868. if(!dbquery->exec(query))
  6869. {
  6870. QSqlError error= dbquery->lastError();
  6871. qDebug()<<error.databaseText();
  6872. qDebug()<<error.driverText();
  6873. qDebug()<<error.text();
  6874. qDebug()<<dbquery->lastQuery();
  6875. }
  6876. while(dbquery->next())
  6877. {
  6878. QString displayValue(dbquery->value(displayColumn).toString());
  6879. QString dataValue(dbquery->value(dataColumn).toString());
  6880. if(dataColumnShown)
  6881. {
  6882. displayValue.append(QString(" (%1)").arg(dataValue));
  6883. }
  6884. addItem(displayValue,dataValue);
  6885. }
  6886. }
  6887. /*:604*//*605:*/
  6888. #line 13240 "./typica.w"
  6889. SqlComboBox::SqlComboBox():
  6890. dataColumn(0),displayColumn(0),dataColumnShown(false),
  6891. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  6892. {
  6893. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  6894. }
  6895. SqlComboBox::~SqlComboBox()
  6896. {
  6897. }
  6898. /*:605*/
  6899. #line 562 "./typica.w"
  6900. /*607:*/
  6901. #line 13279 "./typica.w"
  6902. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  6903. {
  6904. delegate= widget;
  6905. }
  6906. /*:607*//*608:*/
  6907. #line 13288 "./typica.w"
  6908. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  6909. const QStyleOptionViewItem&,
  6910. const QModelIndex&)const
  6911. {
  6912. return delegate->clone(parent);
  6913. }
  6914. /*:608*//*609:*/
  6915. #line 13299 "./typica.w"
  6916. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  6917. const QModelIndex&index)const
  6918. {
  6919. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6920. self->setCurrentIndex(self->findData(
  6921. index.model()->data(index,
  6922. Qt::UserRole).toString()));
  6923. }
  6924. /*:609*//*610:*/
  6925. #line 13312 "./typica.w"
  6926. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  6927. QAbstractItemModel*model,
  6928. const QModelIndex&index)const
  6929. {
  6930. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  6931. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  6932. Qt::UserRole);
  6933. model->setData(index,self->currentText(),Qt::DisplayRole);
  6934. }
  6935. /*:610*//*611:*/
  6936. #line 13325 "./typica.w"
  6937. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  6938. const QStyleOptionViewItem&option,
  6939. const QModelIndex&)const
  6940. {
  6941. editor->setGeometry(option.rect);
  6942. }
  6943. /*:611*//*612:*/
  6944. #line 13336 "./typica.w"
  6945. QSize SqlComboBoxDelegate::sizeHint()const
  6946. {
  6947. return delegate->sizeHint();
  6948. }
  6949. /*:612*//*613:*/
  6950. #line 13344 "./typica.w"
  6951. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  6952. :QItemDelegate(parent)
  6953. {
  6954. }
  6955. /*:613*/
  6956. #line 563 "./typica.w"
  6957. /*576:*/
  6958. #line 12606 "./typica.w"
  6959. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  6960. {
  6961. /*577:*/
  6962. #line 12621 "./typica.w"
  6963. setOrganizationName("Wilson's Coffee & Tea");
  6964. setOrganizationDomain("wilsonscoffee.com");
  6965. setApplicationName(PROGRAM_NAME);
  6966. /*:577*/
  6967. #line 12609 "./typica.w"
  6968. /*578:*/
  6969. #line 12630 "./typica.w"
  6970. QTranslator*base= new QTranslator;
  6971. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6972. {
  6973. installTranslator(base);
  6974. }
  6975. QTranslator*app= new QTranslator;
  6976. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  6977. {
  6978. installTranslator(app);
  6979. }
  6980. /*:578*/
  6981. #line 12610 "./typica.w"
  6982. /*295:*/
  6983. #line 123 "./measurement.w"
  6984. qRegisterMetaType<Measurement> ("Measurement");
  6985. /*:295*/
  6986. #line 12611 "./typica.w"
  6987. /*784:*/
  6988. #line 16625 "./typica.w"
  6989. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  6990. tr("NI DAQmx Base"),
  6991. "nidaqmxbase",NULL);
  6992. topLevelNodeInserters.append(inserter);
  6993. /*:784*//*792:*/
  6994. #line 16856 "./typica.w"
  6995. #ifdef Q_OS_WIN32
  6996. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  6997. topLevelNodeInserters.append(inserter);
  6998. #endif
  6999. /*:792*//*816:*/
  7000. #line 17823 "./typica.w"
  7001. #if 0
  7002. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7003. topLevelNodeInserters.append(inserter);
  7004. #endif
  7005. /*:816*//*865:*/
  7006. #line 19336 "./typica.w"
  7007. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7008. topLevelNodeInserters.append(inserter);
  7009. #line 1 "./modbus.w"
  7010. /*:865*//*871:*/
  7011. #line 324 "./modbus.w"
  7012. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7013. topLevelNodeInserters.append(inserter);
  7014. /*:871*//*887:*/
  7015. #line 272 "./unsupportedserial.w"
  7016. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7017. "unsupporteddevice",NULL);
  7018. topLevelNodeInserters.append(inserter);
  7019. /*:887*//*921:*/
  7020. #line 190 "./phidgets.w"
  7021. QLibrary phidgetsCheck("phidget21");
  7022. if(phidgetsCheck.load())
  7023. {
  7024. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7025. "phidgets1048",NULL);
  7026. topLevelNodeInserters.append(inserter);
  7027. phidgetsCheck.unload();
  7028. }
  7029. else
  7030. {
  7031. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7032. if(phidgetsCheck.load())
  7033. {
  7034. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7035. "phidgets1048",NULL);
  7036. topLevelNodeInserters.append(inserter);
  7037. phidgetsCheck.unload();
  7038. }
  7039. }
  7040. /*:921*//*1012:*/
  7041. #line 1241 "./dataqsdk.w"
  7042. #ifdef Q_OS_WIN32
  7043. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7044. "dataqsdk",NULL);
  7045. topLevelNodeInserters.append(inserter);
  7046. #endif
  7047. #line 19988 "./typica.w"
  7048. #line 1 "./scales.w"
  7049. /*:1012*//*1037:*/
  7050. #line 557 "./scales.w"
  7051. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7052. topLevelNodeInserters.append(inserter);
  7053. #line 19990 "./typica.w"
  7054. #line 1 "./valueannotation.w"
  7055. /*:1037*/
  7056. #line 12612 "./typica.w"
  7057. }
  7058. /*:576*//*580:*/
  7059. #line 12653 "./typica.w"
  7060. QDomDocument*Application::configuration()
  7061. {
  7062. return&conf;
  7063. }
  7064. /*:580*//*581:*/
  7065. #line 12662 "./typica.w"
  7066. QSqlDatabase Application::database()
  7067. {
  7068. QString connectionName;
  7069. QSqlDatabase connection=
  7070. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7071. do
  7072. {
  7073. connectionName= QUuid::createUuid().toString();
  7074. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7075. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7076. }
  7077. /*:581*//*719:*/
  7078. #line 15158 "./typica.w"
  7079. void Application::saveDeviceConfiguration()
  7080. {
  7081. QSettings settings;
  7082. settings.setValue("DeviceConfiguration",
  7083. QVariant(deviceConfigurationDocument.toByteArray()));
  7084. }
  7085. /*:719*//*720:*/
  7086. #line 15170 "./typica.w"
  7087. QDomDocument Application::deviceConfiguration()
  7088. {
  7089. if(deviceConfigurationDocument.isNull())
  7090. {
  7091. /*721:*/
  7092. #line 15184 "./typica.w"
  7093. QSettings settings;
  7094. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7095. QString etext;
  7096. int eline;
  7097. int ecol;
  7098. if(document.length()==0)
  7099. {
  7100. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7101. /*722:*/
  7102. #line 15208 "./typica.w"
  7103. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7104. emptyDocument.open(QIODevice::ReadOnly);
  7105. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7106. &etext,&eline,&ecol))
  7107. {
  7108. /*723:*/
  7109. #line 15225 "./typica.w"
  7110. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7111. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7112. qDebug()<<etext;
  7113. /*:723*/
  7114. #line 15214 "./typica.w"
  7115. }
  7116. else
  7117. {
  7118. saveDeviceConfiguration();
  7119. }
  7120. /*:722*/
  7121. #line 15193 "./typica.w"
  7122. }
  7123. else
  7124. {
  7125. if(!deviceConfigurationDocument.setContent(document,false,
  7126. &etext,&eline,&ecol))
  7127. {
  7128. /*723:*/
  7129. #line 15225 "./typica.w"
  7130. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7131. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7132. qDebug()<<etext;
  7133. /*:723*/
  7134. #line 15200 "./typica.w"
  7135. /*722:*/
  7136. #line 15208 "./typica.w"
  7137. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7138. emptyDocument.open(QIODevice::ReadOnly);
  7139. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7140. &etext,&eline,&ecol))
  7141. {
  7142. /*723:*/
  7143. #line 15225 "./typica.w"
  7144. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7145. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7146. qDebug()<<etext;
  7147. /*:723*/
  7148. #line 15214 "./typica.w"
  7149. }
  7150. else
  7151. {
  7152. saveDeviceConfiguration();
  7153. }
  7154. /*:722*/
  7155. #line 15201 "./typica.w"
  7156. }
  7157. }
  7158. /*:721*/
  7159. #line 15175 "./typica.w"
  7160. }
  7161. return deviceConfigurationDocument;
  7162. }
  7163. /*:720*//*751:*/
  7164. #line 15826 "./typica.w"
  7165. void Application::registerDeviceConfigurationWidget(QString driver,
  7166. QMetaObject widget)
  7167. {
  7168. deviceConfigurationWidgets.insert(driver,widget);
  7169. }
  7170. /*:751*//*752:*/
  7171. #line 15842 "./typica.w"
  7172. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7173. const QModelIndex&index)
  7174. {
  7175. QVariant nodeReference= index.data(Qt::UserRole);
  7176. QDomElement referenceElement= model->referenceElement(
  7177. model->data(index,Qt::UserRole).toString());
  7178. QMetaObject metaObject=
  7179. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7180. QWidget::staticMetaObject);
  7181. QWidget*editor;
  7182. if(metaObject.className()==QWidget::staticMetaObject.className())
  7183. {
  7184. editor= NULL;
  7185. }
  7186. else
  7187. {
  7188. editor= qobject_cast<QWidget*> (
  7189. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7190. Q_ARG(QModelIndex,index)));
  7191. }
  7192. return editor;
  7193. }
  7194. /*:752*/
  7195. #line 564 "./typica.w"
  7196. /*622:*/
  7197. #line 13492 "./typica.w"
  7198. SqlConnectionSetup::SqlConnectionSetup():
  7199. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7200. portnumber(new QLineEdit),
  7201. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7202. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7203. cancelButton(new QPushButton(tr("Cancel"))),
  7204. connectButton(new QPushButton(tr("Connect")))
  7205. {
  7206. driver->addItem("PostgreSQL","QPSQL");
  7207. formLayout->addRow(tr("Database driver:"),driver);
  7208. formLayout->addRow(tr("Host name:"),hostname);
  7209. formLayout->addRow(tr("Port number:"),portnumber);
  7210. portnumber->setText("5432");
  7211. formLayout->addRow(tr("Database name:"),dbname);
  7212. formLayout->addRow(tr("User name:"),user);
  7213. password->setEchoMode(QLineEdit::Password);
  7214. formLayout->addRow(tr("Password:"),password);
  7215. layout->addLayout(formLayout);
  7216. buttons->addStretch(1);
  7217. buttons->addWidget(cancelButton);
  7218. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7219. buttons->addWidget(connectButton);
  7220. layout->addLayout(buttons);
  7221. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7222. connectButton->setDefault(true);
  7223. setLayout(layout);
  7224. setModal(true);
  7225. }
  7226. SqlConnectionSetup::~SqlConnectionSetup()
  7227. {
  7228. }
  7229. /*:622*//*623:*/
  7230. #line 13530 "./typica.w"
  7231. void SqlConnectionSetup::testConnection()
  7232. {
  7233. QSqlDatabase database=
  7234. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7235. toString());
  7236. database.setConnectOptions("application_name=Typica");
  7237. database.setHostName(hostname->text());
  7238. database.setPort(portnumber->text().toInt());
  7239. database.setDatabaseName(dbname->text());
  7240. database.setUserName(user->text());
  7241. database.setPassword(password->text());
  7242. if(database.open())
  7243. {
  7244. QSettings settings;
  7245. settings.setValue("database/exists","true");
  7246. settings.setValue("database/driver",
  7247. driver->itemData(driver->currentIndex()).toString());
  7248. settings.setValue("database/hostname",hostname->text());
  7249. settings.setValue("database/portnumber",portnumber->text());
  7250. settings.setValue("database/dbname",dbname->text());
  7251. settings.setValue("database/user",user->text());
  7252. settings.setValue("database/password",password->text());
  7253. database.close();
  7254. accept();
  7255. }
  7256. else
  7257. {
  7258. QMessageBox::information(this,tr("Database connection failed"),
  7259. tr("Failed to connect to database."));
  7260. }
  7261. }
  7262. /*:623*/
  7263. #line 565 "./typica.w"
  7264. /*627:*/
  7265. #line 13635 "./typica.w"
  7266. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7267. {
  7268. setModel(new QSqlQueryModel);
  7269. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7270. this,SLOT(openRow(QModelIndex)));
  7271. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7272. this,SLOT(persistColumnResize(int,int,int)));
  7273. }
  7274. /*:627*//*628:*/
  7275. #line 13650 "./typica.w"
  7276. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7277. {
  7278. /*629:*/
  7279. #line 13659 "./typica.w"
  7280. QSettings settings;
  7281. /*630:*/
  7282. #line 13672 "./typica.w"
  7283. QWidget*topLevelWidget= this;
  7284. while(topLevelWidget->parentWidget())
  7285. {
  7286. topLevelWidget= topLevelWidget->parentWidget();
  7287. }
  7288. /*:630*/
  7289. #line 13661 "./typica.w"
  7290. settings.setValue(QString("columnWidths/%1/%2/%3").
  7291. arg(topLevelWidget->objectName()).
  7292. arg(objectName()).arg(column),
  7293. QVariant(newsize));
  7294. /*:629*/
  7295. #line 13653 "./typica.w"
  7296. }
  7297. /*:628*//*631:*/
  7298. #line 13682 "./typica.w"
  7299. void SqlQueryView::showEvent(QShowEvent*event)
  7300. {
  7301. /*632:*/
  7302. #line 13692 "./typica.w"
  7303. QSettings settings;
  7304. /*630:*/
  7305. #line 13672 "./typica.w"
  7306. QWidget*topLevelWidget= this;
  7307. while(topLevelWidget->parentWidget())
  7308. {
  7309. topLevelWidget= topLevelWidget->parentWidget();
  7310. }
  7311. /*:630*/
  7312. #line 13694 "./typica.w"
  7313. QString baseKey=
  7314. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7315. arg(objectName());
  7316. for(int i= 0;i<model()->columnCount();i++)
  7317. {
  7318. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7319. if(settings.contains(key))
  7320. {
  7321. setColumnWidth(i,settings.value(key).toInt());
  7322. }
  7323. }
  7324. /*:632*/
  7325. #line 13685 "./typica.w"
  7326. event->accept();
  7327. }
  7328. /*:631*//*633:*/
  7329. #line 13709 "./typica.w"
  7330. void SqlQueryView::openRow(const QModelIndex&index)
  7331. {
  7332. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7333. emit openEntryRow(index.row());
  7334. }
  7335. /*:633*//*634:*/
  7336. #line 13718 "./typica.w"
  7337. void SqlQueryView::setQuery(const QString&query)
  7338. {
  7339. QSqlDatabase database= AppInstance->database();
  7340. database.open();
  7341. QSqlQuery q(query,database);
  7342. ((QSqlQueryModel*)model())->setQuery(q);
  7343. database.close();
  7344. }
  7345. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7346. const QVariant&value,int role)
  7347. {
  7348. return model()->setHeaderData(section,orientation,value,role);
  7349. }
  7350. /*:634*//*635:*/
  7351. #line 13736 "./typica.w"
  7352. QVariant SqlQueryView::data(int row,int column,int role)
  7353. {
  7354. return model()->data(model()->index(row,column),role);
  7355. }
  7356. /*:635*/
  7357. #line 566 "./typica.w"
  7358. /*170:*/
  7359. #line 3939 "./typica.w"
  7360. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7361. {
  7362. QSqlDatabase database= AppInstance->database();
  7363. database.open();
  7364. q= new QSqlQuery(query,database);
  7365. connection= database.connectionName();
  7366. }
  7367. /*:170*//*171:*/
  7368. #line 3952 "./typica.w"
  7369. SqlQueryConnection::~SqlQueryConnection()
  7370. {
  7371. delete q;
  7372. {
  7373. QSqlDatabase database= QSqlDatabase::database(connection);
  7374. database.close();
  7375. }
  7376. QSqlDatabase::removeDatabase(connection);
  7377. }
  7378. /*:171*//*172:*/
  7379. #line 3966 "./typica.w"
  7380. QSqlQuery*SqlQueryConnection::operator->()const
  7381. {
  7382. return q;
  7383. }
  7384. /*:172*/
  7385. #line 567 "./typica.w"
  7386. /*654:*/
  7387. #line 14095 "./typica.w"
  7388. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7389. area(frame),configuration(description)
  7390. {
  7391. refresh();
  7392. }
  7393. ReportTable::~ReportTable()
  7394. {
  7395. }
  7396. /*:654*//*655:*/
  7397. #line 14111 "./typica.w"
  7398. void ReportTable::bind(QString placeholder,QVariant value)
  7399. {
  7400. bindings.insert(placeholder,value);
  7401. }
  7402. /*:655*//*656:*/
  7403. #line 14121 "./typica.w"
  7404. void ReportTable::refresh()
  7405. {
  7406. /*657:*/
  7407. #line 14142 "./typica.w"
  7408. QTextCursor cursor= area->firstCursorPosition();
  7409. while(cursor<area->lastCursorPosition())
  7410. {
  7411. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7412. }
  7413. cursor.removeSelectedText();
  7414. /*:657*/
  7415. #line 14124 "./typica.w"
  7416. int rows= 1;
  7417. int columns= 1;
  7418. int currentRow= 0;
  7419. QTextTable*table= cursor.insertTable(rows,columns);
  7420. /*658:*/
  7421. #line 14155 "./typica.w"
  7422. QTextTableFormat format= table->format();
  7423. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7424. if(configuration.hasAttribute("align"))
  7425. {
  7426. if(configuration.attribute("align")=="center")
  7427. {
  7428. format.setAlignment(Qt::AlignHCenter);
  7429. }
  7430. }
  7431. table->setFormat(format);
  7432. /*:658*/
  7433. #line 14129 "./typica.w"
  7434. /*659:*/
  7435. #line 14169 "./typica.w"
  7436. QDomNodeList children= configuration.childNodes();
  7437. for(int i= 0;i<children.count();i++)
  7438. {
  7439. QDomNode current;
  7440. QDomElement currentElement;
  7441. current= children.at(i);
  7442. if(current.isElement())
  7443. {
  7444. currentElement= current.toElement();
  7445. if(currentElement.tagName()=="query")
  7446. {
  7447. /*660:*/
  7448. #line 14196 "./typica.w"
  7449. SqlQueryConnection h;
  7450. QSqlQuery*query= h.operator->();
  7451. query->prepare(currentElement.text());
  7452. foreach(QString key,bindings.uniqueKeys())
  7453. {
  7454. if(currentElement.text().contains(key))
  7455. {
  7456. query->bindValue(key,bindings.value(key));
  7457. }
  7458. }
  7459. query->exec();
  7460. if(!query->next())
  7461. {
  7462. continue;
  7463. }
  7464. if(query->record().count()> columns)
  7465. {
  7466. table->appendColumns(query->record().count()-columns);
  7467. }
  7468. do
  7469. {
  7470. table->appendRows(1);
  7471. rows++;
  7472. currentRow++;
  7473. for(int j= 0;j<query->record().count();j++)
  7474. {
  7475. QTextTableCell cell= table->cellAt(currentRow,j);
  7476. cursor= cell.firstCursorPosition();
  7477. cursor.insertText(query->value(j).toString());
  7478. }
  7479. }while(query->next());
  7480. /*:660*/
  7481. #line 14181 "./typica.w"
  7482. }
  7483. else if(currentElement.tagName()=="row")
  7484. {
  7485. /*661:*/
  7486. #line 14236 "./typica.w"
  7487. table->appendRows(1);
  7488. currentRow++;
  7489. rows++;
  7490. QDomNodeList rowChildren= currentElement.childNodes();
  7491. int currentColumn= 0;
  7492. for(int j= 0;j<rowChildren.count();j++)
  7493. {
  7494. QDomNode node;
  7495. QDomElement nodeElement;
  7496. node= rowChildren.at(j);
  7497. if(node.isElement())
  7498. {
  7499. nodeElement= node.toElement();
  7500. if(nodeElement.tagName()=="cell")
  7501. {
  7502. if(currentColumn==columns)
  7503. {
  7504. table->appendColumns(1);
  7505. columns++;
  7506. }
  7507. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7508. cursor= cell.firstCursorPosition();
  7509. cursor.insertText(nodeElement.text());
  7510. currentColumn++;
  7511. }
  7512. }
  7513. }
  7514. /*:661*/
  7515. #line 14185 "./typica.w"
  7516. }
  7517. }
  7518. }
  7519. /*:659*/
  7520. #line 14130 "./typica.w"
  7521. if(rows> 1)
  7522. {
  7523. table->removeRows(0,1);
  7524. }
  7525. }
  7526. /*:656*/
  7527. #line 568 "./typica.w"
  7528. /*687:*/
  7529. #line 14340 "./typica.w"
  7530. FormArray::FormArray(QDomElement description):configuration(description),
  7531. maxwidth(-1),maxheight(-1)
  7532. {
  7533. setWidget(&itemContainer);
  7534. itemContainer.setLayout(&itemLayout);
  7535. }
  7536. /*:687*//*688:*/
  7537. #line 14357 "./typica.w"
  7538. void FormArray::addElements(int copies)
  7539. {
  7540. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7541. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7542. QWidget*widget;
  7543. for(int i= 0;i<copies;i++)
  7544. {
  7545. widget= new QWidget;
  7546. if(maxwidth> -1)
  7547. {
  7548. widget->setMaximumWidth(maxwidth);
  7549. }
  7550. if(maxheight> -1)
  7551. {
  7552. widget->setMaximumHeight(maxheight);
  7553. }
  7554. if(configuration.hasChildNodes())
  7555. {
  7556. widgetStack->push(widget);
  7557. populateWidget(configuration,widgetStack,layoutStack);
  7558. widgetStack->pop();
  7559. widget->setMinimumHeight(widget->sizeHint().height());
  7560. itemLayout.addWidget(widget);
  7561. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  7562. {
  7563. itemContainer.setMinimumHeight(maxheight*elements()+50);
  7564. }
  7565. else
  7566. {
  7567. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  7568. +widget->sizeHint().height());
  7569. }
  7570. if(maxwidth> -1)
  7571. {
  7572. itemContainer.setMinimumWidth(maxwidth+50);
  7573. }
  7574. else
  7575. {
  7576. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  7577. }
  7578. }
  7579. }
  7580. }
  7581. /*:688*//*689:*/
  7582. #line 14407 "./typica.w"
  7583. QWidget*FormArray::elementAt(int index)
  7584. {
  7585. if(index<itemLayout.count())
  7586. {
  7587. QLayoutItem*item= itemLayout.itemAt(index);
  7588. return item->widget();
  7589. }
  7590. else
  7591. {
  7592. return NULL;
  7593. }
  7594. }
  7595. /*:689*//*690:*/
  7596. #line 14424 "./typica.w"
  7597. void FormArray::removeAllElements()
  7598. {
  7599. while(itemLayout.count()> 0)
  7600. {
  7601. QLayoutItem*item;
  7602. item= itemLayout.itemAt(0);
  7603. item->widget()->hide();
  7604. itemLayout.removeWidget(item->widget());
  7605. }
  7606. itemContainer.setMinimumHeight(0);
  7607. }
  7608. /*:690*//*691:*/
  7609. #line 14440 "./typica.w"
  7610. int FormArray::elements()
  7611. {
  7612. return itemLayout.count();
  7613. }
  7614. /*:691*//*692:*/
  7615. #line 14451 "./typica.w"
  7616. void FormArray::setMaximumElementWidth(int width)
  7617. {
  7618. maxwidth= width;
  7619. }
  7620. void FormArray::setMaximumElementHeight(int height)
  7621. {
  7622. maxheight= height;
  7623. }
  7624. /*:692*/
  7625. #line 569 "./typica.w"
  7626. /*698:*/
  7627. #line 14582 "./typica.w"
  7628. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  7629. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  7630. {
  7631. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  7632. QPointF(0,5);
  7633. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  7634. QPointF(10,5);
  7635. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  7636. QPointF(0,0);
  7637. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  7638. initialBrush.setColor(QColor(170,170,255));
  7639. initialBrush.setStyle(Qt::SolidPattern);
  7640. finalBrush.setColor(Qt::blue);
  7641. finalBrush.setStyle(Qt::SolidPattern);
  7642. initialDecrement.setPolygon(left);
  7643. initialDecrement.setBrush(initialBrush);
  7644. initialDecrement.setPos(0,0);
  7645. scene.addItem(&initialDecrement);
  7646. initialIncrement.setPolygon(right);
  7647. initialIncrement.setBrush(initialBrush);
  7648. initialIncrement.setPos(122,0);
  7649. scene.addItem(&initialIncrement);
  7650. finalDecrement.setPolygon(left);
  7651. finalDecrement.setBrush(finalBrush);
  7652. finalDecrement.setPos(0,12);
  7653. scene.addItem(&finalDecrement);
  7654. finalIncrement.setPolygon(right);
  7655. finalIncrement.setBrush(finalBrush);
  7656. finalIncrement.setPos(122,12);
  7657. scene.addItem(&finalIncrement);
  7658. scalePath.moveTo(0,10);
  7659. scalePath.lineTo(100,10);
  7660. scalePath.moveTo(0,0);
  7661. scalePath.lineTo(0,20);
  7662. scalePath.moveTo(10,5);
  7663. scalePath.lineTo(10,15);
  7664. scalePath.moveTo(20,5);
  7665. scalePath.lineTo(20,15);
  7666. scalePath.moveTo(30,5);
  7667. scalePath.lineTo(30,15);
  7668. scalePath.moveTo(40,5);
  7669. scalePath.lineTo(40,15);
  7670. scalePath.moveTo(50,0);
  7671. scalePath.lineTo(50,20);
  7672. scalePath.moveTo(60,5);
  7673. scalePath.lineTo(60,15);
  7674. scalePath.moveTo(70,5);
  7675. scalePath.lineTo(70,15);
  7676. scalePath.moveTo(80,5);
  7677. scalePath.lineTo(80,15);
  7678. scalePath.moveTo(90,5);
  7679. scalePath.lineTo(90,15);
  7680. scalePath.moveTo(100,0);
  7681. scalePath.lineTo(100,20);
  7682. scaleLine.setPath(scalePath);
  7683. scaleLine.setPos(16,1);
  7684. scene.addItem(&scaleLine);
  7685. setScene(&scene);
  7686. initialIndicator.setPolygon(down);
  7687. initialIndicator.setBrush(initialBrush);
  7688. finalIndicator.setPolygon(up);
  7689. finalIndicator.setBrush(finalBrush);
  7690. setMinimumSize(sizeHint());
  7691. setMaximumSize(sizeHint());
  7692. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7693. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7694. setMinimumSize(sizeHint());
  7695. }
  7696. /*:698*//*699:*/
  7697. #line 14655 "./typica.w"
  7698. QSize ScaleControl::sizeHint()const
  7699. {
  7700. return QSize(140,30);
  7701. }
  7702. /*:699*//*700:*/
  7703. #line 14664 "./typica.w"
  7704. void ScaleControl::setInitialValue(double value)
  7705. {
  7706. if(value>=0&&value<=10)
  7707. {
  7708. nonScoredValue= value;
  7709. if(!initialSet)
  7710. {
  7711. scene.addItem(&initialIndicator);
  7712. }
  7713. initialSet= true;
  7714. initialIndicator.setPos(value*10+16,10);
  7715. emit initialChanged(value);
  7716. if(!finalSet)
  7717. {
  7718. setFinalValue(value);
  7719. }
  7720. }
  7721. }
  7722. void ScaleControl::setFinalValue(double value)
  7723. {
  7724. if(value>=0&&value<=10)
  7725. {
  7726. scoredValue= value;
  7727. if(!finalSet)
  7728. {
  7729. scene.addItem(&finalIndicator);
  7730. }
  7731. finalSet= true;
  7732. finalIndicator.setPos(value*10+16,11);
  7733. emit finalChanged(value);
  7734. }
  7735. }
  7736. /*:700*//*701:*/
  7737. #line 14701 "./typica.w"
  7738. double ScaleControl::initialValue(void)
  7739. {
  7740. return nonScoredValue;
  7741. }
  7742. double ScaleControl::finalValue(void)
  7743. {
  7744. return scoredValue;
  7745. }
  7746. /*:701*//*702:*/
  7747. #line 14722 "./typica.w"
  7748. void ScaleControl::mousePressEvent(QMouseEvent*event)
  7749. {
  7750. /*703:*/
  7751. #line 14734 "./typica.w"
  7752. if(event->button()!=Qt::LeftButton)
  7753. {
  7754. event->ignore();
  7755. return;
  7756. }
  7757. /*:703*/
  7758. #line 14725 "./typica.w"
  7759. scaleDown= true;
  7760. event->accept();
  7761. }
  7762. /*:702*//*704:*/
  7763. #line 14745 "./typica.w"
  7764. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  7765. {
  7766. /*703:*/
  7767. #line 14734 "./typica.w"
  7768. if(event->button()!=Qt::LeftButton)
  7769. {
  7770. event->ignore();
  7771. return;
  7772. }
  7773. /*:703*/
  7774. #line 14748 "./typica.w"
  7775. if(!scaleDown)
  7776. {
  7777. event->ignore();
  7778. return;
  7779. }
  7780. scaleDown= false;
  7781. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7782. /*705:*/
  7783. #line 14770 "./typica.w"
  7784. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  7785. {
  7786. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7787. {
  7788. if(initialSet)
  7789. {
  7790. setInitialValue(nonScoredValue-0.05);
  7791. }
  7792. event->accept();
  7793. return;
  7794. }
  7795. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7796. {
  7797. if(finalSet)
  7798. {
  7799. setFinalValue(scoredValue-0.05);
  7800. event->accept();
  7801. return;
  7802. }
  7803. }
  7804. }
  7805. /*:705*/
  7806. #line 14756 "./typica.w"
  7807. /*706:*/
  7808. #line 14796 "./typica.w"
  7809. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  7810. {
  7811. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7812. {
  7813. if(initialSet)
  7814. {
  7815. setInitialValue(nonScoredValue+0.05);
  7816. event->accept();
  7817. return;
  7818. }
  7819. }
  7820. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  7821. {
  7822. if(finalSet)
  7823. {
  7824. setFinalValue(scoredValue+0.05);
  7825. event->accept();
  7826. return;
  7827. }
  7828. }
  7829. }
  7830. /*:706*/
  7831. #line 14757 "./typica.w"
  7832. /*707:*/
  7833. #line 14822 "./typica.w"
  7834. double relativeX= sceneCoordinate.x()-16;
  7835. if(initialSet)
  7836. {
  7837. if(relativeX>=0&&relativeX<=100)
  7838. {
  7839. setFinalValue(relativeX/10.0);
  7840. event->accept();
  7841. return;
  7842. }
  7843. }
  7844. else
  7845. {
  7846. if(relativeX>=0&&relativeX<=100)
  7847. {
  7848. setInitialValue(relativeX/10.0);
  7849. event->accept();
  7850. return;
  7851. }
  7852. }
  7853. /*:707*/
  7854. #line 14758 "./typica.w"
  7855. event->ignore();
  7856. return;
  7857. }
  7858. /*:704*/
  7859. #line 570 "./typica.w"
  7860. /*709:*/
  7861. #line 14888 "./typica.w"
  7862. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  7863. valueSet(false),scaleDown(false)
  7864. {
  7865. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7866. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  7867. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  7868. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  7869. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  7870. theBrush.setColor(Qt::blue);
  7871. theBrush.setStyle(Qt::SolidPattern);
  7872. increment.setPolygon(up);
  7873. increment.setBrush(theBrush);
  7874. increment.setPos(0,0);
  7875. scene.addItem(&increment);
  7876. decrement.setPolygon(down);
  7877. decrement.setBrush(theBrush);
  7878. decrement.setPos(0,122);
  7879. scene.addItem(&decrement);
  7880. scalePath.moveTo(5,0);
  7881. scalePath.lineTo(5,100);
  7882. scalePath.moveTo(0,0);
  7883. scalePath.lineTo(10,0);
  7884. scalePath.moveTo(0,10);
  7885. scalePath.lineTo(10,10);
  7886. scalePath.moveTo(0,20);
  7887. scalePath.lineTo(10,20);
  7888. scalePath.moveTo(0,30);
  7889. scalePath.lineTo(10,30);
  7890. scalePath.moveTo(0,40);
  7891. scalePath.lineTo(10,40);
  7892. scalePath.moveTo(0,50);
  7893. scalePath.lineTo(10,50);
  7894. scalePath.moveTo(0,60);
  7895. scalePath.lineTo(10,60);
  7896. scalePath.moveTo(0,70);
  7897. scalePath.lineTo(10,70);
  7898. scalePath.moveTo(0,80);
  7899. scalePath.lineTo(10,80);
  7900. scalePath.moveTo(0,90);
  7901. scalePath.lineTo(10,90);
  7902. scalePath.moveTo(0,100);
  7903. scalePath.lineTo(10,100);
  7904. scaleLine.setPath(scalePath);
  7905. scaleLine.setPos(0,16);
  7906. scene.addItem(&scaleLine);
  7907. setScene(&scene);
  7908. indicator.setPolygon(left);
  7909. indicator.setBrush(theBrush);
  7910. setMinimumSize(sizeHint());
  7911. setMaximumSize(sizeHint());
  7912. }
  7913. /*:709*//*710:*/
  7914. #line 14943 "./typica.w"
  7915. QSize IntensityControl::sizeHint()const
  7916. {
  7917. return QSize(25,160);
  7918. }
  7919. /*:710*//*711:*/
  7920. #line 14958 "./typica.w"
  7921. void IntensityControl::setValue(double val)
  7922. {
  7923. if(val>=0&&val<=10)
  7924. {
  7925. theValue= val;
  7926. if(!valueSet)
  7927. {
  7928. scene.addItem(&indicator);
  7929. }
  7930. valueSet= true;
  7931. indicator.setPos(6,(100-(val*10))+16);
  7932. emit(valueChanged(val));
  7933. }
  7934. else if(val<1)
  7935. {
  7936. setValue(0);
  7937. }
  7938. else
  7939. {
  7940. setValue(10);
  7941. }
  7942. }
  7943. double IntensityControl::value()
  7944. {
  7945. return theValue;
  7946. }
  7947. /*:711*//*712:*/
  7948. #line 14990 "./typica.w"
  7949. void IntensityControl::mousePressEvent(QMouseEvent*event)
  7950. {
  7951. /*703:*/
  7952. #line 14734 "./typica.w"
  7953. if(event->button()!=Qt::LeftButton)
  7954. {
  7955. event->ignore();
  7956. return;
  7957. }
  7958. /*:703*/
  7959. #line 14993 "./typica.w"
  7960. scaleDown= true;
  7961. event->accept();
  7962. }
  7963. /*:712*//*713:*/
  7964. #line 15004 "./typica.w"
  7965. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  7966. {
  7967. /*703:*/
  7968. #line 14734 "./typica.w"
  7969. if(event->button()!=Qt::LeftButton)
  7970. {
  7971. event->ignore();
  7972. return;
  7973. }
  7974. /*:703*/
  7975. #line 15007 "./typica.w"
  7976. if(!scaleDown)
  7977. {
  7978. event->ignore();
  7979. return;
  7980. }
  7981. scaleDown= false;
  7982. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  7983. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  7984. {
  7985. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  7986. {
  7987. if(valueSet)
  7988. {
  7989. setValue(theValue+0.05);
  7990. }
  7991. event->accept();
  7992. return;
  7993. }
  7994. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  7995. {
  7996. if(valueSet)
  7997. {
  7998. setValue(theValue-0.05);
  7999. }
  8000. event->accept();
  8001. return;
  8002. }
  8003. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8004. {
  8005. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8006. event->accept();
  8007. return;
  8008. }
  8009. }
  8010. }
  8011. /*:713*/
  8012. #line 571 "./typica.w"
  8013. /*364:*/
  8014. #line 8233 "./typica.w"
  8015. void ThresholdDetector::newMeasurement(Measurement measure)
  8016. {
  8017. if((currentDirection==Ascending&&previousValue<threshold&&
  8018. previousValue>=0)||(currentDirection==Descending&&
  8019. previousValue> threshold&&previousValue>=0))
  8020. {
  8021. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8022. (currentDirection==Descending&&measure.temperature()<=threshold))
  8023. {
  8024. double offset= measure.time().hour()*60*60;
  8025. offset+= measure.time().minute()*60;
  8026. offset+= measure.time().second();
  8027. offset+= measure.time().msec()/1000;
  8028. emit timeForValue(offset);
  8029. }
  8030. }
  8031. previousValue= measure.temperature();
  8032. }
  8033. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8034. previousValue(-1),threshold(value),currentDirection(Ascending)
  8035. {
  8036. }
  8037. void ThresholdDetector::setThreshold(double value)
  8038. {
  8039. threshold= value;
  8040. }
  8041. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8042. {
  8043. currentDirection= direction;
  8044. }
  8045. /*:364*/
  8046. #line 572 "./typica.w"
  8047. /*795:*/
  8048. #line 16896 "./typica.w"
  8049. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8050. lister(new QextSerialEnumerator)
  8051. {
  8052. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8053. QextPortInfo port;
  8054. foreach(port,ports)
  8055. {
  8056. #ifdef Q_OS_WIN32
  8057. addItem(port.portName);
  8058. #else
  8059. addItem(port.physName);
  8060. #endif
  8061. }
  8062. lister->setUpNotifications();
  8063. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8064. this,SLOT(addDevice(QextPortInfo)));
  8065. setEditable(true);
  8066. }
  8067. void PortSelector::addDevice(QextPortInfo port)
  8068. {
  8069. addItem(port.portName);
  8070. }
  8071. /*:795*/
  8072. #line 573 "./typica.w"
  8073. /*797:*/
  8074. #line 16988 "./typica.w"
  8075. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8076. {
  8077. QMetaObject meta= BaudSelector::staticMetaObject;
  8078. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8079. for(int i= 0;i<type.keyCount();i++)
  8080. {
  8081. addItem(QString("%1").arg(type.value(i)));
  8082. }
  8083. }
  8084. /*:797*/
  8085. #line 574 "./typica.w"
  8086. /*799:*/
  8087. #line 17026 "./typica.w"
  8088. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8089. {
  8090. QMetaObject meta= ParitySelector::staticMetaObject;
  8091. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8092. for(int i= 0;i<type.keyCount();i++)
  8093. {
  8094. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8095. }
  8096. }
  8097. /*:799*/
  8098. #line 575 "./typica.w"
  8099. /*801:*/
  8100. #line 17056 "./typica.w"
  8101. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8102. {
  8103. QMetaObject meta= FlowSelector::staticMetaObject;
  8104. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8105. for(int i= 0;i<type.keyCount();i++)
  8106. {
  8107. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8108. }
  8109. }
  8110. /*:801*/
  8111. #line 576 "./typica.w"
  8112. /*803:*/
  8113. #line 17091 "./typica.w"
  8114. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8115. {
  8116. QMetaObject meta= StopSelector::staticMetaObject;
  8117. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8118. for(int i= 0;i<type.keyCount();i++)
  8119. {
  8120. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8121. }
  8122. }
  8123. /*:803*/
  8124. #line 577 "./typica.w"
  8125. /*863:*/
  8126. #line 18877 "./typica.w"
  8127. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8128. :BasicDeviceConfigurationWidget(model,index),
  8129. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8130. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8131. decimalQuery(new QCheckBox(tr("Enable"))),
  8132. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8133. unitQuery(new QCheckBox(tr("Enable"))),
  8134. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8135. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8136. pVAddress(new ShortHexSpinBox),
  8137. sVEnabled(new QCheckBox(tr("Enable"))),
  8138. sVReadAddress(new ShortHexSpinBox),
  8139. deviceLimit(new QCheckBox(tr("Enable"))),
  8140. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8141. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8142. sVWritable(new QCheckBox(tr("Enable"))),
  8143. sVOutputAddr(new ShortHexSpinBox),
  8144. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8145. {
  8146. QHBoxLayout*layout= new QHBoxLayout;
  8147. QWidget*form= new QWidget;
  8148. QHBoxLayout*masterLayout= new QHBoxLayout;
  8149. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8150. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8151. QFormLayout*serialSection= new QFormLayout;
  8152. serialSection->addRow(QString(tr("Port:")),port);
  8153. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8154. serialSection->addRow(QString(tr("Parity:")),parity);
  8155. serialSection->addRow(QString(tr("Flow control:")),flow);
  8156. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8157. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8158. serialSectionBox->setLayout(serialSection);
  8159. portAndDeviceLayout->addWidget(serialSectionBox);
  8160. QFormLayout*deviceSection= new QFormLayout;
  8161. station->setMinimum(1);
  8162. station->setMaximum(255);
  8163. decimalPosition->setMinimum(0);
  8164. decimalPosition->setMaximum(9);
  8165. valueF->setMinimum(0);
  8166. valueF->setMaximum(0xFFFF);
  8167. valueC->setMinimum(0);
  8168. valueC->setMaximum(0xFFFF);
  8169. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8170. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8171. deviceSection->addRow(tr("Station:"),station);
  8172. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8173. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8174. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8175. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8176. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8177. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8178. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8179. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8180. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8181. deviceSectionBox->setLayout(deviceSection);
  8182. portAndDeviceLayout->addWidget(deviceSectionBox);
  8183. QFormLayout*pVSection= new QFormLayout;
  8184. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8185. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8186. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8187. pVSection->addRow(pVHideBox);
  8188. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8189. processValueBox->setLayout(pVSection);
  8190. seriesLayout->addWidget(processValueBox);
  8191. QFormLayout*sVSection= new QFormLayout;
  8192. sVLower->setDecimals(1);
  8193. sVLower->setMinimum(0.0);
  8194. sVLower->setMaximum(999.9);
  8195. sVUpper->setDecimals(1);
  8196. sVUpper->setMinimum(0.0);
  8197. sVUpper->setMaximum(999.9);
  8198. sVSection->addRow(tr("Set value:"),sVEnabled);
  8199. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8200. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8201. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8202. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8203. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8204. sVSection->addRow(tr("Lower limit:"),sVLower);
  8205. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8206. sVSection->addRow(tr("Output set value:"),sVWritable);
  8207. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8208. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8209. sVSection->addRow(sVHideBox);
  8210. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8211. setValueBox->setLayout(sVSection);
  8212. seriesLayout->addWidget(setValueBox);
  8213. masterLayout->addLayout(portAndDeviceLayout);
  8214. masterLayout->addLayout(seriesLayout);
  8215. form->setLayout(masterLayout);
  8216. /*771:*/
  8217. #line 16337 "./typica.w"
  8218. QDomElement referenceElement=
  8219. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8220. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8221. QDomElement node;
  8222. /*:771*/
  8223. #line 18967 "./typica.w"
  8224. for(int i= 0;i<configData.size();i++)
  8225. {
  8226. node= configData.at(i).toElement();
  8227. if(node.attribute("name")=="port")
  8228. {
  8229. QString portname= node.attribute("value");
  8230. int idx= port->findText(portname);
  8231. if(idx>=0)
  8232. {
  8233. port->setCurrentIndex(idx);
  8234. }
  8235. else
  8236. {
  8237. port->addItem(portname);
  8238. }
  8239. }
  8240. else if(node.attribute("name")=="baud")
  8241. {
  8242. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8243. }
  8244. else if(node.attribute("name")=="parity")
  8245. {
  8246. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8247. }
  8248. else if(node.attribute("name")=="flow")
  8249. {
  8250. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8251. }
  8252. else if(node.attribute("name")=="stop")
  8253. {
  8254. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8255. }
  8256. else if(node.attribute("name")=="station")
  8257. {
  8258. station->setValue(node.attribute("value").toInt());
  8259. }
  8260. else if(node.attribute("name")=="decimalQuery")
  8261. {
  8262. if(node.attribute("value")=="true")
  8263. {
  8264. decimalQuery->setChecked(true);
  8265. }
  8266. else
  8267. {
  8268. decimalQuery->setChecked(false);
  8269. }
  8270. }
  8271. else if(node.attribute("name")=="decimalAddress")
  8272. {
  8273. decimalAddress->setValue(node.attribute("value").toInt());
  8274. }
  8275. else if(node.attribute("name")=="decimalPosition")
  8276. {
  8277. decimalPosition->setValue(node.attribute("value").toInt());
  8278. }
  8279. else if(node.attribute("name")=="unitQuery")
  8280. {
  8281. if(node.attribute("value")=="true")
  8282. {
  8283. unitQuery->setChecked(true);
  8284. }
  8285. else
  8286. {
  8287. unitQuery->setChecked(false);
  8288. }
  8289. }
  8290. else if(node.attribute("name")=="unitAddress")
  8291. {
  8292. unitAddress->setValue(node.attribute("value").toInt());
  8293. }
  8294. else if(node.attribute("name")=="valueF")
  8295. {
  8296. valueF->setValue(node.attribute("value").toInt());
  8297. }
  8298. else if(node.attribute("name")=="valueC")
  8299. {
  8300. valueC->setValue(node.attribute("value").toInt());
  8301. }
  8302. else if(node.attribute("name")=="fixedUnit")
  8303. {
  8304. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8305. }
  8306. else if(node.attribute("name")=="pVAddress")
  8307. {
  8308. pVAddress->setValue(node.attribute("value").toInt());
  8309. }
  8310. else if(node.attribute("name")=="sVEnabled")
  8311. {
  8312. if(node.attribute("value")=="true")
  8313. {
  8314. sVEnabled->setChecked(true);
  8315. }
  8316. else
  8317. {
  8318. sVEnabled->setChecked(false);
  8319. }
  8320. }
  8321. else if(node.attribute("name")=="sVReadAddress")
  8322. {
  8323. sVReadAddress->setValue(node.attribute("value").toInt());
  8324. }
  8325. else if(node.attribute("name")=="deviceLimit")
  8326. {
  8327. if(node.attribute("value")=="true")
  8328. {
  8329. deviceLimit->setChecked(true);
  8330. }
  8331. else
  8332. {
  8333. deviceLimit->setChecked(false);
  8334. }
  8335. }
  8336. else if(node.attribute("name")=="sVLowerAddr")
  8337. {
  8338. sVLowerAddr->setValue(node.attribute("value").toInt());
  8339. }
  8340. else if(node.attribute("name")=="sVUpperAddr")
  8341. {
  8342. sVUpperAddr->setValue(node.attribute("value").toInt());
  8343. }
  8344. else if(node.attribute("name")=="sVLower")
  8345. {
  8346. sVLower->setValue(node.attribute("value").toDouble());
  8347. }
  8348. else if(node.attribute("name")=="sVUpper")
  8349. {
  8350. sVUpper->setValue(node.attribute("value").toDouble());
  8351. }
  8352. else if(node.attribute("name")=="sVWritable")
  8353. {
  8354. if(node.attribute("value")=="true")
  8355. {
  8356. sVWritable->setChecked(true);
  8357. }
  8358. else
  8359. {
  8360. sVWritable->setChecked(false);
  8361. }
  8362. }
  8363. else if(node.attribute("name")=="sVOutputAddr")
  8364. {
  8365. sVOutputAddr->setValue(node.attribute("value").toInt());
  8366. }
  8367. else if(node.attribute("name")=="pvcolname")
  8368. {
  8369. pVColumnName->setText(node.attribute("value"));
  8370. }
  8371. else if(node.attribute("name")=="svcolname")
  8372. {
  8373. sVColumnName->setText(node.attribute("value"));
  8374. }
  8375. else if(node.attribute("name")=="pvhidden")
  8376. {
  8377. pVHideBox->setChecked(node.attribute("value")=="true");
  8378. }
  8379. else if(node.attribute("name")=="svhidden")
  8380. {
  8381. sVHideBox->setChecked(node.attribute("value")=="true");
  8382. }
  8383. }
  8384. updatePort(port->currentText());
  8385. updateBaudRate(baud->currentText());
  8386. updateParity(parity->itemData(parity->currentIndex()).toString());
  8387. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8388. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8389. updateStation(station->value());
  8390. updateFixedDecimal(decimalQuery->isChecked());
  8391. updateDecimalAddress(decimalAddress->value());
  8392. updateDecimalPosition(decimalPosition->value());
  8393. updateFixedUnit(unitQuery->isChecked());
  8394. updateUnitAddress(unitAddress->value());
  8395. updateValueForF(valueF->value());
  8396. updateValueForC(valueC->value());
  8397. updateUnit(fixedUnit->currentText());
  8398. updatePVAddress(pVAddress->value());
  8399. updateSVEnabled(sVEnabled->isChecked());
  8400. updateSVReadAddress(sVReadAddress->value());
  8401. updateDeviceLimit(deviceLimit->isChecked());
  8402. updateSVLowerAddress(sVLowerAddr->value());
  8403. updateSVUpperAddress(sVUpperAddr->value());
  8404. updateSVLower(sVLower->value());
  8405. updateSVUpper(sVUpper->value());
  8406. updateSVWritable(sVWritable->isChecked());
  8407. updateSVWriteAddress(sVOutputAddr->value());
  8408. updatePVColumnName(pVColumnName->text());
  8409. updateSVColumnName(sVColumnName->text());
  8410. updatePVHidden(pVHideBox->isChecked());
  8411. updateSVHidden(sVHideBox->isChecked());
  8412. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8413. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8414. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8415. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8416. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8417. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8418. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8419. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8420. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8421. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8422. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8423. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8424. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8425. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8426. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8427. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8428. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8429. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8430. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8431. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8432. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8433. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8434. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8435. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8436. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8437. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8438. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8439. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8440. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8441. layout->addWidget(form);
  8442. setLayout(layout);
  8443. }
  8444. void ModbusConfigurator::updatePort(const QString&newPort)
  8445. {
  8446. updateAttribute("port",newPort);
  8447. }
  8448. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8449. {
  8450. updateAttribute("baud",newRate);
  8451. }
  8452. void ModbusConfigurator::updateParity(const QString&)
  8453. {
  8454. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8455. }
  8456. void ModbusConfigurator::updateFlowControl(const QString&)
  8457. {
  8458. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8459. }
  8460. void ModbusConfigurator::updateStopBits(const QString&)
  8461. {
  8462. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8463. }
  8464. void ModbusConfigurator::updateStation(int station)
  8465. {
  8466. updateAttribute("station",QString("%1").arg(station));
  8467. }
  8468. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8469. {
  8470. updateAttribute("decimalQuery",fixed?"true":"false");
  8471. }
  8472. void ModbusConfigurator::updateDecimalAddress(int address)
  8473. {
  8474. updateAttribute("decimalAddress",QString("%1").arg(address));
  8475. }
  8476. void ModbusConfigurator::updateDecimalPosition(int position)
  8477. {
  8478. updateAttribute("decimalPosition",QString("%1").arg(position));
  8479. }
  8480. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8481. {
  8482. updateAttribute("unitQuery",fixed?"true":"false");
  8483. }
  8484. void ModbusConfigurator::updateUnitAddress(int address)
  8485. {
  8486. updateAttribute("unitAddress",QString("%1").arg(address));
  8487. }
  8488. void ModbusConfigurator::updateValueForF(int value)
  8489. {
  8490. updateAttribute("valueF",QString("%1").arg(value));
  8491. }
  8492. void ModbusConfigurator::updateValueForC(int value)
  8493. {
  8494. updateAttribute("valueC",QString("%1").arg(value));
  8495. }
  8496. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8497. {
  8498. updateAttribute("fixedUnit",newUnit);
  8499. }
  8500. void ModbusConfigurator::updatePVAddress(int address)
  8501. {
  8502. updateAttribute("pVAddress",QString("%1").arg(address));
  8503. }
  8504. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8505. {
  8506. updateAttribute("sVEnabled",enabled?"true":"false");
  8507. }
  8508. void ModbusConfigurator::updateSVReadAddress(int address)
  8509. {
  8510. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8511. }
  8512. void ModbusConfigurator::updateDeviceLimit(bool query)
  8513. {
  8514. updateAttribute("deviceLimit",query?"true":"false");
  8515. }
  8516. void ModbusConfigurator::updateSVLowerAddress(int address)
  8517. {
  8518. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8519. }
  8520. void ModbusConfigurator::updateSVUpperAddress(int address)
  8521. {
  8522. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8523. }
  8524. void ModbusConfigurator::updateSVLower(double value)
  8525. {
  8526. updateAttribute("sVLower",QString("%1").arg(value));
  8527. }
  8528. void ModbusConfigurator::updateSVUpper(double value)
  8529. {
  8530. updateAttribute("sVUpper",QString("%1").arg(value));
  8531. }
  8532. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8533. {
  8534. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8535. }
  8536. void ModbusConfigurator::updateSVWriteAddress(int address)
  8537. {
  8538. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8539. }
  8540. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8541. {
  8542. updateAttribute("pvcolname",name);
  8543. }
  8544. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8545. {
  8546. updateAttribute("svcolname",name);
  8547. }
  8548. void ModbusConfigurator::updatePVHidden(bool hidden)
  8549. {
  8550. updateAttribute("pvhidden",hidden?"true":"false");
  8551. }
  8552. void ModbusConfigurator::updateSVHidden(bool hidden)
  8553. {
  8554. updateAttribute("svhidden",hidden?"true":"false");
  8555. }
  8556. /*:863*/
  8557. #line 578 "./typica.w"
  8558. /*806:*/
  8559. #line 17144 "./typica.w"
  8560. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  8561. {
  8562. setMinimum(0);
  8563. setMaximum(0xFFFF);
  8564. setPrefix("0x");
  8565. setMinimumWidth(65);
  8566. }
  8567. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  8568. {
  8569. if(input.size()==2)
  8570. {
  8571. return QValidator::Intermediate;
  8572. }
  8573. bool okay;
  8574. input.toInt(&okay,16);
  8575. if(okay)
  8576. {
  8577. return QValidator::Acceptable;
  8578. }
  8579. return QValidator::Invalid;
  8580. }
  8581. int ShortHexSpinBox::valueFromText(const QString&text)const
  8582. {
  8583. return text.toInt(NULL,16);
  8584. }
  8585. QString ShortHexSpinBox::textFromValue(int value)const
  8586. {
  8587. QString retval;
  8588. retval.setNum(value,16);
  8589. while(retval.size()<4)
  8590. {
  8591. retval.prepend("0");
  8592. }
  8593. return retval.toUpper();
  8594. }
  8595. /*:806*/
  8596. #line 579 "./typica.w"
  8597. /*847:*/
  8598. #line 18176 "./typica.w"
  8599. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  8600. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  8601. waiting(false)
  8602. {
  8603. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  8604. Qt::UserRole).toString());
  8605. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  8606. QDomElement node;
  8607. QVariantMap attributes;
  8608. for(int i= 0;i<portConfigData.size();i++)
  8609. {
  8610. node= portConfigData.at(i).toElement();
  8611. attributes.insert(node.attribute("name"),node.attribute("value"));
  8612. }
  8613. port= new QextSerialPort(attributes.value("port").toString(),
  8614. QextSerialPort::EventDriven);
  8615. int baudRate= attributes.value("baud").toInt();
  8616. port->setBaudRate((BaudRateType)baudRate);
  8617. double temp= ((double)(1)/(double)(baudRate))*48;
  8618. delayTime= (int)(temp*3000);
  8619. messageDelayTimer->setSingleShot(true);
  8620. commTimeout->setSingleShot(true);
  8621. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  8622. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  8623. port->setDataBits(DATA_8);
  8624. port->setParity((ParityType)attributes.value("parity").toInt());
  8625. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  8626. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  8627. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  8628. port->open(QIODevice::ReadWrite);
  8629. station= (char)attributes.value("station").toInt();
  8630. if(attributes.value("decimalQuery")=="true")
  8631. {
  8632. decimalPosition= 0;
  8633. QByteArray message;
  8634. message.append(station);
  8635. message.append((char)0x03);
  8636. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  8637. char*addressBytes= (char*)&address;
  8638. message.append(addressBytes[1]);
  8639. message.append(addressBytes[0]);
  8640. message.append((char)0x00);
  8641. message.append((char)0x01);
  8642. queueMessage(message,this,"decimalResponse(QByteArray)");
  8643. }
  8644. else
  8645. {
  8646. decimalPosition= attributes.value("decimalPosition").toInt();
  8647. }
  8648. valueF= attributes.value("valueF").toInt();
  8649. valueC= attributes.value("valueC").toInt();
  8650. if(attributes.value("unitQuery")=="true")
  8651. {
  8652. QByteArray message;
  8653. message.append(station);
  8654. message.append((char)0x03);
  8655. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  8656. char*addressBytes= (char*)&address;
  8657. message.append(addressBytes[1]);
  8658. message.append(addressBytes[0]);
  8659. message.append((char)0x00);
  8660. message.append((char)0x01);
  8661. queueMessage(message,this,"unitResponse(QByteArray)");
  8662. }
  8663. else
  8664. {
  8665. if(attributes.value("fixedUnit")=="Celsius")
  8666. {
  8667. unitIsF= false;
  8668. }
  8669. }
  8670. if(attributes.value("sVWritable")=="true")
  8671. {
  8672. if(attributes.value("deviceLimit")=="true")
  8673. {
  8674. QByteArray lmessage;
  8675. lmessage.append(station);
  8676. lmessage.append((char)0x03);
  8677. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  8678. char*addressBytes= (char*)&laddress;
  8679. lmessage.append(addressBytes[1]);
  8680. lmessage.append(addressBytes[0]);
  8681. lmessage.append((char)0x00);
  8682. lmessage.append((char)0x01);
  8683. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  8684. QByteArray umessage;
  8685. umessage.append(station);
  8686. umessage.append((char)0x03);
  8687. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  8688. addressBytes= (char*)&uaddress;
  8689. umessage.append(addressBytes[1]);
  8690. umessage.append(addressBytes[0]);
  8691. umessage.append((char)0x00);
  8692. umessage.append((char)0x01);
  8693. queueMessage(umessage,this,"svuResponse(QByteArray)");
  8694. }
  8695. else
  8696. {
  8697. outputSVLower= attributes.value("sVLower").toDouble();
  8698. outputSVUpper= attributes.value("sVUpper").toDouble();
  8699. }
  8700. outputSVStub.append(station);
  8701. outputSVStub.append((char)0x06);
  8702. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  8703. char*addressBytes= (char*)&address;
  8704. outputSVStub.append(addressBytes[1]);
  8705. outputSVStub.append(addressBytes[0]);
  8706. }
  8707. Channel*pv= new Channel;
  8708. channels.append(pv);
  8709. pvStub.append(station);
  8710. pvStub.append((char)0x04);
  8711. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  8712. char*pvac= (char*)&pvaddress;
  8713. pvStub.append(pvac[1]);
  8714. pvStub.append(pvac[0]);
  8715. pvStub.append((char)0x00);
  8716. pvStub.append((char)0x01);
  8717. svenabled= attributes.value("sVEnabled").toBool();
  8718. if(svenabled)
  8719. {
  8720. Channel*sv= new Channel;
  8721. channels.append(sv);
  8722. svStub.append(station);
  8723. svStub.append((char)0x04);
  8724. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  8725. char*svac= (char*)&svaddress;
  8726. svStub.append(svac[1]);
  8727. svStub.append(svac[0]);
  8728. svStub.append((char)0x00);
  8729. svStub.append((char)0x01);
  8730. if(svaddress-pvaddress==1)
  8731. {
  8732. mStub.append(station);
  8733. mStub.append((char)0x04);
  8734. mStub.append(pvac[1]);
  8735. mStub.append(pvac[0]);
  8736. mStub.append((char)0x00);
  8737. mStub.append((char)0x02);
  8738. }
  8739. }
  8740. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  8741. requestMeasurement();
  8742. }
  8743. double ModbusRTUDevice::SVLower()
  8744. {
  8745. return outputSVLower;
  8746. }
  8747. double ModbusRTUDevice::SVUpper()
  8748. {
  8749. return outputSVUpper;
  8750. }
  8751. int ModbusRTUDevice::decimals()
  8752. {
  8753. return decimalPosition;
  8754. }
  8755. void ModbusRTUDevice::decimalResponse(QByteArray response)
  8756. {
  8757. quint16 temp;
  8758. char*tchar= (char*)&temp;
  8759. tchar[1]= response.at(3);
  8760. tchar[0]= response.at(4);
  8761. decimalPosition= temp;
  8762. emit SVDecimalChanged(decimalPosition);
  8763. qDebug()<<"Received decimal response";
  8764. }
  8765. void ModbusRTUDevice::unitResponse(QByteArray response)
  8766. {
  8767. quint16 temp;
  8768. char*tchar= (char*)&temp;
  8769. tchar[1]= response.at(3);
  8770. tchar[0]= response.at(4);
  8771. int value= temp;
  8772. if(value==valueF)
  8773. {
  8774. unitIsF= true;
  8775. }
  8776. else
  8777. {
  8778. unitIsF= false;
  8779. }
  8780. qDebug()<<"Received unit response";
  8781. }
  8782. void ModbusRTUDevice::svlResponse(QByteArray response)
  8783. {
  8784. quint16 temp;
  8785. char*tchar= (char*)&temp;
  8786. tchar[1]= response.at(3);
  8787. tchar[0]= response.at(4);
  8788. outputSVLower= (double)temp;
  8789. for(int i= 0;i<decimalPosition;i++)
  8790. {
  8791. outputSVLower/= 10;
  8792. }
  8793. emit SVLowerChanged(outputSVLower);
  8794. qDebug()<<"Received set value lower bound response";
  8795. }
  8796. void ModbusRTUDevice::svuResponse(QByteArray response)
  8797. {
  8798. quint16 temp;
  8799. char*tchar= (char*)&temp;
  8800. tchar[1]= response.at(3);
  8801. tchar[0]= response.at(4);
  8802. outputSVUpper= (double)temp;
  8803. for(int i= 0;i<decimalPosition;i++)
  8804. {
  8805. outputSVUpper/= 10;
  8806. }
  8807. emit SVUpperChanged(outputSVUpper);
  8808. qDebug()<<"Received set value upper bound response";
  8809. }
  8810. void ModbusRTUDevice::requestMeasurement()
  8811. {
  8812. if(mStub.length()> 0)
  8813. {
  8814. queueMessage(mStub,this,"mResponse(QByteArray)");
  8815. }
  8816. else
  8817. {
  8818. queueMessage(pvStub,this,"mResponse(QByteArray)");
  8819. if(svenabled)
  8820. {
  8821. queueMessage(svStub,this,"mResponse(QByteArray)");
  8822. }
  8823. }
  8824. }
  8825. void ModbusRTUDevice::mResponse(QByteArray response)
  8826. {
  8827. QTime time= QTime::currentTime();
  8828. if(response.at(2)==0x04)
  8829. {
  8830. /*848:*/
  8831. #line 18430 "./typica.w"
  8832. quint16 pv;
  8833. quint16 sv;
  8834. char*pvBytes= (char*)&pv;
  8835. char*svBytes= (char*)&sv;
  8836. pvBytes[1]= response.at(3);
  8837. pvBytes[0]= response.at(4);
  8838. svBytes[1]= response.at(5);
  8839. svBytes[0]= response.at(6);
  8840. double pvOut= (double)pv;
  8841. double svOut= (double)sv;
  8842. for(int i= 0;i<decimalPosition;i++)
  8843. {
  8844. pvOut/= 10;
  8845. svOut/= 10;
  8846. }
  8847. if(!unitIsF)
  8848. {
  8849. pvOut= pvOut*9/5+32;
  8850. svOut= svOut*9/5+32;
  8851. }
  8852. Measurement pvm(pvOut,time,Units::Fahrenheit);
  8853. Measurement svm(svOut,time,Units::Fahrenheit);
  8854. channels.at(0)->input(pvm);
  8855. channels.at(1)->input(svm);
  8856. /*:848*/
  8857. #line 18417 "./typica.w"
  8858. }
  8859. else
  8860. {
  8861. /*849:*/
  8862. #line 18460 "./typica.w"
  8863. quint16 value;
  8864. char*valueBytes= (char*)&value;
  8865. valueBytes[1]= response.at(3);
  8866. valueBytes[0]= response.at(4);
  8867. double valueOut= (double)value;
  8868. for(int i= 0;i<decimalPosition;i++)
  8869. {
  8870. valueOut/= 10;
  8871. }
  8872. if(!unitIsF)
  8873. {
  8874. valueOut= valueOut*9/5+32;
  8875. }
  8876. if(!svenabled)
  8877. {
  8878. Measurement vm(valueOut,time,Units::Fahrenheit);
  8879. channels.at(0)->input(vm);
  8880. }
  8881. else
  8882. {
  8883. if(readingsv)
  8884. {
  8885. Measurement pvm(savedpv,time,Units::Fahrenheit);
  8886. Measurement svm(valueOut,time,Units::Fahrenheit);
  8887. channels.at(0)->input(pvm);
  8888. channels.at(1)->input(svm);
  8889. readingsv= false;
  8890. }
  8891. else
  8892. {
  8893. savedpv= valueOut;
  8894. readingsv= true;
  8895. }
  8896. }
  8897. /*:849*/
  8898. #line 18421 "./typica.w"
  8899. }
  8900. }
  8901. /*:847*//*850:*/
  8902. #line 18498 "./typica.w"
  8903. ModbusRTUDevice::~ModbusRTUDevice()
  8904. {
  8905. commTimeout->stop();
  8906. messageDelayTimer->stop();
  8907. port->close();
  8908. }
  8909. /*:850*//*851:*/
  8910. #line 18525 "./typica.w"
  8911. void ModbusRTUDevice::dataAvailable()
  8912. {
  8913. if(messageDelayTimer->isActive())
  8914. {
  8915. messageDelayTimer->stop();
  8916. }
  8917. responseBuffer.append(port->readAll());
  8918. /*852:*/
  8919. #line 18571 "./typica.w"
  8920. if(responseBuffer.size()<5)
  8921. {
  8922. return;
  8923. }
  8924. switch(responseBuffer.at(1))
  8925. {
  8926. case 0x01:
  8927. case 0x02:
  8928. if(responseBuffer.size()<6)
  8929. {
  8930. return;
  8931. }
  8932. responseBuffer= responseBuffer.left(6);
  8933. break;
  8934. case 0x03:
  8935. case 0x04:
  8936. if(responseBuffer.size()<5+responseBuffer.at(2))
  8937. {
  8938. return;
  8939. }
  8940. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  8941. break;
  8942. case 0x05:
  8943. case 0x06:
  8944. case 0x10:
  8945. if(responseBuffer.size()<8)
  8946. {
  8947. return;
  8948. }
  8949. responseBuffer= responseBuffer.left(8);
  8950. break;
  8951. }
  8952. /*:852*/
  8953. #line 18533 "./typica.w"
  8954. commTimeout->stop();
  8955. if(calculateCRC(responseBuffer)==0)
  8956. {
  8957. QObject*object= retObjQueue.at(0);
  8958. char*method= callbackQueue.at(0);
  8959. QMetaMethod metamethod= object->metaObject()->
  8960. method(object->metaObject()->
  8961. indexOfMethod(QMetaObject::normalizedSignature(method)));
  8962. metamethod.invoke(object,Qt::QueuedConnection,
  8963. Q_ARG(QByteArray,responseBuffer));
  8964. messageQueue.removeAt(0);
  8965. retObjQueue.removeAt(0);
  8966. callbackQueue.removeAt(0);
  8967. }
  8968. else
  8969. {
  8970. qDebug()<<"CRC failed";
  8971. }
  8972. messageDelayTimer->start(delayTime);
  8973. waiting= false;
  8974. responseBuffer.clear();
  8975. }
  8976. /*:851*//*853:*/
  8977. #line 18613 "./typica.w"
  8978. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  8979. {
  8980. quint16 retval= 0xFFFF;
  8981. int i= 0;
  8982. while(i<data.size())
  8983. {
  8984. retval^= 0x00FF&(quint16)data.at(i);
  8985. for(int j= 0;j<8;j++)
  8986. {
  8987. if(retval&1)
  8988. {
  8989. retval= (retval>>1)^0xA001;
  8990. }
  8991. else
  8992. {
  8993. retval>>= 1;
  8994. }
  8995. }
  8996. i++;
  8997. }
  8998. return retval;
  8999. }
  9000. /*:853*//*854:*/
  9001. #line 18644 "./typica.w"
  9002. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9003. const char*callback)
  9004. {
  9005. messageQueue.append(request);
  9006. retObjQueue.append(object);
  9007. callbackQueue.append(const_cast<char*> (callback));
  9008. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9009. {
  9010. sendNextMessage();
  9011. }
  9012. }
  9013. void ModbusRTUDevice::sendNextMessage()
  9014. {
  9015. if(messageQueue.size()> 0&&!waiting)
  9016. {
  9017. QByteArray message= messageQueue.at(0);
  9018. quint16 crc= calculateCRC(message);
  9019. char*check= (char*)&crc;
  9020. message.append(check[0]);
  9021. message.append(check[1]);
  9022. qDebug()<<"Writing"<<message.toHex();
  9023. port->write(message);
  9024. commTimeout->start(2000);
  9025. messageDelayTimer->start(delayTime);
  9026. waiting= true;
  9027. }
  9028. else
  9029. {
  9030. emit queueEmpty();
  9031. }
  9032. }
  9033. void ModbusRTUDevice::outputSV(double value)
  9034. {
  9035. for(int i= 0;i<decimalPosition;i++)
  9036. {
  9037. value*= 10;
  9038. }
  9039. quint16 outval= (quint16)value;
  9040. QByteArray message(outputSVStub);
  9041. char*valBytes= (char*)&outval;
  9042. message.append(valBytes[1]);
  9043. message.append(valBytes[0]);
  9044. queueMessage(message,this,"ignore(QByteArray)");
  9045. }
  9046. /*:854*//*855:*/
  9047. #line 18694 "./typica.w"
  9048. void ModbusRTUDevice::ignore(QByteArray)
  9049. {
  9050. return;
  9051. }
  9052. /*:855*//*856:*/
  9053. #line 18707 "./typica.w"
  9054. void ModbusRTUDevice::timeout()
  9055. {
  9056. qDebug()<<"Communications timeout.";
  9057. responseBuffer.clear();
  9058. waiting= false;
  9059. messageDelayTimer->start();
  9060. }
  9061. /*:856*/
  9062. #line 580 "./typica.w"
  9063. /*725:*/
  9064. #line 15262 "./typica.w"
  9065. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9066. DeviceTreeModelNode*parent)
  9067. :domNode(node),rowNumber(row),parentItem(parent)
  9068. {
  9069. }
  9070. DeviceTreeModelNode::~DeviceTreeModelNode()
  9071. {
  9072. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9073. for(i= children.begin();i!=children.end();i++)
  9074. {
  9075. delete i.value();
  9076. }
  9077. }
  9078. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9079. {
  9080. return parentItem;
  9081. }
  9082. int DeviceTreeModelNode::row()
  9083. {
  9084. return rowNumber;
  9085. }
  9086. QDomNode DeviceTreeModelNode::node()const
  9087. {
  9088. return domNode;
  9089. }
  9090. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9091. {
  9092. if(children.contains(index))
  9093. {
  9094. return children[index];
  9095. }
  9096. if(index>=0&&index<domNode.childNodes().count())
  9097. {
  9098. QDomNode childNode= domNode.childNodes().item(index);
  9099. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9100. index,this);
  9101. children[index]= childItem;
  9102. return childItem;
  9103. }
  9104. return NULL;
  9105. }
  9106. /*:725*/
  9107. #line 581 "./typica.w"
  9108. /*727:*/
  9109. #line 15351 "./typica.w"
  9110. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9111. :QAbstractItemModel(parent)
  9112. {
  9113. document= AppInstance->deviceConfiguration();
  9114. QDomNodeList elements= document.elementsByTagName("devices");
  9115. if(elements.size()!=1)
  9116. {
  9117. qDebug()<<"Unexpected result when loading device map.";
  9118. }
  9119. treeRoot= elements.at(0);
  9120. root= new DeviceTreeModelNode(treeRoot,0);
  9121. elements= document.elementsByTagName("references");
  9122. if(elements.size()!=1)
  9123. {
  9124. qDebug()<<"No references section. Creating.";
  9125. referenceSection= document.createElement("references");
  9126. document.appendChild(referenceSection);
  9127. }
  9128. else
  9129. {
  9130. referenceSection= elements.at(0);
  9131. }
  9132. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9133. AppInstance,SLOT(saveDeviceConfiguration()));
  9134. connect(this,SIGNAL(modelReset()),
  9135. AppInstance,SLOT(saveDeviceConfiguration()));
  9136. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9137. AppInstance,SLOT(saveDeviceConfiguration()));
  9138. }
  9139. /*:727*//*728:*/
  9140. #line 15386 "./typica.w"
  9141. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9142. {
  9143. return 1;
  9144. }
  9145. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9146. {
  9147. if(parent.column()> 0)
  9148. {
  9149. return 0;
  9150. }
  9151. /*729:*/
  9152. #line 15405 "./typica.w"
  9153. DeviceTreeModelNode*parentItem;
  9154. if(!parent.isValid())
  9155. {
  9156. parentItem= root;
  9157. }
  9158. else
  9159. {
  9160. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9161. }
  9162. /*:729*/
  9163. #line 15398 "./typica.w"
  9164. return parentItem->node().childNodes().count();
  9165. }
  9166. /*:728*//*730:*/
  9167. #line 15419 "./typica.w"
  9168. QModelIndex DeviceTreeModel::index(int row,int column,
  9169. const QModelIndex&parent)const
  9170. {
  9171. if(!hasIndex(row,column,parent))
  9172. {
  9173. return QModelIndex();
  9174. }
  9175. /*729:*/
  9176. #line 15405 "./typica.w"
  9177. DeviceTreeModelNode*parentItem;
  9178. if(!parent.isValid())
  9179. {
  9180. parentItem= root;
  9181. }
  9182. else
  9183. {
  9184. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9185. }
  9186. /*:729*/
  9187. #line 15427 "./typica.w"
  9188. DeviceTreeModelNode*childItem= parentItem->child(row);
  9189. if(childItem)
  9190. {
  9191. return createIndex(row,column,childItem);
  9192. }
  9193. return QModelIndex();
  9194. }
  9195. /*:730*//*731:*/
  9196. #line 15438 "./typica.w"
  9197. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9198. {
  9199. if(!child.isValid())
  9200. {
  9201. return QModelIndex();
  9202. }
  9203. DeviceTreeModelNode*childItem=
  9204. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9205. DeviceTreeModelNode*parentItem= childItem->parent();
  9206. if(!parentItem||parentItem==root)
  9207. {
  9208. return QModelIndex();
  9209. }
  9210. return createIndex(parentItem->row(),0,parentItem);
  9211. }
  9212. /*:731*//*732:*/
  9213. #line 15457 "./typica.w"
  9214. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9215. {
  9216. if(!index.isValid())
  9217. {
  9218. return 0;
  9219. }
  9220. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9221. }
  9222. /*:732*//*733:*/
  9223. #line 15472 "./typica.w"
  9224. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9225. {
  9226. if(!index.isValid())
  9227. {
  9228. return QVariant();
  9229. }
  9230. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9231. {
  9232. return QVariant();
  9233. }
  9234. DeviceTreeModelNode*item=
  9235. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9236. QDomNode node= item->node();
  9237. QDomElement element= node.toElement();
  9238. switch(role)
  9239. {
  9240. case Qt::DisplayRole:
  9241. case Qt::EditRole:
  9242. return QVariant(element.attribute("name"));
  9243. case Qt::UserRole:
  9244. return QVariant(element.attribute("reference"));
  9245. default:
  9246. return QVariant();
  9247. }
  9248. return QVariant();
  9249. }
  9250. /*:733*//*734:*/
  9251. #line 15504 "./typica.w"
  9252. bool DeviceTreeModel::setData(const QModelIndex&index,
  9253. const QVariant&value,int)
  9254. {
  9255. if(!index.isValid())
  9256. {
  9257. return false;
  9258. }
  9259. DeviceTreeModelNode*item=
  9260. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9261. QDomNode node= item->node();
  9262. QDomElement element= node.toElement();
  9263. element.setAttribute("name",value.toString());
  9264. emit dataChanged(index,index);
  9265. return true;
  9266. }
  9267. /*:734*//*735:*/
  9268. #line 15527 "./typica.w"
  9269. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9270. const QModelIndex&parent)
  9271. {
  9272. QString referenceID= QUuid::createUuid().toString();
  9273. /*729:*/
  9274. #line 15405 "./typica.w"
  9275. DeviceTreeModelNode*parentItem;
  9276. if(!parent.isValid())
  9277. {
  9278. parentItem= root;
  9279. }
  9280. else
  9281. {
  9282. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9283. }
  9284. /*:729*/
  9285. #line 15532 "./typica.w"
  9286. QDomNode parentNode= parentItem->node();
  9287. int newRowNumber= rowCount(parent);
  9288. beginInsertRows(parent,newRowNumber,newRowNumber);
  9289. QDomElement deviceElement= document.createElement("node");
  9290. deviceElement.setAttribute("name",name);
  9291. deviceElement.setAttribute("reference",referenceID);
  9292. parentNode.appendChild(deviceElement);
  9293. QDomElement referenceElement= document.createElement("reference");
  9294. referenceElement.setAttribute("id",referenceID);
  9295. referenceElement.setAttribute("driver",driver);
  9296. referenceSection.appendChild(referenceElement);
  9297. endInsertRows();
  9298. }
  9299. /*:735*//*736:*/
  9300. #line 15550 "./typica.w"
  9301. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9302. {
  9303. /*729:*/
  9304. #line 15405 "./typica.w"
  9305. DeviceTreeModelNode*parentItem;
  9306. if(!parent.isValid())
  9307. {
  9308. parentItem= root;
  9309. }
  9310. else
  9311. {
  9312. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9313. }
  9314. /*:729*/
  9315. #line 15553 "./typica.w"
  9316. QDomNode parentNode= parentItem->node();
  9317. QDomNodeList childNodes= parentNode.childNodes();
  9318. if(childNodes.size()<row+count)
  9319. {
  9320. return false;
  9321. }
  9322. beginRemoveRows(parent,row,row+count-1);
  9323. QList<QDomElement> removalList;
  9324. for(int i= row;i<row+count;i++)
  9325. {
  9326. removalList.append(childNodes.at(i).toElement());
  9327. }
  9328. QDomElement element;
  9329. QDomElement reference;
  9330. for(int i= 0;i<count;i++)
  9331. {
  9332. element= removalList.at(i);
  9333. if(element.hasAttribute("reference"))
  9334. {
  9335. reference= referenceElement(element.attribute("reference"));
  9336. if(!reference.isNull())
  9337. {
  9338. referenceSection.removeChild(reference);
  9339. }
  9340. }
  9341. parentNode.removeChild(element);
  9342. }
  9343. endRemoveRows();
  9344. beginResetModel();
  9345. delete root;
  9346. root= new DeviceTreeModelNode(treeRoot,0);
  9347. endResetModel();
  9348. return true;
  9349. }
  9350. /*:736*//*737:*/
  9351. #line 15592 "./typica.w"
  9352. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9353. {
  9354. QDomNodeList childNodes= referenceSection.childNodes();
  9355. QDomElement element;
  9356. for(int i= 0;i<childNodes.size();i++)
  9357. {
  9358. element= childNodes.at(i).toElement();
  9359. if(element.hasAttribute("id"))
  9360. {
  9361. if(element.attribute("id")==id)
  9362. {
  9363. return element;
  9364. }
  9365. }
  9366. }
  9367. return QDomElement();
  9368. }
  9369. /*:737*//*738:*/
  9370. #line 15613 "./typica.w"
  9371. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9372. {
  9373. return QVariant();
  9374. }
  9375. /*:738*//*739:*/
  9376. #line 15622 "./typica.w"
  9377. DeviceTreeModel::~DeviceTreeModel()
  9378. {
  9379. delete root;
  9380. }
  9381. /*:739*/
  9382. #line 582 "./typica.w"
  9383. /*766:*/
  9384. #line 16122 "./typica.w"
  9385. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9386. DeviceTreeModel*model,const QModelIndex&index)
  9387. :QWidget(NULL),deviceModel(model),currentNode(index)
  9388. {
  9389. }
  9390. /*:766*//*767:*/
  9391. #line 16134 "./typica.w"
  9392. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9393. const QString&value)
  9394. {
  9395. QDomElement referenceElement= deviceModel->referenceElement(
  9396. deviceModel->data(currentNode,Qt::UserRole).toString());
  9397. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9398. QDomElement node;
  9399. bool found= false;
  9400. for(int i= 0;i<configData.size();i++)
  9401. {
  9402. node= configData.at(i).toElement();
  9403. if(node.attribute("name")==name)
  9404. {
  9405. node.setAttribute("value",value);
  9406. found= true;
  9407. break;
  9408. }
  9409. }
  9410. if(!found)
  9411. {
  9412. node= AppInstance->deviceConfiguration().createElement("attribute");
  9413. node.setAttribute("name",name);
  9414. node.setAttribute("value",value);
  9415. referenceElement.appendChild(node);
  9416. }
  9417. AppInstance->saveDeviceConfiguration();
  9418. }
  9419. /*:767*//*768:*/
  9420. #line 16168 "./typica.w"
  9421. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9422. const QString&driver)
  9423. {
  9424. deviceModel->newNode(name,driver,currentNode);
  9425. }
  9426. /*:768*/
  9427. #line 583 "./typica.w"
  9428. /*757:*/
  9429. #line 15966 "./typica.w"
  9430. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9431. view(new QTreeView),configArea(new QScrollArea)
  9432. {
  9433. QSplitter*splitter= new QSplitter;
  9434. QWidget*leftWidget= new QWidget;
  9435. leftWidget->setMinimumWidth(200);
  9436. QVBoxLayout*left= new QVBoxLayout;
  9437. view->setAnimated(true);
  9438. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9439. document= AppInstance->deviceConfiguration();
  9440. model= new DeviceTreeModel;
  9441. view->setModel(model);
  9442. view->setTextElideMode(Qt::ElideNone);
  9443. view->expandAll();
  9444. view->resizeColumnToContents(0);
  9445. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9446. QHBoxLayout*treeButtons= new QHBoxLayout;
  9447. QToolButton*addDeviceButton= new QToolButton;
  9448. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9449. addDeviceButton->setToolTip(tr("New Roaster"));
  9450. connect(addDeviceButton,SIGNAL(clicked()),
  9451. this,SLOT(addDevice()));
  9452. QToolButton*removeNodeButton= new QToolButton;
  9453. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9454. removeNodeButton->setToolTip(tr("Delete Selection"));
  9455. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9456. treeButtons->addWidget(addDeviceButton);
  9457. treeButtons->addWidget(removeNodeButton);
  9458. left->addWidget(view);
  9459. left->addLayout(treeButtons);
  9460. leftWidget->setLayout(left);
  9461. splitter->addWidget(leftWidget);
  9462. configArea->setMinimumWidth(580);
  9463. configArea->setMinimumHeight(460);
  9464. configArea->setWidgetResizable(true);
  9465. splitter->addWidget(configArea);
  9466. QVBoxLayout*centralLayout= new QVBoxLayout;
  9467. centralLayout->addWidget(splitter);
  9468. setLayout(centralLayout);
  9469. connect(view,SIGNAL(activated(QModelIndex)),
  9470. this,SLOT(newSelection(QModelIndex)));
  9471. connect(view,SIGNAL(clicked(QModelIndex)),
  9472. this,SLOT(newSelection(QModelIndex)));
  9473. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9474. view,SLOT(expand(QModelIndex)));
  9475. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9476. this,SLOT(resizeColumn()));
  9477. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9478. this,SLOT(resizeColumn()));
  9479. }
  9480. /*:757*//*758:*/
  9481. #line 16021 "./typica.w"
  9482. void DeviceConfigurationWindow::addDevice()
  9483. {
  9484. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9485. }
  9486. /*:758*//*759:*/
  9487. #line 16029 "./typica.w"
  9488. void DeviceConfigurationWindow::removeNode()
  9489. {
  9490. QModelIndex index= view->currentIndex();
  9491. if(index.isValid())
  9492. {
  9493. int row= index.row();
  9494. QModelIndex parent= index.parent();
  9495. model->removeRow(row,parent);
  9496. }
  9497. }
  9498. /*:759*//*760:*/
  9499. #line 16045 "./typica.w"
  9500. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9501. {
  9502. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9503. if(editor)
  9504. {
  9505. configArea->setWidget(editor);
  9506. editor->show();
  9507. }
  9508. }
  9509. /*:760*//*761:*/
  9510. #line 16062 "./typica.w"
  9511. void DeviceConfigurationWindow::resizeColumn()
  9512. {
  9513. view->resizeColumnToContents(0);
  9514. }
  9515. /*:761*/
  9516. #line 584 "./typica.w"
  9517. /*781:*/
  9518. #line 16543 "./typica.w"
  9519. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9520. const QModelIndex&index):
  9521. BasicDeviceConfigurationWidget(model,index)
  9522. {
  9523. QFormLayout*layout= new QFormLayout;
  9524. QLineEdit*columnName= new QLineEdit;
  9525. layout->addRow(tr("Column Name:"),columnName);
  9526. QComboBox*typeSelector= new QComboBox;
  9527. typeSelector->addItem("J");
  9528. typeSelector->addItem("K");
  9529. typeSelector->addItem("T");
  9530. typeSelector->addItem("B");
  9531. typeSelector->addItem("E");
  9532. typeSelector->addItem("N");
  9533. typeSelector->addItem("R");
  9534. typeSelector->addItem("S");
  9535. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9536. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9537. layout->addRow(hideSeries);
  9538. setLayout(layout);
  9539. /*771:*/
  9540. #line 16337 "./typica.w"
  9541. QDomElement referenceElement=
  9542. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9543. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9544. QDomElement node;
  9545. /*:771*/
  9546. #line 16564 "./typica.w"
  9547. for(int i= 0;i<configData.size();i++)
  9548. {
  9549. node= configData.at(i).toElement();
  9550. if(node.attribute("name")=="type")
  9551. {
  9552. typeSelector->setCurrentIndex(
  9553. typeSelector->findText(node.attribute("value")));
  9554. }
  9555. else if(node.attribute("name")=="columnname")
  9556. {
  9557. columnName->setText(node.attribute("value"));
  9558. }
  9559. else if(node.attribute("name")=="hidden")
  9560. {
  9561. hideSeries->setChecked(node.attribute("value")=="true");
  9562. }
  9563. }
  9564. updateThermocoupleType(typeSelector->currentText());
  9565. updateColumnName(columnName->text());
  9566. updateHidden(hideSeries->isChecked());
  9567. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  9568. this,SLOT(updateThermocoupleType(QString)));
  9569. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  9570. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  9571. }
  9572. /*:781*//*782:*/
  9573. #line 16594 "./typica.w"
  9574. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  9575. {
  9576. updateAttribute("type",type);
  9577. }
  9578. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  9579. {
  9580. updateAttribute("columnname",name);
  9581. }
  9582. void Ni9211TcConfWidget::updateHidden(bool hidden)
  9583. {
  9584. updateAttribute("hidden",hidden?"true":"false");
  9585. }
  9586. /*:782*/
  9587. #line 585 "./typica.w"
  9588. /*777:*/
  9589. #line 16457 "./typica.w"
  9590. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  9591. const QModelIndex&index)
  9592. :BasicDeviceConfigurationWidget(model,index)
  9593. {
  9594. QVBoxLayout*layout= new QVBoxLayout;
  9595. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9596. QLabel*label= new QLabel(tr("Device ID:"));
  9597. QLineEdit*deviceId= new QLineEdit;
  9598. deviceIdLayout->addWidget(label);
  9599. deviceIdLayout->addWidget(deviceId);
  9600. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9601. layout->addLayout(deviceIdLayout);
  9602. layout->addWidget(addChannelButton);
  9603. /*771:*/
  9604. #line 16337 "./typica.w"
  9605. QDomElement referenceElement=
  9606. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9607. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9608. QDomElement node;
  9609. /*:771*/
  9610. #line 16471 "./typica.w"
  9611. for(int i= 0;i<configData.size();i++)
  9612. {
  9613. node= configData.at(i).toElement();
  9614. if(node.attribute("name")=="deviceID")
  9615. {
  9616. deviceId->setText(node.attribute("value","Dev1"));
  9617. break;
  9618. }
  9619. }
  9620. updateDeviceId(deviceId->text());
  9621. connect(addChannelButton,SIGNAL(clicked()),
  9622. this,SLOT(addChannel()));
  9623. connect(deviceId,SIGNAL(textEdited(QString)),
  9624. this,SLOT(updateDeviceId(QString)));
  9625. setLayout(layout);
  9626. }
  9627. /*:777*//*778:*/
  9628. #line 16493 "./typica.w"
  9629. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  9630. {
  9631. updateAttribute("deviceID",newId);
  9632. }
  9633. /*:778*//*779:*/
  9634. #line 16501 "./typica.w"
  9635. void NiDaqMxBase9211ConfWidget::addChannel()
  9636. {
  9637. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  9638. }
  9639. /*:779*/
  9640. #line 586 "./typica.w"
  9641. /*775:*/
  9642. #line 16408 "./typica.w"
  9643. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  9644. DeviceTreeModel*model,const QModelIndex&index):
  9645. BasicDeviceConfigurationWidget(model,index)
  9646. {
  9647. QHBoxLayout*layout= new QHBoxLayout;
  9648. QToolButton*addDeviceButton= new QToolButton;
  9649. addDeviceButton->setText(tr("Add Device"));
  9650. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  9651. "nidaqmxbase9211series");
  9652. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9653. "nidaqmxbase9211series");
  9654. connect(add9211,SIGNAL(triggered(QString,QString)),
  9655. this,SLOT(insertChildNode(QString,QString)));
  9656. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9657. this,SLOT(insertChildNode(QString,QString)));
  9658. QMenu*deviceMenu= new QMenu;
  9659. deviceMenu->addAction(add9211);
  9660. deviceMenu->addAction(add9211a);
  9661. addDeviceButton->setMenu(deviceMenu);
  9662. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9663. layout->addWidget(addDeviceButton);
  9664. setLayout(layout);
  9665. }
  9666. /*:775*/
  9667. #line 587 "./typica.w"
  9668. /*642:*/
  9669. #line 13882 "./typica.w"
  9670. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  9671. QObject*parent):
  9672. QAction(reportName,parent),reportFile(fileName)
  9673. {
  9674. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  9675. }
  9676. /*:642*//*643:*/
  9677. #line 13898 "./typica.w"
  9678. void ReportAction::createReport()
  9679. {
  9680. QFile file(reportFile);
  9681. QDomDocument document;
  9682. if(file.open(QIODevice::ReadOnly))
  9683. {
  9684. document.setContent(&file,true);
  9685. QDomElement element= document.documentElement();
  9686. QScriptEngine*engine= AppInstance->engine;
  9687. QScriptContext*context= engine->pushContext();
  9688. QScriptValue object;
  9689. QString targetID= reportFile;
  9690. /*198:*/
  9691. #line 4632 "./typica.w"
  9692. ScriptQMainWindow*window= new ScriptQMainWindow;
  9693. window->setObjectName(targetID);
  9694. object= engine->newQObject(window);
  9695. setQMainWindowProperties(object,engine);
  9696. QWidget*central= new(QWidget);
  9697. central->setParent(window);
  9698. central->setObjectName("centralWidget");
  9699. window->setCentralWidget(central);
  9700. if(element.hasChildNodes())
  9701. {
  9702. /*199:*/
  9703. #line 4667 "./typica.w"
  9704. QStack<QWidget*> widgetStack;
  9705. QStack<QLayout*> layoutStack;
  9706. QString windowScript;
  9707. widgetStack.push(central);
  9708. QDomNodeList windowChildren= element.childNodes();
  9709. int i= 0;
  9710. while(i<windowChildren.count())
  9711. {
  9712. QDomNode current;
  9713. QDomElement element;
  9714. current= windowChildren.at(i);
  9715. if(current.isElement())
  9716. {
  9717. element= current.toElement();
  9718. if(element.tagName()=="program")
  9719. {
  9720. windowScript.append(element.text());
  9721. }
  9722. else if(element.tagName()=="layout")
  9723. {
  9724. element.setAttribute("trcontext","configuration");
  9725. addLayoutToWidget(element,&widgetStack,&layoutStack);
  9726. }
  9727. else if(element.tagName()=="menu")
  9728. {
  9729. /*200:*/
  9730. #line 4715 "./typica.w"
  9731. QMenuBar*bar= window->menuBar();
  9732. bar->setParent(window);
  9733. bar->setObjectName("menuBar");
  9734. if(element.hasAttribute("name"))
  9735. {
  9736. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  9737. element.attribute("name").toUtf8().data()));
  9738. menu->setParent(bar);
  9739. if(element.hasAttribute("type"))
  9740. {
  9741. if(element.attribute("type")=="reports")
  9742. {
  9743. if(element.hasAttribute("src"))
  9744. {
  9745. /*640:*/
  9746. #line 13842 "./typica.w"
  9747. QSettings settings;
  9748. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  9749. toString()).
  9750. arg(element.attribute("src"));
  9751. QDir::addSearchPath("reports",reportDirectory);
  9752. QDir directory(reportDirectory);
  9753. directory.setFilter(QDir::Files);
  9754. directory.setSorting(QDir::Name);
  9755. QStringList nameFilter;
  9756. nameFilter<<"*.xml";
  9757. directory.setNameFilters(nameFilter);
  9758. QFileInfoList reportFiles= directory.entryInfoList();
  9759. for(int i= 0;i<reportFiles.size();i++)
  9760. {
  9761. QFileInfo reportFile= reportFiles.at(i);
  9762. /*644:*/
  9763. #line 13922 "./typica.w"
  9764. QString path= reportFile.absoluteFilePath();
  9765. QFile file(path);
  9766. if(file.open(QIODevice::ReadOnly))
  9767. {
  9768. QDomDocument document;
  9769. document.setContent(&file,true);
  9770. QDomElement root= document.documentElement();
  9771. QString translationContext= root.attribute("id");
  9772. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  9773. if(!titleNode.isNull())
  9774. {
  9775. QDomElement titleElement= titleNode.toElement();
  9776. QString title= QCoreApplication::translate("configuration",
  9777. titleElement.text().toUtf8().data());
  9778. if(!title.isEmpty())
  9779. {
  9780. QStringList hierarchy= title.split(":->");
  9781. QMenu*insertionPoint= menu;
  9782. /*645:*/
  9783. #line 13951 "./typica.w"
  9784. for(int j= 0;j<hierarchy.size()-1;j++)
  9785. {
  9786. QObjectList menuList= insertionPoint->children();
  9787. bool menuFound= false;
  9788. for(int k= 0;k<menuList.size();k++)
  9789. {
  9790. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  9791. if(currentItem)
  9792. {
  9793. if(currentItem->title()==hierarchy.at(j))
  9794. {
  9795. menuFound= true;
  9796. insertionPoint= currentItem;
  9797. break;
  9798. }
  9799. }
  9800. }
  9801. if(!menuFound)
  9802. {
  9803. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  9804. }
  9805. }
  9806. /*:645*/
  9807. #line 13941 "./typica.w"
  9808. ReportAction*action= new ReportAction(path,hierarchy.last());
  9809. insertionPoint->addAction(action);
  9810. }
  9811. }
  9812. }
  9813. /*:644*/
  9814. #line 13858 "./typica.w"
  9815. }
  9816. /*:640*/
  9817. #line 4730 "./typica.w"
  9818. }
  9819. }
  9820. }
  9821. if(element.hasChildNodes())
  9822. {
  9823. /*201:*/
  9824. #line 4743 "./typica.w"
  9825. QDomNodeList menuItems= element.childNodes();
  9826. int j= 0;
  9827. while(j<menuItems.count())
  9828. {
  9829. QDomNode item= menuItems.at(j);
  9830. if(item.isElement())
  9831. {
  9832. QDomElement itemElement= item.toElement();
  9833. if(itemElement.tagName()=="item")
  9834. {
  9835. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  9836. itemElement.text().toUtf8().data()),menu);
  9837. if(itemElement.hasAttribute("id"))
  9838. {
  9839. itemAction->setObjectName(itemElement.attribute("id"));
  9840. }
  9841. if(itemElement.hasAttribute("shortcut"))
  9842. {
  9843. itemAction->setShortcut(itemElement.attribute("shortcut"));
  9844. }
  9845. menu->addAction(itemAction);
  9846. }
  9847. else if(itemElement.tagName()=="separator")
  9848. {
  9849. menu->addSeparator();
  9850. }
  9851. }
  9852. j++;
  9853. }
  9854. #line 1 "./helpmenu.w"
  9855. /*:201*/
  9856. #line 4736 "./typica.w"
  9857. }
  9858. }
  9859. /*:200*/
  9860. #line 4693 "./typica.w"
  9861. }
  9862. }
  9863. i++;
  9864. }
  9865. QScriptValue oldThis= context->thisObject();
  9866. context->setThisObject(object);
  9867. QScriptValue result= engine->evaluate(windowScript);
  9868. /*192:*/
  9869. #line 4449 "./typica.w"
  9870. if(engine->hasUncaughtException())
  9871. {
  9872. int line= engine->uncaughtExceptionLineNumber();
  9873. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  9874. result.toString();
  9875. QString trace;
  9876. foreach(trace,engine->uncaughtExceptionBacktrace())
  9877. {
  9878. qDebug()<<trace;
  9879. }
  9880. }
  9881. /*:192*/
  9882. #line 4701 "./typica.w"
  9883. context->setThisObject(oldThis);
  9884. /*:199*/
  9885. #line 4643 "./typica.w"
  9886. }
  9887. /*202:*/
  9888. #line 9 "./helpmenu.w"
  9889. HelpMenu*helpMenu= new HelpMenu();
  9890. window->menuBar()->addMenu(helpMenu);
  9891. /*:202*/
  9892. #line 4645 "./typica.w"
  9893. window->show();
  9894. /*:198*/
  9895. #line 13911 "./typica.w"
  9896. file.close();
  9897. engine->popContext();
  9898. }
  9899. }
  9900. /*:643*/
  9901. #line 588 "./typica.w"
  9902. /*241:*/
  9903. #line 5829 "./typica.w"
  9904. NumericDelegate::NumericDelegate(QObject*parent):
  9905. QItemDelegate(parent)
  9906. {
  9907. }
  9908. /*:241*//*242:*/
  9909. #line 5841 "./typica.w"
  9910. void NumericDelegate::setEditorData(QWidget*editor,
  9911. const QModelIndex&index)const
  9912. {
  9913. QString value= index.model()->data(index,Qt::EditRole).toString();
  9914. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9915. line->setText(value);
  9916. }
  9917. /*:242*//*243:*/
  9918. #line 5856 "./typica.w"
  9919. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  9920. const QModelIndex&index)const
  9921. {
  9922. QLineEdit*line= static_cast<QLineEdit*> (editor);
  9923. model->setData(index,line->text(),Qt::EditRole);
  9924. QScriptEngine*engine= AppInstance->engine;
  9925. engine->pushContext();
  9926. QString script= QString("Number(%1)").arg(line->text());
  9927. QScriptValue result= engine->evaluate(line->text());
  9928. if(result.isNumber())
  9929. {
  9930. model->setData(index,result.toVariant(),Qt::DisplayRole);
  9931. }
  9932. else
  9933. {
  9934. model->setData(index,QVariant(),Qt::DisplayRole);
  9935. }
  9936. engine->popContext();
  9937. }
  9938. /*:243*//*244:*/
  9939. #line 5879 "./typica.w"
  9940. QWidget*NumericDelegate::createEditor(QWidget*parent,
  9941. const QStyleOptionViewItem&,
  9942. const QModelIndex&)const
  9943. {
  9944. return(new QLineEdit(parent));
  9945. }
  9946. /*:244*//*245:*/
  9947. #line 5890 "./typica.w"
  9948. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  9949. const QStyleOptionViewItem&option,
  9950. const QModelIndex&)const
  9951. {
  9952. editor->setGeometry(option.rect);
  9953. }
  9954. /*:245*/
  9955. #line 589 "./typica.w"
  9956. /*786:*/
  9957. #line 16653 "./typica.w"
  9958. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  9959. const QModelIndex&index)
  9960. :BasicDeviceConfigurationWidget(model,index)
  9961. {
  9962. QHBoxLayout*layout= new QHBoxLayout;
  9963. QToolButton*addDeviceButton= new QToolButton;
  9964. addDeviceButton->setText(tr("Add Device"));
  9965. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  9966. "nidaqmx9211series");
  9967. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  9968. "nidaqmxtc01");
  9969. connect(add9211a,SIGNAL(triggered(QString,QString)),
  9970. this,SLOT(insertChildNode(QString,QString)));
  9971. connect(addtc01,SIGNAL(triggered(QString,QString)),
  9972. this,SLOT(insertChildNode(QString,QString)));
  9973. QMenu*deviceMenu= new QMenu;
  9974. deviceMenu->addAction(add9211a);
  9975. deviceMenu->addAction(addtc01);
  9976. addDeviceButton->setMenu(deviceMenu);
  9977. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  9978. layout->addWidget(addDeviceButton);
  9979. setLayout(layout);
  9980. }
  9981. /*:786*/
  9982. #line 590 "./typica.w"
  9983. /*788:*/
  9984. #line 16702 "./typica.w"
  9985. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  9986. const QModelIndex&index)
  9987. :BasicDeviceConfigurationWidget(model,index)
  9988. {
  9989. QVBoxLayout*layout= new QVBoxLayout;
  9990. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  9991. QLabel*label= new QLabel(tr("Device ID:"));
  9992. QLineEdit*deviceId= new QLineEdit;
  9993. deviceIdLayout->addWidget(label);
  9994. deviceIdLayout->addWidget(deviceId);
  9995. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  9996. layout->addLayout(deviceIdLayout);
  9997. layout->addWidget(addChannelButton);
  9998. /*771:*/
  9999. #line 16337 "./typica.w"
  10000. QDomElement referenceElement=
  10001. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10002. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10003. QDomElement node;
  10004. /*:771*/
  10005. #line 16716 "./typica.w"
  10006. for(int i= 0;i<configData.size();i++)
  10007. {
  10008. node= configData.at(i).toElement();
  10009. if(node.attribute("name")=="deviceID")
  10010. {
  10011. deviceId->setText(node.attribute("value","Dev1"));
  10012. break;
  10013. }
  10014. }
  10015. updateDeviceId(deviceId->text());
  10016. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10017. connect(deviceId,SIGNAL(textEdited(QString)),
  10018. this,SLOT(updateDeviceId(QString)));
  10019. setLayout(layout);
  10020. }
  10021. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10022. {
  10023. updateAttribute("deviceID",newId);
  10024. }
  10025. void NiDaqMx9211ConfWidget::addChannel()
  10026. {
  10027. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10028. }
  10029. /*:788*/
  10030. #line 591 "./typica.w"
  10031. /*790:*/
  10032. #line 16767 "./typica.w"
  10033. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10034. const QModelIndex&index)
  10035. :BasicDeviceConfigurationWidget(model,index)
  10036. {
  10037. QFormLayout*layout= new QFormLayout;
  10038. QLineEdit*deviceId= new QLineEdit;
  10039. layout->addRow(tr("Device ID:"),deviceId);
  10040. QLineEdit*columnName= new QLineEdit;
  10041. layout->addRow(tr("Column Name:"),columnName);
  10042. QComboBox*typeSelector= new QComboBox;
  10043. typeSelector->addItem("J");
  10044. typeSelector->addItem("K");
  10045. typeSelector->addItem("T");
  10046. typeSelector->addItem("B");
  10047. typeSelector->addItem("E");
  10048. typeSelector->addItem("N");
  10049. typeSelector->addItem("R");
  10050. typeSelector->addItem("S");
  10051. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10052. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10053. layout->addRow(hideSeries);
  10054. /*771:*/
  10055. #line 16337 "./typica.w"
  10056. QDomElement referenceElement=
  10057. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10058. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10059. QDomElement node;
  10060. /*:771*/
  10061. #line 16789 "./typica.w"
  10062. for(int i= 0;i<configData.size();i++)
  10063. {
  10064. node= configData.at(i).toElement();
  10065. if(node.attribute("name")=="deviceID")
  10066. {
  10067. deviceId->setText(node.attribute("value"));
  10068. }
  10069. else if(node.attribute("name")=="type")
  10070. {
  10071. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10072. }
  10073. else if(node.attribute("name")=="columnname")
  10074. {
  10075. columnName->setText(node.attribute("value"));
  10076. }
  10077. else if(node.attribute("name")=="hidden")
  10078. {
  10079. hideSeries->setChecked(node.attribute("value")=="true");
  10080. }
  10081. }
  10082. updateDeviceId(deviceId->text());
  10083. updateThermocoupleType(typeSelector->currentText());
  10084. updateColumnName(columnName->text());
  10085. updateHidden(hideSeries->isChecked());
  10086. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10087. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10088. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10089. setLayout(layout);
  10090. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10091. }
  10092. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10093. {
  10094. updateAttribute("deviceID",newId);
  10095. }
  10096. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10097. {
  10098. updateAttribute("type",type);
  10099. }
  10100. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10101. {
  10102. updateAttribute("columnname",name);
  10103. }
  10104. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10105. {
  10106. updateAttribute("hidden",hidden?"true":"false");
  10107. }
  10108. /*:790*/
  10109. #line 592 "./typica.w"
  10110. /*808:*/
  10111. #line 17209 "./typica.w"
  10112. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10113. const QModelIndex&index)
  10114. :BasicDeviceConfigurationWidget(model,index)
  10115. {
  10116. QFormLayout*layout= new QFormLayout;
  10117. QToolButton*addDeviceButton= new QToolButton;
  10118. addDeviceButton->setText(tr("Add Device"));
  10119. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10120. "Modbus RTU Device",
  10121. "modbusrtudevice");
  10122. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10123. this,SLOT(insertChildNode(QString,QString)));
  10124. QMenu*deviceMenu= new QMenu;
  10125. deviceMenu->addAction(addModbusRtuDevice);
  10126. addDeviceButton->setMenu(deviceMenu);
  10127. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10128. layout->addRow(QString(),addDeviceButton);
  10129. PortSelector*port= new PortSelector;
  10130. layout->addRow(tr("Port:"),port);
  10131. connect(port,SIGNAL(currentIndexChanged(QString)),
  10132. this,SLOT(updatePort(QString)));
  10133. connect(port,SIGNAL(editTextChanged(QString)),
  10134. this,SLOT(updatePort(QString)));
  10135. BaudSelector*rate= new BaudSelector;
  10136. layout->addRow(tr("Baud:"),rate);
  10137. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10138. this,SLOT(updateBaudRate(QString)));
  10139. ParitySelector*parity= new ParitySelector;
  10140. layout->addRow(tr("Parity:"),parity);
  10141. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10142. this,SLOT(updateParity(QString)));
  10143. FlowSelector*flow= new FlowSelector;
  10144. layout->addRow(tr("Flow Control:"),flow);
  10145. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10146. this,SLOT(updateFlowControl(QString)));
  10147. StopSelector*stop= new StopSelector;
  10148. layout->addRow(tr("Stop Bits:"),stop);
  10149. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10150. this,SLOT(updateStopBits(QString)));
  10151. /*771:*/
  10152. #line 16337 "./typica.w"
  10153. QDomElement referenceElement=
  10154. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10155. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10156. QDomElement node;
  10157. /*:771*/
  10158. #line 17249 "./typica.w"
  10159. for(int i= 0;i<configData.size();i++)
  10160. {
  10161. node= configData.at(i).toElement();
  10162. if(node.attribute("name")=="port")
  10163. {
  10164. int j= port->findText(node.attribute("value"));
  10165. if(j>=0)
  10166. {
  10167. port->setCurrentIndex(j);
  10168. }
  10169. else
  10170. {
  10171. port->insertItem(0,node.attribute("value"));
  10172. port->setCurrentIndex(0);
  10173. }
  10174. }
  10175. else if(node.attribute("name")=="baudrate")
  10176. {
  10177. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10178. }
  10179. else if(node.attribute("name")=="parity")
  10180. {
  10181. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10182. }
  10183. else if(node.attribute("name")=="flowcontrol")
  10184. {
  10185. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10186. }
  10187. else if(node.attribute("name")=="stopbits")
  10188. {
  10189. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10190. }
  10191. }
  10192. updatePort(port->currentText());
  10193. updateBaudRate(rate->currentText());
  10194. updateParity(parity->currentText());
  10195. updateFlowControl(flow->currentText());
  10196. updateStopBits(stop->currentText());
  10197. setLayout(layout);
  10198. }
  10199. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10200. {
  10201. updateAttribute("port",newPort);
  10202. }
  10203. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10204. {
  10205. updateAttribute("baudrate",newRate);
  10206. }
  10207. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10208. {
  10209. updateAttribute("parity",newParity);
  10210. }
  10211. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10212. {
  10213. updateAttribute("flowcontrol",newFlow);
  10214. }
  10215. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10216. {
  10217. updateAttribute("stopbits",newStopBits);
  10218. }
  10219. /*:808*/
  10220. #line 593 "./typica.w"
  10221. /*810:*/
  10222. #line 17372 "./typica.w"
  10223. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10224. const QModelIndex&index)
  10225. :BasicDeviceConfigurationWidget(model,index),
  10226. unitSpecificationLayout(new QStackedLayout),
  10227. decimalSpecificationLayout(new QStackedLayout)
  10228. {
  10229. QVBoxLayout*layout= new QVBoxLayout;
  10230. QToolButton*addChannelButton= new QToolButton;
  10231. addChannelButton->setText(tr("Add Channel"));
  10232. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10233. "Temperature Process Value",
  10234. "modbustemperaturepv");
  10235. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10236. "Temperature Set Value",
  10237. "modbustemperaturesv");
  10238. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10239. this,SLOT(insertChildNode(QString,QString)));
  10240. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10241. this,SLOT(insertChildNode(QString,QString)));
  10242. QMenu*channelMenu= new QMenu;
  10243. channelMenu->addAction(addTemperaturePV);
  10244. channelMenu->addAction(addTemperatureSV);
  10245. addChannelButton->setMenu(channelMenu);
  10246. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10247. layout->addWidget(addChannelButton);
  10248. QHBoxLayout*stationLayout= new QHBoxLayout;
  10249. QLabel*stationLabel= new QLabel(tr("Station:"));
  10250. QSpinBox*stationNumber= new QSpinBox;
  10251. stationNumber->setMinimum(0);
  10252. stationNumber->setMaximum(255);
  10253. stationLayout->addWidget(stationLabel);
  10254. stationLayout->addWidget(stationNumber);
  10255. layout->addLayout(stationLayout);
  10256. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10257. layout->addWidget(fixedUnit);
  10258. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10259. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10260. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10261. QComboBox*fixedUnitSelector= new QComboBox;
  10262. fixedUnitSelector->addItem("Fahrenheit");
  10263. fixedUnitSelector->addItem("Celsius");
  10264. fixedUnitLayout->addWidget(fixedUnitLabel);
  10265. fixedUnitLayout->addWidget(fixedUnitSelector);
  10266. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10267. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10268. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10269. QFormLayout*queriedUnitLayout= new QFormLayout;
  10270. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10271. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10272. QSpinBox*valueF= new QSpinBox;
  10273. valueF->setMinimum(0);
  10274. valueF->setMaximum(65535);
  10275. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10276. QSpinBox*valueC= new QSpinBox;
  10277. valueC->setMinimum(0);
  10278. valueC->setMaximum(65535);
  10279. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10280. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10281. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10282. layout->addLayout(unitSpecificationLayout);
  10283. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10284. layout->addWidget(fixedPrecision);
  10285. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10286. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10287. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10288. fixedPrecisionValue->setMinimum(0);
  10289. fixedPrecisionValue->setMaximum(9);
  10290. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10291. fixedPrecisionValue);
  10292. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10293. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10294. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10295. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10296. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10297. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10298. precisionAddress);
  10299. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10300. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10301. layout->addLayout(decimalSpecificationLayout);
  10302. /*771:*/
  10303. #line 16337 "./typica.w"
  10304. QDomElement referenceElement=
  10305. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10306. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10307. QDomElement node;
  10308. /*:771*/
  10309. #line 17452 "./typica.w"
  10310. for(int i= 0;i<configData.size();i++)
  10311. {
  10312. node= configData.at(i).toElement();
  10313. if(node.attribute("name")=="station")
  10314. {
  10315. stationNumber->setValue(node.attribute("value").toInt());
  10316. }
  10317. else if(node.attribute("name")=="fixedunit")
  10318. {
  10319. if(node.attribute("value")=="true")
  10320. {
  10321. fixedUnit->setCheckState(Qt::Checked);
  10322. }
  10323. else if(node.attribute("value")=="false")
  10324. {
  10325. fixedUnit->setCheckState(Qt::Unchecked);
  10326. }
  10327. }
  10328. else if(node.attribute("name")=="fixedprecision")
  10329. {
  10330. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10331. }
  10332. else if(node.attribute("name")=="unit")
  10333. {
  10334. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10335. }
  10336. else if(node.attribute("name")=="unitaddress")
  10337. {
  10338. unitAddress->setValue(node.attribute("value").toInt());
  10339. }
  10340. else if(node.attribute("name")=="fvalue")
  10341. {
  10342. valueF->setValue(node.attribute("value").toInt());
  10343. }
  10344. else if(node.attribute("name")=="cvalue")
  10345. {
  10346. valueC->setValue(node.attribute("value").toInt());
  10347. }
  10348. else if(node.attribute("name")=="precisionaddress")
  10349. {
  10350. precisionAddress->setValue(node.attribute("value").toInt());
  10351. }
  10352. else if(node.attribute("name")=="precision")
  10353. {
  10354. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10355. }
  10356. }
  10357. updateStationNumber(stationNumber->value());
  10358. updateFixedUnit(fixedUnit->isChecked());
  10359. updateFixedDecimal(fixedPrecision->isChecked());
  10360. updateUnit(fixedUnitSelector->currentText());
  10361. updateUnitAddress(unitAddress->value());
  10362. updateValueF(valueF->value());
  10363. updateValueC(valueC->value());
  10364. updatePrecisionAddress(precisionAddress->value());
  10365. updatePrecisionValue(fixedPrecisionValue->value());
  10366. connect(stationNumber,SIGNAL(valueChanged(int)),
  10367. this,SLOT(updateStationNumber(int)));
  10368. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10369. this,SLOT(updateUnit(QString)));
  10370. connect(unitAddress,SIGNAL(valueChanged(int)),
  10371. this,SLOT(updateUnitAddress(int)));
  10372. connect(valueF,SIGNAL(valueChanged(int)),
  10373. this,SLOT(updateValueF(int)));
  10374. connect(valueC,SIGNAL(valueChanged(int)),
  10375. this,SLOT(updateValueC(int)));
  10376. connect(fixedUnit,SIGNAL(toggled(bool)),
  10377. this,SLOT(updateFixedUnit(bool)));
  10378. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10379. this,SLOT(updateFixedDecimal(bool)));
  10380. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10381. this,SLOT(updatePrecisionValue(int)));
  10382. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10383. this,SLOT(updatePrecisionAddress(int)));
  10384. setLayout(layout);
  10385. }
  10386. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10387. {
  10388. updateAttribute("station",QString("%1").arg(newStation));
  10389. }
  10390. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10391. {
  10392. if(newFixed)
  10393. {
  10394. unitSpecificationLayout->setCurrentIndex(0);
  10395. updateAttribute("fixedunit","true");
  10396. }
  10397. else
  10398. {
  10399. unitSpecificationLayout->setCurrentIndex(1);
  10400. updateAttribute("fixedunit","false");
  10401. }
  10402. }
  10403. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10404. {
  10405. if(newFixed)
  10406. {
  10407. decimalSpecificationLayout->setCurrentIndex(0);
  10408. updateAttribute("fixedprecision","true");
  10409. }
  10410. else
  10411. {
  10412. decimalSpecificationLayout->setCurrentIndex(1);
  10413. updateAttribute("fixedprecision","false");
  10414. }
  10415. }
  10416. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10417. {
  10418. updateAttribute("unit",newUnit);
  10419. }
  10420. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10421. {
  10422. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10423. }
  10424. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10425. {
  10426. updateAttribute("fvalue",QString("%1").arg(newValue));
  10427. }
  10428. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10429. {
  10430. updateAttribute("cvalue",QString("%1").arg(newValue));
  10431. }
  10432. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10433. {
  10434. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10435. }
  10436. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10437. {
  10438. updateAttribute("precision",QString("%1").arg(newValue));
  10439. }
  10440. /*:810*/
  10441. #line 594 "./typica.w"
  10442. /*812:*/
  10443. #line 17615 "./typica.w"
  10444. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10445. const QModelIndex&index)
  10446. :BasicDeviceConfigurationWidget(model,index)
  10447. {
  10448. QFormLayout*layout= new QFormLayout;
  10449. ShortHexSpinBox*address= new ShortHexSpinBox;
  10450. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10451. /*771:*/
  10452. #line 16337 "./typica.w"
  10453. QDomElement referenceElement=
  10454. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10455. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10456. QDomElement node;
  10457. /*:771*/
  10458. #line 17623 "./typica.w"
  10459. for(int i= 0;i<configData.size();i++)
  10460. {
  10461. node= configData.at(i).toElement();
  10462. if(node.attribute("name")=="address")
  10463. {
  10464. address->setValue(node.attribute("value").toInt());
  10465. break;
  10466. }
  10467. }
  10468. updateAddress(address->value());
  10469. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10470. setLayout(layout);
  10471. }
  10472. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10473. {
  10474. updateAttribute("address",QString("%1").arg(newAddress));
  10475. }
  10476. /*:812*/
  10477. #line 595 "./typica.w"
  10478. /*814:*/
  10479. #line 17671 "./typica.w"
  10480. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10481. const QModelIndex&index)
  10482. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10483. {
  10484. QVBoxLayout*layout= new QVBoxLayout;
  10485. QFormLayout*addressLayout= new QFormLayout;
  10486. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10487. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10488. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10489. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10490. layout->addLayout(addressLayout);
  10491. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10492. layout->addWidget(fixedRange);
  10493. QWidget*queriedRangePlaceholder= new QWidget(this);
  10494. QFormLayout*queriedRangeLayout= new QFormLayout;
  10495. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10496. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10497. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10498. lowerAddress);
  10499. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10500. upperAddress);
  10501. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10502. boundsLayout->addWidget(queriedRangePlaceholder);
  10503. QWidget*fixedRangePlaceholder= new QWidget(this);
  10504. QFormLayout*fixedRangeLayout= new QFormLayout;
  10505. QLineEdit*fixedLower= new QLineEdit;
  10506. QLineEdit*fixedUpper= new QLineEdit;
  10507. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10508. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10509. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  10510. boundsLayout->addWidget(fixedRangePlaceholder);
  10511. layout->addLayout(boundsLayout);
  10512. /*771:*/
  10513. #line 16337 "./typica.w"
  10514. QDomElement referenceElement=
  10515. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10516. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10517. QDomElement node;
  10518. /*:771*/
  10519. #line 17704 "./typica.w"
  10520. for(int i= 0;i<configData.size();i++)
  10521. {
  10522. node= configData.at(i).toElement();
  10523. if(node.attribute("name")=="readaddress")
  10524. {
  10525. readAddress->setValue(node.attribute("value").toInt());
  10526. }
  10527. else if(node.attribute("name")=="writeaddress")
  10528. {
  10529. writeAddress->setValue(node.attribute("value").toInt());
  10530. }
  10531. else if(node.attribute("name")=="fixedrange")
  10532. {
  10533. if(node.attribute("value")=="true")
  10534. {
  10535. fixedRange->setCheckState(Qt::Checked);
  10536. }
  10537. else if(node.attribute("value")=="false")
  10538. {
  10539. fixedRange->setCheckState(Qt::Unchecked);
  10540. }
  10541. }
  10542. else if(node.attribute("name")=="fixedlower")
  10543. {
  10544. fixedLower->setText(node.attribute("value"));
  10545. }
  10546. else if(node.attribute("name")=="fixedupper")
  10547. {
  10548. fixedUpper->setText(node.attribute("value"));
  10549. }
  10550. else if(node.attribute("name")=="loweraddress")
  10551. {
  10552. lowerAddress->setValue(node.attribute("value").toInt());
  10553. }
  10554. else if(node.attribute("name")=="upperaddress")
  10555. {
  10556. upperAddress->setValue(node.attribute("value").toInt());
  10557. }
  10558. }
  10559. updateReadAddress(readAddress->value());
  10560. updateWriteAddress(writeAddress->value());
  10561. updateFixedRange(fixedRange->isChecked());
  10562. updateLower(fixedLower->text());
  10563. updateUpper(fixedUpper->text());
  10564. updateLowerAddress(lowerAddress->value());
  10565. updateUpperAddress(upperAddress->value());
  10566. connect(readAddress,SIGNAL(valueChanged(int)),
  10567. this,SLOT(updateReadAddress(int)));
  10568. connect(writeAddress,SIGNAL(valueChanged(int)),
  10569. this,SLOT(updateWriteAddress(int)));
  10570. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  10571. connect(fixedLower,SIGNAL(textChanged(QString)),
  10572. this,SLOT(updateLower(QString)));
  10573. connect(fixedUpper,SIGNAL(textChanged(QString)),
  10574. this,SLOT(updateUpper(QString)));
  10575. connect(lowerAddress,SIGNAL(valueChanged(int)),
  10576. this,SLOT(updateLowerAddress(int)));
  10577. connect(upperAddress,SIGNAL(valueChanged(int)),
  10578. this,SLOT(updateUpperAddress(int)));
  10579. setLayout(layout);
  10580. }
  10581. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  10582. {
  10583. updateAttribute("readaddress",QString("%1").arg(newAddress));
  10584. }
  10585. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  10586. {
  10587. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  10588. }
  10589. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  10590. {
  10591. if(fixed)
  10592. {
  10593. updateAttribute("fixedrange","true");
  10594. boundsLayout->setCurrentIndex(1);
  10595. }
  10596. else
  10597. {
  10598. updateAttribute("fixedrange","false");
  10599. boundsLayout->setCurrentIndex(0);
  10600. }
  10601. }
  10602. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  10603. {
  10604. updateAttribute("fixedlower",lower);
  10605. }
  10606. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  10607. {
  10608. updateAttribute("fixedupper",upper);
  10609. }
  10610. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  10611. {
  10612. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  10613. }
  10614. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  10615. {
  10616. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  10617. }
  10618. /*:814*/
  10619. #line 596 "./typica.w"
  10620. /*770:*/
  10621. #line 16207 "./typica.w"
  10622. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10623. :BasicDeviceConfigurationWidget(model,index)
  10624. {
  10625. QVBoxLayout*layout= new QVBoxLayout;
  10626. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  10627. QMenu*deviceMenu= new QMenu;
  10628. NodeInserter*insertAction;
  10629. foreach(insertAction,AppInstance->topLevelNodeInserters)
  10630. {
  10631. connect(insertAction,SIGNAL(triggered(QString,QString)),
  10632. this,SLOT(insertChildNode(QString,QString)));
  10633. deviceMenu->addAction(insertAction);
  10634. }
  10635. addDeviceButton->setMenu(deviceMenu);
  10636. layout->addWidget(addDeviceButton);
  10637. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  10638. QMenu*annotationMenu= new QMenu;
  10639. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  10640. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  10641. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  10642. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  10643. tr("Free Text"),
  10644. "freeannotation");
  10645. annotationMenu->addAction(basicButtonInserter);
  10646. annotationMenu->addAction(countingButtonInserter);
  10647. annotationMenu->addAction(spinBoxInserter);
  10648. annotationMenu->addAction(freeAnnotationInserter);
  10649. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  10650. this,SLOT(insertChildNode(QString,QString)));
  10651. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  10652. this,SLOT(insertChildNode(QString,QString)));
  10653. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  10654. this,SLOT(insertChildNode(QString,QString)));
  10655. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10656. this,SLOT(insertChildNode(QString,QString)));
  10657. /*1045:*/
  10658. #line 144 "./valueannotation.w"
  10659. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  10660. tr("Value Annotation"),
  10661. "valueannotation");
  10662. annotationMenu->addAction(valueAnnotationInserter);
  10663. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10664. this,SLOT(insertChildNode(QString,QString)));
  10665. /*:1045*//*1061:*/
  10666. #line 130 "./thresholdannotation.w"
  10667. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  10668. tr("Threshold Annotation"),
  10669. "thresholdannotation");
  10670. annotationMenu->addAction(thresholdAnnotationInserter);
  10671. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  10672. this,SLOT(insertChildNode(QString,QString)));
  10673. /*:1061*/
  10674. #line 16243 "./typica.w"
  10675. addAnnotationControlButton->setMenu(annotationMenu);
  10676. layout->addWidget(addAnnotationControlButton);
  10677. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  10678. QMenu*timersMenu= new QMenu;
  10679. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  10680. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  10681. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  10682. timersMenu->addAction(coolingTimerInserter);
  10683. timersMenu->addAction(rangeTimerInserter);
  10684. timersMenu->addAction(multirangeTimerInserter);
  10685. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  10686. this,SLOT(insertChildNode(QString,QString)));
  10687. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10688. this,SLOT(insertChildNode(QString,QString)));
  10689. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  10690. this,SLOT(insertChildNode(QString,QString)));
  10691. timersButton->setMenu(timersMenu);
  10692. layout->addWidget(timersButton);
  10693. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  10694. QMenu*advancedMenu= new QMenu;
  10695. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  10696. advancedMenu->addAction(linearsplineinserter);
  10697. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  10698. advancedMenu->addAction(translationinserter);
  10699. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10700. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10701. /*971:*/
  10702. #line 258 "./rate.w"
  10703. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  10704. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  10705. advancedMenu->addAction(rateOfChangeInserter);
  10706. /*:971*/
  10707. #line 16272 "./typica.w"
  10708. advancedButton->setMenu(advancedMenu);
  10709. layout->addWidget(advancedButton);
  10710. QHBoxLayout*idLayout= new QHBoxLayout;
  10711. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  10712. idLayout->addWidget(idLabel);
  10713. QSpinBox*id= new QSpinBox;
  10714. idLayout->addWidget(id);
  10715. idLayout->addStretch();
  10716. layout->addLayout(idLayout);
  10717. QHBoxLayout*capacityLayout= new QHBoxLayout;
  10718. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  10719. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  10720. capacity->setMinimum(0.0);
  10721. capacity->setDecimals(3);
  10722. capacity->setMaximum(999999.999);
  10723. QComboBox*capacityUnit= new QComboBox;
  10724. capacityUnit->addItem("g");
  10725. capacityUnit->addItem("Kg");
  10726. capacityUnit->addItem("oz");
  10727. capacityUnit->addItem("Lb");
  10728. capacityUnit->setCurrentIndex(3);
  10729. capacityLayout->addWidget(capacityCheckEnabled);
  10730. capacityLayout->addWidget(capacity);
  10731. capacityLayout->addWidget(capacityUnit);
  10732. capacityLayout->addStretch();
  10733. layout->addLayout(capacityLayout);
  10734. layout->addStretch();
  10735. /*771:*/
  10736. #line 16337 "./typica.w"
  10737. QDomElement referenceElement=
  10738. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10739. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10740. QDomElement node;
  10741. /*:771*/
  10742. #line 16301 "./typica.w"
  10743. for(int i= 0;i<configData.size();i++)
  10744. {
  10745. node= configData.at(i).toElement();
  10746. if(node.attribute("name")=="databaseid")
  10747. {
  10748. id->setValue(node.attribute("value").toInt());
  10749. }
  10750. else if(node.attribute("name")=="checkcapacity")
  10751. {
  10752. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  10753. }
  10754. else if(node.attribute("name")=="capacity")
  10755. {
  10756. capacity->setValue(node.attribute("value").toDouble());
  10757. }
  10758. else if(node.attribute("name")=="capacityunit")
  10759. {
  10760. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  10761. }
  10762. }
  10763. updateRoasterId(id->value());
  10764. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  10765. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  10766. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  10767. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  10768. setLayout(layout);
  10769. }
  10770. /*:770*//*772:*/
  10771. #line 16347 "./typica.w"
  10772. void RoasterConfWidget::updateRoasterId(int id)
  10773. {
  10774. updateAttribute("databaseid",QString("%1").arg(id));
  10775. }
  10776. void RoasterConfWidget::updateCapacityCheck(int value)
  10777. {
  10778. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  10779. }
  10780. void RoasterConfWidget::updateCapacity(const QString&value)
  10781. {
  10782. updateAttribute("capacity",value);
  10783. }
  10784. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  10785. {
  10786. updateAttribute("capacityunit",value);
  10787. }
  10788. /*:772*/
  10789. #line 597 "./typica.w"
  10790. /*818:*/
  10791. #line 17854 "./typica.w"
  10792. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10793. :BasicDeviceConfigurationWidget(model,index)
  10794. {
  10795. QFormLayout*layout= new QFormLayout;
  10796. QLineEdit*buttonTextEdit= new QLineEdit;
  10797. QLineEdit*annotationTextEdit= new QLineEdit;
  10798. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10799. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10800. /*771:*/
  10801. #line 16337 "./typica.w"
  10802. QDomElement referenceElement=
  10803. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10804. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10805. QDomElement node;
  10806. /*:771*/
  10807. #line 17863 "./typica.w"
  10808. for(int i= 0;i<configData.size();i++)
  10809. {
  10810. node= configData.at(i).toElement();
  10811. if(node.attribute("name")=="buttontext")
  10812. {
  10813. buttonTextEdit->setText(node.attribute("value"));
  10814. }
  10815. else if(node.attribute("name")=="annotationtext")
  10816. {
  10817. annotationTextEdit->setText(node.attribute("value"));
  10818. }
  10819. }
  10820. updateButtonText(buttonTextEdit->text());
  10821. updateAnnotationText(annotationTextEdit->text());
  10822. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10823. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10824. setLayout(layout);
  10825. }
  10826. /*:818*//*819:*/
  10827. #line 17885 "./typica.w"
  10828. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  10829. {
  10830. updateAttribute("buttontext",text);
  10831. }
  10832. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10833. {
  10834. updateAttribute("annotationtext",text);
  10835. }
  10836. /*:819*//*822:*/
  10837. #line 17923 "./typica.w"
  10838. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10839. :BasicDeviceConfigurationWidget(model,index)
  10840. {
  10841. QFormLayout*layout= new QFormLayout;
  10842. QLineEdit*buttonTextEdit= new QLineEdit;
  10843. QLineEdit*annotationTextEdit= new QLineEdit;
  10844. layout->addRow(tr("Button Text:"),buttonTextEdit);
  10845. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  10846. /*771:*/
  10847. #line 16337 "./typica.w"
  10848. QDomElement referenceElement=
  10849. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10850. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10851. QDomElement node;
  10852. /*:771*/
  10853. #line 17932 "./typica.w"
  10854. for(int i= 0;i<configData.size();i++)
  10855. {
  10856. node= configData.at(i).toElement();
  10857. if(node.attribute("name")=="buttontext")
  10858. {
  10859. buttonTextEdit->setText(node.attribute("value"));
  10860. }
  10861. else if(node.attribute("name")=="annotationtext")
  10862. {
  10863. annotationTextEdit->setText(node.attribute("value"));
  10864. }
  10865. }
  10866. updateButtonText(buttonTextEdit->text());
  10867. updateAnnotationText(annotationTextEdit->text());
  10868. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  10869. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  10870. QTextEdit*documentation= new QTextEdit;
  10871. 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."));
  10872. documentation->setReadOnly(true);
  10873. layout->addRow("",documentation);
  10874. setLayout(layout);
  10875. }
  10876. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  10877. {
  10878. updateAttribute("buttontext",text);
  10879. }
  10880. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  10881. {
  10882. updateAttribute("annotationtext",text);
  10883. }
  10884. /*:822*/
  10885. #line 598 "./typica.w"
  10886. /*825:*/
  10887. #line 18000 "./typica.w"
  10888. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  10889. :BasicDeviceConfigurationWidget(model,index)
  10890. {
  10891. QFormLayout*layout= new QFormLayout;
  10892. QLineEdit*labelEdit= new QLineEdit;
  10893. layout->addRow(tr("Control Label: "),labelEdit);
  10894. QLineEdit*minimumEdit= new QLineEdit;
  10895. layout->addRow(tr("Minimum Value: "),minimumEdit);
  10896. QLineEdit*maximumEdit= new QLineEdit;
  10897. layout->addRow(tr("Maximum Value: "),maximumEdit);
  10898. QSpinBox*precisionEdit= new QSpinBox;
  10899. precisionEdit->setMinimum(0);
  10900. precisionEdit->setMaximum(9);
  10901. layout->addRow(tr("Precision"),precisionEdit);
  10902. QLineEdit*pretext= new QLineEdit;
  10903. layout->addRow(tr("Prefix text"),pretext);
  10904. QLineEdit*posttext= new QLineEdit;
  10905. layout->addRow(tr("Suffix text"),posttext);
  10906. /*771:*/
  10907. #line 16337 "./typica.w"
  10908. QDomElement referenceElement=
  10909. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10910. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10911. QDomElement node;
  10912. /*:771*/
  10913. #line 18019 "./typica.w"
  10914. for(int i= 0;i<configData.size();i++)
  10915. {
  10916. node= configData.at(i).toElement();
  10917. if(node.attribute("name")=="label")
  10918. {
  10919. labelEdit->setText(node.attribute("value"));
  10920. }
  10921. else if(node.attribute("name")=="minimum")
  10922. {
  10923. minimumEdit->setText(node.attribute("value"));
  10924. }
  10925. else if(node.attribute("name")=="maximum")
  10926. {
  10927. maximumEdit->setText(node.attribute("value"));
  10928. }
  10929. else if(node.attribute("name")=="precision")
  10930. {
  10931. precisionEdit->setValue(node.attribute("value").toInt());
  10932. }
  10933. else if(node.attribute("name")=="pretext")
  10934. {
  10935. pretext->setText(node.attribute("value"));
  10936. }
  10937. else if(node.attribute("name")=="posttext")
  10938. {
  10939. posttext->setText(node.attribute("value"));
  10940. }
  10941. }
  10942. updateLabel(labelEdit->text());
  10943. updateMinimum(minimumEdit->text());
  10944. updateMaximum(maximumEdit->text());
  10945. updatePrecision(precisionEdit->value());
  10946. updatePretext(pretext->text());
  10947. updatePosttext(posttext->text());
  10948. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  10949. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  10950. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  10951. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  10952. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  10953. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  10954. setLayout(layout);
  10955. }
  10956. void NoteSpinConfWidget::updateLabel(const QString&text)
  10957. {
  10958. updateAttribute("label",text);
  10959. }
  10960. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  10961. {
  10962. updateAttribute("minimum",minimum);
  10963. }
  10964. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  10965. {
  10966. updateAttribute("maximum",maximum);
  10967. }
  10968. void NoteSpinConfWidget::updatePrecision(int precision)
  10969. {
  10970. updateAttribute("precision",QString("%1").arg(precision));
  10971. }
  10972. void NoteSpinConfWidget::updatePretext(const QString&text)
  10973. {
  10974. updateAttribute("pretext",text);
  10975. }
  10976. void NoteSpinConfWidget::updatePosttext(const QString&text)
  10977. {
  10978. updateAttribute("posttext",text);
  10979. }
  10980. /*:825*/
  10981. #line 599 "./typica.w"
  10982. /*334:*/
  10983. #line 7549 "./typica.w"
  10984. LinearCalibrator::LinearCalibrator(QObject*parent):
  10985. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  10986. {
  10987. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  10988. }
  10989. /*:334*//*335:*/
  10990. #line 7563 "./typica.w"
  10991. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  10992. {
  10993. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  10994. if(clamp)
  10995. {
  10996. if(outval<Lo1)
  10997. {
  10998. outval= Lo1;
  10999. }
  11000. else if(outval> Up1)
  11001. {
  11002. outval= Up1;
  11003. }
  11004. }
  11005. if(sensitivitySetting>=0.05)
  11006. {
  11007. int temp= qRound(outval/sensitivitySetting);
  11008. outval= temp*sensitivitySetting;
  11009. }
  11010. Measurement adjusted(outval,measure.time(),measure.scale());
  11011. emit measurement(adjusted);
  11012. return adjusted;
  11013. }
  11014. /*:335*//*336:*/
  11015. #line 7590 "./typica.w"
  11016. double LinearCalibrator::measuredLower()
  11017. {
  11018. return Lo2;
  11019. }
  11020. double LinearCalibrator::measuredUpper()
  11021. {
  11022. return Up2;
  11023. }
  11024. double LinearCalibrator::mappedLower()
  11025. {
  11026. return Lo1;
  11027. }
  11028. double LinearCalibrator::mappedUpper()
  11029. {
  11030. return Up1;
  11031. }
  11032. bool LinearCalibrator::isClosedRange()
  11033. {
  11034. return clamp;
  11035. }
  11036. void LinearCalibrator::setMeasuredLower(double lower)
  11037. {
  11038. Lo2= lower;
  11039. }
  11040. void LinearCalibrator::setMeasuredUpper(double upper)
  11041. {
  11042. Up2= upper;
  11043. }
  11044. void LinearCalibrator::setMappedLower(double lower)
  11045. {
  11046. Lo1= lower;
  11047. }
  11048. void LinearCalibrator::setMappedUpper(double upper)
  11049. {
  11050. Up1= upper;
  11051. }
  11052. void LinearCalibrator::setClosedRange(bool closed)
  11053. {
  11054. clamp= closed;
  11055. }
  11056. void LinearCalibrator::setSensitivity(double sensitivity)
  11057. {
  11058. sensitivitySetting= sensitivity;
  11059. }
  11060. double LinearCalibrator::sensitivity()
  11061. {
  11062. return sensitivitySetting;
  11063. }
  11064. /*:336*/
  11065. #line 600 "./typica.w"
  11066. /*341:*/
  11067. #line 7723 "./typica.w"
  11068. void LinearSplineInterpolator::add_pair(double source,double destination)
  11069. {
  11070. pairs->insert(source,destination);
  11071. make_interpolators();
  11072. }
  11073. void LinearSplineInterpolator::make_interpolators()
  11074. {
  11075. if(pairs->size()> 1)
  11076. {
  11077. while(interpolators->size()> 0)
  11078. {
  11079. LinearCalibrator*removed= interpolators->takeFirst();
  11080. removed->deleteLater();
  11081. }
  11082. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11083. QMap<double,double> ::const_iterator j= i+1;
  11084. while(j!=pairs->constEnd())
  11085. {
  11086. LinearCalibrator*segment= new LinearCalibrator();
  11087. segment->setMeasuredLower(i.key());
  11088. segment->setMappedLower(i.value());
  11089. segment->setMeasuredUpper(j.key());
  11090. segment->setMappedUpper(j.value());
  11091. segment->setClosedRange(false);
  11092. interpolators->append(segment);
  11093. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11094. i++;
  11095. j++;
  11096. }
  11097. }
  11098. }
  11099. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11100. QObject(parent),pairs(new QMap<double,double> ),
  11101. interpolators(new QList<LinearCalibrator*> )
  11102. {
  11103. }
  11104. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11105. {
  11106. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11107. int index= -1;
  11108. while(i!=pairs->constEnd())
  11109. {
  11110. if(measure.temperature()<=i.key())
  11111. {
  11112. break;
  11113. }
  11114. i++;
  11115. index++;
  11116. }
  11117. if(index<0)
  11118. {
  11119. index= 0;
  11120. }
  11121. if(index>=interpolators->size())
  11122. {
  11123. index= interpolators->size()-1;
  11124. }
  11125. if(interpolators->at(index)!=NULL)
  11126. {
  11127. return interpolators->at(index)->newMeasurement(measure);
  11128. }
  11129. return Measurement();
  11130. }
  11131. /*:341*/
  11132. #line 601 "./typica.w"
  11133. /*936:*/
  11134. #line 19370 "./typica.w"
  11135. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11136. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11137. {
  11138. QFormLayout*layout= new QFormLayout;
  11139. QLineEdit*source= new QLineEdit;
  11140. layout->addRow(tr("Source column name:"),source);
  11141. QLineEdit*destination= new QLineEdit;
  11142. layout->addRow(tr("Destination column name:"),destination);
  11143. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11144. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11145. QTableView*mappingTable= new QTableView;
  11146. mappingTable->setModel(tablemodel);
  11147. NumericDelegate*delegate= new NumericDelegate;
  11148. mappingTable->setItemDelegate(delegate);
  11149. layout->addRow(tr("Mapping data:"),mappingTable);
  11150. /*771:*/
  11151. #line 16337 "./typica.w"
  11152. QDomElement referenceElement=
  11153. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11154. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11155. QDomElement node;
  11156. /*:771*/
  11157. #line 19386 "./typica.w"
  11158. for(int i= 0;i<configData.size();i++)
  11159. {
  11160. node= configData.at(i).toElement();
  11161. if(node.attribute("name")=="source")
  11162. {
  11163. source->setText(node.attribute("value"));
  11164. }
  11165. else if(node.attribute("name")=="destination")
  11166. {
  11167. destination->setText(node.attribute("value"));
  11168. }
  11169. else if(node.attribute("name")=="sourcevalues")
  11170. {
  11171. /*937:*/
  11172. #line 19425 "./typica.w"
  11173. QString data= node.attribute("value");
  11174. if(data.length()> 3)
  11175. {
  11176. data.chop(2);
  11177. data= data.remove(0,2);
  11178. }
  11179. QStringList itemList= data.split(",");
  11180. /*:937*/
  11181. #line 19400 "./typica.w"
  11182. int column= 0;
  11183. /*938:*/
  11184. #line 19437 "./typica.w"
  11185. for(int j= 0;j<itemList.size();j++)
  11186. {
  11187. tablemodel->setData(tablemodel->index(j,column),
  11188. QVariant(itemList.at(j).toDouble()),
  11189. Qt::DisplayRole);
  11190. }
  11191. /*:938*/
  11192. #line 19402 "./typica.w"
  11193. }
  11194. else if(node.attribute("name")=="destinationvalues")
  11195. {
  11196. /*937:*/
  11197. #line 19425 "./typica.w"
  11198. QString data= node.attribute("value");
  11199. if(data.length()> 3)
  11200. {
  11201. data.chop(2);
  11202. data= data.remove(0,2);
  11203. }
  11204. QStringList itemList= data.split(",");
  11205. /*:937*/
  11206. #line 19407 "./typica.w"
  11207. int column= 1;
  11208. /*938:*/
  11209. #line 19437 "./typica.w"
  11210. for(int j= 0;j<itemList.size();j++)
  11211. {
  11212. tablemodel->setData(tablemodel->index(j,column),
  11213. QVariant(itemList.at(j).toDouble()),
  11214. Qt::DisplayRole);
  11215. }
  11216. /*:938*/
  11217. #line 19409 "./typica.w"
  11218. }
  11219. }
  11220. updateSourceColumn(source->text());
  11221. updateDestinationColumn(destination->text());
  11222. updateKnots();
  11223. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11224. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11225. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11226. setLayout(layout);
  11227. }
  11228. /*:936*//*939:*/
  11229. #line 19448 "./typica.w"
  11230. void LinearSplineInterpolationConfWidget::updateKnots()
  11231. {
  11232. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11233. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11234. }
  11235. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11236. {
  11237. updateAttribute("source",source);
  11238. }
  11239. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11240. {
  11241. updateAttribute("destination",dest);
  11242. }
  11243. /*:939*/
  11244. #line 602 "./typica.w"
  11245. /*956:*/
  11246. #line 19917 "./typica.w"
  11247. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11248. :BasicDeviceConfigurationWidget(model,index),
  11249. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  11250. {
  11251. unitSelector->addItem("Fahrenheit");
  11252. unitSelector->addItem("Celsius");
  11253. temperatureValue->setMinimum(0);
  11254. temperatureValue->setMaximum(1000);
  11255. QFormLayout*layout= new QFormLayout;
  11256. QLineEdit*column= new QLineEdit;
  11257. layout->addRow(tr("Column to match:"),column);
  11258. layout->addRow(tr("Unit:"),unitSelector);
  11259. layout->addRow(tr("Value:"),temperatureValue);
  11260. /*771:*/
  11261. #line 16337 "./typica.w"
  11262. QDomElement referenceElement=
  11263. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11264. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11265. QDomElement node;
  11266. /*:771*/
  11267. #line 19931 "./typica.w"
  11268. for(int i= 0;i<configData.size();i++)
  11269. {
  11270. node= configData.at(i).toElement();
  11271. if(node.attribute("name")=="column")
  11272. {
  11273. column->setText(node.attribute("value"));
  11274. }
  11275. else if(node.attribute("name")=="unit")
  11276. {
  11277. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11278. }
  11279. else if(node.attribute("name")=="value")
  11280. {
  11281. temperatureValue->setValue(node.attribute("value").toDouble());
  11282. }
  11283. }
  11284. updateMatchingColumn(column->text());
  11285. updateTemperature();
  11286. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11287. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11288. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11289. setLayout(layout);
  11290. }
  11291. /*:956*//*957:*/
  11292. #line 19960 "./typica.w"
  11293. void TranslationConfWidget::updateTemperature()
  11294. {
  11295. updateAttribute("unit",unitSelector->currentText());
  11296. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11297. if(unitSelector->currentText()=="Fahrenheit")
  11298. {
  11299. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11300. }
  11301. else
  11302. {
  11303. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11304. }
  11305. }
  11306. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11307. {
  11308. updateAttribute("column",column);
  11309. }
  11310. /*:957*/
  11311. #line 603 "./typica.w"
  11312. /*828:*/
  11313. #line 24 "./freeannotation.w"
  11314. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11315. const QModelIndex&index)
  11316. :BasicDeviceConfigurationWidget(model,index)
  11317. {
  11318. QFormLayout*layout= new QFormLayout;
  11319. QLineEdit*labelEdit= new QLineEdit;
  11320. layout->addRow(tr("Label Text:"),labelEdit);
  11321. /*771:*/
  11322. #line 16337 "./typica.w"
  11323. QDomElement referenceElement=
  11324. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11325. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11326. QDomElement node;
  11327. /*:771*/
  11328. #line 32 "./freeannotation.w"
  11329. for(int i= 0;i<configData.size();i++)
  11330. {
  11331. node= configData.at(i).toElement();
  11332. if(node.attribute("name")=="labeltext")
  11333. {
  11334. labelEdit->setText(node.attribute("value"));
  11335. }
  11336. }
  11337. updateLabel(labelEdit->text());
  11338. connect(labelEdit,SIGNAL(textEdited(QString)),
  11339. this,SLOT(updateLabel(QString)));
  11340. setLayout(layout);
  11341. }
  11342. /*:828*//*829:*/
  11343. #line 49 "./freeannotation.w"
  11344. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11345. {
  11346. updateAttribute("labeltext",text);
  11347. }
  11348. /*:829*/
  11349. #line 604 "./typica.w"
  11350. /*960:*/
  11351. #line 39 "./rate.w"
  11352. void RateOfChange::newMeasurement(Measurement measure)
  11353. {
  11354. cache.append(measure);
  11355. /*961:*/
  11356. #line 64 "./rate.w"
  11357. if(cache.size()> 2)
  11358. {
  11359. bool done= false;
  11360. while(!done)
  11361. {
  11362. if(cache.front().time().secsTo(cache.back().time())> ct)
  11363. {
  11364. cache.removeFirst();
  11365. }
  11366. else if(cache.back().time()<cache.front().time())
  11367. {
  11368. cache.removeFirst();
  11369. done= true;
  11370. }
  11371. else
  11372. {
  11373. done= true;
  11374. }
  11375. if(cache.size()<3)
  11376. {
  11377. done= true;
  11378. }
  11379. }
  11380. }
  11381. /*:961*/
  11382. #line 43 "./rate.w"
  11383. if(cache.size()>=2)
  11384. {
  11385. /*962:*/
  11386. #line 96 "./rate.w"
  11387. int N= cache.size();
  11388. double SXY= 0;
  11389. double SX= 0;
  11390. double SXX= 0;
  11391. double SY= 0;
  11392. double y;
  11393. double x;
  11394. for(int i= 0;i<N;i++)
  11395. {
  11396. y= cache.at(i).temperature();
  11397. SY+= y;
  11398. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11399. SX+= x;
  11400. SXX+= (x*x);
  11401. SXY+= (x*y);
  11402. }
  11403. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11404. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11405. value.insert("relative",true);
  11406. emit newData(value);
  11407. /*:962*/
  11408. #line 46 "./rate.w"
  11409. }
  11410. }
  11411. /*:960*//*963:*/
  11412. #line 120 "./rate.w"
  11413. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11414. {
  11415. setScaleTime(scaletime);
  11416. }
  11417. void RateOfChange::setCacheTime(int seconds)
  11418. {
  11419. ct= seconds;
  11420. }
  11421. void RateOfChange::setScaleTime(int seconds)
  11422. {
  11423. st= (seconds> 0?seconds:1);
  11424. }
  11425. /*:963*/
  11426. #line 605 "./typica.w"
  11427. /*832:*/
  11428. #line 26 "./settings.w"
  11429. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11430. {
  11431. QTabWidget*settingsTab= new QTabWidget;
  11432. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11433. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11434. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11435. settingsTab->addTab(graphSettings,tr("Graph"));
  11436. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11437. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11438. setCentralWidget(settingsTab);
  11439. }
  11440. /*:832*/
  11441. #line 606 "./typica.w"
  11442. /*837:*/
  11443. #line 27 "./graphsettings.w"
  11444. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11445. {
  11446. QTabWidget*graphCategories= new QTabWidget;
  11447. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11448. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11449. QVBoxLayout*layout= new QVBoxLayout;
  11450. layout->addWidget(graphCategories);
  11451. setLayout(layout);
  11452. }
  11453. /*:837*//*839:*/
  11454. #line 65 "./graphsettings.w"
  11455. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11456. colorEdit(new QLineEdit)
  11457. {
  11458. QSettings settings;
  11459. QVBoxLayout*layout= new QVBoxLayout;
  11460. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11461. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11462. updateEnableSetting(enable->isChecked());
  11463. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11464. layout->addWidget(enable);
  11465. QHBoxLayout*colorLayout= new QHBoxLayout;
  11466. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11467. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11468. updateColorSetting(colorEdit->text());
  11469. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11470. QToolButton*colorPickerButton= new QToolButton();
  11471. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11472. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11473. colorLayout->addWidget(colorLabel);
  11474. colorLayout->addWidget(colorEdit);
  11475. colorLayout->addWidget(colorPickerButton);
  11476. colorLayout->addStretch();
  11477. layout->addLayout(colorLayout);
  11478. QHBoxLayout*unitLayout= new QHBoxLayout;
  11479. QLabel*unitLabel= new QLabel(tr("Unit"));
  11480. QComboBox*unitSelector= new QComboBox;
  11481. unitSelector->addItem(tr("Fahrenheit"));
  11482. unitSelector->addItem(tr("Celsius"));
  11483. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11484. updateUnit(unitSelector->currentIndex());
  11485. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11486. unitLayout->addWidget(unitLabel);
  11487. unitLayout->addWidget(unitSelector);
  11488. unitLayout->addStretch();
  11489. layout->addLayout(unitLayout);
  11490. QHBoxLayout*axisLayout= new QHBoxLayout;
  11491. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  11492. QLineEdit*axisEdit= new QLineEdit;
  11493. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, -10, 0, 10, 30, 50").toString());
  11494. updateAxisSetting(axisEdit->text());
  11495. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  11496. axisLayout->addWidget(axisLabel);
  11497. axisLayout->addWidget(axisEdit);
  11498. layout->addLayout(axisLayout);
  11499. layout->addStretch();
  11500. setLayout(layout);
  11501. }
  11502. /*:839*//*840:*/
  11503. #line 116 "./graphsettings.w"
  11504. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  11505. {
  11506. QSettings settings;
  11507. settings.setValue("settings/graph/relative/enable",enabled);
  11508. }
  11509. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  11510. {
  11511. QSettings settings;
  11512. settings.setValue("settings/graph/relative/color",color);
  11513. }
  11514. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  11515. {
  11516. QSettings settings;
  11517. QString settingValue;
  11518. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  11519. QStringList numbers;
  11520. foreach(QString text,points)
  11521. {
  11522. bool okay= false;
  11523. text.toDouble(&okay);
  11524. if(okay)
  11525. {
  11526. numbers.append(text);
  11527. }
  11528. }
  11529. numbers.removeDuplicates();
  11530. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  11531. }
  11532. void GraphSettingsRelativeTab::updateUnit(int unit)
  11533. {
  11534. QSettings settings;
  11535. settings.setValue("settings/graph/relative/unit",unit);
  11536. }
  11537. /*:840*//*841:*/
  11538. #line 159 "./graphsettings.w"
  11539. void GraphSettingsRelativeTab::showColorPicker()
  11540. {
  11541. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  11542. colorEdit->setText(color.name());
  11543. }
  11544. #line 62 "./settings.w"
  11545. #line 1 "./advancedsettings.w"
  11546. /*:841*/
  11547. #line 607 "./typica.w"
  11548. /*995:*/
  11549. #line 682 "./dataqsdk.w"
  11550. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  11551. const QModelIndex&index)
  11552. :BasicDeviceConfigurationWidget(model,index),
  11553. deviceIdStack(new QStackedWidget)
  11554. {
  11555. QVBoxLayout*layout= new QVBoxLayout;
  11556. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  11557. layout->addWidget(autoDetect);
  11558. QWidget*autoLayerWidget= new QWidget;
  11559. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  11560. QLabel*autoLabel= new QLabel(tr("Device number"));
  11561. QSpinBox*autoNumber= new QSpinBox;
  11562. autoNumber->setMinimum(1);
  11563. autoNumber->setMaximum(99);
  11564. autoLayerLayout->addWidget(autoLabel);
  11565. autoLayerLayout->addWidget(autoNumber);
  11566. autoLayerWidget->setLayout(autoLayerLayout);
  11567. QWidget*fixedLayerWidget= new QWidget;
  11568. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  11569. QLabel*fixedLabel= new QLabel(tr("Device port"));
  11570. QComboBox*portSelection= new QComboBox;
  11571. portSelection->setEditable(true);
  11572. portSelection->addItems(DataqSdkDevice::detectHardware());
  11573. fixedLayerLayout->addWidget(fixedLabel);
  11574. fixedLayerLayout->addWidget(portSelection);
  11575. fixedLayerWidget->setLayout(fixedLayerLayout);
  11576. deviceIdStack->addWidget(autoLayerWidget);
  11577. deviceIdStack->addWidget(fixedLayerWidget);
  11578. layout->addWidget(deviceIdStack);
  11579. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  11580. layout->addWidget(addChannelButton);
  11581. /*771:*/
  11582. #line 16337 "./typica.w"
  11583. QDomElement referenceElement=
  11584. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11585. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11586. QDomElement node;
  11587. /*:771*/
  11588. #line 714 "./dataqsdk.w"
  11589. for(int i= 0;i<configData.size();i++)
  11590. {
  11591. node= configData.at(i).toElement();
  11592. if(node.attribute("name")=="autoSelect")
  11593. {
  11594. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  11595. }
  11596. else if(node.attribute("name")=="deviceNumber")
  11597. {
  11598. autoNumber->setValue(node.attribute("value").toInt());
  11599. }
  11600. else if(node.attribute("name")=="port")
  11601. {
  11602. int index= portSelection->findText(node.attribute("value"));
  11603. if(index> -1)
  11604. {
  11605. portSelection->setCurrentIndex(index);
  11606. }
  11607. else
  11608. {
  11609. portSelection->setEditText(node.attribute("value"));
  11610. }
  11611. }
  11612. }
  11613. updateAutoSelect(autoDetect->isChecked());
  11614. updateDeviceNumber(autoNumber->value());
  11615. updatePort(portSelection->currentText());
  11616. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  11617. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  11618. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  11619. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  11620. setLayout(layout);
  11621. }
  11622. /*:995*//*996:*/
  11623. #line 758 "./dataqsdk.w"
  11624. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  11625. {
  11626. if(automatic)
  11627. {
  11628. updateAttribute("autoSelect","true");
  11629. deviceIdStack->setCurrentIndex(0);
  11630. }
  11631. else
  11632. {
  11633. updateAttribute("autoSelect","false");
  11634. deviceIdStack->setCurrentIndex(1);
  11635. }
  11636. }
  11637. /*:996*//*997:*/
  11638. #line 775 "./dataqsdk.w"
  11639. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  11640. {
  11641. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  11642. }
  11643. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  11644. {
  11645. updateAttribute("port",portId);
  11646. }
  11647. /*:997*//*998:*/
  11648. #line 788 "./dataqsdk.w"
  11649. void DataqSdkDeviceConfWidget::addChannel()
  11650. {
  11651. insertChildNode(tr("Channel"),"dataqsdkchannel");
  11652. }
  11653. /*:998*//*1001:*/
  11654. #line 868 "./dataqsdk.w"
  11655. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  11656. const QModelIndex&index)
  11657. :BasicDeviceConfigurationWidget(model,index),
  11658. startButton(new QPushButton(tr("Start"))),
  11659. resetButton(new QPushButton(tr("Reset"))),
  11660. stopButton(new QPushButton(tr("Stop"))),
  11661. calibrator(new LinearCalibrator),
  11662. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  11663. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  11664. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  11665. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  11666. rmCount(0),cmCount(0),
  11667. rmin(std::numeric_limits<double> ::max()),
  11668. rmax(std::numeric_limits<double> ::min()),rmean(0),
  11669. cmin(std::numeric_limits<double> ::max()),
  11670. cmax(std::numeric_limits<double> ::min()),cmean(0)
  11671. {
  11672. /*1005:*/
  11673. #line 1107 "./dataqsdk.w"
  11674. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  11675. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  11676. QDomElement deviceNode;
  11677. QString configPort;
  11678. QString configAuto;
  11679. for(int i= 0;i<deviceConfigData.size();i++)
  11680. {
  11681. deviceNode= deviceConfigData.at(i).toElement();
  11682. if(deviceNode.attribute("name")=="autoSelect")
  11683. {
  11684. autoSelect= (deviceNode.attribute("value")=="true");
  11685. }
  11686. else if(deviceNode.attribute("name")=="deviceNumber")
  11687. {
  11688. configAuto= deviceNode.attribute("value");
  11689. }
  11690. else if(deviceNode.attribute("name")=="port")
  11691. {
  11692. configPort= deviceNode.attribute("value");
  11693. }
  11694. }
  11695. deviceID= autoSelect?configAuto:configPort;
  11696. channelOfInterest= index.row();
  11697. /*:1005*/
  11698. #line 886 "./dataqsdk.w"
  11699. resetButton->setEnabled(false);
  11700. stopButton->setEnabled(false);
  11701. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  11702. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  11703. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  11704. QVBoxLayout*layout= new QVBoxLayout;
  11705. QFormLayout*topLayout= new QFormLayout;
  11706. QLineEdit*columnEdit= new QLineEdit;
  11707. topLayout->addRow(tr("Column name"),columnEdit);
  11708. QComboBox*unitSelector= new QComboBox;
  11709. unitSelector->addItem(tr("Temperature"));
  11710. unitSelector->addItem(tr("Control"));
  11711. topLayout->addRow(tr("Measurement type"),unitSelector);
  11712. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  11713. topLayout->addRow(smoothingBox);
  11714. layout->addLayout(topLayout);
  11715. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  11716. topLayout->addRow(hideSeries);
  11717. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  11718. layout->addWidget(calibrationLabel);
  11719. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  11720. QFormLayout*calibrationControlsLayout= new QFormLayout;
  11721. QLineEdit*measuredLowerEdit= new QLineEdit;
  11722. measuredLowerEdit->setText("0");
  11723. QLineEdit*measuredUpperEdit= new QLineEdit;
  11724. measuredUpperEdit->setText("10");
  11725. QLineEdit*mappedLowerEdit= new QLineEdit;
  11726. mappedLowerEdit->setText("0");
  11727. QLineEdit*mappedUpperEdit= new QLineEdit;
  11728. mappedUpperEdit->setText("10");
  11729. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  11730. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  11731. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  11732. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  11733. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  11734. calibrationControlsLayout->addRow(closedBox);
  11735. QLineEdit*sensitivityEdit= new QLineEdit;
  11736. sensitivityEdit->setText("0");
  11737. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  11738. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  11739. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  11740. deviceControlLayout->addWidget(startButton);
  11741. deviceControlLayout->addWidget(resetButton);
  11742. deviceControlLayout->addWidget(stopButton);
  11743. QFormLayout*indicatorLayout= new QFormLayout;
  11744. currentMeasurement->setReadOnly(true);
  11745. minimumMeasurement->setReadOnly(true);
  11746. maximumMeasurement->setReadOnly(true);
  11747. averageMeasurement->setReadOnly(true);
  11748. currentMapped->setReadOnly(true);
  11749. minimumMapped->setReadOnly(true);
  11750. maximumMapped->setReadOnly(true);
  11751. averageMapped->setReadOnly(true);
  11752. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  11753. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  11754. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  11755. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  11756. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  11757. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  11758. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  11759. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  11760. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  11761. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  11762. calibrationTestLayout->addLayout(deviceControlLayout);
  11763. calibrationTestLayout->addLayout(indicatorLayout);
  11764. calibrationLayout->addLayout(calibrationControlsLayout);
  11765. calibrationLayout->addLayout(calibrationTestLayout);
  11766. layout->addLayout(calibrationLayout);
  11767. /*771:*/
  11768. #line 16337 "./typica.w"
  11769. QDomElement referenceElement=
  11770. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11771. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11772. QDomElement node;
  11773. /*:771*/
  11774. #line 955 "./dataqsdk.w"
  11775. for(int i= 0;i<configData.size();i++)
  11776. {
  11777. node= configData.at(i).toElement();
  11778. if(node.attribute("name")=="column")
  11779. {
  11780. columnEdit->setText(node.attribute("value"));
  11781. }
  11782. else if(node.attribute("name")=="type")
  11783. {
  11784. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11785. }
  11786. else if(node.attribute("name")=="smoothing")
  11787. {
  11788. smoothingBox->setChecked(node.attribute("value")=="true");
  11789. }
  11790. else if(node.attribute("name")=="calibrationMeasuredLower")
  11791. {
  11792. measuredLowerEdit->setText(node.attribute("value"));
  11793. }
  11794. else if(node.attribute("name")=="calibrationMeasuredUpper")
  11795. {
  11796. measuredUpperEdit->setText(node.attribute("value"));
  11797. }
  11798. else if(node.attribute("name")=="calibrationMappedLower")
  11799. {
  11800. mappedLowerEdit->setText(node.attribute("value"));
  11801. }
  11802. else if(node.attribute("name")=="calibrationMappedUpper")
  11803. {
  11804. mappedUpperEdit->setText(node.attribute("value"));
  11805. }
  11806. else if(node.attribute("name")=="calibrationClosedInterval")
  11807. {
  11808. closedBox->setChecked(node.attribute("value")=="true");
  11809. }
  11810. else if(node.attribute("name")=="calibrationSensitivity")
  11811. {
  11812. sensitivityEdit->setText(node.attribute("value"));
  11813. }
  11814. else if(node.attribute("name")=="hidden")
  11815. {
  11816. hideSeries->setChecked(node.attribute("value")=="true");
  11817. }
  11818. }
  11819. updateColumnName(columnEdit->text());
  11820. updateUnits(unitSelector->currentText());
  11821. updateSmoothingEnabled(smoothingBox->isChecked());
  11822. updateMeasuredLower(measuredLowerEdit->text());
  11823. updateMeasuredUpper(measuredUpperEdit->text());
  11824. updateMappedLower(mappedLowerEdit->text());
  11825. updateMappedUpper(mappedUpperEdit->text());
  11826. updateClosedInterval(closedBox->isChecked());
  11827. updateSensitivity(sensitivityEdit->text());
  11828. updateHidden(hideSeries->isChecked());
  11829. connect(columnEdit,SIGNAL(textChanged(QString)),
  11830. this,SLOT(updateColumnName(QString)));
  11831. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  11832. this,SLOT(updateUnits(QString)));
  11833. connect(smoothingBox,SIGNAL(toggled(bool)),
  11834. this,SLOT(updateSmoothingEnabled(bool)));
  11835. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  11836. this,SLOT(updateMeasuredLower(QString)));
  11837. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  11838. this,SLOT(updateMappedLower(QString)));
  11839. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  11840. this,SLOT(updateMeasuredUpper(QString)));
  11841. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  11842. this,SLOT(updateMappedUpper(QString)));
  11843. connect(closedBox,SIGNAL(toggled(bool)),
  11844. this,SLOT(updateClosedInterval(bool)));
  11845. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  11846. this,SLOT(updateSensitivity(QString)));
  11847. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  11848. setLayout(layout);
  11849. }
  11850. /*:1001*//*1002:*/
  11851. #line 1038 "./dataqsdk.w"
  11852. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  11853. {
  11854. updateAttribute("type",unit);
  11855. }
  11856. /*:1002*//*1003:*/
  11857. #line 1047 "./dataqsdk.w"
  11858. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  11859. {
  11860. updateAttribute("calibrationMeasuredLower",value);
  11861. calibrator->setMeasuredLower(value.toDouble());
  11862. }
  11863. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  11864. {
  11865. updateAttribute("calibrationMeasuredUpper",value);
  11866. calibrator->setMeasuredUpper(value.toDouble());
  11867. }
  11868. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  11869. {
  11870. updateAttribute("calibrationMappedLower",value);
  11871. calibrator->setMappedLower(value.toDouble());
  11872. }
  11873. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  11874. {
  11875. updateAttribute("calibrationMappedUpper",value);
  11876. calibrator->setMappedUpper(value.toDouble());
  11877. }
  11878. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  11879. {
  11880. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  11881. calibrator->setClosedRange(closed);
  11882. }
  11883. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  11884. {
  11885. updateAttribute("smoothing",enabled?"true":"false");
  11886. }
  11887. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  11888. {
  11889. updateAttribute("calibrationSensitivity",value);
  11890. calibrator->setSensitivity(value.toDouble());
  11891. }
  11892. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  11893. {
  11894. updateAttribute("hidden",hidden?"true":"false");
  11895. }
  11896. /*:1003*//*1006:*/
  11897. #line 1136 "./dataqsdk.w"
  11898. void DataqSdkChannelConfWidget::startCalibration()
  11899. {
  11900. startButton->setEnabled(false);
  11901. stopButton->setEnabled(true);
  11902. resetButton->setEnabled(true);
  11903. calibrationDevice= new DataqSdkDevice(deviceID);
  11904. Channel*channel;
  11905. for(unsigned int i= 0;i<=channelOfInterest;i++)
  11906. {
  11907. channel= calibrationDevice->newChannel(Units::Unitless);
  11908. }
  11909. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  11910. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  11911. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  11912. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  11913. calibrationDevice->start();
  11914. }
  11915. void DataqSdkChannelConfWidget::stopCalibration()
  11916. {
  11917. startButton->setEnabled(true);
  11918. stopButton->setEnabled(false);
  11919. resetButton->setEnabled(false);
  11920. calibrationDevice->deleteLater();
  11921. /*1008:*/
  11922. #line 1181 "./dataqsdk.w"
  11923. rmCount= 0;
  11924. cmCount= 0;
  11925. rmin= std::numeric_limits<double> ::max();
  11926. rmax= std::numeric_limits<double> ::min();
  11927. rmean= 0;
  11928. cmin= std::numeric_limits<double> ::max();
  11929. cmax= std::numeric_limits<double> ::min();
  11930. cmean= 0;
  11931. /*:1008*/
  11932. #line 1161 "./dataqsdk.w"
  11933. }
  11934. /*:1006*//*1007:*/
  11935. #line 1172 "./dataqsdk.w"
  11936. void DataqSdkChannelConfWidget::resetCalibration()
  11937. {
  11938. /*1008:*/
  11939. #line 1181 "./dataqsdk.w"
  11940. rmCount= 0;
  11941. cmCount= 0;
  11942. rmin= std::numeric_limits<double> ::max();
  11943. rmax= std::numeric_limits<double> ::min();
  11944. rmean= 0;
  11945. cmin= std::numeric_limits<double> ::max();
  11946. cmax= std::numeric_limits<double> ::min();
  11947. cmean= 0;
  11948. /*:1008*/
  11949. #line 1175 "./dataqsdk.w"
  11950. }
  11951. /*:1007*//*1009:*/
  11952. #line 1195 "./dataqsdk.w"
  11953. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  11954. {
  11955. double nv= measure.temperature();
  11956. currentMeasurement->setText(QString("%1").arg(nv));
  11957. rmin= qMin(nv,rmin);
  11958. minimumMeasurement->setText(QString("%1").arg(rmin));
  11959. rmax= qMax(nv,rmax);
  11960. maximumMeasurement->setText(QString("%1").arg(rmax));
  11961. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  11962. rmCount++;
  11963. averageMeasurement->setText(QString("%1").arg(rmean));
  11964. }
  11965. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  11966. {
  11967. double nv= measure.temperature();
  11968. currentMapped->setText(QString("%1").arg(nv));
  11969. cmin= qMin(nv,cmin);
  11970. minimumMapped->setText(QString("%1").arg(cmin));
  11971. cmax= qMax(nv,cmax);
  11972. maximumMapped->setText(QString("%1").arg(cmax));
  11973. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  11974. cmCount++;
  11975. averageMapped->setText(QString("%1").arg(cmean));
  11976. }
  11977. /*:1009*//*1010:*/
  11978. #line 1224 "./dataqsdk.w"
  11979. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  11980. {
  11981. updateAttribute("column",value);
  11982. }
  11983. /*:1010*/
  11984. #line 608 "./typica.w"
  11985. /*1034:*/
  11986. #line 423 "./scales.w"
  11987. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  11988. const QModelIndex&index)
  11989. :BasicDeviceConfigurationWidget(model,index),
  11990. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  11991. flow(new FlowSelector),stop(new StopSelector),
  11992. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  11993. {
  11994. QFormLayout*layout= new QFormLayout;
  11995. layout->addRow(tr("Port:"),port);
  11996. connect(port,SIGNAL(currentIndexChanged(QString)),
  11997. this,SLOT(updatePort(QString)));
  11998. connect(port,SIGNAL(editTextChanged(QString)),
  11999. this,SLOT(updatePort(QString)));
  12000. layout->addRow(tr("Baud:"),baud);
  12001. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12002. this,SLOT(updateBaudRate(QString)));
  12003. layout->addRow(tr("Parity:"),parity);
  12004. connect(parity,SIGNAL(currentIndexChanged(int)),
  12005. this,SLOT(updateParity(int)));
  12006. layout->addRow(tr("Flow Control:"),flow);
  12007. connect(flow,SIGNAL(currentIndexChanged(int)),
  12008. this,SLOT(updateFlowControl(int)));
  12009. layout->addRow(tr("Stop Bits:"),stop);
  12010. connect(stop,SIGNAL(currentIndexChanged(int)),
  12011. this,SLOT(updateStopBits(int)));
  12012. layout->addRow(tr("Weigh Command:"),weighcommand);
  12013. connect(weighcommand,SIGNAL(textChanged(QString)),
  12014. this,SLOT(updateWeighCommand(QString)));
  12015. commandterminator->addItem("CRLF");
  12016. commandterminator->addItem("CR");
  12017. commandterminator->addItem("LF");
  12018. layout->addRow(tr("Command Terminator:"),commandterminator);
  12019. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12020. this,SLOT(updateCommandTerminator(QString)));
  12021. /*771:*/
  12022. #line 16337 "./typica.w"
  12023. QDomElement referenceElement=
  12024. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12025. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12026. QDomElement node;
  12027. /*:771*/
  12028. #line 459 "./scales.w"
  12029. for(int i= 0;i<configData.size();i++)
  12030. {
  12031. node= configData.at(i).toElement();
  12032. if(node.attribute("name")=="port")
  12033. {
  12034. int j= port->findText(node.attribute("value"));
  12035. if(j>=0)
  12036. {
  12037. port->setCurrentIndex(j);
  12038. }
  12039. else
  12040. {
  12041. port->insertItem(0,node.attribute("value"));
  12042. port->setCurrentIndex(0);
  12043. }
  12044. }
  12045. else if(node.attribute("name")=="baudrate")
  12046. {
  12047. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12048. }
  12049. else if(node.attribute("name")=="parity")
  12050. {
  12051. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12052. }
  12053. else if(node.attribute("name")=="flowcontrol")
  12054. {
  12055. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12056. }
  12057. else if(node.attribute("name")=="stopbits")
  12058. {
  12059. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12060. }
  12061. else if(node.attribute("name")=="weighcommand")
  12062. {
  12063. weighcommand->setText(node.attribute("value"));
  12064. }
  12065. else if(node.attribute("name")=="commandterminator")
  12066. {
  12067. commandterminator->setCurrentIndex(
  12068. commandterminator->findText(node.attribute("value")));
  12069. }
  12070. }
  12071. updatePort(port->currentText());
  12072. updateBaudRate(baud->currentText());
  12073. updateParity(parity->currentIndex());
  12074. updateFlowControl(flow->currentIndex());
  12075. updateStopBits(stop->currentIndex());
  12076. updateWeighCommand(weighcommand->text());
  12077. updateCommandTerminator(commandterminator->currentText());
  12078. setLayout(layout);
  12079. }
  12080. /*:1034*//*1035:*/
  12081. #line 514 "./scales.w"
  12082. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12083. {
  12084. updateAttribute("port",newPort);
  12085. }
  12086. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12087. {
  12088. updateAttribute("baudrate",rate);
  12089. }
  12090. void SerialScaleConfWidget::updateParity(int index)
  12091. {
  12092. updateAttribute("parity",parity->itemData(index).toString());
  12093. }
  12094. void SerialScaleConfWidget::updateFlowControl(int index)
  12095. {
  12096. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12097. }
  12098. void SerialScaleConfWidget::updateStopBits(int index)
  12099. {
  12100. updateAttribute("stopbits",stop->itemData(index).toString());
  12101. }
  12102. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12103. {
  12104. updateAttribute("weighcommand",command);
  12105. }
  12106. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12107. {
  12108. updateAttribute("commandterminator",terminator);
  12109. }
  12110. /*:1035*/
  12111. #line 609 "./typica.w"
  12112. /*1047:*/
  12113. #line 195 "./valueannotation.w"
  12114. void ValueAnnotation::newMeasurement(Measurement measure)
  12115. {
  12116. for(int i= 0;i<values.size();i++)
  12117. {
  12118. if(measure.temperature()> values.at(i)-tolerance&&
  12119. measure.temperature()<values.at(i)+tolerance)
  12120. {
  12121. if(i!=lastIndex)
  12122. {
  12123. lastIndex= i;
  12124. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12125. }
  12126. }
  12127. }
  12128. }
  12129. /*:1047*//*1048:*/
  12130. #line 216 "./valueannotation.w"
  12131. void ValueAnnotation::annotate()
  12132. {
  12133. if(lastIndex> -1)
  12134. {
  12135. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12136. }
  12137. }
  12138. /*:1048*//*1049:*/
  12139. #line 228 "./valueannotation.w"
  12140. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12141. {
  12142. values.append(value);
  12143. annotations.append(annotation);
  12144. }
  12145. /*:1049*//*1050:*/
  12146. #line 237 "./valueannotation.w"
  12147. void ValueAnnotation::setAnnotationColumn(int column)
  12148. {
  12149. annotationColumn= column;
  12150. }
  12151. void ValueAnnotation::setTemperatureColumn(int column)
  12152. {
  12153. measurementColumn= column;
  12154. }
  12155. void ValueAnnotation::setTolerance(double epsilon)
  12156. {
  12157. tolerance= epsilon;
  12158. }
  12159. /*:1050*//*1051:*/
  12160. #line 255 "./valueannotation.w"
  12161. ValueAnnotation::ValueAnnotation():QObject(),
  12162. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12163. {
  12164. }
  12165. /*:1051*/
  12166. #line 610 "./typica.w"
  12167. /*1039:*/
  12168. #line 33 "./valueannotation.w"
  12169. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12170. const QModelIndex&index)
  12171. :BasicDeviceConfigurationWidget(model,index),
  12172. tablemodel(new SaltModel(2))
  12173. {
  12174. QFormLayout*layout= new QFormLayout;
  12175. QLineEdit*source= new QLineEdit;
  12176. layout->addRow(tr("Source column name:"),source);
  12177. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12178. noteOnStart->setChecked(true);
  12179. layout->addRow(noteOnStart);
  12180. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12181. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12182. QTableView*annotationTable= new QTableView;
  12183. annotationTable->setModel(tablemodel);
  12184. NumericDelegate*delegate= new NumericDelegate;
  12185. annotationTable->setItemDelegateForColumn(0,delegate);
  12186. layout->addRow(tr("Annotations for values:"),annotationTable);
  12187. /*771:*/
  12188. #line 16337 "./typica.w"
  12189. QDomElement referenceElement=
  12190. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12191. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12192. QDomElement node;
  12193. /*:771*/
  12194. #line 52 "./valueannotation.w"
  12195. for(int i= 0;i<configData.size();i++)
  12196. {
  12197. node= configData.at(i).toElement();
  12198. if(node.attribute("name")=="source")
  12199. {
  12200. source->setText(node.attribute("value"));
  12201. }
  12202. else if(node.attribute("name")=="emitOnStart")
  12203. {
  12204. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12205. }
  12206. else if(node.attribute("name")=="measuredValues")
  12207. {
  12208. /*937:*/
  12209. #line 19425 "./typica.w"
  12210. QString data= node.attribute("value");
  12211. if(data.length()> 3)
  12212. {
  12213. data.chop(2);
  12214. data= data.remove(0,2);
  12215. }
  12216. QStringList itemList= data.split(",");
  12217. /*:937*/
  12218. #line 66 "./valueannotation.w"
  12219. int column= 0;
  12220. /*938:*/
  12221. #line 19437 "./typica.w"
  12222. for(int j= 0;j<itemList.size();j++)
  12223. {
  12224. tablemodel->setData(tablemodel->index(j,column),
  12225. QVariant(itemList.at(j).toDouble()),
  12226. Qt::DisplayRole);
  12227. }
  12228. /*:938*/
  12229. #line 68 "./valueannotation.w"
  12230. }
  12231. else if(node.attribute("name")=="annotations")
  12232. {
  12233. /*1040:*/
  12234. #line 89 "./valueannotation.w"
  12235. QString data= node.attribute("value");
  12236. if(data.length()> 3)
  12237. {
  12238. data.chop(2);
  12239. data= data.remove(0,2);
  12240. }
  12241. QStringList itemList= data.split(",");
  12242. for(int i= 0;i<itemList.size();i++)
  12243. {
  12244. itemList[i]= itemList[i].simplified();
  12245. }
  12246. /*:1040*/
  12247. #line 72 "./valueannotation.w"
  12248. int column= 1;
  12249. /*1041:*/
  12250. #line 104 "./valueannotation.w"
  12251. for(int i= 0;i<itemList.size();i++)
  12252. {
  12253. tablemodel->setData(tablemodel->index(i,column),
  12254. QVariant(itemList.at(i)),
  12255. Qt::DisplayRole);
  12256. }
  12257. /*:1041*/
  12258. #line 74 "./valueannotation.w"
  12259. }
  12260. }
  12261. updateSourceColumn(source->text());
  12262. updateStart(noteOnStart->isChecked());
  12263. updateAnnotations();
  12264. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12265. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12266. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12267. setLayout(layout);
  12268. }
  12269. /*:1039*//*1042:*/
  12270. #line 115 "./valueannotation.w"
  12271. void ValueAnnotationConfWidget::updateAnnotations()
  12272. {
  12273. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12274. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12275. }
  12276. /*:1042*//*1043:*/
  12277. #line 125 "./valueannotation.w"
  12278. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12279. {
  12280. updateAttribute("source",source);
  12281. }
  12282. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12283. {
  12284. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12285. }
  12286. /*:1043*/
  12287. #line 611 "./typica.w"
  12288. /*867:*/
  12289. #line 44 "./modbus.w"
  12290. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12291. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12292. m_flow(new FlowSelector),m_stop(new StopSelector)
  12293. {
  12294. QFormLayout*layout= new QFormLayout;
  12295. PortSelector*port= new PortSelector;
  12296. BaudSelector*baud= new BaudSelector;
  12297. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12298. layout->addRow(QString(tr("Port:")),port);
  12299. layout->addRow(QString(tr("Baud rate:")),baud);
  12300. layout->addRow(QString(tr("Parity:")),m_parity);
  12301. layout->addRow(QString(tr("Flow control:")),m_flow);
  12302. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12303. layout->addRow(newInput);
  12304. /*771:*/
  12305. #line 16337 "./typica.w"
  12306. QDomElement referenceElement=
  12307. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12308. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12309. QDomElement node;
  12310. /*:771*/
  12311. #line 60 "./modbus.w"
  12312. for(int i= 0;i<configData.size();i++)
  12313. {
  12314. node= configData.at(i).toElement();
  12315. if(node.attribute("name")=="port")
  12316. {
  12317. int idx= port->findText(node.attribute("value"));
  12318. if(idx>=0)
  12319. {
  12320. port->setCurrentIndex(idx);
  12321. }
  12322. else
  12323. {
  12324. port->addItem(node.attribute("value"));
  12325. }
  12326. }
  12327. else if(node.attribute("name")=="baud")
  12328. {
  12329. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12330. }
  12331. else if(node.attribute("name")=="parity")
  12332. {
  12333. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12334. }
  12335. else if(node.attribute("name")=="flow")
  12336. {
  12337. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12338. }
  12339. else if(node.attribute("name")=="stop")
  12340. {
  12341. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12342. }
  12343. }
  12344. updatePort(port->currentText());
  12345. updateBaudRate(baud->currentText());
  12346. updateParity(m_parity->currentIndex());
  12347. updateFlowControl(m_flow->currentIndex());
  12348. updateStopBits(m_stop->currentIndex());
  12349. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12350. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12351. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12352. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12353. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12354. this,SLOT(updateFlowControl(int)));
  12355. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12356. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12357. setLayout(layout);
  12358. }
  12359. void ModbusNGConfWidget::updatePort(const QString&value)
  12360. {
  12361. updateAttribute("port",value);
  12362. }
  12363. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12364. {
  12365. updateAttribute("baud",value);
  12366. }
  12367. void ModbusNGConfWidget::updateParity(int value)
  12368. {
  12369. updateAttribute("parity",m_parity->itemData(value).toString());
  12370. }
  12371. void ModbusNGConfWidget::updateFlowControl(int value)
  12372. {
  12373. updateAttribute("flow",m_flow->itemData(value).toString());
  12374. }
  12375. void ModbusNGConfWidget::updateStopBits(int value)
  12376. {
  12377. updateAttribute("stop",m_stop->itemData(value).toString());
  12378. }
  12379. void ModbusNGConfWidget::addInput()
  12380. {
  12381. insertChildNode(tr("Input"),"modbusnginput");
  12382. }
  12383. /*:867*//*869:*/
  12384. #line 164 "./modbus.w"
  12385. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12386. {
  12387. QFormLayout*layout= new QFormLayout;
  12388. QSpinBox*station= new QSpinBox;
  12389. station->setMinimum(1);
  12390. station->setMaximum(247);
  12391. layout->addRow(tr("Station ID"),station);
  12392. QComboBox*function= new QComboBox;
  12393. function->addItem("3","3");
  12394. function->addItem("4","4");
  12395. function->setCurrentIndex(1);
  12396. layout->addRow(tr("Function"),function);
  12397. ShortHexSpinBox*address= new ShortHexSpinBox;
  12398. layout->addRow(tr("Address"),address);
  12399. QComboBox*format= new QComboBox;
  12400. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12401. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12402. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12403. layout->addRow(tr("Data format"),format);
  12404. QSpinBox*decimals= new QSpinBox;
  12405. decimals->setMinimum(0);
  12406. decimals->setMaximum(9);
  12407. layout->addRow(tr("Decimal places"),decimals);
  12408. QComboBox*unit= new QComboBox;
  12409. unit->addItem("Celsius","C");
  12410. unit->addItem("Fahrenheit","F");
  12411. unit->setCurrentIndex(1);
  12412. layout->addRow(tr("Unit"),unit);
  12413. QLineEdit*column= new QLineEdit;
  12414. layout->addRow(tr("Column name"),column);
  12415. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12416. layout->addRow(hidden);
  12417. /*771:*/
  12418. #line 16337 "./typica.w"
  12419. QDomElement referenceElement=
  12420. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12421. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12422. QDomElement node;
  12423. /*:771*/
  12424. #line 198 "./modbus.w"
  12425. for(int i= 0;i<configData.size();i++)
  12426. {
  12427. node= configData.at(i).toElement();
  12428. if(node.attribute("name")=="station")
  12429. {
  12430. station->setValue(node.attribute("value").toInt());
  12431. }
  12432. else if(node.attribute("name")=="function")
  12433. {
  12434. function->setCurrentIndex(function->findText(node.attribute("value")));
  12435. }
  12436. else if(node.attribute("name")=="address")
  12437. {
  12438. address->setValue(node.attribute("value").toInt());
  12439. }
  12440. else if(node.attribute("name")=="format")
  12441. {
  12442. format->setCurrentIndex(format->findData(node.attribute("value")));
  12443. }
  12444. else if(node.attribute("name")=="decimals")
  12445. {
  12446. decimals->setValue(node.attribute("value").toInt());
  12447. }
  12448. else if(node.attribute("name")=="unit")
  12449. {
  12450. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12451. }
  12452. else if(node.attribute("name")=="column")
  12453. {
  12454. column->setText(node.attribute("value"));
  12455. }
  12456. else if(node.attribute("name")=="hidden")
  12457. {
  12458. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12459. }
  12460. }
  12461. updateStation(station->value());
  12462. updateFunction(function->currentIndex());
  12463. updateAddress(address->value());
  12464. updateFormat(format->currentIndex());
  12465. updateDecimals(decimals->value());
  12466. updateUnit(unit->currentIndex());
  12467. updateColumnName(column->text());
  12468. updateHidden(hidden->isChecked());
  12469. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12470. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12471. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12472. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12473. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12474. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12475. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12476. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12477. setLayout(layout);
  12478. }
  12479. void ModbusNGInputConfWidget::updateStation(int value)
  12480. {
  12481. updateAttribute("station",QString("%1").arg(value));
  12482. }
  12483. void ModbusNGInputConfWidget::updateFunction(int value)
  12484. {
  12485. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12486. }
  12487. void ModbusNGInputConfWidget::updateAddress(int value)
  12488. {
  12489. updateAttribute("address",QString("%1").arg(value));
  12490. }
  12491. void ModbusNGInputConfWidget::updateFormat(int value)
  12492. {
  12493. switch(value)
  12494. {
  12495. case 0:
  12496. updateAttribute("format","16fixedint");
  12497. break;
  12498. case 1:
  12499. updateAttribute("format","32floathl");
  12500. break;
  12501. case 2:
  12502. updateAttribute("format","32floatlh");
  12503. break;
  12504. }
  12505. }
  12506. void ModbusNGInputConfWidget::updateDecimals(int value)
  12507. {
  12508. updateAttribute("decimals",QString("%1").arg(value));
  12509. }
  12510. void ModbusNGInputConfWidget::updateUnit(int value)
  12511. {
  12512. switch(value)
  12513. {
  12514. case 0:
  12515. updateAttribute("unit","C");
  12516. break;
  12517. case 1:
  12518. updateAttribute("unit","F");
  12519. break;
  12520. }
  12521. }
  12522. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  12523. {
  12524. updateAttribute("column",value);
  12525. }
  12526. void ModbusNGInputConfWidget::updateHidden(bool value)
  12527. {
  12528. updateAttribute("hidden",value?"true":"false");
  12529. }
  12530. /*:869*//*874:*/
  12531. #line 394 "./modbus.w"
  12532. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  12533. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  12534. scanPosition(0),waiting(false)
  12535. {
  12536. QDomElement portReferenceElement=
  12537. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12538. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  12539. QDomElement node;
  12540. QVariantMap attributes;
  12541. for(int i= 0;i<portConfigData.size();i++)
  12542. {
  12543. node= portConfigData.at(i).toElement();
  12544. attributes.insert(node.attribute("name"),node.attribute("value"));
  12545. }
  12546. port= new QextSerialPort(attributes.value("port").toString(),
  12547. QextSerialPort::EventDriven);
  12548. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  12549. port->setDataBits(DATA_8);
  12550. port->setParity((ParityType)attributes.value("parity").toInt());
  12551. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  12552. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  12553. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  12554. messageDelayTimer->setSingleShot(true);
  12555. commTimeout->setSingleShot(true);
  12556. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  12557. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  12558. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  12559. port->open(QIODevice::ReadWrite);
  12560. for(int i= 0;i<model->rowCount(index);i++)
  12561. {
  12562. QModelIndex channelIndex= model->index(i,0,index);
  12563. QDomElement channelReferenceElement=
  12564. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  12565. QDomNodeList channelConfigData=
  12566. channelReferenceElement.elementsByTagName("attribute");
  12567. QDomElement channelNode;
  12568. QVariantMap channelAttributes;
  12569. for(int j= 0;j<channelConfigData.size();j++)
  12570. {
  12571. channelNode= channelConfigData.at(j).toElement();
  12572. channelAttributes.insert(channelNode.attribute("name"),
  12573. channelNode.attribute("value"));
  12574. }
  12575. ModbusScanItem scanItem;
  12576. QString format= channelAttributes.value("format").toString();
  12577. if(format=="16fixedint")
  12578. {
  12579. scanItem.format= Int16;
  12580. }
  12581. else if(format=="32floathl")
  12582. {
  12583. scanItem.format= FloatHL;
  12584. }
  12585. else if(format=="32floatlh")
  12586. {
  12587. scanItem.format= FloatLH;
  12588. }
  12589. scanItem.request.append((char)channelAttributes.value("station").toInt());
  12590. scanItem.request.append((char)channelAttributes.value("function").toInt());
  12591. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  12592. char*startAddressBytes= (char*)&startAddress;
  12593. scanItem.request.append(startAddressBytes[1]);
  12594. scanItem.request.append(startAddressBytes[0]);
  12595. scanItem.request.append((char)0x00);
  12596. if(scanItem.format==Int16)
  12597. {
  12598. scanItem.request.append((char)0x01);
  12599. }
  12600. else
  12601. {
  12602. scanItem.request.append((char)0x02);
  12603. }
  12604. quint16 crc= calculateCRC(scanItem.request);
  12605. char*crcBytes= (char*)&crc;
  12606. scanItem.request.append(crcBytes[0]);
  12607. scanItem.request.append(crcBytes[1]);
  12608. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  12609. if(channelAttributes.value("unit").toString()=="C")
  12610. {
  12611. scanItem.unit= Units::Celsius;
  12612. }
  12613. else
  12614. {
  12615. scanItem.unit= Units::Fahrenheit;
  12616. }
  12617. scanList.append(scanItem);
  12618. channels.append(new Channel);
  12619. channelNames.append(channelAttributes.value("column").toString());
  12620. hiddenStates.append(
  12621. channelAttributes.value("hidden").toString()=="true"?true:false);
  12622. channelLabels.append(model->data(channelIndex,0).toString());
  12623. }
  12624. messageDelayTimer->start();
  12625. }
  12626. ModbusNG::~ModbusNG()
  12627. {
  12628. commTimeout->stop();
  12629. messageDelayTimer->stop();
  12630. port->close();
  12631. }
  12632. void ModbusNG::sendNextMessage()
  12633. {
  12634. if(scanList.length()> 0&&!waiting)
  12635. {
  12636. port->write(scanList.at(scanPosition).request);
  12637. commTimeout->start(2000);
  12638. messageDelayTimer->start(delayTime);
  12639. waiting= true;
  12640. }
  12641. }
  12642. void ModbusNG::timeout()
  12643. {
  12644. qDebug()<<"Communications timeout.";
  12645. messageDelayTimer->start();
  12646. }
  12647. void ModbusNG::dataAvailable()
  12648. {
  12649. if(messageDelayTimer->isActive())
  12650. {
  12651. messageDelayTimer->stop();
  12652. }
  12653. responseBuffer.append(port->readAll());
  12654. if(responseBuffer.size()<5)
  12655. {
  12656. return;
  12657. }
  12658. if(responseBuffer.size()<5+responseBuffer.at(2))
  12659. {
  12660. return;
  12661. }
  12662. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  12663. commTimeout->stop();
  12664. if(calculateCRC(responseBuffer)==0)
  12665. {
  12666. quint16 intresponse;
  12667. float floatresponse;
  12668. char*ibytes= (char*)&intresponse;
  12669. char*fbytes= (char*)&floatresponse;
  12670. double output;
  12671. switch(scanList.at(scanPosition).format)
  12672. {
  12673. case Int16:
  12674. ibytes[0]= responseBuffer.at(4);
  12675. ibytes[1]= responseBuffer.at(3);
  12676. output= intresponse;
  12677. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  12678. {
  12679. output/= 10;
  12680. }
  12681. break;
  12682. case FloatHL:
  12683. fbytes[0]= responseBuffer.at(4);
  12684. fbytes[1]= responseBuffer.at(3);
  12685. fbytes[2]= responseBuffer.at(6);
  12686. fbytes[3]= responseBuffer.at(5);
  12687. output= floatresponse;
  12688. break;
  12689. case FloatLH:
  12690. fbytes[0]= responseBuffer.at(6);
  12691. fbytes[1]= responseBuffer.at(5);
  12692. fbytes[2]= responseBuffer.at(4);
  12693. fbytes[3]= responseBuffer.at(3);
  12694. output= floatresponse;
  12695. break;
  12696. }
  12697. if(scanList.at(scanPosition).unit==Units::Celsius)
  12698. {
  12699. output= output*9.0/5.0+32.0;
  12700. }
  12701. scanList.at(scanPosition).lastValue= output;
  12702. }
  12703. else
  12704. {
  12705. qDebug()<<"CRC failed";
  12706. }
  12707. scanPosition= (scanPosition+1)%scanList.size();
  12708. if(scanPosition==0)
  12709. {
  12710. QTime time= QTime::currentTime();
  12711. for(int i= 0;i<scanList.size();i++)
  12712. {
  12713. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  12714. }
  12715. }
  12716. responseBuffer.clear();
  12717. waiting= false;
  12718. messageDelayTimer->start(delayTime);
  12719. }
  12720. quint16 ModbusNG::calculateCRC(QByteArray data)
  12721. {
  12722. quint16 retval= 0xFFFF;
  12723. int i= 0;
  12724. while(i<data.size())
  12725. {
  12726. retval^= 0x00FF&(quint16)data.at(i);
  12727. for(int j= 0;j<8;j++)
  12728. {
  12729. if(retval&1)
  12730. {
  12731. retval= (retval>>1)^0xA001;
  12732. }
  12733. else
  12734. {
  12735. retval>>= 1;
  12736. }
  12737. }
  12738. i++;
  12739. }
  12740. return retval;
  12741. }
  12742. int ModbusNG::channelCount()
  12743. {
  12744. return channels.size();
  12745. }
  12746. Channel*ModbusNG::getChannel(int channel)
  12747. {
  12748. return channels.at(channel);
  12749. }
  12750. QString ModbusNG::channelColumnName(int channel)
  12751. {
  12752. return channelNames.at(channel);
  12753. }
  12754. QString ModbusNG::channelIndicatorText(int channel)
  12755. {
  12756. return channelLabels.at(channel);
  12757. }
  12758. bool ModbusNG::isChannelHidden(int channel)
  12759. {
  12760. return hiddenStates.at(channel);
  12761. }
  12762. /*:874*/
  12763. #line 612 "./typica.w"
  12764. /*1056:*/
  12765. #line 33 "./thresholdannotation.w"
  12766. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  12767. const QModelIndex&index)
  12768. :BasicDeviceConfigurationWidget(model,index)
  12769. {
  12770. QFormLayout*layout= new QFormLayout;
  12771. QLineEdit*source= new QLineEdit;
  12772. layout->addRow(tr("Source column name:"),source);
  12773. QDoubleSpinBox*value= new QDoubleSpinBox;
  12774. /*:1056*//*1058:*/
  12775. #line 55 "./thresholdannotation.w"
  12776. value->setMinimum(std::numeric_limits<double> ::min());
  12777. value->setMaximum(std::numeric_limits<double> ::max());
  12778. value->setDecimals(2);
  12779. layout->addRow(tr("Threshold value:"),value);
  12780. QComboBox*direction= new QComboBox;
  12781. direction->addItem(tr("Ascending"));
  12782. direction->addItem(tr("Descending"));
  12783. layout->addRow(tr("Direction:"),direction);
  12784. QLineEdit*annotation= new QLineEdit;
  12785. layout->addRow(tr("Annotation:"),annotation);
  12786. /*771:*/
  12787. #line 16337 "./typica.w"
  12788. QDomElement referenceElement=
  12789. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12790. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12791. QDomElement node;
  12792. /*:771*/
  12793. #line 67 "./thresholdannotation.w"
  12794. for(int i= 0;i<configData.size();i++)
  12795. {
  12796. node= configData.at(i).toElement();
  12797. if(node.attribute("name")=="source")
  12798. {
  12799. source->setText(node.attribute("value"));
  12800. }
  12801. else if(node.attribute("name")=="value")
  12802. {
  12803. value->setValue(node.attribute("value").toDouble());
  12804. }
  12805. else if(node.attribute("name")=="direction")
  12806. {
  12807. direction->setCurrentIndex(node.attribute("value").toInt());
  12808. }
  12809. else if(node.attribute("name")=="annotation")
  12810. {
  12811. annotation->setText(node.attribute("value"));
  12812. }
  12813. }
  12814. updateSourceColumn(source->text());
  12815. updateThreshold(value->value());
  12816. updateDirection(direction->currentIndex());
  12817. updateAnnotation(annotation->text());
  12818. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12819. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  12820. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  12821. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  12822. setLayout(layout);
  12823. }
  12824. /*:1058*//*1059:*/
  12825. #line 101 "./thresholdannotation.w"
  12826. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  12827. {
  12828. updateAttribute("source",source);
  12829. }
  12830. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  12831. {
  12832. updateAttribute("value",QString("%1").arg(value));
  12833. }
  12834. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  12835. {
  12836. updateAttribute("direction",QString("%1").arg(direction));
  12837. }
  12838. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  12839. {
  12840. updateAttribute("annotation",annotation);
  12841. }
  12842. /*:1059*/
  12843. #line 613 "./typica.w"
  12844. /*1063:*/
  12845. #line 167 "./thresholdannotation.w"
  12846. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  12847. {
  12848. t.setInterval(0);
  12849. t.setSingleShot(true);
  12850. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  12851. }
  12852. void Annotator::setAnnotation(const QString&annotation)
  12853. {
  12854. note= annotation;
  12855. }
  12856. void Annotator::setTemperatureColumn(int tempcolumn)
  12857. {
  12858. tc= tempcolumn;
  12859. }
  12860. void Annotator::setAnnotationColumn(int annotationcolumn)
  12861. {
  12862. ac= annotationcolumn;
  12863. }
  12864. /*:1063*//*1064:*/
  12865. #line 196 "./thresholdannotation.w"
  12866. void Annotator::catchTimer()
  12867. {
  12868. emit annotation(note,tc,ac);
  12869. }
  12870. void Annotator::annotate()
  12871. {
  12872. t.start();
  12873. }
  12874. /*:1064*/
  12875. #line 614 "./typica.w"
  12876. /*:4*//*250:*/
  12877. #line 5955 "./typica.w"
  12878. /*247:*/
  12879. #line 5918 "./typica.w"
  12880. void ScriptValidator::fixup(QString&input)const
  12881. {
  12882. QScriptEngine*engine= AppInstance->engine;
  12883. engine->pushContext();
  12884. input= engine->evaluate(input).toString();
  12885. engine->popContext();
  12886. }
  12887. /*:247*//*248:*/
  12888. #line 5931 "./typica.w"
  12889. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  12890. {
  12891. if(v)
  12892. {
  12893. if(v->validate(input,pos)==QValidator::Acceptable)
  12894. {
  12895. return QValidator::Acceptable;
  12896. }
  12897. }
  12898. return QValidator::Intermediate;
  12899. }
  12900. /*:248*//*249:*/
  12901. #line 5946 "./typica.w"
  12902. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  12903. :QValidator(parent),v(validator)
  12904. {
  12905. }
  12906. /*:249*/
  12907. #line 5956 "./typica.w"
  12908. /*:250*//*845:*/
  12909. #line 60 "./advancedsettings.w"
  12910. /*843:*/
  12911. #line 26 "./advancedsettings.w"
  12912. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  12913. {
  12914. QSettings settings;
  12915. QFormLayout*layout= new QFormLayout;
  12916. QCheckBox*logDiagnostics= new QCheckBox;
  12917. logDiagnostics->setCheckState(
  12918. settings.value("settings/advanced/logging",false).toBool()?
  12919. Qt::Checked:Qt::Unchecked);
  12920. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  12921. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  12922. setLayout(layout);
  12923. }
  12924. /*:843*//*844:*/
  12925. #line 43 "./advancedsettings.w"
  12926. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  12927. {
  12928. QSettings settings;
  12929. settings.setValue("settings/advanced/logging",enabled);
  12930. if(enabled)
  12931. {
  12932. qInstallMsgHandler(messageFileOutput);
  12933. }
  12934. else
  12935. {
  12936. qInstallMsgHandler(0);
  12937. }
  12938. }
  12939. /*:844*/
  12940. #line 61 "./advancedsettings.w"
  12941. #line 18101 "./typica.w"
  12942. /*:845*//*904:*/
  12943. #line 639 "./unsupportedserial.w"
  12944. /*879:*/
  12945. #line 58 "./unsupportedserial.w"
  12946. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  12947. const QModelIndex&index)
  12948. :BasicDeviceConfigurationWidget(model,index),
  12949. deviceSettingsModel(new SaltModel(2)),
  12950. scriptEditor(new QTextEdit)
  12951. {
  12952. scriptEditor->setTabStopWidth(20);
  12953. QVBoxLayout*dummyLayout= new QVBoxLayout;
  12954. QTabWidget*central= new QTabWidget;
  12955. QWidget*deviceConfigurationWidget= new QWidget;
  12956. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  12957. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12958. deviceConfigurationLayout->addWidget(addChannelButton);
  12959. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12960. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  12961. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  12962. QTableView*deviceSettingsView= new QTableView;
  12963. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  12964. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  12965. deviceSettingsView->setModel(deviceSettingsModel);
  12966. deviceConfigurationLayout->addWidget(deviceSettingsView);
  12967. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  12968. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  12969. central->addTab(scriptEditor,tr("Script"));
  12970. dummyLayout->addWidget(central);
  12971. /*771:*/
  12972. #line 16337 "./typica.w"
  12973. QDomElement referenceElement=
  12974. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12975. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12976. QDomElement node;
  12977. /*:771*/
  12978. #line 86 "./unsupportedserial.w"
  12979. for(int i= 0;i<configData.size();i++)
  12980. {
  12981. node= configData.at(i).toElement();
  12982. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  12983. {
  12984. int column= 0;
  12985. if(node.attribute("name")=="values")
  12986. {
  12987. column= 1;
  12988. }
  12989. QString data= node.attribute("value");
  12990. if(data.length()> 3)
  12991. {
  12992. data.chop(2);
  12993. data= data.remove(0,2);
  12994. }
  12995. QStringList keyList= data.split(", ");
  12996. for(int j= 0;j<keyList.size();j++)
  12997. {
  12998. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  12999. QVariant(keyList.at(j)),
  13000. Qt::EditRole);
  13001. }
  13002. }
  13003. else if(node.attribute("name")=="script")
  13004. {
  13005. scriptEditor->setPlainText(node.attribute("value"));
  13006. }
  13007. }
  13008. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13009. this,SLOT(updateConfiguration()));
  13010. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13011. setLayout(dummyLayout);
  13012. }
  13013. /*:879*//*880:*/
  13014. #line 131 "./unsupportedserial.w"
  13015. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13016. {
  13017. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13018. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13019. }
  13020. /*:880*//*881:*/
  13021. #line 144 "./unsupportedserial.w"
  13022. void UnsupportedSerialDeviceConfWidget::saveScript()
  13023. {
  13024. updateAttribute("script",scriptEditor->toPlainText());
  13025. }
  13026. /*:881*//*882:*/
  13027. #line 155 "./unsupportedserial.w"
  13028. void UnsupportedSerialDeviceConfWidget::addChannel()
  13029. {
  13030. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13031. }
  13032. /*:882*//*884:*/
  13033. #line 183 "./unsupportedserial.w"
  13034. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13035. const QModelIndex&index)
  13036. :BasicDeviceConfigurationWidget(model,index),
  13037. channelSettingsModel(new SaltModel(2))
  13038. {
  13039. QFormLayout*layout= new QFormLayout;
  13040. QLineEdit*columnName= new QLineEdit;
  13041. layout->addRow(tr("Column Name:"),columnName);
  13042. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13043. layout->addRow(hideSeries);
  13044. QTableView*channelSettings= new QTableView;
  13045. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13046. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13047. channelSettings->setModel(channelSettingsModel);
  13048. layout->addRow(channelSettings);
  13049. setLayout(layout);
  13050. /*771:*/
  13051. #line 16337 "./typica.w"
  13052. QDomElement referenceElement=
  13053. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13054. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13055. QDomElement node;
  13056. /*:771*/
  13057. #line 200 "./unsupportedserial.w"
  13058. for(int i= 0;i<configData.size();i++)
  13059. {
  13060. node= configData.at(i).toElement();
  13061. if(node.attribute("name")=="columnname")
  13062. {
  13063. columnName->setText(node.attribute("value"));
  13064. }
  13065. else if(node.attribute("name")=="hidden")
  13066. {
  13067. hideSeries->setChecked(node.attribute("value")=="true");
  13068. }
  13069. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13070. {
  13071. int column= 0;
  13072. if(node.attribute("name")=="values")
  13073. {
  13074. column= 1;
  13075. }
  13076. QString data= node.attribute("value");
  13077. if(data.length()> 3)
  13078. {
  13079. data.chop(2);
  13080. data= data.remove(0,2);
  13081. }
  13082. QStringList keyList= data.split(", ");
  13083. for(int j= 0;j<keyList.size();j++)
  13084. {
  13085. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13086. QVariant(keyList.at(j)),
  13087. Qt::EditRole);
  13088. }
  13089. }
  13090. }
  13091. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13092. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13093. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13094. this,SLOT(updateConfiguration()));
  13095. }
  13096. /*:884*//*885:*/
  13097. #line 244 "./unsupportedserial.w"
  13098. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13099. {
  13100. updateAttribute("columnname",value);
  13101. }
  13102. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13103. {
  13104. updateAttribute("hidden",hidden?"true":"false");
  13105. }
  13106. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13107. {
  13108. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13109. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13110. }
  13111. /*:885*/
  13112. #line 640 "./unsupportedserial.w"
  13113. /*892:*/
  13114. #line 371 "./unsupportedserial.w"
  13115. void JavaScriptDevice::start()
  13116. {
  13117. QScriptValue object= scriptengine->newQObject(this);
  13118. /*893:*/
  13119. #line 390 "./unsupportedserial.w"
  13120. QScriptValue settingsObject= scriptengine->newObject();
  13121. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13122. while(i!=deviceSettings.constEnd())
  13123. {
  13124. settingsObject.setProperty(i.key(),i.value().toString());
  13125. i++;
  13126. }
  13127. object.setProperty("settings",settingsObject);
  13128. /*:893*/
  13129. #line 375 "./unsupportedserial.w"
  13130. /*894:*/
  13131. #line 405 "./unsupportedserial.w"
  13132. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13133. for(int i= 0;i<channelCount();i++)
  13134. {
  13135. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13136. QScriptValue channelSettingsObject= scriptengine->newObject();
  13137. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13138. while(j!=channelSettings.at(i).constEnd())
  13139. {
  13140. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13141. j++;
  13142. }
  13143. channelObject.setProperty("settings",channelSettingsObject);
  13144. channelsArray.setProperty(i,channelObject);
  13145. }
  13146. object.setProperty("channels",channelsArray);
  13147. /*:894*/
  13148. #line 376 "./unsupportedserial.w"
  13149. QScriptContext*context= scriptengine->currentContext();
  13150. QScriptValue oldThis= context->thisObject();
  13151. context->setThisObject(object);
  13152. QScriptValue result= scriptengine->evaluate(deviceScript);
  13153. QScriptEngine*engine= scriptengine;
  13154. /*192:*/
  13155. #line 4449 "./typica.w"
  13156. if(engine->hasUncaughtException())
  13157. {
  13158. int line= engine->uncaughtExceptionLineNumber();
  13159. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13160. result.toString();
  13161. QString trace;
  13162. foreach(trace,engine->uncaughtExceptionBacktrace())
  13163. {
  13164. qDebug()<<trace;
  13165. }
  13166. }
  13167. /*:192*/
  13168. #line 382 "./unsupportedserial.w"
  13169. context->setThisObject(oldThis);
  13170. }
  13171. /*:892*//*897:*/
  13172. #line 446 "./unsupportedserial.w"
  13173. void JavaScriptDevice::stop()
  13174. {
  13175. emit deviceStopRequested();
  13176. }
  13177. /*:897*//*898:*/
  13178. #line 459 "./unsupportedserial.w"
  13179. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13180. QScriptEngine*engine):
  13181. QObject(NULL),scriptengine(engine)
  13182. {
  13183. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13184. QDomElement deviceReferenceElement=
  13185. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13186. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13187. QDomElement node;
  13188. QStringList deviceKeys;
  13189. QStringList deviceValues;
  13190. for(int i= 0;i<deviceConfigData.size();i++)
  13191. {
  13192. node= deviceConfigData.at(i).toElement();
  13193. if(node.attribute("name")=="keys")
  13194. {
  13195. QString data= node.attribute("value");
  13196. if(data.length()> 3)
  13197. {
  13198. data.chop(2);
  13199. data= data.remove(0,2);
  13200. }
  13201. deviceKeys= data.split(", ");
  13202. }
  13203. else if(node.attribute("name")=="values")
  13204. {
  13205. QString data= node.attribute("value");
  13206. if(data.length()> 3)
  13207. {
  13208. data.chop(2);
  13209. data= data.remove(0,2);
  13210. }
  13211. deviceValues= data.split(", ");
  13212. }
  13213. else if(node.attribute("name")=="script")
  13214. {
  13215. deviceScript= node.attribute("value");
  13216. }
  13217. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13218. }
  13219. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13220. {
  13221. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13222. }
  13223. if(model->hasChildren(index))
  13224. {
  13225. for(int i= 0;i<model->rowCount(index);i++)
  13226. {
  13227. QModelIndex channelIndex= model->index(i,0,index);
  13228. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13229. channelList.append(new Channel);
  13230. QDomElement channelReferenceElement=
  13231. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13232. QDomNodeList channelConfigData=
  13233. channelReferenceElement.elementsByTagName("attribute");
  13234. QStringList channelKeys;
  13235. QStringList channelValues;
  13236. for(int j= 0;j<channelConfigData.size();j++)
  13237. {
  13238. node= channelConfigData.at(j).toElement();
  13239. if(node.attribute("name")=="keys")
  13240. {
  13241. QString data= node.attribute("value");
  13242. if(data.length()> 3)
  13243. {
  13244. data.chop(2);
  13245. data= data.remove(0,2);
  13246. }
  13247. channelKeys= data.split(", ");
  13248. }
  13249. else if(node.attribute("name")=="values")
  13250. {
  13251. QString data= node.attribute("value");
  13252. if(data.length()> 3)
  13253. {
  13254. data.chop(2);
  13255. data= data.remove(0,2);
  13256. }
  13257. channelValues= data.split(", ");
  13258. }
  13259. else if(node.attribute("name")=="hidden")
  13260. {
  13261. hiddenState.append(node.attribute("value")=="true");
  13262. }
  13263. else if(node.attribute("name")=="columnname")
  13264. {
  13265. columnNames.append(node.attribute("value"));
  13266. }
  13267. }
  13268. QVariantMap cs;
  13269. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13270. {
  13271. cs.insert(channelKeys[j],channelValues[j]);
  13272. }
  13273. channelSettings.append(cs);
  13274. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13275. channelUnits.append(Units::Fahrenheit);
  13276. }
  13277. }
  13278. }
  13279. /*:898*//*899:*/
  13280. #line 564 "./unsupportedserial.w"
  13281. int JavaScriptDevice::channelCount()
  13282. {
  13283. return channelList.length();
  13284. }
  13285. Channel*JavaScriptDevice::getChannel(int channel)
  13286. {
  13287. return channelList.at(channel);
  13288. }
  13289. bool JavaScriptDevice::isChannelHidden(int channel)
  13290. {
  13291. return hiddenState.at(channel);
  13292. }
  13293. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13294. {
  13295. return channelUnits.at(channel);
  13296. }
  13297. QString JavaScriptDevice::channelColumnName(int channel)
  13298. {
  13299. if(channel>=0&&channel<columnNames.length())
  13300. {
  13301. return columnNames.at(channel);
  13302. }
  13303. return QString();
  13304. }
  13305. QString JavaScriptDevice::channelIndicatorText(int channel)
  13306. {
  13307. return indicatorTexts.at(channel);
  13308. }
  13309. /*:899*//*900:*/
  13310. #line 601 "./unsupportedserial.w"
  13311. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13312. {
  13313. annotationTemperatureColumn= tcol;
  13314. }
  13315. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13316. {
  13317. annotationNoteColumn= ncol;
  13318. }
  13319. /*:900*/
  13320. #line 641 "./unsupportedserial.w"
  13321. /*:904*//*930:*/
  13322. #line 444 "./phidgets.w"
  13323. /*914:*/
  13324. #line 31 "./phidgets.w"
  13325. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13326. const QModelIndex&index)
  13327. :BasicDeviceConfigurationWidget(model,index)
  13328. {
  13329. QFormLayout*layout= new QFormLayout;
  13330. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13331. QSpinBox*sampleRate= new QSpinBox;
  13332. sampleRate->setMinimum(40);
  13333. sampleRate->setMaximum(600);
  13334. sampleRate->setSingleStep(40);
  13335. sampleRate->setValue(360);
  13336. /*771:*/
  13337. #line 16337 "./typica.w"
  13338. QDomElement referenceElement=
  13339. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13340. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13341. QDomElement node;
  13342. /*:771*/
  13343. #line 44 "./phidgets.w"
  13344. for(int i= 0;i<configData.size();i++)
  13345. {
  13346. node= configData.at(i).toElement();
  13347. if(node.attribute("name")=="sampleRate")
  13348. {
  13349. sampleRate->setValue(node.attribute("value").toInt());
  13350. }
  13351. }
  13352. updateRate(sampleRate->value());
  13353. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13354. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13355. layout->addRow(addChannelButton);
  13356. layout->addRow(tr("Sample rate:"),sampleRate);
  13357. setLayout(layout);
  13358. }
  13359. /*:914*//*915:*/
  13360. #line 66 "./phidgets.w"
  13361. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13362. {
  13363. insertChildNode(tr("Channel"),"phidgets1048channel");
  13364. }
  13365. /*:915*//*916:*/
  13366. #line 74 "./phidgets.w"
  13367. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13368. {
  13369. updateAttribute("sampleRate",QString("%1").arg(ms));
  13370. }
  13371. /*:916*//*918:*/
  13372. #line 103 "./phidgets.w"
  13373. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13374. DeviceTreeModel*model,const QModelIndex&index)
  13375. :BasicDeviceConfigurationWidget(model,index),
  13376. tcType(new QComboBox)
  13377. {
  13378. QFormLayout*layout= new QFormLayout;
  13379. QLineEdit*columnName= new QLineEdit;
  13380. layout->addRow(tr("Column Name:"),columnName);
  13381. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13382. layout->addRow(hideSeries);
  13383. layout->addRow(tr("Thermocouple Type:"),tcType);
  13384. tcType->addItem("Type K","1");
  13385. tcType->addItem("Type J","2");
  13386. tcType->addItem("Type E","3");
  13387. tcType->addItem("Type T","4");
  13388. QSpinBox*channel= new QSpinBox;
  13389. layout->addRow(tr("Channel:"),channel);
  13390. channel->setMinimum(0);
  13391. channel->setMaximum(3);
  13392. setLayout(layout);
  13393. /*771:*/
  13394. #line 16337 "./typica.w"
  13395. QDomElement referenceElement=
  13396. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13397. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13398. QDomElement node;
  13399. /*:771*/
  13400. #line 124 "./phidgets.w"
  13401. for(int i= 0;i<configData.size();i++)
  13402. {
  13403. node= configData.at(i).toElement();
  13404. if(node.attribute("name")=="columnname")
  13405. {
  13406. columnName->setText(node.attribute("value"));
  13407. }
  13408. else if(node.attribute("name")=="hidden")
  13409. {
  13410. hideSeries->setChecked(node.attribute("value")=="true");
  13411. }
  13412. else if(node.attribute("name")=="tctype")
  13413. {
  13414. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  13415. }
  13416. else if(node.attribute("name")=="channel")
  13417. {
  13418. channel->setValue(node.attribute("value").toInt());
  13419. }
  13420. }
  13421. updateColumnName(columnName->text());
  13422. updateHidden(hideSeries->isChecked());
  13423. updateTC(tcType->currentIndex());
  13424. updateChannel(channel->value());
  13425. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13426. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13427. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  13428. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  13429. }
  13430. /*:918*//*919:*/
  13431. #line 157 "./phidgets.w"
  13432. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  13433. {
  13434. updateAttribute("columnname",value);
  13435. }
  13436. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  13437. {
  13438. updateAttribute("hidden",hidden?"true":"false");
  13439. }
  13440. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  13441. {
  13442. updateAttribute("tctype",tcType->itemData(index).toString());
  13443. }
  13444. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  13445. {
  13446. updateAttribute("channel",QString("%1").arg(channel));
  13447. }
  13448. /*:919*//*923:*/
  13449. #line 246 "./phidgets.w"
  13450. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  13451. :QObject(NULL),driver("phidget21"),device(NULL)
  13452. {
  13453. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13454. QDomElement deviceReferenceElement=
  13455. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13456. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13457. QDomElement node;
  13458. for(int i= 0;i<deviceConfigData.size();i++)
  13459. {
  13460. node= deviceConfigData.at(i).toElement();
  13461. if(node.attribute("name")=="sampleRate")
  13462. {
  13463. sampleTimer.setInterval(node.attribute("value").toInt());
  13464. }
  13465. }
  13466. if(model->hasChildren(index))
  13467. {
  13468. for(int i= 0;i<model->rowCount(index);i++)
  13469. {
  13470. QModelIndex channelIndex= model->index(i,0,index);
  13471. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13472. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13473. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  13474. for(int j= 0;j<channelConfigData.size();j++)
  13475. {
  13476. node= channelConfigData.at(j).toElement();
  13477. if(node.attribute("name")=="channel")
  13478. {
  13479. int channelID= node.attribute("value").toInt();
  13480. channelIndices.append(channelID);
  13481. Channel*channel= new Channel;
  13482. channelList.append(channel);
  13483. channelMap.insert(channelID,channel);
  13484. }
  13485. else if(node.attribute("name")=="hidden")
  13486. {
  13487. hiddenState.append(node.attribute("value")=="true");
  13488. }
  13489. else if(node.attribute("name")=="columnname")
  13490. {
  13491. columnNames.append(node.attribute("value"));
  13492. }
  13493. else if(node.attribute("name")=="tctype")
  13494. {
  13495. tctypes.append(node.attribute("value").toInt());
  13496. }
  13497. }
  13498. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13499. }
  13500. }
  13501. }
  13502. /*:923*//*924:*/
  13503. #line 306 "./phidgets.w"
  13504. int PhidgetsTemperatureSensor::channelCount()
  13505. {
  13506. return channelList.length();
  13507. }
  13508. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  13509. {
  13510. return channelList.at(channel);
  13511. }
  13512. /*:924*//*925:*/
  13513. #line 319 "./phidgets.w"
  13514. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  13515. {
  13516. return hiddenState.at(channel);
  13517. }
  13518. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  13519. {
  13520. if(channel>=0&&channel<columnNames.length())
  13521. {
  13522. return columnNames.at(channel);
  13523. }
  13524. return QString();
  13525. }
  13526. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  13527. {
  13528. if(channel>=0&&channel<indicatorTexts.length())
  13529. {
  13530. return indicatorTexts.at(channel);
  13531. }
  13532. return QString();
  13533. }
  13534. /*:925*//*927:*/
  13535. #line 371 "./phidgets.w"
  13536. void PhidgetsTemperatureSensor::start()
  13537. {
  13538. if(!driver.load())
  13539. {
  13540. driver.setFileName("Phidget21.framework/Phidget21");
  13541. if(!driver.load())
  13542. {
  13543. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  13544. tr("Failed to find phidget21. Please install it."));
  13545. return;
  13546. }
  13547. }
  13548. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  13549. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  13550. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  13551. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  13552. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  13553. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  13554. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  13555. {
  13556. QMessageBox::critical(NULL,tr("Typica: Link error"),
  13557. tr("Failed to link a required symbol in phidget21."));
  13558. return;
  13559. }
  13560. createDevice(&device);
  13561. openDevice(device,-1);
  13562. int error;
  13563. if((error= waitForOpen(device,10000)))
  13564. {
  13565. closeDevice(device);
  13566. deleteDevice(device);
  13567. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  13568. tr("CPhidget_waitForAttachment returns error %n",0,error));
  13569. return;
  13570. }
  13571. for(int i= 0;i<channelIndices.length();i++)
  13572. {
  13573. setTCType(device,channelIndices.at(i),tctypes.at(i));
  13574. }
  13575. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  13576. sampleTimer.start();
  13577. }
  13578. /*:927*//*928:*/
  13579. #line 418 "./phidgets.w"
  13580. void PhidgetsTemperatureSensor::getMeasurements()
  13581. {
  13582. double value= 0.0;
  13583. QTime time= QTime::currentTime();
  13584. foreach(int i,channelIndices)
  13585. {
  13586. getTemperature(device,i,&value);
  13587. Measurement measure(value*9.0/5.0+32.0,time);
  13588. channelMap[i]->input(measure);
  13589. }
  13590. }
  13591. /*:928*//*929:*/
  13592. #line 433 "./phidgets.w"
  13593. void PhidgetsTemperatureSensor::stop()
  13594. {
  13595. sampleTimer.stop();
  13596. closeDevice(device);
  13597. deleteDevice(device);
  13598. driver.unload();
  13599. }
  13600. /*:929*/
  13601. #line 445 "./phidgets.w"
  13602. /*:930*//*944:*/
  13603. #line 19533 "./typica.w"
  13604. /*942:*/
  13605. #line 19495 "./typica.w"
  13606. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  13607. const QModelIndex&index)
  13608. :BasicDeviceConfigurationWidget(model,index)
  13609. {
  13610. QHBoxLayout*layout= new QHBoxLayout;
  13611. QLabel*label= new QLabel(tr("Cooling Time: "));
  13612. QTimeEdit*editor= new QTimeEdit;
  13613. editor->setDisplayFormat("mm:ss");
  13614. /*771:*/
  13615. #line 16337 "./typica.w"
  13616. QDomElement referenceElement=
  13617. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13618. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13619. QDomElement node;
  13620. /*:771*/
  13621. #line 19504 "./typica.w"
  13622. for(int i= 0;i<configData.size();i++)
  13623. {
  13624. node= configData.at(i).toElement();
  13625. if(node.attribute("name")=="reset")
  13626. {
  13627. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  13628. }
  13629. }
  13630. updateResetTime(editor->time());
  13631. connect(editor,SIGNAL(timeChanged(QTime)),
  13632. this,SLOT(updateResetTime(QTime)));
  13633. layout->addWidget(label);
  13634. layout->addWidget(editor);
  13635. setLayout(layout);
  13636. }
  13637. void CoolingTimerConfWidget::updateResetTime(QTime time)
  13638. {
  13639. updateAttribute("reset",time.toString("mm:ss"));
  13640. }
  13641. /*:942*/
  13642. #line 19534 "./typica.w"
  13643. /*:944*//*949:*/
  13644. #line 19792 "./typica.w"
  13645. /*946:*/
  13646. #line 19566 "./typica.w"
  13647. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13648. :BasicDeviceConfigurationWidget(model,index)
  13649. {
  13650. QVBoxLayout*layout= new QVBoxLayout;
  13651. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  13652. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  13653. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  13654. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  13655. QButtonGroup*startOptionGroup= new QButtonGroup;
  13656. startOptionGroup->addButton(startBatchOption,1);
  13657. startOptionGroup->addButton(buttonOption,2);
  13658. startOptionGroup->addButton(thresholdOption,3);
  13659. startBatchOption->setChecked(true);
  13660. QGridLayout*startOptions= new QGridLayout;
  13661. startOptions->addWidget(startBatchOption,0,0);
  13662. startOptions->addWidget(buttonOption,1,0);
  13663. startOptions->addWidget(thresholdOption,2,0);
  13664. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  13665. QLineEdit*buttonTextEdit= new QLineEdit;
  13666. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  13667. buttonTextOptions->addWidget(buttonTextLabel);
  13668. buttonTextOptions->addWidget(buttonTextEdit);
  13669. startOptions->addLayout(buttonTextOptions,1,1);
  13670. QFormLayout*thresholdOptions= new QFormLayout;
  13671. QLineEdit*startColumnName= new QLineEdit;
  13672. QLineEdit*startValue= new QLineEdit;
  13673. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  13674. thresholdOptions->addRow(tr("Value: "),startValue);
  13675. startOptions->addLayout(thresholdOptions,2,1);
  13676. startConfigurationGroup->setLayout(startOptions);
  13677. layout->addWidget(startConfigurationGroup);
  13678. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  13679. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  13680. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  13681. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  13682. QButtonGroup*stopOptionGroup= new QButtonGroup;
  13683. stopOptionGroup->addButton(stopBatchOption,1);
  13684. stopOptionGroup->addButton(stopButtonOption,2);
  13685. stopOptionGroup->addButton(stopThresholdOption,3);
  13686. stopBatchOption->setChecked(true);
  13687. QGridLayout*stopOptions= new QGridLayout;
  13688. stopOptions->addWidget(stopBatchOption,0,0);
  13689. stopOptions->addWidget(stopButtonOption,1,0);
  13690. stopOptions->addWidget(stopThresholdOption,2,0);
  13691. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  13692. QLineEdit*stopButtonEdit= new QLineEdit;
  13693. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  13694. stopButtonTextOptions->addWidget(stopButtonLabel);
  13695. stopButtonTextOptions->addWidget(stopButtonEdit);
  13696. stopOptions->addLayout(stopButtonTextOptions,1,1);
  13697. QLineEdit*stopColumnName= new QLineEdit;
  13698. QLineEdit*stopValue= new QLineEdit;
  13699. QFormLayout*stopThresholdOptions= new QFormLayout;
  13700. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  13701. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  13702. stopOptions->addLayout(stopThresholdOptions,2,1);
  13703. stopConfigurationGroup->setLayout(stopOptions);
  13704. layout->addWidget(stopConfigurationGroup);
  13705. /*771:*/
  13706. #line 16337 "./typica.w"
  13707. QDomElement referenceElement=
  13708. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13709. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13710. QDomElement node;
  13711. /*:771*/
  13712. #line 19628 "./typica.w"
  13713. for(int i= 0;i<configData.size();i++)
  13714. {
  13715. node= configData.at(i).toElement();
  13716. if(node.attribute("name")=="startbuttontext")
  13717. {
  13718. buttonTextEdit->setText(node.attribute("value"));
  13719. }
  13720. else if(node.attribute("name")=="stopbuttontext")
  13721. {
  13722. stopButtonEdit->setText(node.attribute("value"));
  13723. }
  13724. else if(node.attribute("name")=="startcolumnname")
  13725. {
  13726. startColumnName->setText(node.attribute("value"));
  13727. }
  13728. else if(node.attribute("name")=="stopcolumnname")
  13729. {
  13730. stopColumnName->setText(node.attribute("value"));
  13731. }
  13732. else if(node.attribute("name")=="startvalue")
  13733. {
  13734. startValue->setText(node.attribute("value"));
  13735. }
  13736. else if(node.attribute("name")=="stopvalue")
  13737. {
  13738. stopValue->setText(node.attribute("value"));
  13739. }
  13740. else if(node.attribute("name")=="starttrigger")
  13741. {
  13742. if(node.attribute("value")=="batch")
  13743. {
  13744. startBatchOption->setChecked(true);
  13745. }
  13746. else if(node.attribute("value")=="manual")
  13747. {
  13748. buttonOption->setChecked(true);
  13749. }
  13750. else if(node.attribute("value")=="value")
  13751. {
  13752. thresholdOption->setChecked(true);
  13753. }
  13754. }
  13755. else if(node.attribute("name")=="stoptrigger")
  13756. {
  13757. if(node.attribute("value")=="batch")
  13758. {
  13759. stopBatchOption->setChecked(true);
  13760. }
  13761. else if(node.attribute("value")=="manual")
  13762. {
  13763. stopButtonOption->setChecked(true);
  13764. }
  13765. else if(node.attribute("value")=="value")
  13766. {
  13767. stopThresholdOption->setChecked(true);
  13768. }
  13769. }
  13770. }
  13771. updateStartButtonText(buttonTextEdit->text());
  13772. updateStopButtonText(stopButtonEdit->text());
  13773. updateStartColumnName(startColumnName->text());
  13774. updateStopColumnName(stopColumnName->text());
  13775. updateStartValue(startValue->text());
  13776. updateStopValue(stopValue->text());
  13777. updateStartTrigger(startOptionGroup->checkedId());
  13778. updateStopTrigger(stopOptionGroup->checkedId());
  13779. setLayout(layout);
  13780. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  13781. this,SLOT(updateStartButtonText(QString)));
  13782. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  13783. this,SLOT(updateStopButtonText(QString)));
  13784. connect(startColumnName,SIGNAL(textChanged(QString)),
  13785. this,SLOT(updateStartColumnName(QString)));
  13786. connect(stopColumnName,SIGNAL(textChanged(QString)),
  13787. this,SLOT(updateStopColumnName(QString)));
  13788. connect(startValue,SIGNAL(textChanged(QString)),
  13789. this,SLOT(updateStartValue(QString)));
  13790. connect(stopValue,SIGNAL(textChanged(QString)),
  13791. this,SLOT(updateStopValue(QString)));
  13792. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  13793. this,SLOT(updateStartTrigger(int)));
  13794. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  13795. this,SLOT(updateStopTrigger(int)));
  13796. }
  13797. /*:946*//*947:*/
  13798. #line 19718 "./typica.w"
  13799. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  13800. {
  13801. updateAttribute("startbuttontext",text);
  13802. }
  13803. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  13804. {
  13805. updateAttribute("stopbuttontext",text);
  13806. }
  13807. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  13808. {
  13809. updateAttribute("startcolumnname",text);
  13810. }
  13811. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  13812. {
  13813. updateAttribute("stopcolumnname",text);
  13814. }
  13815. void RangeTimerConfWidget::updateStartValue(const QString&text)
  13816. {
  13817. updateAttribute("startvalue",text);
  13818. }
  13819. void RangeTimerConfWidget::updateStopValue(const QString&text)
  13820. {
  13821. updateAttribute("stopvalue",text);
  13822. }
  13823. void RangeTimerConfWidget::updateStartTrigger(int option)
  13824. {
  13825. switch(option)
  13826. {
  13827. case 1:
  13828. updateAttribute("starttrigger","batch");
  13829. break;
  13830. case 2:
  13831. updateAttribute("starttrigger","manual");
  13832. break;
  13833. case 3:
  13834. updateAttribute("starttrigger","value");
  13835. break;
  13836. default:
  13837. break;
  13838. }
  13839. }
  13840. void RangeTimerConfWidget::updateStopTrigger(int option)
  13841. {
  13842. switch(option)
  13843. {
  13844. case 1:
  13845. updateAttribute("stoptrigger","batch");
  13846. break;
  13847. case 2:
  13848. updateAttribute("stoptrigger","manual");
  13849. break;
  13850. case 3:
  13851. updateAttribute("stoptrigger","value");
  13852. break;
  13853. default:
  13854. break;
  13855. }
  13856. }
  13857. /*:947*/
  13858. #line 19793 "./typica.w"
  13859. /*:949*//*954:*/
  13860. #line 19893 "./typica.w"
  13861. /*951:*/
  13862. #line 19817 "./typica.w"
  13863. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  13864. const QModelIndex&index)
  13865. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  13866. {
  13867. QFormLayout*layout= new QFormLayout;
  13868. QLineEdit*trigger= new QLineEdit;
  13869. layout->addRow(tr("Trigger column name:"),trigger);
  13870. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  13871. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  13872. QTableView*rangeTable= new QTableView;
  13873. rangeTable->setModel(tablemodel);
  13874. layout->addRow(tr("Range data:"),rangeTable);
  13875. /*771:*/
  13876. #line 16337 "./typica.w"
  13877. QDomElement referenceElement=
  13878. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13879. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13880. QDomElement node;
  13881. /*:771*/
  13882. #line 19830 "./typica.w"
  13883. for(int i= 0;i<configData.size();i++)
  13884. {
  13885. node= configData.at(i).toElement();
  13886. if(node.attribute("name")=="trigger")
  13887. {
  13888. trigger->setText(node.attribute("value"));
  13889. }
  13890. else if(node.attribute("name")=="rangenames")
  13891. {
  13892. QString data= node.attribute("value");
  13893. if(data.length()> 3)
  13894. {
  13895. data.chop(2);
  13896. data= data.remove(0,2);
  13897. }
  13898. QStringList itemList= data.split(", ");
  13899. for(int j= 0;j<itemList.size();j++)
  13900. {
  13901. QString item= itemList.at(j);
  13902. item.chop(1);
  13903. item= item.remove(0,1);
  13904. tablemodel->setData(tablemodel->index(j,0),
  13905. QVariant(item),Qt::DisplayRole);
  13906. }
  13907. }
  13908. else if(node.attribute("name")=="endtemps")
  13909. {
  13910. /*937:*/
  13911. #line 19425 "./typica.w"
  13912. QString data= node.attribute("value");
  13913. if(data.length()> 3)
  13914. {
  13915. data.chop(2);
  13916. data= data.remove(0,2);
  13917. }
  13918. QStringList itemList= data.split(",");
  13919. /*:937*/
  13920. #line 19858 "./typica.w"
  13921. int column= 1;
  13922. /*938:*/
  13923. #line 19437 "./typica.w"
  13924. for(int j= 0;j<itemList.size();j++)
  13925. {
  13926. tablemodel->setData(tablemodel->index(j,column),
  13927. QVariant(itemList.at(j).toDouble()),
  13928. Qt::DisplayRole);
  13929. }
  13930. /*:938*/
  13931. #line 19860 "./typica.w"
  13932. }
  13933. }
  13934. updateColumnName(trigger->text());
  13935. updateRangeData();
  13936. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13937. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  13938. setLayout(layout);
  13939. }
  13940. /*:951*//*952:*/
  13941. #line 19874 "./typica.w"
  13942. void MultiRangeTimerConfWidget::updateRangeData()
  13943. {
  13944. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  13945. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  13946. }
  13947. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  13948. {
  13949. updateAttribute("trigger",text);
  13950. }
  13951. /*:952*/
  13952. #line 19894 "./typica.w"
  13953. /*:954*//*972:*/
  13954. #line 265 "./rate.w"
  13955. /*968:*/
  13956. #line 191 "./rate.w"
  13957. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  13958. :BasicDeviceConfigurationWidget(model,index)
  13959. {
  13960. QFormLayout*layout= new QFormLayout;
  13961. QLineEdit*column= new QLineEdit;
  13962. layout->addRow(tr("Primary series column name:"),column);
  13963. QSpinBox*cacheTime= new QSpinBox;
  13964. cacheTime->setMinimum(0);
  13965. cacheTime->setMaximum(300);
  13966. layout->addRow(tr("Cache time:"),cacheTime);
  13967. QSpinBox*scaleTime= new QSpinBox;
  13968. scaleTime->setMinimum(1);
  13969. scaleTime->setMaximum(300);
  13970. layout->addRow(tr("Scale time:"),scaleTime);
  13971. /*771:*/
  13972. #line 16337 "./typica.w"
  13973. QDomElement referenceElement=
  13974. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13975. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13976. QDomElement node;
  13977. /*:771*/
  13978. #line 206 "./rate.w"
  13979. for(int i= 0;i<configData.size();i++)
  13980. {
  13981. node= configData.at(i).toElement();
  13982. if(node.attribute("name")=="column")
  13983. {
  13984. column->setText(node.attribute("value"));
  13985. }
  13986. else if(node.attribute("name")=="cache")
  13987. {
  13988. cacheTime->setValue(node.attribute("value").toInt());
  13989. }
  13990. else if(node.attribute("name")=="scale")
  13991. {
  13992. scaleTime->setValue(node.attribute("value").toInt());
  13993. }
  13994. }
  13995. updateColumn(column->text());
  13996. updateCacheTime(cacheTime->text());
  13997. updateScaleTime(scaleTime->text());
  13998. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  13999. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  14000. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  14001. setLayout(layout);
  14002. }
  14003. /*:968*//*969:*/
  14004. #line 235 "./rate.w"
  14005. void RateOfChangeConfWidget::updateColumn(const QString&column)
  14006. {
  14007. updateAttribute("column",column);
  14008. }
  14009. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  14010. {
  14011. updateAttribute("cache",seconds);
  14012. }
  14013. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  14014. {
  14015. updateAttribute("scale",seconds);
  14016. }
  14017. /*:969*/
  14018. #line 266 "./rate.w"
  14019. #line 19986 "./typica.w"
  14020. #line 1 "./dataqsdk.w"
  14021. /*:972*/
  14022. #line 529 "./typica.w"
  14023. /*8:*/
  14024. #line 675 "./typica.w"
  14025. template<class TYPE> TYPE getself(QScriptContext*context)
  14026. {
  14027. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  14028. return self;
  14029. }
  14030. template<> QTime getself(QScriptContext*context)
  14031. {
  14032. QTime self= context->thisObject().toVariant().toTime();
  14033. return self;
  14034. }
  14035. template<> QByteArray getself(QScriptContext*context)
  14036. {
  14037. QByteArray self= context->thisObject().toVariant().toByteArray();
  14038. return self;
  14039. }
  14040. template<> SqlQueryConnection*getself(QScriptContext*context)
  14041. {
  14042. SqlQueryConnection*self=
  14043. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  14044. return self;
  14045. }
  14046. template<> QXmlQuery*getself(QScriptContext*context)
  14047. {
  14048. QXmlQuery*self=
  14049. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  14050. return self;
  14051. }
  14052. template<> QXmlStreamWriter*getself(QScriptContext*context)
  14053. {
  14054. QXmlStreamWriter*self=
  14055. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  14056. return self;
  14057. }
  14058. template<> QXmlStreamReader*getself(QScriptContext*context)
  14059. {
  14060. QXmlStreamReader*self=
  14061. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  14062. return self;
  14063. }
  14064. /*:8*//*9:*/
  14065. #line 726 "./typica.w"
  14066. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  14067. {
  14068. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  14069. return argument;
  14070. }
  14071. template<> QString argument(int arg,QScriptContext*context)
  14072. {
  14073. return context->argument(arg).toString();
  14074. }
  14075. template<> QVariant argument(int arg,QScriptContext*context)
  14076. {
  14077. return context->argument(arg).toVariant();
  14078. }
  14079. template<> int argument(int arg,QScriptContext*context)
  14080. {
  14081. return context->argument(arg).toInt32();
  14082. }
  14083. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  14084. {
  14085. return(SqlQueryConnection*)
  14086. qscriptvalue_cast<void*> (context->argument(arg));
  14087. }
  14088. template<> QModelIndex argument(int arg,QScriptContext*context)
  14089. {
  14090. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  14091. }
  14092. template<> double argument(int arg,QScriptContext*context)
  14093. {
  14094. return(double)(context->argument(arg).toNumber());
  14095. }
  14096. template<> Units::Unit argument(int arg,QScriptContext*context)
  14097. {
  14098. return(Units::Unit)(context->argument(arg).toInt32());
  14099. }
  14100. template<> QByteArray argument(int arg,QScriptContext*context)
  14101. {
  14102. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  14103. }
  14104. /*:9*//*13:*/
  14105. #line 818 "./typica.w"
  14106. void setQObjectProperties(QScriptValue,QScriptEngine*)
  14107. {
  14108. }
  14109. /*:13*//*15:*/
  14110. #line 832 "./typica.w"
  14111. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  14112. {
  14113. }
  14114. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  14115. {
  14116. }
  14117. /*:15*//*18:*/
  14118. #line 871 "./typica.w"
  14119. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  14120. {
  14121. QScriptValue object= engine->newQObject(new QWidget);
  14122. setQWidgetProperties(object,engine);
  14123. return object;
  14124. }
  14125. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14126. {
  14127. setQObjectProperties(value,engine);
  14128. setQPaintDeviceProperties(value,engine);
  14129. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  14130. value.setProperty("activateWindow",
  14131. engine->newFunction(QWidget_activateWindow));
  14132. }
  14133. /*:18*//*19:*/
  14134. #line 893 "./typica.w"
  14135. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  14136. {
  14137. if(context->argumentCount()==1)
  14138. {
  14139. QWidget*self= getself<QWidget*> (context);
  14140. QLayout*layout= argument<QLayout*> (0,context);
  14141. if(layout)
  14142. {
  14143. self->setLayout(layout);
  14144. }
  14145. else
  14146. {
  14147. context->throwError("Incorrect argument type passed to "
  14148. "QWidget::setLayout(). This method requires "
  14149. "a QLayout.");
  14150. }
  14151. }
  14152. else
  14153. {
  14154. context->throwError("Incorrect number of arguments passed to "
  14155. "QWidget::setLayout(). This method takes one "
  14156. "QLayout as an argument.");
  14157. }
  14158. return QScriptValue();
  14159. }
  14160. QScriptValue QWidget_activateWindow(QScriptContext*context,
  14161. QScriptEngine*)
  14162. {
  14163. QWidget*self= getself<QWidget*> (context);
  14164. self->activateWindow();
  14165. return QScriptValue();
  14166. }
  14167. /*:19*//*22:*/
  14168. #line 955 "./typica.w"
  14169. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  14170. {
  14171. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  14172. argument<QString> (0,context),
  14173. argument<QString> (1,context),
  14174. QMessageBox::Ok|QMessageBox::Cancel);
  14175. if(selection==QMessageBox::Ok){
  14176. return QScriptValue(true);
  14177. }
  14178. return QScriptValue(false);
  14179. }
  14180. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  14181. {
  14182. QMessageBox::critical(NULL,argument<QString> (0,context),
  14183. argument<QString> (1,context));
  14184. return QScriptValue();
  14185. }
  14186. /*:22*//*24:*/
  14187. #line 1022 "./typica.w"
  14188. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  14189. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  14190. {
  14191. }
  14192. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  14193. {
  14194. QSettings settings;
  14195. settings.beginGroup(key);
  14196. settings.setValue("pos",pos());
  14197. settings.setValue("size",size());
  14198. settings.endGroup();
  14199. }
  14200. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  14201. {
  14202. QSettings settings;
  14203. settings.beginGroup(key);
  14204. if(settings.contains("size"))
  14205. {
  14206. resize(settings.value("size").toSize());
  14207. }
  14208. if(settings.contains("pos"))
  14209. {
  14210. move(settings.value("pos").toPoint());
  14211. }
  14212. settings.endGroup();
  14213. }
  14214. void ScriptQMainWindow::displayStatus(const QString&message)
  14215. {
  14216. statusBar()->showMessage(message);
  14217. }
  14218. void ScriptQMainWindow::showEvent(QShowEvent*event)
  14219. {
  14220. if(!event->spontaneous())
  14221. {
  14222. /*29:*/
  14223. #line 1134 "./typica.w"
  14224. QSettings settings;
  14225. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  14226. toByteArray());
  14227. /*:29*/
  14228. #line 1062 "./typica.w"
  14229. event->accept();
  14230. }
  14231. else
  14232. {
  14233. event->ignore();
  14234. }
  14235. }
  14236. void ScriptQMainWindow::show()
  14237. {
  14238. QMainWindow::show();
  14239. }
  14240. /*:24*//*25:*/
  14241. #line 1083 "./typica.w"
  14242. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  14243. {
  14244. if(isWindowModified()){
  14245. /*26:*/
  14246. #line 1097 "./typica.w"
  14247. QMessageBox::StandardButton result;
  14248. result= QMessageBox::warning(this,"Typica",closePrompt(),
  14249. QMessageBox::Ok|QMessageBox::Cancel);
  14250. if(result==QMessageBox::Cancel)
  14251. {
  14252. event->ignore();
  14253. return;
  14254. }
  14255. /*:26*/
  14256. #line 1087 "./typica.w"
  14257. }
  14258. emit aboutToClose();
  14259. /*28:*/
  14260. #line 1128 "./typica.w"
  14261. QSettings settings;
  14262. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  14263. /*:28*/
  14264. #line 1090 "./typica.w"
  14265. event->accept();
  14266. }
  14267. /*:25*//*27:*/
  14268. #line 1109 "./typica.w"
  14269. QString ScriptQMainWindow::closePrompt()
  14270. {
  14271. return cprompt;
  14272. }
  14273. void ScriptQMainWindow::setClosePrompt(QString prompt)
  14274. {
  14275. cprompt= prompt;
  14276. }
  14277. /*:27*//*32:*/
  14278. #line 1162 "./typica.w"
  14279. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  14280. {
  14281. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  14282. setQMainWindowProperties(object,engine);
  14283. return object;
  14284. }
  14285. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  14286. {
  14287. setQWidgetProperties(value,engine);
  14288. value.setProperty("setCentralWidget",
  14289. engine->newFunction(QMainWindow_setCentralWidget));
  14290. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  14291. }
  14292. /*:32*//*33:*/
  14293. #line 1184 "./typica.w"
  14294. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  14295. QScriptEngine*)
  14296. {
  14297. if(context->argumentCount()==1)
  14298. {
  14299. QMainWindow*self= getself<QMainWindow*> (context);
  14300. QWidget*widget= argument<QWidget*> (0,context);
  14301. if(widget)
  14302. {
  14303. self->setCentralWidget(widget);
  14304. }
  14305. else
  14306. {
  14307. context->throwError("Incorrect argument type passed to "
  14308. "QMainWindow::setCentralWidget(). This "
  14309. "method requires a QWidget.");
  14310. }
  14311. }
  14312. else
  14313. {
  14314. context->throwError("Incorrect number of arguments passed to "
  14315. "QMainWindow::setCentralWidget(). This method "
  14316. "takes one QWidget as an argument.");
  14317. }
  14318. return QScriptValue();
  14319. }
  14320. /*:33*//*34:*/
  14321. #line 1218 "./typica.w"
  14322. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  14323. {
  14324. QScriptValue object;
  14325. if(context->argumentCount()==0)
  14326. {
  14327. QMainWindow*self= getself<QMainWindow*> (context);
  14328. QMenuBar*bar= self->menuBar();
  14329. object= engine->newQObject(bar);
  14330. setQMenuBarProperties(object,engine);
  14331. }
  14332. else
  14333. {
  14334. context->throwError("Incorrect number of arguments passed to "
  14335. "QMainWindow::menuBar(). This method takes no "
  14336. "arguments.");
  14337. }
  14338. return object;
  14339. }
  14340. /*:34*//*36:*/
  14341. #line 1248 "./typica.w"
  14342. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  14343. {
  14344. setQWidgetProperties(value,engine);
  14345. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  14346. }
  14347. /*:36*//*37:*/
  14348. #line 1263 "./typica.w"
  14349. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  14350. {
  14351. QScriptValue object;
  14352. if(context->argumentCount()==1)
  14353. {
  14354. QMenuBar*self= getself<QMenuBar*> (context);
  14355. QString title= argument<QString> (0,context);
  14356. object= engine->newQObject(self->addMenu(title));
  14357. setQMenuProperties(object,engine);
  14358. }
  14359. else
  14360. {
  14361. context->throwError("Incorrect number of arguments passed to "
  14362. "QMenuBar::addMenu(). This method takes one "
  14363. "string as an argument.");
  14364. }
  14365. return object;
  14366. }
  14367. /*:37*//*39:*/
  14368. #line 1293 "./typica.w"
  14369. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  14370. {
  14371. setQWidgetProperties(value,engine);
  14372. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  14373. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  14374. }
  14375. /*:39*//*40:*/
  14376. #line 1303 "./typica.w"
  14377. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  14378. {
  14379. if(context->argumentCount()==1)
  14380. {
  14381. QMenu*self= getself<QMenu*> (context);
  14382. QAction*action= argument<QAction*> (0,context);
  14383. if(action)
  14384. {
  14385. self->addAction(action);
  14386. }
  14387. else
  14388. {
  14389. context->throwError("Incorrect argument type passed to "
  14390. "QMenu::addAction(). This method requires a "
  14391. "QAction.");
  14392. }
  14393. }
  14394. else
  14395. {
  14396. context->throwError("Incorrect number of arguments passed to "
  14397. "QMenu::addAction(). This method takes one "
  14398. "QAction as an argument.");
  14399. }
  14400. return QScriptValue();
  14401. }
  14402. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  14403. {
  14404. if(context->argumentCount()==0)
  14405. {
  14406. QMenu*self= getself<QMenu*> (context);
  14407. self->addSeparator();
  14408. }
  14409. else
  14410. {
  14411. context->throwError("Incorrect number of arguments passed to "
  14412. "QMenu::addSeparator(). This method takes no "
  14413. "arguments.");
  14414. }
  14415. return QScriptValue();
  14416. }
  14417. /*:40*//*43:*/
  14418. #line 1365 "./typica.w"
  14419. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  14420. {
  14421. QScriptValue object= engine->newQObject(new QFrame);
  14422. setQFrameProperties(object,engine);
  14423. return object;
  14424. }
  14425. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  14426. {
  14427. setQWidgetProperties(value,engine);
  14428. }
  14429. /*:43*//*46:*/
  14430. #line 1399 "./typica.w"
  14431. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  14432. {
  14433. QString text;
  14434. if(context->argumentCount()==1)
  14435. {
  14436. text= argument<QString> (0,context);
  14437. }
  14438. QScriptValue object= engine->newQObject(new QLabel(text));
  14439. setQLabelProperties(object,engine);
  14440. return object;
  14441. }
  14442. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  14443. {
  14444. setQFrameProperties(value,engine);
  14445. }
  14446. /*:46*//*49:*/
  14447. #line 1441 "./typica.w"
  14448. QScriptValue constructQSvgWidget(QScriptContext*,
  14449. QScriptEngine*engine)
  14450. {
  14451. QScriptValue object= engine->newQObject(new QSvgWidget);
  14452. setQSvgWidgetProperties(object,engine);
  14453. return object;
  14454. }
  14455. /*:49*//*50:*/
  14456. #line 1452 "./typica.w"
  14457. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  14458. {
  14459. setQWidgetProperties(value,engine);
  14460. value.setProperty("loadDevice",
  14461. engine->newFunction(QSvgWidget_loadDevice));
  14462. }
  14463. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  14464. {
  14465. if(context->argumentCount()==1)
  14466. {
  14467. QSvgWidget*self= getself<QSvgWidget*> (context);
  14468. QIODevice*device= argument<QIODevice*> (0,context);
  14469. device->reset();
  14470. QByteArray data= device->readAll();
  14471. self->load(data);
  14472. }
  14473. else
  14474. {
  14475. context->throwError("Incorrect number of arguments passed to "
  14476. "QSvgWidget::loadData(). This method takes one "
  14477. "QIODevice as an argument.");
  14478. }
  14479. return QScriptValue();
  14480. }
  14481. /*:50*//*52:*/
  14482. #line 1490 "./typica.w"
  14483. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  14484. QStack<QLayout*> *layoutStack)
  14485. {
  14486. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  14487. QSvgWidget*widget= new QSvgWidget;
  14488. layout->addWidget(widget);
  14489. QString id= element.attribute("id");
  14490. if(!id.isEmpty())
  14491. {
  14492. widget->setObjectName(id);
  14493. }
  14494. }
  14495. /*:52*//*55:*/
  14496. #line 1523 "./typica.w"
  14497. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  14498. {
  14499. QScriptValue object= engine->newQObject(new QLineEdit());
  14500. setQLineEditProperties(object,engine);
  14501. return object;
  14502. }
  14503. /*:55*//*56:*/
  14504. #line 1534 "./typica.w"
  14505. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  14506. {
  14507. setQWidgetProperties(value,engine);
  14508. }
  14509. /*:56*//*59:*/
  14510. #line 1570 "./typica.w"
  14511. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  14512. {
  14513. QScriptValue object= engine->newQObject(new QSplitter);
  14514. setQSplitterProperties(object,engine);
  14515. return object;
  14516. }
  14517. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  14518. {
  14519. setQFrameProperties(value,engine);
  14520. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  14521. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  14522. value.setProperty("restoreState",
  14523. engine->newFunction(QSplitter_restoreState));
  14524. value.setProperty("count",engine->newFunction(QSplitter_count));
  14525. }
  14526. /*:59*//*60:*/
  14527. #line 1591 "./typica.w"
  14528. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  14529. {
  14530. if(context->argumentCount()==1)
  14531. {
  14532. QSplitter*self= getself<QSplitter*> (context);
  14533. QWidget*widget= argument<QWidget*> (0,context);
  14534. if(widget)
  14535. {
  14536. self->addWidget(widget);
  14537. }
  14538. else
  14539. {
  14540. context->throwError("Incorrect argument type passed to "
  14541. "QSplitter::addWidget(). This method "
  14542. "requires a QWidget.");
  14543. }
  14544. }
  14545. else
  14546. {
  14547. context->throwError("Incorrect number of arguments passed to "
  14548. "QSplitter::addWidget(). This method takes one "
  14549. "QWidget as an argument.");
  14550. }
  14551. return QScriptValue();
  14552. }
  14553. /*:60*//*61:*/
  14554. #line 1628 "./typica.w"
  14555. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  14556. {
  14557. QSplitter*self= getself<QSplitter*> (context);
  14558. return QScriptValue(self->count());
  14559. }
  14560. /*:61*//*62:*/
  14561. #line 1641 "./typica.w"
  14562. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  14563. {
  14564. if(context->argumentCount()==1)
  14565. {
  14566. QSplitter*self= getself<QSplitter*> (context);
  14567. QString key= argument<QString> (0,context);
  14568. QSettings settings;
  14569. settings.setValue(key,self->saveState());
  14570. }
  14571. else
  14572. {
  14573. context->throwError("Incorrect number of arguments passed to "
  14574. "QSplitter::saveState(). This method takes one "
  14575. "string as an argument.");
  14576. }
  14577. return QScriptValue();
  14578. }
  14579. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  14580. {
  14581. if(context->argumentCount()==1)
  14582. {
  14583. QSplitter*self= getself<QSplitter*> (context);
  14584. QString key= argument<QString> (0,context);
  14585. QSettings settings;
  14586. self->restoreState(settings.value(key).toByteArray());
  14587. }
  14588. else
  14589. {
  14590. context->throwError("Incorrect number of arguments passed to "
  14591. "QSplitter::restoreState(). This method takes "
  14592. "one string as an argument.");
  14593. }
  14594. return QScriptValue();
  14595. }
  14596. /*:62*//*64:*/
  14597. #line 1694 "./typica.w"
  14598. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14599. {
  14600. setQLayoutItemProperties(value,engine);
  14601. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  14602. }
  14603. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14604. {
  14605. if(context->argumentCount()==1)
  14606. {
  14607. QLayout*self= getself<QLayout*> (context);
  14608. QWidget*widget= argument<QWidget*> (0,context);
  14609. if(widget)
  14610. {
  14611. self->addWidget(widget);
  14612. }
  14613. else
  14614. {
  14615. context->throwError("Incorrect argument type passed to "
  14616. "QLayout::addWidget(). This method requires "
  14617. "a QWidget.");
  14618. }
  14619. }
  14620. else
  14621. {
  14622. context->throwError("Incorrect number of arguments passed to "
  14623. "QLayout::addWidget(). This method takes one "
  14624. "QWidget as an argument.");
  14625. }
  14626. return QScriptValue();
  14627. }
  14628. /*:64*//*67:*/
  14629. #line 1761 "./typica.w"
  14630. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  14631. {
  14632. QScriptValue object=
  14633. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  14634. setQBoxLayoutProperties(object,engine);
  14635. return object;
  14636. }
  14637. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  14638. {
  14639. setQLayoutProperties(value,engine);
  14640. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  14641. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  14642. }
  14643. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  14644. {
  14645. if(context->argumentCount()> 0&&context->argumentCount()<3)
  14646. {
  14647. QBoxLayout*self= getself<QBoxLayout*> (context);
  14648. QLayout*layout= argument<QLayout*> (0,context);
  14649. int stretch= 0;
  14650. if(context->argumentCount()==2)
  14651. {
  14652. stretch= argument<int> (1,context);
  14653. }
  14654. if(layout)
  14655. {
  14656. self->addLayout(layout,stretch);
  14657. }
  14658. else
  14659. {
  14660. context->throwError("Incorrect argument type passed to "
  14661. "QLayout::addLayout(). This method requires "
  14662. "a QLayout.");
  14663. }
  14664. }
  14665. else
  14666. {
  14667. context->throwError("Incorrect number of arguments passed to "
  14668. "QLayout::addLayout(). This method takes one "
  14669. "QLayout as an argument and optionally one integer.");
  14670. }
  14671. return QScriptValue();
  14672. }
  14673. /*:67*//*68:*/
  14674. #line 1812 "./typica.w"
  14675. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  14676. {
  14677. if(context->argumentCount()> 0&&context->argumentCount()<4)
  14678. {
  14679. QBoxLayout*self= getself<QBoxLayout*> (context);
  14680. QWidget*widget= argument<QWidget*> (0,context);
  14681. int stretch= 0;
  14682. Qt::Alignment alignment= 0;
  14683. if(context->argumentCount()> 1)
  14684. {
  14685. stretch= argument<int> (1,context);
  14686. }
  14687. if(context->argumentCount()> 2)
  14688. {
  14689. alignment= (Qt::Alignment)(argument<int> (2,context));
  14690. }
  14691. if(widget)
  14692. {
  14693. self->addWidget(widget,stretch,alignment);
  14694. }
  14695. else
  14696. {
  14697. context->throwError("Incorrect argument type passed to "
  14698. "QBoxLayout::addWidget(). This method requires "
  14699. "a QWidget.");
  14700. }
  14701. }
  14702. else
  14703. {
  14704. context->throwError("Incorrect number of arguments passed to "
  14705. "QBoxLayout::addWidget(). This method takes one "
  14706. "QWidget and optionally up to two integers as "
  14707. "arguments.");
  14708. }
  14709. return QScriptValue();
  14710. }
  14711. /*:68*//*71:*/
  14712. #line 1876 "./typica.w"
  14713. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  14714. {
  14715. QScriptValue object= engine->newQObject(new QAction(NULL));
  14716. setQActionProperties(object,engine);
  14717. return object;
  14718. }
  14719. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  14720. {
  14721. setQObjectProperties(value,engine);
  14722. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  14723. }
  14724. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  14725. {
  14726. if(context->argumentCount()==1)
  14727. {
  14728. QAction*self= getself<QAction*> (context);
  14729. self->setShortcut(argument<QString> (0,context));
  14730. }
  14731. else
  14732. {
  14733. context->throwError("Incorrect number of arguments passed to "
  14734. "QAction::setShortcut(). This method takes one "
  14735. "string as an argument.");
  14736. }
  14737. return QScriptValue();
  14738. }
  14739. /*:71*//*74:*/
  14740. #line 1934 "./typica.w"
  14741. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  14742. QScriptEngine*engine)
  14743. {
  14744. QScriptValue retval;
  14745. if(context->argumentCount()==3)
  14746. {
  14747. QWidget*widget= argument<QWidget*> (0,context);
  14748. if(widget)
  14749. {
  14750. QString caption= argument<QString> (1,context);
  14751. QString dir= argument<QString> (2,context);
  14752. retval= QScriptValue(engine,
  14753. QFileDialog::getOpenFileName(widget,caption,
  14754. dir,"",0,0));
  14755. setQFileDialogProperties(retval,engine);
  14756. }
  14757. else
  14758. {
  14759. context->throwError("Incorrect argument type passed to "
  14760. "QFileDialog::getOpenFileName(). The first "
  14761. "argument to this method must be a QWidget.");
  14762. }
  14763. }
  14764. else
  14765. {
  14766. context->throwError("Incorrect number of arguments passed to "
  14767. "QFileDialog::getOpenFileName(). This method "
  14768. "takes one QWidget followed by two strings for a "
  14769. "total of three arguments.");
  14770. }
  14771. return retval;
  14772. }
  14773. /*:74*//*75:*/
  14774. #line 1970 "./typica.w"
  14775. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  14776. QScriptEngine*engine)
  14777. {
  14778. QScriptValue retval;
  14779. if(context->argumentCount()==3)
  14780. {
  14781. QWidget*widget= argument<QWidget*> (0,context);
  14782. if(widget)
  14783. {
  14784. QString caption= argument<QString> (1,context);
  14785. QString dir= argument<QString> (2,context);
  14786. retval= QScriptValue(engine,
  14787. QFileDialog::getSaveFileName(widget,caption,
  14788. dir,"",0,0));
  14789. setQFileDialogProperties(retval,engine);
  14790. }
  14791. else
  14792. {
  14793. context->throwError("Incorrect argument type passed to "
  14794. "QFileDialog::getSaveFileName(). The first "
  14795. "argument to this method must be a QWidget.");
  14796. }
  14797. }
  14798. else
  14799. {
  14800. context->throwError("Incorrect number of arguments passed to "
  14801. "QFileDialog::getSaveFileName(). This method "
  14802. "takes one QWidget followed by two strings for a "
  14803. "total of three arguments.");
  14804. }
  14805. return retval;
  14806. }
  14807. /*:75*//*76:*/
  14808. #line 2007 "./typica.w"
  14809. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  14810. {
  14811. setQDialogProperties(value,engine);
  14812. }
  14813. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  14814. {
  14815. setQWidgetProperties(value,engine);
  14816. }
  14817. /*:76*//*79:*/
  14818. #line 2048 "./typica.w"
  14819. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  14820. {
  14821. QScriptValue object=
  14822. engine->newQObject(new QFile(argument<QString> (0,context)));
  14823. setQFileProperties(object,engine);
  14824. return object;
  14825. }
  14826. /*:79*//*80:*/
  14827. #line 2059 "./typica.w"
  14828. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  14829. {
  14830. setQIODeviceProperties(value,engine);
  14831. value.setProperty("remove",engine->newFunction(QFile_remove));
  14832. }
  14833. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  14834. {
  14835. QFile*self= getself<QFile*> (context);
  14836. bool retval= self->remove();
  14837. return QScriptValue(engine,retval);
  14838. }
  14839. /*:80*//*81:*/
  14840. #line 2081 "./typica.w"
  14841. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  14842. {
  14843. setQObjectProperties(value,engine);
  14844. value.setProperty("open",engine->newFunction(QIODevice_open));
  14845. value.setProperty("close",engine->newFunction(QIODevice_close));
  14846. value.setProperty("readToString",
  14847. engine->newFunction(QIODevice_readToString));
  14848. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  14849. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  14850. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  14851. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  14852. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  14853. value.setProperty("read",engine->newFunction(QIODevice_read));
  14854. }
  14855. /*:81*//*82:*/
  14856. #line 2102 "./typica.w"
  14857. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  14858. {
  14859. QIODevice*self= getself<QIODevice*> (context);
  14860. bool retval= false;
  14861. if(context->argumentCount()==1)
  14862. {
  14863. switch(argument<int> (0,context))
  14864. {
  14865. case 1:
  14866. retval= self->open(QIODevice::ReadOnly);
  14867. break;
  14868. case 2:
  14869. retval= self->open(QIODevice::WriteOnly);
  14870. break;
  14871. case 3:
  14872. retval= self->open(QIODevice::ReadWrite);
  14873. break;
  14874. default:
  14875. break;
  14876. }
  14877. }
  14878. else
  14879. {
  14880. retval= self->open(QIODevice::ReadWrite);
  14881. }
  14882. return QScriptValue(retval);
  14883. }
  14884. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  14885. {
  14886. QIODevice*self= getself<QIODevice*> (context);
  14887. self->close();
  14888. return QScriptValue();
  14889. }
  14890. /*:82*//*83:*/
  14891. #line 2142 "./typica.w"
  14892. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  14893. {
  14894. QIODevice*self= getself<QIODevice*> (context);
  14895. self->reset();
  14896. return QScriptValue(QString(self->readAll()));
  14897. }
  14898. /*:83*//*84:*/
  14899. #line 2158 "./typica.w"
  14900. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  14901. {
  14902. QIODevice*self= getself<QIODevice*> (context);
  14903. if(context->argumentCount()==1)
  14904. {
  14905. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  14906. }
  14907. context->throwError("Incorrect number of arguments passed to "
  14908. "QIODevice::putChar()");
  14909. return QScriptValue();
  14910. }
  14911. /*:84*//*85:*/
  14912. #line 2176 "./typica.w"
  14913. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  14914. {
  14915. QIODevice*self= getself<QIODevice*> (context);
  14916. if(context->argumentCount()==1)
  14917. {
  14918. self->write(argument<QString> (0,context).toUtf8());
  14919. }
  14920. else
  14921. {
  14922. context->throwError("Incorrect number of arguments passed to "
  14923. "QIODevice::writeString()");
  14924. }
  14925. return QScriptValue();
  14926. }
  14927. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  14928. {
  14929. QIODevice*self= getself<QIODevice*> (context);
  14930. if(context->argumentCount()==1)
  14931. {
  14932. self->write(argument<QByteArray> (0,context));
  14933. }
  14934. else
  14935. {
  14936. context->throwError("Incorrect number of arguments passed to "
  14937. "QIODevice::writeBytes()");
  14938. }
  14939. return QScriptValue();
  14940. }
  14941. /*:85*//*86:*/
  14942. #line 2210 "./typica.w"
  14943. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  14944. {
  14945. QIODevice*self= getself<QIODevice*> (context);
  14946. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  14947. setQByteArrayProperties(value,engine);
  14948. return value;
  14949. }
  14950. /*:86*//*87:*/
  14951. #line 2221 "./typica.w"
  14952. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  14953. {
  14954. QIODevice*self= getself<QIODevice*> (context);
  14955. QScriptValue value= engine->toScriptValue<QByteArray> (
  14956. self->peek(argument<int> (0,context)));
  14957. setQByteArrayProperties(value,engine);
  14958. return value;
  14959. }
  14960. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  14961. {
  14962. QIODevice*self= getself<QIODevice*> (context);
  14963. QScriptValue value= engine->toScriptValue<QByteArray> (
  14964. self->read(argument<int> (0,context)));
  14965. setQByteArrayProperties(value,engine);
  14966. return value;
  14967. }
  14968. /*:87*//*90:*/
  14969. #line 2266 "./typica.w"
  14970. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  14971. {
  14972. QScriptValue object= engine->newQObject(new QProcess);
  14973. setQProcessProperties(object,engine);
  14974. return object;
  14975. }
  14976. /*:90*//*91:*/
  14977. #line 2277 "./typica.w"
  14978. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  14979. {
  14980. setQIODeviceProperties(value,engine);
  14981. value.setProperty("execute",engine->newFunction(QProcess_execute));
  14982. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  14983. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  14984. value.setProperty("start",engine->newFunction(QProcess_start));
  14985. }
  14986. /*:91*//*92:*/
  14987. #line 2291 "./typica.w"
  14988. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  14989. {
  14990. QProcess*self= getself<QProcess*> (context);
  14991. QString program= argument<QString> (0,context);
  14992. QStringList arguments= QStringList();
  14993. if(context->argumentCount()> 1){
  14994. arguments= argument<QVariant> (1,context).toStringList();
  14995. }
  14996. int retval= self->execute(program,arguments);
  14997. return QScriptValue(retval);
  14998. }
  14999. /*:92*//*93:*/
  15000. #line 2306 "./typica.w"
  15001. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  15002. {
  15003. QProcess*self= getself<QProcess*> (context);
  15004. QString program= argument<QString> (0,context);
  15005. QStringList arguments= QStringList();
  15006. if(context->argumentCount()> 1){
  15007. arguments= argument<QVariant> (1,context).toStringList();
  15008. }
  15009. QString workingDirectory= "";
  15010. if(context->argumentCount()> 2){
  15011. workingDirectory= argument<QString> (2,context);
  15012. }
  15013. bool retval;
  15014. switch(context->argumentCount())
  15015. {
  15016. case 1:
  15017. retval= self->startDetached(program);
  15018. break;
  15019. case 2:
  15020. retval= self->startDetached(program,arguments);
  15021. break;
  15022. case 3:
  15023. retval= self->startDetached(program,arguments,workingDirectory);
  15024. break;
  15025. default:
  15026. retval= false;
  15027. }
  15028. return QScriptValue(retval);
  15029. }
  15030. /*:93*//*94:*/
  15031. #line 2339 "./typica.w"
  15032. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  15033. {
  15034. QProcess*self= getself<QProcess*> (context);
  15035. QString directory= argument<QString> (0,context);
  15036. self->setWorkingDirectory(directory);
  15037. return QScriptValue();
  15038. }
  15039. /*:94*//*95:*/
  15040. #line 2351 "./typica.w"
  15041. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  15042. {
  15043. QProcess*self= getself<QProcess*> (context);
  15044. QString program= argument<QString> (0,context);
  15045. QStringList arguments= QStringList();
  15046. if(context->argumentCount()> 1){
  15047. arguments= argument<QVariant> (1,context).toStringList();
  15048. }
  15049. self->start(program,arguments);
  15050. return QScriptValue();
  15051. }
  15052. /*:95*//*97:*/
  15053. #line 2392 "./typica.w"
  15054. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  15055. {
  15056. QScriptValue object= engine->newVariant(QVariant(bytes));
  15057. setQByteArrayProperties(object,engine);
  15058. return object;
  15059. }
  15060. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  15061. {
  15062. bytes= value.toVariant().toByteArray();
  15063. }
  15064. /*:97*//*99:*/
  15065. #line 2415 "./typica.w"
  15066. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  15067. {
  15068. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  15069. setQByteArrayProperties(object,engine);
  15070. return object;
  15071. }
  15072. /*:99*//*100:*/
  15073. #line 2426 "./typica.w"
  15074. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  15075. {
  15076. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  15077. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  15078. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  15079. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  15080. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  15081. value.setProperty("size",engine->newFunction(QByteArray_size));
  15082. value.setProperty("left",engine->newFunction(QByteArray_left));
  15083. value.setProperty("right",engine->newFunction(QByteArray_right));
  15084. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  15085. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  15086. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  15087. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  15088. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  15089. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  15090. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  15091. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  15092. }
  15093. /*:100*//*101:*/
  15094. #line 2450 "./typica.w"
  15095. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  15096. {
  15097. QByteArray self= getself<QByteArray> (context);
  15098. QByteArray retval;
  15099. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  15100. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  15101. setQByteArrayProperties(value,engine);
  15102. return value;
  15103. }
  15104. /*:101*//*102:*/
  15105. #line 2464 "./typica.w"
  15106. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  15107. {
  15108. QByteArray self= getself<QByteArray> (context);
  15109. return QScriptValue((int)(self.at(argument<int> (0,context))));
  15110. }
  15111. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  15112. {
  15113. QByteArray self= getself<QByteArray> (context);
  15114. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  15115. return QScriptValue();
  15116. }
  15117. /*:102*//*103:*/
  15118. #line 2482 "./typica.w"
  15119. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  15120. {
  15121. QByteArray self= getself<QByteArray> (context);
  15122. QScriptValue value=
  15123. engine->toScriptValue<QByteArray> (
  15124. self.append(argument<QByteArray> (0,context)));
  15125. setQByteArrayProperties(value,engine);
  15126. return value;
  15127. }
  15128. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  15129. {
  15130. QByteArray self= getself<QByteArray> (context);
  15131. QScriptValue value= engine->toScriptValue<QByteArray> (
  15132. self.append(argument<QString> (0,context)));
  15133. setQByteArrayProperties(value,engine);
  15134. return value;
  15135. }
  15136. /*:103*//*104:*/
  15137. #line 2504 "./typica.w"
  15138. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  15139. {
  15140. QByteArray self= getself<QByteArray> (context);
  15141. return QScriptValue(self.size());
  15142. }
  15143. /*:104*//*105:*/
  15144. #line 2514 "./typica.w"
  15145. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  15146. {
  15147. QByteArray self= getself<QByteArray> (context);
  15148. QScriptValue value= engine->toScriptValue<QByteArray> (
  15149. self.left(argument<int> (0,context)));
  15150. setQByteArrayProperties(value,engine);
  15151. return value;
  15152. }
  15153. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  15154. {
  15155. QByteArray self= getself<QByteArray> (context);
  15156. QScriptValue value= engine->toScriptValue<QByteArray> (
  15157. self.right(argument<int> (0,context)));
  15158. setQByteArrayProperties(value,engine);
  15159. return value;
  15160. }
  15161. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  15162. {
  15163. QByteArray self= getself<QByteArray> (context);
  15164. int length= -1;
  15165. if(context->argumentCount()> 1)
  15166. {
  15167. length= argument<int> (1,context);
  15168. }
  15169. QScriptValue value= engine->toScriptValue<QByteArray> (
  15170. self.mid(argument<int> (0,context),length));
  15171. setQByteArrayProperties(value,engine);
  15172. return value;
  15173. }
  15174. /*:105*//*106:*/
  15175. #line 2549 "./typica.w"
  15176. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  15177. {
  15178. QByteArray self= getself<QByteArray> (context);
  15179. self.chop(argument<int> (0,context));
  15180. return QScriptValue();
  15181. }
  15182. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  15183. {
  15184. QByteArray self= getself<QByteArray> (context);
  15185. QScriptValue value= engine->toScriptValue<QByteArray> (
  15186. self.remove(argument<int> (0,context),argument<int> (1,context)));
  15187. setQByteArrayProperties(value,engine);
  15188. return value;
  15189. }
  15190. /*:106*//*107:*/
  15191. #line 2572 "./typica.w"
  15192. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  15193. {
  15194. QByteArray self= getself<QByteArray> (context);
  15195. int value= 0;
  15196. char*bytes= (char*)&value;
  15197. bytes[0]= self[0];
  15198. return QScriptValue(value);
  15199. }
  15200. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  15201. {
  15202. QByteArray self= getself<QByteArray> (context);
  15203. int value= 0;
  15204. char*bytes= (char*)&value;
  15205. bytes[0]= self[0];
  15206. bytes[1]= self[1];
  15207. return QScriptValue(value);
  15208. }
  15209. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  15210. {
  15211. QByteArray self= getself<QByteArray> (context);
  15212. int value= 0;
  15213. char*bytes= (char*)&value;
  15214. bytes[0]= self[0];
  15215. bytes[1]= self[1];
  15216. bytes[2]= self[2];
  15217. bytes[3]= self[3];
  15218. return QScriptValue(value);
  15219. }
  15220. /*:107*//*108:*/
  15221. #line 2608 "./typica.w"
  15222. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  15223. {
  15224. QByteArray self= getself<QByteArray> (context);
  15225. float value= 0.0;
  15226. char*bytes= (char*)&value;
  15227. bytes[0]= self[0];
  15228. bytes[1]= self[1];
  15229. bytes[2]= self[2];
  15230. bytes[3]= self[3];
  15231. return QScriptValue(value);
  15232. }
  15233. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  15234. {
  15235. QByteArray self= getself<QByteArray> (context);
  15236. double value= 0.0;
  15237. char*bytes= (char*)&value;
  15238. bytes[0]= self[0];
  15239. bytes[1]= self[1];
  15240. bytes[2]= self[2];
  15241. bytes[3]= self[3];
  15242. bytes[4]= self[4];
  15243. bytes[5]= self[5];
  15244. bytes[6]= self[6];
  15245. bytes[7]= self[7];
  15246. return QScriptValue(value);
  15247. }
  15248. /*:108*//*111:*/
  15249. #line 2663 "./typica.w"
  15250. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  15251. {
  15252. qint8 value= (qint8)(argument<int> (0,context));
  15253. char*bytes= (char*)&value;
  15254. QByteArray retval;
  15255. retval.resize(1);
  15256. retval[0]= bytes[0];
  15257. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15258. setQByteArrayProperties(v,engine);
  15259. return v;
  15260. }
  15261. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  15262. {
  15263. qint16 value= (qint16)(argument<int> (0,context));
  15264. char*bytes= (char*)&value;
  15265. QByteArray retval;
  15266. retval.resize(2);
  15267. retval[0]= bytes[0];
  15268. retval[1]= bytes[1];
  15269. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15270. setQByteArrayProperties(v,engine);
  15271. return v;
  15272. }
  15273. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  15274. {
  15275. qint32 value= (qint32)(argument<int> (0,context));
  15276. char*bytes= (char*)&value;
  15277. QByteArray retval;
  15278. retval.resize(4);
  15279. retval[0]= bytes[0];
  15280. retval[1]= bytes[1];
  15281. retval[2]= bytes[2];
  15282. retval[3]= bytes[3];
  15283. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15284. setQByteArrayProperties(v,engine);
  15285. return v;
  15286. }
  15287. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  15288. {
  15289. float value= (float)(argument<double> (0,context));
  15290. char*bytes= (char*)&value;
  15291. QByteArray retval;
  15292. retval.resize(4);
  15293. retval[0]= bytes[0];
  15294. retval[1]= bytes[1];
  15295. retval[2]= bytes[2];
  15296. retval[3]= bytes[3];
  15297. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15298. setQByteArrayProperties(v,engine);
  15299. return v;
  15300. }
  15301. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  15302. {
  15303. double value= (double)(argument<double> (0,context));
  15304. char*bytes= (char*)&value;
  15305. QByteArray retval;
  15306. retval.resize(8);
  15307. retval[0]= bytes[0];
  15308. retval[1]= bytes[1];
  15309. retval[2]= bytes[2];
  15310. retval[3]= bytes[3];
  15311. retval[4]= bytes[4];
  15312. retval[5]= bytes[5];
  15313. retval[6]= bytes[6];
  15314. retval[7]= bytes[7];
  15315. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  15316. setQByteArrayProperties(v,engine);
  15317. return v;
  15318. }
  15319. /*:111*//*114:*/
  15320. #line 2760 "./typica.w"
  15321. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  15322. {
  15323. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  15324. QScriptValue object= engine->newQObject(new QBuffer(array));
  15325. setQBufferProperties(object,engine);
  15326. return object;
  15327. }
  15328. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  15329. {
  15330. setQIODeviceProperties(value,engine);
  15331. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  15332. }
  15333. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  15334. {
  15335. QBuffer*self= getself<QBuffer*> (context);
  15336. self->setData(argument<QString> (0,context).toAscii());
  15337. return QScriptValue();
  15338. }
  15339. /*:114*//*117:*/
  15340. #line 2809 "./typica.w"
  15341. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  15342. {
  15343. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  15344. setXQueryProperties(object,engine);
  15345. return object;
  15346. }
  15347. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  15348. {
  15349. QXmlQuery*self= getself<QXmlQuery*> (context);
  15350. delete self;
  15351. return QScriptValue();
  15352. }
  15353. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  15354. {
  15355. value.setProperty("bind",engine->newFunction(XQuery_bind));
  15356. value.setProperty("exec",engine->newFunction(XQuery_exec));
  15357. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  15358. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  15359. }
  15360. /*:117*//*118:*/
  15361. #line 2835 "./typica.w"
  15362. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  15363. {
  15364. QXmlQuery*self= getself<QXmlQuery*> (context);
  15365. QIODevice*buffer= argument<QIODevice*> (1,context);
  15366. self->bindVariable(argument<QString> (0,context),buffer);
  15367. return QScriptValue();
  15368. }
  15369. /*:118*//*119:*/
  15370. #line 2846 "./typica.w"
  15371. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  15372. {
  15373. QXmlQuery*self= getself<QXmlQuery*> (context);
  15374. self->setQuery(argument<QString> (0,context));
  15375. return QScriptValue();
  15376. }
  15377. /*:119*//*120:*/
  15378. #line 2856 "./typica.w"
  15379. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  15380. {
  15381. QXmlQuery*self= getself<QXmlQuery*> (context);
  15382. QString result;
  15383. self->evaluateTo(&result);
  15384. return QScriptValue(result);
  15385. }
  15386. /*:120*//*123:*/
  15387. #line 2911 "./typica.w"
  15388. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  15389. {
  15390. QXmlStreamWriter*retval;
  15391. if(context->argumentCount()==1)
  15392. {
  15393. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  15394. }
  15395. else
  15396. {
  15397. retval= new QXmlStreamWriter;
  15398. }
  15399. QScriptValue object= engine->toScriptValue<void*> (retval);
  15400. setXmlWriterProperties(object,engine);
  15401. return object;
  15402. }
  15403. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  15404. {
  15405. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  15406. value.setProperty("writeAttribute",
  15407. engine->newFunction(XmlWriter_writeAttribute));
  15408. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  15409. value.setProperty("writeCharacters",
  15410. engine->newFunction(XmlWriter_writeCharacters));
  15411. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  15412. value.setProperty("writeEmptyElement",
  15413. engine->newFunction(XmlWriter_writeEmptyElement));
  15414. value.setProperty("writeEndDocument",
  15415. engine->newFunction(XmlWriter_writeEndDocument));
  15416. value.setProperty("writeEndElement",
  15417. engine->newFunction(XmlWriter_writeEndElement));
  15418. value.setProperty("writeEntityReference",
  15419. engine->newFunction(XmlWriter_writeEntityReference));
  15420. value.setProperty("writeProcessingInstruction",
  15421. engine->newFunction(XmlWriter_writeProcessingInstruction));
  15422. value.setProperty("writeStartDocument",
  15423. engine->newFunction(XmlWriter_writeStartDocument));
  15424. value.setProperty("writeStartElement",
  15425. engine->newFunction(XmlWriter_writeStartElement));
  15426. value.setProperty("writeTextElement",
  15427. engine->newFunction(XmlWriter_writeTextElement));
  15428. }
  15429. /*:123*//*124:*/
  15430. #line 2958 "./typica.w"
  15431. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  15432. {
  15433. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15434. QIODevice*device= argument<QIODevice*> (0,context);
  15435. self->setDevice(device);
  15436. return QScriptValue();
  15437. }
  15438. /*:124*//*125:*/
  15439. #line 2972 "./typica.w"
  15440. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  15441. QScriptEngine*)
  15442. {
  15443. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15444. self->writeStartDocument(argument<QString> (0,context));
  15445. return QScriptValue();
  15446. }
  15447. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  15448. QScriptEngine*)
  15449. {
  15450. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15451. self->writeEndDocument();
  15452. return QScriptValue();
  15453. }
  15454. /*:125*//*126:*/
  15455. #line 2991 "./typica.w"
  15456. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  15457. {
  15458. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15459. self->writeDTD(argument<QString> (0,context));
  15460. return QScriptValue();
  15461. }
  15462. /*:126*//*127:*/
  15463. #line 3002 "./typica.w"
  15464. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  15465. QScriptEngine*)
  15466. {
  15467. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15468. self->writeStartElement(argument<QString> (0,context));
  15469. return QScriptValue();
  15470. }
  15471. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  15472. {
  15473. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15474. self->writeAttribute(argument<QString> (0,context),
  15475. argument<QString> (1,context));
  15476. return QScriptValue();
  15477. }
  15478. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  15479. {
  15480. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15481. self->writeCharacters(argument<QString> (0,context));
  15482. return QScriptValue();
  15483. }
  15484. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  15485. {
  15486. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15487. self->writeEndElement();
  15488. return QScriptValue();
  15489. }
  15490. /*:127*//*128:*/
  15491. #line 3038 "./typica.w"
  15492. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  15493. QScriptEngine*)
  15494. {
  15495. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15496. self->writeEmptyElement(argument<QString> (0,context));
  15497. return QScriptValue();
  15498. }
  15499. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  15500. QScriptEngine*)
  15501. {
  15502. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15503. self->writeTextElement(argument<QString> (0,context),
  15504. argument<QString> (1,context));
  15505. return QScriptValue();
  15506. }
  15507. /*:128*//*129:*/
  15508. #line 3059 "./typica.w"
  15509. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  15510. {
  15511. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15512. self->writeCDATA(argument<QString> (0,context));
  15513. return QScriptValue();
  15514. }
  15515. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  15516. QScriptEngine*)
  15517. {
  15518. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15519. self->writeEntityReference(argument<QString> (0,context));
  15520. return QScriptValue();
  15521. }
  15522. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  15523. QScriptEngine*)
  15524. {
  15525. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  15526. self->writeProcessingInstruction(argument<QString> (0,context),
  15527. argument<QString> (1,context));
  15528. return QScriptValue();
  15529. }
  15530. /*:129*//*132:*/
  15531. #line 3118 "./typica.w"
  15532. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  15533. {
  15534. QXmlStreamReader*retval=
  15535. new QXmlStreamReader(argument<QIODevice*> (0,context));
  15536. QScriptValue object= engine->toScriptValue<void*> (retval);
  15537. setXmlReaderProperties(object,engine);
  15538. return object;
  15539. }
  15540. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  15541. {
  15542. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  15543. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  15544. value.setProperty("hasAttribute",
  15545. engine->newFunction(XmlReader_hasAttribute));
  15546. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  15547. value.setProperty("isStartElement",
  15548. engine->newFunction(XmlReader_isStartElement));
  15549. value.setProperty("name",engine->newFunction(XmlReader_name));
  15550. value.setProperty("readElementText",
  15551. engine->newFunction(XmlReader_readElementText));
  15552. value.setProperty("readNext",
  15553. engine->newFunction(XmlReader_readNext));
  15554. value.setProperty("text",engine->newFunction(XmlReader_text));
  15555. }
  15556. /*:132*//*133:*/
  15557. #line 3148 "./typica.w"
  15558. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  15559. {
  15560. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15561. QString retval=
  15562. self->attributes().value(argument<QString> (0,context)).toString();
  15563. return QScriptValue(retval);
  15564. }
  15565. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  15566. {
  15567. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15568. bool retval=
  15569. self->attributes().hasAttribute(argument<QString> (0,context));
  15570. return QScriptValue(retval);
  15571. }
  15572. /*:133*//*134:*/
  15573. #line 3168 "./typica.w"
  15574. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  15575. {
  15576. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15577. return QScriptValue(self->atEnd());
  15578. }
  15579. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  15580. {
  15581. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15582. return QScriptValue(self->isDTD());
  15583. }
  15584. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  15585. {
  15586. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15587. return QScriptValue(self->isStartElement());
  15588. }
  15589. /*:134*//*135:*/
  15590. #line 3189 "./typica.w"
  15591. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  15592. {
  15593. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15594. self->readNext();
  15595. return QScriptValue();
  15596. }
  15597. /*:135*//*136:*/
  15598. #line 3199 "./typica.w"
  15599. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  15600. {
  15601. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15602. return QScriptValue(self->name().toString());
  15603. }
  15604. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  15605. {
  15606. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15607. return QScriptValue(self->readElementText());
  15608. }
  15609. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  15610. {
  15611. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  15612. return QScriptValue(self->text().toString());
  15613. }
  15614. /*:136*//*139:*/
  15615. #line 3241 "./typica.w"
  15616. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  15617. {
  15618. setQObjectProperties(value,engine);
  15619. value.setProperty("value",engine->newFunction(QSettings_value));
  15620. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  15621. }
  15622. /*:139*//*140:*/
  15623. #line 3253 "./typica.w"
  15624. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  15625. {
  15626. QScriptValue object;
  15627. if(context->argumentCount()==1||context->argumentCount()==2)
  15628. {
  15629. QSettings settings;
  15630. QString key= argument<QString> (0,context);
  15631. QVariant value;
  15632. QVariant retval;
  15633. if(context->argumentCount()> 1)
  15634. {
  15635. value= argument<QVariant> (1,context);
  15636. retval= settings.value(key,value);
  15637. }
  15638. else
  15639. {
  15640. retval= settings.value(key);
  15641. }
  15642. object= engine->newVariant(retval);
  15643. }
  15644. else
  15645. {
  15646. context->throwError("Incorrect number of arguments passed to "
  15647. "QSettings::value(). This method takes one "
  15648. "string and one optional variant type.");
  15649. }
  15650. return object;
  15651. }
  15652. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  15653. {
  15654. if(context->argumentCount()==2)
  15655. {
  15656. QSettings settings;
  15657. QString key= argument<QString> (0,context);
  15658. QVariant value= argument<QVariant> (1,context);
  15659. settings.setValue(key,value);
  15660. }
  15661. else
  15662. {
  15663. context->throwError("Incorrect number of arguments passed to "
  15664. "QSettings::setValue(). This method takes one "
  15665. "string and one variant type for a total of two "
  15666. "arguments.");
  15667. }
  15668. return QScriptValue();
  15669. }
  15670. /*:140*//*143:*/
  15671. #line 3322 "./typica.w"
  15672. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  15673. {
  15674. QScriptValue object= engine->newQObject(new QLCDNumber());
  15675. setQLCDNumberProperties(object,engine);
  15676. return object;
  15677. }
  15678. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  15679. {
  15680. setQFrameProperties(value,engine);
  15681. }
  15682. /*:143*//*146:*/
  15683. #line 3380 "./typica.w"
  15684. QScriptValue constructQTime(QScriptContext*context,
  15685. QScriptEngine*engine)
  15686. {
  15687. QScriptValue object;
  15688. if(context->argumentCount()==0||
  15689. (context->argumentCount()>=2&&context->argumentCount()<=4))
  15690. {
  15691. int arg1= 0;
  15692. int arg2= 0;
  15693. int arg3= 0;
  15694. int arg4= 0;
  15695. switch(context->argumentCount())
  15696. {
  15697. case 4:
  15698. arg4= argument<int> (3,context);
  15699. case 3:
  15700. arg3= argument<int> (2,context);
  15701. case 2:
  15702. arg2= argument<int> (1,context);
  15703. arg1= argument<int> (0,context);
  15704. default:
  15705. break;
  15706. }
  15707. if(context->argumentCount())
  15708. {
  15709. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  15710. arg4));
  15711. }
  15712. else
  15713. {
  15714. object= engine->toScriptValue<QTime> (QTime());
  15715. }
  15716. setQTimeProperties(object,engine);
  15717. }
  15718. else
  15719. {
  15720. context->throwError("Incorrect number of arguments passed to "
  15721. "QTime::QTime(). This method takes zero, two, "
  15722. "three, or four integer arguments.");
  15723. }
  15724. return object;
  15725. }
  15726. /*:146*//*147:*/
  15727. #line 3428 "./typica.w"
  15728. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  15729. {
  15730. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  15731. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  15732. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  15733. value.setProperty("hour",engine->newFunction(QTime_hour));
  15734. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  15735. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  15736. value.setProperty("minute",engine->newFunction(QTime_minute));
  15737. value.setProperty("msec",engine->newFunction(QTime_msec));
  15738. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  15739. value.setProperty("restart",engine->newFunction(QTime_restart));
  15740. value.setProperty("second",engine->newFunction(QTime_second));
  15741. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  15742. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  15743. value.setProperty("start",engine->newFunction(QTime_start));
  15744. value.setProperty("toString",engine->newFunction(QTime_toString));
  15745. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  15746. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  15747. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  15748. }
  15749. /*:147*//*148:*/
  15750. #line 3457 "./typica.w"
  15751. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  15752. {
  15753. QTime self= getself<QTime> (context);
  15754. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  15755. (self.second()*1000)+self.msec();
  15756. return QScriptValue(retval);
  15757. }
  15758. /*:148*//*149:*/
  15759. #line 3471 "./typica.w"
  15760. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  15761. {
  15762. QTime time;
  15763. QScriptValue retval;
  15764. if(context->argumentCount()==1)
  15765. {
  15766. QTime self= getself<QTime> (context);
  15767. time= self.addMSecs(argument<int> (0,context));
  15768. retval= engine->toScriptValue<QTime> (time);
  15769. setQTimeProperties(retval,engine);
  15770. }
  15771. else
  15772. {
  15773. context->throwError("Incorrect number of arguments passed to "
  15774. "QTime::addMSecs(). This method takes one "
  15775. "integer as an argument.");
  15776. }
  15777. return retval;
  15778. }
  15779. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  15780. {
  15781. QTime time;
  15782. QScriptValue retval;
  15783. if(context->argumentCount()==1)
  15784. {
  15785. QTime self= getself<QTime> (context);
  15786. time= self.addSecs(argument<int> (0,context));
  15787. retval= engine->toScriptValue<QTime> (time);
  15788. setQTimeProperties(retval,engine);
  15789. }
  15790. else
  15791. {
  15792. context->throwError("Incorrect number of arguments passed to "
  15793. "QTime::addSecs(). This method takes one "
  15794. "integer as an argument.");
  15795. }
  15796. return retval;
  15797. }
  15798. /*:149*//*150:*/
  15799. #line 3514 "./typica.w"
  15800. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  15801. {
  15802. QScriptValue retval;
  15803. if(context->argumentCount()==0)
  15804. {
  15805. QTime self= getself<QTime> (context);
  15806. retval= QScriptValue(engine,self.elapsed());
  15807. }
  15808. else
  15809. {
  15810. context->throwError("Incorrect number of arguments passed to "
  15811. "QTime::elapsed(). This method takes no "
  15812. "arguments.");
  15813. }
  15814. return retval;
  15815. }
  15816. /*:150*//*151:*/
  15817. #line 3535 "./typica.w"
  15818. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  15819. {
  15820. QScriptValue retval;
  15821. if(context->argumentCount()==0)
  15822. {
  15823. QTime self= getself<QTime> (context);
  15824. retval= QScriptValue(engine,self.hour());
  15825. }
  15826. else
  15827. {
  15828. context->throwError("Incorrect number of arguments passed to "
  15829. "QTime::hour(). This method takes no "
  15830. "arguments.");
  15831. }
  15832. return retval;
  15833. }
  15834. /*:151*//*152:*/
  15835. #line 3555 "./typica.w"
  15836. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  15837. {
  15838. QScriptValue retval;
  15839. if(context->argumentCount()==0)
  15840. {
  15841. QTime self= getself<QTime> (context);
  15842. retval= QScriptValue(engine,self.minute());
  15843. }
  15844. else
  15845. {
  15846. context->throwError("Incorrect number of arguments passed to "
  15847. "QTime::minute(). This method takes no "
  15848. "arguments.");
  15849. }
  15850. return retval;
  15851. }
  15852. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  15853. {
  15854. QScriptValue retval;
  15855. if(context->argumentCount()==0)
  15856. {
  15857. QTime self= getself<QTime> (context);
  15858. retval= QScriptValue(engine,self.second());
  15859. }
  15860. else
  15861. {
  15862. context->throwError("Incorrect number of arguments passed to "
  15863. "QTime::second(). This method takes no "
  15864. "arguments.");
  15865. }
  15866. return retval;
  15867. }
  15868. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  15869. {
  15870. QScriptValue retval;
  15871. if(context->argumentCount()==0)
  15872. {
  15873. QTime self= getself<QTime> (context);
  15874. retval= QScriptValue(engine,self.msec());
  15875. }
  15876. else
  15877. {
  15878. context->throwError("Incorrect number of arguments passed to "
  15879. "QTime::msec(). This method takes no "
  15880. "arguments.");
  15881. }
  15882. return retval;
  15883. }
  15884. /*:152*//*153:*/
  15885. #line 3611 "./typica.w"
  15886. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  15887. {
  15888. QScriptValue retval;
  15889. if(context->argumentCount()==0)
  15890. {
  15891. QTime self= getself<QTime> (context);
  15892. retval= QScriptValue(engine,self.isNull());
  15893. }
  15894. else
  15895. {
  15896. context->throwError("Incorrect number of arguments passed to "
  15897. "QTime::isNull(). This method takes no "
  15898. "arguments.");
  15899. }
  15900. return retval;
  15901. }
  15902. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  15903. {
  15904. QScriptValue retval;
  15905. if(context->argumentCount()==0)
  15906. {
  15907. QTime self= getself<QTime> (context);
  15908. retval= QScriptValue(engine,self.isValid());
  15909. }
  15910. else
  15911. {
  15912. context->throwError("Incorrect number of arguments passed to "
  15913. "QTime::isValid(). This method takes no "
  15914. "arguments.");
  15915. }
  15916. return retval;
  15917. }
  15918. /*:153*//*154:*/
  15919. #line 3649 "./typica.w"
  15920. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  15921. {
  15922. QScriptValue retval;
  15923. if(context->argumentCount()==1)
  15924. {
  15925. QTime self= getself<QTime> (context);
  15926. QTime arg= argument<QVariant> (0,context).toTime();
  15927. retval= QScriptValue(engine,self.msecsTo(arg));
  15928. }
  15929. else
  15930. {
  15931. context->throwError("Incorrect number of arguments passed to "
  15932. "QTime::msecsTo(). This method takes one QTime.");
  15933. }
  15934. return retval;
  15935. }
  15936. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  15937. {
  15938. QScriptValue retval;
  15939. if(context->argumentCount()==1)
  15940. {
  15941. QTime self= getself<QTime> (context);
  15942. QTime arg= argument<QVariant> (0,context).toTime();
  15943. retval= QScriptValue(engine,self.secsTo(arg));
  15944. }
  15945. else
  15946. {
  15947. context->throwError("Incorrect number of arguments passed to "
  15948. "QTime::secsTo(). This method takes one QTime.");
  15949. }
  15950. return retval;
  15951. }
  15952. /*:154*//*155:*/
  15953. #line 3688 "./typica.w"
  15954. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  15955. {
  15956. QScriptValue retval;
  15957. if(context->argumentCount()==0)
  15958. {
  15959. QTime self= getself<QTime> (context);
  15960. retval= QScriptValue(engine,self.restart());
  15961. }
  15962. else
  15963. {
  15964. context->throwError("Incorrect number of arguments passed to "
  15965. "QTime::restart(). This method takes no "
  15966. "arguments.");
  15967. }
  15968. return retval;
  15969. }
  15970. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  15971. {
  15972. if(context->argumentCount()==0)
  15973. {
  15974. QTime self= getself<QTime> (context);
  15975. self.start();
  15976. }
  15977. else
  15978. {
  15979. context->throwError("Incorrect number of arguments passed to "
  15980. "QTime::start(). This method takes no arguments.");
  15981. }
  15982. return QScriptValue();
  15983. }
  15984. /*:155*//*156:*/
  15985. #line 3724 "./typica.w"
  15986. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  15987. {
  15988. QScriptValue retval;
  15989. if(context->argumentCount()==3||context->argumentCount()==4)
  15990. {
  15991. QTime self= getself<QTime> (context);
  15992. int arg1= 0;
  15993. int arg2= 0;
  15994. int arg3= 0;
  15995. int arg4= 0;
  15996. switch(context->argumentCount())
  15997. {
  15998. case 4:
  15999. arg4= argument<int> (3,context);
  16000. case 3:
  16001. arg3= argument<int> (2,context);
  16002. arg2= argument<int> (1,context);
  16003. arg1= argument<int> (0,context);
  16004. default:
  16005. break;
  16006. }
  16007. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  16008. }
  16009. else
  16010. {
  16011. context->throwError("Incorrect number of arguments passed to "
  16012. "QTime::setHMS(). This method takes three or "
  16013. "four integer arguments.");
  16014. }
  16015. return retval;
  16016. }
  16017. /*:156*//*157:*/
  16018. #line 3760 "./typica.w"
  16019. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  16020. {
  16021. QScriptValue retval;
  16022. if(context->argumentCount()==1)
  16023. {
  16024. QTime self= getself<QTime> (context);
  16025. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  16026. }
  16027. else
  16028. {
  16029. context->throwError("Incorrect number of arguments passed to "
  16030. "QTime::toString(). This method takes one QString "
  16031. "as an argument.");
  16032. }
  16033. return retval;
  16034. }
  16035. /*:157*//*158:*/
  16036. #line 3781 "./typica.w"
  16037. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  16038. {
  16039. QScriptValue object;
  16040. object= engine->toScriptValue<QTime> (QTime::currentTime());
  16041. setQTimeProperties(object,engine);
  16042. return object;
  16043. }
  16044. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  16045. {
  16046. QScriptValue object;
  16047. if(context->argumentCount()==2)
  16048. {
  16049. QString time= argument<QString> (0,context);
  16050. QString format= argument<QString> (1,context);
  16051. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  16052. setQTimeProperties(object,engine);
  16053. }
  16054. else
  16055. {
  16056. context->throwError("Incorrect number of arguments passed to "
  16057. "QTime::fromString(). This method takes two "
  16058. "string arguments.");
  16059. }
  16060. return object;
  16061. }
  16062. /*:158*//*159:*/
  16063. #line 3812 "./typica.w"
  16064. template<> QTime argument(int arg,QScriptContext*context)
  16065. {
  16066. return qscriptvalue_cast<QTime> (context->argument(arg));
  16067. }
  16068. /*:159*//*161:*/
  16069. #line 3830 "./typica.w"
  16070. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  16071. {
  16072. setQFrameProperties(value,engine);
  16073. }
  16074. /*:161*//*163:*/
  16075. #line 3844 "./typica.w"
  16076. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  16077. {
  16078. setQAbstractScrollAreaProperties(value,engine);
  16079. }
  16080. /*:163*//*165:*/
  16081. #line 3858 "./typica.w"
  16082. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  16083. {
  16084. setQAbstractScrollAreaProperties(value,engine);
  16085. }
  16086. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  16087. {
  16088. setQAbstractItemViewProperties(value,engine);
  16089. }
  16090. /*:165*//*168:*/
  16091. #line 3891 "./typica.w"
  16092. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  16093. {
  16094. QScriptValue object= engine->newQObject(new QPushButton());
  16095. setQPushButtonProperties(object,engine);
  16096. return object;
  16097. }
  16098. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  16099. {
  16100. setQAbstractButtonProperties(value,engine);
  16101. }
  16102. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  16103. {
  16104. setQWidgetProperties(value,engine);
  16105. }
  16106. /*:168*//*175:*/
  16107. #line 4003 "./typica.w"
  16108. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  16109. {
  16110. SqlQueryConnection*obj= new SqlQueryConnection();
  16111. QScriptValue object=
  16112. engine->toScriptValue<void*> (obj);
  16113. setQSqlQueryProperties(object,engine);
  16114. return object;
  16115. }
  16116. /*:175*//*176:*/
  16117. #line 4016 "./typica.w"
  16118. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  16119. {
  16120. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  16121. value.setProperty("bindFileData",
  16122. engine->newFunction(QSqlQuery_bindFileData));
  16123. value.setProperty("bindDeviceData",
  16124. engine->newFunction(QSqlQuery_bindDeviceData));
  16125. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  16126. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  16127. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  16128. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  16129. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  16130. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  16131. }
  16132. /*:176*//*177:*/
  16133. #line 4034 "./typica.w"
  16134. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  16135. {
  16136. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  16137. QScriptValue retval;
  16138. if(context->argumentCount()==1)
  16139. {
  16140. retval= QScriptValue(engine,
  16141. q->exec(argument<QString> (0,context)));
  16142. }
  16143. else
  16144. {
  16145. retval= QScriptValue(engine,q->exec());
  16146. }
  16147. if(q->lastError().isValid())
  16148. {
  16149. qDebug()<<q->lastQuery();
  16150. qDebug()<<q->lastError().text();
  16151. }
  16152. return retval;
  16153. }
  16154. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  16155. {
  16156. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16157. return QScriptValue(query->lastQuery());
  16158. }
  16159. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  16160. {
  16161. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16162. return QScriptValue(engine,query->next());
  16163. }
  16164. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  16165. {
  16166. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16167. return QScriptValue(engine,
  16168. query->value(argument<int> (0,context)).toString());
  16169. }
  16170. /*:177*//*178:*/
  16171. #line 4078 "./typica.w"
  16172. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  16173. {
  16174. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16175. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  16176. }
  16177. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  16178. {
  16179. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16180. query->bindValue(argument<QString> (0,context),
  16181. argument<QVariant> (1,context));
  16182. return QScriptValue();
  16183. }
  16184. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  16185. QScriptEngine*)
  16186. {
  16187. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16188. QString placeholder= argument<QString> (0,context);
  16189. QString filename= argument<QString> (1,context);
  16190. QFile file(filename);
  16191. QByteArray data;
  16192. if(file.open(QIODevice::ReadOnly))
  16193. {
  16194. data= file.readAll();
  16195. file.close();
  16196. }
  16197. query->bindValue(placeholder,data);
  16198. return QScriptValue();
  16199. }
  16200. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  16201. QScriptEngine*)
  16202. {
  16203. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  16204. QString placeholder= argument<QString> (0,context);
  16205. QIODevice*device= argument<QIODevice*> (1,context);
  16206. device->reset();
  16207. QByteArray data;
  16208. data= device->readAll();
  16209. query->bindValue(placeholder,data);
  16210. return QScriptValue();
  16211. }
  16212. /*:178*//*179:*/
  16213. #line 4130 "./typica.w"
  16214. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16215. {
  16216. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  16217. delete query;
  16218. return QScriptValue::UndefinedValue;
  16219. }
  16220. /*:179*//*182:*/
  16221. #line 4177 "./typica.w"
  16222. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  16223. {
  16224. QFileInfo info(argument<QString> (0,context));
  16225. QScriptValue retval(engine,info.baseName());
  16226. return retval;
  16227. }
  16228. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  16229. {
  16230. QFileInfo info(argument<QString> (0,context));
  16231. QDir dir= info.dir();
  16232. QScriptValue retval(engine,dir.path());
  16233. return retval;
  16234. }
  16235. /*:182*//*183:*/
  16236. #line 4196 "./typica.w"
  16237. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  16238. {
  16239. SqlQueryConnection h;
  16240. QSqlQuery*query= h.operator->();
  16241. QString q= "SELECT file FROM files WHERE id = :file";
  16242. query->prepare(q);
  16243. query->bindValue(":file",argument<int> (0,context));
  16244. query->exec();
  16245. query->next();
  16246. QByteArray array= query->value(0).toByteArray();
  16247. QFile file(argument<QString> (1,context));
  16248. file.open(QIODevice::WriteOnly);
  16249. file.write(array);
  16250. file.close();
  16251. return QScriptValue();
  16252. }
  16253. /*:183*//*184:*/
  16254. #line 4217 "./typica.w"
  16255. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  16256. {
  16257. QString source= argument<QString> (0,context);
  16258. source.remove(0,1);
  16259. source.chop(1);
  16260. QStringList elements= source.split(",");
  16261. QString element;
  16262. QScriptValue dest= engine->newArray(elements.size());
  16263. int i= 0;
  16264. foreach(element,elements)
  16265. {
  16266. if(element.startsWith("\"")&&element.endsWith("\""))
  16267. {
  16268. element.chop(1);
  16269. element= element.remove(0,1);
  16270. }
  16271. dest.setProperty(i,QScriptValue(engine,element));
  16272. i++;
  16273. }
  16274. return dest;
  16275. }
  16276. /*:184*//*185:*/
  16277. #line 4243 "./typica.w"
  16278. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  16279. {
  16280. QString font= argument<QString> (0,context);
  16281. QString classname;
  16282. if(context->argumentCount()> 1)
  16283. {
  16284. classname= argument<QString> (1,context);
  16285. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  16286. }
  16287. else
  16288. {
  16289. QApplication::setFont(QFont(font));
  16290. }
  16291. return QScriptValue();
  16292. }
  16293. /*:185*//*186:*/
  16294. #line 4263 "./typica.w"
  16295. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  16296. {
  16297. SqlQueryConnection h;
  16298. QSqlQuery*query= h.operator->();
  16299. QString q= "SELECT file FROM files WHERE id = :file";
  16300. query->prepare(q);
  16301. query->bindValue(":file",argument<int> (0,context));
  16302. query->exec();
  16303. query->next();
  16304. QByteArray array= query->value(0).toByteArray();
  16305. QBuffer buffer(&array);
  16306. buffer.open(QIODevice::ReadOnly);
  16307. QXmlQuery xquery;
  16308. xquery.bindVariable("profile",&buffer);
  16309. QString xq;
  16310. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  16311. xquery.setQuery(xq);
  16312. QString result;
  16313. xquery.evaluateTo(&result);
  16314. return QScriptValue(result);
  16315. }
  16316. /*:186*//*187:*/
  16317. #line 4290 "./typica.w"
  16318. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  16319. {
  16320. QWidget::setTabOrder(argument<QWidget*> (0,context),
  16321. argument<QWidget*> (1,context));
  16322. return QScriptValue();
  16323. }
  16324. /*:187*//*188:*/
  16325. #line 4301 "./typica.w"
  16326. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  16327. {
  16328. return QScriptValue(QCoreApplication::translate(
  16329. "configuration",
  16330. argument<QString> (1,context).toUtf8().data()));
  16331. }
  16332. /*:188*//*195:*/
  16333. #line 4553 "./typica.w"
  16334. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  16335. {
  16336. QString targetID= argument<QString> (0,context);
  16337. QDomNode element;
  16338. QScriptValue object;
  16339. /*197:*/
  16340. #line 4600 "./typica.w"
  16341. QDomNodeList windows=
  16342. AppInstance->configuration()->documentElement().elementsByTagName("window");
  16343. QDomNode nullNode;
  16344. int i= 0;
  16345. element= nullNode;
  16346. while(i<windows.count())
  16347. {
  16348. element= windows.at(i);
  16349. QDomNamedNodeMap attributes= element.attributes();
  16350. if(attributes.contains("id"))
  16351. {
  16352. if(attributes.namedItem("id").toAttr().value()==targetID)
  16353. {
  16354. break;
  16355. }
  16356. }
  16357. element= nullNode;
  16358. i++;
  16359. }
  16360. /*:197*/
  16361. #line 4559 "./typica.w"
  16362. if(!element.isNull())
  16363. {
  16364. /*198:*/
  16365. #line 4632 "./typica.w"
  16366. ScriptQMainWindow*window= new ScriptQMainWindow;
  16367. window->setObjectName(targetID);
  16368. object= engine->newQObject(window);
  16369. setQMainWindowProperties(object,engine);
  16370. QWidget*central= new(QWidget);
  16371. central->setParent(window);
  16372. central->setObjectName("centralWidget");
  16373. window->setCentralWidget(central);
  16374. if(element.hasChildNodes())
  16375. {
  16376. /*199:*/
  16377. #line 4667 "./typica.w"
  16378. QStack<QWidget*> widgetStack;
  16379. QStack<QLayout*> layoutStack;
  16380. QString windowScript;
  16381. widgetStack.push(central);
  16382. QDomNodeList windowChildren= element.childNodes();
  16383. int i= 0;
  16384. while(i<windowChildren.count())
  16385. {
  16386. QDomNode current;
  16387. QDomElement element;
  16388. current= windowChildren.at(i);
  16389. if(current.isElement())
  16390. {
  16391. element= current.toElement();
  16392. if(element.tagName()=="program")
  16393. {
  16394. windowScript.append(element.text());
  16395. }
  16396. else if(element.tagName()=="layout")
  16397. {
  16398. element.setAttribute("trcontext","configuration");
  16399. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16400. }
  16401. else if(element.tagName()=="menu")
  16402. {
  16403. /*200:*/
  16404. #line 4715 "./typica.w"
  16405. QMenuBar*bar= window->menuBar();
  16406. bar->setParent(window);
  16407. bar->setObjectName("menuBar");
  16408. if(element.hasAttribute("name"))
  16409. {
  16410. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16411. element.attribute("name").toUtf8().data()));
  16412. menu->setParent(bar);
  16413. if(element.hasAttribute("type"))
  16414. {
  16415. if(element.attribute("type")=="reports")
  16416. {
  16417. if(element.hasAttribute("src"))
  16418. {
  16419. /*640:*/
  16420. #line 13842 "./typica.w"
  16421. QSettings settings;
  16422. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16423. toString()).
  16424. arg(element.attribute("src"));
  16425. QDir::addSearchPath("reports",reportDirectory);
  16426. QDir directory(reportDirectory);
  16427. directory.setFilter(QDir::Files);
  16428. directory.setSorting(QDir::Name);
  16429. QStringList nameFilter;
  16430. nameFilter<<"*.xml";
  16431. directory.setNameFilters(nameFilter);
  16432. QFileInfoList reportFiles= directory.entryInfoList();
  16433. for(int i= 0;i<reportFiles.size();i++)
  16434. {
  16435. QFileInfo reportFile= reportFiles.at(i);
  16436. /*644:*/
  16437. #line 13922 "./typica.w"
  16438. QString path= reportFile.absoluteFilePath();
  16439. QFile file(path);
  16440. if(file.open(QIODevice::ReadOnly))
  16441. {
  16442. QDomDocument document;
  16443. document.setContent(&file,true);
  16444. QDomElement root= document.documentElement();
  16445. QString translationContext= root.attribute("id");
  16446. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16447. if(!titleNode.isNull())
  16448. {
  16449. QDomElement titleElement= titleNode.toElement();
  16450. QString title= QCoreApplication::translate("configuration",
  16451. titleElement.text().toUtf8().data());
  16452. if(!title.isEmpty())
  16453. {
  16454. QStringList hierarchy= title.split(":->");
  16455. QMenu*insertionPoint= menu;
  16456. /*645:*/
  16457. #line 13951 "./typica.w"
  16458. for(int j= 0;j<hierarchy.size()-1;j++)
  16459. {
  16460. QObjectList menuList= insertionPoint->children();
  16461. bool menuFound= false;
  16462. for(int k= 0;k<menuList.size();k++)
  16463. {
  16464. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16465. if(currentItem)
  16466. {
  16467. if(currentItem->title()==hierarchy.at(j))
  16468. {
  16469. menuFound= true;
  16470. insertionPoint= currentItem;
  16471. break;
  16472. }
  16473. }
  16474. }
  16475. if(!menuFound)
  16476. {
  16477. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16478. }
  16479. }
  16480. /*:645*/
  16481. #line 13941 "./typica.w"
  16482. ReportAction*action= new ReportAction(path,hierarchy.last());
  16483. insertionPoint->addAction(action);
  16484. }
  16485. }
  16486. }
  16487. /*:644*/
  16488. #line 13858 "./typica.w"
  16489. }
  16490. /*:640*/
  16491. #line 4730 "./typica.w"
  16492. }
  16493. }
  16494. }
  16495. if(element.hasChildNodes())
  16496. {
  16497. /*201:*/
  16498. #line 4743 "./typica.w"
  16499. QDomNodeList menuItems= element.childNodes();
  16500. int j= 0;
  16501. while(j<menuItems.count())
  16502. {
  16503. QDomNode item= menuItems.at(j);
  16504. if(item.isElement())
  16505. {
  16506. QDomElement itemElement= item.toElement();
  16507. if(itemElement.tagName()=="item")
  16508. {
  16509. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16510. itemElement.text().toUtf8().data()),menu);
  16511. if(itemElement.hasAttribute("id"))
  16512. {
  16513. itemAction->setObjectName(itemElement.attribute("id"));
  16514. }
  16515. if(itemElement.hasAttribute("shortcut"))
  16516. {
  16517. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16518. }
  16519. menu->addAction(itemAction);
  16520. }
  16521. else if(itemElement.tagName()=="separator")
  16522. {
  16523. menu->addSeparator();
  16524. }
  16525. }
  16526. j++;
  16527. }
  16528. #line 1 "./helpmenu.w"
  16529. /*:201*/
  16530. #line 4736 "./typica.w"
  16531. }
  16532. }
  16533. /*:200*/
  16534. #line 4693 "./typica.w"
  16535. }
  16536. }
  16537. i++;
  16538. }
  16539. QScriptValue oldThis= context->thisObject();
  16540. context->setThisObject(object);
  16541. QScriptValue result= engine->evaluate(windowScript);
  16542. /*192:*/
  16543. #line 4449 "./typica.w"
  16544. if(engine->hasUncaughtException())
  16545. {
  16546. int line= engine->uncaughtExceptionLineNumber();
  16547. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16548. result.toString();
  16549. QString trace;
  16550. foreach(trace,engine->uncaughtExceptionBacktrace())
  16551. {
  16552. qDebug()<<trace;
  16553. }
  16554. }
  16555. /*:192*/
  16556. #line 4701 "./typica.w"
  16557. context->setThisObject(oldThis);
  16558. /*:199*/
  16559. #line 4643 "./typica.w"
  16560. }
  16561. /*202:*/
  16562. #line 9 "./helpmenu.w"
  16563. HelpMenu*helpMenu= new HelpMenu();
  16564. window->menuBar()->addMenu(helpMenu);
  16565. /*:202*/
  16566. #line 4645 "./typica.w"
  16567. window->show();
  16568. /*:198*/
  16569. #line 4562 "./typica.w"
  16570. }
  16571. return object;
  16572. }
  16573. /*:195*//*196:*/
  16574. #line 4573 "./typica.w"
  16575. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  16576. {
  16577. QString targetID= argument<QString> (0,context);
  16578. QFile file(QString("reports:%1").arg(targetID));
  16579. QScriptValue object;
  16580. if(file.open(QIODevice::ReadOnly))
  16581. {
  16582. QDomDocument document;
  16583. document.setContent(&file,true);
  16584. QDomElement element= document.documentElement();
  16585. if(!element.isNull())
  16586. {
  16587. /*198:*/
  16588. #line 4632 "./typica.w"
  16589. ScriptQMainWindow*window= new ScriptQMainWindow;
  16590. window->setObjectName(targetID);
  16591. object= engine->newQObject(window);
  16592. setQMainWindowProperties(object,engine);
  16593. QWidget*central= new(QWidget);
  16594. central->setParent(window);
  16595. central->setObjectName("centralWidget");
  16596. window->setCentralWidget(central);
  16597. if(element.hasChildNodes())
  16598. {
  16599. /*199:*/
  16600. #line 4667 "./typica.w"
  16601. QStack<QWidget*> widgetStack;
  16602. QStack<QLayout*> layoutStack;
  16603. QString windowScript;
  16604. widgetStack.push(central);
  16605. QDomNodeList windowChildren= element.childNodes();
  16606. int i= 0;
  16607. while(i<windowChildren.count())
  16608. {
  16609. QDomNode current;
  16610. QDomElement element;
  16611. current= windowChildren.at(i);
  16612. if(current.isElement())
  16613. {
  16614. element= current.toElement();
  16615. if(element.tagName()=="program")
  16616. {
  16617. windowScript.append(element.text());
  16618. }
  16619. else if(element.tagName()=="layout")
  16620. {
  16621. element.setAttribute("trcontext","configuration");
  16622. addLayoutToWidget(element,&widgetStack,&layoutStack);
  16623. }
  16624. else if(element.tagName()=="menu")
  16625. {
  16626. /*200:*/
  16627. #line 4715 "./typica.w"
  16628. QMenuBar*bar= window->menuBar();
  16629. bar->setParent(window);
  16630. bar->setObjectName("menuBar");
  16631. if(element.hasAttribute("name"))
  16632. {
  16633. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  16634. element.attribute("name").toUtf8().data()));
  16635. menu->setParent(bar);
  16636. if(element.hasAttribute("type"))
  16637. {
  16638. if(element.attribute("type")=="reports")
  16639. {
  16640. if(element.hasAttribute("src"))
  16641. {
  16642. /*640:*/
  16643. #line 13842 "./typica.w"
  16644. QSettings settings;
  16645. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  16646. toString()).
  16647. arg(element.attribute("src"));
  16648. QDir::addSearchPath("reports",reportDirectory);
  16649. QDir directory(reportDirectory);
  16650. directory.setFilter(QDir::Files);
  16651. directory.setSorting(QDir::Name);
  16652. QStringList nameFilter;
  16653. nameFilter<<"*.xml";
  16654. directory.setNameFilters(nameFilter);
  16655. QFileInfoList reportFiles= directory.entryInfoList();
  16656. for(int i= 0;i<reportFiles.size();i++)
  16657. {
  16658. QFileInfo reportFile= reportFiles.at(i);
  16659. /*644:*/
  16660. #line 13922 "./typica.w"
  16661. QString path= reportFile.absoluteFilePath();
  16662. QFile file(path);
  16663. if(file.open(QIODevice::ReadOnly))
  16664. {
  16665. QDomDocument document;
  16666. document.setContent(&file,true);
  16667. QDomElement root= document.documentElement();
  16668. QString translationContext= root.attribute("id");
  16669. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  16670. if(!titleNode.isNull())
  16671. {
  16672. QDomElement titleElement= titleNode.toElement();
  16673. QString title= QCoreApplication::translate("configuration",
  16674. titleElement.text().toUtf8().data());
  16675. if(!title.isEmpty())
  16676. {
  16677. QStringList hierarchy= title.split(":->");
  16678. QMenu*insertionPoint= menu;
  16679. /*645:*/
  16680. #line 13951 "./typica.w"
  16681. for(int j= 0;j<hierarchy.size()-1;j++)
  16682. {
  16683. QObjectList menuList= insertionPoint->children();
  16684. bool menuFound= false;
  16685. for(int k= 0;k<menuList.size();k++)
  16686. {
  16687. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  16688. if(currentItem)
  16689. {
  16690. if(currentItem->title()==hierarchy.at(j))
  16691. {
  16692. menuFound= true;
  16693. insertionPoint= currentItem;
  16694. break;
  16695. }
  16696. }
  16697. }
  16698. if(!menuFound)
  16699. {
  16700. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  16701. }
  16702. }
  16703. /*:645*/
  16704. #line 13941 "./typica.w"
  16705. ReportAction*action= new ReportAction(path,hierarchy.last());
  16706. insertionPoint->addAction(action);
  16707. }
  16708. }
  16709. }
  16710. /*:644*/
  16711. #line 13858 "./typica.w"
  16712. }
  16713. /*:640*/
  16714. #line 4730 "./typica.w"
  16715. }
  16716. }
  16717. }
  16718. if(element.hasChildNodes())
  16719. {
  16720. /*201:*/
  16721. #line 4743 "./typica.w"
  16722. QDomNodeList menuItems= element.childNodes();
  16723. int j= 0;
  16724. while(j<menuItems.count())
  16725. {
  16726. QDomNode item= menuItems.at(j);
  16727. if(item.isElement())
  16728. {
  16729. QDomElement itemElement= item.toElement();
  16730. if(itemElement.tagName()=="item")
  16731. {
  16732. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  16733. itemElement.text().toUtf8().data()),menu);
  16734. if(itemElement.hasAttribute("id"))
  16735. {
  16736. itemAction->setObjectName(itemElement.attribute("id"));
  16737. }
  16738. if(itemElement.hasAttribute("shortcut"))
  16739. {
  16740. itemAction->setShortcut(itemElement.attribute("shortcut"));
  16741. }
  16742. menu->addAction(itemAction);
  16743. }
  16744. else if(itemElement.tagName()=="separator")
  16745. {
  16746. menu->addSeparator();
  16747. }
  16748. }
  16749. j++;
  16750. }
  16751. #line 1 "./helpmenu.w"
  16752. /*:201*/
  16753. #line 4736 "./typica.w"
  16754. }
  16755. }
  16756. /*:200*/
  16757. #line 4693 "./typica.w"
  16758. }
  16759. }
  16760. i++;
  16761. }
  16762. QScriptValue oldThis= context->thisObject();
  16763. context->setThisObject(object);
  16764. QScriptValue result= engine->evaluate(windowScript);
  16765. /*192:*/
  16766. #line 4449 "./typica.w"
  16767. if(engine->hasUncaughtException())
  16768. {
  16769. int line= engine->uncaughtExceptionLineNumber();
  16770. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  16771. result.toString();
  16772. QString trace;
  16773. foreach(trace,engine->uncaughtExceptionBacktrace())
  16774. {
  16775. qDebug()<<trace;
  16776. }
  16777. }
  16778. /*:192*/
  16779. #line 4701 "./typica.w"
  16780. context->setThisObject(oldThis);
  16781. /*:199*/
  16782. #line 4643 "./typica.w"
  16783. }
  16784. /*202:*/
  16785. #line 9 "./helpmenu.w"
  16786. HelpMenu*helpMenu= new HelpMenu();
  16787. window->menuBar()->addMenu(helpMenu);
  16788. /*:202*/
  16789. #line 4645 "./typica.w"
  16790. window->show();
  16791. /*:198*/
  16792. #line 4586 "./typica.w"
  16793. }
  16794. file.close();
  16795. }
  16796. return object;
  16797. }
  16798. /*:196*//*214:*/
  16799. #line 4788 "./typica.w"
  16800. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  16801. QStack<QLayout*> *layoutStack)
  16802. {
  16803. if(element.hasAttribute("type"))
  16804. {
  16805. /*215:*/
  16806. #line 4809 "./typica.w"
  16807. QLayout*layout;
  16808. QString layoutType= element.attribute("type");
  16809. if(layoutType=="horizontal")
  16810. {
  16811. layout= new QHBoxLayout;
  16812. layoutStack->push(layout);
  16813. populateBoxLayout(element,widgetStack,layoutStack);
  16814. }
  16815. else if(layoutType=="vertical")
  16816. {
  16817. layout= new QVBoxLayout;
  16818. layoutStack->push(layout);
  16819. populateBoxLayout(element,widgetStack,layoutStack);
  16820. }
  16821. else if(layoutType=="grid")
  16822. {
  16823. layout= new QGridLayout;
  16824. layoutStack->push(layout);
  16825. populateGridLayout(element,widgetStack,layoutStack);
  16826. }
  16827. else if(layoutType=="stack")
  16828. {
  16829. layout= new QStackedLayout;
  16830. layoutStack->push(layout);
  16831. populateStackedLayout(element,widgetStack,layoutStack);
  16832. }
  16833. if(element.hasAttribute("id"))
  16834. {
  16835. layout->setObjectName(element.attribute("id"));
  16836. }
  16837. if(element.hasAttribute("spacing"))
  16838. {
  16839. layout->setSpacing(element.attribute("spacing").toInt());
  16840. }
  16841. if(element.hasAttribute("margin"))
  16842. {
  16843. int m= element.attribute("margin").toInt();
  16844. layout->setContentsMargins(m,m,m,m);
  16845. }
  16846. /*:215*/
  16847. #line 4794 "./typica.w"
  16848. QWidget*widget= widgetStack->top();
  16849. if(layout)
  16850. {
  16851. widget->setLayout(layout);
  16852. }
  16853. layoutStack->pop();
  16854. }
  16855. }
  16856. /*:214*//*216:*/
  16857. #line 4856 "./typica.w"
  16858. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16859. QStack<QLayout*> *layoutStack)
  16860. {
  16861. QDomNodeList children= element.childNodes();
  16862. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  16863. for(int i= 0;i<children.count();i++)
  16864. {
  16865. QDomNode current;
  16866. QDomElement currentElement;
  16867. current= children.at(i);
  16868. if(current.isElement())
  16869. {
  16870. currentElement= current.toElement();
  16871. if(currentElement.tagName()=="page")
  16872. {
  16873. QWidget*widget= new QWidget;
  16874. layout->addWidget(widget);
  16875. widgetStack->push(widget);
  16876. currentElement.setAttribute("trcontext","configuration");
  16877. populateWidget(currentElement,widgetStack,layoutStack);
  16878. widgetStack->pop();
  16879. }
  16880. }
  16881. }
  16882. }
  16883. /*:216*//*217:*/
  16884. #line 4889 "./typica.w"
  16885. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16886. QStack<QLayout*> *layoutStack)
  16887. {
  16888. QDomNodeList children= element.childNodes();
  16889. int row= -1;
  16890. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  16891. for(int i= 0;i<children.count();i++)
  16892. {
  16893. QDomNode current;
  16894. QDomElement currentElement;
  16895. current= children.at(i);
  16896. if(current.isElement())
  16897. {
  16898. currentElement= current.toElement();
  16899. if(currentElement.tagName()=="row")
  16900. {
  16901. row++;
  16902. if(currentElement.hasAttribute("height"))
  16903. {
  16904. layout->setRowMinimumHeight(row,
  16905. currentElement.attribute("height").toInt());
  16906. }
  16907. if(currentElement.hasAttribute("stretch"))
  16908. {
  16909. layout->setRowStretch(row,
  16910. currentElement.attribute("stretch").toInt());
  16911. }
  16912. /*218:*/
  16913. #line 4945 "./typica.w"
  16914. int column= -1;
  16915. QDomNodeList rowChildren= currentElement.childNodes();
  16916. for(int j= 0;j<rowChildren.count();j++)
  16917. {
  16918. QDomNode columnNode;
  16919. QDomElement columnElement;
  16920. columnNode= rowChildren.at(j);
  16921. if(columnNode.isElement())
  16922. {
  16923. columnElement= columnNode.toElement();
  16924. if(columnElement.tagName()=="column")
  16925. {
  16926. column++;
  16927. if(columnElement.hasAttribute("column"))
  16928. {
  16929. column= columnElement.attribute("column").toInt();
  16930. }
  16931. if(columnElement.hasAttribute("width"))
  16932. {
  16933. layout->setColumnMinimumWidth(column,
  16934. columnElement.attribute("width").toInt());
  16935. }
  16936. if(columnElement.hasAttribute("stretch"))
  16937. {
  16938. layout->setColumnStretch(column,
  16939. columnElement.attribute("stretch").toInt());
  16940. }
  16941. int hspan= 1;
  16942. int vspan= 1;
  16943. if(columnElement.hasAttribute("rowspan"))
  16944. {
  16945. vspan= columnElement.attribute("rowspan").toInt();
  16946. }
  16947. if(columnElement.hasAttribute("colspan"))
  16948. {
  16949. hspan= columnElement.attribute("colspan").toInt();
  16950. }
  16951. QHBoxLayout*cell= new QHBoxLayout;
  16952. layout->addLayout(cell,row,column,vspan,hspan);
  16953. layoutStack->push(cell);
  16954. columnElement.setAttribute("trcontext","configuration");
  16955. populateBoxLayout(columnElement,widgetStack,layoutStack);
  16956. layoutStack->pop();
  16957. }
  16958. }
  16959. }
  16960. /*:218*/
  16961. #line 4917 "./typica.w"
  16962. }
  16963. }
  16964. }
  16965. }
  16966. /*:217*//*219:*/
  16967. #line 4996 "./typica.w"
  16968. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  16969. QStack<QLayout*> *layoutStack)
  16970. {
  16971. QDomNodeList children= element.childNodes();
  16972. for(int i= 0;i<children.count();i++)
  16973. {
  16974. QDomNode current;
  16975. QDomElement currentElement;
  16976. current= children.at(i);
  16977. if(current.isElement())
  16978. {
  16979. currentElement= current.toElement();
  16980. currentElement.setAttribute("trcontext","configuration");
  16981. if(currentElement.tagName()=="button")
  16982. {
  16983. addButtonToLayout(currentElement,widgetStack,layoutStack);
  16984. }
  16985. else if(currentElement.tagName()=="calendar")
  16986. {
  16987. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  16988. }
  16989. else if(currentElement.tagName()=="decoration")
  16990. {
  16991. addDecorationToLayout(currentElement,widgetStack,
  16992. layoutStack);
  16993. }
  16994. else if(currentElement.tagName()=="layout")
  16995. {
  16996. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  16997. }
  16998. else if(currentElement.tagName()=="splitter")
  16999. {
  17000. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  17001. }
  17002. else if(currentElement.tagName()=="label")
  17003. {
  17004. QBoxLayout*layout=
  17005. qobject_cast<QBoxLayout*> (layoutStack->top());
  17006. QLabel*label= new QLabel(QCoreApplication::translate(
  17007. "configuration",
  17008. currentElement.text().toUtf8().data()));
  17009. layout->addWidget(label);
  17010. }
  17011. else if(currentElement.tagName()=="lcdtemperature")
  17012. {
  17013. addTemperatureDisplayToLayout(currentElement,widgetStack,
  17014. layoutStack);
  17015. }
  17016. else if(currentElement.tagName()=="lcdtimer")
  17017. {
  17018. addTimerDisplayToLayout(currentElement,widgetStack,
  17019. layoutStack);
  17020. }
  17021. else if(currentElement.tagName()=="line")
  17022. {
  17023. addLineToLayout(currentElement,widgetStack,layoutStack);
  17024. }
  17025. else if(currentElement.tagName()=="report")
  17026. {
  17027. addReportToLayout(currentElement,widgetStack,layoutStack);
  17028. }
  17029. else if(currentElement.tagName()=="sqldrop")
  17030. {
  17031. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  17032. }
  17033. else if(currentElement.tagName()=="sqltablearray")
  17034. {
  17035. addSaltToLayout(currentElement,widgetStack,layoutStack);
  17036. }
  17037. else if(currentElement.tagName()=="sqlview")
  17038. {
  17039. addSqlQueryViewToLayout(currentElement,widgetStack,
  17040. layoutStack);
  17041. }
  17042. else if(currentElement.tagName()=="textarea")
  17043. {
  17044. addTextToLayout(currentElement,widgetStack,layoutStack);
  17045. }
  17046. else if(currentElement.tagName()=="spinbox")
  17047. {
  17048. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  17049. }
  17050. else if(currentElement.tagName()=="formarray")
  17051. {
  17052. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  17053. }
  17054. else if(currentElement.tagName()=="hscale")
  17055. {
  17056. addScaleControlToLayout(currentElement,widgetStack,
  17057. layoutStack);
  17058. }
  17059. else if(currentElement.tagName()=="vscale")
  17060. {
  17061. addIntensityControlToLayout(currentElement,widgetStack,
  17062. layoutStack);
  17063. }
  17064. else if(currentElement.tagName()=="webview")
  17065. {
  17066. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  17067. }
  17068. else if(currentElement.tagName()=="stretch")
  17069. {
  17070. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17071. layout->addStretch();
  17072. }
  17073. /*51:*/
  17074. #line 1482 "./typica.w"
  17075. else if(currentElement.tagName()=="svgwidget")
  17076. {
  17077. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  17078. }
  17079. /*:51*//*682:*/
  17080. #line 453 "./daterangeselector.w"
  17081. else if(currentElement.tagName()=="daterange")
  17082. {
  17083. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  17084. }
  17085. /*:682*/
  17086. #line 5102 "./typica.w"
  17087. }
  17088. }
  17089. }
  17090. /*:219*//*220:*/
  17091. #line 5110 "./typica.w"
  17092. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17093. QStack<QLayout*> *layoutStack)
  17094. {
  17095. QLayout*targetLayout= layoutStack->pop();
  17096. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  17097. if(element.hasAttribute("type"))
  17098. {
  17099. /*215:*/
  17100. #line 4809 "./typica.w"
  17101. QLayout*layout;
  17102. QString layoutType= element.attribute("type");
  17103. if(layoutType=="horizontal")
  17104. {
  17105. layout= new QHBoxLayout;
  17106. layoutStack->push(layout);
  17107. populateBoxLayout(element,widgetStack,layoutStack);
  17108. }
  17109. else if(layoutType=="vertical")
  17110. {
  17111. layout= new QVBoxLayout;
  17112. layoutStack->push(layout);
  17113. populateBoxLayout(element,widgetStack,layoutStack);
  17114. }
  17115. else if(layoutType=="grid")
  17116. {
  17117. layout= new QGridLayout;
  17118. layoutStack->push(layout);
  17119. populateGridLayout(element,widgetStack,layoutStack);
  17120. }
  17121. else if(layoutType=="stack")
  17122. {
  17123. layout= new QStackedLayout;
  17124. layoutStack->push(layout);
  17125. populateStackedLayout(element,widgetStack,layoutStack);
  17126. }
  17127. if(element.hasAttribute("id"))
  17128. {
  17129. layout->setObjectName(element.attribute("id"));
  17130. }
  17131. if(element.hasAttribute("spacing"))
  17132. {
  17133. layout->setSpacing(element.attribute("spacing").toInt());
  17134. }
  17135. if(element.hasAttribute("margin"))
  17136. {
  17137. int m= element.attribute("margin").toInt();
  17138. layout->setContentsMargins(m,m,m,m);
  17139. }
  17140. /*:215*/
  17141. #line 5118 "./typica.w"
  17142. boxLayout->addLayout(layout);
  17143. layoutStack->pop();
  17144. }
  17145. layoutStack->push(targetLayout);
  17146. }
  17147. /*:220*//*221:*/
  17148. #line 5129 "./typica.w"
  17149. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  17150. QStack<QLayout*> *layoutStack)
  17151. {
  17152. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17153. QSplitter*splitter= new(QSplitter);
  17154. layout->addWidget(splitter);
  17155. /*222:*/
  17156. #line 5142 "./typica.w"
  17157. QString orientation= element.attribute("type");
  17158. if(orientation=="horizontal")
  17159. {
  17160. splitter->setOrientation(Qt::Horizontal);
  17161. }
  17162. else if(orientation=="vertical")
  17163. {
  17164. splitter->setOrientation(Qt::Vertical);
  17165. }
  17166. QString id= element.attribute("id");
  17167. if(!id.isEmpty())
  17168. {
  17169. splitter->setObjectName(id);
  17170. }
  17171. if(element.hasChildNodes())
  17172. {
  17173. widgetStack->push(splitter);
  17174. populateSplitter(element,widgetStack,layoutStack);
  17175. widgetStack->pop();
  17176. }
  17177. /*:222*/
  17178. #line 5136 "./typica.w"
  17179. }
  17180. /*:221*//*223:*/
  17181. #line 5168 "./typica.w"
  17182. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17183. QStack<QLayout*> *layoutStack)
  17184. {
  17185. QDomNodeList children= element.childNodes();
  17186. for(int i= 0;i<children.count();i++)
  17187. {
  17188. QDomNode current;
  17189. QDomElement currentElement;
  17190. current= children.at(i);
  17191. if(current.isElement())
  17192. {
  17193. currentElement= current.toElement();
  17194. currentElement.setAttribute("trcontext","configuration");
  17195. if(currentElement.tagName()=="decoration")
  17196. {
  17197. addDecorationToSplitter(currentElement,widgetStack,
  17198. layoutStack);
  17199. }
  17200. else if(currentElement.tagName()=="graph")
  17201. {
  17202. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  17203. }
  17204. else if(currentElement.tagName()=="splitter")
  17205. {
  17206. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  17207. }
  17208. else if(currentElement.tagName()=="lcdtemperature")
  17209. {
  17210. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  17211. layoutStack);
  17212. }
  17213. else if(currentElement.tagName()=="lcdtimer")
  17214. {
  17215. addTimerDisplayToSplitter(currentElement,widgetStack,
  17216. layoutStack);
  17217. }
  17218. else if(currentElement.tagName()=="measurementtable")
  17219. {
  17220. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  17221. }
  17222. else if(currentElement.tagName()=="widget")
  17223. {
  17224. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  17225. }
  17226. }
  17227. }
  17228. }
  17229. /*:223*//*224:*/
  17230. #line 5219 "./typica.w"
  17231. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17232. QStack<QLayout*> *layoutStack)
  17233. {
  17234. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  17235. QSplitter*splitter= new(QSplitter);
  17236. splitter->setParent(parent);
  17237. parent->addWidget(splitter);
  17238. /*222:*/
  17239. #line 5142 "./typica.w"
  17240. QString orientation= element.attribute("type");
  17241. if(orientation=="horizontal")
  17242. {
  17243. splitter->setOrientation(Qt::Horizontal);
  17244. }
  17245. else if(orientation=="vertical")
  17246. {
  17247. splitter->setOrientation(Qt::Vertical);
  17248. }
  17249. QString id= element.attribute("id");
  17250. if(!id.isEmpty())
  17251. {
  17252. splitter->setObjectName(id);
  17253. }
  17254. if(element.hasChildNodes())
  17255. {
  17256. widgetStack->push(splitter);
  17257. populateSplitter(element,widgetStack,layoutStack);
  17258. widgetStack->pop();
  17259. }
  17260. /*:222*/
  17261. #line 5227 "./typica.w"
  17262. }
  17263. /*:224*//*225:*/
  17264. #line 5236 "./typica.w"
  17265. void addTemperatureDisplayToSplitter(QDomElement element,
  17266. QStack<QWidget*> *widgetStack,
  17267. QStack<QLayout*> *)
  17268. {
  17269. TemperatureDisplay*display= new(TemperatureDisplay);
  17270. if(element.hasAttribute("id"))
  17271. {
  17272. display->setObjectName(element.attribute("id"));
  17273. }
  17274. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17275. splitter->addWidget(display);
  17276. }
  17277. void addTemperatureDisplayToLayout(QDomElement element,
  17278. QStack<QWidget*> *,
  17279. QStack<QLayout*> *layoutStack)
  17280. {
  17281. TemperatureDisplay*display= new(TemperatureDisplay);
  17282. if(element.hasAttribute("id"))
  17283. {
  17284. display->setObjectName(element.attribute("id"));
  17285. }
  17286. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17287. layout->addWidget(display);
  17288. }
  17289. /*:225*//*226:*/
  17290. #line 5267 "./typica.w"
  17291. void addTimerDisplayToSplitter(QDomElement element,
  17292. QStack<QWidget*> *widgetStack,
  17293. QStack<QLayout*> *)
  17294. {
  17295. TimerDisplay*display= new(TimerDisplay);
  17296. if(element.hasAttribute("id"))
  17297. {
  17298. display->setObjectName(element.attribute("id"));
  17299. }
  17300. if(element.hasAttribute("format"))
  17301. {
  17302. display->setDisplayFormat(element.attribute("format"));
  17303. }
  17304. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17305. splitter->addWidget(display);
  17306. }
  17307. void addTimerDisplayToLayout(QDomElement element,
  17308. QStack<QWidget*> *,
  17309. QStack<QLayout*> *layoutStack)
  17310. {
  17311. TimerDisplay*display= new(TimerDisplay);
  17312. if(element.hasAttribute("id"))
  17313. {
  17314. display->setObjectName(element.attribute("id"));
  17315. }
  17316. if(element.hasAttribute("format"))
  17317. {
  17318. display->setDisplayFormat(element.attribute("format"));
  17319. }
  17320. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17321. layout->addWidget(display);
  17322. }
  17323. /*:226*//*227:*/
  17324. #line 5305 "./typica.w"
  17325. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  17326. QStack<QLayout*> *layoutStack)
  17327. {
  17328. /*228:*/
  17329. #line 5326 "./typica.w"
  17330. QString labelText=
  17331. QCoreApplication::translate("configuration",
  17332. element.attribute("name").toUtf8().data());
  17333. Qt::Orientations orientation= Qt::Horizontal;
  17334. if(element.hasAttribute("type"))
  17335. {
  17336. if(element.attribute("type")=="horizontal")
  17337. {
  17338. orientation= Qt::Horizontal;
  17339. }
  17340. else if(element.attribute("type")=="vertical")
  17341. {
  17342. orientation= Qt::Vertical;
  17343. }
  17344. }
  17345. /*229:*/
  17346. #line 5353 "./typica.w"
  17347. QWidget*theWidget= NULL;
  17348. QDomNodeList children= element.childNodes();
  17349. for(int i= 0;i<children.count();i++)
  17350. {
  17351. QDomNode item= children.at(i);
  17352. if(item.isElement())
  17353. {
  17354. QDomElement itemElement= item.toElement();
  17355. if(itemElement.tagName()=="lcdtemperature")
  17356. {
  17357. TemperatureDisplay*display= new TemperatureDisplay;
  17358. if(itemElement.hasAttribute("id"))
  17359. {
  17360. display->setObjectName(itemElement.attribute("id"));
  17361. }
  17362. theWidget= display;
  17363. }
  17364. else if(itemElement.tagName()=="lcdtimer")
  17365. {
  17366. TimerDisplay*display= new TimerDisplay;
  17367. if(itemElement.hasAttribute("id"))
  17368. {
  17369. display->setObjectName(itemElement.attribute("id"));
  17370. }
  17371. if(itemElement.hasAttribute("format"))
  17372. {
  17373. display->setDisplayFormat(itemElement.attribute("format"));
  17374. }
  17375. theWidget= display;
  17376. }
  17377. }
  17378. }
  17379. /*:229*/
  17380. #line 5342 "./typica.w"
  17381. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17382. orientation);
  17383. if(element.hasAttribute("id"))
  17384. {
  17385. decoration->setObjectName(element.attribute("id"));
  17386. }
  17387. /*:228*/
  17388. #line 5309 "./typica.w"
  17389. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17390. layout->addWidget(decoration);
  17391. }
  17392. void addDecorationToSplitter(QDomElement element,
  17393. QStack<QWidget*> *widgetStack,
  17394. QStack<QLayout*> *)
  17395. {
  17396. /*228:*/
  17397. #line 5326 "./typica.w"
  17398. QString labelText=
  17399. QCoreApplication::translate("configuration",
  17400. element.attribute("name").toUtf8().data());
  17401. Qt::Orientations orientation= Qt::Horizontal;
  17402. if(element.hasAttribute("type"))
  17403. {
  17404. if(element.attribute("type")=="horizontal")
  17405. {
  17406. orientation= Qt::Horizontal;
  17407. }
  17408. else if(element.attribute("type")=="vertical")
  17409. {
  17410. orientation= Qt::Vertical;
  17411. }
  17412. }
  17413. /*229:*/
  17414. #line 5353 "./typica.w"
  17415. QWidget*theWidget= NULL;
  17416. QDomNodeList children= element.childNodes();
  17417. for(int i= 0;i<children.count();i++)
  17418. {
  17419. QDomNode item= children.at(i);
  17420. if(item.isElement())
  17421. {
  17422. QDomElement itemElement= item.toElement();
  17423. if(itemElement.tagName()=="lcdtemperature")
  17424. {
  17425. TemperatureDisplay*display= new TemperatureDisplay;
  17426. if(itemElement.hasAttribute("id"))
  17427. {
  17428. display->setObjectName(itemElement.attribute("id"));
  17429. }
  17430. theWidget= display;
  17431. }
  17432. else if(itemElement.tagName()=="lcdtimer")
  17433. {
  17434. TimerDisplay*display= new TimerDisplay;
  17435. if(itemElement.hasAttribute("id"))
  17436. {
  17437. display->setObjectName(itemElement.attribute("id"));
  17438. }
  17439. if(itemElement.hasAttribute("format"))
  17440. {
  17441. display->setDisplayFormat(itemElement.attribute("format"));
  17442. }
  17443. theWidget= display;
  17444. }
  17445. }
  17446. }
  17447. /*:229*/
  17448. #line 5342 "./typica.w"
  17449. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  17450. orientation);
  17451. if(element.hasAttribute("id"))
  17452. {
  17453. decoration->setObjectName(element.attribute("id"));
  17454. }
  17455. /*:228*/
  17456. #line 5318 "./typica.w"
  17457. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17458. splitter->addWidget(decoration);
  17459. }
  17460. /*:227*//*230:*/
  17461. #line 5392 "./typica.w"
  17462. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17463. QStack<QLayout*> *layoutStack)
  17464. {
  17465. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17466. QWidget*widget= new QWidget;
  17467. if(element.hasAttribute("id"))
  17468. {
  17469. widget->setObjectName(element.attribute("id"));
  17470. }
  17471. splitter->addWidget(widget);
  17472. if(element.hasChildNodes())
  17473. {
  17474. widgetStack->push(widget);
  17475. populateWidget(element,widgetStack,layoutStack);
  17476. widgetStack->pop();
  17477. }
  17478. }
  17479. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  17480. QStack<QLayout*> *layoutStack)
  17481. {
  17482. QDomNodeList children= element.childNodes();
  17483. for(int i= 0;i<children.count();i++)
  17484. {
  17485. QDomNode current;
  17486. QDomElement currentElement;
  17487. current= children.at(i);
  17488. if(current.isElement())
  17489. {
  17490. currentElement= current.toElement();
  17491. if(currentElement.tagName()=="layout")
  17492. {
  17493. currentElement.setAttribute("trcontext","configuration");
  17494. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  17495. }
  17496. }
  17497. }
  17498. }
  17499. /*:230*//*231:*/
  17500. #line 5436 "./typica.w"
  17501. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  17502. QStack<QLayout*> *layoutStack)
  17503. {
  17504. QAbstractButton*button= NULL;
  17505. QString text=
  17506. QCoreApplication::translate("configuration",
  17507. element.attribute("name").toUtf8().data());
  17508. if(element.hasAttribute("type"))
  17509. {
  17510. QString type= element.attribute("type");
  17511. if(type=="annotation")
  17512. {
  17513. AnnotationButton*abutton= new AnnotationButton(text);
  17514. if(element.hasAttribute("annotation"))
  17515. {
  17516. abutton->setAnnotation(element.attribute("annotation"));
  17517. }
  17518. if(element.hasAttribute("series"))
  17519. {
  17520. abutton->setTemperatureColumn(element.attribute("series").
  17521. toInt());
  17522. }
  17523. if(element.hasAttribute("column"))
  17524. {
  17525. abutton->setAnnotationColumn(element.attribute("column").
  17526. toInt());
  17527. }
  17528. button= abutton;
  17529. }
  17530. else if(type=="check")
  17531. {
  17532. button= new QCheckBox(text);
  17533. }
  17534. else if(type=="push")
  17535. {
  17536. button= new QPushButton(text);
  17537. }
  17538. }
  17539. if(element.hasAttribute("id"))
  17540. {
  17541. button->setObjectName(element.attribute("id"));
  17542. }
  17543. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17544. layout->addWidget(button);
  17545. }
  17546. /*:231*//*232:*/
  17547. #line 5490 "./typica.w"
  17548. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  17549. QStack<QLayout*> *layoutStack)
  17550. {
  17551. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  17552. if(element.hasAttribute("pretext"))
  17553. {
  17554. box->setPretext(QCoreApplication::translate(
  17555. "configuration",
  17556. element.attribute("pretext").toUtf8().data()));
  17557. }
  17558. if(element.hasAttribute("posttext"))
  17559. {
  17560. box->setPosttext(QCoreApplication::translate(
  17561. "configuration",
  17562. element.attribute("posttext").toUtf8().data()));
  17563. }
  17564. if(element.hasAttribute("series"))
  17565. {
  17566. box->setTemperatureColumn(element.attribute("series").toInt());
  17567. }
  17568. if(element.hasAttribute("column"))
  17569. {
  17570. box->setAnnotationColumn(element.attribute("column").toInt());
  17571. }
  17572. if(element.hasAttribute("min"))
  17573. {
  17574. box->setMinimum(element.attribute("min").toDouble());
  17575. }
  17576. if(element.hasAttribute("max"))
  17577. {
  17578. box->setMaximum(element.attribute("max").toDouble());
  17579. }
  17580. if(element.hasAttribute("decimals"))
  17581. {
  17582. box->setDecimals(element.attribute("decimals").toInt());
  17583. }
  17584. if(element.hasAttribute("step"))
  17585. {
  17586. box->setSingleStep(element.attribute("step").toDouble());
  17587. }
  17588. if(element.hasAttribute("id"))
  17589. {
  17590. box->setObjectName(element.attribute("id"));
  17591. }
  17592. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17593. layout->addWidget(box);
  17594. }
  17595. /*:232*//*233:*/
  17596. #line 5550 "./typica.w"
  17597. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17598. QStack<QLayout*> *)
  17599. {
  17600. ZoomLog*widget= new ZoomLog;
  17601. if(element.hasAttribute("id"))
  17602. {
  17603. widget->setObjectName(element.attribute("id"));
  17604. }
  17605. if(element.hasChildNodes())
  17606. {
  17607. QDomNodeList children= element.childNodes();
  17608. int column= 0;
  17609. for(int i= 0;i<children.count();i++)
  17610. {
  17611. QDomNode current;
  17612. QDomElement currentElement;
  17613. current= children.at(i);
  17614. if(current.isElement())
  17615. {
  17616. currentElement= current.toElement();
  17617. if(currentElement.tagName()=="column")
  17618. {
  17619. QString text=
  17620. QCoreApplication::translate(
  17621. "configuration",
  17622. currentElement.text().toUtf8().data());
  17623. widget->setHeaderData(column,text);
  17624. column++;
  17625. }
  17626. }
  17627. }
  17628. }
  17629. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17630. if(splitter)
  17631. {
  17632. splitter->addWidget(widget);
  17633. }
  17634. else
  17635. {
  17636. qDebug()<<"Splitter not found at top of widget stack!";
  17637. }
  17638. }
  17639. /*:233*//*234:*/
  17640. #line 5597 "./typica.w"
  17641. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  17642. QStack<QLayout*> *)
  17643. {
  17644. GraphView*view= new GraphView;
  17645. if(element.hasAttribute("id"))
  17646. {
  17647. view->setObjectName(element.attribute("id"));
  17648. }
  17649. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  17650. splitter->addWidget(view);
  17651. }
  17652. /*:234*//*235:*/
  17653. #line 5614 "./typica.w"
  17654. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  17655. QStack<QLayout*> *layoutStack)
  17656. {
  17657. SqlComboBox*box= new SqlComboBox();
  17658. if(element.hasAttribute("data"))
  17659. {
  17660. box->setDataColumn(element.attribute("data").toInt());
  17661. }
  17662. if(element.hasAttribute("display"))
  17663. {
  17664. box->setDisplayColumn(element.attribute("display").toInt());
  17665. }
  17666. if(element.hasAttribute("showdata"))
  17667. {
  17668. if(element.attribute("showdata")=="true")
  17669. {
  17670. box->showData(true);
  17671. }
  17672. }
  17673. if(element.hasAttribute("editable"))
  17674. {
  17675. if(element.attribute("editable")=="true")
  17676. {
  17677. box->setEditable(true);
  17678. }
  17679. }
  17680. if(element.hasChildNodes())
  17681. {
  17682. QDomNodeList children= element.childNodes();
  17683. for(int i= 0;i<children.count();i++)
  17684. {
  17685. QDomNode current;
  17686. QDomElement currentElement;
  17687. current= children.at(i);
  17688. if(current.isElement())
  17689. {
  17690. currentElement= current.toElement();
  17691. if(currentElement.tagName()=="null")
  17692. {
  17693. box->addNullOption();
  17694. }
  17695. else if(currentElement.tagName()=="query")
  17696. {
  17697. box->addSqlOptions(currentElement.text());
  17698. }
  17699. }
  17700. }
  17701. }
  17702. if(element.hasAttribute("id"))
  17703. {
  17704. box->setObjectName(element.attribute("id"));
  17705. }
  17706. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17707. layout->addWidget(box);
  17708. }
  17709. /*:235*//*236:*/
  17710. #line 5693 "./typica.w"
  17711. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  17712. QStack<QLayout*> *layoutStack)
  17713. {
  17714. QTableView*view= new QTableView;
  17715. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  17716. SaltModel*model= new SaltModel(element.childNodes().count());
  17717. if(element.hasAttribute("id"))
  17718. {
  17719. view->setObjectName(element.attribute("id"));
  17720. }
  17721. if(element.hasChildNodes())
  17722. {
  17723. QDomNodeList children= element.childNodes();
  17724. int currentColumn= 0;
  17725. for(int i= 0;i<children.count();i++)
  17726. {
  17727. QDomNode current;
  17728. QDomElement currentElement;
  17729. current= children.at(i);
  17730. if(current.isElement())
  17731. {
  17732. currentElement= current.toElement();
  17733. if(currentElement.tagName()=="column")
  17734. {
  17735. if(currentElement.hasAttribute("name"))
  17736. {
  17737. model->setHeaderData(currentColumn,
  17738. Qt::Horizontal,
  17739. QCoreApplication::translate(
  17740. "configuration",
  17741. currentElement.attribute("name").toUtf8().data()));
  17742. }
  17743. if(currentElement.hasAttribute("delegate"))
  17744. {
  17745. /*237:*/
  17746. #line 5744 "./typica.w"
  17747. if(currentElement.attribute("delegate")=="sql")
  17748. {
  17749. /*238:*/
  17750. #line 5760 "./typica.w"
  17751. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  17752. SqlComboBox*widget= new SqlComboBox();
  17753. if(currentElement.hasAttribute("nulltext"))
  17754. {
  17755. widget->setNullText(currentElement.attribute("nulltext"));
  17756. }
  17757. if(currentElement.hasAttribute("nulldata"))
  17758. {
  17759. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  17760. }
  17761. if(currentElement.hasAttribute("null"))
  17762. {
  17763. if(currentElement.attribute("null")=="true")
  17764. {
  17765. widget->addNullOption();
  17766. }
  17767. }
  17768. if(currentElement.hasAttribute("showdata"))
  17769. {
  17770. if(currentElement.attribute("showdata")=="true")
  17771. {
  17772. widget->showData(true);
  17773. }
  17774. }
  17775. if(currentElement.hasAttribute("data"))
  17776. {
  17777. widget->setDataColumn(currentElement.attribute("data").toInt());
  17778. }
  17779. if(currentElement.hasAttribute("display"))
  17780. {
  17781. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  17782. }
  17783. widget->addSqlOptions(currentElement.text());
  17784. delegate->setWidget(widget);
  17785. view->setItemDelegateForColumn(currentColumn,delegate);
  17786. /*:238*/
  17787. #line 5747 "./typica.w"
  17788. }
  17789. else if(currentElement.attribute("delegate")=="numeric")
  17790. {
  17791. /*239:*/
  17792. #line 5801 "./typica.w"
  17793. NumericDelegate*delegate= new NumericDelegate;
  17794. view->setItemDelegateForColumn(currentColumn,delegate);
  17795. /*:239*/
  17796. #line 5751 "./typica.w"
  17797. }
  17798. /*:237*/
  17799. #line 5728 "./typica.w"
  17800. }
  17801. currentColumn++;
  17802. }
  17803. }
  17804. }
  17805. }
  17806. view->setModel(model);
  17807. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17808. layout->addWidget(view);
  17809. }
  17810. /*:236*//*251:*/
  17811. #line 5974 "./typica.w"
  17812. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  17813. QStack<QLayout*> *layoutStack)
  17814. {
  17815. QLineEdit*widget= new QLineEdit(element.text());
  17816. if(element.hasAttribute("id"))
  17817. {
  17818. widget->setObjectName(element.attribute("id"));
  17819. }
  17820. if(element.hasAttribute("writable"))
  17821. {
  17822. if(element.attribute("writable")=="false")
  17823. {
  17824. widget->setReadOnly(true);
  17825. }
  17826. }
  17827. if(element.hasAttribute("validator"))
  17828. {
  17829. if(element.attribute("validator")=="numeric")
  17830. {
  17831. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  17832. }
  17833. else if(element.attribute("validator")=="integer")
  17834. {
  17835. widget->setValidator(new ScriptValidator(new QIntValidator));
  17836. }
  17837. else if(element.attribute("validator")=="expression"&&
  17838. element.hasAttribute("expression"))
  17839. {
  17840. widget->setValidator(new QRegExpValidator(
  17841. QRegExp(element.attribute("expression")),
  17842. NULL));
  17843. }
  17844. }
  17845. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17846. layout->addWidget(widget);
  17847. }
  17848. /*:251*//*252:*/
  17849. #line 6015 "./typica.w"
  17850. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  17851. QStack<QLayout*> *layoutStack)
  17852. {
  17853. QTextEdit*widget= new QTextEdit;
  17854. if(element.hasAttribute("id"))
  17855. {
  17856. widget->setObjectName(element.attribute("id"));
  17857. }
  17858. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17859. layout->addWidget(widget);
  17860. }
  17861. /*:252*//*253:*/
  17862. #line 6032 "./typica.w"
  17863. void addSqlQueryViewToLayout(QDomElement element,
  17864. QStack<QWidget*> *,
  17865. QStack<QLayout*> *layoutStack)
  17866. {
  17867. SqlQueryView*view= new SqlQueryView;
  17868. if(element.hasAttribute("id"))
  17869. {
  17870. view->setObjectName(element.attribute("id"));
  17871. }
  17872. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17873. layout->addWidget(view);
  17874. }
  17875. /*:253*//*254:*/
  17876. #line 6049 "./typica.w"
  17877. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  17878. QStack<QLayout*> *layoutStack)
  17879. {
  17880. QWidget*widget;
  17881. if(element.hasAttribute("time"))
  17882. {
  17883. if(element.attribute("time")=="true")
  17884. {
  17885. QDateTimeEdit*edit= new QDateTimeEdit;
  17886. edit->setDateTime(QDateTime::currentDateTime());
  17887. edit->setCalendarPopup(true);
  17888. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  17889. widget= qobject_cast<QWidget*> (edit);
  17890. }
  17891. else
  17892. {
  17893. QDateEdit*edit= new QDateEdit;
  17894. edit->setDate(QDate::currentDate());
  17895. edit->setCalendarPopup(true);
  17896. edit->setDisplayFormat("yyyy-MM-dd");
  17897. widget= qobject_cast<QWidget*> (edit);
  17898. }
  17899. }
  17900. else
  17901. {
  17902. QDateEdit*edit= new QDateEdit;
  17903. edit->setDate(QDate::currentDate());
  17904. edit->setCalendarPopup(true);
  17905. edit->setDisplayFormat("yyyy-MM-dd");
  17906. widget= qobject_cast<QWidget*> (edit);
  17907. }
  17908. if(element.hasAttribute("id"))
  17909. {
  17910. widget->setObjectName(element.attribute("id"));
  17911. }
  17912. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  17913. layout->addWidget(widget);
  17914. }
  17915. /*:254*//*255:*/
  17916. #line 6092 "./typica.w"
  17917. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  17918. {
  17919. setQDateTimeEditProperties(value,engine);
  17920. }
  17921. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  17922. {
  17923. setQAbstractSpinBoxProperties(value,engine);
  17924. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  17925. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  17926. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  17927. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  17928. value.setProperty("setToCurrentTime",
  17929. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  17930. }
  17931. /*:255*//*256:*/
  17932. #line 6114 "./typica.w"
  17933. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  17934. {
  17935. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17936. if(context->argumentCount()==3)
  17937. {
  17938. self->setDate(QDate(argument<int> (0,context),
  17939. argument<int> (1,context),
  17940. argument<int> (2,context)));
  17941. }
  17942. else
  17943. {
  17944. context->throwError("Incorrect number of arguments passed to "
  17945. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  17946. "specifying the year, month, and day.");
  17947. }
  17948. return QScriptValue();
  17949. }
  17950. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  17951. {
  17952. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17953. return QScriptValue(self->date().day());
  17954. }
  17955. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  17956. {
  17957. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17958. return QScriptValue(self->date().month());
  17959. }
  17960. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  17961. {
  17962. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17963. return QScriptValue(self->date().year());
  17964. }
  17965. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  17966. {
  17967. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  17968. self->setDateTime(QDateTime::currentDateTime());
  17969. return QScriptValue();
  17970. }
  17971. /*:256*//*260:*/
  17972. #line 6189 "./typica.w"
  17973. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  17974. {
  17975. QObject*parent= argument<QObject*> (0,context);
  17976. QString name= argument<QString> (1,context);
  17977. QObject*object= parent->findChild<QObject*> (name);
  17978. QScriptValue value;
  17979. if(object)
  17980. {
  17981. value= engine->newQObject(object);
  17982. QString className= object->metaObject()->className();
  17983. /*261:*/
  17984. #line 6207 "./typica.w"
  17985. if(className=="TemperatureDisplay")
  17986. {
  17987. setTemperatureDisplayProperties(value,engine);
  17988. }
  17989. else if(className=="TimerDisplay")
  17990. {
  17991. setTimerDisplayProperties(value,engine);
  17992. }
  17993. else if(className=="QAction")
  17994. {
  17995. setQActionProperties(value,engine);
  17996. }
  17997. else if(className=="QBoxLayout")
  17998. {
  17999. setQBoxLayoutProperties(value,engine);
  18000. }
  18001. else if(className=="QDateEdit")
  18002. {
  18003. setQDateEditProperties(value,engine);
  18004. }
  18005. else if(className=="QDateTimeEdit")
  18006. {
  18007. setQDateTimeEditProperties(value,engine);
  18008. }
  18009. else if(className=="QFrame")
  18010. {
  18011. setQFrameProperties(value,engine);
  18012. }
  18013. else if(className=="QHBoxLayout")
  18014. {
  18015. setQBoxLayoutProperties(value,engine);
  18016. }
  18017. else if(className=="QLCDNumber")
  18018. {
  18019. setQLCDNumberProperties(value,engine);
  18020. }
  18021. else if(className=="QMenu")
  18022. {
  18023. setQMenuProperties(value,engine);
  18024. }
  18025. else if(className=="QMenuBar")
  18026. {
  18027. setQMenuBarProperties(value,engine);
  18028. }
  18029. else if(className=="QPushButton")
  18030. {
  18031. setQPushButtonProperties(value,engine);
  18032. }
  18033. else if(className=="QSplitter")
  18034. {
  18035. setQSplitterProperties(value,engine);
  18036. }
  18037. else if(className=="QTableView")
  18038. {
  18039. if(object->property("tabletype").isValid())
  18040. {
  18041. if(object->property("tabletype").toString()=="SaltTable")
  18042. {
  18043. setSaltTableProperties(value,engine);
  18044. }
  18045. }
  18046. }
  18047. else if(className=="QVBoxLayout")
  18048. {
  18049. setQBoxLayoutProperties(value,engine);
  18050. }
  18051. else if(className=="QWidget")
  18052. {
  18053. setQWidgetProperties(value,engine);
  18054. }
  18055. else if(className=="ScriptQMainWindow")
  18056. {
  18057. setQMainWindowProperties(value,engine);
  18058. }
  18059. else if(className=="SqlComboBox")
  18060. {
  18061. setSqlComboBoxProperties(value,engine);
  18062. }
  18063. else if(className=="SqlQueryView")
  18064. {
  18065. setSqlQueryViewProperties(value,engine);
  18066. }
  18067. else if(className=="ZoomLog")
  18068. {
  18069. setZoomLogProperties(value,engine);
  18070. }
  18071. else if(className=="QTextEdit")
  18072. {
  18073. setQTextEditProperties(value,engine);
  18074. }
  18075. else if(className=="QWebView")
  18076. {
  18077. setQWebViewProperties(value,engine);
  18078. }
  18079. else if(className=="QLineEdit")
  18080. {
  18081. setQLineEditProperties(value,engine);
  18082. }
  18083. else if(className=="QSvgWidget")
  18084. {
  18085. setQSvgWidgetProperties(value,engine);
  18086. }
  18087. /*:261*/
  18088. #line 6200 "./typica.w"
  18089. }
  18090. return value;
  18091. }
  18092. /*:260*//*263:*/
  18093. #line 6340 "./typica.w"
  18094. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  18095. {
  18096. QTableView*self= getself<QTableView*> (context);
  18097. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18098. QString datum;
  18099. double total= 0.0;
  18100. int column= argument<int> (0,context);
  18101. int role= argument<int> (1,context);
  18102. for(int i= 0;i<model->rowCount();i++)
  18103. {
  18104. datum= model->data(model->index(i,column),role).toString();
  18105. if(!datum.isEmpty())
  18106. {
  18107. total+= datum.toDouble();
  18108. }
  18109. }
  18110. return QScriptValue(engine,total);
  18111. }
  18112. /*:263*//*264:*/
  18113. #line 6364 "./typica.w"
  18114. QScriptValue SaltTable_columnArray(QScriptContext*context,
  18115. QScriptEngine*engine)
  18116. {
  18117. QTableView*self= getself<QTableView*> (context);
  18118. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18119. int column= argument<int> (0,context);
  18120. int role= argument<int> (1,context);
  18121. QString literal= model->arrayLiteral(column,role);
  18122. return QScriptValue(engine,literal);
  18123. }
  18124. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  18125. QScriptEngine*engine)
  18126. {
  18127. QTableView*self= getself<QTableView*> (context);
  18128. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18129. int column= argument<int> (0,context);
  18130. int role= argument<int> (1,context);
  18131. QString literal= model->quotedArrayLiteral(column,role);
  18132. return QScriptValue(engine,literal);
  18133. }
  18134. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  18135. QScriptEngine*engine)
  18136. {
  18137. QTableView*self= getself<QTableView*> (context);
  18138. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18139. int column= argument<int> (0,context);
  18140. int role= argument<int> (1,context);
  18141. QString literal= model->arrayLiteral(column,role);
  18142. literal.chop(1);
  18143. literal= literal.remove(0,1);
  18144. return QScriptValue(engine,literal);
  18145. }
  18146. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  18147. QScriptEngine*engine)
  18148. {
  18149. QTableView*self= getself<QTableView*> (context);
  18150. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18151. int column= argument<int> (0,context);
  18152. int role= argument<int> (1,context);
  18153. QString literal= model->quotedArrayLiteral(column,role);
  18154. literal.chop(1);
  18155. literal= literal.remove(0,1);
  18156. return QScriptValue(engine,literal);
  18157. }
  18158. /*:264*//*265:*/
  18159. #line 6416 "./typica.w"
  18160. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  18161. {
  18162. QTableView*self= getself<QTableView*> (context);
  18163. QScriptValue value= engine->newQObject(self->model());
  18164. return value;
  18165. }
  18166. /*:265*//*266:*/
  18167. #line 6430 "./typica.w"
  18168. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  18169. {
  18170. QTableView*self= getself<QTableView*> (context);
  18171. int row= argument<int> (0,context);
  18172. int column= argument<int> (1,context);
  18173. QVariant value= argument<QVariant> (2,context);
  18174. int role= argument<int> (3,context);
  18175. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18176. QModelIndex cell= model->index(row,column);
  18177. model->setData(cell,value,role);
  18178. self->update(cell);
  18179. return QScriptValue();
  18180. }
  18181. /*:266*//*267:*/
  18182. #line 6448 "./typica.w"
  18183. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  18184. {
  18185. QTableView*self= getself<QTableView*> (context);
  18186. int row= argument<int> (0,context);
  18187. int column= argument<int> (1,context);
  18188. int role= argument<int> (2,context);
  18189. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18190. QModelIndex cell= model->index(row,column);
  18191. QVariant value= model->data(cell,role);
  18192. QScriptValue retval= engine->newVariant(value);
  18193. retval.setProperty("value",QScriptValue(value.toString()));
  18194. return retval;
  18195. }
  18196. /*:267*//*268:*/
  18197. #line 6468 "./typica.w"
  18198. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  18199. {
  18200. QTableView*self= getself<QTableView*> (context);
  18201. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18202. model->clear();
  18203. return QScriptValue();
  18204. }
  18205. /*:268*//*269:*/
  18206. #line 6480 "./typica.w"
  18207. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  18208. {
  18209. QTableView*self= getself<QTableView*> (context);
  18210. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18211. int row= argument<int> (0,context);
  18212. return engine->newVariant(model->removeRow(row));
  18213. }
  18214. /*:269*//*270:*/
  18215. #line 6493 "./typica.w"
  18216. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  18217. {
  18218. QTableView*self= getself<QTableView*> (context);
  18219. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  18220. QVariant value= argument<QVariant> (0,context);
  18221. int column= argument<int> (1,context);
  18222. return engine->newVariant(model->findData(value,column));
  18223. }
  18224. /*:270*//*271:*/
  18225. #line 6506 "./typica.w"
  18226. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  18227. {
  18228. setQWidgetProperties(value,engine);
  18229. value.setProperty("columnArray",
  18230. engine->newFunction(SaltTable_columnArray));
  18231. value.setProperty("quotedColumnArray",
  18232. engine->newFunction(SaltTable_quotedColumnArray));
  18233. value.setProperty("bindableColumnArray",
  18234. engine->newFunction(SaltTable_bindableColumnArray));
  18235. value.setProperty("bindableQuotedColumnArray",
  18236. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  18237. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  18238. value.setProperty("data",engine->newFunction(SaltTable_data));
  18239. value.setProperty("model",engine->newFunction(SaltTable_model));
  18240. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  18241. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  18242. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  18243. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  18244. }
  18245. /*:271*//*273:*/
  18246. #line 6543 "./typica.w"
  18247. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18248. {
  18249. setQComboBoxProperties(value,engine);
  18250. }
  18251. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  18252. {
  18253. setQWidgetProperties(value,engine);
  18254. value.setProperty("currentData",
  18255. engine->newFunction(QComboBox_currentData));
  18256. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  18257. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  18258. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  18259. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  18260. }
  18261. QScriptValue QComboBox_currentData(QScriptContext*context,
  18262. QScriptEngine*engine)
  18263. {
  18264. QComboBox*self= getself<QComboBox*> (context);
  18265. return QScriptValue(engine,
  18266. self->itemData(self->currentIndex()).toString());
  18267. }
  18268. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  18269. {
  18270. QComboBox*self= getself<QComboBox*> (context);
  18271. self->addItem(argument<QString> (0,context));
  18272. return QScriptValue();
  18273. }
  18274. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  18275. {
  18276. QComboBox*self= getself<QComboBox*> (context);
  18277. self->setModel(argument<QAbstractItemModel*> (0,context));
  18278. return QScriptValue();
  18279. }
  18280. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  18281. {
  18282. QComboBox*self= getself<QComboBox*> (context);
  18283. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  18284. }
  18285. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  18286. {
  18287. QComboBox*self= getself<QComboBox*> (context);
  18288. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  18289. }
  18290. #line 1 "./abouttypica.w"
  18291. /*:273*//*286:*/
  18292. #line 401 "./units.w"
  18293. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  18294. {
  18295. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  18296. argument<Units::Unit> (1,context),
  18297. argument<Units::Unit> (2,context)));
  18298. }
  18299. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  18300. QScriptEngine*)
  18301. {
  18302. return QScriptValue(Units::convertRelativeTemperature(
  18303. argument<double> (0,context),
  18304. argument<Units::Unit> (1,context),
  18305. argument<Units::Unit> (2,context)));
  18306. }
  18307. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  18308. {
  18309. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  18310. }
  18311. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  18312. {
  18313. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  18314. argument<Units::Unit> (1,context),
  18315. argument<Units::Unit> (2,context)));
  18316. }
  18317. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  18318. {
  18319. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  18320. }
  18321. /*:286*//*289:*/
  18322. #line 449 "./units.w"
  18323. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  18324. {
  18325. return engine->newVariant(QVariant(value));
  18326. }
  18327. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  18328. {
  18329. value= sv.toVariant().value<Units::Unit> ();
  18330. }
  18331. /*:289*//*299:*/
  18332. #line 149 "./measurement.w"
  18333. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  18334. {
  18335. QScriptValue object;
  18336. if(context->argumentCount()==2||context->argumentCount()==3)
  18337. {
  18338. double measurement= argument<double> (0,context);
  18339. QTime timestamp= argument<QTime> (1,context);
  18340. Units::Unit unit= Units::Fahrenheit;
  18341. if(context->argumentCount()==3)
  18342. {
  18343. unit= argument<Units::Unit> (2,context);
  18344. }
  18345. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  18346. setMeasurementProperties(object,engine);
  18347. }
  18348. else
  18349. {
  18350. context->throwError("Incorrect number of arguments passed to "
  18351. "Measurement::Measurement(). This method takes two "
  18352. "or three arguments.");
  18353. }
  18354. return object;
  18355. }
  18356. /*:299*//*300:*/
  18357. #line 176 "./measurement.w"
  18358. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  18359. {
  18360. }
  18361. /*:300*//*301:*/
  18362. #line 184 "./measurement.w"
  18363. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  18364. {
  18365. QVariant var;
  18366. var.setValue(measurement);
  18367. return engine->newVariant(var);
  18368. }
  18369. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  18370. {
  18371. measurement= value.toVariant().value<Measurement> ();
  18372. }
  18373. #line 6612 "./typica.w"
  18374. /*:301*//*319:*/
  18375. #line 7190 "./typica.w"
  18376. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  18377. {
  18378. QScriptValue object;
  18379. if(context->argumentCount()==1)
  18380. {
  18381. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  18382. QScriptEngine::ScriptOwnership);
  18383. setDAQProperties(object,engine);
  18384. }
  18385. else if(context->argumentCount()==2)
  18386. {
  18387. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  18388. argument<QString> (1,context)),
  18389. QScriptEngine::ScriptOwnership);
  18390. setDAQProperties(object,engine);
  18391. }
  18392. else
  18393. {
  18394. context->throwError("Incorrect number of arguments passed to DAQ"
  18395. "constructor. The DAQ constructor takes one"
  18396. "string as an argument specifying a device name."
  18397. "Example: Dev1");
  18398. }
  18399. return object;
  18400. }
  18401. /*:319*//*320:*/
  18402. #line 7220 "./typica.w"
  18403. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  18404. {
  18405. setQObjectProperties(value,engine);
  18406. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  18407. }
  18408. /*:320*//*321:*/
  18409. #line 7230 "./typica.w"
  18410. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18411. {
  18412. DAQ*self= getself<DAQ*> (context);
  18413. QScriptValue object;
  18414. if(self)
  18415. {
  18416. object=
  18417. engine->newQObject(self->newChannel(argument<int> (0,context),
  18418. argument<int> (1,context)));
  18419. setChannelProperties(object,engine);
  18420. }
  18421. return object;
  18422. }
  18423. /*:321*//*328:*/
  18424. #line 7386 "./typica.w"
  18425. QScriptValue constructFakeDAQ(QScriptContext*context,
  18426. QScriptEngine*engine)
  18427. {
  18428. QScriptValue object;
  18429. if(context->argumentCount()==1)
  18430. {
  18431. object=
  18432. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  18433. QScriptEngine::ScriptOwnership);
  18434. setFakeDAQProperties(object,engine);
  18435. }
  18436. else
  18437. {
  18438. context->throwError("Incorrect number of arguments passed to DAQ"
  18439. "constructor. The DAQ constructor takes one"
  18440. "string as an argument specifying a device name."
  18441. "Example: Dev1");
  18442. }
  18443. return object;
  18444. }
  18445. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  18446. {
  18447. setQObjectProperties(value,engine);
  18448. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  18449. }
  18450. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  18451. {
  18452. FakeDAQ*self= getself<FakeDAQ*> (context);
  18453. QScriptValue object;
  18454. if(self)
  18455. {
  18456. object=
  18457. engine->newQObject(self->newChannel(argument<int> (0,context),
  18458. argument<int> (1,context)));
  18459. setChannelProperties(object,engine);
  18460. }
  18461. return object;
  18462. }
  18463. /*:328*//*332:*/
  18464. #line 7477 "./typica.w"
  18465. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  18466. {
  18467. setQObjectProperties(value,engine);
  18468. }
  18469. /*:332*//*339:*/
  18470. #line 7669 "./typica.w"
  18471. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  18472. {
  18473. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  18474. setLinearCalibratorProperties(object,engine);
  18475. return object;
  18476. }
  18477. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  18478. {
  18479. setQObjectProperties(value,engine);
  18480. }
  18481. /*:339*//*344:*/
  18482. #line 7807 "./typica.w"
  18483. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  18484. {
  18485. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  18486. setLinearSplineInterpolatorProperties(object,engine);
  18487. return object;
  18488. }
  18489. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  18490. {
  18491. setQObjectProperties(value,engine);
  18492. }
  18493. /*:344*//*354:*/
  18494. #line 8016 "./typica.w"
  18495. QScriptValue constructTemperatureDisplay(QScriptContext*,
  18496. QScriptEngine*engine)
  18497. {
  18498. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  18499. setTemperatureDisplayProperties(object,engine);
  18500. return object;
  18501. }
  18502. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18503. {
  18504. setQLCDNumberProperties(value,engine);
  18505. value.setProperty("setDisplayUnits",
  18506. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  18507. }
  18508. /*:354*//*355:*/
  18509. #line 8040 "./typica.w"
  18510. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18511. {
  18512. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  18513. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18514. return QScriptValue();
  18515. }
  18516. /*:355*//*362:*/
  18517. #line 8177 "./typica.w"
  18518. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  18519. QScriptEngine*engine)
  18520. {
  18521. QScriptValue object=
  18522. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  18523. setMeasurementTimeOffsetProperties(object,engine);
  18524. return object;
  18525. }
  18526. void setMeasurementTimeOffsetProperties(QScriptValue value,
  18527. QScriptEngine*engine)
  18528. {
  18529. setQObjectProperties(value,engine);
  18530. }
  18531. /*:362*//*367:*/
  18532. #line 8286 "./typica.w"
  18533. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  18534. {
  18535. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  18536. return object;
  18537. }
  18538. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  18539. {
  18540. setQObjectProperties(value,engine);
  18541. }
  18542. /*:367*//*372:*/
  18543. #line 8383 "./typica.w"
  18544. QScriptValue constructZeroEmitter(QScriptContext*context,
  18545. QScriptEngine*engine)
  18546. {
  18547. QScriptValue object=
  18548. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  18549. setZeroEmitterProperties(object,engine);
  18550. return object;
  18551. }
  18552. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  18553. {
  18554. setQObjectProperties(value,engine);
  18555. }
  18556. /*:372*//*377:*/
  18557. #line 8463 "./typica.w"
  18558. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  18559. QScriptEngine*engine)
  18560. {
  18561. QScriptValue object=
  18562. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  18563. setMeasurementAdapterProperties(object,engine);
  18564. return object;
  18565. }
  18566. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  18567. {
  18568. setQObjectProperties(value,engine);
  18569. }
  18570. /*:377*//*394:*/
  18571. #line 8925 "./typica.w"
  18572. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  18573. {
  18574. QScriptValue object= engine->newQObject(new GraphView);
  18575. setGraphViewProperties(object,engine);
  18576. return object;
  18577. }
  18578. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  18579. {
  18580. setQGraphicsViewProperties(value,engine);
  18581. }
  18582. /*:394*//*417:*/
  18583. #line 9563 "./typica.w"
  18584. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  18585. {
  18586. QScriptValue object= engine->newQObject(new ZoomLog);
  18587. setZoomLogProperties(object,engine);
  18588. return object;
  18589. }
  18590. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  18591. {
  18592. setQTableViewProperties(value,engine);
  18593. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  18594. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  18595. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  18596. value.setProperty("restoreState",
  18597. engine->newFunction(ZoomLog_restoreState));
  18598. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  18599. value.setProperty("saveTemporary",
  18600. engine->newFunction(ZoomLog_saveTemporary));
  18601. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  18602. }
  18603. /*:417*//*418:*/
  18604. #line 9590 "./typica.w"
  18605. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  18606. {
  18607. ZoomLog*self= getself<ZoomLog*> (context);
  18608. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  18609. return QScriptValue(engine,retval);
  18610. }
  18611. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  18612. {
  18613. ZoomLog*self= getself<ZoomLog*> (context);
  18614. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  18615. return QScriptValue(engine,retval);
  18616. }
  18617. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  18618. QScriptEngine*engine)
  18619. {
  18620. ZoomLog*self= getself<ZoomLog*> (context);
  18621. QString filename= QDir::tempPath();
  18622. filename.append("/");
  18623. filename.append(QUuid::createUuid().toString());
  18624. filename.append(".xml");
  18625. QFile*file= new QFile(filename);
  18626. self->saveXML(file);
  18627. file->close();
  18628. delete file;
  18629. return QScriptValue(engine,filename);
  18630. }
  18631. /*:418*//*419:*/
  18632. #line 9638 "./typica.w"
  18633. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  18634. {
  18635. ZoomLog*self= getself<ZoomLog*> (context);
  18636. QString key= argument<QString> (0,context);
  18637. int columns= argument<int> (1,context);
  18638. QSettings settings;
  18639. for(int i= 0;i<columns;i++)
  18640. {
  18641. if(self->columnWidth(i))
  18642. {
  18643. settings.beginGroup(key);
  18644. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  18645. settings.endGroup();
  18646. }
  18647. }
  18648. return QScriptValue();
  18649. }
  18650. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  18651. {
  18652. ZoomLog*self= getself<ZoomLog*> (context);
  18653. QString key= argument<QString> (0,context);
  18654. int columns= argument<int> (1,context);
  18655. QSettings settings;
  18656. for(int i= 0;i<columns;i++)
  18657. {
  18658. settings.beginGroup(key);
  18659. self->setColumnWidth(i,
  18660. settings.value(QString("%1").arg(i),80).toInt());
  18661. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  18662. {
  18663. self->setColumnWidth(i,80);
  18664. }
  18665. settings.endGroup();
  18666. }
  18667. return QScriptValue();
  18668. }
  18669. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  18670. {
  18671. ZoomLog*self= getself<ZoomLog*> (context);
  18672. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  18673. }
  18674. /*:419*//*420:*/
  18675. #line 9691 "./typica.w"
  18676. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  18677. {
  18678. ZoomLog*self= getself<ZoomLog*> (context);
  18679. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  18680. return QScriptValue();
  18681. }
  18682. /*:420*//*455:*/
  18683. #line 10511 "./typica.w"
  18684. QScriptValue constructAnnotationButton(QScriptContext*context,
  18685. QScriptEngine*engine)
  18686. {
  18687. QScriptValue object=
  18688. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  18689. setAnnotationButtonProperties(object,engine);
  18690. return object;
  18691. }
  18692. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  18693. {
  18694. setQPushButtonProperties(value,engine);
  18695. }
  18696. /*:455*//*463:*/
  18697. #line 10654 "./typica.w"
  18698. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  18699. QScriptEngine*engine)
  18700. {
  18701. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  18702. argument<QString> (0,context),argument<QString> (1,context)));
  18703. setAnnotationSpinBoxProperties(object,engine);
  18704. return object;
  18705. }
  18706. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18707. {
  18708. setQDoubleSpinBoxProperties(value,engine);
  18709. }
  18710. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18711. {
  18712. setQAbstractSpinBoxProperties(value,engine);
  18713. }
  18714. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  18715. {
  18716. setQWidgetProperties(value,engine);
  18717. }
  18718. /*:463*//*484:*/
  18719. #line 11077 "./typica.w"
  18720. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  18721. {
  18722. QScriptValue object= engine->newQObject(new TimerDisplay);
  18723. setTimerDisplayProperties(object,engine);
  18724. return object;
  18725. }
  18726. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  18727. {
  18728. setQLCDNumberProperties(value,engine);
  18729. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  18730. }
  18731. /*:484*//*485:*/
  18732. #line 11096 "./typica.w"
  18733. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  18734. {
  18735. TimerDisplay*self= getself<TimerDisplay*> (context);
  18736. if(self)
  18737. {
  18738. switch(argument<int> (0,context))
  18739. {
  18740. case 0:
  18741. self->setMode(TimerDisplay::CountUp);
  18742. break;
  18743. case 1:
  18744. self->setMode(TimerDisplay::CountDown);
  18745. break;
  18746. case 2:
  18747. self->setMode(TimerDisplay::Clock);
  18748. break;
  18749. default:
  18750. break;
  18751. }
  18752. }
  18753. return QScriptValue();
  18754. }
  18755. /*:485*//*512:*/
  18756. #line 11602 "./typica.w"
  18757. QScriptValue constructWidgetDecorator(QScriptContext*context,
  18758. QScriptEngine*engine)
  18759. {
  18760. QWidget*widget= argument<QWidget*> (0,context);
  18761. QString text= argument<QString> (1,context);
  18762. Qt::Orientations orientation;
  18763. switch(argument<int> (2,context))
  18764. {
  18765. case 2:
  18766. orientation= Qt::Vertical;
  18767. break;
  18768. default:
  18769. orientation= Qt::Horizontal;
  18770. break;
  18771. }
  18772. QScriptValue object=
  18773. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  18774. setWidgetDecoratorProperties(object,engine);
  18775. return object;
  18776. }
  18777. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  18778. {
  18779. setQWidgetProperties(value,engine);
  18780. }
  18781. /*:512*//*525:*/
  18782. #line 11883 "./typica.w"
  18783. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  18784. {
  18785. QScriptValue object= engine->newQObject(new LogEditWindow);
  18786. return object;
  18787. }
  18788. /*:525*//*544:*/
  18789. #line 12410 "./typica.w"
  18790. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  18791. {
  18792. QIODevice*device= argument<QIODevice*> (0,context);
  18793. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  18794. argument<int> (1,context)));
  18795. object.setProperty("input",engine->newFunction(XMLInput_input));
  18796. return object;
  18797. }
  18798. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  18799. {
  18800. XMLInput*self= getself<XMLInput*> (context);
  18801. self->input();
  18802. return QScriptValue();
  18803. }
  18804. /*:544*//*558:*/
  18805. #line 157 "./webview.w"
  18806. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  18807. {
  18808. QScriptValue object= engine->newQObject(new TypicaWebView);
  18809. setQWebViewProperties(object,engine);
  18810. return object;
  18811. }
  18812. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  18813. {
  18814. setQWidgetProperties(value,engine);
  18815. }
  18816. /*:558*//*559:*/
  18817. #line 174 "./webview.w"
  18818. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  18819. QStack<QLayout*> *layoutStack)
  18820. {
  18821. TypicaWebView*view= new TypicaWebView;
  18822. if(element.hasAttribute("id"))
  18823. {
  18824. view->setObjectName(element.attribute("id"));
  18825. }
  18826. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18827. layout->addWidget(view);
  18828. }
  18829. /*:559*//*564:*/
  18830. #line 225 "./webview.w"
  18831. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  18832. {
  18833. QVariant var;
  18834. var.setValue(element);
  18835. QScriptValue object= engine->newVariant(var);
  18836. return object;
  18837. }
  18838. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  18839. {
  18840. element= value.toVariant().value<QWebElement> ();
  18841. }
  18842. /*:564*//*569:*/
  18843. #line 290 "./webview.w"
  18844. template<> QWebElement argument(int arg,QScriptContext*context)
  18845. {
  18846. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  18847. }
  18848. /*:569*//*570:*/
  18849. #line 299 "./webview.w"
  18850. QScriptValue constructWebElement(QScriptContext*context,
  18851. QScriptEngine*engine)
  18852. {
  18853. QWebElement element= argument<QWebElement> (0,context);
  18854. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  18855. return object;
  18856. }
  18857. /*:570*//*638:*/
  18858. #line 13763 "./typica.w"
  18859. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  18860. {
  18861. QScriptValue object= engine->newQObject(new SqlQueryView);
  18862. setSqlQueryViewProperties(object,engine);
  18863. return object;
  18864. }
  18865. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  18866. {
  18867. setQTableViewProperties(value,engine);
  18868. value.setProperty("setHeaderData",
  18869. engine->newFunction(SqlQueryView_setHeaderData));
  18870. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  18871. }
  18872. /*:638*//*639:*/
  18873. #line 13781 "./typica.w"
  18874. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  18875. {
  18876. SqlQueryView*self= getself<SqlQueryView*> (context);
  18877. QString query= argument<QString> (0,context);
  18878. self->setQuery(query);
  18879. self->reset();
  18880. return QScriptValue();
  18881. }
  18882. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  18883. QScriptEngine*)
  18884. {
  18885. SqlQueryView*self= getself<SqlQueryView*> (context);
  18886. int section= argument<int> (0,context);
  18887. QString data= argument<QString> (1,context);
  18888. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  18889. return QScriptValue();
  18890. }
  18891. /*:639*//*647:*/
  18892. #line 13990 "./typica.w"
  18893. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  18894. QStack<QLayout*> *layoutStack)
  18895. {
  18896. QTextEdit*widget= new QTextEdit;
  18897. if(element.hasAttribute("id"))
  18898. {
  18899. widget->setObjectName(element.attribute("id"));
  18900. }
  18901. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18902. layout->addWidget(widget);
  18903. QTextDocument*document= new QTextDocument;
  18904. QFont defaultFont;
  18905. defaultFont.setPointSize(11);
  18906. document->setDefaultFont(defaultFont);
  18907. QTextCursor cursor(document);
  18908. /*648:*/
  18909. #line 14013 "./typica.w"
  18910. QDomNodeList children= element.childNodes();
  18911. for(int i= 0;i<children.count();i++)
  18912. {
  18913. QDomNode current;
  18914. QDomElement currentElement;
  18915. current= children.at(i);
  18916. if(current.isElement())
  18917. {
  18918. currentElement= current.toElement();
  18919. /*649:*/
  18920. #line 14030 "./typica.w"
  18921. if(currentElement.tagName()=="style")
  18922. {
  18923. document->setDefaultStyleSheet(currentElement.text());
  18924. }
  18925. /*:649*//*650:*/
  18926. #line 14041 "./typica.w"
  18927. if(currentElement.tagName()=="html")
  18928. {
  18929. cursor.insertHtml(currentElement.text());
  18930. }
  18931. /*:650*//*651:*/
  18932. #line 14051 "./typica.w"
  18933. if(currentElement.tagName()=="text")
  18934. {
  18935. cursor.insertText(currentElement.text());
  18936. }
  18937. /*:651*//*652:*/
  18938. #line 14061 "./typica.w"
  18939. if(currentElement.tagName()=="table")
  18940. {
  18941. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  18942. ReportTable*table= new ReportTable(frame,currentElement);
  18943. table->setParent(widget);
  18944. if(currentElement.hasAttribute("id"))
  18945. {
  18946. table->setObjectName(currentElement.attribute("id"));
  18947. }
  18948. }
  18949. /*:652*/
  18950. #line 14023 "./typica.w"
  18951. }
  18952. }
  18953. /*:648*/
  18954. #line 14006 "./typica.w"
  18955. widget->setDocument(document);
  18956. }
  18957. /*:647*//*663:*/
  18958. #line 14274 "./typica.w"
  18959. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  18960. {
  18961. QTextEdit*self= getself<QTextEdit*> (context);
  18962. QTextDocument*document= self->document();
  18963. QPrinter printer;
  18964. QPrintDialog printwindow(&printer,self);
  18965. if(printwindow.exec()!=QDialog::Accepted)
  18966. {
  18967. return QScriptValue();
  18968. }
  18969. document->print(&printer);
  18970. return QScriptValue();
  18971. }
  18972. /*:663*//*664:*/
  18973. #line 14292 "./typica.w"
  18974. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  18975. {
  18976. setQAbstractScrollAreaProperties(value,engine);
  18977. value.setProperty("print",engine->newFunction(QTextEdit_print));
  18978. }
  18979. #line 1 "./daterangeselector.w"
  18980. /*:664*//*683:*/
  18981. #line 463 "./daterangeselector.w"
  18982. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  18983. QStack<QLayout*> *layoutStack)
  18984. {
  18985. DateRangeSelector*widget= new DateRangeSelector;
  18986. if(element.hasAttribute("id"))
  18987. {
  18988. widget->setObjectName(element.attribute("id"));
  18989. }
  18990. if(element.hasAttribute("initial"))
  18991. {
  18992. widget->setCurrentIndex(element.attribute("initial").toInt());
  18993. }
  18994. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18995. layout->addWidget(widget);
  18996. }
  18997. /*:683*//*694:*/
  18998. #line 14472 "./typica.w"
  18999. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  19000. QStack<QLayout*> *layoutStack)
  19001. {
  19002. FormArray*widget= new FormArray(element);
  19003. if(element.hasAttribute("id"))
  19004. {
  19005. widget->setObjectName(element.attribute("id"));
  19006. }
  19007. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19008. layout->addWidget(widget);
  19009. }
  19010. /*:694*//*715:*/
  19011. #line 15059 "./typica.w"
  19012. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  19013. QStack<QLayout*> *layoutStack)
  19014. {
  19015. ScaleControl*scale= new ScaleControl;
  19016. if(element.hasAttribute("id"))
  19017. {
  19018. scale->setObjectName(element.attribute("id"));
  19019. }
  19020. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19021. layout->addWidget(scale);
  19022. }
  19023. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  19024. QStack<QLayout*> *layoutStack)
  19025. {
  19026. IntensityControl*scale= new IntensityControl;
  19027. if(element.hasAttribute("id"))
  19028. {
  19029. scale->setObjectName(element.attribute("id"));
  19030. }
  19031. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19032. layout->addWidget(scale);
  19033. }
  19034. /*:715*//*741:*/
  19035. #line 15649 "./typica.w"
  19036. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  19037. {
  19038. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  19039. setDeviceTreeModelProperties(object,engine);
  19040. return object;
  19041. }
  19042. /*:741*//*743:*/
  19043. #line 15672 "./typica.w"
  19044. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  19045. {
  19046. setQAbstractItemModelProperties(value,engine);
  19047. value.setProperty("referenceElement",
  19048. engine->newFunction(DeviceTreeModel_referenceElement));
  19049. }
  19050. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  19051. {
  19052. setQObjectProperties(value,engine);
  19053. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  19054. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  19055. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  19056. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  19057. }
  19058. /*:743*//*744:*/
  19059. #line 15699 "./typica.w"
  19060. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  19061. QScriptEngine*engine)
  19062. {
  19063. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  19064. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  19065. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  19066. QDomElement node;
  19067. QVariantMap retval;
  19068. retval.insert("driver",referenceElement.attribute("driver"));
  19069. for(int i= 0;i<configData.size();i++)
  19070. {
  19071. node= configData.at(i).toElement();
  19072. retval.insert(node.attribute("name"),node.attribute("value"));
  19073. }
  19074. return engine->toScriptValue(retval);
  19075. }
  19076. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  19077. {
  19078. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19079. QModelIndex index= argument<QModelIndex> (0,context);
  19080. int role= argument<int> (1,context);
  19081. return engine->toScriptValue(model->data(index,role));
  19082. }
  19083. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  19084. {
  19085. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19086. int row= 0;
  19087. int column= 0;
  19088. QModelIndex index;
  19089. if(context->argumentCount()> 1)
  19090. {
  19091. row= argument<int> (0,context);
  19092. column= argument<int> (1,context);
  19093. }
  19094. if(context->argumentCount()> 2)
  19095. {
  19096. index= argument<QModelIndex> (2,context);
  19097. }
  19098. QModelIndex retval= model->index(row,column,index);
  19099. return engine->toScriptValue(retval);
  19100. }
  19101. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  19102. QScriptEngine*)
  19103. {
  19104. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19105. QModelIndex index;
  19106. if(context->argumentCount()==1)
  19107. {
  19108. index= argument<QModelIndex> (0,context);
  19109. }
  19110. return QScriptValue(model->rowCount(index));
  19111. }
  19112. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  19113. QScriptEngine*engine)
  19114. {
  19115. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  19116. QModelIndex index;
  19117. if(context->argumentCount()==1)
  19118. {
  19119. index= argument<QModelIndex> (0,context);
  19120. }
  19121. return QScriptValue(engine,model->hasChildren(index));
  19122. }
  19123. /*:744*//*747:*/
  19124. #line 15783 "./typica.w"
  19125. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  19126. {
  19127. QVariant var;
  19128. var.setValue(index);
  19129. QScriptValue object= engine->newVariant(var);
  19130. return object;
  19131. }
  19132. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  19133. {
  19134. index= value.toVariant().value<QModelIndex> ();
  19135. }
  19136. /*:747*//*763:*/
  19137. #line 16081 "./typica.w"
  19138. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  19139. QScriptEngine*engine)
  19140. {
  19141. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  19142. return object;
  19143. }
  19144. /*:763*//*834:*/
  19145. #line 47 "./settings.w"
  19146. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  19147. {
  19148. QScriptValue object= engine->newQObject(new SettingsWindow);
  19149. return object;
  19150. }
  19151. /*:834*//*859:*/
  19152. #line 18735 "./typica.w"
  19153. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  19154. {
  19155. QScriptValue object;
  19156. if(context->argumentCount()==2)
  19157. {
  19158. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  19159. argument<QModelIndex> (1,context)),
  19160. QScriptEngine::ScriptOwnership);
  19161. setModbusRTUDeviceProperties(object,engine);
  19162. }
  19163. else
  19164. {
  19165. context->throwError("Incorrect number of arguments passed to "
  19166. "ModbusRTUDevice constructor. This takes the configuration model "
  19167. "and an index.");
  19168. }
  19169. return object;
  19170. }
  19171. /*:859*//*860:*/
  19172. #line 18757 "./typica.w"
  19173. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  19174. {
  19175. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19176. QScriptValue object;
  19177. if(self)
  19178. {
  19179. if(self->channels.size()> 0)
  19180. {
  19181. object= engine->newQObject(self->channels.at(0));
  19182. setChannelProperties(object,engine);
  19183. }
  19184. }
  19185. return object;
  19186. }
  19187. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  19188. {
  19189. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  19190. QScriptValue object;
  19191. if(self)
  19192. {
  19193. if(self->channels.size()> 1)
  19194. {
  19195. object= engine->newQObject(self->channels.at(1));
  19196. setChannelProperties(object,engine);
  19197. }
  19198. }
  19199. return object;
  19200. }
  19201. /*:860*//*861:*/
  19202. #line 18790 "./typica.w"
  19203. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19204. {
  19205. setQObjectProperties(value,engine);
  19206. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  19207. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  19208. }
  19209. /*:861*//*877:*/
  19210. #line 653 "./modbus.w"
  19211. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  19212. {
  19213. QScriptValue object;
  19214. if(context->argumentCount()==2)
  19215. {
  19216. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  19217. argument<QModelIndex> (1,context)),
  19218. QScriptEngine::ScriptOwnership);
  19219. setModbusNGProperties(object,engine);
  19220. }
  19221. else
  19222. {
  19223. context->throwError("Incorrect number of arguments passed to "
  19224. "ModbusNG constructor.");
  19225. }
  19226. return object;
  19227. }
  19228. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  19229. {
  19230. setQObjectProperties(value,engine);
  19231. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  19232. }
  19233. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  19234. {
  19235. ModbusNG*self= getself<ModbusNG*> (context);
  19236. QScriptValue object;
  19237. if(self)
  19238. {
  19239. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19240. setChannelProperties(object,engine);
  19241. }
  19242. return object;
  19243. }
  19244. #line 19341 "./typica.w"
  19245. #line 1 "./unsupportedserial.w"
  19246. /*:877*//*891:*/
  19247. #line 357 "./unsupportedserial.w"
  19248. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  19249. {
  19250. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  19251. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  19252. QScriptValue object= engine->newQObject(device);
  19253. setQObjectProperties(object,engine);
  19254. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  19255. return object;
  19256. }
  19257. /*:891*//*896:*/
  19258. #line 430 "./unsupportedserial.w"
  19259. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  19260. {
  19261. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  19262. QScriptValue object;
  19263. if(self)
  19264. {
  19265. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19266. setChannelProperties(object,engine);
  19267. }
  19268. return object;
  19269. }
  19270. /*:896*//*903:*/
  19271. #line 630 "./unsupportedserial.w"
  19272. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  19273. {
  19274. return engine->toScriptValue<QTime> (QTime::currentTime());
  19275. }
  19276. /*:903*//*907:*/
  19277. #line 667 "./unsupportedserial.w"
  19278. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  19279. {
  19280. QScriptValue object= engine->newQObject(new QextSerialPort());
  19281. setSerialPortProperties(object,engine);
  19282. return object;
  19283. }
  19284. /*:907*//*908:*/
  19285. #line 678 "./unsupportedserial.w"
  19286. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  19287. {
  19288. setQIODeviceProperties(value,engine);
  19289. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  19290. }
  19291. /*:908*//*909:*/
  19292. #line 687 "./unsupportedserial.w"
  19293. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  19294. {
  19295. QextSerialPort*self= getself<QextSerialPort*> (context);
  19296. self->flush();
  19297. return QScriptValue();
  19298. }
  19299. /*:909*//*912:*/
  19300. #line 721 "./unsupportedserial.w"
  19301. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  19302. {
  19303. setQObjectProperties(value,engine);
  19304. }
  19305. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  19306. {
  19307. QScriptValue object= engine->newQObject(new QTimer);
  19308. setQTimerProperties(object,engine);
  19309. return object;
  19310. }
  19311. #line 19343 "./typica.w"
  19312. #line 1 "./phidgets.w"
  19313. /*:912*//*933:*/
  19314. #line 463 "./phidgets.w"
  19315. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  19316. {
  19317. if(context->argumentCount()!=1)
  19318. {
  19319. context->throwError("Incorrect number of arguments passed to "
  19320. "PhidgetsTemperatureSensor constructor. This takes "
  19321. "a QModelIndex.");
  19322. }
  19323. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  19324. setQObjectProperties(object,engine);
  19325. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  19326. return object;
  19327. }
  19328. /*:933*//*934:*/
  19329. #line 480 "./phidgets.w"
  19330. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  19331. {
  19332. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  19333. QScriptValue object;
  19334. if(self)
  19335. {
  19336. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  19337. setChannelProperties(object,engine);
  19338. }
  19339. return object;
  19340. }
  19341. #line 19345 "./typica.w"
  19342. /*:934*//*966:*/
  19343. #line 151 "./rate.w"
  19344. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  19345. {
  19346. int cachetime= 1;
  19347. int scaletime= 1;
  19348. if(context->argumentCount()> 0)
  19349. {
  19350. cachetime= argument<int> (0,context);
  19351. if(context->argumentCount()> 1)
  19352. {
  19353. scaletime= argument<int> (1,context);
  19354. }
  19355. }
  19356. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  19357. setRateOfChangeProperties(object,engine);
  19358. return object;
  19359. }
  19360. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  19361. {
  19362. setQObjectProperties(value,engine);
  19363. }
  19364. /*:966*//*991:*/
  19365. #line 614 "./dataqsdk.w"
  19366. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  19367. {
  19368. QScriptValue object;
  19369. if(context->argumentCount()==1)
  19370. {
  19371. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  19372. QScriptEngine::ScriptOwnership);
  19373. setDataqSdkDeviceProperties(object,engine);
  19374. }
  19375. else
  19376. {
  19377. context->throwError("Incorrect number of arguments passed to "
  19378. "DataqSdkDevice. The constructor takes one string "
  19379. "as an argument specifying a device name. "
  19380. "Example: Dev1");
  19381. }
  19382. return object;
  19383. }
  19384. /*:991*//*992:*/
  19385. #line 637 "./dataqsdk.w"
  19386. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  19387. {
  19388. setQObjectProperties(value,engine);
  19389. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  19390. }
  19391. /*:992*//*993:*/
  19392. #line 647 "./dataqsdk.w"
  19393. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  19394. {
  19395. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  19396. QScriptValue object;
  19397. if(self)
  19398. {
  19399. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  19400. setChannelProperties(object,engine);
  19401. }
  19402. return object;
  19403. }
  19404. /*:993*//*1018:*/
  19405. #line 80 "./scales.w"
  19406. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  19407. {
  19408. QScriptValue object;
  19409. QString labelText= "";
  19410. if(context->argumentCount()==1)
  19411. {
  19412. labelText= argument<QString> (0,context);
  19413. }
  19414. object= engine->newQObject(new DragLabel(labelText));
  19415. setDragLabelProperties(object,engine);
  19416. return object;
  19417. }
  19418. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  19419. {
  19420. setQLabelProperties(value,engine);
  19421. }
  19422. /*:1018*//*1028:*/
  19423. #line 298 "./scales.w"
  19424. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  19425. {
  19426. return engine->newVariant(QVariant((int)(value)));
  19427. }
  19428. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  19429. {
  19430. value= (BaudRateType)(sv.toVariant().toInt());
  19431. }
  19432. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  19433. {
  19434. return engine->newVariant(QVariant((int)(value)));
  19435. }
  19436. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  19437. {
  19438. value= (DataBitsType)(sv.toVariant().toInt());
  19439. }
  19440. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  19441. {
  19442. return engine->newVariant(QVariant((int)(value)));
  19443. }
  19444. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  19445. {
  19446. value= (ParityType)(sv.toVariant().toInt());
  19447. }
  19448. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  19449. {
  19450. return engine->newVariant(QVariant((int)(value)));
  19451. }
  19452. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  19453. {
  19454. value= (StopBitsType)(sv.toVariant().toInt());
  19455. }
  19456. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  19457. {
  19458. return engine->newVariant(QVariant((int)(value)));
  19459. }
  19460. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  19461. {
  19462. value= (FlowType)(sv.toVariant().toInt());
  19463. }
  19464. /*:1028*//*1031:*/
  19465. #line 367 "./scales.w"
  19466. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  19467. {
  19468. setQIODeviceProperties(value,engine);
  19469. }
  19470. /*:1031*//*1032:*/
  19471. #line 375 "./scales.w"
  19472. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  19473. {
  19474. QScriptValue object;
  19475. if(context->argumentCount()==1)
  19476. {
  19477. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  19478. setSerialScaleProperties(object,engine);
  19479. }
  19480. else
  19481. {
  19482. context->throwError("Incorrect number of arguments passed to "
  19483. "SerialScale. The constructor takes one string "
  19484. "as an argument specifying a port name.");
  19485. }
  19486. return object;
  19487. }
  19488. /*:1032*//*1054:*/
  19489. #line 278 "./valueannotation.w"
  19490. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  19491. {
  19492. QScriptValue object= engine->newQObject(new ValueAnnotation);
  19493. setValueAnnotationProperties(object,engine);
  19494. return object;
  19495. }
  19496. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  19497. {
  19498. setQObjectProperties(value,engine);
  19499. }
  19500. #line 19992 "./typica.w"
  19501. #line 1 "./thresholdannotation.w"
  19502. /*:1054*//*1067:*/
  19503. #line 223 "./thresholdannotation.w"
  19504. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  19505. {
  19506. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  19507. setAnnotatorProperties(object,engine);
  19508. return object;
  19509. }
  19510. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  19511. {
  19512. setQObjectProperties(value,engine);
  19513. }
  19514. #line 19994 "./typica.w"
  19515. /*:1067*/
  19516. #line 530 "./typica.w"
  19517. /*617:*/
  19518. #line 13398 "./typica.w"
  19519. void messageFileOutput(QtMsgType,const char*msg)
  19520. {
  19521. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  19522. output.open(QIODevice::WriteOnly|QIODevice::Append);
  19523. QTextStream outstream(&output);
  19524. outstream<<msg<<"\r\n";
  19525. }
  19526. /*:617*/
  19527. #line 531 "./typica.w"
  19528. /*614:*/
  19529. #line 13359 "./typica.w"
  19530. int main(int argc,char**argv)
  19531. {
  19532. int*c= &argc;
  19533. Application app(*c,argv);
  19534. QSettings settings;
  19535. /*615:*/
  19536. #line 13385 "./typica.w"
  19537. if(settings.value("settings/advanced/logging",false).toBool())
  19538. {
  19539. qInstallMsgHandler(messageFileOutput);
  19540. }
  19541. /*:615*/
  19542. #line 13365 "./typica.w"
  19543. /*618:*/
  19544. #line 13411 "./typica.w"
  19545. QStringList themeSearchPath= QIcon::themeSearchPaths();
  19546. themeSearchPath.append(":/resources/icons/tango");
  19547. QIcon::setThemeSearchPaths(themeSearchPath);
  19548. QIcon::setThemeName(":/resources/icons/tango");
  19549. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  19550. /*:618*/
  19551. #line 13366 "./typica.w"
  19552. /*619:*/
  19553. #line 13431 "./typica.w"
  19554. QFile entypo(":/resources/fonts/entypo.ttf");
  19555. entypo.open(QIODevice::ReadOnly);
  19556. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  19557. entypo.close();
  19558. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  19559. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  19560. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  19561. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  19562. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  19563. /*:619*/
  19564. #line 13367 "./typica.w"
  19565. /*773:*/
  19566. #line 16371 "./typica.w"
  19567. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  19568. /*:773*//*783:*/
  19569. #line 16613 "./typica.w"
  19570. app.registerDeviceConfigurationWidget("nidaqmxbase",
  19571. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  19572. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  19573. NiDaqMxBase9211ConfWidget::staticMetaObject);
  19574. app.registerDeviceConfigurationWidget("ni9211seriestc",
  19575. Ni9211TcConfWidget::staticMetaObject);
  19576. /*:783*//*791:*/
  19577. #line 16844 "./typica.w"
  19578. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  19579. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  19580. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  19581. /*:791*//*815:*/
  19582. #line 17813 "./typica.w"
  19583. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  19584. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  19585. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  19586. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  19587. /*:815*//*820:*/
  19588. #line 17898 "./typica.w"
  19589. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  19590. /*:820*//*823:*/
  19591. #line 17968 "./typica.w"
  19592. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  19593. /*:823*//*826:*/
  19594. #line 18095 "./typica.w"
  19595. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  19596. #line 1 "./freeannotation.w"
  19597. /*:826*//*830:*/
  19598. #line 57 "./freeannotation.w"
  19599. app.registerDeviceConfigurationWidget("freeannotation",
  19600. FreeAnnotationConfWidget::staticMetaObject);
  19601. #line 18099 "./typica.w"
  19602. #line 1 "./settings.w"
  19603. /*:830*//*864:*/
  19604. #line 19331 "./typica.w"
  19605. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  19606. /*:864*//*870:*/
  19607. #line 317 "./modbus.w"
  19608. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  19609. app.registerDeviceConfigurationWidget("modbusnginput",
  19610. ModbusNGInputConfWidget::staticMetaObject);
  19611. /*:870*//*886:*/
  19612. #line 264 "./unsupportedserial.w"
  19613. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  19614. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  19615. app.registerDeviceConfigurationWidget("unsupporteddevice",
  19616. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  19617. /*:886*//*920:*/
  19618. #line 181 "./phidgets.w"
  19619. app.registerDeviceConfigurationWidget("phidgets1048",
  19620. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  19621. app.registerDeviceConfigurationWidget("phidgets1048channel",
  19622. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  19623. /*:920*//*940:*/
  19624. #line 19467 "./typica.w"
  19625. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  19626. /*:940*//*943:*/
  19627. #line 19527 "./typica.w"
  19628. app.registerDeviceConfigurationWidget("coolingtimer",
  19629. CoolingTimerConfWidget::staticMetaObject);
  19630. /*:943*//*948:*/
  19631. #line 19786 "./typica.w"
  19632. app.registerDeviceConfigurationWidget("rangetimer",
  19633. RangeTimerConfWidget::staticMetaObject);
  19634. /*:948*//*953:*/
  19635. #line 19887 "./typica.w"
  19636. app.registerDeviceConfigurationWidget("multirangetimer",
  19637. MultiRangeTimerConfWidget::staticMetaObject);
  19638. /*:953*//*958:*/
  19639. #line 19982 "./typica.w"
  19640. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  19641. #line 1 "./rate.w"
  19642. /*:958*//*970:*/
  19643. #line 253 "./rate.w"
  19644. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  19645. /*:970*//*1011:*/
  19646. #line 1233 "./dataqsdk.w"
  19647. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  19648. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  19649. DataqSdkChannelConfWidget::staticMetaObject);
  19650. /*:1011*//*1036:*/
  19651. #line 552 "./scales.w"
  19652. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  19653. /*:1036*//*1044:*/
  19654. #line 138 "./valueannotation.w"
  19655. app.registerDeviceConfigurationWidget("valueannotation",
  19656. ValueAnnotationConfWidget::staticMetaObject);
  19657. /*:1044*//*1060:*/
  19658. #line 124 "./thresholdannotation.w"
  19659. app.registerDeviceConfigurationWidget("thresholdannotation",
  19660. ThresholdAnnotationConfWidget::staticMetaObject);
  19661. /*:1060*/
  19662. #line 13369 "./typica.w"
  19663. /*620:*/
  19664. #line 13448 "./typica.w"
  19665. if(settings.value("database/exists","false").toString()=="true")
  19666. {
  19667. /*625:*/
  19668. #line 13577 "./typica.w"
  19669. QSqlDatabase database=
  19670. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  19671. database.setConnectOptions("application_name=Typica");
  19672. database.setHostName(settings.value("database/hostname").toString());
  19673. database.setPort(settings.value("database/portnumber",5432).toInt());
  19674. database.setDatabaseName(settings.value("database/dbname").toString());
  19675. database.setUserName(settings.value("database/user").toString());
  19676. database.setPassword(settings.value("database/password").toString());
  19677. if(!database.open())
  19678. {
  19679. settings.setValue("database/exists","false");
  19680. }
  19681. else
  19682. {
  19683. database.close();
  19684. }
  19685. /*:625*/
  19686. #line 13451 "./typica.w"
  19687. }
  19688. if(settings.value("database/exists","false").toString()=="false")
  19689. {
  19690. /*624:*/
  19691. #line 13568 "./typica.w"
  19692. SqlConnectionSetup dialog;
  19693. dialog.exec();
  19694. /*:624*/
  19695. #line 13455 "./typica.w"
  19696. }
  19697. /*:620*/
  19698. #line 13370 "./typica.w"
  19699. /*189:*/
  19700. #line 4335 "./typica.w"
  19701. QStringList arguments= QCoreApplication::arguments();
  19702. int position= arguments.indexOf("-c");
  19703. QString filename= QString();
  19704. if(position!=-1)
  19705. {
  19706. if(arguments.size()>=position+1)
  19707. {
  19708. filename= arguments.at(position+1);
  19709. }
  19710. }
  19711. if(filename.isEmpty())
  19712. {
  19713. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  19714. settings.value("config","").toString());
  19715. }
  19716. QDir directory;
  19717. if(!filename.isEmpty())
  19718. {
  19719. QFile file(filename);
  19720. QFileInfo info(filename);
  19721. directory= info.dir();
  19722. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  19723. QTranslator*configtr= new QTranslator;
  19724. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  19725. QString("%1/Translations").arg(directory.canonicalPath())))
  19726. {
  19727. QCoreApplication::installTranslator(configtr);
  19728. }
  19729. settings.setValue("config",directory.path());
  19730. if(file.open(QIODevice::ReadOnly))
  19731. {
  19732. app.configuration()->setContent(&file,true);
  19733. }
  19734. }
  19735. /*190:*/
  19736. #line 4376 "./typica.w"
  19737. QDomElement root= app.configuration()->documentElement();
  19738. QDomNodeList children= root.childNodes();
  19739. QString replacementDoc;
  19740. QDomDocument includedDoc;
  19741. QDomDocumentFragment fragment;
  19742. for(int i= 0;i<children.size();i++)
  19743. {
  19744. QDomNode currentNode= children.at(i);
  19745. QDomElement currentElement;
  19746. if(currentNode.nodeName()=="include")
  19747. {
  19748. currentElement= currentNode.toElement();
  19749. if(currentElement.hasAttribute("src"))
  19750. {
  19751. replacementDoc= directory.path();
  19752. replacementDoc.append('/');
  19753. replacementDoc.append(currentElement.attribute("src"));
  19754. QFile doc(replacementDoc);
  19755. if(doc.open(QIODevice::ReadOnly))
  19756. {
  19757. includedDoc.setContent(&doc,true);
  19758. fragment= includedDoc.createDocumentFragment();
  19759. fragment.appendChild(includedDoc.documentElement());
  19760. root.replaceChild(fragment,currentNode);
  19761. doc.close();
  19762. }
  19763. }
  19764. }
  19765. }
  19766. /*:190*/
  19767. #line 4370 "./typica.w"
  19768. /*:189*/
  19769. #line 13371 "./typica.w"
  19770. /*7:*/
  19771. #line 663 "./typica.w"
  19772. QScriptEngine*engine= new QScriptEngine;
  19773. QScriptValue constructor;
  19774. QScriptValue value;
  19775. /*:7*//*17:*/
  19776. #line 860 "./typica.w"
  19777. constructor= engine->newFunction(constructQWidget);
  19778. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  19779. engine->globalObject().setProperty("QWidget",value);
  19780. /*:17*//*21:*/
  19781. #line 947 "./typica.w"
  19782. constructor= engine->newFunction(displayWarning);
  19783. engine->globalObject().setProperty("displayWarning",constructor);
  19784. constructor= engine->newFunction(displayError);
  19785. engine->globalObject().setProperty("displayError",constructor);
  19786. /*:21*//*31:*/
  19787. #line 1153 "./typica.w"
  19788. constructor= engine->newFunction(constructQMainWindow);
  19789. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  19790. constructor);
  19791. engine->globalObject().setProperty("QMainWindow",value);
  19792. /*:31*//*42:*/
  19793. #line 1358 "./typica.w"
  19794. constructor= engine->newFunction(constructQFrame);
  19795. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  19796. engine->globalObject().setProperty("QFrame",value);
  19797. /*:42*//*45:*/
  19798. #line 1391 "./typica.w"
  19799. constructor= engine->newFunction(constructQLabel);
  19800. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  19801. engine->globalObject().setProperty("QLabel",value);
  19802. /*:45*//*48:*/
  19803. #line 1434 "./typica.w"
  19804. constructor= engine->newFunction(constructQSvgWidget);
  19805. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  19806. engine->globalObject().setProperty("QSvgWidget",value);
  19807. /*:48*//*54:*/
  19808. #line 1516 "./typica.w"
  19809. constructor= engine->newFunction(constructQLineEdit);
  19810. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  19811. engine->globalObject().setProperty("QLineEdit",value);
  19812. /*:54*//*58:*/
  19813. #line 1563 "./typica.w"
  19814. constructor= engine->newFunction(constructQSplitter);
  19815. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  19816. engine->globalObject().setProperty("QSplitter",value);
  19817. /*:58*//*66:*/
  19818. #line 1752 "./typica.w"
  19819. constructor= engine->newFunction(constructQBoxLayout);
  19820. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  19821. engine->globalObject().setProperty("QBoxLayout",value);
  19822. /*:66*//*70:*/
  19823. #line 1864 "./typica.w"
  19824. constructor= engine->newFunction(constructQAction);
  19825. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  19826. engine->globalObject().setProperty("QAction",value);
  19827. /*:70*//*73:*/
  19828. #line 1923 "./typica.w"
  19829. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  19830. value.setProperty("getOpenFileName",
  19831. engine->newFunction(QFileDialog_getOpenFileName));
  19832. value.setProperty("getSaveFileName",
  19833. engine->newFunction(QFileDialog_getSaveFileName));
  19834. engine->globalObject().setProperty("QFileDialog",value);
  19835. /*:73*//*78:*/
  19836. #line 2041 "./typica.w"
  19837. constructor= engine->newFunction(constructQFile);
  19838. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  19839. engine->globalObject().setProperty("QFile",value);
  19840. /*:78*//*89:*/
  19841. #line 2259 "./typica.w"
  19842. constructor= engine->newFunction(constructQProcess);
  19843. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  19844. engine->globalObject().setProperty("QProcess",value);
  19845. /*:89*//*98:*/
  19846. #line 2408 "./typica.w"
  19847. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  19848. constructor= engine->newFunction(constructQByteArray);
  19849. engine->globalObject().setProperty("QByteArray",constructor);
  19850. /*:98*//*110:*/
  19851. #line 2650 "./typica.w"
  19852. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  19853. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  19854. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  19855. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  19856. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  19857. /*:110*//*113:*/
  19858. #line 2753 "./typica.w"
  19859. constructor= engine->newFunction(constructQBuffer);
  19860. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  19861. engine->globalObject().setProperty("QBuffer",value);
  19862. /*:113*//*116:*/
  19863. #line 2802 "./typica.w"
  19864. constructor= engine->newFunction(constructXQuery);
  19865. engine->globalObject().setProperty("XQuery",constructor);
  19866. /*:116*//*122:*/
  19867. #line 2904 "./typica.w"
  19868. constructor= engine->newFunction(constructXmlWriter);
  19869. engine->globalObject().setProperty("XmlWriter",constructor);
  19870. /*:122*//*131:*/
  19871. #line 3110 "./typica.w"
  19872. constructor= engine->newFunction(constructXmlReader);
  19873. engine->globalObject().setProperty("XmlReader",constructor);
  19874. /*:131*//*138:*/
  19875. #line 3234 "./typica.w"
  19876. value= engine->newQObject(&settings);
  19877. setQSettingsProperties(value,engine);
  19878. engine->globalObject().setProperty("QSettings",value);
  19879. /*:138*//*142:*/
  19880. #line 3315 "./typica.w"
  19881. constructor= engine->newFunction(constructQLCDNumber);
  19882. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  19883. engine->globalObject().setProperty("QLCDNumber",value);
  19884. /*:142*//*145:*/
  19885. #line 3371 "./typica.w"
  19886. constructor= engine->newFunction(constructQTime);
  19887. engine->globalObject().setProperty("QTime",constructor);
  19888. /*:145*//*167:*/
  19889. #line 3884 "./typica.w"
  19890. constructor= engine->newFunction(constructQPushButton);
  19891. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  19892. engine->globalObject().setProperty("QPushButton",value);
  19893. /*:167*//*174:*/
  19894. #line 3995 "./typica.w"
  19895. constructor= engine->newFunction(constructQSqlQuery);
  19896. engine->globalObject().setProperty("QSqlQuery",constructor);
  19897. /*:174*//*181:*/
  19898. #line 4159 "./typica.w"
  19899. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  19900. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  19901. engine->globalObject().setProperty("sqlToArray",
  19902. engine->newFunction(sqlToArray));
  19903. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  19904. engine->globalObject().setProperty("annotationFromRecord",
  19905. engine->newFunction(annotationFromRecord));
  19906. engine->globalObject().setProperty("setTabOrder",
  19907. engine->newFunction(setTabOrder));
  19908. engine->globalObject().setProperty("saveFileFromDatabase",
  19909. engine->newFunction(saveFileFromDatabase));
  19910. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  19911. /*:181*//*194:*/
  19912. #line 4543 "./typica.w"
  19913. engine->globalObject().setProperty("createWindow",
  19914. engine->newFunction(createWindow));
  19915. engine->globalObject().setProperty("createReport",
  19916. engine->newFunction(createReport));
  19917. /*:194*//*259:*/
  19918. #line 6181 "./typica.w"
  19919. engine->globalObject().setProperty("findChildObject",
  19920. engine->newFunction(findChildObject));
  19921. /*:259*//*285:*/
  19922. #line 389 "./units.w"
  19923. value= engine->newQMetaObject(&Units::staticMetaObject);
  19924. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  19925. value.setProperty("convertRelativeTemperature",
  19926. engine->newFunction(Units_convertRelativeTemperature));
  19927. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  19928. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  19929. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  19930. engine->globalObject().setProperty("Units",value);
  19931. /*:285*//*290:*/
  19932. #line 462 "./units.w"
  19933. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  19934. #line 6605 "./typica.w"
  19935. /*:290*//*298:*/
  19936. #line 141 "./measurement.w"
  19937. constructor= engine->newFunction(constructMeasurement);
  19938. engine->globalObject().setProperty("Measurement",constructor);
  19939. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  19940. /*:298*//*318:*/
  19941. #line 7176 "./typica.w"
  19942. constructor= engine->newFunction(constructDAQ);
  19943. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  19944. value.setProperty("Fahrenheit",Units::Fahrenheit);
  19945. value.setProperty("Celsius",Units::Celsius);
  19946. value.setProperty("Kelvin",Units::Kelvin);
  19947. value.setProperty("Rankine",Units::Rankine);
  19948. engine->globalObject().setProperty("DAQ",value);
  19949. /*:318*//*327:*/
  19950. #line 7378 "./typica.w"
  19951. constructor= engine->newFunction(constructFakeDAQ);
  19952. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  19953. engine->globalObject().setProperty("FakeDAQ",value);
  19954. /*:327*//*338:*/
  19955. #line 7661 "./typica.w"
  19956. constructor= engine->newFunction(constructLinearCalibrator);
  19957. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  19958. constructor);
  19959. engine->globalObject().setProperty("LinearCalibrator",value);
  19960. /*:338*//*343:*/
  19961. #line 7800 "./typica.w"
  19962. constructor= engine->newFunction(constructLinearSplineInterpolator);
  19963. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  19964. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  19965. /*:343*//*353:*/
  19966. #line 8008 "./typica.w"
  19967. constructor= engine->newFunction(constructTemperatureDisplay);
  19968. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  19969. constructor);
  19970. engine->globalObject().setProperty("TemperatureDisplay",value);
  19971. /*:353*//*361:*/
  19972. #line 8166 "./typica.w"
  19973. constructor= engine->newFunction(constructMeasurementTimeOffset);
  19974. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  19975. constructor);
  19976. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  19977. /*:361*//*366:*/
  19978. #line 8277 "./typica.w"
  19979. constructor= engine->newFunction(constructThresholdDetector);
  19980. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  19981. engine->globalObject().setProperty("ThresholdDetector",value);
  19982. /*:366*//*371:*/
  19983. #line 8376 "./typica.w"
  19984. constructor= engine->newFunction(constructZeroEmitter);
  19985. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  19986. engine->globalObject().setProperty("ZeroEmitter",value);
  19987. /*:371*//*376:*/
  19988. #line 8455 "./typica.w"
  19989. constructor= engine->newFunction(constructMeasurementAdapter);
  19990. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  19991. constructor);
  19992. engine->globalObject().setProperty("MeasurementAdapter",value);
  19993. /*:376*//*393:*/
  19994. #line 8918 "./typica.w"
  19995. constructor= engine->newFunction(constructGraphView);
  19996. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  19997. engine->globalObject().setProperty("GraphView",value);
  19998. /*:393*//*416:*/
  19999. #line 9555 "./typica.w"
  20000. constructor= engine->newFunction(constructZoomLog);
  20001. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  20002. engine->globalObject().setProperty("ZoomLog",value);
  20003. /*:416*//*454:*/
  20004. #line 10503 "./typica.w"
  20005. constructor= engine->newFunction(constructAnnotationButton);
  20006. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  20007. constructor);
  20008. engine->globalObject().setProperty("AnnotationButton",value);
  20009. /*:454*//*462:*/
  20010. #line 10645 "./typica.w"
  20011. constructor= engine->newFunction(constructAnnotationSpinBox);
  20012. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  20013. constructor);
  20014. engine->globalObject().setProperty("AnnotationSpinBox",value);
  20015. /*:462*//*483:*/
  20016. #line 11070 "./typica.w"
  20017. constructor= engine->newFunction(constructTimerDisplay);
  20018. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  20019. engine->globalObject().setProperty("TimerDisplay",value);
  20020. /*:483*//*511:*/
  20021. #line 11594 "./typica.w"
  20022. constructor= engine->newFunction(constructWidgetDecorator);
  20023. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  20024. engine->globalObject().setProperty("WidgetDecorator",value);
  20025. /*:511*//*524:*/
  20026. #line 11876 "./typica.w"
  20027. constructor= engine->newFunction(constructLogEditWindow);
  20028. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  20029. engine->globalObject().setProperty("LogEditWindow",value);
  20030. /*:524*//*543:*/
  20031. #line 12403 "./typica.w"
  20032. constructor= engine->newFunction(constructXMLInput);
  20033. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  20034. engine->globalObject().setProperty("XMLInput",value);
  20035. /*:543*//*557:*/
  20036. #line 149 "./webview.w"
  20037. constructor= engine->newFunction(constructWebView);
  20038. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  20039. engine->globalObject().setProperty("WebView",value);
  20040. /*:557*//*565:*/
  20041. #line 241 "./webview.w"
  20042. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  20043. /*:565*//*568:*/
  20044. #line 283 "./webview.w"
  20045. constructor= engine->newFunction(constructWebElement);
  20046. engine->globalObject().setProperty("WebElement",constructor);
  20047. /*:568*//*579:*/
  20048. #line 12646 "./typica.w"
  20049. value= engine->newQObject(AppInstance);
  20050. engine->globalObject().setProperty("Application",value);
  20051. /*:579*//*637:*/
  20052. #line 13755 "./typica.w"
  20053. constructor= engine->newFunction(constructSqlQueryView);
  20054. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  20055. engine->globalObject().setProperty("SqlQueryView",value);
  20056. /*:637*//*742:*/
  20057. #line 15659 "./typica.w"
  20058. constructor= engine->newFunction(constructDeviceTreeModel);
  20059. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  20060. constructor);
  20061. engine->globalObject().setProperty("DeviceTreeModel",value);
  20062. /*:742*//*748:*/
  20063. #line 15799 "./typica.w"
  20064. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  20065. /*:748*//*764:*/
  20066. #line 16091 "./typica.w"
  20067. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  20068. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  20069. constructor);
  20070. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  20071. /*:764*//*835:*/
  20072. #line 56 "./settings.w"
  20073. constructor= engine->newFunction(constructSettingsWindow);
  20074. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  20075. engine->globalObject().setProperty("SettingsWindow",value);
  20076. #line 1 "./graphsettings.w"
  20077. /*:835*//*858:*/
  20078. #line 18726 "./typica.w"
  20079. constructor= engine->newFunction(constructModbusRTUDevice);
  20080. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  20081. engine->globalObject().setProperty("ModbusRTUDevice",value);
  20082. /*:858*//*876:*/
  20083. #line 645 "./modbus.w"
  20084. constructor= engine->newFunction(constructModbusNG);
  20085. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  20086. engine->globalObject().setProperty("ModbusNG",value);
  20087. /*:876*//*890:*/
  20088. #line 350 "./unsupportedserial.w"
  20089. engine->globalObject().setProperty("createDevice",
  20090. engine->newFunction(createDevice));
  20091. /*:890*//*902:*/
  20092. #line 622 "./unsupportedserial.w"
  20093. engine->globalObject().setProperty("getMeasurementTimestamp",
  20094. engine->newFunction(getMeasurementTimestamp));
  20095. /*:902*//*906:*/
  20096. #line 658 "./unsupportedserial.w"
  20097. constructor= engine->newFunction(constructSerialPort);
  20098. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  20099. engine->globalObject().setProperty("SerialPort",value);
  20100. /*:906*//*911:*/
  20101. #line 713 "./unsupportedserial.w"
  20102. constructor= engine->newFunction(constructQTimer);
  20103. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  20104. engine->globalObject().setProperty("Timer",value);
  20105. /*:911*//*931:*/
  20106. #line 450 "./phidgets.w"
  20107. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  20108. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  20109. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  20110. /*:931*//*965:*/
  20111. #line 144 "./rate.w"
  20112. constructor= engine->newFunction(constructRateOfChange);
  20113. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  20114. engine->globalObject().setProperty("RateOfChange",value);
  20115. /*:965*//*990:*/
  20116. #line 604 "./dataqsdk.w"
  20117. constructor= engine->newFunction(constructDataqSdkDevice);
  20118. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  20119. engine->globalObject().setProperty("DataqSdkDevice",value);
  20120. /*:990*//*1017:*/
  20121. #line 73 "./scales.w"
  20122. constructor= engine->newFunction(constructDragLabel);
  20123. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  20124. engine->globalObject().setProperty("DragLabel",value);
  20125. /*:1017*//*1025:*/
  20126. #line 265 "./scales.w"
  20127. constructor= engine->newFunction(constructSerialScale);
  20128. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  20129. engine->globalObject().setProperty("SerialScale",value);
  20130. /*:1025*//*1029:*/
  20131. #line 351 "./scales.w"
  20132. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  20133. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  20134. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  20135. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  20136. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  20137. /*:1029*//*1053:*/
  20138. #line 271 "./valueannotation.w"
  20139. constructor= engine->newFunction(constructValueAnnotation);
  20140. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  20141. engine->globalObject().setProperty("ValueAnnotation",value);
  20142. /*:1053*//*1066:*/
  20143. #line 216 "./thresholdannotation.w"
  20144. constructor= engine->newFunction(constructAnnotator);
  20145. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  20146. engine->globalObject().setProperty("Annotator",value);
  20147. /*:1066*/
  20148. #line 13372 "./typica.w"
  20149. app.engine= engine;
  20150. /*191:*/
  20151. #line 4424 "./typica.w"
  20152. QString styleText;
  20153. QString programText;
  20154. QDomElement currentElement;
  20155. for(int i= 0;i<children.size();i++)
  20156. {
  20157. QDomNode currentNode= children.at(i);
  20158. if(currentNode.nodeName()=="style")
  20159. {
  20160. currentElement= currentNode.toElement();
  20161. styleText.append(currentElement.text());
  20162. }
  20163. else if(currentNode.nodeName()=="program")
  20164. {
  20165. currentElement= currentNode.toElement();
  20166. programText.append(currentElement.text());
  20167. }
  20168. }
  20169. app.setStyleSheet(styleText);
  20170. QScriptValue result= engine->evaluate(programText);
  20171. /*192:*/
  20172. #line 4449 "./typica.w"
  20173. if(engine->hasUncaughtException())
  20174. {
  20175. int line= engine->uncaughtExceptionLineNumber();
  20176. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  20177. result.toString();
  20178. QString trace;
  20179. foreach(trace,engine->uncaughtExceptionBacktrace())
  20180. {
  20181. qDebug()<<trace;
  20182. }
  20183. }
  20184. /*:192*/
  20185. #line 4444 "./typica.w"
  20186. /*:191*/
  20187. #line 13374 "./typica.w"
  20188. int retval= app.exec();
  20189. delete engine;
  20190. return retval;
  20191. }
  20192. /*:614*/
  20193. #line 532 "./typica.w"
  20194. #include "moc_typica.cpp"
  20195. /*:3*/