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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247
  1. /*3:*/
  2. #line 522 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*5:*/
  5. #line 622 "./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 638 "./typica.w"
  18. #include "helpmenu.h"
  19. /*:6*//*304:*/
  20. #line 6864 "./typica.w"
  21. #include "units.h"
  22. #line 1 "./measurement.w"
  23. /*:304*//*575:*/
  24. #line 212 "./webview.w"
  25. #include "webview.h"
  26. /*:575*//*588:*/
  27. #line 390 "./webview.w"
  28. #include "webelement.h"
  29. #line 12852 "./typica.w"
  30. #line 1 "./printerselector.w"
  31. /*:588*//*590:*/
  32. #line 40 "./printerselector.w"
  33. #include "printerselector.h"
  34. /*:590*//*715:*/
  35. #line 487 "./daterangeselector.w"
  36. #include "daterangeselector.h"
  37. #line 14614 "./typica.w"
  38. /*:715*//*823:*/
  39. #line 17185 "./typica.w"
  40. #include "qextserialport.h"
  41. #include "qextserialenumerator.h"
  42. /*:823*//*1049:*/
  43. #line 124 "./dataqsdk.w"
  44. #ifdef Q_OS_WIN32
  45. #include <windef.h>
  46. #else
  47. #define PASCAL
  48. #endif
  49. /*:1049*//*1073:*/
  50. #line 862 "./dataqsdk.w"
  51. #include <limits>
  52. /*:1073*//*1088:*/
  53. #line 62 "./scales.w"
  54. #include "draglabel.h"
  55. /*:1088*//*1103:*/
  56. #line 361 "./scales.w"
  57. #include "scale.h"
  58. /*:1103*/
  59. #line 525 "./typica.w"
  60. /*967:*/
  61. #line 114 "./phidget22.w"
  62. #if defined(__stdcall)
  63. #define CCONV __stdcall
  64. #else
  65. #if defined(_MSC_VER)
  66. #define CCONV __stdcall
  67. #else
  68. #define CCONV
  69. #endif
  70. #endif
  71. typedef int(CCONV*PhidgetPointer)(void*);
  72. typedef int(CCONV*PhidgetPointerStringOut)(void*,char**);
  73. typedef int(CCONV*PhidgetPointerIntOut)(void*,int*);
  74. typedef void(CCONV*PhidgetManagerCallback)(void*,void*,void*);
  75. typedef void(CCONV*PhidgetValueCallback)(void*,void*,double);
  76. typedef int(CCONV*PhidgetPointerCallbackPointer)(void*,
  77. PhidgetManagerCallback,
  78. void*);
  79. typedef int(CCONV*PhidgetPointerVCPointer)(void*,
  80. PhidgetValueCallback,
  81. void*);
  82. typedef int(CCONV*PhidgetPointerIntIn)(void*,int);
  83. /*:967*/
  84. #line 526 "./typica.w"
  85. /*972:*/
  86. #line 220 "./phidget22.w"
  87. void CCONV ChannelListAddChannel(void*manager,void*context,void*device);
  88. void CCONV ChannelListRemoveChannel(void*manager,void*context,
  89. void*device);
  90. /*:972*//*987:*/
  91. #line 773 "./phidget22.w"
  92. void CCONV Phidget22ValueCallback(void*device,void*context,double value);
  93. /*:987*/
  94. #line 527 "./typica.w"
  95. /*26:*/
  96. #line 1059 "./typica.w"
  97. class ScriptQMainWindow:public QMainWindow
  98. {
  99. Q_OBJECT
  100. Q_PROPERTY(QString closePrompt READ closePrompt WRITE setClosePrompt)
  101. public:
  102. ScriptQMainWindow();
  103. QString closePrompt();
  104. public slots:
  105. void show();
  106. void saveSizeAndPosition(const QString&key);
  107. void restoreSizeAndPosition(const QString&key);
  108. void displayStatus(const QString&message= QString());
  109. void setClosePrompt(QString prompt);
  110. void setupFinished();
  111. signals:
  112. void aboutToClose(void);
  113. void windowReady(void);
  114. protected:
  115. void closeEvent(QCloseEvent*event);
  116. void showEvent(QShowEvent*event);
  117. private:
  118. QString cprompt;
  119. };
  120. /*:26*//*173:*/
  121. #line 4019 "./typica.w"
  122. class SqlQueryConnection:public QSqlQuery
  123. {
  124. public:
  125. SqlQueryConnection(const QString&query= QString());
  126. ~SqlQueryConnection();
  127. QSqlQuery*operator->()const;
  128. private:
  129. QString connection;
  130. QSqlQuery*q;
  131. };
  132. /*:173*//*250:*/
  133. #line 6021 "./typica.w"
  134. class NumericDelegate:public QItemDelegate
  135. {
  136. Q_OBJECT
  137. public:
  138. NumericDelegate(QObject*parent= NULL);
  139. QWidget*createEditor(QWidget*parent,
  140. const QStyleOptionViewItem&option,
  141. const QModelIndex&index)const;
  142. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  143. void setModelData(QWidget*editor,QAbstractItemModel*model,
  144. const QModelIndex&index)const;
  145. void updateEditorGeometry(QWidget*editor,
  146. const QStyleOptionViewItem&option,
  147. const QModelIndex&index)const;
  148. };
  149. /*:250*//*256:*/
  150. #line 6114 "./typica.w"
  151. class ScriptValidator:public QValidator
  152. {
  153. Q_OBJECT
  154. public:
  155. ScriptValidator(QValidator*validator,QObject*parent= NULL);
  156. void fixup(QString&input)const;
  157. QValidator::State validate(QString&input,int&pos)const;
  158. private:
  159. QValidator*v;
  160. };
  161. /*:256*//*300:*/
  162. #line 438 "./units.w"
  163. Q_DECLARE_METATYPE(Units::Unit)
  164. /*:300*//*305:*/
  165. #line 19 "./measurement.w"
  166. class Measurement:public QVariantMap
  167. {
  168. public:
  169. Measurement(double temperature= 0,QTime time= QTime(),
  170. Units::Unit sc= Units::Fahrenheit);
  171. Measurement(double temperature);
  172. double temperature()const;
  173. QTime time()const;
  174. void setTemperature(double temperature);
  175. void setTime(QTime time);
  176. void setUnit(Units::Unit scale);
  177. Units::Unit scale()const;
  178. Measurement toFahrenheit();
  179. Measurement toCelsius();
  180. Measurement toKelvin();
  181. Measurement toRankine();
  182. };
  183. /*:305*//*309:*/
  184. #line 128 "./measurement.w"
  185. Q_DECLARE_METATYPE(Measurement)
  186. /*:309*//*316:*/
  187. #line 6928 "./typica.w"
  188. class Channel;
  189. class DAQImplementation;
  190. class DAQ:public QObject
  191. {
  192. Q_OBJECT
  193. Q_ENUMS(ThermocoupleType)
  194. DAQImplementation*imp;
  195. private slots:
  196. void threadFinished();
  197. public:
  198. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  199. ~DAQ();
  200. Channel*newChannel(int units,int thermocouple);
  201. Q_INVOKABLE void setClockRate(double Hz);
  202. Q_INVOKABLE void start();
  203. Q_INVOKABLE void stop();
  204. enum ThermocoupleType
  205. {
  206. TypeJ= 10072,
  207. TypeK= 10073,
  208. TypeN= 10077,
  209. TypeR= 10082,
  210. TypeS= 10085,
  211. TypeT= 10086,
  212. TypeB= 10047,
  213. TypeE= 10055
  214. };
  215. };
  216. /*:316*//*317:*/
  217. #line 6966 "./typica.w"
  218. class DAQImplementation:public QThread
  219. {
  220. Q_OBJECT
  221. public:
  222. DAQImplementation(const QString&driverinfo);
  223. ~DAQImplementation();
  224. void run();
  225. void measure();
  226. /*318:*/
  227. #line 6986 "./typica.w"
  228. typedef int(*daqfp)(...);
  229. daqfp read;
  230. daqfp errorInfo;
  231. daqfp startTask;
  232. daqfp createTask;
  233. daqfp createChannel;
  234. daqfp setClock;
  235. daqfp stopTask;
  236. daqfp clearTask;
  237. daqfp resetDevice;
  238. daqfp waitForMeasurement;
  239. /*:318*/
  240. #line 6975 "./typica.w"
  241. /*319:*/
  242. #line 7002 "./typica.w"
  243. bool useBase;
  244. QString device;
  245. QVector<Channel*> channelMap;
  246. unsigned int handle;
  247. int error;
  248. int channels;
  249. bool ready;
  250. QLibrary driver;
  251. QVector<Units::Unit> unitMap;
  252. /*:319*/
  253. #line 6976 "./typica.w"
  254. };
  255. /*:317*//*335:*/
  256. #line 7507 "./typica.w"
  257. class FakeDAQImplementation:public QThread
  258. {
  259. Q_OBJECT
  260. public:
  261. FakeDAQImplementation();
  262. ~FakeDAQImplementation();
  263. void run();
  264. void measure();
  265. QVector<Channel*> channelMap;
  266. int channels;
  267. bool ready;
  268. double clockRate;
  269. };
  270. class FakeDAQ:public QObject
  271. {
  272. Q_OBJECT
  273. FakeDAQImplementation*imp;
  274. public:
  275. FakeDAQ(QString device);
  276. ~FakeDAQ();
  277. Channel*newChannel(int units,int thermocouple);
  278. Q_INVOKABLE void setClockRate(double Hz);
  279. Q_INVOKABLE void start();
  280. };
  281. /*:335*//*342:*/
  282. #line 7694 "./typica.w"
  283. class Channel:public QObject
  284. {
  285. Q_OBJECT
  286. public:
  287. Channel();
  288. ~Channel();
  289. public slots:
  290. void input(Measurement measurement);
  291. signals:
  292. void newData(Measurement);
  293. };
  294. /*:342*//*346:*/
  295. #line 7761 "./typica.w"
  296. class LinearCalibrator:public QObject
  297. {
  298. Q_OBJECT
  299. Q_PROPERTY(double measuredLower READ measuredLower
  300. WRITE setMeasuredLower)
  301. Q_PROPERTY(double measuredUpper READ measuredUpper
  302. WRITE setMeasuredUpper)
  303. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  304. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  305. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  306. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  307. public:
  308. LinearCalibrator(QObject*parent= NULL);
  309. double measuredLower();
  310. double measuredUpper();
  311. double mappedLower();
  312. double mappedUpper();
  313. bool isClosedRange();
  314. double sensitivity();
  315. public slots:
  316. void setMeasuredLower(double lower);
  317. void setMeasuredUpper(double upper);
  318. void setMappedLower(double lower);
  319. void setMappedUpper(double upper);
  320. void setClosedRange(bool closed);
  321. void setSensitivity(double sensitivity);
  322. Measurement newMeasurement(Measurement measure);
  323. signals:
  324. void measurement(Measurement measure);
  325. void newData(Measurement measure);
  326. private:
  327. double Lo1;
  328. double Lo2;
  329. double Up1;
  330. double Up2;
  331. double sensitivitySetting;
  332. bool clamp;
  333. };
  334. /*:346*//*353:*/
  335. #line 7957 "./typica.w"
  336. class LinearSplineInterpolator:public QObject
  337. {
  338. Q_OBJECT
  339. public:
  340. LinearSplineInterpolator(QObject*parent= NULL);
  341. Q_INVOKABLE void add_pair(double source,double destination);
  342. public slots:
  343. Measurement newMeasurement(Measurement measure);
  344. signals:
  345. void newData(Measurement measure);
  346. private:
  347. void make_interpolators();
  348. QMap<double,double> *pairs;
  349. QList<LinearCalibrator*> *interpolators;
  350. };
  351. /*:353*//*358:*/
  352. #line 8093 "./typica.w"
  353. class TemperatureDisplay:public QLCDNumber
  354. {
  355. Q_OBJECT
  356. int unit;
  357. bool r;
  358. public:
  359. TemperatureDisplay(QWidget*parent= NULL);
  360. ~TemperatureDisplay();
  361. public slots:
  362. void setValue(Measurement temperature);
  363. void invalidate();
  364. void setDisplayUnits(Units::Unit scale);
  365. void setRelativeMode(bool relative);
  366. };
  367. /*:358*//*369:*/
  368. #line 8312 "./typica.w"
  369. class MeasurementTimeOffset:public QObject
  370. {
  371. Q_OBJECT
  372. QTime epoch;
  373. QTime previous;
  374. bool hasPrevious;
  375. public:
  376. MeasurementTimeOffset(QTime zero);
  377. QTime zeroTime();
  378. public slots:
  379. void newMeasurement(Measurement measure);
  380. void setZeroTime(QTime zero);
  381. signals:
  382. void measurement(Measurement measure);
  383. };
  384. /*:369*//*376:*/
  385. #line 8464 "./typica.w"
  386. class ThresholdDetector:public QObject
  387. {
  388. Q_OBJECT
  389. Q_ENUMS(EdgeDirection)
  390. public:
  391. enum EdgeDirection{
  392. Ascending,Descending
  393. };
  394. ThresholdDetector(double value);
  395. public slots:
  396. void newMeasurement(Measurement measure);
  397. void setThreshold(double value);
  398. void setEdgeDirection(EdgeDirection direction);
  399. signals:
  400. void timeForValue(double);
  401. private:
  402. bool previousValueValid;
  403. double previousValue;
  404. double threshold;
  405. EdgeDirection currentDirection;
  406. };
  407. /*:376*//*381:*/
  408. #line 8580 "./typica.w"
  409. class ZeroEmitter:public QObject
  410. {
  411. Q_OBJECT
  412. Q_PROPERTY(int column READ column WRITE setColumn)
  413. Measurement cache;
  414. int col;
  415. public:
  416. ZeroEmitter(int tempcolumn= 1);
  417. int column();
  418. double lastTemperature();
  419. public slots:
  420. void newMeasurement(Measurement measure);
  421. void setColumn(int column);
  422. void emitZero();
  423. signals:
  424. void measurement(Measurement measure,int tempcolumn);
  425. };
  426. /*:381*//*386:*/
  427. #line 8674 "./typica.w"
  428. class MeasurementAdapter:public QObject
  429. {
  430. Q_OBJECT
  431. int col;
  432. public:
  433. MeasurementAdapter(int tempcolumn);
  434. int column();
  435. public slots:
  436. void newMeasurement(Measurement measure);
  437. void setColumn(int column);
  438. signals:
  439. void measurement(Measurement measure,int tempcolumn);
  440. };
  441. /*:386*//*391:*/
  442. #line 8763 "./typica.w"
  443. class GraphView:public QGraphicsView
  444. {
  445. Q_OBJECT
  446. QGraphicsScene*theScene;
  447. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  448. QMap<int,QPointF> *prevPoints;
  449. QMap<int,double> *translations;
  450. QList<QGraphicsItem*> *gridLinesF;
  451. QList<QGraphicsItem*> *gridLinesC;
  452. QList<QGraphicsItem*> *relativeGridLines;
  453. bool relativeEnabled;
  454. bool timeIndicatorEnabled;
  455. QGraphicsLineItem*timeLine;
  456. LinearSplineInterpolator*relativeAdjuster;
  457. public:
  458. GraphView(QWidget*parent= NULL);
  459. void removeSeries(int column);
  460. protected:
  461. void resizeEvent(QResizeEvent*event);
  462. public slots:
  463. void newMeasurement(Measurement measure,int tempcolumn);
  464. void setSeriesTranslation(int column,double offset);
  465. void setTimeIndicatorEnabled(bool enabled);
  466. void clear();
  467. void showF();
  468. void showC();
  469. };
  470. /*:391*//*408:*/
  471. #line 9231 "./typica.w"
  472. class MeasurementModel;
  473. class ZoomLog:public QTableView
  474. {
  475. Q_OBJECT
  476. /*409:*/
  477. #line 9280 "./typica.w"
  478. MeasurementModel*model_ms;
  479. MeasurementModel*model_1s;
  480. MeasurementModel*model_5s;
  481. MeasurementModel*model_10s;
  482. MeasurementModel*model_15s;
  483. MeasurementModel*model_30s;
  484. MeasurementModel*model_1m;
  485. QList<MeasurementModel*> modelSet;
  486. QHash<int,Measurement> lastMeasurement;
  487. MeasurementModel*currentModel;
  488. QList<int> saveTempCols;
  489. QList<int> saveControlCols;
  490. QList<int> saveNoteCols;
  491. QList<int> currentColumnSet;
  492. /*:409*/
  493. #line 9236 "./typica.w"
  494. void switchLOD(MeasurementModel*m);
  495. private slots:
  496. void centerOn(int row);
  497. void persistColumnResize(int column,int oldsize,int newsize);
  498. void restoreColumnWidths();
  499. public:
  500. ZoomLog();
  501. QVariant data(int row,int column)const;
  502. Q_INVOKABLE int rowCount();
  503. bool saveXML(QIODevice*device);
  504. bool saveCSV(QIODevice*device);
  505. QString lastTime(int series);
  506. Q_INVOKABLE Units::Unit displayUnits();
  507. public slots:
  508. void setVisible(bool visibility);
  509. void setHeaderData(int section,QString text);
  510. void LOD_ms();
  511. void LOD_1s();
  512. void LOD_5s();
  513. void LOD_10s();
  514. void LOD_15s();
  515. void LOD_30s();
  516. void LOD_1m();
  517. void newMeasurement(Measurement measure,int tempcolumn);
  518. void newAnnotation(QString annotation,int tempcolumn,
  519. int annotationcolumn);
  520. void clear();
  521. void addOutputTemperatureColumn(int column);
  522. void addOutputControlColumn(int column);
  523. void addOutputAnnotationColumn(int column);
  524. void clearOutputColumns();
  525. void setDisplayUnits(Units::Unit scale);
  526. void addToCurrentColumnSet(int column);
  527. void clearCurrentColumnSet();
  528. protected:
  529. virtual void showEvent(QShowEvent*event);
  530. };
  531. /*:408*//*434:*/
  532. #line 9985 "./typica.w"
  533. class MeasurementList;
  534. class MeasurementModel:public QAbstractItemModel
  535. {
  536. Q_OBJECT
  537. Units::Unit unit;
  538. QList<MeasurementList*> *entries;
  539. QStringList*hData;
  540. int colcount;
  541. QHash<int,int> *lastTemperature;
  542. QList<MeasurementList*> ::iterator lastInsertion;
  543. QHash<int,bool> *controlColumns;
  544. public:
  545. MeasurementModel(QObject*parent= NULL);
  546. ~MeasurementModel();
  547. int rowCount(const QModelIndex&parent= QModelIndex())const;
  548. int columnCount(const QModelIndex&parent= QModelIndex())const;
  549. bool setHeaderData(int section,Qt::Orientation orientation,
  550. const QVariant&value,int role= Qt::DisplayRole);
  551. QVariant data(const QModelIndex&index,int role)const;
  552. bool setData(const QModelIndex&index,const QVariant&value,
  553. int role= Qt::EditRole);
  554. Qt::ItemFlags flags(const QModelIndex&index)const;
  555. QVariant headerData(int section,Qt::Orientation orientation,
  556. int role= Qt::DisplayRole)const;
  557. QModelIndex index(int row,int column,
  558. const QModelIndex&parent= QModelIndex())const;
  559. QModelIndex parent(const QModelIndex&index)const;
  560. Units::Unit displayUnits();
  561. public slots:
  562. void newMeasurement(Measurement measure,int tempcolumn);
  563. void newAnnotation(QString annotation,int tempcolumn,
  564. int annotationColumn);
  565. void clear();
  566. void setDisplayUnits(Units::Unit scale);
  567. signals:
  568. void rowChanged(int);
  569. };
  570. /*:434*//*435:*/
  571. #line 10029 "./typica.w"
  572. class MeasurementList:public QVariantList
  573. {
  574. public:
  575. bool operator<(const MeasurementList&other)const;
  576. bool operator==(const MeasurementList&other)const;
  577. };
  578. /*:435*//*461:*/
  579. #line 10687 "./typica.w"
  580. class AnnotationButton:public QPushButton
  581. {
  582. Q_OBJECT
  583. QString note;
  584. int tc;
  585. int ac;
  586. int count;
  587. public:
  588. AnnotationButton(const QString&text,QWidget*parent= NULL);
  589. public slots:
  590. void setAnnotation(const QString&annotation);
  591. void setTemperatureColumn(int tempcolumn);
  592. void setAnnotationColumn(int annotationcolumn);
  593. void annotate();
  594. void resetCount();
  595. signals:
  596. void annotation(QString annotation,int tempcolumn,
  597. int notecolumn);
  598. };
  599. /*:461*//*469:*/
  600. #line 10812 "./typica.w"
  601. class AnnotationSpinBox:public QDoubleSpinBox
  602. {
  603. Q_OBJECT
  604. QString pretext;
  605. QString posttext;
  606. int tc;
  607. int ac;
  608. bool change;
  609. public:
  610. AnnotationSpinBox(const QString&pret,const QString&postt,
  611. QWidget*parent= NULL);
  612. public slots:
  613. void setPretext(const QString&pret);
  614. void setPosttext(const QString&postt);
  615. void setTemperatureColumn(int tempcolumn);
  616. void setAnnotationColumn(int annotationcolumn);
  617. void annotate();
  618. void resetChange();
  619. signals:
  620. void annotation(QString annotation,int tempcolumn,
  621. int notecolumn);
  622. };
  623. /*:469*//*477:*/
  624. #line 10971 "./typica.w"
  625. class TimerDisplay:public QLCDNumber
  626. {
  627. Q_OBJECT
  628. /*478:*/
  629. #line 11021 "./typica.w"
  630. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  631. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  632. Q_PROPERTY(bool running READ isRunning)
  633. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  634. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  635. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  636. Q_PROPERTY(QString value READ value)
  637. /*:478*/
  638. #line 10975 "./typica.w"
  639. private slots:
  640. void updateTime();
  641. void setCountUpMode();
  642. void setCountDownMode();
  643. void setClockMode();
  644. public:
  645. TimerDisplay(QWidget*parent= NULL);
  646. ~TimerDisplay();
  647. enum TimerMode
  648. {
  649. CountUp,
  650. CountDown,
  651. Clock
  652. };
  653. QString value();
  654. QTime seconds();
  655. TimerMode mode();
  656. bool isRunning();
  657. QTime resetValue();
  658. QString displayFormat();
  659. bool autoReset();
  660. public slots:
  661. void setTimer(QTime value= QTime(0,0,0));
  662. void setMode(TimerMode mode);
  663. void startTimer();
  664. void stopTimer();
  665. void copyTimer();
  666. void setResetValue(QTime value= QTime(0,0,0));
  667. void reset();
  668. void setDisplayFormat(QString format);
  669. void setAutoReset(bool reset);
  670. void updateDisplay();
  671. signals:
  672. void valueChanged(QTime);
  673. void runStateChanged(bool);
  674. private:
  675. /*479:*/
  676. #line 11032 "./typica.w"
  677. QTime s;
  678. QTime r;
  679. QTimer clock;
  680. TimerDisplay::TimerMode m;
  681. bool running;
  682. bool ar;
  683. QAction*startAction;
  684. QAction*stopAction;
  685. QAction*resetAction;
  686. QString f;
  687. QTime relative;
  688. QTime base;
  689. /*:479*/
  690. #line 11012 "./typica.w"
  691. };
  692. /*:477*//*500:*/
  693. #line 11424 "./typica.w"
  694. class PackLayout:public QLayout
  695. {
  696. int doLayout(const QRect&rect,bool testOnly)const;
  697. QList<QLayoutItem*> itemList;
  698. Qt::Orientations orientation;
  699. public:
  700. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  701. PackLayout(int spacing= -1);
  702. ~PackLayout();
  703. void addItem(QLayoutItem*item);
  704. Qt::Orientations expandingDirections()const;
  705. bool hasHeightForWidth()const;
  706. int heightForWidth(int width)const;
  707. int count()const;
  708. QLayoutItem*itemAt(int index)const;
  709. QSize minimumSize()const;
  710. void setGeometry(const QRect&rect);
  711. void setOrientation(Qt::Orientations direction);
  712. QSize sizeHint()const;
  713. QLayoutItem*takeAt(int index);
  714. };
  715. /*:500*//*513:*/
  716. #line 11702 "./typica.w"
  717. class SceneButton:public QGraphicsScene
  718. {
  719. Q_OBJECT
  720. public:
  721. SceneButton();
  722. ~SceneButton();
  723. protected:
  724. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  725. signals:
  726. void clicked(QPoint pos);
  727. };
  728. /*:513*//*515:*/
  729. #line 11744 "./typica.w"
  730. class WidgetDecorator:public QWidget
  731. {
  732. Q_OBJECT
  733. PackLayout*layout;
  734. QGraphicsView*label;
  735. QGraphicsTextItem*text;
  736. SceneButton*scene;
  737. public:
  738. WidgetDecorator(QWidget*widget,const QString&labeltext,
  739. Qt::Orientations orientation= Qt::Horizontal,
  740. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  741. ~WidgetDecorator();
  742. void setBackgroundBrush(QBrush background);
  743. void setTextColor(QColor color);
  744. };
  745. /*:515*//*526:*/
  746. #line 11919 "./typica.w"
  747. class LogEditWindow:public QMainWindow
  748. {
  749. Q_OBJECT
  750. QWidget*centralWidget;
  751. PackLayout*mainLayout;
  752. QHBoxLayout*addRowsLayout;
  753. QLabel*startTimeLabel;
  754. QTimeEdit*startTime;
  755. QLabel*endTimeLabel;
  756. QTimeEdit*endTime;
  757. QLabel*intervalLabel;
  758. QSpinBox*interval;
  759. QPushButton*addRows;
  760. QAction*saveXml;
  761. QAction*saveCsv;
  762. QAction*openXml;
  763. MeasurementModel*model;
  764. QTableView*log;
  765. private slots:
  766. void addTheRows();
  767. void saveXML();
  768. void saveCSV();
  769. void openXML();
  770. protected:
  771. void closeEvent(QCloseEvent*event);
  772. public:
  773. LogEditWindow();
  774. };
  775. /*:526*//*540:*/
  776. #line 12227 "./typica.w"
  777. class XMLOutput:public QObject
  778. {
  779. Q_OBJECT
  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. XMLOutput(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. /*:540*//*547:*/
  797. #line 12463 "./typica.w"
  798. class XMLInput:public QObject
  799. {
  800. Q_OBJECT
  801. int firstc;
  802. QIODevice*in;
  803. public:
  804. XMLInput(QIODevice*input,int c);
  805. void setFirstColumn(int column);
  806. void setDevice(QIODevice*device);
  807. bool input();
  808. signals:
  809. void measure(Measurement,int);
  810. void annotation(QString,int,int);
  811. void newTemperatureColumn(int,QString);
  812. void newAnnotationColumn(int,QString);
  813. void lastColumn(int);
  814. };
  815. /*:547*//*558:*/
  816. #line 12717 "./typica.w"
  817. class CSVOutput
  818. {
  819. MeasurementModel*data;
  820. QIODevice*out;
  821. int time;
  822. QMap<int,QString> temperatureColumns;
  823. QMap<int,QString> controlColumns;
  824. QMap<int,QString> annotationColumns;
  825. public:
  826. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  827. void addTemperatureColumn(const QString&series,int column);
  828. void addControlColumn(const QString&series,int column);
  829. void addAnnotationColumn(const QString&series,int column);
  830. void setModel(MeasurementModel*model);
  831. void setTimeColumn(int column);
  832. void setDevice(QIODevice*device);
  833. bool output();
  834. };
  835. /*:558*//*598:*/
  836. #line 12862 "./typica.w"
  837. #define AppInstance (qobject_cast<Application *> (qApp))
  838. class NodeInserter;
  839. class DeviceTreeModel;
  840. class Application:public QApplication
  841. {
  842. Q_OBJECT
  843. public:
  844. Application(int&argc,char**argv);
  845. QDomDocument*configuration();
  846. /*747:*/
  847. #line 15460 "./typica.w"
  848. QDomDocument deviceConfiguration();
  849. /*:747*//*780:*/
  850. #line 16133 "./typica.w"
  851. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  852. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  853. const QModelIndex&index);
  854. /*:780*//*785:*/
  855. #line 16237 "./typica.w"
  856. QList<NodeInserter*> topLevelNodeInserters;
  857. /*:785*/
  858. #line 12873 "./typica.w"
  859. QSqlDatabase database();
  860. Q_INVOKABLE bool databaseConnected();
  861. Q_INVOKABLE QString currentTypicaUser();
  862. Q_INVOKABLE bool login(const QString&user,const QString&password);
  863. Q_INVOKABLE bool autoLogin();
  864. QScriptEngine*engine;
  865. public slots:
  866. void setDatabaseConnected(bool status);
  867. void setCurrentTypicaUser(const QString&user);
  868. /*748:*/
  869. #line 15467 "./typica.w"
  870. void saveDeviceConfiguration();
  871. /*:748*/
  872. #line 12883 "./typica.w"
  873. signals:
  874. void userChanged(const QString&user);
  875. private:
  876. /*746:*/
  877. #line 15451 "./typica.w"
  878. QDomDocument deviceConfigurationDocument;
  879. /*:746*//*779:*/
  880. #line 16127 "./typica.w"
  881. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  882. /*:779*/
  883. #line 12887 "./typica.w"
  884. QDomDocument conf;
  885. bool connectionStatus;
  886. QString currentUser;
  887. };
  888. /*:598*//*607:*/
  889. #line 13029 "./typica.w"
  890. class SaltModel:public QAbstractItemModel
  891. {
  892. Q_OBJECT
  893. QList<QList<QMap<int,QVariant> > > modelData;
  894. QStringList hData;
  895. int colcount;
  896. public:
  897. SaltModel(int columns);
  898. ~SaltModel();
  899. int rowCount(const QModelIndex&parent= QModelIndex())const;
  900. int columnCount(const QModelIndex&parent= QModelIndex())const;
  901. bool setHeaderData(int section,Qt::Orientation orientation,
  902. const QVariant&value,int role= Qt::DisplayRole);
  903. QVariant data(const QModelIndex&index,int role)const;
  904. bool setData(const QModelIndex&index,const QVariant&value,
  905. int role= Qt::EditRole);
  906. Qt::ItemFlags flags(const QModelIndex&index)const;
  907. QVariant headerData(int section,Qt::Orientation orientation,
  908. int role= Qt::DisplayRole)const;
  909. QModelIndex index(int row,int column,
  910. const QModelIndex&parent= QModelIndex())const;
  911. QModelIndex parent(const QModelIndex&index)const;
  912. QString arrayLiteral(int column,int role)const;
  913. QString quotedArrayLiteral(int column,int role)const;
  914. void clear();
  915. bool removeRows(int row,int count,
  916. const QModelIndex&parent= QModelIndex());
  917. int findData(const QVariant&value,int column,int role= Qt::UserRole);
  918. };
  919. /*:607*//*623:*/
  920. #line 13414 "./typica.w"
  921. class SqlComboBox:public QComboBox
  922. {
  923. Q_OBJECT
  924. int dataColumn;
  925. int displayColumn;
  926. bool dataColumnShown;
  927. QString specialNullText;
  928. QVariant specialNullData;
  929. public:
  930. SqlComboBox();
  931. ~SqlComboBox();
  932. SqlComboBox*clone(QWidget*parent);
  933. public slots:
  934. void addNullOption();
  935. void addSqlOptions(QString query);
  936. void setDataColumn(int column);
  937. void setDisplayColumn(int column);
  938. void showData(bool show);
  939. void setNullText(QString nullText);
  940. void setNullData(QVariant nullData);
  941. };
  942. /*:623*//*630:*/
  943. #line 13561 "./typica.w"
  944. class SqlComboBoxDelegate:public QItemDelegate
  945. {
  946. Q_OBJECT
  947. SqlComboBox*delegate;
  948. public:
  949. SqlComboBoxDelegate(QObject*parent= NULL);
  950. QWidget*createEditor(QWidget*parent,
  951. const QStyleOptionViewItem&option,
  952. const QModelIndex&index)const;
  953. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  954. void setModelData(QWidget*editor,QAbstractItemModel*model,
  955. const QModelIndex&index)const;
  956. void setWidget(SqlComboBox*widget);
  957. virtual QSize sizeHint()const;
  958. void updateEditorGeometry(QWidget*editor,
  959. const QStyleOptionViewItem&option,
  960. const QModelIndex&index)const;
  961. };
  962. /*:630*//*645:*/
  963. #line 13772 "./typica.w"
  964. class SqlConnectionSetup:public QDialog
  965. {
  966. Q_OBJECT
  967. public:
  968. SqlConnectionSetup();
  969. ~SqlConnectionSetup();
  970. public slots:
  971. void testConnection();
  972. private:
  973. QFormLayout*formLayout;
  974. QComboBox*driver;
  975. QLineEdit*hostname;
  976. QLineEdit*portnumber;
  977. QLineEdit*dbname;
  978. QLineEdit*user;
  979. QLineEdit*password;
  980. QVBoxLayout*layout;
  981. QHBoxLayout*buttons;
  982. QPushButton*cancelButton;
  983. QPushButton*connectButton;
  984. };
  985. /*:645*//*650:*/
  986. #line 13922 "./typica.w"
  987. class SqlQueryView:public QTableView
  988. {
  989. Q_OBJECT
  990. public:
  991. SqlQueryView(QWidget*parent= NULL);
  992. void setQuery(const QString&query);
  993. bool setHeaderData(int section,Qt::Orientation orientation,
  994. const QVariant&value,int role);
  995. Q_INVOKABLE QVariant data(int row,int column,
  996. int role= Qt::DisplayRole);
  997. signals:
  998. void openEntry(QString key);
  999. void openEntryRow(int row);
  1000. protected:
  1001. virtual void showEvent(QShowEvent*event);
  1002. private slots:
  1003. void openRow(const QModelIndex&index);
  1004. void persistColumnResize(int column,int oldsize,int newsize);
  1005. };
  1006. /*:650*//*665:*/
  1007. #line 14177 "./typica.w"
  1008. class ReportAction:public QAction
  1009. {
  1010. Q_OBJECT
  1011. public:
  1012. ReportAction(const QString&fileName,const QString&reportName,
  1013. QObject*parent= NULL);
  1014. private slots:
  1015. void createReport();
  1016. private:
  1017. QString reportFile;
  1018. };
  1019. /*:665*//*677:*/
  1020. #line 14388 "./typica.w"
  1021. class ReportTable:public QObject
  1022. {
  1023. Q_OBJECT
  1024. QTextFrame*area;
  1025. QDomElement configuration;
  1026. QMap<QString,QVariant> bindings;
  1027. public:
  1028. ReportTable(QTextFrame*frame,QDomElement description);
  1029. ~ReportTable();
  1030. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  1031. public slots:
  1032. void refresh();
  1033. };
  1034. /*:677*//*690:*/
  1035. #line 63 "./plugins.w"
  1036. class PluginAction:public QAction
  1037. {
  1038. Q_OBJECT
  1039. Q_PROPERTY(QString preRun READ preRun WRITE setPreRun);
  1040. Q_PROPERTY(QString postRun READ postRun WRITE setPostRun);
  1041. public:
  1042. PluginAction(const QFileInfo&info,QObject*parent);
  1043. QString preRun();
  1044. QString postRun();
  1045. public slots:
  1046. void setPreRun(const QString&script);
  1047. void setPostRun(const QString&script);
  1048. private slots:
  1049. void runScript();
  1050. private:
  1051. QString pluginFile;
  1052. QString preRunScript;
  1053. QString postRunScript;
  1054. };
  1055. /*:690*//*693:*/
  1056. #line 155 "./plugins.w"
  1057. Q_DECLARE_METATYPE(QScriptValue)
  1058. /*:693*//*716:*/
  1059. #line 14629 "./typica.w"
  1060. class FormArray:public QScrollArea
  1061. {
  1062. Q_OBJECT
  1063. QDomElement configuration;
  1064. QWidget itemContainer;
  1065. QVBoxLayout itemLayout;
  1066. int maxwidth;
  1067. int maxheight;
  1068. public:
  1069. FormArray(QDomElement description);
  1070. Q_INVOKABLE QWidget*elementAt(int index);
  1071. Q_INVOKABLE int elements();
  1072. public slots:
  1073. void addElements(int copies= 1);
  1074. void removeAllElements();
  1075. void setMaximumElementWidth(int width);
  1076. void setMaximumElementHeight(int height);
  1077. };
  1078. /*:716*//*726:*/
  1079. #line 14845 "./typica.w"
  1080. class ScaleControl:public QGraphicsView
  1081. {
  1082. Q_OBJECT
  1083. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  1084. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  1085. /*727:*/
  1086. #line 14871 "./typica.w"
  1087. QGraphicsScene scene;
  1088. QGraphicsPolygonItem initialDecrement;
  1089. QGraphicsPolygonItem initialIncrement;
  1090. QGraphicsPolygonItem finalDecrement;
  1091. QGraphicsPolygonItem finalIncrement;
  1092. QGraphicsPolygonItem initialIndicator;
  1093. QGraphicsPolygonItem finalIndicator;
  1094. QGraphicsPathItem scaleLine;
  1095. QPolygonF left;
  1096. QPolygonF right;
  1097. QPolygonF down;
  1098. QPolygonF up;
  1099. QPainterPath scalePath;
  1100. QBrush initialBrush;
  1101. QBrush finalBrush;
  1102. double nonScoredValue;
  1103. double scoredValue;
  1104. bool initialSet;
  1105. bool finalSet;
  1106. bool scaleDown;
  1107. /*:727*/
  1108. #line 14851 "./typica.w"
  1109. public:
  1110. ScaleControl();
  1111. double initialValue(void);
  1112. double finalValue(void);
  1113. virtual QSize sizeHint()const;
  1114. public slots:
  1115. void setInitialValue(double value);
  1116. void setFinalValue(double value);
  1117. signals:
  1118. void initialChanged(double);
  1119. void finalChanged(double);
  1120. protected:
  1121. virtual void mousePressEvent(QMouseEvent*event);
  1122. virtual void mouseReleaseEvent(QMouseEvent*event);
  1123. };
  1124. /*:726*//*738:*/
  1125. #line 15168 "./typica.w"
  1126. class IntensityControl:public QGraphicsView
  1127. {
  1128. Q_OBJECT
  1129. Q_PROPERTY(double value READ value WRITE setValue)
  1130. QGraphicsScene scene;
  1131. QGraphicsPolygonItem decrement;
  1132. QGraphicsPolygonItem increment;
  1133. QGraphicsPolygonItem indicator;
  1134. QGraphicsPathItem scaleLine;
  1135. QPolygonF left;
  1136. QPolygonF up;
  1137. QPolygonF down;
  1138. QPainterPath scalePath;
  1139. QBrush theBrush;
  1140. double theValue;
  1141. bool valueSet;
  1142. bool scaleDown;
  1143. public:
  1144. IntensityControl();
  1145. double value();
  1146. virtual QSize sizeHint()const;
  1147. public slots:
  1148. void setValue(double val);
  1149. signals:
  1150. void valueChanged(double);
  1151. protected:
  1152. virtual void mousePressEvent(QMouseEvent*event);
  1153. virtual void mouseReleaseEvent(QMouseEvent*event);
  1154. };
  1155. /*:738*//*754:*/
  1156. #line 15556 "./typica.w"
  1157. class DeviceTreeModelNode
  1158. {
  1159. public:
  1160. DeviceTreeModelNode(QDomNode&node,int row,
  1161. DeviceTreeModelNode*parent= NULL);
  1162. ~DeviceTreeModelNode();
  1163. DeviceTreeModelNode*child(int index);
  1164. DeviceTreeModelNode*parent();
  1165. QDomNode node()const;
  1166. int row();
  1167. private:
  1168. QDomNode domNode;
  1169. QHash<int,DeviceTreeModelNode*> children;
  1170. int rowNumber;
  1171. DeviceTreeModelNode*parentItem;
  1172. };
  1173. /*:754*//*756:*/
  1174. #line 15631 "./typica.w"
  1175. class DeviceTreeModel:public QAbstractItemModel
  1176. {
  1177. Q_OBJECT
  1178. public:
  1179. DeviceTreeModel(QObject*parent= NULL);
  1180. ~DeviceTreeModel();
  1181. QVariant data(const QModelIndex&index,int role)const;
  1182. Qt::ItemFlags flags(const QModelIndex&index)const;
  1183. QVariant headerData(int section,Qt::Orientation orientation,
  1184. int role= Qt::DisplayRole)const;
  1185. QModelIndex index(int row,int column,
  1186. const QModelIndex&parent= QModelIndex())const;
  1187. QModelIndex parent(const QModelIndex&child)const;
  1188. Q_INVOKABLE int rowCount(const QModelIndex&parent= QModelIndex())const;
  1189. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1190. bool setData(const QModelIndex&index,const QVariant&value,
  1191. int role);
  1192. bool removeRows(int row,int count,const QModelIndex&parent);
  1193. QDomElement referenceElement(const QString&id);
  1194. public slots:
  1195. void newNode(const QString&name,const QString&driver,
  1196. const QModelIndex&parent);
  1197. private:
  1198. QDomDocument document;
  1199. DeviceTreeModelNode*root;
  1200. QDomNode referenceSection;
  1201. QDomNode treeRoot;
  1202. };
  1203. /*:756*//*775:*/
  1204. #line 16085 "./typica.w"
  1205. Q_DECLARE_METATYPE(QModelIndex)
  1206. /*:775*//*783:*/
  1207. #line 16192 "./typica.w"
  1208. class NodeInserter:public QAction
  1209. {
  1210. Q_OBJECT
  1211. public:
  1212. NodeInserter(const QString&title,const QString&name,
  1213. const QString&driver,QObject*parent= NULL);
  1214. signals:
  1215. void triggered(QString name,QString driver);
  1216. private slots:
  1217. void onTriggered();
  1218. private:
  1219. QString defaultNodeName;
  1220. QString driverString;
  1221. };
  1222. /*:783*//*786:*/
  1223. #line 16247 "./typica.w"
  1224. class DeviceConfigurationWindow:public QWidget
  1225. {
  1226. Q_OBJECT
  1227. public:
  1228. DeviceConfigurationWindow();
  1229. public slots:
  1230. void addDevice();
  1231. void removeNode();
  1232. void newSelection(const QModelIndex&index);
  1233. private slots:
  1234. void resizeColumn();
  1235. private:
  1236. QDomDocument document;
  1237. DeviceTreeModel*model;
  1238. QTreeView*view;
  1239. QScrollArea*configArea;
  1240. };
  1241. /*:786*//*795:*/
  1242. #line 16417 "./typica.w"
  1243. class BasicDeviceConfigurationWidget:public QWidget
  1244. {
  1245. Q_OBJECT
  1246. public:
  1247. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1248. const QModelIndex&index);
  1249. public slots:
  1250. void insertChildNode(const QString&name,const QString&driver);
  1251. void updateAttribute(const QString&name,const QString&value);
  1252. protected:
  1253. DeviceTreeModel*deviceModel;
  1254. QModelIndex currentNode;
  1255. };
  1256. /*:795*//*799:*/
  1257. #line 16502 "./typica.w"
  1258. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1259. {
  1260. Q_OBJECT
  1261. public:
  1262. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1263. const QModelIndex&index);
  1264. private slots:
  1265. void updateRoasterId(int id);
  1266. void updateCapacityCheck(int value);
  1267. void updateCapacity(const QString&value);
  1268. void updateCapacityUnit(const QString&value);
  1269. };
  1270. /*:799*//*804:*/
  1271. #line 16707 "./typica.w"
  1272. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1273. {
  1274. Q_OBJECT
  1275. public:
  1276. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1277. const QModelIndex&index);
  1278. };
  1279. /*:804*//*806:*/
  1280. #line 16753 "./typica.w"
  1281. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1282. {
  1283. Q_OBJECT
  1284. public:
  1285. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1286. const QModelIndex&index);
  1287. private slots:
  1288. void addChannel();
  1289. void updateDeviceId(const QString&newId);
  1290. };
  1291. /*:806*//*810:*/
  1292. #line 16839 "./typica.w"
  1293. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1294. {
  1295. Q_OBJECT
  1296. public:
  1297. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1298. const QModelIndex&index);
  1299. private slots:
  1300. void updateThermocoupleType(const QString&type);
  1301. void updateColumnName(const QString&name);
  1302. void updateHidden(bool hidden);
  1303. };
  1304. /*:810*//*815:*/
  1305. #line 16955 "./typica.w"
  1306. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1307. {
  1308. Q_OBJECT
  1309. public:
  1310. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1311. const QModelIndex&index);
  1312. };
  1313. /*:815*//*817:*/
  1314. #line 16996 "./typica.w"
  1315. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1316. {
  1317. Q_OBJECT
  1318. public:
  1319. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1320. const QModelIndex&index);
  1321. private slots:
  1322. void addChannel();
  1323. void updateDeviceId(const QString&newId);
  1324. };
  1325. /*:817*//*819:*/
  1326. #line 17065 "./typica.w"
  1327. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1328. {
  1329. Q_OBJECT
  1330. public:
  1331. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1332. const QModelIndex&index);
  1333. private slots:
  1334. void updateDeviceId(const QString&newId);
  1335. void updateThermocoupleType(const QString&type);
  1336. void updateColumnName(const QString&name);
  1337. void updateHidden(bool hidden);
  1338. };
  1339. /*:819*//*824:*/
  1340. #line 17196 "./typica.w"
  1341. class PortSelector:public QComboBox
  1342. {
  1343. Q_OBJECT
  1344. public:
  1345. PortSelector(QWidget*parent= NULL);
  1346. private slots:
  1347. void addDevice(QextPortInfo port);
  1348. private:
  1349. QextSerialEnumerator*lister;
  1350. };
  1351. /*:824*//*826:*/
  1352. #line 17244 "./typica.w"
  1353. class BaudSelector:public QComboBox
  1354. {
  1355. Q_OBJECT
  1356. Q_ENUMS(BaudRateType)
  1357. public:
  1358. BaudSelector(QWidget*parent= NULL);
  1359. enum BaudRateType
  1360. {
  1361. #if defined(Q_OS_UNIX) || defined(qdoc)
  1362. BAUD50= 50,
  1363. BAUD75= 75,
  1364. BAUD134= 134,
  1365. BAUD150= 150,
  1366. BAUD200= 200,
  1367. BAUD1800= 1800,
  1368. #if defined(B76800) || defined(qdoc)
  1369. BAUD76800= 76800,
  1370. #endif
  1371. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1372. BAUD230400= 230400,
  1373. BAUD460800= 460800,
  1374. BAUD500000= 500000,
  1375. BAUD576000= 576000,
  1376. BAUD921600= 921600,
  1377. BAUD1000000= 1000000,
  1378. BAUD1152000= 1152000,
  1379. BAUD1500000= 1500000,
  1380. BAUD2000000= 2000000,
  1381. BAUD2500000= 2500000,
  1382. BAUD3000000= 3000000,
  1383. BAUD3500000= 3500000,
  1384. BAUD4000000= 4000000,
  1385. #endif
  1386. #endif
  1387. #if defined(Q_OS_WIN) || defined(qdoc)
  1388. BAUD14400= 14400,
  1389. BAUD56000= 56000,
  1390. BAUD128000= 128000,
  1391. BAUD256000= 256000,
  1392. #endif
  1393. BAUD110= 110,
  1394. BAUD300= 300,
  1395. BAUD600= 600,
  1396. BAUD1200= 1200,
  1397. BAUD2400= 2400,
  1398. BAUD4800= 4800,
  1399. BAUD9600= 9600,
  1400. BAUD19200= 19200,
  1401. BAUD38400= 38400,
  1402. BAUD57600= 57600,
  1403. BAUD115200= 115200
  1404. };
  1405. };
  1406. /*:826*//*828:*/
  1407. #line 17315 "./typica.w"
  1408. class ParitySelector:public QComboBox
  1409. {
  1410. Q_OBJECT
  1411. Q_ENUMS(ParityType)
  1412. public:
  1413. ParitySelector(QWidget*parent= NULL);
  1414. enum ParityType
  1415. {
  1416. PAR_NONE,
  1417. PAR_ODD,
  1418. PAR_EVEN,
  1419. #if defined(Q_OS_WIN) || defined(qdoc)
  1420. PAR_MARK,
  1421. #endif
  1422. PAR_SPACE
  1423. };
  1424. };
  1425. /*:828*//*830:*/
  1426. #line 17353 "./typica.w"
  1427. class FlowSelector:public QComboBox
  1428. {
  1429. Q_OBJECT
  1430. Q_ENUMS(FlowType)
  1431. public:
  1432. FlowSelector(QWidget*parent= NULL);
  1433. enum FlowType
  1434. {
  1435. FLOW_OFF,
  1436. FLOW_HARDWARE,
  1437. FLOW_XONXOFF
  1438. };
  1439. };
  1440. /*:830*//*832:*/
  1441. #line 17386 "./typica.w"
  1442. class StopSelector:public QComboBox
  1443. {
  1444. Q_OBJECT
  1445. Q_ENUMS(StopBitsType)
  1446. public:
  1447. StopSelector(QWidget*parent= NULL);
  1448. enum StopBitsType
  1449. {
  1450. STOP_1,
  1451. #if defined(Q_OS_WIN) || defined(qdoc)
  1452. STOP_1_5,
  1453. #endif
  1454. STOP_2
  1455. };
  1456. };
  1457. /*:832*//*835:*/
  1458. #line 17443 "./typica.w"
  1459. class ShortHexSpinBox:public QSpinBox
  1460. {
  1461. Q_OBJECT
  1462. public:
  1463. ShortHexSpinBox(QWidget*parent= NULL);
  1464. virtual QValidator::State validate(QString&input,int&pos)const;
  1465. protected:
  1466. virtual int valueFromText(const QString&text)const;
  1467. virtual QString textFromValue(int value)const;
  1468. };
  1469. /*:835*//*837:*/
  1470. #line 17505 "./typica.w"
  1471. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1472. {
  1473. Q_OBJECT
  1474. public:
  1475. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1476. const QModelIndex&index);
  1477. private slots:
  1478. void updatePort(const QString&newPort);
  1479. void updateBaudRate(const QString&newRate);
  1480. void updateParity(const QString&newParity);
  1481. void updateFlowControl(const QString&newFlow);
  1482. void updateStopBits(const QString&newStopBits);
  1483. };
  1484. /*:837*//*839:*/
  1485. #line 17656 "./typica.w"
  1486. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1487. {
  1488. Q_OBJECT
  1489. public:
  1490. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1491. const QModelIndex&index);
  1492. private slots:
  1493. void updateStationNumber(int newStation);
  1494. void updateFixedUnit(bool newFixed);
  1495. void updateFixedDecimal(bool newFixed);
  1496. void updateUnit(const QString&newUnit);
  1497. void updateUnitAddress(int newAddress);
  1498. void updateValueF(int newValue);
  1499. void updateValueC(int newValue);
  1500. void updatePrecisionAddress(int newAddress);
  1501. void updatePrecisionValue(int newValue);
  1502. private:
  1503. QStackedLayout*unitSpecificationLayout;
  1504. QStackedLayout*decimalSpecificationLayout;
  1505. };
  1506. /*:839*//*841:*/
  1507. #line 17915 "./typica.w"
  1508. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1509. {
  1510. Q_OBJECT
  1511. public:
  1512. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1513. const QModelIndex&index);
  1514. private slots:
  1515. void updateAddress(int newAddress);
  1516. };
  1517. /*:841*//*843:*/
  1518. #line 17961 "./typica.w"
  1519. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1520. {
  1521. Q_OBJECT
  1522. public:
  1523. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1524. const QModelIndex&index);
  1525. private slots:
  1526. void updateReadAddress(int newAddress);
  1527. void updateWriteAddress(int newAddress);
  1528. void updateFixedRange(bool fixed);
  1529. void updateLower(const QString&lower);
  1530. void updateUpper(const QString&upper);
  1531. void updateLowerAddress(int newAddress);
  1532. void updateUpperAddress(int newAddress);
  1533. private:
  1534. QStackedLayout*boundsLayout;
  1535. };
  1536. /*:843*//*847:*/
  1537. #line 18155 "./typica.w"
  1538. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1539. {
  1540. Q_OBJECT
  1541. public:
  1542. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1543. private slots:
  1544. void updateButtonText(const QString&text);
  1545. void updateAnnotationText(const QString&text);
  1546. };
  1547. /*:847*//*851:*/
  1548. #line 18223 "./typica.w"
  1549. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1550. {
  1551. Q_OBJECT
  1552. public:
  1553. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1554. private slots:
  1555. void updateButtonText(const QString&text);
  1556. void updateAnnotationText(const QString&text);
  1557. };
  1558. /*:851*//*854:*/
  1559. #line 18297 "./typica.w"
  1560. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1561. {
  1562. Q_OBJECT
  1563. public:
  1564. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1565. private slots:
  1566. void updateLabel(const QString&text);
  1567. void updateMinimum(const QString&minimum);
  1568. void updateMaximum(const QString&maximum);
  1569. void updatePrecision(int precision);
  1570. void updatePretext(const QString&text);
  1571. void updatePosttext(const QString&text);
  1572. };
  1573. /*:854*//*857:*/
  1574. #line 12 "./freeannotation.w"
  1575. class FreeAnnotationConfWidget:public BasicDeviceConfigurationWidget
  1576. {
  1577. Q_OBJECT
  1578. public:
  1579. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1580. private slots:
  1581. void updateLabel(const QString&text);
  1582. };
  1583. /*:857*//*861:*/
  1584. #line 11 "./settings.w"
  1585. class SettingsWindow:public QMainWindow
  1586. {
  1587. Q_OBJECT
  1588. public:
  1589. SettingsWindow();
  1590. };
  1591. /*:861*//*866:*/
  1592. #line 8 "./graphsettings.w"
  1593. class GraphSettingsWidget:public QWidget
  1594. {
  1595. Q_OBJECT
  1596. public:
  1597. GraphSettingsWidget();
  1598. };
  1599. /*:866*//*868:*/
  1600. #line 46 "./graphsettings.w"
  1601. class GraphSettingsRelativeTab:public QWidget
  1602. {
  1603. Q_OBJECT
  1604. public:
  1605. GraphSettingsRelativeTab();
  1606. public slots:
  1607. void updateEnableSetting(bool enable);
  1608. void updateColorSetting(const QString&color);
  1609. void updateAxisSetting(const QString&gridList);
  1610. void updateUnit(int unit);
  1611. void showColorPicker();
  1612. private:
  1613. QLineEdit*colorEdit;
  1614. };
  1615. /*:868*//*872:*/
  1616. #line 7 "./advancedsettings.w"
  1617. class AdvancedSettingsWidget:public QWidget
  1618. {
  1619. Q_OBJECT
  1620. public:
  1621. AdvancedSettingsWidget();
  1622. public slots:
  1623. void enableDiagnosticLogging(bool enabled);
  1624. };
  1625. /*:872*//*876:*/
  1626. #line 18422 "./typica.w"
  1627. class ModbusRTUDevice:public QObject
  1628. {
  1629. Q_OBJECT
  1630. public:
  1631. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1632. ~ModbusRTUDevice();
  1633. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1634. Q_INVOKABLE double SVLower();
  1635. Q_INVOKABLE double SVUpper();
  1636. Q_INVOKABLE int decimals();
  1637. QList<Channel*> channels;
  1638. public slots:
  1639. void outputSV(double sv);
  1640. signals:
  1641. void SVLowerChanged(double);
  1642. void SVUpperChanged(double);
  1643. void SVDecimalChanged(int);
  1644. void queueEmpty();
  1645. private slots:
  1646. void dataAvailable();
  1647. void sendNextMessage();
  1648. void decimalResponse(QByteArray response);
  1649. void unitResponse(QByteArray response);
  1650. void svlResponse(QByteArray response);
  1651. void svuResponse(QByteArray response);
  1652. void requestMeasurement();
  1653. void mResponse(QByteArray response);
  1654. void ignore(QByteArray response);
  1655. void timeout();
  1656. private:
  1657. QextSerialPort*port;
  1658. QByteArray responseBuffer;
  1659. QList<QByteArray> messageQueue;
  1660. QList<QObject*> retObjQueue;
  1661. QList<char*> callbackQueue;
  1662. quint16 calculateCRC(QByteArray data);
  1663. QTimer*messageDelayTimer;
  1664. QTimer*commTimeout;
  1665. int delayTime;
  1666. char station;
  1667. int decimalPosition;
  1668. int valueF;
  1669. int valueC;
  1670. bool unitIsF;
  1671. double outputSVLower;
  1672. double outputSVUpper;
  1673. QByteArray outputSVStub;
  1674. QByteArray pvStub;
  1675. QByteArray svStub;
  1676. QByteArray mStub;
  1677. quint16 pvaddress;
  1678. quint16 svaddress;
  1679. bool svenabled;
  1680. bool readingsv;
  1681. double savedpv;
  1682. bool waiting;
  1683. };
  1684. /*:876*//*892:*/
  1685. #line 19125 "./typica.w"
  1686. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1687. {
  1688. Q_OBJECT
  1689. public:
  1690. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1691. private slots:
  1692. void updatePort(const QString&newPort);
  1693. void updateBaudRate(const QString&newRate);
  1694. void updateParity(const QString&newParity);
  1695. void updateFlowControl(const QString&newFlow);
  1696. void updateStopBits(const QString&newStopBits);
  1697. void updateStation(int station);
  1698. void updateFixedDecimal(bool fixed);
  1699. void updateDecimalAddress(int address);
  1700. void updateDecimalPosition(int position);
  1701. void updateFixedUnit(bool fixed);
  1702. void updateUnitAddress(int address);
  1703. void updateValueForF(int value);
  1704. void updateValueForC(int value);
  1705. void updateUnit(const QString&newUnit);
  1706. void updatePVAddress(int address);
  1707. void updateSVEnabled(bool enabled);
  1708. void updateSVReadAddress(int address);
  1709. void updateDeviceLimit(bool query);
  1710. void updateSVLowerAddress(int address);
  1711. void updateSVUpperAddress(int address);
  1712. void updateSVLower(double value);
  1713. void updateSVUpper(double value);
  1714. void updateSVWritable(bool canWriteSV);
  1715. void updateSVWriteAddress(int address);
  1716. void updatePVColumnName(const QString&name);
  1717. void updateSVColumnName(const QString&name);
  1718. void updatePVHidden(bool hidden);
  1719. void updateSVHidden(bool hidden);
  1720. private:
  1721. PortSelector*port;
  1722. BaudSelector*baud;
  1723. ParitySelector*parity;
  1724. FlowSelector*flow;
  1725. StopSelector*stop;
  1726. QSpinBox*station;
  1727. QCheckBox*decimalQuery;
  1728. ShortHexSpinBox*decimalAddress;
  1729. QSpinBox*decimalPosition;
  1730. QCheckBox*unitQuery;
  1731. ShortHexSpinBox*unitAddress;
  1732. QSpinBox*valueF;
  1733. QSpinBox*valueC;
  1734. QComboBox*fixedUnit;
  1735. ShortHexSpinBox*pVAddress;
  1736. QCheckBox*sVEnabled;
  1737. ShortHexSpinBox*sVReadAddress;
  1738. QCheckBox*deviceLimit;
  1739. ShortHexSpinBox*sVLowerAddr;
  1740. ShortHexSpinBox*sVUpperAddr;
  1741. QDoubleSpinBox*sVLower;
  1742. QDoubleSpinBox*sVUpper;
  1743. QCheckBox*sVWritable;
  1744. ShortHexSpinBox*sVOutputAddr;
  1745. QLineEdit*pVColumnName;
  1746. QLineEdit*sVColumnName;
  1747. };
  1748. /*:892*//*896:*/
  1749. #line 22 "./modbus.w"
  1750. class ModbusNGConfWidget:public BasicDeviceConfigurationWidget
  1751. {
  1752. Q_OBJECT
  1753. public:
  1754. Q_INVOKABLE ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1755. private slots:
  1756. void updatePort(const QString&value);
  1757. void updateBaudRate(const QString&value);
  1758. void updateParity(int value);
  1759. void updateFlowControl(int value);
  1760. void updateStopBits(int value);
  1761. void addInput();
  1762. private:
  1763. ParitySelector*m_parity;
  1764. FlowSelector*m_flow;
  1765. StopSelector*m_stop;
  1766. };
  1767. /*:896*//*898:*/
  1768. #line 144 "./modbus.w"
  1769. class ModbusNGInputConfWidget:public BasicDeviceConfigurationWidget
  1770. {
  1771. Q_OBJECT
  1772. public:
  1773. Q_INVOKABLE ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1774. private slots:
  1775. void updateStation(int value);
  1776. void updateAddress(int value);
  1777. void updateFunction(int value);
  1778. void updateFormat(int value);
  1779. void updateDecimals(int value);
  1780. void updateUnit(int value);
  1781. void updateColumnName(const QString&value);
  1782. void updateHidden(bool value);
  1783. };
  1784. /*:898*//*902:*/
  1785. #line 342 "./modbus.w"
  1786. enum ModbusDataFormat
  1787. {
  1788. Int16,
  1789. FloatHL,
  1790. FloatLH
  1791. };
  1792. struct ModbusScanItem
  1793. {
  1794. QByteArray request;
  1795. ModbusDataFormat format;
  1796. int decimalPosition;
  1797. Units::Unit unit;
  1798. mutable double lastValue;
  1799. };
  1800. /*:902*//*903:*/
  1801. #line 362 "./modbus.w"
  1802. class ModbusNG:public QObject
  1803. {
  1804. Q_OBJECT
  1805. public:
  1806. ModbusNG(DeviceTreeModel*model,const QModelIndex&index);
  1807. ~ModbusNG();
  1808. Q_INVOKABLE int channelCount();
  1809. Channel*getChannel(int);
  1810. Q_INVOKABLE QString channelColumnName(int);
  1811. Q_INVOKABLE QString channelIndicatorText(int);
  1812. Q_INVOKABLE bool isChannelHidden(int);
  1813. Q_INVOKABLE QString channelType(int);
  1814. private slots:
  1815. void sendNextMessage();
  1816. void timeout();
  1817. void dataAvailable();
  1818. void rateLimitTimeout();
  1819. private:
  1820. quint16 calculateCRC(QByteArray data);
  1821. QextSerialPort*port;
  1822. int delayTime;
  1823. QTimer*messageDelayTimer;
  1824. QTimer*commTimeout;
  1825. QTimer*rateLimiter;
  1826. int scanPosition;
  1827. bool waiting;
  1828. QByteArray responseBuffer;
  1829. QList<Channel*> channels;
  1830. QList<ModbusScanItem> scanList;
  1831. QList<QString> channelNames;
  1832. QList<QString> channelLabels;
  1833. QList<bool> hiddenStates;
  1834. QList<QString> channelTypeList;
  1835. QVector<double> lastMeasurement;
  1836. };
  1837. /*:903*//*908:*/
  1838. #line 36 "./unsupportedserial.w"
  1839. class UnsupportedSerialDeviceConfWidget:public BasicDeviceConfigurationWidget
  1840. {
  1841. Q_OBJECT
  1842. public:
  1843. Q_INVOKABLE UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  1844. const QModelIndex&index);
  1845. private slots:
  1846. void updateConfiguration();
  1847. void saveScript();
  1848. void addChannel();
  1849. private:
  1850. SaltModel*deviceSettingsModel;
  1851. QTextEdit*scriptEditor;
  1852. };
  1853. /*:908*//*913:*/
  1854. #line 166 "./unsupportedserial.w"
  1855. class UnsupportedDeviceChannelConfWidget:public BasicDeviceConfigurationWidget
  1856. {
  1857. Q_OBJECT
  1858. public:
  1859. Q_INVOKABLE UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  1860. const QModelIndex&index);
  1861. private slots:
  1862. void updateColumnName(const QString&value);
  1863. void updateHidden(bool hidden);
  1864. void updateConfiguration();
  1865. private:
  1866. SaltModel*channelSettingsModel;
  1867. };
  1868. /*:913*//*918:*/
  1869. #line 298 "./unsupportedserial.w"
  1870. class JavaScriptDevice:public QObject
  1871. {
  1872. Q_OBJECT
  1873. public:
  1874. Q_INVOKABLE JavaScriptDevice(const QModelIndex&deviceIndex,
  1875. QScriptEngine*engine);
  1876. Q_INVOKABLE int channelCount();
  1877. Channel*getChannel(int channel);
  1878. Q_INVOKABLE bool isChannelHidden(int channel);
  1879. Q_INVOKABLE Units::Unit expectedChannelUnit(int channel);
  1880. Q_INVOKABLE QString channelColumnName(int channel);
  1881. Q_INVOKABLE QString channelIndicatorText(int channel);
  1882. public slots:
  1883. void setTemperatureColumn(int tcol);
  1884. void setAnnotationColumn(int ncol);
  1885. void start();
  1886. void stop();
  1887. signals:
  1888. void annotation(QString note,int tcol,int ncol);
  1889. void triggerStartBatch();
  1890. void triggerStopBatch();
  1891. void deviceStopRequested();
  1892. private:
  1893. QVariantMap deviceSettings;
  1894. QString deviceScript;
  1895. QList<Channel*> channelList;
  1896. QList<bool> hiddenState;
  1897. QList<Units::Unit> channelUnits;
  1898. QList<QString> columnNames;
  1899. QList<QString> indicatorTexts;
  1900. QList<QVariantMap> channelSettings;
  1901. int annotationTemperatureColumn;
  1902. int annotationNoteColumn;
  1903. QScriptEngine*scriptengine;
  1904. };
  1905. /*:918*//*940:*/
  1906. #line 11 "./phidgets.w"
  1907. class PhidgetsTemperatureSensorConfWidget:public BasicDeviceConfigurationWidget
  1908. {
  1909. Q_OBJECT
  1910. public:
  1911. Q_INVOKABLE PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  1912. const QModelIndex&index);
  1913. private slots:
  1914. void addChannel();
  1915. void updateRate(int ms);
  1916. };
  1917. /*:940*//*944:*/
  1918. #line 82 "./phidgets.w"
  1919. class PhidgetTemperatureSensorChannelConfWidget:public BasicDeviceConfigurationWidget
  1920. {
  1921. Q_OBJECT
  1922. public:
  1923. Q_INVOKABLE PhidgetTemperatureSensorChannelConfWidget(DeviceTreeModel*model,
  1924. const QModelIndex&index);
  1925. private slots:
  1926. void updateColumnName(const QString&value);
  1927. void updateHidden(bool hidden);
  1928. void updateTC(int index);
  1929. void updateChannel(int channel);
  1930. private:
  1931. QComboBox*tcType;
  1932. };
  1933. /*:944*//*949:*/
  1934. #line 213 "./phidgets.w"
  1935. class PhidgetsTemperatureSensor:public QObject
  1936. {
  1937. Q_OBJECT
  1938. public:
  1939. Q_INVOKABLE PhidgetsTemperatureSensor(const QModelIndex&deviceIndex);
  1940. Q_INVOKABLE int channelCount();
  1941. Channel*getChannel(int channel);
  1942. Q_INVOKABLE bool isChannelHidden(int channel);
  1943. Q_INVOKABLE QString channelColumnName(int channel);
  1944. Q_INVOKABLE QString channelIndicatorText(int channel);
  1945. public slots:
  1946. void start();
  1947. void stop();
  1948. private slots:
  1949. void getMeasurements();
  1950. private:
  1951. QList<int> channelIndices;
  1952. QList<int> tctypes;
  1953. QList<Channel*> channelList;
  1954. QMap<int,Channel*> channelMap;
  1955. QList<bool> hiddenState;
  1956. QList<QString> columnNames;
  1957. QList<QString> indicatorTexts;
  1958. QLibrary driver;
  1959. QTimer sampleTimer;
  1960. void*device;
  1961. /*953:*/
  1962. #line 349 "./phidgets.w"
  1963. #ifdef _WIN32
  1964. typedef int(__stdcall*PhidgetHandleOnly)(void*);
  1965. typedef int(__stdcall*PhidgetHandleInt)(void*,int);
  1966. typedef int(__stdcall*PhidgetHandleIntInt)(void*,int,int);
  1967. typedef int(__stdcall*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1968. #else
  1969. typedef int(*PhidgetHandleOnly)(void*);
  1970. typedef int(*PhidgetHandleInt)(void*,int);
  1971. typedef int(*PhidgetHandleIntInt)(void*,int,int);
  1972. typedef int(*PhidgetHandleIntDoubleOut)(void*,int,double*);
  1973. #endif
  1974. PhidgetHandleOnly createDevice;
  1975. PhidgetHandleInt openDevice;
  1976. PhidgetHandleInt waitForOpen;
  1977. PhidgetHandleIntInt setTCType;
  1978. PhidgetHandleIntDoubleOut getTemperature;
  1979. PhidgetHandleOnly closeDevice;
  1980. PhidgetHandleOnly deleteDevice;
  1981. /*:953*/
  1982. #line 240 "./phidgets.w"
  1983. };
  1984. /*:949*//*964:*/
  1985. #line 46 "./phidget22.w"
  1986. class PhidgetConfWidget:public BasicDeviceConfigurationWidget
  1987. {
  1988. Q_OBJECT
  1989. public:
  1990. Q_INVOKABLE PhidgetConfWidget(DeviceTreeModel*model,
  1991. const QModelIndex&index);
  1992. private slots:
  1993. void addChannel();
  1994. };
  1995. /*:964*//*966:*/
  1996. #line 96 "./phidget22.w"
  1997. class PhidgetChannelSelector:public QComboBox
  1998. {
  1999. Q_OBJECT
  2000. public:
  2001. PhidgetChannelSelector();
  2002. ~PhidgetChannelSelector();
  2003. void addChannel(void*device);
  2004. void removeChannel(void*device);
  2005. private:
  2006. QLibrary driver;
  2007. void*manager;
  2008. /*968:*/
  2009. #line 141 "./phidget22.w"
  2010. PhidgetPointer createManager;
  2011. PhidgetPointerCallbackPointer setOnAttachManager;
  2012. PhidgetPointerCallbackPointer setOnDetachManager;
  2013. PhidgetPointer openManager;
  2014. PhidgetPointerStringOut getDeviceName;
  2015. PhidgetPointerIntOut getDeviceSerialNumber;
  2016. PhidgetPointerIntOut getChannel;
  2017. PhidgetPointerIntOut getChannelClass;
  2018. PhidgetPointerIntOut getChannelSubclass;
  2019. PhidgetPointerIntOut getHubPort;
  2020. PhidgetPointer closeManager;
  2021. PhidgetPointer deleteManager;
  2022. /*:968*/
  2023. #line 108 "./phidget22.w"
  2024. };
  2025. /*:966*//*976:*/
  2026. #line 298 "./phidget22.w"
  2027. class PhidgetChannelConfWidget:public BasicDeviceConfigurationWidget
  2028. {
  2029. Q_OBJECT
  2030. public:
  2031. Q_INVOKABLE PhidgetChannelConfWidget(DeviceTreeModel*model,
  2032. const QModelIndex&index);
  2033. public slots:
  2034. void changeSelectedChannel(int index);
  2035. void updateSerialNumber(const QString&value);
  2036. void updateChannel(const QString&value);
  2037. void updateHubPort(const QString&value);
  2038. void updateColumnName(const QString&value);
  2039. void updateChannelType(int value);
  2040. void updateTCType(int value);
  2041. void updateRTDType(int value);
  2042. void updateRTDWiring(int value);
  2043. void updateHidden(int value);
  2044. private:
  2045. PhidgetChannelSelector*channelSelector;
  2046. QLineEdit*serialNumber;
  2047. QLineEdit*channel;
  2048. QLineEdit*hubPort;
  2049. QComboBox*subtype;
  2050. QStackedLayout*subtypeLayout;
  2051. QComboBox*tctype;
  2052. QComboBox*rtdtype;
  2053. QComboBox*rtdwiring;
  2054. };
  2055. /*:976*//*980:*/
  2056. #line 538 "./phidget22.w"
  2057. struct PhidgetChannelData
  2058. {
  2059. Channel*channel;
  2060. QString columnName;
  2061. QString indicatorLabel;
  2062. int serialNumber;
  2063. int channelNumber;
  2064. int channelType;
  2065. int hubPort;
  2066. int tcType;
  2067. int rtdType;
  2068. int wiring;
  2069. bool hidden;
  2070. void*device;
  2071. };
  2072. /*:980*//*981:*/
  2073. #line 559 "./phidget22.w"
  2074. class Phidget22:public QObject
  2075. {
  2076. Q_OBJECT
  2077. public:
  2078. Q_INVOKABLE Phidget22(const QModelIndex&deviceIndex);
  2079. Q_INVOKABLE int channelCount();
  2080. Channel*getChannel(int channel);
  2081. Q_INVOKABLE bool isChannelHidden(int channel);
  2082. Q_INVOKABLE QString channelColumnName(int channel);
  2083. Q_INVOKABLE QString channelIndicatorText(int channel);
  2084. public slots:
  2085. void start();
  2086. void stop();
  2087. private:
  2088. QList<PhidgetChannelData*> channelConfiguration;
  2089. QLibrary driver;
  2090. PhidgetPointer p_createTemperatureSensor;
  2091. PhidgetPointerIntIn p_setSerialNumber;
  2092. PhidgetPointerIntIn p_setChannelNumber;
  2093. PhidgetPointerIntIn p_setHubPort;
  2094. PhidgetPointerIntIn p_setTCType;
  2095. PhidgetPointerIntIn p_setRTDType;
  2096. PhidgetPointerIntIn p_setRTDWiring;
  2097. PhidgetPointerVCPointer p_setNewDataCallback;
  2098. PhidgetPointerIntIn p_open;
  2099. PhidgetPointer p_close;
  2100. PhidgetPointer p_delete;
  2101. };
  2102. /*:981*//*994:*/
  2103. #line 19667 "./typica.w"
  2104. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  2105. {
  2106. Q_OBJECT
  2107. public:
  2108. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  2109. const QModelIndex&index);
  2110. private slots:
  2111. void updateSourceColumn(const QString&source);
  2112. void updateDestinationColumn(const QString&dest);
  2113. void updateKnots();
  2114. private:
  2115. SaltModel*tablemodel;
  2116. };
  2117. /*:994*//*1000:*/
  2118. #line 19797 "./typica.w"
  2119. class CoolingTimerConfWidget:public BasicDeviceConfigurationWidget
  2120. {
  2121. Q_OBJECT
  2122. public:
  2123. Q_INVOKABLE CoolingTimerConfWidget(DeviceTreeModel*model,
  2124. const QModelIndex&index);
  2125. private slots:
  2126. void updateResetTime(QTime time);
  2127. };
  2128. /*:1000*//*1004:*/
  2129. #line 19863 "./typica.w"
  2130. class RangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2131. {
  2132. Q_OBJECT
  2133. public:
  2134. Q_INVOKABLE RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2135. private slots:
  2136. void updateStartButtonText(const QString&text);
  2137. void updateStopButtonText(const QString&text);
  2138. void updateStartColumnName(const QString&text);
  2139. void updateStopColumnName(const QString&text);
  2140. void updateStartValue(const QString&text);
  2141. void updateStopValue(const QString&text);
  2142. void updateStartTrigger(int option);
  2143. void updateStopTrigger(int option);
  2144. };
  2145. /*:1004*//*1009:*/
  2146. #line 20115 "./typica.w"
  2147. class MultiRangeTimerConfWidget:public BasicDeviceConfigurationWidget
  2148. {
  2149. Q_OBJECT
  2150. public:
  2151. Q_INVOKABLE MultiRangeTimerConfWidget(DeviceTreeModel*model,
  2152. const QModelIndex&index);
  2153. private slots:
  2154. void updateColumnName(const QString&text);
  2155. void updateRangeData();
  2156. private:
  2157. SaltModel*tablemodel;
  2158. };
  2159. /*:1009*//*1014:*/
  2160. #line 20217 "./typica.w"
  2161. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  2162. {
  2163. Q_OBJECT
  2164. public:
  2165. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2166. private slots:
  2167. void updateMatchingColumn(const QString&column);
  2168. void updateTemperature();
  2169. void updateDelay();
  2170. private:
  2171. QDoubleSpinBox*temperatureValue;
  2172. QComboBox*unitSelector;
  2173. QSpinBox*delaySelector;
  2174. };
  2175. /*:1014*//*1018:*/
  2176. #line 16 "./rate.w"
  2177. class RateOfChange:public QObject
  2178. {
  2179. Q_OBJECT
  2180. public:
  2181. RateOfChange(int cachetime= 1,int scaletime= 1);
  2182. public slots:
  2183. void newMeasurement(Measurement measure);
  2184. void setCacheTime(int seconds);
  2185. void setScaleTime(int seconds);
  2186. signals:
  2187. void newData(Measurement measure);
  2188. private:
  2189. int ct;
  2190. int st;
  2191. QList<Measurement> cache;
  2192. };
  2193. /*:1018*//*1026:*/
  2194. #line 177 "./rate.w"
  2195. class RateOfChangeConfWidget:public BasicDeviceConfigurationWidget
  2196. {
  2197. Q_OBJECT
  2198. public:
  2199. Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  2200. private slots:
  2201. void updateColumn(const QString&column);
  2202. void updateCacheTime(const QString&seconds);
  2203. void updateScaleTime(const QString&seconds);
  2204. };
  2205. /*:1026*//*1032:*/
  2206. #line 15 "./mergeseries.w"
  2207. class MergeSeries:public QObject
  2208. {
  2209. Q_OBJECT
  2210. public:
  2211. MergeSeries();
  2212. public slots:
  2213. void in1(Measurement measure);
  2214. void in2(Measurement measure);
  2215. signals:
  2216. void newData(Measurement measure);
  2217. protected:
  2218. virtual void calculate(Measurement m1,Measurement m2)= 0;
  2219. private:
  2220. Measurement last1;
  2221. Measurement last2;
  2222. bool received1;
  2223. bool received2;
  2224. };
  2225. class DifferenceSeries:public MergeSeries
  2226. {
  2227. Q_OBJECT
  2228. public:
  2229. DifferenceSeries();
  2230. protected:
  2231. void calculate(Measurement m1,Measurement m2);
  2232. };
  2233. class MeanSeries:public MergeSeries
  2234. {
  2235. Q_OBJECT
  2236. public:
  2237. MeanSeries();
  2238. protected:
  2239. void calculate(Measurement m1,Measurement m2);
  2240. };
  2241. /*:1032*//*1040:*/
  2242. #line 167 "./mergeseries.w"
  2243. class MergeSeriesConfWidget:public BasicDeviceConfigurationWidget
  2244. {
  2245. Q_OBJECT
  2246. public:
  2247. Q_INVOKABLE MergeSeriesConfWidget(DeviceTreeModel*model,
  2248. const QModelIndex&index);
  2249. private slots:
  2250. void updateColumn1(const QString&column);
  2251. void updateColumn2(const QString&column);
  2252. void updateOutput(const QString&column);
  2253. void updateType(int type);
  2254. };
  2255. /*:1040*//*1046:*/
  2256. #line 19 "./dataqsdk.w"
  2257. class DataqSdkDeviceImplementation;
  2258. class DataqSdkDevice:public QObject
  2259. {
  2260. Q_OBJECT
  2261. DataqSdkDeviceImplementation*imp;
  2262. private slots:
  2263. void threadFinished();
  2264. public:
  2265. DataqSdkDevice(QString device);
  2266. ~DataqSdkDevice();
  2267. Channel*newChannel(Units::Unit scale);
  2268. Q_INVOKABLE void setClockRate(double Hz);
  2269. Q_INVOKABLE void start();
  2270. static QStringList detectPorts();
  2271. static QStringList detectHardware();
  2272. };
  2273. /*:1046*//*1047:*/
  2274. #line 49 "./dataqsdk.w"
  2275. class DataqSdkDeviceImplementation:public QThread
  2276. {
  2277. Q_OBJECT
  2278. public:
  2279. DataqSdkDeviceImplementation();
  2280. ~DataqSdkDeviceImplementation();
  2281. void run();
  2282. /*1048:*/
  2283. #line 70 "./dataqsdk.w"
  2284. typedef struct di_inlist_struct{
  2285. unsigned short chan;
  2286. unsigned short diff;
  2287. unsigned short gain;
  2288. unsigned short unipolar;
  2289. unsigned short dig_out_enable;
  2290. unsigned short dig_out;
  2291. unsigned short ave;
  2292. unsigned short counter;
  2293. }DI_INLIST_STRUCT;
  2294. typedef int(PASCAL*FPDIOPEN)(unsigned);
  2295. typedef int(PASCAL*FPDICLOSE)(void);
  2296. typedef double(PASCAL*FPDISAMPLERATE)(double,long*,long*);
  2297. typedef double(PASCAL*FPDIMAXIMUMRATE)(double);
  2298. typedef int(PASCAL*FPDILISTLENGTH)(unsigned,unsigned);
  2299. typedef int(PASCAL*FPDIINLIST)(di_inlist_struct*);
  2300. typedef int*(PASCAL*FPDIBUFFERALLOC)(unsigned,unsigned);
  2301. typedef int(PASCAL*FPDISTARTSCAN)(void);
  2302. typedef unsigned(PASCAL*FPDISTATUSREAD)(short*,unsigned);
  2303. typedef unsigned(PASCAL*FPDIBUFFERSTATUS)(unsigned);
  2304. typedef int(PASCAL*FPDIBURSTRATE)(unsigned);
  2305. typedef int(PASCAL*FPDISTOPSCAN)(void);
  2306. FPDIOPEN di_open;
  2307. FPDICLOSE di_close;
  2308. FPDISAMPLERATE di_sample_rate;
  2309. FPDIMAXIMUMRATE di_maximum_rate;
  2310. FPDILISTLENGTH di_list_length;
  2311. FPDIINLIST di_inlist;
  2312. FPDIBUFFERALLOC di_buffer_alloc;
  2313. FPDISTARTSCAN di_start_scan;
  2314. FPDISTATUSREAD di_status_read;
  2315. FPDIBUFFERSTATUS di_buffer_status;
  2316. FPDIBURSTRATE di_burst_rate;
  2317. FPDISTOPSCAN di_stop_scan;
  2318. /*:1048*/
  2319. #line 57 "./dataqsdk.w"
  2320. /*1050:*/
  2321. #line 134 "./dataqsdk.w"
  2322. bool isOpen;
  2323. double sampleRate;
  2324. long oversample;
  2325. long burstDivisor;
  2326. QString device;
  2327. unsigned deviceNumber;
  2328. QVector<Channel*> channelMap;
  2329. int error;
  2330. int channels;
  2331. bool ready;
  2332. QLibrary*driver;
  2333. QVector<Units::Unit> unitMap;
  2334. int*input_buffer;
  2335. QTimer*eventClock;
  2336. QMultiMap<int,double> smoother;
  2337. /*:1050*/
  2338. #line 58 "./dataqsdk.w"
  2339. public slots:
  2340. void measure();
  2341. private:
  2342. qint16*buffer;
  2343. };
  2344. /*:1047*//*1067:*/
  2345. #line 663 "./dataqsdk.w"
  2346. class DataqSdkDeviceConfWidget:public BasicDeviceConfigurationWidget
  2347. {
  2348. Q_OBJECT
  2349. public:
  2350. Q_INVOKABLE DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  2351. const QModelIndex&index);
  2352. private slots:
  2353. void updateAutoSelect(bool automatic);
  2354. void updateDeviceNumber(int deviceNumber);
  2355. void updatePort(QString portId);
  2356. void addChannel();
  2357. private:
  2358. QStackedWidget*deviceIdStack;
  2359. };
  2360. /*:1067*//*1072:*/
  2361. #line 808 "./dataqsdk.w"
  2362. class DataqSdkChannelConfWidget:public BasicDeviceConfigurationWidget
  2363. {
  2364. Q_OBJECT
  2365. public:
  2366. Q_INVOKABLE DataqSdkChannelConfWidget(DeviceTreeModel*model,
  2367. const QModelIndex&index);
  2368. private slots:
  2369. void updateUnits(const QString&unit);
  2370. void updateColumnName(const QString&value);
  2371. void updateMeasuredLower(const QString&value);
  2372. void updateMeasuredUpper(const QString&value);
  2373. void updateMappedLower(const QString&value);
  2374. void updateMappedUpper(const QString&value);
  2375. void updateClosedInterval(bool closed);
  2376. void updateSmoothingEnabled(bool enabled);
  2377. void updateSensitivity(const QString&value);
  2378. void startCalibration();
  2379. void stopCalibration();
  2380. void resetCalibration();
  2381. void updateInput(Measurement measure);
  2382. void updateOutput(Measurement measure);
  2383. void updateHidden(bool hidden);
  2384. private:
  2385. QPushButton*startButton;
  2386. QPushButton*resetButton;
  2387. QPushButton*stopButton;
  2388. /*1077:*/
  2389. #line 1098 "./dataqsdk.w"
  2390. bool autoSelect;
  2391. QString deviceID;
  2392. unsigned int channelOfInterest;
  2393. /*:1077*/
  2394. #line 835 "./dataqsdk.w"
  2395. DataqSdkDevice*calibrationDevice;
  2396. LinearCalibrator*calibrator;
  2397. QLineEdit*currentMeasurement;
  2398. QLineEdit*minimumMeasurement;
  2399. QLineEdit*maximumMeasurement;
  2400. QLineEdit*averageMeasurement;
  2401. QLineEdit*currentMapped;
  2402. QLineEdit*minimumMapped;
  2403. QLineEdit*maximumMapped;
  2404. QLineEdit*averageMapped;
  2405. int rmCount;
  2406. int cmCount;
  2407. double rmin;
  2408. double rmax;
  2409. double rmean;
  2410. double cmin;
  2411. double cmax;
  2412. double cmean;
  2413. };
  2414. /*:1072*//*1099:*/
  2415. #line 273 "./scales.w"
  2416. Q_DECLARE_METATYPE(BaudRateType)
  2417. Q_DECLARE_METATYPE(DataBitsType)
  2418. Q_DECLARE_METATYPE(ParityType)
  2419. Q_DECLARE_METATYPE(StopBitsType)
  2420. Q_DECLARE_METATYPE(FlowType)
  2421. /*:1099*//*1106:*/
  2422. #line 396 "./scales.w"
  2423. class SerialScaleConfWidget:public BasicDeviceConfigurationWidget
  2424. {
  2425. Q_OBJECT
  2426. public:
  2427. Q_INVOKABLE SerialScaleConfWidget(DeviceTreeModel*model,
  2428. const QModelIndex&index);
  2429. private slots:
  2430. void updatePort(const QString&newPort);
  2431. void updateBaudRate(const QString&rate);
  2432. void updateParity(int index);
  2433. void updateFlowControl(int index);
  2434. void updateStopBits(int index);
  2435. void updateWeighCommand(const QString&command);
  2436. void updateCommandTerminator(const QString&terminator);
  2437. private:
  2438. PortSelector*port;
  2439. BaudSelector*baud;
  2440. ParitySelector*parity;
  2441. FlowSelector*flow;
  2442. StopSelector*stop;
  2443. QLineEdit*weighcommand;
  2444. QComboBox*commandterminator;
  2445. };
  2446. /*:1106*//*1111:*/
  2447. #line 14 "./valueannotation.w"
  2448. class ValueAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2449. {
  2450. Q_OBJECT
  2451. public:
  2452. Q_INVOKABLE ValueAnnotationConfWidget(DeviceTreeModel*model,
  2453. const QModelIndex&index);
  2454. private slots:
  2455. void updateSourceColumn(const QString&source);
  2456. void updateAnnotations();
  2457. void updateStart(bool noteOnStart);
  2458. private:
  2459. SaltModel*tablemodel;
  2460. };
  2461. /*:1111*//*1119:*/
  2462. #line 165 "./valueannotation.w"
  2463. class ValueAnnotation:public QObject
  2464. {
  2465. Q_OBJECT
  2466. public:
  2467. ValueAnnotation();
  2468. Q_INVOKABLE void setAnnotation(double value,const QString&annotation);
  2469. public slots:
  2470. void newMeasurement(Measurement measure);
  2471. void annotate();
  2472. void setAnnotationColumn(int column);
  2473. void setTemperatureColumn(int column);
  2474. void setTolerance(double epsilon);
  2475. signals:
  2476. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2477. private:
  2478. int lastIndex;
  2479. int annotationColumn;
  2480. int measurementColumn;
  2481. QList<double> values;
  2482. QStringList annotations;
  2483. double tolerance;
  2484. };
  2485. /*:1119*//*1128:*/
  2486. #line 14 "./thresholdannotation.w"
  2487. class ThresholdAnnotationConfWidget:public BasicDeviceConfigurationWidget
  2488. {
  2489. Q_OBJECT
  2490. public:
  2491. Q_INVOKABLE ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  2492. const QModelIndex&index);
  2493. private slots:
  2494. void updateSourceColumn(const QString&source);
  2495. void updateThreshold(double value);
  2496. void updateDirection(int index);
  2497. void updateAnnotation(const QString&note);
  2498. };
  2499. /*:1128*//*1133:*/
  2500. #line 127 "./thresholdannotation.w"
  2501. class Annotator:public QObject
  2502. {
  2503. Q_OBJECT
  2504. QString note;
  2505. int tc;
  2506. int ac;
  2507. QTimer t;
  2508. public:
  2509. Annotator(const QString&text);
  2510. public slots:
  2511. void setAnnotation(const QString&annotation);
  2512. void setTemperatureColumn(int tempcolumn);
  2513. void setAnnotationColumn(int annotationcolumn);
  2514. void annotate();
  2515. private slots:
  2516. void catchTimer();
  2517. signals:
  2518. void annotation(QString annotation,int tempcolumn,int notecolumn);
  2519. };
  2520. /*:1133*//*1144:*/
  2521. #line 78 "./user.w"
  2522. class LoginDialog:public QDialog
  2523. {
  2524. Q_OBJECT
  2525. public:
  2526. LoginDialog();
  2527. public slots:
  2528. void attemptLogin();
  2529. private:
  2530. QLineEdit*user;
  2531. QLineEdit*password;
  2532. QLabel*warning;
  2533. QPushButton*login;
  2534. };
  2535. /*:1144*//*1150:*/
  2536. #line 162 "./user.w"
  2537. class UserLabel:public QLabel
  2538. {
  2539. Q_OBJECT
  2540. public:
  2541. UserLabel();
  2542. public slots:
  2543. void updateLabel(const QString&user);
  2544. protected:
  2545. void mouseReleaseEvent(QMouseEvent*event);
  2546. };
  2547. /*:1150*//*1154:*/
  2548. #line 209 "./user.w"
  2549. class NewTypicaUser:public QDialog
  2550. {
  2551. Q_OBJECT
  2552. public:
  2553. NewTypicaUser();
  2554. public slots:
  2555. void createAndReset();
  2556. void createAndClose();
  2557. void validate();
  2558. void cancelValidate();
  2559. private:
  2560. void createNewUser();
  2561. QLineEdit*userField;
  2562. QLineEdit*passwordField;
  2563. QCheckBox*autoLogin;
  2564. QPushButton*saveAndCloseButton;
  2565. QPushButton*saveAndNewButton;
  2566. QPushButton*cancelButton;
  2567. };
  2568. /*:1154*/
  2569. #line 528 "./typica.w"
  2570. /*971:*/
  2571. #line 203 "./phidget22.w"
  2572. void CCONV ChannelListAddChannel(void*,void*context,void*device)
  2573. {
  2574. PhidgetChannelSelector*list=
  2575. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2576. list->addChannel(device);
  2577. }
  2578. void CCONV ChannelListRemoveChannel(void*,void*context,void*device)
  2579. {
  2580. PhidgetChannelSelector*list=
  2581. qobject_cast<PhidgetChannelSelector*> ((QObject*)context);
  2582. list->removeChannel(device);
  2583. }
  2584. /*:971*//*986:*/
  2585. #line 762 "./phidget22.w"
  2586. void CCONV Phidget22ValueCallback(void*,void*context,double value)
  2587. {
  2588. Channel*channel= (Channel*)context;
  2589. QTime time= QTime::currentTime();
  2590. Measurement measure(value*9.0/5.0+32.0,time);
  2591. channel->input(measure);
  2592. }
  2593. /*:986*/
  2594. #line 529 "./typica.w"
  2595. /*12:*/
  2596. #line 819 "./typica.w"
  2597. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  2598. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*engine);
  2599. /*:12*//*14:*/
  2600. #line 844 "./typica.w"
  2601. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2602. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  2603. /*:14*//*19:*/
  2604. #line 904 "./typica.w"
  2605. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2606. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  2607. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  2608. QScriptValue QWidget_activateWindow(QScriptContext*context,
  2609. QScriptEngine*engine);
  2610. /*:19*//*23:*/
  2611. #line 994 "./typica.w"
  2612. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*engine);
  2613. QScriptValue displayError(QScriptContext*context,QScriptEngine*engine);
  2614. /*:23*//*33:*/
  2615. #line 1218 "./typica.w"
  2616. QScriptValue constructQMainWindow(QScriptContext*context,
  2617. QScriptEngine*engine);
  2618. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  2619. QScriptEngine*engine);
  2620. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  2621. QScriptEngine*engine);
  2622. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  2623. /*:33*//*38:*/
  2624. #line 1317 "./typica.w"
  2625. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  2626. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  2627. /*:38*//*41:*/
  2628. #line 1362 "./typica.w"
  2629. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  2630. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  2631. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  2632. /*:41*//*44:*/
  2633. #line 1428 "./typica.w"
  2634. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  2635. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  2636. /*:44*//*47:*/
  2637. #line 1461 "./typica.w"
  2638. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  2639. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  2640. /*:47*//*50:*/
  2641. #line 1499 "./typica.w"
  2642. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine);
  2643. QScriptValue constructQSvgWidget(QScriptContext*context,
  2644. QScriptEngine*engine);
  2645. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,
  2646. QScriptEngine*engine);
  2647. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2648. QStack<QLayout*> *layoutStack);
  2649. /*:50*//*56:*/
  2650. #line 1586 "./typica.w"
  2651. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine);
  2652. QScriptValue constructQLineEdit(QScriptContext*context,QScriptEngine*engine);
  2653. /*:56*//*60:*/
  2654. #line 1625 "./typica.w"
  2655. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  2656. QScriptValue QSplitter_addWidget(QScriptContext*context,
  2657. QScriptEngine*engine);
  2658. QScriptValue QSplitter_saveState(QScriptContext*context,
  2659. QScriptEngine*engine);
  2660. QScriptValue QSplitter_restoreState(QScriptContext*context,
  2661. QScriptEngine*engine);
  2662. QScriptValue QSplitter_count(QScriptContext*context,
  2663. QScriptEngine*engine);
  2664. QScriptValue QSplitter_setCollapsible(QScriptContext*context,
  2665. QScriptEngine*engine);
  2666. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  2667. /*:60*//*67:*/
  2668. #line 1786 "./typica.w"
  2669. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2670. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2671. /*:67*//*69:*/
  2672. #line 1841 "./typica.w"
  2673. QScriptValue constructQBoxLayout(QScriptContext*context,
  2674. QScriptEngine*engine);
  2675. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  2676. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  2677. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  2678. /*:69*//*73:*/
  2679. #line 1954 "./typica.w"
  2680. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  2681. QScriptValue QAction_setShortcut(QScriptContext*context,
  2682. QScriptEngine*engine);
  2683. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  2684. /*:73*//*76:*/
  2685. #line 2010 "./typica.w"
  2686. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  2687. QScriptEngine*engine);
  2688. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  2689. QScriptEngine*engine);
  2690. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  2691. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  2692. /*:76*//*81:*/
  2693. #line 2121 "./typica.w"
  2694. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  2695. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  2696. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  2697. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  2698. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  2699. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  2700. QScriptValue QIODevice_readToString(QScriptContext*context,
  2701. QScriptEngine*engine);
  2702. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*engine);
  2703. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*engine);
  2704. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*engine);
  2705. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine);
  2706. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine);
  2707. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine);
  2708. /*:81*//*92:*/
  2709. #line 2347 "./typica.w"
  2710. QScriptValue constructQProcess(QScriptContext*context,QScriptEngine*engine);
  2711. void setQProcessProperties(QScriptValue value,QScriptEngine*engine);
  2712. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*engine);
  2713. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*engine);
  2714. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*engine);
  2715. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*engine);
  2716. /*:92*//*100:*/
  2717. #line 2465 "./typica.w"
  2718. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes);
  2719. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes);
  2720. QScriptValue constructQByteArray(QScriptContext*context,QScriptEngine*engine);
  2721. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine);
  2722. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine);
  2723. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*engine);
  2724. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*engine);
  2725. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine);
  2726. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine);
  2727. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*engine);
  2728. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine);
  2729. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine);
  2730. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine);
  2731. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*engine);
  2732. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine);
  2733. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*engine);
  2734. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*engine);
  2735. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*engine);
  2736. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*engine);
  2737. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*engine);
  2738. /*:100*//*113:*/
  2739. #line 2739 "./typica.w"
  2740. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine);
  2741. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine);
  2742. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine);
  2743. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine);
  2744. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine);
  2745. /*:113*//*116:*/
  2746. #line 2844 "./typica.w"
  2747. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  2748. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  2749. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  2750. /*:116*//*119:*/
  2751. #line 2889 "./typica.w"
  2752. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  2753. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2754. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  2755. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  2756. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2757. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  2758. /*:119*//*125:*/
  2759. #line 2971 "./typica.w"
  2760. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  2761. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  2762. QScriptEngine*engine);
  2763. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  2764. QScriptEngine*engine);
  2765. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  2766. QScriptEngine*engine);
  2767. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  2768. QScriptEngine*engine);
  2769. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  2770. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  2771. QScriptEngine*engine);
  2772. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  2773. QScriptEngine*engine);
  2774. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  2775. QScriptEngine*engine);
  2776. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  2777. QScriptEngine*engine);
  2778. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  2779. QScriptEngine*engine);
  2780. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  2781. QScriptEngine*engine);
  2782. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  2783. QScriptEngine*engine);
  2784. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  2785. QScriptEngine*engine);
  2786. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  2787. /*:125*//*134:*/
  2788. #line 3189 "./typica.w"
  2789. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  2790. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  2791. QScriptValue XmlReader_attribute(QScriptContext*context,
  2792. QScriptEngine*engine);
  2793. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  2794. QScriptEngine*engine);
  2795. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  2796. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  2797. QScriptEngine*engine);
  2798. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  2799. QScriptValue XmlReader_readElementText(QScriptContext*context,
  2800. QScriptEngine*engine);
  2801. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  2802. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  2803. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  2804. /*:134*//*141:*/
  2805. #line 3324 "./typica.w"
  2806. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  2807. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  2808. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  2809. /*:141*//*145:*/
  2810. #line 3406 "./typica.w"
  2811. QScriptValue constructQLCDNumber(QScriptContext*context,
  2812. QScriptEngine*engine);
  2813. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  2814. /*:145*//*148:*/
  2815. #line 3444 "./typica.w"
  2816. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  2817. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  2818. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  2819. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  2820. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  2821. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  2822. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  2823. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  2824. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  2825. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  2826. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  2827. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  2828. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  2829. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  2830. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  2831. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  2832. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  2833. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  2834. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  2835. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  2836. /*:148*//*164:*/
  2837. #line 3922 "./typica.w"
  2838. void setQAbstractScrollAreaProperties(QScriptValue value,
  2839. QScriptEngine*engine);
  2840. /*:164*//*166:*/
  2841. #line 3937 "./typica.w"
  2842. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  2843. /*:166*//*168:*/
  2844. #line 3950 "./typica.w"
  2845. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  2846. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  2847. /*:168*//*170:*/
  2848. #line 3974 "./typica.w"
  2849. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  2850. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  2851. QScriptValue constructQPushButton(QScriptContext*context,
  2852. QScriptEngine*engine);
  2853. /*:170*//*177:*/
  2854. #line 4073 "./typica.w"
  2855. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  2856. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  2857. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  2858. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  2859. QScriptEngine*engine);
  2860. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  2861. QScriptEngine*engine);
  2862. QScriptValue QSqlQuery_exec(QScriptContext*context,
  2863. QScriptEngine*engine);
  2864. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  2865. QScriptEngine*engine);
  2866. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  2867. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  2868. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  2869. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  2870. /*:177*//*184:*/
  2871. #line 4244 "./typica.w"
  2872. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  2873. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  2874. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  2875. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  2876. QScriptValue annotationFromRecord(QScriptContext*context,
  2877. QScriptEngine*engine);
  2878. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  2879. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*engine);
  2880. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*engine);
  2881. /*:184*//*197:*/
  2882. #line 4591 "./typica.w"
  2883. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  2884. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine);
  2885. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2886. QStack<QLayout*> *layoutStack);
  2887. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2888. QStack<QLayout*> *layoutStack);
  2889. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2890. QStack<QLayout*> *layoutStack);
  2891. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2892. QStack<QLayout*> *layoutStack);
  2893. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2894. QStack<QLayout*> *layoutStack);
  2895. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2896. QStack<QLayout*> *layoutStack);
  2897. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2898. QStack<QLayout*> *layoutStack);
  2899. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  2900. QStack<QLayout*> *layoutStack);
  2901. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2902. QStack<QLayout*> *layoutStack);
  2903. void addTemperatureDisplayToSplitter(QDomElement element,
  2904. QStack<QWidget*> *widgetStack,
  2905. QStack<QLayout*> *layoutStack);
  2906. void addTemperatureDisplayToLayout(QDomElement element,
  2907. QStack<QWidget*> *widgetStack,
  2908. QStack<QLayout*> *layoutStack);
  2909. void addTimerDisplayToSplitter(QDomElement element,
  2910. QStack<QWidget*> *widgetStack,
  2911. QStack<QLayout*> *layoutStack);
  2912. void addTimerDisplayToLayout(QDomElement element,
  2913. QStack<QWidget*> *widgetStack,
  2914. QStack<QLayout*> *layoutStack);
  2915. void addDecorationToSplitter(QDomElement element,
  2916. QStack<QWidget*> *widgetStack,
  2917. QStack<QLayout*> *layoutStack);
  2918. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2919. QStack<QLayout*> *layoutStack);
  2920. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2921. QStack<QLayout*> *layoutStack);
  2922. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2923. QStack<QLayout*> *layoutStack);
  2924. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2925. QStack<QLayout*> *layoutStack);
  2926. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  2927. QStack<QLayout*> *layoutStack);
  2928. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2929. QStack<QLayout*> *layoutStack);
  2930. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2931. QStack<QLayout*> *layoutStack);
  2932. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2933. QStack<QLayout*> *layoutStack);
  2934. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2935. QStack<QLayout*> *layoutStack);
  2936. void addSqlQueryViewToLayout(QDomElement element,
  2937. QStack<QWidget*> *widgetStack,
  2938. QStack<QLayout*> *layoutStack);
  2939. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2940. QStack<QLayout*> *layoutStack);
  2941. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2942. QStack<QLayout*> *layoutStack);
  2943. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2944. QStack<QLayout*> *layoutStack);
  2945. /*:197*//*226:*/
  2946. #line 5072 "./typica.w"
  2947. QScriptValue constructQTabBar(QScriptContext*context,QScriptEngine*engine);
  2948. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine);
  2949. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*engine);
  2950. /*:226*//*267:*/
  2951. #line 6371 "./typica.w"
  2952. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  2953. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2954. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  2955. QScriptEngine*engine);
  2956. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  2957. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  2958. QScriptEngine*engine);
  2959. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  2960. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*engine);
  2961. /*:267*//*270:*/
  2962. #line 6416 "./typica.w"
  2963. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  2964. /*:270*//*271:*/
  2965. #line 6424 "./typica.w"
  2966. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  2967. /*:271*//*275:*/
  2968. #line 6571 "./typica.w"
  2969. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  2970. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  2971. QScriptEngine*engine);
  2972. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  2973. QScriptEngine*engine);
  2974. QScriptValue SaltTable_columnSum(QScriptContext*context,
  2975. QScriptEngine*engine);
  2976. QScriptValue SaltTable_columnArray(QScriptContext*context,
  2977. QScriptEngine*engine);
  2978. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  2979. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  2980. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  2981. QScriptEngine*engine);
  2982. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  2983. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*engine);
  2984. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine);
  2985. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine);
  2986. /*:275*//*285:*/
  2987. #line 6787 "./typica.w"
  2988. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2989. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  2990. QScriptValue QComboBox_currentData(QScriptContext*context,
  2991. QScriptEngine*engine);
  2992. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  2993. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  2994. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  2995. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine);
  2996. /*:285*//*297:*/
  2997. #line 379 "./units.w"
  2998. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*engine);
  2999. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  3000. QScriptEngine*engine);
  3001. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*engine);
  3002. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*engine);
  3003. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*engine);
  3004. /*:297*//*301:*/
  3005. #line 443 "./units.w"
  3006. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value);
  3007. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value);
  3008. /*:301*//*310:*/
  3009. #line 133 "./measurement.w"
  3010. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine);
  3011. void setMeasurementProperties(QScriptValue value,QScriptEngine*engine);
  3012. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement);
  3013. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement);
  3014. /*:310*//*330:*/
  3015. #line 7422 "./typica.w"
  3016. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  3017. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3018. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  3019. /*:330*//*339:*/
  3020. #line 7627 "./typica.w"
  3021. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  3022. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  3023. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  3024. /*:339*//*344:*/
  3025. #line 7728 "./typica.w"
  3026. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  3027. /*:344*//*350:*/
  3028. #line 7910 "./typica.w"
  3029. QScriptValue constructLinearCalibrator(QScriptContext*context,
  3030. QScriptEngine*engine);
  3031. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  3032. /*:350*//*355:*/
  3033. #line 8050 "./typica.w"
  3034. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  3035. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  3036. /*:355*//*365:*/
  3037. #line 8255 "./typica.w"
  3038. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  3039. QScriptEngine*engine);
  3040. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3041. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,
  3042. QScriptEngine*engine);
  3043. /*:365*//*373:*/
  3044. #line 8414 "./typica.w"
  3045. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  3046. QScriptEngine*engine);
  3047. void setMeasurementTimeOffsetProperties(QScriptValue value,
  3048. QScriptEngine*engine);
  3049. /*:373*//*378:*/
  3050. #line 8537 "./typica.w"
  3051. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  3052. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  3053. /*:378*//*383:*/
  3054. #line 8635 "./typica.w"
  3055. QScriptValue constructZeroEmitter(QScriptContext*context,
  3056. QScriptEngine*engine);
  3057. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  3058. /*:383*//*388:*/
  3059. #line 8714 "./typica.w"
  3060. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  3061. QScriptEngine*engine);
  3062. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  3063. /*:388*//*405:*/
  3064. #line 9178 "./typica.w"
  3065. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  3066. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  3067. /*:405*//*428:*/
  3068. #line 9817 "./typica.w"
  3069. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  3070. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  3071. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  3072. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  3073. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  3074. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  3075. QScriptEngine*engine);
  3076. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  3077. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  3078. QScriptEngine*engnie);
  3079. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,
  3080. QScriptEngine*engine);
  3081. /*:428*//*466:*/
  3082. #line 10774 "./typica.w"
  3083. QScriptValue constructAnnotationButton(QScriptContext*context,
  3084. QScriptEngine*engine);
  3085. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  3086. /*:466*//*474:*/
  3087. #line 10914 "./typica.w"
  3088. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  3089. QScriptEngine*engine);
  3090. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3091. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3092. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  3093. /*:474*//*495:*/
  3094. #line 11340 "./typica.w"
  3095. QScriptValue constructTimerDisplay(QScriptContext*context,
  3096. QScriptEngine*engine);
  3097. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  3098. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*engine);
  3099. /*:495*//*523:*/
  3100. #line 11865 "./typica.w"
  3101. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  3102. QScriptValue constructWidgetDecorator(QScriptContext*context,
  3103. QScriptEngine*engine);
  3104. /*:523*//*536:*/
  3105. #line 12148 "./typica.w"
  3106. QScriptValue constructLogEditWindow(QScriptContext*context,
  3107. QScriptEngine*engine);
  3108. /*:536*//*555:*/
  3109. #line 12675 "./typica.w"
  3110. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  3111. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  3112. /*:555*//*574:*/
  3113. #line 204 "./webview.w"
  3114. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  3115. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  3116. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3117. QStack<QLayout*> *layoutStack);
  3118. /*:574*//*577:*/
  3119. #line 234 "./webview.w"
  3120. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element);
  3121. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element);
  3122. /*:577*//*581:*/
  3123. #line 292 "./webview.w"
  3124. QScriptValue constructWebElement(QScriptContext*context,
  3125. QScriptEngine*engine);
  3126. /*:581*//*593:*/
  3127. #line 67 "./printerselector.w"
  3128. QScriptValue constructPrinterSelector(QScriptContext*context,
  3129. QScriptEngine*engine);
  3130. void addPrinterSelectorToLayout(QDomElement element,
  3131. QStack<QWidget*> *widgetStack,
  3132. QStack<QLayout*> *layoutStack);
  3133. /*:593*//*660:*/
  3134. #line 14056 "./typica.w"
  3135. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  3136. QScriptValue constructSqlQueryView(QScriptContext*context,
  3137. QScriptEngine*engine);
  3138. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  3139. QScriptEngine*engine);
  3140. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  3141. QScriptEngine*engine);
  3142. /*:660*//*670:*/
  3143. #line 14295 "./typica.w"
  3144. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3145. QStack<QLayout*> *layoutStack);
  3146. /*:670*//*686:*/
  3147. #line 14580 "./typica.w"
  3148. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  3149. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  3150. /*:686*//*714:*/
  3151. #line 480 "./daterangeselector.w"
  3152. void addDateRangeToLayout(QDomElement element,
  3153. QStack<QWidget*> *widgetStack,
  3154. QStack<QLayout*> *layoutStack);
  3155. /*:714*//*723:*/
  3156. #line 14779 "./typica.w"
  3157. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  3158. QStack<QLayout*> *layoutStack);
  3159. /*:723*//*744:*/
  3160. #line 15363 "./typica.w"
  3161. void addScaleControlToLayout(QDomElement element,
  3162. QStack<QWidget*> *widgetStack,
  3163. QStack<QLayout*> *layoutStack);
  3164. void addIntensityControlToLayout(QDomElement element,
  3165. QStack<QWidget*> *widgetStack,
  3166. QStack<QLayout*> *layoutStack);
  3167. /*:744*//*770:*/
  3168. #line 15949 "./typica.w"
  3169. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  3170. QScriptEngine*engine);
  3171. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  3172. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  3173. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  3174. QScriptEngine*engine);
  3175. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  3176. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  3177. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  3178. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  3179. /*:770*//*776:*/
  3180. #line 16091 "./typica.w"
  3181. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  3182. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  3183. /*:776*//*792:*/
  3184. #line 16389 "./typica.w"
  3185. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  3186. QScriptEngine*engine);
  3187. /*:792*//*863:*/
  3188. #line 42 "./settings.w"
  3189. QScriptValue constructSettingsWindow(QScriptContext*context,QScriptEngine*engine);
  3190. /*:863*//*887:*/
  3191. #line 19032 "./typica.w"
  3192. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  3193. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  3194. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  3195. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3196. /*:887*//*905:*/
  3197. #line 698 "./modbus.w"
  3198. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine);
  3199. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine);
  3200. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine);
  3201. /*:905*//*919:*/
  3202. #line 345 "./unsupportedserial.w"
  3203. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine);
  3204. /*:919*//*925:*/
  3205. #line 425 "./unsupportedserial.w"
  3206. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine);
  3207. /*:925*//*931:*/
  3208. #line 617 "./unsupportedserial.w"
  3209. QScriptValue getMeasurementTimestamp(QScriptContext*context,QScriptEngine*engine);
  3210. /*:931*//*935:*/
  3211. #line 651 "./unsupportedserial.w"
  3212. QScriptValue constructSerialPort(QScriptContext*context,QScriptEngine*engine);
  3213. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine);
  3214. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*engine);
  3215. /*:935*//*959:*/
  3216. #line 457 "./phidgets.w"
  3217. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine);
  3218. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine);
  3219. /*:959*//*991:*/
  3220. #line 805 "./phidget22.w"
  3221. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine);
  3222. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine);
  3223. /*:991*//*1023:*/
  3224. #line 138 "./rate.w"
  3225. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine);
  3226. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine);
  3227. /*:1023*//*1037:*/
  3228. #line 129 "./mergeseries.w"
  3229. QScriptValue constructDifferenceSeries(QScriptContext*context,
  3230. QScriptEngine*engine);
  3231. QScriptValue constructMeanSeries(QScriptContext*context,
  3232. QScriptEngine*engine);
  3233. /*:1037*//*1062:*/
  3234. #line 597 "./dataqsdk.w"
  3235. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine);
  3236. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine);
  3237. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine);
  3238. /*:1062*//*1089:*/
  3239. #line 67 "./scales.w"
  3240. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine);
  3241. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine);
  3242. /*:1089*//*1097:*/
  3243. #line 259 "./scales.w"
  3244. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine);
  3245. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine);
  3246. /*:1097*//*1100:*/
  3247. #line 284 "./scales.w"
  3248. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value);
  3249. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value);
  3250. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value);
  3251. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value);
  3252. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value);
  3253. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value);
  3254. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value);
  3255. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value);
  3256. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value);
  3257. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value);
  3258. /*:1100*//*1125:*/
  3259. #line 265 "./valueannotation.w"
  3260. QScriptValue constructValueAnnotation(QScriptContext*context,QScriptEngine*engine);
  3261. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine);
  3262. /*:1125*//*1136:*/
  3263. #line 194 "./thresholdannotation.w"
  3264. QScriptValue constructAnnotator(QScriptContext*context,
  3265. QScriptEngine*engine);
  3266. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine);
  3267. /*:1136*//*1149:*/
  3268. #line 151 "./user.w"
  3269. QScriptValue constructLoginDialog(QScriptContext*context,QScriptEngine*engine);
  3270. /*:1149*//*1159:*/
  3271. #line 339 "./user.w"
  3272. QScriptValue constructNewTypicaUser(QScriptContext*context,QScriptEngine*engine);
  3273. /*:1159*/
  3274. #line 530 "./typica.w"
  3275. /*640:*/
  3276. #line 13698 "./typica.w"
  3277. void messageFileOutput(QtMsgType type,const char*msg);
  3278. /*:640*/
  3279. #line 531 "./typica.w"
  3280. /*4:*/
  3281. #line 540 "./typica.w"
  3282. /*784:*/
  3283. #line 16212 "./typica.w"
  3284. NodeInserter::NodeInserter(const QString&title,const QString&name,
  3285. const QString&driver,QObject*parent):
  3286. QAction(title,parent),defaultNodeName(name),driverString(driver)
  3287. {
  3288. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  3289. }
  3290. void NodeInserter::onTriggered()
  3291. {
  3292. emit triggered(defaultNodeName,driverString);
  3293. }
  3294. /*:784*/
  3295. #line 541 "./typica.w"
  3296. /*306:*/
  3297. #line 40 "./measurement.w"
  3298. Measurement::Measurement(double temperature,QTime time,Units::Unit sc)
  3299. {
  3300. insert("measurement",temperature);
  3301. insert("time",time);
  3302. insert("unit",sc);
  3303. }
  3304. Measurement::Measurement(double temperature)
  3305. {
  3306. insert("measurement",temperature);
  3307. insert("time",QTime::currentTime());
  3308. insert("unit",Units::Fahrenheit);
  3309. }
  3310. void Measurement::setTemperature(double temperature)
  3311. {
  3312. insert("measurement",temperature);
  3313. }
  3314. void Measurement::setTime(QTime time)
  3315. {
  3316. insert("time",time);
  3317. }
  3318. void Measurement::setUnit(Units::Unit scale)
  3319. {
  3320. insert("unit",scale);
  3321. }
  3322. double Measurement::temperature()const
  3323. {
  3324. return value("measurement").toDouble();
  3325. }
  3326. QTime Measurement::time()const
  3327. {
  3328. return value("time").toTime();
  3329. }
  3330. Units::Unit Measurement::scale()const
  3331. {
  3332. return(Units::Unit)(value("unit").toInt());
  3333. }
  3334. /*:306*//*307:*/
  3335. #line 88 "./measurement.w"
  3336. Measurement Measurement::toFahrenheit()
  3337. {
  3338. return Measurement(Units::convertTemperature(this->temperature(),
  3339. this->scale(),Units::Fahrenheit),
  3340. this->time(),Units::Fahrenheit);
  3341. }
  3342. Measurement Measurement::toCelsius()
  3343. {
  3344. return Measurement(Units::convertTemperature(this->temperature(),
  3345. this->scale(),Units::Celsius),
  3346. this->time(),Units::Celsius);
  3347. }
  3348. Measurement Measurement::toKelvin()
  3349. {
  3350. return Measurement(Units::convertTemperature(this->temperature(),
  3351. this->scale(),Units::Kelvin),
  3352. this->time(),Units::Kelvin);
  3353. }
  3354. Measurement Measurement::toRankine()
  3355. {
  3356. return Measurement(Units::convertTemperature(this->temperature(),
  3357. this->scale(),Units::Rankine),
  3358. this->time(),Units::Rankine);
  3359. }
  3360. /*:307*/
  3361. #line 542 "./typica.w"
  3362. /*320:*/
  3363. #line 7027 "./typica.w"
  3364. void DAQImplementation::measure()
  3365. {
  3366. int samplesRead= 0;
  3367. double buffer[channels];
  3368. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  3369. (unsigned long)(0),buffer,(unsigned long)(channels),
  3370. &samplesRead,(signed long)(0));
  3371. if(error)
  3372. {
  3373. ready= false;
  3374. }
  3375. else
  3376. {
  3377. if(samplesRead)
  3378. {
  3379. QTime time= QTime::currentTime();
  3380. for(int i= 0;i<samplesRead;i++)
  3381. {
  3382. for(int j= 0;j<channels;j++)
  3383. {
  3384. double measuredValue= buffer[j+(i*channels)];
  3385. Measurement measure(measuredValue,time,
  3386. unitMap[j]);
  3387. channelMap[j]->input(measure);
  3388. }
  3389. }
  3390. }
  3391. }
  3392. }
  3393. /*:320*//*321:*/
  3394. #line 7070 "./typica.w"
  3395. void DAQImplementation::run()
  3396. {
  3397. setPriority(QThread::TimeCriticalPriority);
  3398. while(ready)
  3399. {
  3400. measure();
  3401. }
  3402. }
  3403. /*:321*//*322:*/
  3404. #line 7086 "./typica.w"
  3405. void DAQ::threadFinished()
  3406. {
  3407. if(imp->error)
  3408. {
  3409. /*323:*/
  3410. #line 7137 "./typica.w"
  3411. imp->ready= false;
  3412. QMessageBox warning;
  3413. warning.setStandardButtons(QMessageBox::Cancel);
  3414. warning.setIcon(QMessageBox::Warning);
  3415. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3416. unsigned long bytes= imp->errorInfo(NULL,0);
  3417. char string[bytes];
  3418. imp->errorInfo(string,bytes);
  3419. warning.setInformativeText(QString(string));
  3420. warning.setWindowTitle(QString(PROGRAM_NAME));
  3421. warning.exec();
  3422. /*:323*/
  3423. #line 7091 "./typica.w"
  3424. }
  3425. }
  3426. /*:322*//*324:*/
  3427. #line 7162 "./typica.w"
  3428. void DAQ::start()
  3429. {
  3430. if(imp->ready)
  3431. {
  3432. imp->error= imp->startTask(imp->handle);
  3433. if(imp->error)
  3434. {
  3435. /*323:*/
  3436. #line 7137 "./typica.w"
  3437. imp->ready= false;
  3438. QMessageBox warning;
  3439. warning.setStandardButtons(QMessageBox::Cancel);
  3440. warning.setIcon(QMessageBox::Warning);
  3441. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3442. unsigned long bytes= imp->errorInfo(NULL,0);
  3443. char string[bytes];
  3444. imp->errorInfo(string,bytes);
  3445. warning.setInformativeText(QString(string));
  3446. warning.setWindowTitle(QString(PROGRAM_NAME));
  3447. warning.exec();
  3448. /*:323*/
  3449. #line 7170 "./typica.w"
  3450. }
  3451. else
  3452. {
  3453. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3454. imp->start();
  3455. }
  3456. }
  3457. }
  3458. void DAQ::stop()
  3459. {
  3460. if(imp->useBase)
  3461. {
  3462. imp->ready= false;
  3463. imp->wait(ULONG_MAX);
  3464. imp->stopTask(imp->handle);
  3465. }
  3466. else
  3467. {
  3468. imp->ready= false;
  3469. imp->error= imp->stopTask(imp->handle);
  3470. if(imp->error)
  3471. {
  3472. /*323:*/
  3473. #line 7137 "./typica.w"
  3474. imp->ready= false;
  3475. QMessageBox warning;
  3476. warning.setStandardButtons(QMessageBox::Cancel);
  3477. warning.setIcon(QMessageBox::Warning);
  3478. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3479. unsigned long bytes= imp->errorInfo(NULL,0);
  3480. char string[bytes];
  3481. imp->errorInfo(string,bytes);
  3482. warning.setInformativeText(QString(string));
  3483. warning.setWindowTitle(QString(PROGRAM_NAME));
  3484. warning.exec();
  3485. /*:323*/
  3486. #line 7194 "./typica.w"
  3487. }
  3488. imp->error= imp->clearTask(imp->handle);
  3489. if(imp->error)
  3490. {
  3491. /*323:*/
  3492. #line 7137 "./typica.w"
  3493. imp->ready= false;
  3494. QMessageBox warning;
  3495. warning.setStandardButtons(QMessageBox::Cancel);
  3496. warning.setIcon(QMessageBox::Warning);
  3497. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3498. unsigned long bytes= imp->errorInfo(NULL,0);
  3499. char string[bytes];
  3500. imp->errorInfo(string,bytes);
  3501. warning.setInformativeText(QString(string));
  3502. warning.setWindowTitle(QString(PROGRAM_NAME));
  3503. warning.exec();
  3504. /*:323*/
  3505. #line 7199 "./typica.w"
  3506. }
  3507. }
  3508. }
  3509. /*:324*//*325:*/
  3510. #line 7209 "./typica.w"
  3511. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  3512. {
  3513. imp->device= device;
  3514. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  3515. if(imp->error)
  3516. {
  3517. /*323:*/
  3518. #line 7137 "./typica.w"
  3519. imp->ready= false;
  3520. QMessageBox warning;
  3521. warning.setStandardButtons(QMessageBox::Cancel);
  3522. warning.setIcon(QMessageBox::Warning);
  3523. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3524. unsigned long bytes= imp->errorInfo(NULL,0);
  3525. char string[bytes];
  3526. imp->errorInfo(string,bytes);
  3527. warning.setInformativeText(QString(string));
  3528. warning.setWindowTitle(QString(PROGRAM_NAME));
  3529. warning.exec();
  3530. /*:323*/
  3531. #line 7216 "./typica.w"
  3532. }
  3533. else
  3534. {
  3535. imp->ready= true;
  3536. }
  3537. }
  3538. /*:325*//*326:*/
  3539. #line 7230 "./typica.w"
  3540. Channel*DAQ::newChannel(int units,int thermocouple)
  3541. {
  3542. Channel*retval= new Channel();
  3543. imp->channelMap[imp->channels]= retval;
  3544. imp->unitMap[imp->channels]= (Units::Unit)units;
  3545. imp->channels++;
  3546. if(imp->ready)
  3547. {
  3548. if(imp->useBase)
  3549. {
  3550. imp->error= imp->createChannel(imp->handle,
  3551. QString("%1/ai%2").arg(imp->device).
  3552. arg(imp->channels-1).
  3553. toAscii().data(),
  3554. "",(double)(-1.0),(double)(100.0),
  3555. (signed long)(units),
  3556. (signed long)(thermocouple),
  3557. (signed long)(10200),(double)(0),
  3558. "");
  3559. }
  3560. else
  3561. {
  3562. imp->error= imp->createChannel(imp->handle,
  3563. QString("%1/ai%2").arg(imp->device).
  3564. arg(imp->channels-1).
  3565. toAscii().data(),
  3566. "",(double)(50.0),(double)(500.0),
  3567. (signed long)(units),
  3568. (signed long)(thermocouple),
  3569. (signed long)(10200),(double)(0),
  3570. "");
  3571. }
  3572. if(imp->error)
  3573. {
  3574. /*323:*/
  3575. #line 7137 "./typica.w"
  3576. imp->ready= false;
  3577. QMessageBox warning;
  3578. warning.setStandardButtons(QMessageBox::Cancel);
  3579. warning.setIcon(QMessageBox::Warning);
  3580. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3581. unsigned long bytes= imp->errorInfo(NULL,0);
  3582. char string[bytes];
  3583. imp->errorInfo(string,bytes);
  3584. warning.setInformativeText(QString(string));
  3585. warning.setWindowTitle(QString(PROGRAM_NAME));
  3586. warning.exec();
  3587. /*:323*/
  3588. #line 7265 "./typica.w"
  3589. }
  3590. }
  3591. return retval;
  3592. }
  3593. /*:326*//*327:*/
  3594. #line 7279 "./typica.w"
  3595. void DAQ::setClockRate(double Hz)
  3596. {
  3597. if(imp->ready)
  3598. {
  3599. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  3600. (signed long)(10280),(signed long)(10123),
  3601. (unsigned long long)(1));
  3602. if(imp->error)
  3603. {
  3604. /*323:*/
  3605. #line 7137 "./typica.w"
  3606. imp->ready= false;
  3607. QMessageBox warning;
  3608. warning.setStandardButtons(QMessageBox::Cancel);
  3609. warning.setIcon(QMessageBox::Warning);
  3610. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3611. unsigned long bytes= imp->errorInfo(NULL,0);
  3612. char string[bytes];
  3613. imp->errorInfo(string,bytes);
  3614. warning.setInformativeText(QString(string));
  3615. warning.setWindowTitle(QString(PROGRAM_NAME));
  3616. warning.exec();
  3617. /*:323*/
  3618. #line 7289 "./typica.w"
  3619. }
  3620. }
  3621. }
  3622. /*:327*//*328:*/
  3623. #line 7299 "./typica.w"
  3624. DAQ::~DAQ()
  3625. {
  3626. if(imp->useBase)
  3627. {
  3628. imp->resetDevice(imp->device.toAscii().data());
  3629. imp->clearTask(imp->handle);
  3630. }
  3631. else
  3632. {
  3633. if(imp->ready)
  3634. {
  3635. imp->ready= false;
  3636. imp->wait(ULONG_MAX);
  3637. imp->stopTask(imp->handle);
  3638. imp->resetDevice(imp->device.toAscii().data());
  3639. imp->clearTask(imp->handle);
  3640. }
  3641. }
  3642. delete imp;
  3643. }
  3644. /*:328*//*329:*/
  3645. #line 7330 "./typica.w"
  3646. DAQImplementation::DAQImplementation(const QString&driverinfo)
  3647. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  3648. unitMap(4)
  3649. {
  3650. if(driverinfo=="nidaqmxbase")
  3651. {
  3652. useBase= true;
  3653. }
  3654. else
  3655. {
  3656. useBase= false;
  3657. }
  3658. if(useBase)
  3659. {
  3660. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  3661. if(!driver.load())
  3662. {
  3663. driver.setFileName("nidaqmxbase");
  3664. if(!driver.load())
  3665. {
  3666. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3667. tr("Failed to find nidaqmxbase. Please install it."));
  3668. QApplication::quit();
  3669. }
  3670. }
  3671. }
  3672. else
  3673. {
  3674. driver.setFileName("nicaiu");
  3675. if(!driver.load())
  3676. {
  3677. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  3678. tr("Failed to find nidaqmx. Please install it."));
  3679. QApplication::quit();
  3680. }
  3681. }
  3682. if(useBase)
  3683. {
  3684. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  3685. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  3686. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  3687. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  3688. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  3689. ==0||
  3690. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  3691. 0||
  3692. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  3693. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  3694. 0||
  3695. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  3696. {
  3697. waitForMeasurement= NULL;
  3698. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3699. tr("Failed to link a required symbol in NI-DAQmxBase."));
  3700. QApplication::quit();
  3701. }
  3702. }
  3703. else
  3704. {
  3705. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  3706. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  3707. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  3708. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  3709. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  3710. ==0||
  3711. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  3712. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  3713. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  3714. 0||
  3715. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  3716. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  3717. {
  3718. QMessageBox::critical(NULL,tr("Typica: Link error"),
  3719. tr("Failed to link a required symbol in NI-DAQmx."));
  3720. QApplication::quit();
  3721. }
  3722. }
  3723. }
  3724. DAQImplementation::~DAQImplementation()
  3725. {
  3726. driver.unload();
  3727. }
  3728. /*:329*/
  3729. #line 543 "./typica.w"
  3730. /*1051:*/
  3731. #line 197 "./dataqsdk.w"
  3732. void DataqSdkDeviceImplementation::measure()
  3733. {
  3734. unsigned count= channels*40;
  3735. di_status_read(buffer,count);
  3736. QTime time= QTime::currentTime();
  3737. for(unsigned int i= 0;i<count;i++)
  3738. {
  3739. buffer[i]= buffer[i]&0xFFFC;
  3740. }
  3741. QList<int> countList;
  3742. for(unsigned int i= 0;i<(unsigned)channels;i++)
  3743. {
  3744. QList<double> channelBuffer;
  3745. for(unsigned int j= 0;j<40;j++)
  3746. {
  3747. channelBuffer<<((double)buffer[i+(channels*j)]*10.0)/32768.0;
  3748. if(i==0)
  3749. {
  3750. countList<<buffer[i+(channels*j)];
  3751. }
  3752. }
  3753. double value= 0.0;
  3754. for(unsigned int j= 0;j<40;j++)
  3755. {
  3756. value+= channelBuffer[j];
  3757. }
  3758. value/= 40.0;
  3759. if(i==0)
  3760. {
  3761. QList<double> smoothingList;
  3762. smoothingList<<value;
  3763. QList<int> smoothingKeys= smoother.uniqueKeys();
  3764. for(int j= 0;j<smoothingKeys.size();j++)
  3765. {
  3766. if(countList.contains(smoothingKeys[j]))
  3767. {
  3768. QList<double> keyValues= smoother.values(smoothingKeys[j]);
  3769. for(int k= 0;k<keyValues.size();k++)
  3770. {
  3771. smoothingList<<keyValues[k];
  3772. }
  3773. }
  3774. else
  3775. {
  3776. smoother.remove(smoothingKeys[j]);
  3777. }
  3778. }
  3779. qSort(countList);
  3780. int lastCount= 0;
  3781. for(int j= 0;j<countList.size();j++)
  3782. {
  3783. if(j==0||countList[j]!=lastCount)
  3784. {
  3785. smoother.insert(countList[j],value);
  3786. lastCount= countList[j];
  3787. }
  3788. }
  3789. value= 0.0;
  3790. for(int j= 0;j<smoothingList.size();j++)
  3791. {
  3792. value+= smoothingList[j];
  3793. }
  3794. value/= smoothingList.size();
  3795. }
  3796. Measurement measure(value,time,unitMap[i]);
  3797. channelMap[i]->input(measure);
  3798. }
  3799. }
  3800. /*:1051*//*1052:*/
  3801. #line 290 "./dataqsdk.w"
  3802. void DataqSdkDeviceImplementation::run()
  3803. {
  3804. if(!ready)
  3805. {
  3806. error= 9;
  3807. return;
  3808. }
  3809. driver= new QLibrary(device);
  3810. if(!driver->load())
  3811. {
  3812. error= 1;
  3813. qDebug()<<"Failed to load driver: "<<device;
  3814. return;
  3815. }
  3816. di_open= (FPDIOPEN)driver->resolve("di_open");
  3817. di_close= (FPDICLOSE)driver->resolve("di_close");
  3818. di_sample_rate= (FPDISAMPLERATE)driver->resolve("di_sample_rate");
  3819. di_maximum_rate= (FPDIMAXIMUMRATE)driver->resolve("di_maximum_rate");
  3820. di_list_length= (FPDILISTLENGTH)driver->resolve("di_list_length");
  3821. di_inlist= (FPDIINLIST)driver->resolve("di_inlist");
  3822. di_buffer_alloc= (FPDIBUFFERALLOC)driver->resolve("di_buffer_alloc");
  3823. di_start_scan= (FPDISTARTSCAN)driver->resolve("di_start_scan");
  3824. di_status_read= (FPDISTATUSREAD)driver->resolve("di_status_read");
  3825. di_buffer_status= (FPDIBUFFERSTATUS)driver->resolve("di_buffer_status");
  3826. di_burst_rate= (FPDIBURSTRATE)driver->resolve("di_burst_rate");
  3827. di_stop_scan= (FPDISTOPSCAN)driver->resolve("di_stop_scan");
  3828. if((!di_open)||(!di_close)||(!di_sample_rate)||(!di_maximum_rate)||
  3829. (!di_list_length)||(!di_inlist)||(!di_buffer_alloc)||
  3830. (!di_start_scan)||(!di_status_read)||(!di_buffer_status)||
  3831. (!di_burst_rate)||(!di_stop_scan))
  3832. {
  3833. error= 2;
  3834. return;
  3835. }
  3836. error= di_open(deviceNumber);
  3837. if(error)
  3838. {
  3839. di_close();
  3840. error= di_open(deviceNumber);
  3841. if(error)
  3842. {
  3843. error= 3;
  3844. di_close();
  3845. return;
  3846. }
  3847. }
  3848. isOpen= true;
  3849. di_maximum_rate(240.0);
  3850. sampleRate= di_sample_rate(sampleRate*channels*40,&oversample,
  3851. &burstDivisor);
  3852. buffer= new qint16[(int)sampleRate];
  3853. di_inlist_struct inlist[16]= {{0,0,0,0,0,0,0,0}};
  3854. for(unsigned short i= 0;i<channels;i++)
  3855. {
  3856. inlist[i].chan= i;
  3857. inlist[i].gain= 0;
  3858. inlist[i].ave= 1;
  3859. inlist[i].counter= (oversample-1);
  3860. }
  3861. error= di_list_length(channels,0);
  3862. if(error)
  3863. {
  3864. error= 4;
  3865. return;
  3866. }
  3867. error= di_inlist(inlist);
  3868. if(error)
  3869. {
  3870. error= 5;
  3871. return;
  3872. }
  3873. input_buffer= di_buffer_alloc(0,4096);
  3874. if(input_buffer==NULL)
  3875. {
  3876. error= 6;
  3877. return;
  3878. }
  3879. error= di_start_scan();
  3880. if(error)
  3881. {
  3882. error= 7;
  3883. return;
  3884. }
  3885. while(ready)
  3886. {
  3887. measure();
  3888. }
  3889. }
  3890. /*:1052*//*1053:*/
  3891. #line 386 "./dataqsdk.w"
  3892. void DataqSdkDevice::threadFinished()
  3893. {
  3894. if(imp->error)
  3895. {
  3896. /*1054:*/
  3897. #line 400 "./dataqsdk.w"
  3898. imp->ready= false;
  3899. QMessageBox warning;
  3900. warning.setStandardButtons(QMessageBox::Cancel);
  3901. warning.setIcon(QMessageBox::Warning);
  3902. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  3903. warning.setInformativeText(tr("An error occurred"));
  3904. warning.setWindowTitle(QString(PROGRAM_NAME));
  3905. warning.exec();
  3906. /*:1054*/
  3907. #line 391 "./dataqsdk.w"
  3908. }
  3909. }
  3910. /*:1053*//*1055:*/
  3911. #line 417 "./dataqsdk.w"
  3912. void DataqSdkDevice::start()
  3913. {
  3914. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  3915. imp->start();
  3916. }
  3917. /*:1055*//*1056:*/
  3918. #line 428 "./dataqsdk.w"
  3919. QStringList DataqSdkDevice::detectHardware()
  3920. {
  3921. QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
  3922. QSettings::NativeFormat);
  3923. QStringList keys= deviceLookup.childKeys();
  3924. QStringList devices;
  3925. for(int i= 0;i<keys.size();i++)
  3926. {
  3927. QString value= deviceLookup.value(keys.at(i)).toString();
  3928. if(value.startsWith("USB\\VID_0683&PID_1450\\"))
  3929. {
  3930. devices.append(value.split("\\").at(2));
  3931. }
  3932. }
  3933. QStringList portList;
  3934. foreach(QString device,devices)
  3935. {
  3936. QString deviceKey= QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
  3937. QSettings deviceEntry(deviceKey,QSettings::NativeFormat);
  3938. portList.append(deviceEntry.value("FriendlyName").toString());
  3939. }
  3940. return portList;
  3941. }
  3942. QStringList DataqSdkDevice::detectPorts()
  3943. {
  3944. QStringList friendlyNames= detectHardware();
  3945. QStringList portList;
  3946. foreach(QString name,friendlyNames)
  3947. {
  3948. name.remove(0,name.indexOf("COM"));
  3949. name.chop(1);
  3950. portList.append(name);
  3951. }
  3952. return portList;
  3953. }
  3954. /*:1056*//*1057:*/
  3955. #line 473 "./dataqsdk.w"
  3956. DataqSdkDevice::DataqSdkDevice(QString device):imp(new DataqSdkDeviceImplementation)
  3957. {
  3958. bool usesAuto= false;
  3959. int autoIndex= device.toInt(&usesAuto);
  3960. QString finalizedPort;
  3961. if(usesAuto)
  3962. {
  3963. QStringList portList= detectPorts();
  3964. if(autoIndex> 0&&autoIndex<=portList.size())
  3965. {
  3966. finalizedPort= portList.at(autoIndex-1);
  3967. }
  3968. else
  3969. {
  3970. imp->error= 8;
  3971. qDebug()<<"Failed to detect port.";
  3972. }
  3973. }
  3974. else
  3975. {
  3976. finalizedPort= device;
  3977. }
  3978. int rstart= finalizedPort.indexOf("COM");
  3979. finalizedPort.remove(0,rstart+3);
  3980. bool chopFinished= false;
  3981. int finalizedPortNumber= 0;
  3982. while(finalizedPort.size()> 0&&!chopFinished)
  3983. {
  3984. finalizedPortNumber= finalizedPort.toInt(&chopFinished);
  3985. if(!chopFinished)
  3986. {
  3987. finalizedPort.chop(1);
  3988. }
  3989. }
  3990. if(finalizedPortNumber<10)
  3991. {
  3992. imp->device= QString("DI10%1NT.DLL").arg(finalizedPort);
  3993. }
  3994. else
  3995. {
  3996. imp->device= QString("DI1%1NT.DLL").arg(finalizedPort);
  3997. }
  3998. imp->deviceNumber= 0x12C02D00;
  3999. imp->deviceNumber+= finalizedPortNumber;
  4000. imp->ready= true;
  4001. }
  4002. /*:1057*//*1058:*/
  4003. #line 523 "./dataqsdk.w"
  4004. Channel*DataqSdkDevice::newChannel(Units::Unit scale)
  4005. {
  4006. Channel*retval= NULL;
  4007. if(imp->ready)
  4008. {
  4009. retval= new Channel();
  4010. imp->channelMap[imp->channels]= retval;
  4011. imp->unitMap[imp->channels]= scale;
  4012. imp->channels++;
  4013. }
  4014. return retval;
  4015. }
  4016. /*:1058*//*1059:*/
  4017. #line 547 "./dataqsdk.w"
  4018. void DataqSdkDevice::setClockRate(double Hz)
  4019. {
  4020. imp->sampleRate= Hz;
  4021. }
  4022. /*:1059*//*1060:*/
  4023. #line 557 "./dataqsdk.w"
  4024. DataqSdkDevice::~DataqSdkDevice()
  4025. {
  4026. if(imp->ready)
  4027. {
  4028. imp->ready= false;
  4029. }
  4030. imp->wait(ULONG_MAX);
  4031. delete imp;
  4032. }
  4033. /*:1060*//*1061:*/
  4034. #line 575 "./dataqsdk.w"
  4035. DataqSdkDeviceImplementation::DataqSdkDeviceImplementation():QThread(NULL),
  4036. channelMap(4),error(0),channels(0),ready(false),unitMap(4)
  4037. {
  4038. }
  4039. DataqSdkDeviceImplementation::~DataqSdkDeviceImplementation()
  4040. {
  4041. if(isOpen)
  4042. {
  4043. di_stop_scan();
  4044. di_close();
  4045. }
  4046. if(driver->isLoaded())
  4047. {
  4048. driver->unload();
  4049. }
  4050. }
  4051. /*:1061*/
  4052. #line 544 "./typica.w"
  4053. /*336:*/
  4054. #line 7539 "./typica.w"
  4055. void FakeDAQImplementation::measure()
  4056. {
  4057. msleep((int)(1000/clockRate));
  4058. QTime time= QTime::currentTime();
  4059. for(int i= 0;i<channels;i++)
  4060. {
  4061. Measurement measure(qrand()%500,time);
  4062. channelMap[i]->input(measure);
  4063. }
  4064. }
  4065. /*:336*//*337:*/
  4066. #line 7553 "./typica.w"
  4067. void FakeDAQImplementation::run()
  4068. {
  4069. setPriority(QThread::TimeCriticalPriority);
  4070. while(ready)
  4071. {
  4072. measure();
  4073. }
  4074. }
  4075. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  4076. channels(0),ready(false),clockRate(1)
  4077. {
  4078. }
  4079. FakeDAQImplementation::~FakeDAQImplementation()
  4080. {
  4081. }
  4082. /*:337*//*338:*/
  4083. #line 7578 "./typica.w"
  4084. void FakeDAQ::start()
  4085. {
  4086. if(imp->ready)
  4087. {
  4088. imp->start();
  4089. }
  4090. }
  4091. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  4092. {
  4093. imp->ready= true;
  4094. }
  4095. Channel*FakeDAQ::newChannel(int,int)
  4096. {
  4097. Channel*retval;
  4098. if(imp->ready)
  4099. {
  4100. retval= new Channel();
  4101. imp->channelMap[imp->channels]= retval;
  4102. imp->channels++;
  4103. }
  4104. else
  4105. {
  4106. return NULL;
  4107. }
  4108. return retval;
  4109. }
  4110. void FakeDAQ::setClockRate(double Hz)
  4111. {
  4112. if(imp->ready)
  4113. {
  4114. imp->clockRate= Hz;
  4115. }
  4116. }
  4117. FakeDAQ::~FakeDAQ()
  4118. {
  4119. imp->ready= false;
  4120. imp->wait(ULONG_MAX);
  4121. delete imp;
  4122. }
  4123. /*:338*/
  4124. #line 545 "./typica.w"
  4125. /*343:*/
  4126. #line 7709 "./typica.w"
  4127. Channel::Channel():QObject(NULL)
  4128. {
  4129. }
  4130. Channel::~Channel()
  4131. {
  4132. }
  4133. void Channel::input(Measurement measurement)
  4134. {
  4135. emit newData(measurement);
  4136. }
  4137. /*:343*/
  4138. #line 546 "./typica.w"
  4139. /*359:*/
  4140. #line 8114 "./typica.w"
  4141. void TemperatureDisplay::setRelativeMode(bool relative)
  4142. {
  4143. r= relative;
  4144. }
  4145. /*:359*//*360:*/
  4146. #line 8131 "./typica.w"
  4147. void TemperatureDisplay::setValue(Measurement temperature)
  4148. {
  4149. QString number;
  4150. switch(unit)
  4151. {
  4152. case Units::Fahrenheit:
  4153. display(QString("%1'F").
  4154. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  4155. 2)));
  4156. break;
  4157. case Units::Celsius:
  4158. if(!r){
  4159. display(QString("%1'C").
  4160. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  4161. 2)));
  4162. }else{
  4163. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4164. display(QString("%1'C").arg(number));
  4165. }
  4166. break;
  4167. case Units::Kelvin:
  4168. if(!r){
  4169. display(QString("%1").
  4170. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  4171. 2)));
  4172. }else{
  4173. number.setNum(temperature.temperature()*(5.0/9.0),'f',2);
  4174. display(QString("%1").arg(number));
  4175. }
  4176. break;
  4177. case Units::Rankine:
  4178. display(QString("%1'r").
  4179. arg(number.setNum(temperature.toRankine().temperature(),'f',
  4180. 2)));
  4181. break;
  4182. case Units::Unitless:
  4183. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4184. break;
  4185. default:
  4186. switch(temperature.scale())
  4187. {
  4188. case Units::Fahrenheit:
  4189. display(QString("%1'F").
  4190. arg(number.setNum(temperature.temperature(),'f',2)));
  4191. break;
  4192. case Units::Celsius:
  4193. display(QString("%1'C").
  4194. arg(number.setNum(temperature.temperature(),'f',2)));
  4195. break;
  4196. case Units::Kelvin:
  4197. display(QString("%1").
  4198. arg(number.setNum(temperature.temperature(),'f',2)));
  4199. break;
  4200. case Units::Rankine:
  4201. display(QString("%1'r").
  4202. arg(number.setNum(temperature.temperature(),'f',2)));
  4203. break;
  4204. case Units::Unitless:
  4205. display(QString("%1").arg(number.setNum(temperature.temperature(),'f',0)));
  4206. break;
  4207. default:
  4208. qDebug()<<"Warning: Attempting to convert a non-temperature unit to a temperature unit";
  4209. break;
  4210. }
  4211. break;
  4212. }
  4213. }
  4214. /*:360*//*361:*/
  4215. #line 8210 "./typica.w"
  4216. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  4217. QLCDNumber(8,parent),unit(Units::Fahrenheit),r(false)
  4218. {
  4219. setSegmentStyle(Filled);
  4220. display("---.--'F");
  4221. }
  4222. /*:361*//*362:*/
  4223. #line 8226 "./typica.w"
  4224. void TemperatureDisplay::invalidate()
  4225. {
  4226. display("---.--'F");
  4227. }
  4228. /*:362*//*363:*/
  4229. #line 8238 "./typica.w"
  4230. void TemperatureDisplay::setDisplayUnits(Units::Unit scale)
  4231. {
  4232. unit= scale;
  4233. }
  4234. /*:363*//*364:*/
  4235. #line 8246 "./typica.w"
  4236. TemperatureDisplay::~TemperatureDisplay()
  4237. {
  4238. }
  4239. /*:364*/
  4240. #line 547 "./typica.w"
  4241. /*370:*/
  4242. #line 8346 "./typica.w"
  4243. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  4244. {
  4245. if(measure.time()<epoch)
  4246. {
  4247. if(hasPrevious)
  4248. {
  4249. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  4250. epoch.msec());
  4251. QTime jitComp(epoch.hour(),measure.time().minute(),
  4252. measure.time().second(),measure.time().msec());
  4253. int relTime= jitBase.msecsTo(jitComp);
  4254. /*371:*/
  4255. #line 8380 "./typica.w"
  4256. QTime newTime(0,0,0,0);
  4257. newTime= newTime.addMSecs(relTime);
  4258. if(newTime.hour()> 0)
  4259. {
  4260. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4261. }
  4262. Measurement rel= measure;
  4263. rel.setTime(newTime);
  4264. emit measurement(rel);
  4265. /*:371*/
  4266. #line 8358 "./typica.w"
  4267. }
  4268. else
  4269. {
  4270. Measurement rel= measure;
  4271. rel.setTime(QTime(0,0,0,0));
  4272. emit measurement(rel);
  4273. }
  4274. }
  4275. else
  4276. {
  4277. int relTime= epoch.msecsTo(measure.time());
  4278. /*371:*/
  4279. #line 8380 "./typica.w"
  4280. QTime newTime(0,0,0,0);
  4281. newTime= newTime.addMSecs(relTime);
  4282. if(newTime.hour()> 0)
  4283. {
  4284. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  4285. }
  4286. Measurement rel= measure;
  4287. rel.setTime(newTime);
  4288. emit measurement(rel);
  4289. /*:371*/
  4290. #line 8370 "./typica.w"
  4291. }
  4292. hasPrevious= true;
  4293. previous= measure.time();
  4294. }
  4295. /*:370*//*372:*/
  4296. #line 8393 "./typica.w"
  4297. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  4298. previous(0,0,0,0),hasPrevious(false)
  4299. {
  4300. }
  4301. QTime MeasurementTimeOffset::zeroTime()
  4302. {
  4303. return epoch;
  4304. }
  4305. void MeasurementTimeOffset::setZeroTime(QTime zero)
  4306. {
  4307. epoch= zero;
  4308. hasPrevious= false;
  4309. }
  4310. /*:372*/
  4311. #line 548 "./typica.w"
  4312. /*382:*/
  4313. #line 8601 "./typica.w"
  4314. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn)
  4315. {
  4316. }
  4317. int ZeroEmitter::column()
  4318. {
  4319. return col;
  4320. }
  4321. double ZeroEmitter::lastTemperature()
  4322. {
  4323. return cache.temperature();
  4324. }
  4325. void ZeroEmitter::newMeasurement(Measurement measure)
  4326. {
  4327. cache= measure;
  4328. }
  4329. void ZeroEmitter::setColumn(int column)
  4330. {
  4331. col= column;
  4332. }
  4333. void ZeroEmitter::emitZero()
  4334. {
  4335. cache.setTime(QTime(0,0,0,0));
  4336. emit measurement(cache,col);
  4337. }
  4338. /*:382*/
  4339. #line 549 "./typica.w"
  4340. /*387:*/
  4341. #line 8691 "./typica.w"
  4342. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  4343. {
  4344. }
  4345. int MeasurementAdapter::column()
  4346. {
  4347. return col;
  4348. }
  4349. void MeasurementAdapter::newMeasurement(Measurement measure)
  4350. {
  4351. emit measurement(measure,col);
  4352. }
  4353. void MeasurementAdapter::setColumn(int column)
  4354. {
  4355. col= column;
  4356. }
  4357. /*:387*/
  4358. #line 550 "./typica.w"
  4359. /*392:*/
  4360. #line 8813 "./typica.w"
  4361. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  4362. theScene(new QGraphicsScene),
  4363. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  4364. prevPoints(new QMap<int,QPointF> ),
  4365. translations(new QMap<int,double> ),
  4366. gridLinesF(new QList<QGraphicsItem*> ),
  4367. gridLinesC(new QList<QGraphicsItem*> ),
  4368. relativeGridLines(new QList<QGraphicsItem*> ),
  4369. relativeEnabled(false),
  4370. timeIndicatorEnabled(false),
  4371. timeLine(new QGraphicsLineItem),
  4372. relativeAdjuster(new LinearSplineInterpolator)
  4373. {
  4374. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4375. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4376. setScene(theScene);
  4377. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  4378. QPen timePen;
  4379. timePen.setColor(QColor(160,160,164,127));
  4380. timeLine->setPen(timePen);
  4381. timeLine->setLine(0,0,0,-500);
  4382. timeLine->hide();
  4383. theScene->addItem(timeLine);
  4384. /*393:*/
  4385. #line 8853 "./typica.w"
  4386. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  4387. tempaxis->setLine(-10,-500,-10,0);
  4388. theScene->addItem(tempaxis);
  4389. QGraphicsLineItem*gridLine;
  4390. QGraphicsTextItem*label;
  4391. for(int y= -100;y> -600;y-= 100)
  4392. {
  4393. gridLine= new QGraphicsLineItem;
  4394. gridLine->setLine(0,y,1200,y);
  4395. theScene->addItem(gridLine);
  4396. label= new QGraphicsTextItem;
  4397. label->setHtml(QString("%1&deg;F").arg(-y));
  4398. label->setPos(-55,y-(label->boundingRect().height()/2));
  4399. theScene->addItem(label);
  4400. gridLinesF->append(gridLine);
  4401. gridLinesF->append(label);
  4402. }
  4403. for(int degC= 50;degC<=250;degC+= 50)
  4404. {
  4405. gridLine= new QGraphicsLineItem;
  4406. int y= -(degC*(9.0/5.0)+32);
  4407. gridLine->setLine(0,y,1200,y);
  4408. gridLine->hide();
  4409. theScene->addItem(gridLine);
  4410. gridLinesC->append(gridLine);
  4411. label= new QGraphicsTextItem;
  4412. label->setHtml(QString("%1&deg;C").arg(degC));
  4413. label->setPos(-55,y-(label->boundingRect().height()/2));
  4414. label->hide();
  4415. theScene->addItem(label);
  4416. gridLinesC->append(label);
  4417. }
  4418. /*:393*/
  4419. #line 8837 "./typica.w"
  4420. ;
  4421. /*394:*/
  4422. #line 8894 "./typica.w"
  4423. QSettings settings;
  4424. if(settings.contains("settings/graph/relative/enable"))
  4425. {
  4426. if(settings.value("settings/graph/relative/enable").toBool())
  4427. {
  4428. relativeEnabled= true;
  4429. QColor relativeColor= QColor(settings.value("settings/graph/relative/color").toString());
  4430. QString unit= QString(settings.value("settings/graph/relative/unit").toInt()==0?"F":"C");
  4431. QMap<double,QString> relativeAxisPairs;
  4432. QStringList relativeAxisLabels= settings.value("settings/graph/relative/grid").toString().split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  4433. foreach(QString item,relativeAxisLabels)
  4434. {
  4435. relativeAxisPairs.insert(item.toDouble(),item);
  4436. }
  4437. if(relativeAxisPairs.size()> 1)
  4438. {
  4439. double skip= 500.0/(relativeAxisPairs.size()-1);
  4440. double y= 0;
  4441. foreach(double key,relativeAxisPairs.keys())
  4442. {
  4443. gridLine= new QGraphicsLineItem;
  4444. gridLine->setLine(0,y,1205,y);
  4445. gridLine->setPen(QPen(relativeColor));
  4446. theScene->addItem(gridLine);
  4447. relativeGridLines->append(gridLine);
  4448. label= new QGraphicsTextItem;
  4449. label->setHtml(QString("%1&deg;%2").arg(relativeAxisPairs.value(key)).arg(unit));
  4450. label->setPos(1210,y-(label->boundingRect().height()/2));
  4451. theScene->addItem(label);
  4452. relativeGridLines->append(label);
  4453. if(unit=="F")
  4454. {
  4455. relativeAdjuster->add_pair(key,-y);
  4456. }
  4457. else
  4458. {
  4459. relativeAdjuster->add_pair(key*(9.0/5.0),-y);
  4460. }
  4461. y-= skip;
  4462. }
  4463. }
  4464. }
  4465. }
  4466. /*:394*/
  4467. #line 8838 "./typica.w"
  4468. /*396:*/
  4469. #line 8971 "./typica.w"
  4470. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  4471. timeaxis->setLine(0,10,1200,10);
  4472. theScene->addItem(timeaxis);
  4473. for(int x= 0;x<1201;x+= 120)
  4474. {
  4475. QGraphicsLineItem*tick= new QGraphicsLineItem;
  4476. tick->setLine(x,0,x,20);
  4477. theScene->addItem(tick);
  4478. QGraphicsTextItem*label= new QGraphicsTextItem;
  4479. label->setPlainText(QString("%1").arg(x/60));
  4480. label->setPos(x-(label->boundingRect().width()/2),20);
  4481. theScene->addItem(label);
  4482. }
  4483. /*:396*/
  4484. #line 8839 "./typica.w"
  4485. ;
  4486. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4487. }
  4488. /*:392*//*395:*/
  4489. #line 8941 "./typica.w"
  4490. void GraphView::showF()
  4491. {
  4492. for(int i= 0;i<gridLinesF->size();i++)
  4493. {
  4494. gridLinesF->at(i)->show();
  4495. }
  4496. for(int i= 0;i<gridLinesC->size();i++)
  4497. {
  4498. gridLinesC->at(i)->hide();
  4499. }
  4500. }
  4501. void GraphView::showC()
  4502. {
  4503. for(int i= 0;i<gridLinesF->size();i++)
  4504. {
  4505. gridLinesF->at(i)->hide();
  4506. }
  4507. for(int i= 0;i<gridLinesC->size();i++)
  4508. {
  4509. gridLinesC->at(i)->show();
  4510. }
  4511. }
  4512. /*:395*//*397:*/
  4513. #line 8990 "./typica.w"
  4514. void GraphView::resizeEvent(QResizeEvent*)
  4515. {
  4516. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  4517. }
  4518. /*:397*//*398:*/
  4519. #line 9004 "./typica.w"
  4520. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  4521. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  4522. {
  4523. double offset= 0;
  4524. if(measure.contains("relative"))
  4525. {
  4526. if(measure.value("relative").toBool())
  4527. {
  4528. if(relativeEnabled)
  4529. {
  4530. measure.setTemperature(relativeAdjuster->newMeasurement(measure).temperature());
  4531. }
  4532. else
  4533. {
  4534. return;
  4535. }
  4536. }
  4537. }
  4538. if(translations->contains(tempcolumn))
  4539. {
  4540. offset= translations->value(tempcolumn);
  4541. }
  4542. if(prevPoints->contains(tempcolumn))
  4543. {
  4544. /*400:*/
  4545. #line 9081 "./typica.w"
  4546. QGraphicsLineItem*segment= new QGraphicsLineItem;
  4547. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  4548. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  4549. -(prevPoints->value(tempcolumn).y()),
  4550. nextPoint.x()+offset,-(nextPoint.y()));
  4551. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  4552. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  4553. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  4554. Qt::darkYellow};
  4555. segment->setPen(p[tempcolumn%12]);
  4556. theScene->addItem(segment);
  4557. prevPoints->insert(tempcolumn,nextPoint);
  4558. if(timeIndicatorEnabled)
  4559. {
  4560. timeLine->setLine(nextPoint.x()+offset,0,nextPoint.x()+offset,-500);
  4561. }
  4562. /*:400*/
  4563. #line 9030 "./typica.w"
  4564. if(graphLines->contains(tempcolumn))
  4565. {
  4566. graphLines->value(tempcolumn)->append(segment);
  4567. }
  4568. else
  4569. {
  4570. QList<QGraphicsLineItem*> *newLine=
  4571. new QList<QGraphicsLineItem*> ;
  4572. newLine->append(segment);
  4573. graphLines->insert(tempcolumn,newLine);
  4574. }
  4575. }
  4576. else
  4577. {
  4578. /*399:*/
  4579. #line 9066 "./typica.w"
  4580. int x= FULLTIMETOINT(measure.time())/1000;
  4581. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  4582. if(timeIndicatorEnabled)
  4583. {
  4584. timeLine->setLine(x,0,x,-500);
  4585. }
  4586. /*:399*/
  4587. #line 9047 "./typica.w"
  4588. }
  4589. }
  4590. /*:398*//*401:*/
  4591. #line 9102 "./typica.w"
  4592. void GraphView::clear()
  4593. {
  4594. int i;
  4595. foreach(i,prevPoints->keys())
  4596. {
  4597. removeSeries(i);
  4598. }
  4599. translations->clear();
  4600. }
  4601. /*:401*//*402:*/
  4602. #line 9116 "./typica.w"
  4603. void GraphView::removeSeries(int column)
  4604. {
  4605. if(graphLines->contains(column))
  4606. {
  4607. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4608. QGraphicsLineItem*segment;
  4609. foreach(segment,*series)
  4610. {
  4611. theScene->removeItem(segment);
  4612. }
  4613. qDeleteAll(*series);
  4614. }
  4615. graphLines->remove(column);
  4616. prevPoints->remove(column);
  4617. }
  4618. /*:402*//*403:*/
  4619. #line 9135 "./typica.w"
  4620. void GraphView::setSeriesTranslation(int column,double offset)
  4621. {
  4622. if(graphLines->contains(column))
  4623. {
  4624. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  4625. QGraphicsLineItem*segment;
  4626. foreach(segment,*series)
  4627. {
  4628. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  4629. }
  4630. }
  4631. if(translations->contains(column))
  4632. {
  4633. translations->insert(column,offset+translations->value(column));
  4634. }
  4635. else
  4636. {
  4637. translations->insert(column,offset);
  4638. }
  4639. }
  4640. /*:403*//*404:*/
  4641. #line 9162 "./typica.w"
  4642. void GraphView::setTimeIndicatorEnabled(bool enabled)
  4643. {
  4644. timeIndicatorEnabled= enabled;
  4645. if(enabled)
  4646. {
  4647. timeLine->show();
  4648. }
  4649. else
  4650. {
  4651. timeLine->hide();
  4652. }
  4653. }
  4654. /*:404*/
  4655. #line 551 "./typica.w"
  4656. /*410:*/
  4657. #line 9309 "./typica.w"
  4658. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  4659. {
  4660. if(measure.time()!=QTime(0,0,0,0))
  4661. {
  4662. /*412:*/
  4663. #line 9383 "./typica.w"
  4664. if(lastMeasurement.contains(tempcolumn))
  4665. {
  4666. if(lastMeasurement[tempcolumn].time()<measure.time())
  4667. {
  4668. QList<QTime> timelist;
  4669. QList<double> templist;
  4670. QTime z= QTime(0,0,0,0);
  4671. double ptime= (double)(z.secsTo(lastMeasurement[tempcolumn].time()));
  4672. double ptemp= lastMeasurement[tempcolumn].temperature();
  4673. double ctime= (double)(z.secsTo(measure.time()));
  4674. double ctemp= measure.temperature();
  4675. for(QTime i= lastMeasurement.value(tempcolumn).time().addSecs(1);i<measure.time();i= i.addSecs(1))
  4676. {
  4677. timelist.append(i);
  4678. double v= ((ptemp*(ctime-z.secsTo(i)))+(ctemp*(z.secsTo(i)-ptime)))/(ctime-ptime);
  4679. templist.append(v);
  4680. }
  4681. for(int i= 0;i<timelist.size();i++)
  4682. {
  4683. Measurement synthesized= measure;
  4684. synthesized.setTime(timelist[i]);
  4685. synthesized.setTemperature(templist[i]);
  4686. newMeasurement(synthesized,tempcolumn);
  4687. }
  4688. }
  4689. }
  4690. /*:412*/
  4691. #line 9314 "./typica.w"
  4692. }
  4693. model_ms->newMeasurement(measure,tempcolumn);
  4694. if(lastMeasurement.contains(tempcolumn))
  4695. {
  4696. if(measure.time().second()!=
  4697. lastMeasurement.value(tempcolumn).time().second())
  4698. {
  4699. Measurement adjusted= measure;
  4700. QTime adjtime(0,measure.time().minute(),measure.time().second(),0);
  4701. adjusted.setTime(adjtime);
  4702. model_1s->newMeasurement(adjusted,tempcolumn);
  4703. if(adjusted.time().second()%5==0)
  4704. {
  4705. model_5s->newMeasurement(adjusted,tempcolumn);
  4706. if(adjusted.time().second()%10==0)
  4707. {
  4708. model_10s->newMeasurement(adjusted,tempcolumn);
  4709. }
  4710. if(adjusted.time().second()%15==0)
  4711. {
  4712. model_15s->newMeasurement(adjusted,tempcolumn);
  4713. if(adjusted.time().second()%30==0)
  4714. {
  4715. model_30s->newMeasurement(adjusted,tempcolumn);
  4716. if(adjusted.time().second()==0)
  4717. {
  4718. model_1m->newMeasurement(adjusted,tempcolumn);
  4719. }
  4720. }
  4721. }
  4722. }
  4723. }
  4724. /*414:*/
  4725. #line 9436 "./typica.w"
  4726. if(currentColumnSet.contains(tempcolumn))
  4727. {
  4728. int replicationcolumn;
  4729. foreach(replicationcolumn,currentColumnSet)
  4730. {
  4731. if(replicationcolumn!=tempcolumn)
  4732. {
  4733. if(lastMeasurement.contains(replicationcolumn))
  4734. {
  4735. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  4736. {
  4737. Measurement synthetic= lastMeasurement.value(replicationcolumn);
  4738. synthetic.setTime(measure.time());
  4739. model_ms->newMeasurement(synthetic,replicationcolumn);
  4740. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  4741. {
  4742. Measurement adjusted= synthetic;
  4743. adjusted.setTime(QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  4744. model_1s->newMeasurement(adjusted,replicationcolumn);
  4745. if(adjusted.time().second()%5==0)
  4746. {
  4747. model_5s->newMeasurement(adjusted,replicationcolumn);
  4748. if(adjusted.time().second()%10==0)
  4749. {
  4750. model_10s->newMeasurement(adjusted,replicationcolumn);
  4751. }
  4752. if(adjusted.time().second()%15==0)
  4753. {
  4754. model_15s->newMeasurement(adjusted,replicationcolumn);
  4755. if(adjusted.time().second()%30==0)
  4756. {
  4757. model_30s->newMeasurement(adjusted,replicationcolumn);
  4758. if(adjusted.time().second()==0)
  4759. {
  4760. model_1m->newMeasurement(adjusted,replicationcolumn);
  4761. }
  4762. }
  4763. }
  4764. }
  4765. }
  4766. lastMeasurement[replicationcolumn]= synthetic;
  4767. }
  4768. }
  4769. }
  4770. }
  4771. }
  4772. /*:414*/
  4773. #line 9347 "./typica.w"
  4774. }
  4775. else
  4776. {
  4777. /*411:*/
  4778. #line 9359 "./typica.w"
  4779. MeasurementModel*m;
  4780. foreach(m,modelSet)
  4781. {
  4782. m->newMeasurement(measure,tempcolumn);
  4783. }
  4784. /*:411*/
  4785. #line 9351 "./typica.w"
  4786. }
  4787. lastMeasurement.insert(tempcolumn,measure);
  4788. }
  4789. /*:410*//*413:*/
  4790. #line 9422 "./typica.w"
  4791. void ZoomLog::addToCurrentColumnSet(int column)
  4792. {
  4793. currentColumnSet.append(column);
  4794. }
  4795. void ZoomLog::clearCurrentColumnSet()
  4796. {
  4797. currentColumnSet.clear();
  4798. }
  4799. /*:413*//*415:*/
  4800. #line 9506 "./typica.w"
  4801. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  4802. int annotationcolumn)
  4803. {
  4804. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4805. MeasurementModel*m;
  4806. if(lastMeasurement.contains(tempcolumn))
  4807. {
  4808. foreach(m,modelSet)
  4809. {
  4810. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  4811. }
  4812. }
  4813. foreach(m,modelSet)
  4814. {
  4815. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  4816. }
  4817. }
  4818. /*:415*//*416:*/
  4819. #line 9530 "./typica.w"
  4820. void ZoomLog::centerOn(int row)
  4821. {
  4822. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  4823. }
  4824. /*:416*//*417:*/
  4825. #line 9540 "./typica.w"
  4826. void ZoomLog::clear()
  4827. {
  4828. MeasurementModel*m;
  4829. foreach(m,modelSet)
  4830. {
  4831. m->clear();
  4832. }
  4833. lastMeasurement.clear();
  4834. saveTempCols.clear();
  4835. saveControlCols.clear();
  4836. saveNoteCols.clear();
  4837. }
  4838. /*:417*//*418:*/
  4839. #line 9558 "./typica.w"
  4840. QVariant ZoomLog::data(int row,int column)const
  4841. {
  4842. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  4843. Qt::DisplayRole);
  4844. }
  4845. int ZoomLog::rowCount()
  4846. {
  4847. return model_ms->rowCount();
  4848. }
  4849. /*:418*//*419:*/
  4850. #line 9581 "./typica.w"
  4851. bool ZoomLog::saveXML(QIODevice*device)
  4852. {
  4853. Units::Unit prevUnits= model_ms->displayUnits();
  4854. if(prevUnits!=Units::Fahrenheit)
  4855. {
  4856. model_ms->setDisplayUnits(Units::Fahrenheit);
  4857. }
  4858. XMLOutput writer(model_ms,device,0);
  4859. int c;
  4860. foreach(c,saveTempCols)
  4861. {
  4862. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4863. toString(),c);
  4864. }
  4865. foreach(c,saveControlCols)
  4866. {
  4867. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4868. toString(),c);
  4869. }
  4870. foreach(c,saveNoteCols)
  4871. {
  4872. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4873. toString(),c);
  4874. }
  4875. bool retval= writer.output();
  4876. if(prevUnits!=Units::Fahrenheit)
  4877. {
  4878. model_ms->setDisplayUnits(prevUnits);
  4879. }
  4880. return retval;
  4881. }
  4882. /*:419*//*420:*/
  4883. #line 9617 "./typica.w"
  4884. bool ZoomLog::saveCSV(QIODevice*device)
  4885. {
  4886. CSVOutput writer(currentModel,device,0);
  4887. int c;
  4888. foreach(c,saveTempCols)
  4889. {
  4890. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  4891. toString(),c);
  4892. }
  4893. foreach(c,saveControlCols)
  4894. {
  4895. writer.addControlColumn(model_ms->headerData(c,Qt::Horizontal).
  4896. toString(),c);
  4897. }
  4898. foreach(c,saveNoteCols)
  4899. {
  4900. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  4901. toString(),c);
  4902. }
  4903. return writer.output();
  4904. }
  4905. /*:420*//*421:*/
  4906. #line 9646 "./typica.w"
  4907. void ZoomLog::switchLOD(MeasurementModel*m)
  4908. {
  4909. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  4910. setModel(m);
  4911. currentModel= m;
  4912. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4913. }
  4914. void ZoomLog::LOD_ms()
  4915. {
  4916. switchLOD(model_ms);
  4917. }
  4918. void ZoomLog::LOD_1s()
  4919. {
  4920. switchLOD(model_1s);
  4921. }
  4922. void ZoomLog::LOD_5s()
  4923. {
  4924. switchLOD(model_5s);
  4925. }
  4926. void ZoomLog::LOD_10s()
  4927. {
  4928. switchLOD(model_10s);
  4929. }
  4930. void ZoomLog::LOD_15s()
  4931. {
  4932. switchLOD(model_15s);
  4933. }
  4934. void ZoomLog::LOD_30s()
  4935. {
  4936. switchLOD(model_30s);
  4937. }
  4938. void ZoomLog::LOD_1m()
  4939. {
  4940. switchLOD(model_1m);
  4941. }
  4942. /*:421*//*422:*/
  4943. #line 9694 "./typica.w"
  4944. void ZoomLog::setDisplayUnits(Units::Unit scale)
  4945. {
  4946. model_ms->setDisplayUnits(scale);
  4947. model_1s->setDisplayUnits(scale);
  4948. model_5s->setDisplayUnits(scale);
  4949. model_10s->setDisplayUnits(scale);
  4950. model_15s->setDisplayUnits(scale);
  4951. model_30s->setDisplayUnits(scale);
  4952. model_1m->setDisplayUnits(scale);
  4953. }
  4954. Units::Unit ZoomLog::displayUnits()
  4955. {
  4956. return model_ms->displayUnits();
  4957. }
  4958. /*:422*//*423:*/
  4959. #line 9714 "./typica.w"
  4960. QString ZoomLog::lastTime(int series)
  4961. {
  4962. Measurement measure= lastMeasurement.value(series);
  4963. QTime time= measure.time();
  4964. return time.toString("h:mm:ss.zzz");
  4965. }
  4966. /*:423*//*424:*/
  4967. #line 9724 "./typica.w"
  4968. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  4969. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  4970. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  4971. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  4972. {
  4973. setEditTriggers(QAbstractItemView::NoEditTriggers);
  4974. setSelectionMode(QAbstractItemView::NoSelection);
  4975. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  4976. model_30s<<model_1m;
  4977. currentModel= model_30s;
  4978. setModel(currentModel);
  4979. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  4980. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  4981. this,SLOT(persistColumnResize(int,int,int)));
  4982. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  4983. this,SLOT(restoreColumnWidths()));
  4984. }
  4985. /*:424*//*425:*/
  4986. #line 9747 "./typica.w"
  4987. void ZoomLog::setHeaderData(int section,QString text)
  4988. {
  4989. MeasurementModel*m;
  4990. foreach(m,modelSet)
  4991. {
  4992. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  4993. }
  4994. }
  4995. /*:425*//*426:*/
  4996. #line 9765 "./typica.w"
  4997. void ZoomLog::addOutputTemperatureColumn(int column)
  4998. {
  4999. saveTempCols.append(column);
  5000. }
  5001. void ZoomLog::addOutputControlColumn(int column)
  5002. {
  5003. saveControlCols.append(column);
  5004. }
  5005. void ZoomLog::addOutputAnnotationColumn(int column)
  5006. {
  5007. saveNoteCols.append(column);
  5008. }
  5009. void ZoomLog::clearOutputColumns()
  5010. {
  5011. saveTempCols.clear();
  5012. saveControlCols.clear();
  5013. saveNoteCols.clear();
  5014. }
  5015. /*:426*//*427:*/
  5016. #line 9791 "./typica.w"
  5017. void ZoomLog::persistColumnResize(int column,int,int newsize)
  5018. {
  5019. /*653:*/
  5020. #line 13971 "./typica.w"
  5021. QSettings settings;
  5022. /*654:*/
  5023. #line 13984 "./typica.w"
  5024. QWidget*topLevelWidget= this;
  5025. while(topLevelWidget->parentWidget())
  5026. {
  5027. topLevelWidget= topLevelWidget->parentWidget();
  5028. }
  5029. /*:654*/
  5030. #line 13973 "./typica.w"
  5031. settings.setValue(QString("columnWidths/%1/%2/%3").
  5032. arg(topLevelWidget->objectName()).
  5033. arg(objectName()).arg(column),
  5034. QVariant(newsize));
  5035. /*:653*/
  5036. #line 9794 "./typica.w"
  5037. }
  5038. void ZoomLog::restoreColumnWidths()
  5039. {
  5040. /*656:*/
  5041. #line 14004 "./typica.w"
  5042. QSettings settings;
  5043. /*654:*/
  5044. #line 13984 "./typica.w"
  5045. QWidget*topLevelWidget= this;
  5046. while(topLevelWidget->parentWidget())
  5047. {
  5048. topLevelWidget= topLevelWidget->parentWidget();
  5049. }
  5050. /*:654*/
  5051. #line 14006 "./typica.w"
  5052. QString baseKey=
  5053. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5054. arg(objectName());
  5055. for(int i= 0;i<model()->columnCount();i++)
  5056. {
  5057. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5058. if(settings.contains(key))
  5059. {
  5060. setColumnWidth(i,settings.value(key).toInt());
  5061. }
  5062. }
  5063. /*:656*/
  5064. #line 9799 "./typica.w"
  5065. }
  5066. void ZoomLog::setVisible(bool visibility)
  5067. {
  5068. QTableView::setVisible(visibility);
  5069. }
  5070. void ZoomLog::showEvent(QShowEvent*)
  5071. {
  5072. /*656:*/
  5073. #line 14004 "./typica.w"
  5074. QSettings settings;
  5075. /*654:*/
  5076. #line 13984 "./typica.w"
  5077. QWidget*topLevelWidget= this;
  5078. while(topLevelWidget->parentWidget())
  5079. {
  5080. topLevelWidget= topLevelWidget->parentWidget();
  5081. }
  5082. /*:654*/
  5083. #line 14006 "./typica.w"
  5084. QString baseKey=
  5085. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5086. arg(objectName());
  5087. for(int i= 0;i<model()->columnCount();i++)
  5088. {
  5089. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5090. if(settings.contains(key))
  5091. {
  5092. setColumnWidth(i,settings.value(key).toInt());
  5093. }
  5094. }
  5095. /*:656*/
  5096. #line 9809 "./typica.w"
  5097. }
  5098. /*:427*/
  5099. #line 552 "./typica.w"
  5100. /*436:*/
  5101. #line 10042 "./typica.w"
  5102. bool MeasurementList::operator<(const MeasurementList&other)const
  5103. {
  5104. return this->first().toTime()<other.first().toTime();
  5105. }
  5106. bool MeasurementList::operator==(const MeasurementList&other)const
  5107. {
  5108. return this->first().toTime()==other.first().toTime();
  5109. }
  5110. /*:436*//*437:*/
  5111. #line 10058 "./typica.w"
  5112. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  5113. {
  5114. return QModelIndex();
  5115. }
  5116. /*:437*//*438:*/
  5117. #line 10068 "./typica.w"
  5118. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  5119. {
  5120. if(measure.scale()==Units::Unitless)
  5121. {
  5122. controlColumns->insert(tempcolumn,true);
  5123. }
  5124. else
  5125. {
  5126. controlColumns->insert(tempcolumn,false);
  5127. }
  5128. MeasurementList*temp;
  5129. temp= new MeasurementList;
  5130. temp->append(QVariant(measure.time()));
  5131. /*439:*/
  5132. #line 10127 "./typica.w"
  5133. /*440:*/
  5134. #line 10172 "./typica.w"
  5135. QList<MeasurementList*> ::iterator i= lastInsertion;
  5136. bool quickscan= false;
  5137. if(entries->size()> 5)
  5138. {
  5139. if(**i<*temp)
  5140. {
  5141. i+= 1;
  5142. for(int j= 10;j> 0;j--)
  5143. {
  5144. if(i!=entries->end())
  5145. {
  5146. if(**i<*temp)
  5147. {
  5148. i+= 1;
  5149. }
  5150. else
  5151. {
  5152. quickscan= true;
  5153. break;
  5154. }
  5155. }
  5156. else
  5157. {
  5158. quickscan= true;
  5159. break;
  5160. }
  5161. }
  5162. }
  5163. else
  5164. {
  5165. if(**i==*temp)
  5166. {
  5167. quickscan= true;
  5168. }
  5169. }
  5170. }
  5171. /*:440*/
  5172. #line 10128 "./typica.w"
  5173. if(quickscan==false)
  5174. {
  5175. i= entries->begin();
  5176. QList<MeasurementList*> ::iterator u= entries->end();
  5177. QList<MeasurementList*> ::iterator midpoint;
  5178. int n= u-i;
  5179. int rA;
  5180. while(n> 0)
  5181. {
  5182. rA= n>>1;
  5183. midpoint= i+rA;
  5184. if(**midpoint<*temp)
  5185. {
  5186. i= midpoint+1;
  5187. n-= rA+1;
  5188. }
  5189. else
  5190. {
  5191. n= rA;
  5192. }
  5193. }
  5194. }
  5195. /*:439*/
  5196. #line 10082 "./typica.w"
  5197. MeasurementList*newEntry;
  5198. int insertion;
  5199. if(i!=entries->end())
  5200. {
  5201. insertion= entries->indexOf(*i);
  5202. if((*i)->first().toTime()==measure.time())
  5203. {
  5204. /*441:*/
  5205. #line 10214 "./typica.w"
  5206. if((*i)->size()<tempcolumn+1)
  5207. {
  5208. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  5209. {
  5210. (*i)->append(QVariant());
  5211. }
  5212. }
  5213. (*i)->replace(tempcolumn,measure);
  5214. lastInsertion= i;
  5215. emit dataChanged(createIndex(insertion,tempcolumn),
  5216. createIndex(insertion,tempcolumn));
  5217. lastTemperature->insert(tempcolumn,insertion);
  5218. /*:441*/
  5219. #line 10090 "./typica.w"
  5220. }
  5221. else
  5222. {
  5223. /*442:*/
  5224. #line 10232 "./typica.w"
  5225. beginInsertRows(QModelIndex(),insertion,insertion);
  5226. newEntry= new MeasurementList;
  5227. newEntry->append(QVariant(measure.time()));
  5228. for(int j= 0;j<tempcolumn+1;j++)
  5229. {
  5230. newEntry->append(QVariant());
  5231. }
  5232. newEntry->replace(tempcolumn,measure);
  5233. lastInsertion= entries->insert(i,newEntry);
  5234. endInsertRows();
  5235. lastTemperature->insert(tempcolumn,insertion);
  5236. /*:442*/
  5237. #line 10094 "./typica.w"
  5238. }
  5239. }
  5240. else
  5241. {
  5242. /*443:*/
  5243. #line 10250 "./typica.w"
  5244. insertion= entries->size();
  5245. /*442:*/
  5246. #line 10232 "./typica.w"
  5247. beginInsertRows(QModelIndex(),insertion,insertion);
  5248. newEntry= new MeasurementList;
  5249. newEntry->append(QVariant(measure.time()));
  5250. for(int j= 0;j<tempcolumn+1;j++)
  5251. {
  5252. newEntry->append(QVariant());
  5253. }
  5254. newEntry->replace(tempcolumn,measure);
  5255. lastInsertion= entries->insert(i,newEntry);
  5256. endInsertRows();
  5257. lastTemperature->insert(tempcolumn,insertion);
  5258. /*:442*/
  5259. #line 10252 "./typica.w"
  5260. /*:443*/
  5261. #line 10099 "./typica.w"
  5262. }
  5263. if(tempcolumn>=colcount)
  5264. {
  5265. colcount= tempcolumn+1;
  5266. }
  5267. emit rowChanged(insertion);
  5268. delete temp;
  5269. }
  5270. /*:438*//*444:*/
  5271. #line 10262 "./typica.w"
  5272. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  5273. int annotationColumn)
  5274. {
  5275. int r;
  5276. if(lastTemperature->contains(tempcolumn))
  5277. {
  5278. r= lastTemperature->value(tempcolumn);
  5279. }
  5280. else
  5281. {
  5282. r= 0;
  5283. }
  5284. if(r==0&&entries->size()==0)
  5285. {
  5286. /*445:*/
  5287. #line 10300 "./typica.w"
  5288. beginInsertRows(QModelIndex(),0,0);
  5289. MeasurementList*newEntry= new MeasurementList;
  5290. newEntry->append(QVariant(QTime(0,0,0,0)));
  5291. entries->append(newEntry);
  5292. endInsertRows();
  5293. /*:445*/
  5294. #line 10277 "./typica.w"
  5295. }
  5296. MeasurementList*row= entries->at(r);
  5297. if(row->size()<=annotationColumn)
  5298. {
  5299. for(int i= row->size()-1;i<annotationColumn+1;i++)
  5300. {
  5301. row->append(QVariant());
  5302. }
  5303. }
  5304. row->replace(annotationColumn,annotation);
  5305. emit dataChanged(createIndex(r,annotationColumn),
  5306. createIndex(r,annotationColumn));
  5307. emit rowChanged(r);
  5308. if(annotationColumn> colcount-1)
  5309. {
  5310. colcount= annotationColumn+1;
  5311. }
  5312. }
  5313. /*:444*//*446:*/
  5314. #line 10311 "./typica.w"
  5315. void MeasurementModel::clear()
  5316. {
  5317. beginRemoveRows(QModelIndex(),0,entries->size());
  5318. while(entries->size()!=0)
  5319. {
  5320. MeasurementList*row= entries->takeFirst();
  5321. delete row;
  5322. }
  5323. endRemoveRows();
  5324. colcount= hData->size();
  5325. lastTemperature->clear();
  5326. reset();
  5327. }
  5328. /*:446*//*447:*/
  5329. #line 10344 "./typica.w"
  5330. bool MeasurementModel::setData(const QModelIndex&index,
  5331. const QVariant&value,int role)
  5332. {
  5333. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  5334. {
  5335. return false;
  5336. }
  5337. /*448:*/
  5338. #line 10376 "./typica.w"
  5339. bool valid= false;
  5340. if(index.isValid())
  5341. {
  5342. if(index.row()<entries->size())
  5343. {
  5344. if(index.column()<colcount)
  5345. {
  5346. valid= true;
  5347. }
  5348. }
  5349. }
  5350. /*:448*/
  5351. #line 10352 "./typica.w"
  5352. if(!valid)
  5353. {
  5354. return false;
  5355. }
  5356. MeasurementList*row= entries->at(index.row());
  5357. if(index.column()>=row->size())
  5358. {
  5359. /*449:*/
  5360. #line 10393 "./typica.w"
  5361. for(int i= row->size()-1;i<index.column();i++)
  5362. {
  5363. row->append(QVariant());
  5364. }
  5365. /*:449*/
  5366. #line 10360 "./typica.w"
  5367. }
  5368. if(index.column()==0)
  5369. {
  5370. /*450:*/
  5371. #line 10408 "./typica.w"
  5372. QTime time;
  5373. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  5374. {
  5375. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  5376. {
  5377. return false;
  5378. }
  5379. }
  5380. row= entries->takeAt(index.row());
  5381. row->replace(index.column(),QVariant(time));
  5382. MeasurementList*temp= row;
  5383. /*439:*/
  5384. #line 10127 "./typica.w"
  5385. /*440:*/
  5386. #line 10172 "./typica.w"
  5387. QList<MeasurementList*> ::iterator i= lastInsertion;
  5388. bool quickscan= false;
  5389. if(entries->size()> 5)
  5390. {
  5391. if(**i<*temp)
  5392. {
  5393. i+= 1;
  5394. for(int j= 10;j> 0;j--)
  5395. {
  5396. if(i!=entries->end())
  5397. {
  5398. if(**i<*temp)
  5399. {
  5400. i+= 1;
  5401. }
  5402. else
  5403. {
  5404. quickscan= true;
  5405. break;
  5406. }
  5407. }
  5408. else
  5409. {
  5410. quickscan= true;
  5411. break;
  5412. }
  5413. }
  5414. }
  5415. else
  5416. {
  5417. if(**i==*temp)
  5418. {
  5419. quickscan= true;
  5420. }
  5421. }
  5422. }
  5423. /*:440*/
  5424. #line 10128 "./typica.w"
  5425. if(quickscan==false)
  5426. {
  5427. i= entries->begin();
  5428. QList<MeasurementList*> ::iterator u= entries->end();
  5429. QList<MeasurementList*> ::iterator midpoint;
  5430. int n= u-i;
  5431. int rA;
  5432. while(n> 0)
  5433. {
  5434. rA= n>>1;
  5435. midpoint= i+rA;
  5436. if(**midpoint<*temp)
  5437. {
  5438. i= midpoint+1;
  5439. n-= rA+1;
  5440. }
  5441. else
  5442. {
  5443. n= rA;
  5444. }
  5445. }
  5446. }
  5447. /*:439*/
  5448. #line 10420 "./typica.w"
  5449. entries->insert(i,row);
  5450. int newRow= entries->indexOf(*i);
  5451. if(newRow<index.row())
  5452. {
  5453. emit dataChanged(createIndex(newRow,index.column()),index);
  5454. }
  5455. else
  5456. {
  5457. emit dataChanged(index,createIndex(newRow,index.column()));
  5458. }
  5459. /*:450*/
  5460. #line 10364 "./typica.w"
  5461. }
  5462. else
  5463. {
  5464. /*451:*/
  5465. #line 10434 "./typica.w"
  5466. row->replace(index.column(),value);
  5467. emit dataChanged(index,index);
  5468. /*:451*/
  5469. #line 10368 "./typica.w"
  5470. }
  5471. return true;
  5472. }
  5473. /*:447*//*452:*/
  5474. #line 10442 "./typica.w"
  5475. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  5476. unit(Units::Fahrenheit),hData(new QStringList),
  5477. lastTemperature(new QHash<int,int> ),
  5478. controlColumns(new QHash<int,bool> )
  5479. {
  5480. colcount= 1;
  5481. entries= new QList<MeasurementList*> ;
  5482. lastInsertion= entries->begin();
  5483. hData->append(tr("Time"));
  5484. }
  5485. /*:452*//*453:*/
  5486. #line 10456 "./typica.w"
  5487. MeasurementModel::~MeasurementModel()
  5488. {
  5489. clear();
  5490. delete entries;
  5491. delete hData;
  5492. }
  5493. /*:453*//*454:*/
  5494. #line 10468 "./typica.w"
  5495. int MeasurementModel::rowCount(const QModelIndex&parent)const
  5496. {
  5497. if(parent==QModelIndex())
  5498. {
  5499. return entries->size();
  5500. }
  5501. return 0;
  5502. }
  5503. int MeasurementModel::columnCount(const QModelIndex&parent)const
  5504. {
  5505. if(parent==QModelIndex())
  5506. {
  5507. return colcount;
  5508. }
  5509. return 0;
  5510. }
  5511. /*:454*//*455:*/
  5512. #line 10495 "./typica.w"
  5513. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  5514. const QVariant&value,int)
  5515. {
  5516. if(orientation==Qt::Horizontal)
  5517. {
  5518. if(hData->size()<section+1)
  5519. {
  5520. for(int i= hData->size();i<section+1;i++)
  5521. {
  5522. if(colcount<i)
  5523. {
  5524. beginInsertColumns(QModelIndex(),i,i);
  5525. }
  5526. hData->append(QString());
  5527. if(colcount<i)
  5528. {
  5529. endInsertColumns();
  5530. }
  5531. }
  5532. }
  5533. hData->replace(section,value.toString());
  5534. emit headerDataChanged(orientation,section,section);
  5535. if(colcount<section+1)
  5536. {
  5537. colcount= section+1;
  5538. }
  5539. return true;
  5540. }
  5541. return false;
  5542. }
  5543. /*:455*//*456:*/
  5544. #line 10535 "./typica.w"
  5545. void MeasurementModel::setDisplayUnits(Units::Unit scale)
  5546. {
  5547. beginResetModel();
  5548. unit= scale;
  5549. endResetModel();
  5550. }
  5551. Units::Unit MeasurementModel::displayUnits()
  5552. {
  5553. return unit;
  5554. }
  5555. /*:456*//*457:*/
  5556. #line 10561 "./typica.w"
  5557. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  5558. {
  5559. /*448:*/
  5560. #line 10376 "./typica.w"
  5561. bool valid= false;
  5562. if(index.isValid())
  5563. {
  5564. if(index.row()<entries->size())
  5565. {
  5566. if(index.column()<colcount)
  5567. {
  5568. valid= true;
  5569. }
  5570. }
  5571. }
  5572. /*:448*/
  5573. #line 10564 "./typica.w"
  5574. if(!valid)
  5575. {
  5576. return QVariant();
  5577. }
  5578. MeasurementList*row= entries->at(index.row());
  5579. if(role==Qt::UserRole)
  5580. {
  5581. return QVariant(row->at(index.column()));
  5582. }
  5583. if(role==Qt::DisplayRole||role==Qt::EditRole)
  5584. {
  5585. if(index.column()> row->size())
  5586. {
  5587. return QVariant();
  5588. }
  5589. else
  5590. {
  5591. if(index.column()==0)
  5592. {
  5593. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  5594. }
  5595. else if(lastTemperature->contains(index.column()))
  5596. {
  5597. QVariantMap v= row->at(index.column()).toMap();
  5598. if(!v.contains("measurement"))
  5599. {
  5600. return QVariant();
  5601. }
  5602. if((Units::Unit)(v.value("unit").toInt())==Units::Unitless)
  5603. {
  5604. return v.value("measurement");
  5605. }
  5606. else
  5607. {
  5608. if(v.contains("relative"))
  5609. {
  5610. if(v.value("relative").toBool())
  5611. {
  5612. return QVariant(QString("%1").arg(Units::convertRelativeTemperature(v.value("measurement").
  5613. toDouble(),(Units::Unit)(v.value("unit").toInt()),unit)));
  5614. }
  5615. }
  5616. return QVariant(QString("%1").
  5617. arg(Units::convertTemperature(v.value("measurement").toDouble(),
  5618. (Units::Unit)(v.value("unit").toInt()),unit)));
  5619. }
  5620. }
  5621. return QVariant(row->at(index.column()).toString());
  5622. }
  5623. }
  5624. return QVariant();
  5625. }
  5626. /*:457*//*458:*/
  5627. #line 10620 "./typica.w"
  5628. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  5629. int role)const
  5630. {
  5631. if(orientation==Qt::Horizontal)
  5632. {
  5633. if(role==Qt::DisplayRole)
  5634. {
  5635. if(section<hData->size())
  5636. {
  5637. return QVariant(hData->at(section));
  5638. }
  5639. }
  5640. }
  5641. return QVariant();
  5642. }
  5643. /*:458*//*459:*/
  5644. #line 10647 "./typica.w"
  5645. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  5646. {
  5647. /*448:*/
  5648. #line 10376 "./typica.w"
  5649. bool valid= false;
  5650. if(index.isValid())
  5651. {
  5652. if(index.row()<entries->size())
  5653. {
  5654. if(index.column()<colcount)
  5655. {
  5656. valid= true;
  5657. }
  5658. }
  5659. }
  5660. /*:448*/
  5661. #line 10650 "./typica.w"
  5662. if(valid)
  5663. {
  5664. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5665. }
  5666. return 0;
  5667. }
  5668. /*:459*//*460:*/
  5669. #line 10662 "./typica.w"
  5670. QModelIndex MeasurementModel::index(int row,int column,
  5671. const QModelIndex&parent)const
  5672. {
  5673. if(parent==QModelIndex())
  5674. {
  5675. if(row<entries->size()&&entries->isEmpty()==false)
  5676. {
  5677. if(column<entries->at(row)->size())
  5678. {
  5679. return createIndex(row,column);
  5680. }
  5681. }
  5682. }
  5683. return QModelIndex();
  5684. }
  5685. /*:460*/
  5686. #line 553 "./typica.w"
  5687. /*462:*/
  5688. #line 10713 "./typica.w"
  5689. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  5690. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  5691. {
  5692. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  5693. }
  5694. /*:462*//*463:*/
  5695. #line 10728 "./typica.w"
  5696. void AnnotationButton::annotate()
  5697. {
  5698. if(note.contains("%1"))
  5699. {
  5700. count++;
  5701. emit annotation(note.arg(count),tc,ac);
  5702. }
  5703. else
  5704. {
  5705. emit annotation(note,tc,ac);
  5706. }
  5707. }
  5708. /*:463*//*464:*/
  5709. #line 10746 "./typica.w"
  5710. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  5711. {
  5712. tc= tempcolumn;
  5713. }
  5714. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  5715. {
  5716. ac= annotationcolumn;
  5717. }
  5718. void AnnotationButton::setAnnotation(const QString&annotation)
  5719. {
  5720. note= annotation;
  5721. }
  5722. /*:464*//*465:*/
  5723. #line 10765 "./typica.w"
  5724. void AnnotationButton::resetCount()
  5725. {
  5726. count= 0;
  5727. }
  5728. /*:465*/
  5729. #line 554 "./typica.w"
  5730. /*470:*/
  5731. #line 10848 "./typica.w"
  5732. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  5733. const QString&postt,
  5734. QWidget*parent)
  5735. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  5736. {
  5737. resetChange();
  5738. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  5739. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  5740. }
  5741. /*:470*//*471:*/
  5742. #line 10865 "./typica.w"
  5743. void AnnotationSpinBox::resetChange()
  5744. {
  5745. change= true;
  5746. }
  5747. /*:471*//*472:*/
  5748. #line 10876 "./typica.w"
  5749. void AnnotationSpinBox::annotate()
  5750. {
  5751. if(change)
  5752. {
  5753. change= false;
  5754. emit annotation(QString("%1%2%3").arg(pretext).
  5755. arg(value()).arg(posttext),tc,ac);
  5756. }
  5757. }
  5758. /*:472*//*473:*/
  5759. #line 10889 "./typica.w"
  5760. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  5761. {
  5762. tc= tempcolumn;
  5763. }
  5764. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  5765. {
  5766. ac= annotationcolumn;
  5767. }
  5768. void AnnotationSpinBox::setPretext(const QString&pret)
  5769. {
  5770. pretext= pret;
  5771. }
  5772. void AnnotationSpinBox::setPosttext(const QString&postt)
  5773. {
  5774. posttext= postt;
  5775. }
  5776. /*:473*/
  5777. #line 555 "./typica.w"
  5778. /*480:*/
  5779. #line 11058 "./typica.w"
  5780. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  5781. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  5782. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  5783. stopAction(new QAction(tr("Stop"),NULL)),
  5784. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  5785. relative(QTime::currentTime()),base(QTime(0,0,0))
  5786. {
  5787. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  5788. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  5789. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  5790. clock.setInterval(500);
  5791. clock.setSingleShot(false);
  5792. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  5793. setSegmentStyle(Filled);
  5794. updateDisplay();
  5795. }
  5796. /*:480*//*481:*/
  5797. #line 11079 "./typica.w"
  5798. void TimerDisplay::updateTime()
  5799. {
  5800. QTime time;
  5801. int cseconds= 0;
  5802. int oseconds= 0;
  5803. int r= 0;
  5804. QTime nt= QTime(0,0,0);
  5805. int n= 0;
  5806. int bseconds= 0;
  5807. switch(m)
  5808. {
  5809. case TimerDisplay::CountUp:
  5810. /*482:*/
  5811. #line 11111 "./typica.w"
  5812. /*483:*/
  5813. #line 11124 "./typica.w"
  5814. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5815. time= QTime::currentTime();
  5816. cseconds= TIMETOINT(time);
  5817. oseconds= TIMETOINT(relative);
  5818. r= cseconds-oseconds;
  5819. /*:483*/
  5820. #line 11112 "./typica.w"
  5821. nt= nt.addSecs(r);
  5822. if(nt!=s)
  5823. {
  5824. s= nt;
  5825. emit valueChanged(s);
  5826. }
  5827. /*:482*/
  5828. #line 11092 "./typica.w"
  5829. ;
  5830. break;
  5831. case TimerDisplay::CountDown:
  5832. /*484:*/
  5833. #line 11136 "./typica.w"
  5834. if(s> QTime(0,0,0))
  5835. {
  5836. /*483:*/
  5837. #line 11124 "./typica.w"
  5838. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  5839. time= QTime::currentTime();
  5840. cseconds= TIMETOINT(time);
  5841. oseconds= TIMETOINT(relative);
  5842. r= cseconds-oseconds;
  5843. /*:483*/
  5844. #line 11139 "./typica.w"
  5845. bseconds= TIMETOINT(base);
  5846. n= bseconds-r;
  5847. nt= nt.addSecs(n);
  5848. if(nt!=s)
  5849. {
  5850. s= nt;
  5851. emit valueChanged(s);
  5852. }
  5853. }else{
  5854. stopTimer();
  5855. }
  5856. /*:484*/
  5857. #line 11095 "./typica.w"
  5858. ;
  5859. break;
  5860. case TimerDisplay::Clock:
  5861. /*485:*/
  5862. #line 11155 "./typica.w"
  5863. time= QTime::currentTime();
  5864. if(time!=s)
  5865. {
  5866. s= time;
  5867. emit valueChanged(s);
  5868. }
  5869. /*:485*/
  5870. #line 11098 "./typica.w"
  5871. ;
  5872. break;
  5873. default:
  5874. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  5875. break;
  5876. }
  5877. updateDisplay();
  5878. }
  5879. /*:481*//*486:*/
  5880. #line 11167 "./typica.w"
  5881. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  5882. void TimerDisplay::startTimer()
  5883. {
  5884. if(!running)
  5885. {
  5886. relative= QTime::currentTime();
  5887. if(ar)
  5888. {
  5889. reset();
  5890. }
  5891. else
  5892. {
  5893. relative= TIMESUBTRACT(relative,s);
  5894. }
  5895. if(m==Clock)
  5896. {
  5897. updateTime();
  5898. }
  5899. base= s;
  5900. clock.start();
  5901. running= true;
  5902. emit runStateChanged(true);
  5903. }
  5904. }
  5905. /*:486*//*487:*/
  5906. #line 11197 "./typica.w"
  5907. void TimerDisplay::stopTimer()
  5908. {
  5909. if(running)
  5910. {
  5911. clock.stop();
  5912. running= false;
  5913. emit runStateChanged(false);
  5914. }
  5915. }
  5916. /*:487*//*488:*/
  5917. #line 11210 "./typica.w"
  5918. TimerDisplay::~TimerDisplay()
  5919. {
  5920. clock.stop();
  5921. }
  5922. /*:488*//*489:*/
  5923. #line 11219 "./typica.w"
  5924. void TimerDisplay::setCountUpMode()
  5925. {
  5926. m= TimerDisplay::CountUp;
  5927. }
  5928. void TimerDisplay::setCountDownMode()
  5929. {
  5930. m= TimerDisplay::CountDown;
  5931. }
  5932. void TimerDisplay::setClockMode()
  5933. {
  5934. m= TimerDisplay::Clock;
  5935. }
  5936. /*:489*//*490:*/
  5937. #line 11237 "./typica.w"
  5938. QString TimerDisplay::value()
  5939. {
  5940. return s.toString(f);
  5941. }
  5942. QTime TimerDisplay::seconds()
  5943. {
  5944. return s;
  5945. }
  5946. TimerDisplay::TimerMode TimerDisplay::mode()
  5947. {
  5948. return m;
  5949. }
  5950. bool TimerDisplay::isRunning()
  5951. {
  5952. return running;
  5953. }
  5954. QTime TimerDisplay::resetValue()
  5955. {
  5956. return r;
  5957. }
  5958. QString TimerDisplay::displayFormat()
  5959. {
  5960. return f;
  5961. }
  5962. bool TimerDisplay::autoReset()
  5963. {
  5964. return ar;
  5965. }
  5966. /*:490*//*491:*/
  5967. #line 11275 "./typica.w"
  5968. void TimerDisplay::setTimer(QTime value)
  5969. {
  5970. if(value.isValid())
  5971. {
  5972. s= value;
  5973. updateDisplay();
  5974. emit valueChanged(value);
  5975. }
  5976. }
  5977. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  5978. {
  5979. m= mode;
  5980. }
  5981. void TimerDisplay::setResetValue(QTime value)
  5982. {
  5983. r= value;
  5984. }
  5985. void TimerDisplay::setDisplayFormat(QString format)
  5986. {
  5987. f= format;
  5988. setNumDigits(format.length());
  5989. }
  5990. void TimerDisplay::setAutoReset(bool reset)
  5991. {
  5992. ar= reset;
  5993. }
  5994. /*:491*//*492:*/
  5995. #line 11310 "./typica.w"
  5996. void TimerDisplay::copyTimer()
  5997. {
  5998. QApplication::clipboard()->setText(value());
  5999. }
  6000. /*:492*//*493:*/
  6001. #line 11319 "./typica.w"
  6002. void TimerDisplay::reset()
  6003. {
  6004. if(!running)
  6005. {
  6006. s= r;
  6007. updateDisplay();
  6008. }
  6009. }
  6010. /*:493*//*494:*/
  6011. #line 11332 "./typica.w"
  6012. void TimerDisplay::updateDisplay()
  6013. {
  6014. display(value());
  6015. }
  6016. /*:494*/
  6017. #line 556 "./typica.w"
  6018. /*501:*/
  6019. #line 11457 "./typica.w"
  6020. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  6021. {
  6022. int x= rect.x();
  6023. int y= rect.y();
  6024. QLayoutItem*item;
  6025. if(orientation==Qt::Horizontal)
  6026. {
  6027. /*502:*/
  6028. #line 11481 "./typica.w"
  6029. foreach(item,itemList)
  6030. {
  6031. int nextX= x+item->sizeHint().width()+spacing();
  6032. int right= x+item->sizeHint().width();
  6033. if(item==itemList.last())
  6034. {
  6035. right= rect.right();
  6036. }
  6037. int bottom= rect.bottom();
  6038. if(!testOnly)
  6039. {
  6040. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6041. }
  6042. x= nextX;
  6043. }
  6044. /*:502*/
  6045. #line 11465 "./typica.w"
  6046. }
  6047. else
  6048. {
  6049. /*503:*/
  6050. #line 11500 "./typica.w"
  6051. foreach(item,itemList)
  6052. {
  6053. int nextY= y+item->sizeHint().height()+spacing();
  6054. int bottom= y+item->sizeHint().height();
  6055. if(item==itemList.last())
  6056. {
  6057. bottom= rect.bottom();
  6058. }
  6059. int right= rect.right();
  6060. if(!testOnly)
  6061. {
  6062. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  6063. }
  6064. y= nextY;
  6065. }
  6066. /*:503*/
  6067. #line 11469 "./typica.w"
  6068. }
  6069. return y;
  6070. }
  6071. /*:501*//*504:*/
  6072. #line 11524 "./typica.w"
  6073. QSize PackLayout::minimumSize()const
  6074. {
  6075. QSize size;
  6076. QLayoutItem*item;
  6077. foreach(item,itemList)
  6078. {
  6079. if(orientation==Qt::Horizontal)
  6080. {
  6081. size+= QSize(item->minimumSize().width(),0);
  6082. if(size.height()<item->minimumSize().height())
  6083. {
  6084. size.setHeight(item->minimumSize().height());
  6085. }
  6086. }
  6087. else
  6088. {
  6089. size+= QSize(0,item->minimumSize().height());
  6090. if(size.width()<item->minimumSize().width())
  6091. {
  6092. size.setWidth(item->minimumSize().width());
  6093. }
  6094. }
  6095. }
  6096. size+= QSize(2*margin(),2*margin());
  6097. return size;
  6098. }
  6099. /*:504*//*505:*/
  6100. #line 11556 "./typica.w"
  6101. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  6102. QLayout(parent)
  6103. {
  6104. setMargin(margin);
  6105. setSpacing(spacing);
  6106. setOrientation(Qt::Horizontal);
  6107. }
  6108. PackLayout::PackLayout(int spacing)
  6109. {
  6110. setSpacing(spacing);
  6111. setOrientation(Qt::Horizontal);
  6112. }
  6113. /*:505*//*506:*/
  6114. #line 11574 "./typica.w"
  6115. PackLayout::~PackLayout()
  6116. {
  6117. QLayoutItem*item;
  6118. while((item= takeAt(0)))
  6119. {
  6120. delete item;
  6121. }
  6122. }
  6123. /*:506*//*507:*/
  6124. #line 11588 "./typica.w"
  6125. QLayoutItem*PackLayout::takeAt(int index)
  6126. {
  6127. if(index>=0&&index<itemList.size())
  6128. {
  6129. return itemList.takeAt(index);
  6130. }
  6131. else
  6132. {
  6133. return NULL;
  6134. }
  6135. }
  6136. /*:507*//*508:*/
  6137. #line 11604 "./typica.w"
  6138. QLayoutItem*PackLayout::itemAt(int index)const
  6139. {
  6140. if(index>=0&&index<itemList.size())
  6141. {
  6142. return itemList.at(index);
  6143. }
  6144. else
  6145. {
  6146. return NULL;
  6147. }
  6148. }
  6149. /*:508*//*509:*/
  6150. #line 11627 "./typica.w"
  6151. void PackLayout::addItem(QLayoutItem*item)
  6152. {
  6153. itemList.append(item);
  6154. }
  6155. /*:509*//*510:*/
  6156. #line 11635 "./typica.w"
  6157. int PackLayout::count()const
  6158. {
  6159. return itemList.size();
  6160. }
  6161. /*:510*//*511:*/
  6162. #line 11647 "./typica.w"
  6163. Qt::Orientations PackLayout::expandingDirections()const
  6164. {
  6165. return Qt::Vertical|Qt::Horizontal;
  6166. }
  6167. bool PackLayout::hasHeightForWidth()const
  6168. {
  6169. return false;
  6170. }
  6171. int PackLayout::heightForWidth(int width)const
  6172. {
  6173. return doLayout(QRect(0,0,width,0),true);
  6174. }
  6175. void PackLayout::setGeometry(const QRect&rect)
  6176. {
  6177. QLayout::setGeometry(rect);
  6178. doLayout(rect,false);
  6179. }
  6180. QSize PackLayout::sizeHint()const
  6181. {
  6182. return minimumSize();
  6183. }
  6184. /*:511*//*512:*/
  6185. #line 11678 "./typica.w"
  6186. void PackLayout::setOrientation(Qt::Orientations direction)
  6187. {
  6188. orientation= direction;
  6189. doLayout(geometry(),false);
  6190. }
  6191. /*:512*/
  6192. #line 557 "./typica.w"
  6193. /*514:*/
  6194. #line 11717 "./typica.w"
  6195. SceneButton::SceneButton():QGraphicsScene()
  6196. {
  6197. }
  6198. SceneButton::~SceneButton()
  6199. {
  6200. }
  6201. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  6202. {
  6203. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  6204. }
  6205. /*:514*/
  6206. #line 558 "./typica.w"
  6207. /*516:*/
  6208. #line 11763 "./typica.w"
  6209. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  6210. Qt::Orientations orientation,
  6211. QWidget*parent,Qt::WindowFlags f):
  6212. QWidget(parent,f),label(new QGraphicsView()),
  6213. scene(new SceneButton())
  6214. {
  6215. layout= new PackLayout(this);
  6216. layout->setOrientation(orientation);
  6217. /*517:*/
  6218. #line 11783 "./typica.w"
  6219. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6220. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6221. label->setFrameShape(QFrame::NoFrame);
  6222. label->setInteractive(true);
  6223. /*:517*/
  6224. #line 11772 "./typica.w"
  6225. /*518:*/
  6226. #line 11794 "./typica.w"
  6227. scene->setBackgroundBrush(Qt::cyan);
  6228. text= scene->addText(labeltext);
  6229. if(orientation==Qt::Horizontal)
  6230. {
  6231. text->rotate(270.0);
  6232. }
  6233. label->setScene(scene);
  6234. /*:518*/
  6235. #line 11773 "./typica.w"
  6236. /*519:*/
  6237. #line 11812 "./typica.w"
  6238. if(orientation==Qt::Horizontal)
  6239. {
  6240. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  6241. }
  6242. else
  6243. {
  6244. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  6245. }
  6246. label->centerOn(text);
  6247. /*:519*/
  6248. #line 11774 "./typica.w"
  6249. /*520:*/
  6250. #line 11827 "./typica.w"
  6251. layout->addWidget(label);
  6252. layout->addWidget(widget);
  6253. if(orientation==Qt::Horizontal)
  6254. {
  6255. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  6256. widget->sizeHint().height());
  6257. }
  6258. else
  6259. {
  6260. setMinimumSize(widget->sizeHint().width(),
  6261. widget->sizeHint().height()+label->sizeHint().height());
  6262. }
  6263. /*:520*/
  6264. #line 11775 "./typica.w"
  6265. }
  6266. /*:516*//*521:*/
  6267. #line 11844 "./typica.w"
  6268. void WidgetDecorator::setBackgroundBrush(QBrush background)
  6269. {
  6270. scene->setBackgroundBrush(background);
  6271. }
  6272. void WidgetDecorator::setTextColor(QColor color)
  6273. {
  6274. text->setDefaultTextColor(color);
  6275. }
  6276. /*:521*//*522:*/
  6277. #line 11857 "./typica.w"
  6278. WidgetDecorator::~WidgetDecorator()
  6279. {
  6280. }
  6281. /*:522*/
  6282. #line 559 "./typica.w"
  6283. /*527:*/
  6284. #line 11956 "./typica.w"
  6285. void LogEditWindow::addTheRows()
  6286. {
  6287. QTime s= startTime->time();
  6288. while(s<endTime->time())
  6289. {
  6290. model->newMeasurement(Measurement(0,s),1);
  6291. s= s.addSecs(interval->value());
  6292. }
  6293. model->newMeasurement(Measurement(0,endTime->time()),1);
  6294. }
  6295. /*:527*//*528:*/
  6296. #line 11970 "./typica.w"
  6297. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  6298. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  6299. addRowsLayout(new QHBoxLayout(NULL)),
  6300. startTimeLabel(new QLabel("Start Time")),
  6301. startTime(new QTimeEdit(QTime(0,0,0,0))),
  6302. endTimeLabel(new QLabel("End Time")),
  6303. endTime(new QTimeEdit(QTime(0,20,0,0))),
  6304. intervalLabel(new QLabel("Interval (seconds)")),
  6305. interval(new QSpinBox()),
  6306. addRows(new QPushButton("Add Rows")),
  6307. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  6308. saveCsv(new QAction(tr("Export CSV"),NULL)),
  6309. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  6310. model(new MeasurementModel()),
  6311. log(new QTableView())
  6312. {
  6313. /*529:*/
  6314. #line 12007 "./typica.w"
  6315. QSettings settings;
  6316. resize(settings.value("logSize",QSize(620,400)).toSize());
  6317. move(settings.value("logPos",QPoint(200,60)).toPoint());
  6318. /*:529*/
  6319. #line 11987 "./typica.w"
  6320. /*530:*/
  6321. #line 12020 "./typica.w"
  6322. mainLayout->setOrientation(Qt::Vertical);
  6323. addRowsLayout->addSpacing(10);
  6324. addRowsLayout->addWidget(startTimeLabel);
  6325. addRowsLayout->addWidget(startTime);
  6326. addRowsLayout->addSpacing(10);
  6327. startTime->setDisplayFormat("mm:ss");
  6328. addRowsLayout->addWidget(endTimeLabel);
  6329. addRowsLayout->addWidget(endTime);
  6330. addRowsLayout->addSpacing(10);
  6331. endTime->setDisplayFormat("mm:ss");
  6332. addRowsLayout->addWidget(intervalLabel);
  6333. addRowsLayout->addWidget(interval);
  6334. addRowsLayout->addSpacing(10);
  6335. interval->setRange(0,60);
  6336. interval->setValue(30);
  6337. addRowsLayout->addWidget(addRows);
  6338. addRowsLayout->addSpacing(10);
  6339. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  6340. /*:530*/
  6341. #line 11988 "./typica.w"
  6342. /*531:*/
  6343. #line 12043 "./typica.w"
  6344. model->setHeaderData(0,Qt::Horizontal,"Time");
  6345. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  6346. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  6347. model->clear();
  6348. /*:531*/
  6349. #line 11989 "./typica.w"
  6350. /*532:*/
  6351. #line 12052 "./typica.w"
  6352. log->setModel(model);
  6353. log->setColumnWidth(0,100);
  6354. log->setColumnWidth(1,100);
  6355. log->setColumnWidth(2,100);
  6356. /*:532*/
  6357. #line 11990 "./typica.w"
  6358. mainLayout->addItem(addRowsLayout);
  6359. mainLayout->addWidget(log);
  6360. centralWidget->setLayout(mainLayout);
  6361. setCentralWidget(centralWidget);
  6362. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  6363. fileMenu->addAction(openXml);
  6364. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  6365. fileMenu->addAction(saveXml);
  6366. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  6367. fileMenu->addAction(saveCsv);
  6368. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  6369. }
  6370. /*:528*//*533:*/
  6371. #line 12063 "./typica.w"
  6372. void LogEditWindow::saveXML()
  6373. {
  6374. QSettings settings;
  6375. QString lastDir= settings.value("lastDirectory").toString();
  6376. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  6377. lastDir,"",0);
  6378. QFile file(filename);
  6379. XMLOutput writer(model,&file,0);
  6380. writer.addTemperatureColumn("Temperature",1);
  6381. writer.addAnnotationColumn("Annotation",2);
  6382. if(writer.output())
  6383. {
  6384. QFileInfo info(filename);
  6385. QDir directory= info.dir();
  6386. lastDir= directory.path();
  6387. settings.setValue("lastDirectory",lastDir);
  6388. }
  6389. }
  6390. void LogEditWindow::saveCSV()
  6391. {
  6392. QSettings settings;
  6393. QString lastDir= settings.value("lastDirectory").toString();
  6394. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  6395. lastDir,"",0);
  6396. QFile file(filename);
  6397. CSVOutput writer(model,&file,0);
  6398. writer.addTemperatureColumn("Temperature",1);
  6399. writer.addAnnotationColumn("Annotation",2);
  6400. if(writer.output())
  6401. {
  6402. QFileInfo info(filename);
  6403. QDir directory= info.dir();
  6404. lastDir= directory.path();
  6405. settings.setValue("lastDirectory",lastDir);
  6406. }
  6407. }
  6408. /*:533*//*534:*/
  6409. #line 12106 "./typica.w"
  6410. void LogEditWindow::openXML()
  6411. {
  6412. QSettings settings;
  6413. QString lastDir= settings.value("lastDirectory").toString();
  6414. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  6415. lastDir,"",0);
  6416. if(filename.isNull())
  6417. {
  6418. return;
  6419. }
  6420. QFile file(filename);
  6421. XMLInput reader(&file,1);
  6422. connect(&reader,SIGNAL(measure(Measurement,int)),
  6423. model,SLOT(newMeasurement(Measurement,int)));
  6424. connect(&reader,SIGNAL(annotation(QString,int,int)),
  6425. model,SLOT(newAnnotation(QString,int,int)));
  6426. if(reader.input())
  6427. {
  6428. QFileInfo info(filename);
  6429. setWindowTitle(QString(tr("%1 - %2")).
  6430. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  6431. QDir directory= info.dir();
  6432. lastDir= directory.path();
  6433. settings.setValue("lastDirectory",lastDir);
  6434. }
  6435. }
  6436. /*:534*//*535:*/
  6437. #line 12137 "./typica.w"
  6438. void LogEditWindow::closeEvent(QCloseEvent*event)
  6439. {
  6440. QSettings settings;
  6441. settings.setValue("logSize",size());
  6442. settings.setValue("logPos",pos());
  6443. event->accept();
  6444. }
  6445. /*:535*/
  6446. #line 560 "./typica.w"
  6447. /*541:*/
  6448. #line 12252 "./typica.w"
  6449. bool XMLOutput::output()
  6450. {
  6451. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6452. {
  6453. return false;
  6454. }
  6455. QXmlStreamWriter xmlout(out);
  6456. xmlout.writeStartDocument("1.0");
  6457. xmlout.writeDTD("<!DOCTYPE roastlog3.0>");
  6458. xmlout.writeStartElement("roastlog");
  6459. /*542:*/
  6460. #line 12285 "./typica.w"
  6461. foreach(int c,temperatureColumns.keys())
  6462. {
  6463. xmlout.writeStartElement("tempseries");
  6464. xmlout.writeAttribute("name",temperatureColumns.value(c));
  6465. xmlout.writeEndElement();
  6466. }
  6467. foreach(int c,controlColumns.keys())
  6468. {
  6469. xmlout.writeStartElement("controlseries");
  6470. xmlout.writeAttribute("name",controlColumns.value(c));
  6471. xmlout.writeEndElement();
  6472. }
  6473. foreach(int c,annotationColumns.keys())
  6474. {
  6475. xmlout.writeStartElement("noteseries");
  6476. xmlout.writeAttribute("name",annotationColumns.value(c));
  6477. xmlout.writeEndElement();
  6478. }
  6479. /*:542*/
  6480. #line 12263 "./typica.w"
  6481. xmlout.writeStartElement("roast");
  6482. bool oresult;
  6483. for(int i= 0;i<data->rowCount();i++)
  6484. {
  6485. /*543:*/
  6486. #line 12310 "./typica.w"
  6487. oresult= false;
  6488. foreach(int c,temperatureColumns.keys())
  6489. {
  6490. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6491. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6492. {
  6493. oresult= true;
  6494. break;
  6495. }
  6496. }
  6497. foreach(int c,controlColumns.keys())
  6498. {
  6499. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6500. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6501. {
  6502. oresult= true;
  6503. break;
  6504. }
  6505. }
  6506. if(oresult==false)
  6507. {
  6508. foreach(int c,annotationColumns.keys())
  6509. {
  6510. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6511. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6512. isEmpty()))
  6513. {
  6514. oresult= true;
  6515. break;
  6516. }
  6517. }
  6518. }
  6519. /*:543*/
  6520. #line 12268 "./typica.w"
  6521. if(oresult)
  6522. {
  6523. /*544:*/
  6524. #line 12349 "./typica.w"
  6525. xmlout.writeStartElement("tuple");
  6526. xmlout.writeTextElement("time",data->data(data->index(i,time),
  6527. Qt::DisplayRole).toString());
  6528. foreach(int c,temperatureColumns.keys())
  6529. {
  6530. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6531. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6532. {
  6533. xmlout.writeStartElement("temperature");
  6534. xmlout.writeAttribute("series",temperatureColumns.value(c));
  6535. if(data->data(data->index(i,c),Qt::UserRole).toMap().contains("relative"))
  6536. {
  6537. if(data->data(data->index(i,c),Qt::UserRole).toMap().value("relative").toBool())
  6538. {
  6539. xmlout.writeAttribute("relative","true");
  6540. }
  6541. }
  6542. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6543. toString());
  6544. xmlout.writeEndElement();
  6545. }
  6546. }
  6547. foreach(int c,controlColumns.keys())
  6548. {
  6549. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6550. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6551. {
  6552. xmlout.writeStartElement("control");
  6553. xmlout.writeAttribute("series",controlColumns.value(c));
  6554. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).toString());
  6555. xmlout.writeEndElement();
  6556. }
  6557. }
  6558. foreach(int c,annotationColumns.keys())
  6559. {
  6560. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6561. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6562. {
  6563. xmlout.writeStartElement("annotation");
  6564. xmlout.writeAttribute("series",annotationColumns.value(c));
  6565. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  6566. toString());
  6567. xmlout.writeEndElement();
  6568. }
  6569. }
  6570. xmlout.writeEndElement();
  6571. /*:544*/
  6572. #line 12271 "./typica.w"
  6573. }
  6574. }
  6575. xmlout.writeEndElement();
  6576. xmlout.writeEndElement();
  6577. xmlout.writeEndDocument();
  6578. out->close();
  6579. return true;
  6580. }
  6581. /*:541*//*545:*/
  6582. #line 12399 "./typica.w"
  6583. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  6584. :QObject(NULL),data(model),out(device),time(timec)
  6585. {
  6586. }
  6587. void XMLOutput::setModel(MeasurementModel*model)
  6588. {
  6589. data= model;
  6590. }
  6591. void XMLOutput::setTimeColumn(int column)
  6592. {
  6593. time= column;
  6594. }
  6595. void XMLOutput::setDevice(QIODevice*device)
  6596. {
  6597. out= device;
  6598. }
  6599. /*:545*//*546:*/
  6600. #line 12428 "./typica.w"
  6601. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  6602. {
  6603. temperatureColumns.insert(column,series);
  6604. }
  6605. void XMLOutput::addControlColumn(const QString&series,int column)
  6606. {
  6607. controlColumns.insert(column,series);
  6608. }
  6609. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  6610. {
  6611. annotationColumns.insert(column,series);
  6612. }
  6613. /*:546*/
  6614. #line 561 "./typica.w"
  6615. /*548:*/
  6616. #line 12485 "./typica.w"
  6617. bool XMLInput::input()
  6618. {
  6619. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  6620. {
  6621. return false;
  6622. }
  6623. QXmlStreamReader xmlin(in);
  6624. QMap<QString,int> temperatureColumns;
  6625. QMap<QString,int> annotationColumns;
  6626. int nextColumn= firstc;
  6627. /*549:*/
  6628. #line 12516 "./typica.w"
  6629. while(!xmlin.isDTD())
  6630. {
  6631. xmlin.readNext();
  6632. }
  6633. if(xmlin.isDTD())
  6634. {
  6635. if(xmlin.text()=="<!DOCTYPE roastlog>")
  6636. {
  6637. /*550:*/
  6638. #line 12538 "./typica.w"
  6639. emit newTemperatureColumn(firstc,"Bean");
  6640. emit newAnnotationColumn(firstc+1,"Note");
  6641. emit lastColumn(firstc+1);
  6642. /*:550*/
  6643. #line 12525 "./typica.w"
  6644. }
  6645. else
  6646. {
  6647. xmlin.readNext();
  6648. /*551:*/
  6649. #line 12547 "./typica.w"
  6650. while(xmlin.name()!="roast")
  6651. {
  6652. if(xmlin.isStartElement())
  6653. {
  6654. if((xmlin.name()=="tempseries")||(xmlin.name()=="controlseries"))
  6655. {
  6656. temperatureColumns.insert(xmlin.attributes().value("name").
  6657. toString(),
  6658. nextColumn);
  6659. emit newTemperatureColumn(nextColumn,
  6660. xmlin.attributes().value("name").
  6661. toString());
  6662. nextColumn++;
  6663. }
  6664. else if(xmlin.name()=="noteseries")
  6665. {
  6666. annotationColumns.insert(xmlin.attributes().value("name").
  6667. toString(),nextColumn);
  6668. emit newAnnotationColumn(nextColumn,
  6669. xmlin.attributes().value("name").
  6670. toString());
  6671. nextColumn++;
  6672. }
  6673. }
  6674. xmlin.readNext();
  6675. }
  6676. emit lastColumn(nextColumn-1);
  6677. /*:551*/
  6678. #line 12530 "./typica.w"
  6679. }
  6680. }
  6681. /*:549*/
  6682. #line 12496 "./typica.w"
  6683. QTime timeval= QTime();
  6684. double tempval= 0;
  6685. QString noteval= QString();
  6686. int column;
  6687. int counter= 0;
  6688. while(!xmlin.atEnd())
  6689. {
  6690. /*552:*/
  6691. #line 12588 "./typica.w"
  6692. xmlin.readNext();
  6693. if(xmlin.isStartElement())
  6694. {
  6695. /*553:*/
  6696. #line 12614 "./typica.w"
  6697. if(xmlin.name()=="time")
  6698. {
  6699. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  6700. }
  6701. else if(xmlin.name()=="temperature")
  6702. {
  6703. column= xmlin.attributes().hasAttribute("series")?
  6704. temperatureColumns.value(xmlin.attributes().value("series").toString()):firstc;
  6705. bool relative= (xmlin.attributes().value("relative")=="true");
  6706. tempval= xmlin.readElementText().toDouble();
  6707. Measurement measurement(tempval,timeval);
  6708. if(relative)
  6709. {
  6710. measurement.insert("relative",true);
  6711. }
  6712. emit measure(measurement,column);
  6713. }
  6714. else if(xmlin.name()=="control")
  6715. {
  6716. column= xmlin.attributes().value("series").toString().isEmpty()?
  6717. firstc:temperatureColumns.value(xmlin.attributes().
  6718. value("series").toString());
  6719. tempval= xmlin.readElementText().toDouble();
  6720. Measurement measurement(tempval,timeval,Units::Unitless);
  6721. emit measure(measurement,column);
  6722. }
  6723. else if(xmlin.name()=="annotation")
  6724. {
  6725. column= xmlin.attributes().value("series").toString().isEmpty()?
  6726. firstc+1:annotationColumns.value(xmlin.attributes().
  6727. value("series").toString());
  6728. noteval= xmlin.readElementText();
  6729. if(!noteval.isEmpty())
  6730. {
  6731. emit annotation(noteval,firstc,column);
  6732. }
  6733. }
  6734. /*:553*/
  6735. #line 12592 "./typica.w"
  6736. }
  6737. counter++;
  6738. if(counter%100==0)
  6739. {
  6740. QCoreApplication::processEvents();
  6741. }
  6742. /*:552*/
  6743. #line 12504 "./typica.w"
  6744. }
  6745. return true;
  6746. }
  6747. /*:548*//*554:*/
  6748. #line 12655 "./typica.w"
  6749. XMLInput::XMLInput(QIODevice*input,int c):
  6750. firstc(c),in(input)
  6751. {
  6752. }
  6753. void XMLInput::setFirstColumn(int column)
  6754. {
  6755. firstc= column;
  6756. }
  6757. void XMLInput::setDevice(QIODevice*device)
  6758. {
  6759. in= device;
  6760. }
  6761. /*:554*/
  6762. #line 562 "./typica.w"
  6763. /*559:*/
  6764. #line 12746 "./typica.w"
  6765. bool CSVOutput::output()
  6766. {
  6767. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  6768. {
  6769. return false;
  6770. }
  6771. QTextStream output(out);
  6772. /*560:*/
  6773. #line 12770 "./typica.w"
  6774. output<<"Time";
  6775. foreach(int c,temperatureColumns.keys())
  6776. {
  6777. output<<','<<temperatureColumns.value(c);
  6778. }
  6779. foreach(int c,controlColumns.keys())
  6780. {
  6781. output<<','<<controlColumns.value(c);
  6782. }
  6783. foreach(int c,annotationColumns.keys())
  6784. {
  6785. output<<','<<annotationColumns.value(c);
  6786. }
  6787. output<<'\n';
  6788. /*:560*/
  6789. #line 12754 "./typica.w"
  6790. bool oresult;
  6791. for(int i= 0;i<data->rowCount();i++)
  6792. {
  6793. /*543:*/
  6794. #line 12310 "./typica.w"
  6795. oresult= false;
  6796. foreach(int c,temperatureColumns.keys())
  6797. {
  6798. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6799. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6800. {
  6801. oresult= true;
  6802. break;
  6803. }
  6804. }
  6805. foreach(int c,controlColumns.keys())
  6806. {
  6807. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6808. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  6809. {
  6810. oresult= true;
  6811. break;
  6812. }
  6813. }
  6814. if(oresult==false)
  6815. {
  6816. foreach(int c,annotationColumns.keys())
  6817. {
  6818. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  6819. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  6820. isEmpty()))
  6821. {
  6822. oresult= true;
  6823. break;
  6824. }
  6825. }
  6826. }
  6827. /*:543*/
  6828. #line 12758 "./typica.w"
  6829. if(oresult)
  6830. {
  6831. /*561:*/
  6832. #line 12795 "./typica.w"
  6833. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  6834. foreach(int c,temperatureColumns.keys())
  6835. {
  6836. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6837. }
  6838. foreach(int c,controlColumns.keys())
  6839. {
  6840. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6841. }
  6842. foreach(int c,annotationColumns.keys())
  6843. {
  6844. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  6845. }
  6846. output<<'\n';
  6847. /*:561*/
  6848. #line 12761 "./typica.w"
  6849. }
  6850. }
  6851. out->close();
  6852. return true;
  6853. }
  6854. /*:559*//*562:*/
  6855. #line 12814 "./typica.w"
  6856. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  6857. data(model),out(device),time(timec)
  6858. {
  6859. }
  6860. void CSVOutput::setModel(MeasurementModel*model)
  6861. {
  6862. data= model;
  6863. }
  6864. void CSVOutput::setTimeColumn(int column)
  6865. {
  6866. time= column;
  6867. }
  6868. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  6869. {
  6870. temperatureColumns.insert(column,series);
  6871. }
  6872. void CSVOutput::addControlColumn(const QString&series,int column)
  6873. {
  6874. controlColumns.insert(column,series);
  6875. }
  6876. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  6877. {
  6878. annotationColumns.insert(column,series);
  6879. }
  6880. void CSVOutput::setDevice(QIODevice*device)
  6881. {
  6882. out= device;
  6883. }
  6884. #line 1 "./webview.w"
  6885. /*:562*/
  6886. #line 563 "./typica.w"
  6887. /*608:*/
  6888. #line 13102 "./typica.w"
  6889. QString SaltModel::arrayLiteral(int column,int role)const
  6890. {
  6891. QString literal= "'{";
  6892. for(int i= 0;i<rowCount();i++)
  6893. {
  6894. QString datum= data(index(i,column),role).toString();
  6895. if(!datum.isEmpty())
  6896. {
  6897. literal.append(datum);
  6898. literal.append(", ");
  6899. }
  6900. }
  6901. if(literal.size()> 2)
  6902. {
  6903. literal.chop(2);
  6904. }
  6905. literal.append("}'");
  6906. return literal;
  6907. }
  6908. QString SaltModel::quotedArrayLiteral(int column,int role)const
  6909. {
  6910. QString literal= "'{";
  6911. for(int i= 0;i<rowCount();i++)
  6912. {
  6913. QString datum= data(index(i,column),role).toString();
  6914. if(!datum.isEmpty())
  6915. {
  6916. literal.append("\"");
  6917. literal.append(datum);
  6918. literal.append("\", ");
  6919. }
  6920. }
  6921. if(literal.size()> 2)
  6922. {
  6923. literal.chop(2);
  6924. }
  6925. literal.append("}'");
  6926. return literal;
  6927. }
  6928. /*:608*//*609:*/
  6929. #line 13146 "./typica.w"
  6930. QModelIndex SaltModel::parent(const QModelIndex&)const
  6931. {
  6932. return QModelIndex();
  6933. }
  6934. /*:609*//*610:*/
  6935. #line 13165 "./typica.w"
  6936. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  6937. int role)
  6938. {
  6939. /*611:*/
  6940. #line 13196 "./typica.w"
  6941. bool valid= false;
  6942. if(index.isValid())
  6943. {
  6944. if(index.row()<modelData.size())
  6945. {
  6946. if(index.column()<colcount)
  6947. {
  6948. valid= true;
  6949. }
  6950. }
  6951. }
  6952. /*:611*/
  6953. #line 13169 "./typica.w"
  6954. if(!valid)
  6955. {
  6956. return false;
  6957. }
  6958. if(index.row()==modelData.size()-1)
  6959. {
  6960. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  6961. /*612:*/
  6962. #line 13212 "./typica.w"
  6963. QList<QMap<int,QVariant> > newRow;
  6964. QMap<int,QVariant> defaults;
  6965. for(int i= 0;i<colcount;i++)
  6966. {
  6967. newRow.append(defaults);
  6968. }
  6969. modelData.append(newRow);
  6970. /*:612*/
  6971. #line 13177 "./typica.w"
  6972. endInsertRows();
  6973. }
  6974. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  6975. QMap<int,QVariant> cell= row.at(index.column());
  6976. cell.insert(role,value);
  6977. if(role==Qt::EditRole)
  6978. {
  6979. cell.insert(Qt::DisplayRole,value);
  6980. }
  6981. row.replace(index.column(),cell);
  6982. modelData.replace(index.row(),row);
  6983. emit dataChanged(index,index);
  6984. return true;
  6985. }
  6986. /*:610*//*613:*/
  6987. #line 13223 "./typica.w"
  6988. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  6989. {
  6990. for(int i= 0;i<columns;i++)
  6991. {
  6992. hData<<"";
  6993. }
  6994. /*612:*/
  6995. #line 13212 "./typica.w"
  6996. QList<QMap<int,QVariant> > newRow;
  6997. QMap<int,QVariant> defaults;
  6998. for(int i= 0;i<colcount;i++)
  6999. {
  7000. newRow.append(defaults);
  7001. }
  7002. modelData.append(newRow);
  7003. /*:612*/
  7004. #line 13230 "./typica.w"
  7005. }
  7006. /*:613*//*614:*/
  7007. #line 13235 "./typica.w"
  7008. SaltModel::~SaltModel()
  7009. {
  7010. }
  7011. /*:614*//*615:*/
  7012. #line 13245 "./typica.w"
  7013. int SaltModel::rowCount(const QModelIndex&parent)const
  7014. {
  7015. return(parent==QModelIndex()?modelData.size():0);
  7016. }
  7017. int SaltModel::columnCount(const QModelIndex&parent)const
  7018. {
  7019. return(parent==QModelIndex()?colcount:0);
  7020. }
  7021. /*:615*//*616:*/
  7022. #line 13258 "./typica.w"
  7023. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  7024. const QVariant&value,int)
  7025. {
  7026. if(orientation==Qt::Horizontal&&section<colcount)
  7027. {
  7028. hData.replace(section,value.toString());
  7029. emit headerDataChanged(orientation,section,section);
  7030. return true;
  7031. }
  7032. return false;
  7033. }
  7034. /*:616*//*617:*/
  7035. #line 13273 "./typica.w"
  7036. QVariant SaltModel::data(const QModelIndex&index,int role)const
  7037. {
  7038. /*611:*/
  7039. #line 13196 "./typica.w"
  7040. bool valid= false;
  7041. if(index.isValid())
  7042. {
  7043. if(index.row()<modelData.size())
  7044. {
  7045. if(index.column()<colcount)
  7046. {
  7047. valid= true;
  7048. }
  7049. }
  7050. }
  7051. /*:611*/
  7052. #line 13276 "./typica.w"
  7053. if(!valid)
  7054. {
  7055. return QVariant();
  7056. }
  7057. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  7058. QMap<int,QVariant> cell= row.at(index.column());
  7059. return cell.value(role,QVariant());
  7060. }
  7061. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  7062. int role)const
  7063. {
  7064. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  7065. section<colcount)
  7066. {
  7067. return QVariant(hData.at(section));
  7068. }
  7069. return QVariant();
  7070. }
  7071. /*:617*//*618:*/
  7072. #line 13300 "./typica.w"
  7073. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  7074. {
  7075. /*611:*/
  7076. #line 13196 "./typica.w"
  7077. bool valid= false;
  7078. if(index.isValid())
  7079. {
  7080. if(index.row()<modelData.size())
  7081. {
  7082. if(index.column()<colcount)
  7083. {
  7084. valid= true;
  7085. }
  7086. }
  7087. }
  7088. /*:611*/
  7089. #line 13303 "./typica.w"
  7090. if(valid)
  7091. {
  7092. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDropEnabled;
  7093. }
  7094. return 0;
  7095. }
  7096. /*:618*//*619:*/
  7097. #line 13314 "./typica.w"
  7098. QModelIndex SaltModel::index(int row,int column,
  7099. const QModelIndex&parent)const
  7100. {
  7101. if(parent==QModelIndex())
  7102. {
  7103. if(row<modelData.size()&&column<colcount)
  7104. {
  7105. return createIndex(row,column);
  7106. }
  7107. }
  7108. return QModelIndex();
  7109. }
  7110. /*:619*//*620:*/
  7111. #line 13332 "./typica.w"
  7112. void SaltModel::clear()
  7113. {
  7114. beginResetModel();
  7115. modelData.clear();
  7116. /*612:*/
  7117. #line 13212 "./typica.w"
  7118. QList<QMap<int,QVariant> > newRow;
  7119. QMap<int,QVariant> defaults;
  7120. for(int i= 0;i<colcount;i++)
  7121. {
  7122. newRow.append(defaults);
  7123. }
  7124. modelData.append(newRow);
  7125. /*:612*/
  7126. #line 13337 "./typica.w"
  7127. endResetModel();
  7128. }
  7129. /*:620*//*621:*/
  7130. #line 13346 "./typica.w"
  7131. bool SaltModel::removeRows(int row,int count,
  7132. const QModelIndex&parent)
  7133. {
  7134. if(parent==QModelIndex())
  7135. {
  7136. if(row>=0&&count> 0&&(row+count-1)<modelData.size())
  7137. {
  7138. beginRemoveRows(parent,row,row+count-1);
  7139. for(int i= 0;i<count;i++)
  7140. {
  7141. modelData.removeAt(row);
  7142. }
  7143. endRemoveRows();
  7144. if(modelData.size()==0)
  7145. {
  7146. beginInsertRows(parent,0,0);
  7147. /*612:*/
  7148. #line 13212 "./typica.w"
  7149. QList<QMap<int,QVariant> > newRow;
  7150. QMap<int,QVariant> defaults;
  7151. for(int i= 0;i<colcount;i++)
  7152. {
  7153. newRow.append(defaults);
  7154. }
  7155. modelData.append(newRow);
  7156. /*:612*/
  7157. #line 13363 "./typica.w"
  7158. endInsertRows();
  7159. }
  7160. return true;
  7161. }
  7162. }
  7163. return false;
  7164. }
  7165. /*:621*//*622:*/
  7166. #line 13377 "./typica.w"
  7167. int SaltModel::findData(const QVariant&value,int column,int role)
  7168. {
  7169. for(int i= 0;i<modelData.size();i++)
  7170. {
  7171. if(modelData.at(i).size()> column)
  7172. {
  7173. if(modelData.at(i).at(column).contains(role))
  7174. {
  7175. if(modelData.at(i).at(column).value(role)==value)
  7176. {
  7177. return i;
  7178. }
  7179. }
  7180. }
  7181. }
  7182. return-1;
  7183. }
  7184. /*:622*/
  7185. #line 564 "./typica.w"
  7186. /*624:*/
  7187. #line 13441 "./typica.w"
  7188. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  7189. {
  7190. SqlComboBox*widget= new SqlComboBox();
  7191. widget->setParent(parent);
  7192. for(int i= 0;i<count();i++)
  7193. {
  7194. widget->addItem(itemText(i),itemData(i));
  7195. }
  7196. return widget;
  7197. }
  7198. /*:624*//*625:*/
  7199. #line 13458 "./typica.w"
  7200. void SqlComboBox::showData(bool show)
  7201. {
  7202. dataColumnShown= show;
  7203. }
  7204. /*:625*//*626:*/
  7205. #line 13472 "./typica.w"
  7206. void SqlComboBox::addNullOption()
  7207. {
  7208. addItem(specialNullText,specialNullData);
  7209. }
  7210. void SqlComboBox::setNullText(QString nullText)
  7211. {
  7212. specialNullText= nullText;
  7213. }
  7214. void SqlComboBox::setNullData(QVariant nullData)
  7215. {
  7216. specialNullData= nullData;
  7217. }
  7218. /*:626*//*627:*/
  7219. #line 13495 "./typica.w"
  7220. void SqlComboBox::setDataColumn(int column)
  7221. {
  7222. dataColumn= column;
  7223. }
  7224. void SqlComboBox::setDisplayColumn(int column)
  7225. {
  7226. displayColumn= column;
  7227. }
  7228. /*:627*//*628:*/
  7229. #line 13509 "./typica.w"
  7230. void SqlComboBox::addSqlOptions(QString query)
  7231. {
  7232. SqlQueryConnection h;
  7233. QSqlQuery*dbquery= h.operator->();
  7234. if(!dbquery->exec(query))
  7235. {
  7236. QSqlError error= dbquery->lastError();
  7237. qDebug()<<error.databaseText();
  7238. qDebug()<<error.driverText();
  7239. qDebug()<<error.text();
  7240. qDebug()<<dbquery->lastQuery();
  7241. }
  7242. while(dbquery->next())
  7243. {
  7244. QString displayValue(dbquery->value(displayColumn).toString());
  7245. QString dataValue(dbquery->value(dataColumn).toString());
  7246. if(dataColumnShown)
  7247. {
  7248. displayValue.append(QString(" (%1)").arg(dataValue));
  7249. }
  7250. addItem(displayValue,dataValue);
  7251. }
  7252. }
  7253. /*:628*//*629:*/
  7254. #line 13545 "./typica.w"
  7255. SqlComboBox::SqlComboBox():
  7256. dataColumn(0),displayColumn(0),dataColumnShown(false),
  7257. specialNullText(tr("Unknown")),specialNullData(QVariant::String)
  7258. {
  7259. view()->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  7260. }
  7261. SqlComboBox::~SqlComboBox()
  7262. {
  7263. }
  7264. /*:629*/
  7265. #line 565 "./typica.w"
  7266. /*631:*/
  7267. #line 13584 "./typica.w"
  7268. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  7269. {
  7270. delegate= widget;
  7271. }
  7272. /*:631*//*632:*/
  7273. #line 13593 "./typica.w"
  7274. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  7275. const QStyleOptionViewItem&,
  7276. const QModelIndex&)const
  7277. {
  7278. return delegate->clone(parent);
  7279. }
  7280. /*:632*//*633:*/
  7281. #line 13604 "./typica.w"
  7282. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  7283. const QModelIndex&index)const
  7284. {
  7285. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7286. self->setCurrentIndex(self->findData(
  7287. index.model()->data(index,
  7288. Qt::UserRole).toString()));
  7289. }
  7290. /*:633*//*634:*/
  7291. #line 13617 "./typica.w"
  7292. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  7293. QAbstractItemModel*model,
  7294. const QModelIndex&index)const
  7295. {
  7296. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  7297. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  7298. Qt::UserRole);
  7299. model->setData(index,self->currentText(),Qt::DisplayRole);
  7300. }
  7301. /*:634*//*635:*/
  7302. #line 13630 "./typica.w"
  7303. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  7304. const QStyleOptionViewItem&option,
  7305. const QModelIndex&)const
  7306. {
  7307. editor->setGeometry(option.rect);
  7308. }
  7309. /*:635*//*636:*/
  7310. #line 13641 "./typica.w"
  7311. QSize SqlComboBoxDelegate::sizeHint()const
  7312. {
  7313. return delegate->sizeHint();
  7314. }
  7315. /*:636*//*637:*/
  7316. #line 13649 "./typica.w"
  7317. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  7318. :QItemDelegate(parent)
  7319. {
  7320. }
  7321. /*:637*/
  7322. #line 566 "./typica.w"
  7323. /*599:*/
  7324. #line 12896 "./typica.w"
  7325. Application::Application(int&argc,char**argv):QApplication(argc,argv),
  7326. connectionStatus(false),currentUser(QString())
  7327. {
  7328. /*600:*/
  7329. #line 12912 "./typica.w"
  7330. setOrganizationName("Wilson's Coffee & Tea");
  7331. setOrganizationDomain("wilsonscoffee.com");
  7332. setApplicationName(PROGRAM_NAME);
  7333. /*:600*/
  7334. #line 12900 "./typica.w"
  7335. /*601:*/
  7336. #line 12921 "./typica.w"
  7337. QTranslator*base= new QTranslator;
  7338. if(base->load(QString("qt_%1").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7339. {
  7340. installTranslator(base);
  7341. }
  7342. QTranslator*app= new QTranslator;
  7343. if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name()),QString("%1/Translations").arg(QCoreApplication::applicationDirPath())))
  7344. {
  7345. installTranslator(app);
  7346. }
  7347. /*:601*/
  7348. #line 12901 "./typica.w"
  7349. /*308:*/
  7350. #line 123 "./measurement.w"
  7351. qRegisterMetaType<Measurement> ("Measurement");
  7352. /*:308*/
  7353. #line 12902 "./typica.w"
  7354. /*814:*/
  7355. #line 16939 "./typica.w"
  7356. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  7357. tr("NI DAQmx Base"),
  7358. "nidaqmxbase",NULL);
  7359. topLevelNodeInserters.append(inserter);
  7360. /*:814*//*822:*/
  7361. #line 17170 "./typica.w"
  7362. #ifdef Q_OS_WIN32
  7363. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  7364. topLevelNodeInserters.append(inserter);
  7365. #endif
  7366. /*:822*//*846:*/
  7367. #line 18137 "./typica.w"
  7368. #if 0
  7369. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  7370. topLevelNodeInserters.append(inserter);
  7371. #endif
  7372. /*:846*//*895:*/
  7373. #line 19650 "./typica.w"
  7374. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  7375. topLevelNodeInserters.append(inserter);
  7376. #line 1 "./modbus.w"
  7377. /*:895*//*901:*/
  7378. #line 328 "./modbus.w"
  7379. inserter= new NodeInserter(tr("ModbusNG Port"),tr("Modbus RTU Port"),"modbusngport",NULL);
  7380. topLevelNodeInserters.append(inserter);
  7381. /*:901*//*917:*/
  7382. #line 272 "./unsupportedserial.w"
  7383. inserter= new NodeInserter(tr("Other Device"),tr("Other Device"),
  7384. "unsupporteddevice",NULL);
  7385. topLevelNodeInserters.append(inserter);
  7386. /*:917*//*948:*/
  7387. #line 190 "./phidgets.w"
  7388. QLibrary phidgetsCheck("phidget21");
  7389. if(phidgetsCheck.load())
  7390. {
  7391. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7392. "phidgets1048",NULL);
  7393. topLevelNodeInserters.append(inserter);
  7394. phidgetsCheck.unload();
  7395. }
  7396. else
  7397. {
  7398. phidgetsCheck.setFileName("Phidget21.framework/Phidget21");
  7399. if(phidgetsCheck.load())
  7400. {
  7401. inserter= new NodeInserter(tr("Phidgets 1048"),tr("Phidgets 1048"),
  7402. "phidgets1048",NULL);
  7403. topLevelNodeInserters.append(inserter);
  7404. phidgetsCheck.unload();
  7405. }
  7406. }
  7407. /*:948*//*962:*/
  7408. #line 17 "./phidget22.w"
  7409. #if __APPLE__
  7410. QLibrary phidget22check("Phidget22.framework/Phidget22");
  7411. #else
  7412. QLibrary phidget22check("phidget22");
  7413. #endif
  7414. if(phidget22check.load())
  7415. {
  7416. inserter= new NodeInserter(tr("Phidget22"),tr("Phidget22"),"phidget22",
  7417. NULL);
  7418. topLevelNodeInserters.append(inserter);
  7419. phidget22check.unload();
  7420. }
  7421. /*:962*//*1085:*/
  7422. #line 1241 "./dataqsdk.w"
  7423. #ifdef Q_OS_WIN32
  7424. inserter= new NodeInserter(tr("DATAQ SDK Device"),tr("DATAQ Device"),
  7425. "dataqsdk",NULL);
  7426. topLevelNodeInserters.append(inserter);
  7427. #endif
  7428. #line 20321 "./typica.w"
  7429. #line 1 "./scales.w"
  7430. /*:1085*//*1110:*/
  7431. #line 557 "./scales.w"
  7432. inserter= new NodeInserter(tr("Serial Scale"),tr("Scale"),"scale",NULL);
  7433. topLevelNodeInserters.append(inserter);
  7434. #line 20323 "./typica.w"
  7435. #line 1 "./valueannotation.w"
  7436. /*:1110*/
  7437. #line 12903 "./typica.w"
  7438. }
  7439. /*:599*//*603:*/
  7440. #line 12944 "./typica.w"
  7441. QDomDocument*Application::configuration()
  7442. {
  7443. return&conf;
  7444. }
  7445. /*:603*//*604:*/
  7446. #line 12953 "./typica.w"
  7447. QSqlDatabase Application::database()
  7448. {
  7449. QString connectionName;
  7450. QSqlDatabase connection=
  7451. QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection),false);
  7452. do
  7453. {
  7454. connectionName= QUuid::createUuid().toString();
  7455. }while(QSqlDatabase::connectionNames().contains(connectionName));
  7456. return QSqlDatabase::cloneDatabase(connection,QString(connectionName));
  7457. }
  7458. /*:604*//*605:*/
  7459. #line 12969 "./typica.w"
  7460. void Application::setDatabaseConnected(bool status)
  7461. {
  7462. connectionStatus= status;
  7463. }
  7464. bool Application::databaseConnected()
  7465. {
  7466. return connectionStatus;
  7467. }
  7468. /*:605*//*749:*/
  7469. #line 15472 "./typica.w"
  7470. void Application::saveDeviceConfiguration()
  7471. {
  7472. QSettings settings;
  7473. settings.setValue("DeviceConfiguration",
  7474. QVariant(deviceConfigurationDocument.toByteArray()));
  7475. }
  7476. /*:749*//*750:*/
  7477. #line 15484 "./typica.w"
  7478. QDomDocument Application::deviceConfiguration()
  7479. {
  7480. if(deviceConfigurationDocument.isNull())
  7481. {
  7482. /*751:*/
  7483. #line 15498 "./typica.w"
  7484. QSettings settings;
  7485. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  7486. QString etext;
  7487. int eline;
  7488. int ecol;
  7489. if(document.length()==0)
  7490. {
  7491. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  7492. /*752:*/
  7493. #line 15522 "./typica.w"
  7494. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7495. emptyDocument.open(QIODevice::ReadOnly);
  7496. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7497. &etext,&eline,&ecol))
  7498. {
  7499. /*753:*/
  7500. #line 15539 "./typica.w"
  7501. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7502. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7503. qDebug()<<etext;
  7504. /*:753*/
  7505. #line 15528 "./typica.w"
  7506. }
  7507. else
  7508. {
  7509. saveDeviceConfiguration();
  7510. }
  7511. /*:752*/
  7512. #line 15507 "./typica.w"
  7513. }
  7514. else
  7515. {
  7516. if(!deviceConfigurationDocument.setContent(document,false,
  7517. &etext,&eline,&ecol))
  7518. {
  7519. /*753:*/
  7520. #line 15539 "./typica.w"
  7521. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7522. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7523. qDebug()<<etext;
  7524. /*:753*/
  7525. #line 15514 "./typica.w"
  7526. /*752:*/
  7527. #line 15522 "./typica.w"
  7528. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  7529. emptyDocument.open(QIODevice::ReadOnly);
  7530. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  7531. &etext,&eline,&ecol))
  7532. {
  7533. /*753:*/
  7534. #line 15539 "./typica.w"
  7535. qDebug()<<QString(tr("An error occurred loading device configuration."));
  7536. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  7537. qDebug()<<etext;
  7538. /*:753*/
  7539. #line 15528 "./typica.w"
  7540. }
  7541. else
  7542. {
  7543. saveDeviceConfiguration();
  7544. }
  7545. /*:752*/
  7546. #line 15515 "./typica.w"
  7547. }
  7548. }
  7549. /*:751*/
  7550. #line 15489 "./typica.w"
  7551. }
  7552. return deviceConfigurationDocument;
  7553. }
  7554. /*:750*//*781:*/
  7555. #line 16140 "./typica.w"
  7556. void Application::registerDeviceConfigurationWidget(QString driver,
  7557. QMetaObject widget)
  7558. {
  7559. deviceConfigurationWidgets.insert(driver,widget);
  7560. }
  7561. /*:781*//*782:*/
  7562. #line 16156 "./typica.w"
  7563. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  7564. const QModelIndex&index)
  7565. {
  7566. QVariant nodeReference= index.data(Qt::UserRole);
  7567. QDomElement referenceElement= model->referenceElement(
  7568. model->data(index,Qt::UserRole).toString());
  7569. QMetaObject metaObject=
  7570. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  7571. QWidget::staticMetaObject);
  7572. QWidget*editor;
  7573. if(metaObject.className()==QWidget::staticMetaObject.className())
  7574. {
  7575. editor= NULL;
  7576. }
  7577. else
  7578. {
  7579. editor= qobject_cast<QWidget*> (
  7580. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  7581. Q_ARG(QModelIndex,index)));
  7582. }
  7583. return editor;
  7584. }
  7585. /*:782*//*1140:*/
  7586. #line 16 "./user.w"
  7587. QString Application::currentTypicaUser()
  7588. {
  7589. return currentUser;
  7590. }
  7591. /*:1140*//*1141:*/
  7592. #line 26 "./user.w"
  7593. void Application::setCurrentTypicaUser(const QString&user)
  7594. {
  7595. currentUser= user;
  7596. emit userChanged(currentUser);
  7597. }
  7598. /*:1141*//*1142:*/
  7599. #line 37 "./user.w"
  7600. bool Application::login(const QString&user,const QString&password)
  7601. {
  7602. SqlQueryConnection h;
  7603. QSqlQuery*dbquery= h.operator->();
  7604. dbquery->prepare("SELECT 1 FROM typica_users WHERE name = :name AND password = :password AND active = TRUE");
  7605. dbquery->bindValue(":name",user);
  7606. dbquery->bindValue(":password",password);
  7607. dbquery->exec();
  7608. if(dbquery->next())
  7609. {
  7610. currentUser= user;
  7611. emit userChanged(currentUser);
  7612. return true;
  7613. }
  7614. return false;
  7615. }
  7616. /*:1142*//*1143:*/
  7617. #line 58 "./user.w"
  7618. bool Application::autoLogin()
  7619. {
  7620. SqlQueryConnection h;
  7621. QSqlQuery*dbquery= h.operator->();
  7622. dbquery->exec("SELECT name FROM typica_users WHERE auto_login = TRUE");
  7623. if(dbquery->next())
  7624. {
  7625. currentUser= dbquery->value(0).toString();
  7626. emit userChanged(currentUser);
  7627. return true;
  7628. }
  7629. return false;
  7630. }
  7631. /*:1143*/
  7632. #line 567 "./typica.w"
  7633. /*646:*/
  7634. #line 13797 "./typica.w"
  7635. SqlConnectionSetup::SqlConnectionSetup():
  7636. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  7637. portnumber(new QLineEdit),
  7638. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  7639. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  7640. cancelButton(new QPushButton(tr("Cancel"))),
  7641. connectButton(new QPushButton(tr("Connect")))
  7642. {
  7643. QSettings settings;
  7644. driver->addItem("PostgreSQL","QPSQL");
  7645. formLayout->addRow(tr("Database driver:"),driver);
  7646. formLayout->addRow(tr("Host name:"),hostname);
  7647. hostname->setText(settings.value("database/hostname").toString());
  7648. formLayout->addRow(tr("Port number:"),portnumber);
  7649. portnumber->setText(settings.value("database/portnumber","5432").toString());
  7650. formLayout->addRow(tr("Database name:"),dbname);
  7651. dbname->setText(settings.value("database/dbname").toString());
  7652. formLayout->addRow(tr("User name:"),user);
  7653. user->setText(settings.value("database/user").toString());
  7654. password->setEchoMode(QLineEdit::Password);
  7655. formLayout->addRow(tr("Password:"),password);
  7656. password->setText(settings.value("database/password").toString());
  7657. layout->addLayout(formLayout);
  7658. buttons->addStretch(1);
  7659. buttons->addWidget(cancelButton);
  7660. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  7661. buttons->addWidget(connectButton);
  7662. layout->addLayout(buttons);
  7663. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  7664. connectButton->setDefault(true);
  7665. setLayout(layout);
  7666. setModal(true);
  7667. }
  7668. SqlConnectionSetup::~SqlConnectionSetup()
  7669. {
  7670. }
  7671. /*:646*//*647:*/
  7672. #line 13840 "./typica.w"
  7673. void SqlConnectionSetup::testConnection()
  7674. {
  7675. QSqlDatabase database=
  7676. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  7677. toString());
  7678. database.setConnectOptions("application_name=Typica");
  7679. database.setHostName(hostname->text());
  7680. database.setPort(portnumber->text().toInt());
  7681. database.setDatabaseName(dbname->text());
  7682. database.setUserName(user->text());
  7683. database.setPassword(password->text());
  7684. if(database.open())
  7685. {
  7686. QSettings settings;
  7687. settings.setValue("database/exists","true");
  7688. settings.setValue("database/driver",
  7689. driver->itemData(driver->currentIndex()).toString());
  7690. settings.setValue("database/hostname",hostname->text());
  7691. settings.setValue("database/portnumber",portnumber->text());
  7692. settings.setValue("database/dbname",dbname->text());
  7693. settings.setValue("database/user",user->text());
  7694. settings.setValue("database/password",password->text());
  7695. database.close();
  7696. AppInstance->setDatabaseConnected(true);
  7697. accept();
  7698. }
  7699. else
  7700. {
  7701. QMessageBox::information(this,tr("Database connection failed"),
  7702. tr("Failed to connect to database."));
  7703. }
  7704. }
  7705. /*:647*/
  7706. #line 568 "./typica.w"
  7707. /*651:*/
  7708. #line 13947 "./typica.w"
  7709. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  7710. {
  7711. setModel(new QSqlQueryModel);
  7712. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  7713. this,SLOT(openRow(QModelIndex)));
  7714. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  7715. this,SLOT(persistColumnResize(int,int,int)));
  7716. }
  7717. /*:651*//*652:*/
  7718. #line 13962 "./typica.w"
  7719. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  7720. {
  7721. /*653:*/
  7722. #line 13971 "./typica.w"
  7723. QSettings settings;
  7724. /*654:*/
  7725. #line 13984 "./typica.w"
  7726. QWidget*topLevelWidget= this;
  7727. while(topLevelWidget->parentWidget())
  7728. {
  7729. topLevelWidget= topLevelWidget->parentWidget();
  7730. }
  7731. /*:654*/
  7732. #line 13973 "./typica.w"
  7733. settings.setValue(QString("columnWidths/%1/%2/%3").
  7734. arg(topLevelWidget->objectName()).
  7735. arg(objectName()).arg(column),
  7736. QVariant(newsize));
  7737. /*:653*/
  7738. #line 13965 "./typica.w"
  7739. }
  7740. /*:652*//*655:*/
  7741. #line 13994 "./typica.w"
  7742. void SqlQueryView::showEvent(QShowEvent*event)
  7743. {
  7744. /*656:*/
  7745. #line 14004 "./typica.w"
  7746. QSettings settings;
  7747. /*654:*/
  7748. #line 13984 "./typica.w"
  7749. QWidget*topLevelWidget= this;
  7750. while(topLevelWidget->parentWidget())
  7751. {
  7752. topLevelWidget= topLevelWidget->parentWidget();
  7753. }
  7754. /*:654*/
  7755. #line 14006 "./typica.w"
  7756. QString baseKey=
  7757. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  7758. arg(objectName());
  7759. for(int i= 0;i<model()->columnCount();i++)
  7760. {
  7761. QString key= QString("%1/%2").arg(baseKey).arg(i);
  7762. if(settings.contains(key))
  7763. {
  7764. setColumnWidth(i,settings.value(key).toInt());
  7765. }
  7766. }
  7767. /*:656*/
  7768. #line 13997 "./typica.w"
  7769. event->accept();
  7770. }
  7771. /*:655*//*657:*/
  7772. #line 14021 "./typica.w"
  7773. void SqlQueryView::openRow(const QModelIndex&index)
  7774. {
  7775. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  7776. emit openEntryRow(index.row());
  7777. }
  7778. /*:657*//*658:*/
  7779. #line 14030 "./typica.w"
  7780. void SqlQueryView::setQuery(const QString&query)
  7781. {
  7782. QSqlDatabase database= AppInstance->database();
  7783. database.open();
  7784. QSqlQuery q(query,database);
  7785. ((QSqlQueryModel*)model())->setQuery(q);
  7786. database.close();
  7787. }
  7788. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  7789. const QVariant&value,int role)
  7790. {
  7791. return model()->setHeaderData(section,orientation,value,role);
  7792. }
  7793. /*:658*//*659:*/
  7794. #line 14048 "./typica.w"
  7795. QVariant SqlQueryView::data(int row,int column,int role)
  7796. {
  7797. return model()->data(model()->index(row,column),role);
  7798. }
  7799. /*:659*/
  7800. #line 569 "./typica.w"
  7801. /*174:*/
  7802. #line 4037 "./typica.w"
  7803. SqlQueryConnection::SqlQueryConnection(const QString&query)
  7804. {
  7805. QSqlDatabase database= AppInstance->database();
  7806. database.open();
  7807. q= new QSqlQuery(query,database);
  7808. connection= database.connectionName();
  7809. }
  7810. /*:174*//*175:*/
  7811. #line 4050 "./typica.w"
  7812. SqlQueryConnection::~SqlQueryConnection()
  7813. {
  7814. delete q;
  7815. {
  7816. QSqlDatabase database= QSqlDatabase::database(connection);
  7817. database.close();
  7818. }
  7819. QSqlDatabase::removeDatabase(connection);
  7820. }
  7821. /*:175*//*176:*/
  7822. #line 4064 "./typica.w"
  7823. QSqlQuery*SqlQueryConnection::operator->()const
  7824. {
  7825. return q;
  7826. }
  7827. /*:176*/
  7828. #line 570 "./typica.w"
  7829. /*678:*/
  7830. #line 14407 "./typica.w"
  7831. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  7832. area(frame),configuration(description)
  7833. {
  7834. refresh();
  7835. }
  7836. ReportTable::~ReportTable()
  7837. {
  7838. }
  7839. /*:678*//*679:*/
  7840. #line 14423 "./typica.w"
  7841. void ReportTable::bind(QString placeholder,QVariant value)
  7842. {
  7843. bindings.insert(placeholder,value);
  7844. }
  7845. /*:679*//*680:*/
  7846. #line 14433 "./typica.w"
  7847. void ReportTable::refresh()
  7848. {
  7849. /*681:*/
  7850. #line 14454 "./typica.w"
  7851. QTextCursor cursor= area->firstCursorPosition();
  7852. while(cursor<area->lastCursorPosition())
  7853. {
  7854. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  7855. }
  7856. cursor.removeSelectedText();
  7857. /*:681*/
  7858. #line 14436 "./typica.w"
  7859. int rows= 1;
  7860. int columns= 1;
  7861. int currentRow= 0;
  7862. QTextTable*table= cursor.insertTable(rows,columns);
  7863. /*682:*/
  7864. #line 14467 "./typica.w"
  7865. QTextTableFormat format= table->format();
  7866. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  7867. if(configuration.hasAttribute("align"))
  7868. {
  7869. if(configuration.attribute("align")=="center")
  7870. {
  7871. format.setAlignment(Qt::AlignHCenter);
  7872. }
  7873. }
  7874. table->setFormat(format);
  7875. /*:682*/
  7876. #line 14441 "./typica.w"
  7877. /*683:*/
  7878. #line 14481 "./typica.w"
  7879. QDomNodeList children= configuration.childNodes();
  7880. for(int i= 0;i<children.count();i++)
  7881. {
  7882. QDomNode current;
  7883. QDomElement currentElement;
  7884. current= children.at(i);
  7885. if(current.isElement())
  7886. {
  7887. currentElement= current.toElement();
  7888. if(currentElement.tagName()=="query")
  7889. {
  7890. /*684:*/
  7891. #line 14508 "./typica.w"
  7892. SqlQueryConnection h;
  7893. QSqlQuery*query= h.operator->();
  7894. query->prepare(currentElement.text());
  7895. foreach(QString key,bindings.uniqueKeys())
  7896. {
  7897. if(currentElement.text().contains(key))
  7898. {
  7899. query->bindValue(key,bindings.value(key));
  7900. }
  7901. }
  7902. query->exec();
  7903. if(!query->next())
  7904. {
  7905. continue;
  7906. }
  7907. if(query->record().count()> columns)
  7908. {
  7909. table->appendColumns(query->record().count()-columns);
  7910. }
  7911. do
  7912. {
  7913. table->appendRows(1);
  7914. rows++;
  7915. currentRow++;
  7916. for(int j= 0;j<query->record().count();j++)
  7917. {
  7918. QTextTableCell cell= table->cellAt(currentRow,j);
  7919. cursor= cell.firstCursorPosition();
  7920. cursor.insertText(query->value(j).toString());
  7921. }
  7922. }while(query->next());
  7923. /*:684*/
  7924. #line 14493 "./typica.w"
  7925. }
  7926. else if(currentElement.tagName()=="row")
  7927. {
  7928. /*685:*/
  7929. #line 14548 "./typica.w"
  7930. table->appendRows(1);
  7931. currentRow++;
  7932. rows++;
  7933. QDomNodeList rowChildren= currentElement.childNodes();
  7934. int currentColumn= 0;
  7935. for(int j= 0;j<rowChildren.count();j++)
  7936. {
  7937. QDomNode node;
  7938. QDomElement nodeElement;
  7939. node= rowChildren.at(j);
  7940. if(node.isElement())
  7941. {
  7942. nodeElement= node.toElement();
  7943. if(nodeElement.tagName()=="cell")
  7944. {
  7945. if(currentColumn==columns)
  7946. {
  7947. table->appendColumns(1);
  7948. columns++;
  7949. }
  7950. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  7951. cursor= cell.firstCursorPosition();
  7952. cursor.insertText(nodeElement.text());
  7953. currentColumn++;
  7954. }
  7955. }
  7956. }
  7957. /*:685*/
  7958. #line 14497 "./typica.w"
  7959. }
  7960. }
  7961. }
  7962. /*:683*/
  7963. #line 14442 "./typica.w"
  7964. if(rows> 1)
  7965. {
  7966. table->removeRows(0,1);
  7967. }
  7968. }
  7969. /*:680*/
  7970. #line 571 "./typica.w"
  7971. /*717:*/
  7972. #line 14654 "./typica.w"
  7973. FormArray::FormArray(QDomElement description):configuration(description),
  7974. maxwidth(-1),maxheight(-1)
  7975. {
  7976. setWidget(&itemContainer);
  7977. itemContainer.setLayout(&itemLayout);
  7978. }
  7979. /*:717*//*718:*/
  7980. #line 14671 "./typica.w"
  7981. void FormArray::addElements(int copies)
  7982. {
  7983. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  7984. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  7985. QWidget*widget;
  7986. for(int i= 0;i<copies;i++)
  7987. {
  7988. widget= new QWidget;
  7989. if(maxwidth> -1)
  7990. {
  7991. widget->setMaximumWidth(maxwidth);
  7992. }
  7993. if(maxheight> -1)
  7994. {
  7995. widget->setMaximumHeight(maxheight);
  7996. }
  7997. if(configuration.hasChildNodes())
  7998. {
  7999. widgetStack->push(widget);
  8000. populateWidget(configuration,widgetStack,layoutStack);
  8001. widgetStack->pop();
  8002. widget->setMinimumHeight(widget->sizeHint().height());
  8003. itemLayout.addWidget(widget);
  8004. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  8005. {
  8006. itemContainer.setMinimumHeight(maxheight*elements()+50);
  8007. }
  8008. else
  8009. {
  8010. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  8011. +widget->sizeHint().height());
  8012. }
  8013. if(maxwidth> -1)
  8014. {
  8015. itemContainer.setMinimumWidth(maxwidth+50);
  8016. }
  8017. else
  8018. {
  8019. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  8020. }
  8021. }
  8022. }
  8023. }
  8024. /*:718*//*719:*/
  8025. #line 14721 "./typica.w"
  8026. QWidget*FormArray::elementAt(int index)
  8027. {
  8028. if(index<itemLayout.count())
  8029. {
  8030. QLayoutItem*item= itemLayout.itemAt(index);
  8031. return item->widget();
  8032. }
  8033. else
  8034. {
  8035. return NULL;
  8036. }
  8037. }
  8038. /*:719*//*720:*/
  8039. #line 14738 "./typica.w"
  8040. void FormArray::removeAllElements()
  8041. {
  8042. while(itemLayout.count()> 0)
  8043. {
  8044. QLayoutItem*item;
  8045. item= itemLayout.itemAt(0);
  8046. item->widget()->hide();
  8047. itemLayout.removeWidget(item->widget());
  8048. }
  8049. itemContainer.setMinimumHeight(0);
  8050. }
  8051. /*:720*//*721:*/
  8052. #line 14754 "./typica.w"
  8053. int FormArray::elements()
  8054. {
  8055. return itemLayout.count();
  8056. }
  8057. /*:721*//*722:*/
  8058. #line 14765 "./typica.w"
  8059. void FormArray::setMaximumElementWidth(int width)
  8060. {
  8061. maxwidth= width;
  8062. }
  8063. void FormArray::setMaximumElementHeight(int height)
  8064. {
  8065. maxheight= height;
  8066. }
  8067. /*:722*/
  8068. #line 572 "./typica.w"
  8069. /*728:*/
  8070. #line 14896 "./typica.w"
  8071. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  8072. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  8073. {
  8074. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  8075. QPointF(0,5);
  8076. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  8077. QPointF(10,5);
  8078. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  8079. QPointF(0,0);
  8080. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  8081. initialBrush.setColor(QColor(170,170,255));
  8082. initialBrush.setStyle(Qt::SolidPattern);
  8083. finalBrush.setColor(Qt::blue);
  8084. finalBrush.setStyle(Qt::SolidPattern);
  8085. initialDecrement.setPolygon(left);
  8086. initialDecrement.setBrush(initialBrush);
  8087. initialDecrement.setPos(0,0);
  8088. scene.addItem(&initialDecrement);
  8089. initialIncrement.setPolygon(right);
  8090. initialIncrement.setBrush(initialBrush);
  8091. initialIncrement.setPos(122,0);
  8092. scene.addItem(&initialIncrement);
  8093. finalDecrement.setPolygon(left);
  8094. finalDecrement.setBrush(finalBrush);
  8095. finalDecrement.setPos(0,12);
  8096. scene.addItem(&finalDecrement);
  8097. finalIncrement.setPolygon(right);
  8098. finalIncrement.setBrush(finalBrush);
  8099. finalIncrement.setPos(122,12);
  8100. scene.addItem(&finalIncrement);
  8101. scalePath.moveTo(0,10);
  8102. scalePath.lineTo(100,10);
  8103. scalePath.moveTo(0,0);
  8104. scalePath.lineTo(0,20);
  8105. scalePath.moveTo(10,5);
  8106. scalePath.lineTo(10,15);
  8107. scalePath.moveTo(20,5);
  8108. scalePath.lineTo(20,15);
  8109. scalePath.moveTo(30,5);
  8110. scalePath.lineTo(30,15);
  8111. scalePath.moveTo(40,5);
  8112. scalePath.lineTo(40,15);
  8113. scalePath.moveTo(50,0);
  8114. scalePath.lineTo(50,20);
  8115. scalePath.moveTo(60,5);
  8116. scalePath.lineTo(60,15);
  8117. scalePath.moveTo(70,5);
  8118. scalePath.lineTo(70,15);
  8119. scalePath.moveTo(80,5);
  8120. scalePath.lineTo(80,15);
  8121. scalePath.moveTo(90,5);
  8122. scalePath.lineTo(90,15);
  8123. scalePath.moveTo(100,0);
  8124. scalePath.lineTo(100,20);
  8125. scaleLine.setPath(scalePath);
  8126. scaleLine.setPos(16,1);
  8127. scene.addItem(&scaleLine);
  8128. setScene(&scene);
  8129. initialIndicator.setPolygon(down);
  8130. initialIndicator.setBrush(initialBrush);
  8131. finalIndicator.setPolygon(up);
  8132. finalIndicator.setBrush(finalBrush);
  8133. setMinimumSize(sizeHint());
  8134. setMaximumSize(sizeHint());
  8135. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8136. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8137. setMinimumSize(sizeHint());
  8138. }
  8139. /*:728*//*729:*/
  8140. #line 14969 "./typica.w"
  8141. QSize ScaleControl::sizeHint()const
  8142. {
  8143. return QSize(140,30);
  8144. }
  8145. /*:729*//*730:*/
  8146. #line 14978 "./typica.w"
  8147. void ScaleControl::setInitialValue(double value)
  8148. {
  8149. if(value>=0&&value<=10)
  8150. {
  8151. nonScoredValue= value;
  8152. if(!initialSet)
  8153. {
  8154. scene.addItem(&initialIndicator);
  8155. }
  8156. initialSet= true;
  8157. initialIndicator.setPos(value*10+16,10);
  8158. emit initialChanged(value);
  8159. if(!finalSet)
  8160. {
  8161. setFinalValue(value);
  8162. }
  8163. }
  8164. }
  8165. void ScaleControl::setFinalValue(double value)
  8166. {
  8167. if(value>=0&&value<=10)
  8168. {
  8169. scoredValue= value;
  8170. if(!finalSet)
  8171. {
  8172. scene.addItem(&finalIndicator);
  8173. }
  8174. finalSet= true;
  8175. finalIndicator.setPos(value*10+16,11);
  8176. emit finalChanged(value);
  8177. }
  8178. }
  8179. /*:730*//*731:*/
  8180. #line 15015 "./typica.w"
  8181. double ScaleControl::initialValue(void)
  8182. {
  8183. return nonScoredValue;
  8184. }
  8185. double ScaleControl::finalValue(void)
  8186. {
  8187. return scoredValue;
  8188. }
  8189. /*:731*//*732:*/
  8190. #line 15036 "./typica.w"
  8191. void ScaleControl::mousePressEvent(QMouseEvent*event)
  8192. {
  8193. /*733:*/
  8194. #line 15048 "./typica.w"
  8195. if(event->button()!=Qt::LeftButton)
  8196. {
  8197. event->ignore();
  8198. return;
  8199. }
  8200. /*:733*/
  8201. #line 15039 "./typica.w"
  8202. scaleDown= true;
  8203. event->accept();
  8204. }
  8205. /*:732*//*734:*/
  8206. #line 15059 "./typica.w"
  8207. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  8208. {
  8209. /*733:*/
  8210. #line 15048 "./typica.w"
  8211. if(event->button()!=Qt::LeftButton)
  8212. {
  8213. event->ignore();
  8214. return;
  8215. }
  8216. /*:733*/
  8217. #line 15062 "./typica.w"
  8218. if(!scaleDown)
  8219. {
  8220. event->ignore();
  8221. return;
  8222. }
  8223. scaleDown= false;
  8224. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8225. /*735:*/
  8226. #line 15084 "./typica.w"
  8227. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  8228. {
  8229. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8230. {
  8231. if(initialSet)
  8232. {
  8233. setInitialValue(nonScoredValue-0.05);
  8234. }
  8235. event->accept();
  8236. return;
  8237. }
  8238. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8239. {
  8240. if(finalSet)
  8241. {
  8242. setFinalValue(scoredValue-0.05);
  8243. event->accept();
  8244. return;
  8245. }
  8246. }
  8247. }
  8248. /*:735*/
  8249. #line 15070 "./typica.w"
  8250. /*736:*/
  8251. #line 15110 "./typica.w"
  8252. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  8253. {
  8254. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8255. {
  8256. if(initialSet)
  8257. {
  8258. setInitialValue(nonScoredValue+0.05);
  8259. event->accept();
  8260. return;
  8261. }
  8262. }
  8263. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  8264. {
  8265. if(finalSet)
  8266. {
  8267. setFinalValue(scoredValue+0.05);
  8268. event->accept();
  8269. return;
  8270. }
  8271. }
  8272. }
  8273. /*:736*/
  8274. #line 15071 "./typica.w"
  8275. /*737:*/
  8276. #line 15136 "./typica.w"
  8277. double relativeX= sceneCoordinate.x()-16;
  8278. if(initialSet)
  8279. {
  8280. if(relativeX>=0&&relativeX<=100)
  8281. {
  8282. setFinalValue(relativeX/10.0);
  8283. event->accept();
  8284. return;
  8285. }
  8286. }
  8287. else
  8288. {
  8289. if(relativeX>=0&&relativeX<=100)
  8290. {
  8291. setInitialValue(relativeX/10.0);
  8292. event->accept();
  8293. return;
  8294. }
  8295. }
  8296. /*:737*/
  8297. #line 15072 "./typica.w"
  8298. event->ignore();
  8299. return;
  8300. }
  8301. /*:734*/
  8302. #line 573 "./typica.w"
  8303. /*739:*/
  8304. #line 15202 "./typica.w"
  8305. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  8306. valueSet(false),scaleDown(false)
  8307. {
  8308. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8309. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8310. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  8311. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  8312. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  8313. theBrush.setColor(Qt::blue);
  8314. theBrush.setStyle(Qt::SolidPattern);
  8315. increment.setPolygon(up);
  8316. increment.setBrush(theBrush);
  8317. increment.setPos(0,0);
  8318. scene.addItem(&increment);
  8319. decrement.setPolygon(down);
  8320. decrement.setBrush(theBrush);
  8321. decrement.setPos(0,122);
  8322. scene.addItem(&decrement);
  8323. scalePath.moveTo(5,0);
  8324. scalePath.lineTo(5,100);
  8325. scalePath.moveTo(0,0);
  8326. scalePath.lineTo(10,0);
  8327. scalePath.moveTo(0,10);
  8328. scalePath.lineTo(10,10);
  8329. scalePath.moveTo(0,20);
  8330. scalePath.lineTo(10,20);
  8331. scalePath.moveTo(0,30);
  8332. scalePath.lineTo(10,30);
  8333. scalePath.moveTo(0,40);
  8334. scalePath.lineTo(10,40);
  8335. scalePath.moveTo(0,50);
  8336. scalePath.lineTo(10,50);
  8337. scalePath.moveTo(0,60);
  8338. scalePath.lineTo(10,60);
  8339. scalePath.moveTo(0,70);
  8340. scalePath.lineTo(10,70);
  8341. scalePath.moveTo(0,80);
  8342. scalePath.lineTo(10,80);
  8343. scalePath.moveTo(0,90);
  8344. scalePath.lineTo(10,90);
  8345. scalePath.moveTo(0,100);
  8346. scalePath.lineTo(10,100);
  8347. scaleLine.setPath(scalePath);
  8348. scaleLine.setPos(0,16);
  8349. scene.addItem(&scaleLine);
  8350. setScene(&scene);
  8351. indicator.setPolygon(left);
  8352. indicator.setBrush(theBrush);
  8353. setMinimumSize(sizeHint());
  8354. setMaximumSize(sizeHint());
  8355. }
  8356. /*:739*//*740:*/
  8357. #line 15257 "./typica.w"
  8358. QSize IntensityControl::sizeHint()const
  8359. {
  8360. return QSize(25,160);
  8361. }
  8362. /*:740*//*741:*/
  8363. #line 15272 "./typica.w"
  8364. void IntensityControl::setValue(double val)
  8365. {
  8366. if(val>=0&&val<=10)
  8367. {
  8368. theValue= val;
  8369. if(!valueSet)
  8370. {
  8371. scene.addItem(&indicator);
  8372. }
  8373. valueSet= true;
  8374. indicator.setPos(6,(100-(val*10))+16);
  8375. emit(valueChanged(val));
  8376. }
  8377. else if(val<1)
  8378. {
  8379. setValue(0);
  8380. }
  8381. else
  8382. {
  8383. setValue(10);
  8384. }
  8385. }
  8386. double IntensityControl::value()
  8387. {
  8388. return theValue;
  8389. }
  8390. /*:741*//*742:*/
  8391. #line 15304 "./typica.w"
  8392. void IntensityControl::mousePressEvent(QMouseEvent*event)
  8393. {
  8394. /*733:*/
  8395. #line 15048 "./typica.w"
  8396. if(event->button()!=Qt::LeftButton)
  8397. {
  8398. event->ignore();
  8399. return;
  8400. }
  8401. /*:733*/
  8402. #line 15307 "./typica.w"
  8403. scaleDown= true;
  8404. event->accept();
  8405. }
  8406. /*:742*//*743:*/
  8407. #line 15318 "./typica.w"
  8408. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  8409. {
  8410. /*733:*/
  8411. #line 15048 "./typica.w"
  8412. if(event->button()!=Qt::LeftButton)
  8413. {
  8414. event->ignore();
  8415. return;
  8416. }
  8417. /*:733*/
  8418. #line 15321 "./typica.w"
  8419. if(!scaleDown)
  8420. {
  8421. event->ignore();
  8422. return;
  8423. }
  8424. scaleDown= false;
  8425. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  8426. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  8427. {
  8428. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  8429. {
  8430. if(valueSet)
  8431. {
  8432. setValue(theValue+0.05);
  8433. }
  8434. event->accept();
  8435. return;
  8436. }
  8437. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  8438. {
  8439. if(valueSet)
  8440. {
  8441. setValue(theValue-0.05);
  8442. }
  8443. event->accept();
  8444. return;
  8445. }
  8446. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  8447. {
  8448. setValue(10-((sceneCoordinate.y()-16)/10.0));
  8449. event->accept();
  8450. return;
  8451. }
  8452. }
  8453. }
  8454. /*:743*/
  8455. #line 574 "./typica.w"
  8456. /*377:*/
  8457. #line 8497 "./typica.w"
  8458. void ThresholdDetector::newMeasurement(Measurement measure)
  8459. {
  8460. if((currentDirection==Ascending&&previousValue<threshold&&
  8461. previousValueValid)||(currentDirection==Descending&&
  8462. previousValue> threshold&&previousValueValid))
  8463. {
  8464. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  8465. (currentDirection==Descending&&measure.temperature()<=threshold))
  8466. {
  8467. double offset= measure.time().hour()*60*60;
  8468. offset+= measure.time().minute()*60;
  8469. offset+= measure.time().second();
  8470. offset+= measure.time().msec()/1000;
  8471. emit timeForValue(offset);
  8472. }
  8473. }
  8474. previousValue= measure.temperature();
  8475. previousValueValid= true;
  8476. }
  8477. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  8478. previousValueValid(false),
  8479. previousValue(-1),threshold(value),currentDirection(Ascending)
  8480. {
  8481. }
  8482. void ThresholdDetector::setThreshold(double value)
  8483. {
  8484. threshold= value;
  8485. }
  8486. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  8487. {
  8488. currentDirection= direction;
  8489. }
  8490. /*:377*/
  8491. #line 575 "./typica.w"
  8492. /*825:*/
  8493. #line 17210 "./typica.w"
  8494. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  8495. lister(new QextSerialEnumerator)
  8496. {
  8497. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  8498. QextPortInfo port;
  8499. foreach(port,ports)
  8500. {
  8501. #ifdef Q_OS_WIN32
  8502. addItem(port.portName);
  8503. #else
  8504. addItem(port.physName);
  8505. #endif
  8506. }
  8507. lister->setUpNotifications();
  8508. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  8509. this,SLOT(addDevice(QextPortInfo)));
  8510. setEditable(true);
  8511. }
  8512. void PortSelector::addDevice(QextPortInfo port)
  8513. {
  8514. addItem(port.portName);
  8515. }
  8516. /*:825*/
  8517. #line 576 "./typica.w"
  8518. /*827:*/
  8519. #line 17302 "./typica.w"
  8520. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  8521. {
  8522. QMetaObject meta= BaudSelector::staticMetaObject;
  8523. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  8524. for(int i= 0;i<type.keyCount();i++)
  8525. {
  8526. addItem(QString("%1").arg(type.value(i)));
  8527. }
  8528. }
  8529. /*:827*/
  8530. #line 577 "./typica.w"
  8531. /*829:*/
  8532. #line 17340 "./typica.w"
  8533. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  8534. {
  8535. QMetaObject meta= ParitySelector::staticMetaObject;
  8536. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  8537. for(int i= 0;i<type.keyCount();i++)
  8538. {
  8539. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8540. }
  8541. }
  8542. /*:829*/
  8543. #line 578 "./typica.w"
  8544. /*831:*/
  8545. #line 17370 "./typica.w"
  8546. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  8547. {
  8548. QMetaObject meta= FlowSelector::staticMetaObject;
  8549. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  8550. for(int i= 0;i<type.keyCount();i++)
  8551. {
  8552. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8553. }
  8554. }
  8555. /*:831*/
  8556. #line 579 "./typica.w"
  8557. /*833:*/
  8558. #line 17405 "./typica.w"
  8559. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  8560. {
  8561. QMetaObject meta= StopSelector::staticMetaObject;
  8562. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  8563. for(int i= 0;i<type.keyCount();i++)
  8564. {
  8565. addItem(QString(type.key(i)),QVariant(type.value(i)));
  8566. }
  8567. }
  8568. /*:833*/
  8569. #line 580 "./typica.w"
  8570. /*893:*/
  8571. #line 19191 "./typica.w"
  8572. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  8573. :BasicDeviceConfigurationWidget(model,index),
  8574. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  8575. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  8576. decimalQuery(new QCheckBox(tr("Enable"))),
  8577. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  8578. unitQuery(new QCheckBox(tr("Enable"))),
  8579. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  8580. valueC(new QSpinBox),fixedUnit(new QComboBox),
  8581. pVAddress(new ShortHexSpinBox),
  8582. sVEnabled(new QCheckBox(tr("Enable"))),
  8583. sVReadAddress(new ShortHexSpinBox),
  8584. deviceLimit(new QCheckBox(tr("Enable"))),
  8585. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  8586. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  8587. sVWritable(new QCheckBox(tr("Enable"))),
  8588. sVOutputAddr(new ShortHexSpinBox),
  8589. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  8590. {
  8591. QHBoxLayout*layout= new QHBoxLayout;
  8592. QWidget*form= new QWidget;
  8593. QHBoxLayout*masterLayout= new QHBoxLayout;
  8594. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  8595. QVBoxLayout*seriesLayout= new QVBoxLayout;
  8596. QFormLayout*serialSection= new QFormLayout;
  8597. serialSection->addRow(QString(tr("Port:")),port);
  8598. serialSection->addRow(QString(tr("Baud rate:")),baud);
  8599. serialSection->addRow(QString(tr("Parity:")),parity);
  8600. serialSection->addRow(QString(tr("Flow control:")),flow);
  8601. serialSection->addRow(QString(tr("Stop bits:")),stop);
  8602. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  8603. serialSectionBox->setLayout(serialSection);
  8604. portAndDeviceLayout->addWidget(serialSectionBox);
  8605. QFormLayout*deviceSection= new QFormLayout;
  8606. station->setMinimum(1);
  8607. station->setMaximum(255);
  8608. decimalPosition->setMinimum(0);
  8609. decimalPosition->setMaximum(9);
  8610. valueF->setMinimum(0);
  8611. valueF->setMaximum(0xFFFF);
  8612. valueC->setMinimum(0);
  8613. valueC->setMaximum(0xFFFF);
  8614. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  8615. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  8616. deviceSection->addRow(tr("Station:"),station);
  8617. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  8618. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  8619. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  8620. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  8621. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  8622. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  8623. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  8624. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  8625. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  8626. deviceSectionBox->setLayout(deviceSection);
  8627. portAndDeviceLayout->addWidget(deviceSectionBox);
  8628. QFormLayout*pVSection= new QFormLayout;
  8629. pVSection->addRow(tr("Value relative address:"),pVAddress);
  8630. pVSection->addRow(tr("PV column name:"),pVColumnName);
  8631. QCheckBox*pVHideBox= new QCheckBox(tr("Hide this channel"));
  8632. pVSection->addRow(pVHideBox);
  8633. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  8634. processValueBox->setLayout(pVSection);
  8635. seriesLayout->addWidget(processValueBox);
  8636. QFormLayout*sVSection= new QFormLayout;
  8637. sVLower->setDecimals(1);
  8638. sVLower->setMinimum(0.0);
  8639. sVLower->setMaximum(999.9);
  8640. sVUpper->setDecimals(1);
  8641. sVUpper->setMinimum(0.0);
  8642. sVUpper->setMaximum(999.9);
  8643. sVSection->addRow(tr("Set value:"),sVEnabled);
  8644. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  8645. sVSection->addRow(tr("SV column name:"),sVColumnName);
  8646. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  8647. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  8648. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  8649. sVSection->addRow(tr("Lower limit:"),sVLower);
  8650. sVSection->addRow(tr("Upper limit:"),sVUpper);
  8651. sVSection->addRow(tr("Output set value:"),sVWritable);
  8652. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  8653. QCheckBox*sVHideBox= new QCheckBox(tr("Hide this channel"));
  8654. sVSection->addRow(sVHideBox);
  8655. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  8656. setValueBox->setLayout(sVSection);
  8657. seriesLayout->addWidget(setValueBox);
  8658. masterLayout->addLayout(portAndDeviceLayout);
  8659. masterLayout->addLayout(seriesLayout);
  8660. form->setLayout(masterLayout);
  8661. /*801:*/
  8662. #line 16651 "./typica.w"
  8663. QDomElement referenceElement=
  8664. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8665. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8666. QDomElement node;
  8667. /*:801*/
  8668. #line 19281 "./typica.w"
  8669. for(int i= 0;i<configData.size();i++)
  8670. {
  8671. node= configData.at(i).toElement();
  8672. if(node.attribute("name")=="port")
  8673. {
  8674. QString portname= node.attribute("value");
  8675. int idx= port->findText(portname);
  8676. if(idx>=0)
  8677. {
  8678. port->setCurrentIndex(idx);
  8679. }
  8680. else
  8681. {
  8682. port->addItem(portname);
  8683. }
  8684. }
  8685. else if(node.attribute("name")=="baud")
  8686. {
  8687. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  8688. }
  8689. else if(node.attribute("name")=="parity")
  8690. {
  8691. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  8692. }
  8693. else if(node.attribute("name")=="flow")
  8694. {
  8695. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  8696. }
  8697. else if(node.attribute("name")=="stop")
  8698. {
  8699. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  8700. }
  8701. else if(node.attribute("name")=="station")
  8702. {
  8703. station->setValue(node.attribute("value").toInt());
  8704. }
  8705. else if(node.attribute("name")=="decimalQuery")
  8706. {
  8707. if(node.attribute("value")=="true")
  8708. {
  8709. decimalQuery->setChecked(true);
  8710. }
  8711. else
  8712. {
  8713. decimalQuery->setChecked(false);
  8714. }
  8715. }
  8716. else if(node.attribute("name")=="decimalAddress")
  8717. {
  8718. decimalAddress->setValue(node.attribute("value").toInt());
  8719. }
  8720. else if(node.attribute("name")=="decimalPosition")
  8721. {
  8722. decimalPosition->setValue(node.attribute("value").toInt());
  8723. }
  8724. else if(node.attribute("name")=="unitQuery")
  8725. {
  8726. if(node.attribute("value")=="true")
  8727. {
  8728. unitQuery->setChecked(true);
  8729. }
  8730. else
  8731. {
  8732. unitQuery->setChecked(false);
  8733. }
  8734. }
  8735. else if(node.attribute("name")=="unitAddress")
  8736. {
  8737. unitAddress->setValue(node.attribute("value").toInt());
  8738. }
  8739. else if(node.attribute("name")=="valueF")
  8740. {
  8741. valueF->setValue(node.attribute("value").toInt());
  8742. }
  8743. else if(node.attribute("name")=="valueC")
  8744. {
  8745. valueC->setValue(node.attribute("value").toInt());
  8746. }
  8747. else if(node.attribute("name")=="fixedUnit")
  8748. {
  8749. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  8750. }
  8751. else if(node.attribute("name")=="pVAddress")
  8752. {
  8753. pVAddress->setValue(node.attribute("value").toInt());
  8754. }
  8755. else if(node.attribute("name")=="sVEnabled")
  8756. {
  8757. if(node.attribute("value")=="true")
  8758. {
  8759. sVEnabled->setChecked(true);
  8760. }
  8761. else
  8762. {
  8763. sVEnabled->setChecked(false);
  8764. }
  8765. }
  8766. else if(node.attribute("name")=="sVReadAddress")
  8767. {
  8768. sVReadAddress->setValue(node.attribute("value").toInt());
  8769. }
  8770. else if(node.attribute("name")=="deviceLimit")
  8771. {
  8772. if(node.attribute("value")=="true")
  8773. {
  8774. deviceLimit->setChecked(true);
  8775. }
  8776. else
  8777. {
  8778. deviceLimit->setChecked(false);
  8779. }
  8780. }
  8781. else if(node.attribute("name")=="sVLowerAddr")
  8782. {
  8783. sVLowerAddr->setValue(node.attribute("value").toInt());
  8784. }
  8785. else if(node.attribute("name")=="sVUpperAddr")
  8786. {
  8787. sVUpperAddr->setValue(node.attribute("value").toInt());
  8788. }
  8789. else if(node.attribute("name")=="sVLower")
  8790. {
  8791. sVLower->setValue(node.attribute("value").toDouble());
  8792. }
  8793. else if(node.attribute("name")=="sVUpper")
  8794. {
  8795. sVUpper->setValue(node.attribute("value").toDouble());
  8796. }
  8797. else if(node.attribute("name")=="sVWritable")
  8798. {
  8799. if(node.attribute("value")=="true")
  8800. {
  8801. sVWritable->setChecked(true);
  8802. }
  8803. else
  8804. {
  8805. sVWritable->setChecked(false);
  8806. }
  8807. }
  8808. else if(node.attribute("name")=="sVOutputAddr")
  8809. {
  8810. sVOutputAddr->setValue(node.attribute("value").toInt());
  8811. }
  8812. else if(node.attribute("name")=="pvcolname")
  8813. {
  8814. pVColumnName->setText(node.attribute("value"));
  8815. }
  8816. else if(node.attribute("name")=="svcolname")
  8817. {
  8818. sVColumnName->setText(node.attribute("value"));
  8819. }
  8820. else if(node.attribute("name")=="pvhidden")
  8821. {
  8822. pVHideBox->setChecked(node.attribute("value")=="true");
  8823. }
  8824. else if(node.attribute("name")=="svhidden")
  8825. {
  8826. sVHideBox->setChecked(node.attribute("value")=="true");
  8827. }
  8828. }
  8829. updatePort(port->currentText());
  8830. updateBaudRate(baud->currentText());
  8831. updateParity(parity->itemData(parity->currentIndex()).toString());
  8832. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  8833. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  8834. updateStation(station->value());
  8835. updateFixedDecimal(decimalQuery->isChecked());
  8836. updateDecimalAddress(decimalAddress->value());
  8837. updateDecimalPosition(decimalPosition->value());
  8838. updateFixedUnit(unitQuery->isChecked());
  8839. updateUnitAddress(unitAddress->value());
  8840. updateValueForF(valueF->value());
  8841. updateValueForC(valueC->value());
  8842. updateUnit(fixedUnit->currentText());
  8843. updatePVAddress(pVAddress->value());
  8844. updateSVEnabled(sVEnabled->isChecked());
  8845. updateSVReadAddress(sVReadAddress->value());
  8846. updateDeviceLimit(deviceLimit->isChecked());
  8847. updateSVLowerAddress(sVLowerAddr->value());
  8848. updateSVUpperAddress(sVUpperAddr->value());
  8849. updateSVLower(sVLower->value());
  8850. updateSVUpper(sVUpper->value());
  8851. updateSVWritable(sVWritable->isChecked());
  8852. updateSVWriteAddress(sVOutputAddr->value());
  8853. updatePVColumnName(pVColumnName->text());
  8854. updateSVColumnName(sVColumnName->text());
  8855. updatePVHidden(pVHideBox->isChecked());
  8856. updateSVHidden(sVHideBox->isChecked());
  8857. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  8858. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  8859. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  8860. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  8861. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  8862. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  8863. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  8864. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  8865. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  8866. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  8867. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  8868. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  8869. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  8870. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  8871. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  8872. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  8873. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  8874. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  8875. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  8876. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  8877. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  8878. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  8879. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  8880. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  8881. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  8882. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  8883. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  8884. connect(pVHideBox,SIGNAL(toggled(bool)),this,SLOT(updatePVHidden(bool)));
  8885. connect(sVHideBox,SIGNAL(toggled(bool)),this,SLOT(updateSVHidden(bool)));
  8886. layout->addWidget(form);
  8887. setLayout(layout);
  8888. }
  8889. void ModbusConfigurator::updatePort(const QString&newPort)
  8890. {
  8891. updateAttribute("port",newPort);
  8892. }
  8893. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  8894. {
  8895. updateAttribute("baud",newRate);
  8896. }
  8897. void ModbusConfigurator::updateParity(const QString&)
  8898. {
  8899. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  8900. }
  8901. void ModbusConfigurator::updateFlowControl(const QString&)
  8902. {
  8903. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  8904. }
  8905. void ModbusConfigurator::updateStopBits(const QString&)
  8906. {
  8907. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  8908. }
  8909. void ModbusConfigurator::updateStation(int station)
  8910. {
  8911. updateAttribute("station",QString("%1").arg(station));
  8912. }
  8913. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  8914. {
  8915. updateAttribute("decimalQuery",fixed?"true":"false");
  8916. }
  8917. void ModbusConfigurator::updateDecimalAddress(int address)
  8918. {
  8919. updateAttribute("decimalAddress",QString("%1").arg(address));
  8920. }
  8921. void ModbusConfigurator::updateDecimalPosition(int position)
  8922. {
  8923. updateAttribute("decimalPosition",QString("%1").arg(position));
  8924. }
  8925. void ModbusConfigurator::updateFixedUnit(bool fixed)
  8926. {
  8927. updateAttribute("unitQuery",fixed?"true":"false");
  8928. }
  8929. void ModbusConfigurator::updateUnitAddress(int address)
  8930. {
  8931. updateAttribute("unitAddress",QString("%1").arg(address));
  8932. }
  8933. void ModbusConfigurator::updateValueForF(int value)
  8934. {
  8935. updateAttribute("valueF",QString("%1").arg(value));
  8936. }
  8937. void ModbusConfigurator::updateValueForC(int value)
  8938. {
  8939. updateAttribute("valueC",QString("%1").arg(value));
  8940. }
  8941. void ModbusConfigurator::updateUnit(const QString&newUnit)
  8942. {
  8943. updateAttribute("fixedUnit",newUnit);
  8944. }
  8945. void ModbusConfigurator::updatePVAddress(int address)
  8946. {
  8947. updateAttribute("pVAddress",QString("%1").arg(address));
  8948. }
  8949. void ModbusConfigurator::updateSVEnabled(bool enabled)
  8950. {
  8951. updateAttribute("sVEnabled",enabled?"true":"false");
  8952. }
  8953. void ModbusConfigurator::updateSVReadAddress(int address)
  8954. {
  8955. updateAttribute("sVReadAddress",QString("%1").arg(address));
  8956. }
  8957. void ModbusConfigurator::updateDeviceLimit(bool query)
  8958. {
  8959. updateAttribute("deviceLimit",query?"true":"false");
  8960. }
  8961. void ModbusConfigurator::updateSVLowerAddress(int address)
  8962. {
  8963. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  8964. }
  8965. void ModbusConfigurator::updateSVUpperAddress(int address)
  8966. {
  8967. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  8968. }
  8969. void ModbusConfigurator::updateSVLower(double value)
  8970. {
  8971. updateAttribute("sVLower",QString("%1").arg(value));
  8972. }
  8973. void ModbusConfigurator::updateSVUpper(double value)
  8974. {
  8975. updateAttribute("sVUpper",QString("%1").arg(value));
  8976. }
  8977. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  8978. {
  8979. updateAttribute("sVWritable",canWriteSV?"true":"false");
  8980. }
  8981. void ModbusConfigurator::updateSVWriteAddress(int address)
  8982. {
  8983. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  8984. }
  8985. void ModbusConfigurator::updatePVColumnName(const QString&name)
  8986. {
  8987. updateAttribute("pvcolname",name);
  8988. }
  8989. void ModbusConfigurator::updateSVColumnName(const QString&name)
  8990. {
  8991. updateAttribute("svcolname",name);
  8992. }
  8993. void ModbusConfigurator::updatePVHidden(bool hidden)
  8994. {
  8995. updateAttribute("pvhidden",hidden?"true":"false");
  8996. }
  8997. void ModbusConfigurator::updateSVHidden(bool hidden)
  8998. {
  8999. updateAttribute("svhidden",hidden?"true":"false");
  9000. }
  9001. /*:893*/
  9002. #line 581 "./typica.w"
  9003. /*836:*/
  9004. #line 17458 "./typica.w"
  9005. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  9006. {
  9007. setMinimum(0);
  9008. setMaximum(0xFFFF);
  9009. setPrefix("0x");
  9010. setMinimumWidth(65);
  9011. }
  9012. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  9013. {
  9014. if(input.size()==2)
  9015. {
  9016. return QValidator::Intermediate;
  9017. }
  9018. bool okay;
  9019. input.toInt(&okay,16);
  9020. if(okay)
  9021. {
  9022. return QValidator::Acceptable;
  9023. }
  9024. return QValidator::Invalid;
  9025. }
  9026. int ShortHexSpinBox::valueFromText(const QString&text)const
  9027. {
  9028. return text.toInt(NULL,16);
  9029. }
  9030. QString ShortHexSpinBox::textFromValue(int value)const
  9031. {
  9032. QString retval;
  9033. retval.setNum(value,16);
  9034. while(retval.size()<4)
  9035. {
  9036. retval.prepend("0");
  9037. }
  9038. return retval.toUpper();
  9039. }
  9040. /*:836*/
  9041. #line 582 "./typica.w"
  9042. /*877:*/
  9043. #line 18490 "./typica.w"
  9044. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  9045. :QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),unitIsF(true),readingsv(false),
  9046. waiting(false)
  9047. {
  9048. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  9049. Qt::UserRole).toString());
  9050. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  9051. QDomElement node;
  9052. QVariantMap attributes;
  9053. for(int i= 0;i<portConfigData.size();i++)
  9054. {
  9055. node= portConfigData.at(i).toElement();
  9056. attributes.insert(node.attribute("name"),node.attribute("value"));
  9057. }
  9058. port= new QextSerialPort(attributes.value("port").toString(),
  9059. QextSerialPort::EventDriven);
  9060. int baudRate= attributes.value("baud").toInt();
  9061. port->setBaudRate((BaudRateType)baudRate);
  9062. double temp= ((double)(1)/(double)(baudRate))*48;
  9063. delayTime= (int)(temp*3000);
  9064. messageDelayTimer->setSingleShot(true);
  9065. commTimeout->setSingleShot(true);
  9066. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  9067. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  9068. port->setDataBits(DATA_8);
  9069. port->setParity((ParityType)attributes.value("parity").toInt());
  9070. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  9071. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  9072. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  9073. port->open(QIODevice::ReadWrite);
  9074. station= (char)attributes.value("station").toInt();
  9075. if(attributes.value("decimalQuery")=="true")
  9076. {
  9077. decimalPosition= 0;
  9078. QByteArray message;
  9079. message.append(station);
  9080. message.append((char)0x03);
  9081. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  9082. char*addressBytes= (char*)&address;
  9083. message.append(addressBytes[1]);
  9084. message.append(addressBytes[0]);
  9085. message.append((char)0x00);
  9086. message.append((char)0x01);
  9087. queueMessage(message,this,"decimalResponse(QByteArray)");
  9088. }
  9089. else
  9090. {
  9091. decimalPosition= attributes.value("decimalPosition").toInt();
  9092. }
  9093. valueF= attributes.value("valueF").toInt();
  9094. valueC= attributes.value("valueC").toInt();
  9095. if(attributes.value("unitQuery")=="true")
  9096. {
  9097. QByteArray message;
  9098. message.append(station);
  9099. message.append((char)0x03);
  9100. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  9101. char*addressBytes= (char*)&address;
  9102. message.append(addressBytes[1]);
  9103. message.append(addressBytes[0]);
  9104. message.append((char)0x00);
  9105. message.append((char)0x01);
  9106. queueMessage(message,this,"unitResponse(QByteArray)");
  9107. }
  9108. else
  9109. {
  9110. if(attributes.value("fixedUnit")=="Celsius")
  9111. {
  9112. unitIsF= false;
  9113. }
  9114. }
  9115. if(attributes.value("sVWritable")=="true")
  9116. {
  9117. if(attributes.value("deviceLimit")=="true")
  9118. {
  9119. QByteArray lmessage;
  9120. lmessage.append(station);
  9121. lmessage.append((char)0x03);
  9122. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  9123. char*addressBytes= (char*)&laddress;
  9124. lmessage.append(addressBytes[1]);
  9125. lmessage.append(addressBytes[0]);
  9126. lmessage.append((char)0x00);
  9127. lmessage.append((char)0x01);
  9128. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  9129. QByteArray umessage;
  9130. umessage.append(station);
  9131. umessage.append((char)0x03);
  9132. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  9133. addressBytes= (char*)&uaddress;
  9134. umessage.append(addressBytes[1]);
  9135. umessage.append(addressBytes[0]);
  9136. umessage.append((char)0x00);
  9137. umessage.append((char)0x01);
  9138. queueMessage(umessage,this,"svuResponse(QByteArray)");
  9139. }
  9140. else
  9141. {
  9142. outputSVLower= attributes.value("sVLower").toDouble();
  9143. outputSVUpper= attributes.value("sVUpper").toDouble();
  9144. }
  9145. outputSVStub.append(station);
  9146. outputSVStub.append((char)0x06);
  9147. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  9148. char*addressBytes= (char*)&address;
  9149. outputSVStub.append(addressBytes[1]);
  9150. outputSVStub.append(addressBytes[0]);
  9151. }
  9152. Channel*pv= new Channel;
  9153. channels.append(pv);
  9154. pvStub.append(station);
  9155. pvStub.append((char)0x04);
  9156. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  9157. char*pvac= (char*)&pvaddress;
  9158. pvStub.append(pvac[1]);
  9159. pvStub.append(pvac[0]);
  9160. pvStub.append((char)0x00);
  9161. pvStub.append((char)0x01);
  9162. svenabled= attributes.value("sVEnabled").toBool();
  9163. if(svenabled)
  9164. {
  9165. Channel*sv= new Channel;
  9166. channels.append(sv);
  9167. svStub.append(station);
  9168. svStub.append((char)0x04);
  9169. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  9170. char*svac= (char*)&svaddress;
  9171. svStub.append(svac[1]);
  9172. svStub.append(svac[0]);
  9173. svStub.append((char)0x00);
  9174. svStub.append((char)0x01);
  9175. if(svaddress-pvaddress==1)
  9176. {
  9177. mStub.append(station);
  9178. mStub.append((char)0x04);
  9179. mStub.append(pvac[1]);
  9180. mStub.append(pvac[0]);
  9181. mStub.append((char)0x00);
  9182. mStub.append((char)0x02);
  9183. }
  9184. }
  9185. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  9186. requestMeasurement();
  9187. }
  9188. double ModbusRTUDevice::SVLower()
  9189. {
  9190. return outputSVLower;
  9191. }
  9192. double ModbusRTUDevice::SVUpper()
  9193. {
  9194. return outputSVUpper;
  9195. }
  9196. int ModbusRTUDevice::decimals()
  9197. {
  9198. return decimalPosition;
  9199. }
  9200. void ModbusRTUDevice::decimalResponse(QByteArray response)
  9201. {
  9202. quint16 temp;
  9203. char*tchar= (char*)&temp;
  9204. tchar[1]= response.at(3);
  9205. tchar[0]= response.at(4);
  9206. decimalPosition= temp;
  9207. emit SVDecimalChanged(decimalPosition);
  9208. qDebug()<<"Received decimal response";
  9209. }
  9210. void ModbusRTUDevice::unitResponse(QByteArray response)
  9211. {
  9212. quint16 temp;
  9213. char*tchar= (char*)&temp;
  9214. tchar[1]= response.at(3);
  9215. tchar[0]= response.at(4);
  9216. int value= temp;
  9217. if(value==valueF)
  9218. {
  9219. unitIsF= true;
  9220. }
  9221. else
  9222. {
  9223. unitIsF= false;
  9224. }
  9225. qDebug()<<"Received unit response";
  9226. }
  9227. void ModbusRTUDevice::svlResponse(QByteArray response)
  9228. {
  9229. quint16 temp;
  9230. char*tchar= (char*)&temp;
  9231. tchar[1]= response.at(3);
  9232. tchar[0]= response.at(4);
  9233. outputSVLower= (double)temp;
  9234. for(int i= 0;i<decimalPosition;i++)
  9235. {
  9236. outputSVLower/= 10;
  9237. }
  9238. emit SVLowerChanged(outputSVLower);
  9239. qDebug()<<"Received set value lower bound response";
  9240. }
  9241. void ModbusRTUDevice::svuResponse(QByteArray response)
  9242. {
  9243. quint16 temp;
  9244. char*tchar= (char*)&temp;
  9245. tchar[1]= response.at(3);
  9246. tchar[0]= response.at(4);
  9247. outputSVUpper= (double)temp;
  9248. for(int i= 0;i<decimalPosition;i++)
  9249. {
  9250. outputSVUpper/= 10;
  9251. }
  9252. emit SVUpperChanged(outputSVUpper);
  9253. qDebug()<<"Received set value upper bound response";
  9254. }
  9255. void ModbusRTUDevice::requestMeasurement()
  9256. {
  9257. if(mStub.length()> 0)
  9258. {
  9259. queueMessage(mStub,this,"mResponse(QByteArray)");
  9260. }
  9261. else
  9262. {
  9263. queueMessage(pvStub,this,"mResponse(QByteArray)");
  9264. if(svenabled)
  9265. {
  9266. queueMessage(svStub,this,"mResponse(QByteArray)");
  9267. }
  9268. }
  9269. }
  9270. void ModbusRTUDevice::mResponse(QByteArray response)
  9271. {
  9272. QTime time= QTime::currentTime();
  9273. if(response.at(2)==0x04)
  9274. {
  9275. /*878:*/
  9276. #line 18744 "./typica.w"
  9277. quint16 pv;
  9278. quint16 sv;
  9279. char*pvBytes= (char*)&pv;
  9280. char*svBytes= (char*)&sv;
  9281. pvBytes[1]= response.at(3);
  9282. pvBytes[0]= response.at(4);
  9283. svBytes[1]= response.at(5);
  9284. svBytes[0]= response.at(6);
  9285. double pvOut= (double)pv;
  9286. double svOut= (double)sv;
  9287. for(int i= 0;i<decimalPosition;i++)
  9288. {
  9289. pvOut/= 10;
  9290. svOut/= 10;
  9291. }
  9292. if(!unitIsF)
  9293. {
  9294. pvOut= pvOut*9/5+32;
  9295. svOut= svOut*9/5+32;
  9296. }
  9297. Measurement pvm(pvOut,time,Units::Fahrenheit);
  9298. Measurement svm(svOut,time,Units::Fahrenheit);
  9299. channels.at(0)->input(pvm);
  9300. channels.at(1)->input(svm);
  9301. /*:878*/
  9302. #line 18731 "./typica.w"
  9303. }
  9304. else
  9305. {
  9306. /*879:*/
  9307. #line 18774 "./typica.w"
  9308. quint16 value;
  9309. char*valueBytes= (char*)&value;
  9310. valueBytes[1]= response.at(3);
  9311. valueBytes[0]= response.at(4);
  9312. double valueOut= (double)value;
  9313. for(int i= 0;i<decimalPosition;i++)
  9314. {
  9315. valueOut/= 10;
  9316. }
  9317. if(!unitIsF)
  9318. {
  9319. valueOut= valueOut*9/5+32;
  9320. }
  9321. if(!svenabled)
  9322. {
  9323. Measurement vm(valueOut,time,Units::Fahrenheit);
  9324. channels.at(0)->input(vm);
  9325. }
  9326. else
  9327. {
  9328. if(readingsv)
  9329. {
  9330. Measurement pvm(savedpv,time,Units::Fahrenheit);
  9331. Measurement svm(valueOut,time,Units::Fahrenheit);
  9332. channels.at(0)->input(pvm);
  9333. channels.at(1)->input(svm);
  9334. readingsv= false;
  9335. }
  9336. else
  9337. {
  9338. savedpv= valueOut;
  9339. readingsv= true;
  9340. }
  9341. }
  9342. /*:879*/
  9343. #line 18735 "./typica.w"
  9344. }
  9345. }
  9346. /*:877*//*880:*/
  9347. #line 18812 "./typica.w"
  9348. ModbusRTUDevice::~ModbusRTUDevice()
  9349. {
  9350. commTimeout->stop();
  9351. messageDelayTimer->stop();
  9352. port->close();
  9353. }
  9354. /*:880*//*881:*/
  9355. #line 18839 "./typica.w"
  9356. void ModbusRTUDevice::dataAvailable()
  9357. {
  9358. if(messageDelayTimer->isActive())
  9359. {
  9360. messageDelayTimer->stop();
  9361. }
  9362. responseBuffer.append(port->readAll());
  9363. /*882:*/
  9364. #line 18885 "./typica.w"
  9365. if(responseBuffer.size()<5)
  9366. {
  9367. return;
  9368. }
  9369. switch(responseBuffer.at(1))
  9370. {
  9371. case 0x01:
  9372. case 0x02:
  9373. if(responseBuffer.size()<6)
  9374. {
  9375. return;
  9376. }
  9377. responseBuffer= responseBuffer.left(6);
  9378. break;
  9379. case 0x03:
  9380. case 0x04:
  9381. if(responseBuffer.size()<5+responseBuffer.at(2))
  9382. {
  9383. return;
  9384. }
  9385. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  9386. break;
  9387. case 0x05:
  9388. case 0x06:
  9389. case 0x10:
  9390. if(responseBuffer.size()<8)
  9391. {
  9392. return;
  9393. }
  9394. responseBuffer= responseBuffer.left(8);
  9395. break;
  9396. }
  9397. /*:882*/
  9398. #line 18847 "./typica.w"
  9399. commTimeout->stop();
  9400. if(calculateCRC(responseBuffer)==0)
  9401. {
  9402. QObject*object= retObjQueue.at(0);
  9403. char*method= callbackQueue.at(0);
  9404. QMetaMethod metamethod= object->metaObject()->
  9405. method(object->metaObject()->
  9406. indexOfMethod(QMetaObject::normalizedSignature(method)));
  9407. metamethod.invoke(object,Qt::QueuedConnection,
  9408. Q_ARG(QByteArray,responseBuffer));
  9409. messageQueue.removeAt(0);
  9410. retObjQueue.removeAt(0);
  9411. callbackQueue.removeAt(0);
  9412. }
  9413. else
  9414. {
  9415. qDebug()<<"CRC failed";
  9416. }
  9417. messageDelayTimer->start(delayTime);
  9418. waiting= false;
  9419. responseBuffer.clear();
  9420. }
  9421. /*:881*//*883:*/
  9422. #line 18927 "./typica.w"
  9423. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  9424. {
  9425. quint16 retval= 0xFFFF;
  9426. int i= 0;
  9427. while(i<data.size())
  9428. {
  9429. retval^= 0x00FF&(quint16)data.at(i);
  9430. for(int j= 0;j<8;j++)
  9431. {
  9432. if(retval&1)
  9433. {
  9434. retval= (retval>>1)^0xA001;
  9435. }
  9436. else
  9437. {
  9438. retval>>= 1;
  9439. }
  9440. }
  9441. i++;
  9442. }
  9443. return retval;
  9444. }
  9445. /*:883*//*884:*/
  9446. #line 18958 "./typica.w"
  9447. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  9448. const char*callback)
  9449. {
  9450. messageQueue.append(request);
  9451. retObjQueue.append(object);
  9452. callbackQueue.append(const_cast<char*> (callback));
  9453. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  9454. {
  9455. sendNextMessage();
  9456. }
  9457. }
  9458. void ModbusRTUDevice::sendNextMessage()
  9459. {
  9460. if(messageQueue.size()> 0&&!waiting)
  9461. {
  9462. QByteArray message= messageQueue.at(0);
  9463. quint16 crc= calculateCRC(message);
  9464. char*check= (char*)&crc;
  9465. message.append(check[0]);
  9466. message.append(check[1]);
  9467. qDebug()<<"Writing"<<message.toHex();
  9468. port->write(message);
  9469. commTimeout->start(2000);
  9470. messageDelayTimer->start(delayTime);
  9471. waiting= true;
  9472. }
  9473. else
  9474. {
  9475. emit queueEmpty();
  9476. }
  9477. }
  9478. void ModbusRTUDevice::outputSV(double value)
  9479. {
  9480. for(int i= 0;i<decimalPosition;i++)
  9481. {
  9482. value*= 10;
  9483. }
  9484. quint16 outval= (quint16)value;
  9485. QByteArray message(outputSVStub);
  9486. char*valBytes= (char*)&outval;
  9487. message.append(valBytes[1]);
  9488. message.append(valBytes[0]);
  9489. queueMessage(message,this,"ignore(QByteArray)");
  9490. }
  9491. /*:884*//*885:*/
  9492. #line 19008 "./typica.w"
  9493. void ModbusRTUDevice::ignore(QByteArray)
  9494. {
  9495. return;
  9496. }
  9497. /*:885*//*886:*/
  9498. #line 19021 "./typica.w"
  9499. void ModbusRTUDevice::timeout()
  9500. {
  9501. qDebug()<<"Communications timeout.";
  9502. responseBuffer.clear();
  9503. waiting= false;
  9504. messageDelayTimer->start();
  9505. }
  9506. /*:886*/
  9507. #line 583 "./typica.w"
  9508. /*755:*/
  9509. #line 15576 "./typica.w"
  9510. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  9511. DeviceTreeModelNode*parent)
  9512. :domNode(node),rowNumber(row),parentItem(parent)
  9513. {
  9514. }
  9515. DeviceTreeModelNode::~DeviceTreeModelNode()
  9516. {
  9517. QHash<int,DeviceTreeModelNode*> ::iterator i;
  9518. for(i= children.begin();i!=children.end();i++)
  9519. {
  9520. delete i.value();
  9521. }
  9522. }
  9523. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  9524. {
  9525. return parentItem;
  9526. }
  9527. int DeviceTreeModelNode::row()
  9528. {
  9529. return rowNumber;
  9530. }
  9531. QDomNode DeviceTreeModelNode::node()const
  9532. {
  9533. return domNode;
  9534. }
  9535. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  9536. {
  9537. if(children.contains(index))
  9538. {
  9539. return children[index];
  9540. }
  9541. if(index>=0&&index<domNode.childNodes().count())
  9542. {
  9543. QDomNode childNode= domNode.childNodes().item(index);
  9544. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  9545. index,this);
  9546. children[index]= childItem;
  9547. return childItem;
  9548. }
  9549. return NULL;
  9550. }
  9551. /*:755*/
  9552. #line 584 "./typica.w"
  9553. /*757:*/
  9554. #line 15665 "./typica.w"
  9555. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  9556. :QAbstractItemModel(parent)
  9557. {
  9558. document= AppInstance->deviceConfiguration();
  9559. QDomNodeList elements= document.elementsByTagName("devices");
  9560. if(elements.size()!=1)
  9561. {
  9562. qDebug()<<"Unexpected result when loading device map.";
  9563. }
  9564. treeRoot= elements.at(0);
  9565. root= new DeviceTreeModelNode(treeRoot,0);
  9566. elements= document.elementsByTagName("references");
  9567. if(elements.size()!=1)
  9568. {
  9569. qDebug()<<"No references section. Creating.";
  9570. referenceSection= document.createElement("references");
  9571. document.appendChild(referenceSection);
  9572. }
  9573. else
  9574. {
  9575. referenceSection= elements.at(0);
  9576. }
  9577. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  9578. AppInstance,SLOT(saveDeviceConfiguration()));
  9579. connect(this,SIGNAL(modelReset()),
  9580. AppInstance,SLOT(saveDeviceConfiguration()));
  9581. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9582. AppInstance,SLOT(saveDeviceConfiguration()));
  9583. }
  9584. /*:757*//*758:*/
  9585. #line 15700 "./typica.w"
  9586. int DeviceTreeModel::columnCount(const QModelIndex&)const
  9587. {
  9588. return 1;
  9589. }
  9590. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  9591. {
  9592. if(parent.column()> 0)
  9593. {
  9594. return 0;
  9595. }
  9596. /*759:*/
  9597. #line 15719 "./typica.w"
  9598. DeviceTreeModelNode*parentItem;
  9599. if(!parent.isValid())
  9600. {
  9601. parentItem= root;
  9602. }
  9603. else
  9604. {
  9605. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9606. }
  9607. /*:759*/
  9608. #line 15712 "./typica.w"
  9609. return parentItem->node().childNodes().count();
  9610. }
  9611. /*:758*//*760:*/
  9612. #line 15733 "./typica.w"
  9613. QModelIndex DeviceTreeModel::index(int row,int column,
  9614. const QModelIndex&parent)const
  9615. {
  9616. if(!hasIndex(row,column,parent))
  9617. {
  9618. return QModelIndex();
  9619. }
  9620. /*759:*/
  9621. #line 15719 "./typica.w"
  9622. DeviceTreeModelNode*parentItem;
  9623. if(!parent.isValid())
  9624. {
  9625. parentItem= root;
  9626. }
  9627. else
  9628. {
  9629. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9630. }
  9631. /*:759*/
  9632. #line 15741 "./typica.w"
  9633. DeviceTreeModelNode*childItem= parentItem->child(row);
  9634. if(childItem)
  9635. {
  9636. return createIndex(row,column,childItem);
  9637. }
  9638. return QModelIndex();
  9639. }
  9640. /*:760*//*761:*/
  9641. #line 15752 "./typica.w"
  9642. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  9643. {
  9644. if(!child.isValid())
  9645. {
  9646. return QModelIndex();
  9647. }
  9648. DeviceTreeModelNode*childItem=
  9649. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  9650. DeviceTreeModelNode*parentItem= childItem->parent();
  9651. if(!parentItem||parentItem==root)
  9652. {
  9653. return QModelIndex();
  9654. }
  9655. return createIndex(parentItem->row(),0,parentItem);
  9656. }
  9657. /*:761*//*762:*/
  9658. #line 15771 "./typica.w"
  9659. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  9660. {
  9661. if(!index.isValid())
  9662. {
  9663. return 0;
  9664. }
  9665. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  9666. }
  9667. /*:762*//*763:*/
  9668. #line 15786 "./typica.w"
  9669. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  9670. {
  9671. if(!index.isValid())
  9672. {
  9673. return QVariant();
  9674. }
  9675. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  9676. {
  9677. return QVariant();
  9678. }
  9679. DeviceTreeModelNode*item=
  9680. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9681. QDomNode node= item->node();
  9682. QDomElement element= node.toElement();
  9683. switch(role)
  9684. {
  9685. case Qt::DisplayRole:
  9686. case Qt::EditRole:
  9687. return QVariant(element.attribute("name"));
  9688. case Qt::UserRole:
  9689. return QVariant(element.attribute("reference"));
  9690. default:
  9691. return QVariant();
  9692. }
  9693. return QVariant();
  9694. }
  9695. /*:763*//*764:*/
  9696. #line 15818 "./typica.w"
  9697. bool DeviceTreeModel::setData(const QModelIndex&index,
  9698. const QVariant&value,int)
  9699. {
  9700. if(!index.isValid())
  9701. {
  9702. return false;
  9703. }
  9704. DeviceTreeModelNode*item=
  9705. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  9706. QDomNode node= item->node();
  9707. QDomElement element= node.toElement();
  9708. element.setAttribute("name",value.toString());
  9709. emit dataChanged(index,index);
  9710. return true;
  9711. }
  9712. /*:764*//*765:*/
  9713. #line 15841 "./typica.w"
  9714. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  9715. const QModelIndex&parent)
  9716. {
  9717. QString referenceID= QUuid::createUuid().toString();
  9718. /*759:*/
  9719. #line 15719 "./typica.w"
  9720. DeviceTreeModelNode*parentItem;
  9721. if(!parent.isValid())
  9722. {
  9723. parentItem= root;
  9724. }
  9725. else
  9726. {
  9727. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9728. }
  9729. /*:759*/
  9730. #line 15846 "./typica.w"
  9731. QDomNode parentNode= parentItem->node();
  9732. int newRowNumber= rowCount(parent);
  9733. beginInsertRows(parent,newRowNumber,newRowNumber);
  9734. QDomElement deviceElement= document.createElement("node");
  9735. deviceElement.setAttribute("name",name);
  9736. deviceElement.setAttribute("reference",referenceID);
  9737. parentNode.appendChild(deviceElement);
  9738. QDomElement referenceElement= document.createElement("reference");
  9739. referenceElement.setAttribute("id",referenceID);
  9740. referenceElement.setAttribute("driver",driver);
  9741. referenceSection.appendChild(referenceElement);
  9742. endInsertRows();
  9743. }
  9744. /*:765*//*766:*/
  9745. #line 15864 "./typica.w"
  9746. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  9747. {
  9748. /*759:*/
  9749. #line 15719 "./typica.w"
  9750. DeviceTreeModelNode*parentItem;
  9751. if(!parent.isValid())
  9752. {
  9753. parentItem= root;
  9754. }
  9755. else
  9756. {
  9757. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  9758. }
  9759. /*:759*/
  9760. #line 15867 "./typica.w"
  9761. QDomNode parentNode= parentItem->node();
  9762. QDomNodeList childNodes= parentNode.childNodes();
  9763. if(childNodes.size()<row+count)
  9764. {
  9765. return false;
  9766. }
  9767. beginRemoveRows(parent,row,row+count-1);
  9768. QList<QDomElement> removalList;
  9769. for(int i= row;i<row+count;i++)
  9770. {
  9771. removalList.append(childNodes.at(i).toElement());
  9772. }
  9773. QDomElement element;
  9774. QDomElement reference;
  9775. for(int i= 0;i<count;i++)
  9776. {
  9777. element= removalList.at(i);
  9778. if(element.hasAttribute("reference"))
  9779. {
  9780. reference= referenceElement(element.attribute("reference"));
  9781. if(!reference.isNull())
  9782. {
  9783. referenceSection.removeChild(reference);
  9784. }
  9785. }
  9786. parentNode.removeChild(element);
  9787. }
  9788. endRemoveRows();
  9789. beginResetModel();
  9790. delete root;
  9791. root= new DeviceTreeModelNode(treeRoot,0);
  9792. endResetModel();
  9793. return true;
  9794. }
  9795. /*:766*//*767:*/
  9796. #line 15906 "./typica.w"
  9797. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  9798. {
  9799. QDomNodeList childNodes= referenceSection.childNodes();
  9800. QDomElement element;
  9801. for(int i= 0;i<childNodes.size();i++)
  9802. {
  9803. element= childNodes.at(i).toElement();
  9804. if(element.hasAttribute("id"))
  9805. {
  9806. if(element.attribute("id")==id)
  9807. {
  9808. return element;
  9809. }
  9810. }
  9811. }
  9812. return QDomElement();
  9813. }
  9814. /*:767*//*768:*/
  9815. #line 15927 "./typica.w"
  9816. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  9817. {
  9818. return QVariant();
  9819. }
  9820. /*:768*//*769:*/
  9821. #line 15936 "./typica.w"
  9822. DeviceTreeModel::~DeviceTreeModel()
  9823. {
  9824. delete root;
  9825. }
  9826. /*:769*/
  9827. #line 585 "./typica.w"
  9828. /*796:*/
  9829. #line 16436 "./typica.w"
  9830. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  9831. DeviceTreeModel*model,const QModelIndex&index)
  9832. :QWidget(NULL),deviceModel(model),currentNode(index)
  9833. {
  9834. }
  9835. /*:796*//*797:*/
  9836. #line 16448 "./typica.w"
  9837. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  9838. const QString&value)
  9839. {
  9840. QDomElement referenceElement= deviceModel->referenceElement(
  9841. deviceModel->data(currentNode,Qt::UserRole).toString());
  9842. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9843. QDomElement node;
  9844. bool found= false;
  9845. for(int i= 0;i<configData.size();i++)
  9846. {
  9847. node= configData.at(i).toElement();
  9848. if(node.attribute("name")==name)
  9849. {
  9850. node.setAttribute("value",value);
  9851. found= true;
  9852. break;
  9853. }
  9854. }
  9855. if(!found)
  9856. {
  9857. node= AppInstance->deviceConfiguration().createElement("attribute");
  9858. node.setAttribute("name",name);
  9859. node.setAttribute("value",value);
  9860. referenceElement.appendChild(node);
  9861. }
  9862. AppInstance->saveDeviceConfiguration();
  9863. }
  9864. /*:797*//*798:*/
  9865. #line 16482 "./typica.w"
  9866. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  9867. const QString&driver)
  9868. {
  9869. deviceModel->newNode(name,driver,currentNode);
  9870. }
  9871. /*:798*/
  9872. #line 586 "./typica.w"
  9873. /*787:*/
  9874. #line 16280 "./typica.w"
  9875. DeviceConfigurationWindow::DeviceConfigurationWindow():QWidget(NULL),
  9876. view(new QTreeView),configArea(new QScrollArea)
  9877. {
  9878. QSplitter*splitter= new QSplitter;
  9879. QWidget*leftWidget= new QWidget;
  9880. leftWidget->setMinimumWidth(200);
  9881. QVBoxLayout*left= new QVBoxLayout;
  9882. view->setAnimated(true);
  9883. view->setSelectionMode(QAbstractItemView::SingleSelection);
  9884. document= AppInstance->deviceConfiguration();
  9885. model= new DeviceTreeModel;
  9886. view->setModel(model);
  9887. view->setTextElideMode(Qt::ElideNone);
  9888. view->expandAll();
  9889. view->resizeColumnToContents(0);
  9890. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  9891. QHBoxLayout*treeButtons= new QHBoxLayout;
  9892. QToolButton*addDeviceButton= new QToolButton;
  9893. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  9894. addDeviceButton->setToolTip(tr("New Roaster"));
  9895. connect(addDeviceButton,SIGNAL(clicked()),
  9896. this,SLOT(addDevice()));
  9897. QToolButton*removeNodeButton= new QToolButton;
  9898. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  9899. removeNodeButton->setToolTip(tr("Delete Selection"));
  9900. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  9901. treeButtons->addWidget(addDeviceButton);
  9902. treeButtons->addWidget(removeNodeButton);
  9903. left->addWidget(view);
  9904. left->addLayout(treeButtons);
  9905. leftWidget->setLayout(left);
  9906. splitter->addWidget(leftWidget);
  9907. configArea->setMinimumWidth(580);
  9908. configArea->setMinimumHeight(460);
  9909. configArea->setWidgetResizable(true);
  9910. splitter->addWidget(configArea);
  9911. QVBoxLayout*centralLayout= new QVBoxLayout;
  9912. centralLayout->addWidget(splitter);
  9913. setLayout(centralLayout);
  9914. connect(view,SIGNAL(activated(QModelIndex)),
  9915. this,SLOT(newSelection(QModelIndex)));
  9916. connect(view,SIGNAL(clicked(QModelIndex)),
  9917. this,SLOT(newSelection(QModelIndex)));
  9918. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9919. view,SLOT(expand(QModelIndex)));
  9920. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  9921. this,SLOT(resizeColumn()));
  9922. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  9923. this,SLOT(resizeColumn()));
  9924. }
  9925. /*:787*//*788:*/
  9926. #line 16335 "./typica.w"
  9927. void DeviceConfigurationWindow::addDevice()
  9928. {
  9929. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  9930. }
  9931. /*:788*//*789:*/
  9932. #line 16343 "./typica.w"
  9933. void DeviceConfigurationWindow::removeNode()
  9934. {
  9935. QModelIndex index= view->currentIndex();
  9936. if(index.isValid())
  9937. {
  9938. int row= index.row();
  9939. QModelIndex parent= index.parent();
  9940. model->removeRow(row,parent);
  9941. }
  9942. }
  9943. /*:789*//*790:*/
  9944. #line 16359 "./typica.w"
  9945. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  9946. {
  9947. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  9948. if(editor)
  9949. {
  9950. configArea->setWidget(editor);
  9951. editor->show();
  9952. }
  9953. }
  9954. /*:790*//*791:*/
  9955. #line 16376 "./typica.w"
  9956. void DeviceConfigurationWindow::resizeColumn()
  9957. {
  9958. view->resizeColumnToContents(0);
  9959. }
  9960. /*:791*/
  9961. #line 587 "./typica.w"
  9962. /*811:*/
  9963. #line 16857 "./typica.w"
  9964. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  9965. const QModelIndex&index):
  9966. BasicDeviceConfigurationWidget(model,index)
  9967. {
  9968. QFormLayout*layout= new QFormLayout;
  9969. QLineEdit*columnName= new QLineEdit;
  9970. layout->addRow(tr("Column Name:"),columnName);
  9971. QComboBox*typeSelector= new QComboBox;
  9972. typeSelector->addItem("J");
  9973. typeSelector->addItem("K");
  9974. typeSelector->addItem("T");
  9975. typeSelector->addItem("B");
  9976. typeSelector->addItem("E");
  9977. typeSelector->addItem("N");
  9978. typeSelector->addItem("R");
  9979. typeSelector->addItem("S");
  9980. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  9981. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  9982. layout->addRow(hideSeries);
  9983. setLayout(layout);
  9984. /*801:*/
  9985. #line 16651 "./typica.w"
  9986. QDomElement referenceElement=
  9987. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9988. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9989. QDomElement node;
  9990. /*:801*/
  9991. #line 16878 "./typica.w"
  9992. for(int i= 0;i<configData.size();i++)
  9993. {
  9994. node= configData.at(i).toElement();
  9995. if(node.attribute("name")=="type")
  9996. {
  9997. typeSelector->setCurrentIndex(
  9998. typeSelector->findText(node.attribute("value")));
  9999. }
  10000. else if(node.attribute("name")=="columnname")
  10001. {
  10002. columnName->setText(node.attribute("value"));
  10003. }
  10004. else if(node.attribute("name")=="hidden")
  10005. {
  10006. hideSeries->setChecked(node.attribute("value")=="true");
  10007. }
  10008. }
  10009. updateThermocoupleType(typeSelector->currentText());
  10010. updateColumnName(columnName->text());
  10011. updateHidden(hideSeries->isChecked());
  10012. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  10013. this,SLOT(updateThermocoupleType(QString)));
  10014. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10015. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10016. }
  10017. /*:811*//*812:*/
  10018. #line 16908 "./typica.w"
  10019. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  10020. {
  10021. updateAttribute("type",type);
  10022. }
  10023. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  10024. {
  10025. updateAttribute("columnname",name);
  10026. }
  10027. void Ni9211TcConfWidget::updateHidden(bool hidden)
  10028. {
  10029. updateAttribute("hidden",hidden?"true":"false");
  10030. }
  10031. /*:812*/
  10032. #line 588 "./typica.w"
  10033. /*807:*/
  10034. #line 16771 "./typica.w"
  10035. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  10036. const QModelIndex&index)
  10037. :BasicDeviceConfigurationWidget(model,index)
  10038. {
  10039. QVBoxLayout*layout= new QVBoxLayout;
  10040. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10041. QLabel*label= new QLabel(tr("Device ID:"));
  10042. QLineEdit*deviceId= new QLineEdit;
  10043. deviceIdLayout->addWidget(label);
  10044. deviceIdLayout->addWidget(deviceId);
  10045. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10046. layout->addLayout(deviceIdLayout);
  10047. layout->addWidget(addChannelButton);
  10048. /*801:*/
  10049. #line 16651 "./typica.w"
  10050. QDomElement referenceElement=
  10051. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10052. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10053. QDomElement node;
  10054. /*:801*/
  10055. #line 16785 "./typica.w"
  10056. for(int i= 0;i<configData.size();i++)
  10057. {
  10058. node= configData.at(i).toElement();
  10059. if(node.attribute("name")=="deviceID")
  10060. {
  10061. deviceId->setText(node.attribute("value","Dev1"));
  10062. break;
  10063. }
  10064. }
  10065. updateDeviceId(deviceId->text());
  10066. connect(addChannelButton,SIGNAL(clicked()),
  10067. this,SLOT(addChannel()));
  10068. connect(deviceId,SIGNAL(textEdited(QString)),
  10069. this,SLOT(updateDeviceId(QString)));
  10070. setLayout(layout);
  10071. }
  10072. /*:807*//*808:*/
  10073. #line 16807 "./typica.w"
  10074. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  10075. {
  10076. updateAttribute("deviceID",newId);
  10077. }
  10078. /*:808*//*809:*/
  10079. #line 16815 "./typica.w"
  10080. void NiDaqMxBase9211ConfWidget::addChannel()
  10081. {
  10082. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10083. }
  10084. /*:809*/
  10085. #line 589 "./typica.w"
  10086. /*805:*/
  10087. #line 16722 "./typica.w"
  10088. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  10089. DeviceTreeModel*model,const QModelIndex&index):
  10090. BasicDeviceConfigurationWidget(model,index)
  10091. {
  10092. QHBoxLayout*layout= new QHBoxLayout;
  10093. QToolButton*addDeviceButton= new QToolButton;
  10094. addDeviceButton->setText(tr("Add Device"));
  10095. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  10096. "nidaqmxbase9211series");
  10097. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10098. "nidaqmxbase9211series");
  10099. connect(add9211,SIGNAL(triggered(QString,QString)),
  10100. this,SLOT(insertChildNode(QString,QString)));
  10101. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10102. this,SLOT(insertChildNode(QString,QString)));
  10103. QMenu*deviceMenu= new QMenu;
  10104. deviceMenu->addAction(add9211);
  10105. deviceMenu->addAction(add9211a);
  10106. addDeviceButton->setMenu(deviceMenu);
  10107. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10108. layout->addWidget(addDeviceButton);
  10109. setLayout(layout);
  10110. }
  10111. /*:805*/
  10112. #line 590 "./typica.w"
  10113. /*666:*/
  10114. #line 14194 "./typica.w"
  10115. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  10116. QObject*parent):
  10117. QAction(reportName,parent),reportFile(fileName)
  10118. {
  10119. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  10120. }
  10121. /*:666*//*667:*/
  10122. #line 14210 "./typica.w"
  10123. void ReportAction::createReport()
  10124. {
  10125. QFile file(reportFile);
  10126. QDomDocument document;
  10127. if(file.open(QIODevice::ReadOnly))
  10128. {
  10129. document.setContent(&file,true);
  10130. QDomElement element= document.documentElement();
  10131. QScriptEngine*engine= AppInstance->engine;
  10132. QScriptContext*context= engine->pushContext();
  10133. QScriptValue object;
  10134. QString targetID= reportFile;
  10135. /*202:*/
  10136. #line 4747 "./typica.w"
  10137. ScriptQMainWindow*window= new ScriptQMainWindow;
  10138. window->setObjectName(targetID);
  10139. object= engine->newQObject(window);
  10140. setQMainWindowProperties(object,engine);
  10141. QWidget*central= new(QWidget);
  10142. central->setParent(window);
  10143. central->setObjectName("centralWidget");
  10144. window->setCentralWidget(central);
  10145. if(element.hasChildNodes())
  10146. {
  10147. /*203:*/
  10148. #line 4783 "./typica.w"
  10149. QStack<QWidget*> widgetStack;
  10150. QStack<QLayout*> layoutStack;
  10151. QString windowScript;
  10152. widgetStack.push(central);
  10153. QDomNodeList windowChildren= element.childNodes();
  10154. int i= 0;
  10155. while(i<windowChildren.count())
  10156. {
  10157. QDomNode current;
  10158. QDomElement element;
  10159. current= windowChildren.at(i);
  10160. if(current.isElement())
  10161. {
  10162. element= current.toElement();
  10163. if(element.tagName()=="program")
  10164. {
  10165. windowScript.append(element.text());
  10166. }
  10167. else if(element.tagName()=="layout")
  10168. {
  10169. element.setAttribute("trcontext","configuration");
  10170. addLayoutToWidget(element,&widgetStack,&layoutStack);
  10171. }
  10172. else if(element.tagName()=="menu")
  10173. {
  10174. /*204:*/
  10175. #line 4831 "./typica.w"
  10176. QMenuBar*bar= window->menuBar();
  10177. bar->setParent(window);
  10178. bar->setObjectName("menuBar");
  10179. if(element.hasAttribute("name"))
  10180. {
  10181. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  10182. element.attribute("name").toUtf8().data()));
  10183. menu->setParent(bar);
  10184. if(element.hasAttribute("type"))
  10185. {
  10186. if(element.attribute("type")=="reports")
  10187. {
  10188. if(element.hasAttribute("src"))
  10189. {
  10190. /*664:*/
  10191. #line 14154 "./typica.w"
  10192. QSettings settings;
  10193. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  10194. toString()).
  10195. arg(element.attribute("src"));
  10196. QDir::addSearchPath("reports",reportDirectory);
  10197. QDir directory(reportDirectory);
  10198. directory.setFilter(QDir::Files);
  10199. directory.setSorting(QDir::Name);
  10200. QStringList nameFilter;
  10201. nameFilter<<"*.xml";
  10202. directory.setNameFilters(nameFilter);
  10203. QFileInfoList reportFiles= directory.entryInfoList();
  10204. for(int i= 0;i<reportFiles.size();i++)
  10205. {
  10206. QFileInfo reportFile= reportFiles.at(i);
  10207. /*668:*/
  10208. #line 14234 "./typica.w"
  10209. QString path= reportFile.absoluteFilePath();
  10210. QFile file(path);
  10211. if(file.open(QIODevice::ReadOnly))
  10212. {
  10213. QDomDocument document;
  10214. document.setContent(&file,true);
  10215. QDomElement root= document.documentElement();
  10216. QString translationContext= root.attribute("id");
  10217. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  10218. if(!titleNode.isNull())
  10219. {
  10220. QDomElement titleElement= titleNode.toElement();
  10221. QString title= QCoreApplication::translate("configuration",
  10222. titleElement.text().toUtf8().data());
  10223. if(!title.isEmpty())
  10224. {
  10225. QStringList hierarchy= title.split(":->");
  10226. QMenu*insertionPoint= menu;
  10227. /*669:*/
  10228. #line 14263 "./typica.w"
  10229. for(int j= 0;j<hierarchy.size()-1;j++)
  10230. {
  10231. QObjectList menuList= insertionPoint->children();
  10232. bool menuFound= false;
  10233. for(int k= 0;k<menuList.size();k++)
  10234. {
  10235. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  10236. if(currentItem)
  10237. {
  10238. if(currentItem->title()==hierarchy.at(j))
  10239. {
  10240. menuFound= true;
  10241. insertionPoint= currentItem;
  10242. break;
  10243. }
  10244. }
  10245. }
  10246. if(!menuFound)
  10247. {
  10248. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  10249. }
  10250. }
  10251. /*:669*/
  10252. #line 14253 "./typica.w"
  10253. ReportAction*action= new ReportAction(path,hierarchy.last());
  10254. insertionPoint->addAction(action);
  10255. }
  10256. }
  10257. }
  10258. /*:668*/
  10259. #line 14170 "./typica.w"
  10260. }
  10261. /*:664*/
  10262. #line 4846 "./typica.w"
  10263. }
  10264. }
  10265. }
  10266. if(element.hasChildNodes())
  10267. {
  10268. /*205:*/
  10269. #line 4859 "./typica.w"
  10270. QDomNodeList menuItems= element.childNodes();
  10271. int j= 0;
  10272. while(j<menuItems.count())
  10273. {
  10274. QDomNode item= menuItems.at(j);
  10275. if(item.isElement())
  10276. {
  10277. QDomElement itemElement= item.toElement();
  10278. if(itemElement.tagName()=="item")
  10279. {
  10280. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  10281. itemElement.text().toUtf8().data()),menu);
  10282. if(itemElement.hasAttribute("id"))
  10283. {
  10284. itemAction->setObjectName(itemElement.attribute("id"));
  10285. }
  10286. if(itemElement.hasAttribute("shortcut"))
  10287. {
  10288. itemAction->setShortcut(itemElement.attribute("shortcut"));
  10289. }
  10290. menu->addAction(itemAction);
  10291. }
  10292. else if(itemElement.tagName()=="separator")
  10293. {
  10294. menu->addSeparator();
  10295. }
  10296. else if(itemElement.tagName()=="plugins")
  10297. {
  10298. /*689:*/
  10299. #line 21 "./plugins.w"
  10300. QMenu*pluginMenu= new QMenu(menu);
  10301. if(itemElement.hasAttribute("id"))
  10302. {
  10303. pluginMenu->setObjectName(itemElement.attribute("id"));
  10304. }
  10305. if(itemElement.hasAttribute("title"))
  10306. {
  10307. pluginMenu->setTitle(itemElement.attribute("title"));
  10308. }
  10309. if(itemElement.hasAttribute("src"))
  10310. {
  10311. QSettings settings;
  10312. QString pluginDirectory= QString("%1/%2").
  10313. arg(settings.value("config").toString()).
  10314. arg(itemElement.attribute("src"));
  10315. QDir directory(pluginDirectory);
  10316. directory.setFilter(QDir::Files);
  10317. directory.setSorting(QDir::Name);
  10318. QStringList nameFilter;
  10319. nameFilter<<"*.js";
  10320. directory.setNameFilters(nameFilter);
  10321. QFileInfoList pluginFiles= directory.entryInfoList();
  10322. for(int k= 0;k<pluginFiles.size();k++)
  10323. {
  10324. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  10325. if(itemElement.hasAttribute("preRun"))
  10326. {
  10327. pa->setPreRun(itemElement.attribute("preRun"));
  10328. }
  10329. if(itemElement.hasAttribute("postRun"))
  10330. {
  10331. pa->setPostRun(itemElement.attribute("postRun"));
  10332. }
  10333. pluginMenu->addAction(pa);
  10334. }
  10335. }
  10336. menu->addMenu(pluginMenu);
  10337. /*:689*/
  10338. #line 4888 "./typica.w"
  10339. }
  10340. }
  10341. j++;
  10342. }
  10343. #line 1 "./helpmenu.w"
  10344. /*:205*/
  10345. #line 4852 "./typica.w"
  10346. }
  10347. }
  10348. /*:204*/
  10349. #line 4809 "./typica.w"
  10350. }
  10351. }
  10352. i++;
  10353. }
  10354. QScriptValue oldThis= context->thisObject();
  10355. context->setThisObject(object);
  10356. QScriptValue result= engine->evaluate(windowScript);
  10357. /*196:*/
  10358. #line 4562 "./typica.w"
  10359. if(engine->hasUncaughtException())
  10360. {
  10361. int line= engine->uncaughtExceptionLineNumber();
  10362. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  10363. result.toString();
  10364. QString trace;
  10365. foreach(trace,engine->uncaughtExceptionBacktrace())
  10366. {
  10367. qDebug()<<trace;
  10368. }
  10369. }
  10370. /*:196*/
  10371. #line 4817 "./typica.w"
  10372. context->setThisObject(oldThis);
  10373. /*:203*/
  10374. #line 4758 "./typica.w"
  10375. }
  10376. /*206:*/
  10377. #line 9 "./helpmenu.w"
  10378. HelpMenu*helpMenu= new HelpMenu();
  10379. window->menuBar()->addMenu(helpMenu);
  10380. /*:206*/
  10381. #line 4760 "./typica.w"
  10382. window->show();
  10383. window->setupFinished();
  10384. /*:202*/
  10385. #line 14223 "./typica.w"
  10386. file.close();
  10387. engine->popContext();
  10388. }
  10389. }
  10390. /*:667*/
  10391. #line 591 "./typica.w"
  10392. /*251:*/
  10393. #line 6040 "./typica.w"
  10394. NumericDelegate::NumericDelegate(QObject*parent):
  10395. QItemDelegate(parent)
  10396. {
  10397. }
  10398. /*:251*//*252:*/
  10399. #line 6052 "./typica.w"
  10400. void NumericDelegate::setEditorData(QWidget*editor,
  10401. const QModelIndex&index)const
  10402. {
  10403. QString value= index.model()->data(index,Qt::EditRole).toString();
  10404. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10405. line->setText(value);
  10406. }
  10407. /*:252*//*253:*/
  10408. #line 6067 "./typica.w"
  10409. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  10410. const QModelIndex&index)const
  10411. {
  10412. QLineEdit*line= static_cast<QLineEdit*> (editor);
  10413. model->setData(index,line->text(),Qt::EditRole);
  10414. QScriptEngine*engine= AppInstance->engine;
  10415. engine->pushContext();
  10416. QString script= QString("Number(%1)").arg(line->text());
  10417. QScriptValue result= engine->evaluate(line->text());
  10418. if(result.isNumber())
  10419. {
  10420. model->setData(index,result.toVariant(),Qt::DisplayRole);
  10421. }
  10422. else
  10423. {
  10424. model->setData(index,QVariant(),Qt::DisplayRole);
  10425. }
  10426. engine->popContext();
  10427. }
  10428. /*:253*//*254:*/
  10429. #line 6090 "./typica.w"
  10430. QWidget*NumericDelegate::createEditor(QWidget*parent,
  10431. const QStyleOptionViewItem&,
  10432. const QModelIndex&)const
  10433. {
  10434. return(new QLineEdit(parent));
  10435. }
  10436. /*:254*//*255:*/
  10437. #line 6101 "./typica.w"
  10438. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  10439. const QStyleOptionViewItem&option,
  10440. const QModelIndex&)const
  10441. {
  10442. editor->setGeometry(option.rect);
  10443. }
  10444. /*:255*/
  10445. #line 592 "./typica.w"
  10446. /*816:*/
  10447. #line 16967 "./typica.w"
  10448. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  10449. const QModelIndex&index)
  10450. :BasicDeviceConfigurationWidget(model,index)
  10451. {
  10452. QHBoxLayout*layout= new QHBoxLayout;
  10453. QToolButton*addDeviceButton= new QToolButton;
  10454. addDeviceButton->setText(tr("Add Device"));
  10455. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  10456. "nidaqmx9211series");
  10457. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  10458. "nidaqmxtc01");
  10459. connect(add9211a,SIGNAL(triggered(QString,QString)),
  10460. this,SLOT(insertChildNode(QString,QString)));
  10461. connect(addtc01,SIGNAL(triggered(QString,QString)),
  10462. this,SLOT(insertChildNode(QString,QString)));
  10463. QMenu*deviceMenu= new QMenu;
  10464. deviceMenu->addAction(add9211a);
  10465. deviceMenu->addAction(addtc01);
  10466. addDeviceButton->setMenu(deviceMenu);
  10467. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10468. layout->addWidget(addDeviceButton);
  10469. setLayout(layout);
  10470. }
  10471. /*:816*/
  10472. #line 593 "./typica.w"
  10473. /*818:*/
  10474. #line 17016 "./typica.w"
  10475. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  10476. const QModelIndex&index)
  10477. :BasicDeviceConfigurationWidget(model,index)
  10478. {
  10479. QVBoxLayout*layout= new QVBoxLayout;
  10480. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  10481. QLabel*label= new QLabel(tr("Device ID:"));
  10482. QLineEdit*deviceId= new QLineEdit;
  10483. deviceIdLayout->addWidget(label);
  10484. deviceIdLayout->addWidget(deviceId);
  10485. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  10486. layout->addLayout(deviceIdLayout);
  10487. layout->addWidget(addChannelButton);
  10488. /*801:*/
  10489. #line 16651 "./typica.w"
  10490. QDomElement referenceElement=
  10491. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10492. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10493. QDomElement node;
  10494. /*:801*/
  10495. #line 17030 "./typica.w"
  10496. for(int i= 0;i<configData.size();i++)
  10497. {
  10498. node= configData.at(i).toElement();
  10499. if(node.attribute("name")=="deviceID")
  10500. {
  10501. deviceId->setText(node.attribute("value","Dev1"));
  10502. break;
  10503. }
  10504. }
  10505. updateDeviceId(deviceId->text());
  10506. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  10507. connect(deviceId,SIGNAL(textEdited(QString)),
  10508. this,SLOT(updateDeviceId(QString)));
  10509. setLayout(layout);
  10510. }
  10511. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  10512. {
  10513. updateAttribute("deviceID",newId);
  10514. }
  10515. void NiDaqMx9211ConfWidget::addChannel()
  10516. {
  10517. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  10518. }
  10519. /*:818*/
  10520. #line 594 "./typica.w"
  10521. /*820:*/
  10522. #line 17081 "./typica.w"
  10523. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  10524. const QModelIndex&index)
  10525. :BasicDeviceConfigurationWidget(model,index)
  10526. {
  10527. QFormLayout*layout= new QFormLayout;
  10528. QLineEdit*deviceId= new QLineEdit;
  10529. layout->addRow(tr("Device ID:"),deviceId);
  10530. QLineEdit*columnName= new QLineEdit;
  10531. layout->addRow(tr("Column Name:"),columnName);
  10532. QComboBox*typeSelector= new QComboBox;
  10533. typeSelector->addItem("J");
  10534. typeSelector->addItem("K");
  10535. typeSelector->addItem("T");
  10536. typeSelector->addItem("B");
  10537. typeSelector->addItem("E");
  10538. typeSelector->addItem("N");
  10539. typeSelector->addItem("R");
  10540. typeSelector->addItem("S");
  10541. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  10542. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  10543. layout->addRow(hideSeries);
  10544. /*801:*/
  10545. #line 16651 "./typica.w"
  10546. QDomElement referenceElement=
  10547. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10548. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10549. QDomElement node;
  10550. /*:801*/
  10551. #line 17103 "./typica.w"
  10552. for(int i= 0;i<configData.size();i++)
  10553. {
  10554. node= configData.at(i).toElement();
  10555. if(node.attribute("name")=="deviceID")
  10556. {
  10557. deviceId->setText(node.attribute("value"));
  10558. }
  10559. else if(node.attribute("name")=="type")
  10560. {
  10561. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  10562. }
  10563. else if(node.attribute("name")=="columnname")
  10564. {
  10565. columnName->setText(node.attribute("value"));
  10566. }
  10567. else if(node.attribute("name")=="hidden")
  10568. {
  10569. hideSeries->setChecked(node.attribute("value")=="true");
  10570. }
  10571. }
  10572. updateDeviceId(deviceId->text());
  10573. updateThermocoupleType(typeSelector->currentText());
  10574. updateColumnName(columnName->text());
  10575. updateHidden(hideSeries->isChecked());
  10576. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  10577. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  10578. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  10579. setLayout(layout);
  10580. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  10581. }
  10582. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  10583. {
  10584. updateAttribute("deviceID",newId);
  10585. }
  10586. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  10587. {
  10588. updateAttribute("type",type);
  10589. }
  10590. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  10591. {
  10592. updateAttribute("columnname",name);
  10593. }
  10594. void NiDaqMxTc01ConfWidget::updateHidden(bool hidden)
  10595. {
  10596. updateAttribute("hidden",hidden?"true":"false");
  10597. }
  10598. /*:820*/
  10599. #line 595 "./typica.w"
  10600. /*838:*/
  10601. #line 17523 "./typica.w"
  10602. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  10603. const QModelIndex&index)
  10604. :BasicDeviceConfigurationWidget(model,index)
  10605. {
  10606. QFormLayout*layout= new QFormLayout;
  10607. QToolButton*addDeviceButton= new QToolButton;
  10608. addDeviceButton->setText(tr("Add Device"));
  10609. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  10610. "Modbus RTU Device",
  10611. "modbusrtudevice");
  10612. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  10613. this,SLOT(insertChildNode(QString,QString)));
  10614. QMenu*deviceMenu= new QMenu;
  10615. deviceMenu->addAction(addModbusRtuDevice);
  10616. addDeviceButton->setMenu(deviceMenu);
  10617. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  10618. layout->addRow(QString(),addDeviceButton);
  10619. PortSelector*port= new PortSelector;
  10620. layout->addRow(tr("Port:"),port);
  10621. connect(port,SIGNAL(currentIndexChanged(QString)),
  10622. this,SLOT(updatePort(QString)));
  10623. connect(port,SIGNAL(editTextChanged(QString)),
  10624. this,SLOT(updatePort(QString)));
  10625. BaudSelector*rate= new BaudSelector;
  10626. layout->addRow(tr("Baud:"),rate);
  10627. connect(rate,SIGNAL(currentIndexChanged(QString)),
  10628. this,SLOT(updateBaudRate(QString)));
  10629. ParitySelector*parity= new ParitySelector;
  10630. layout->addRow(tr("Parity:"),parity);
  10631. connect(parity,SIGNAL(currentIndexChanged(QString)),
  10632. this,SLOT(updateParity(QString)));
  10633. FlowSelector*flow= new FlowSelector;
  10634. layout->addRow(tr("Flow Control:"),flow);
  10635. connect(flow,SIGNAL(currentIndexChanged(QString)),
  10636. this,SLOT(updateFlowControl(QString)));
  10637. StopSelector*stop= new StopSelector;
  10638. layout->addRow(tr("Stop Bits:"),stop);
  10639. connect(stop,SIGNAL(currentIndexChanged(QString)),
  10640. this,SLOT(updateStopBits(QString)));
  10641. /*801:*/
  10642. #line 16651 "./typica.w"
  10643. QDomElement referenceElement=
  10644. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10645. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10646. QDomElement node;
  10647. /*:801*/
  10648. #line 17563 "./typica.w"
  10649. for(int i= 0;i<configData.size();i++)
  10650. {
  10651. node= configData.at(i).toElement();
  10652. if(node.attribute("name")=="port")
  10653. {
  10654. int j= port->findText(node.attribute("value"));
  10655. if(j>=0)
  10656. {
  10657. port->setCurrentIndex(j);
  10658. }
  10659. else
  10660. {
  10661. port->insertItem(0,node.attribute("value"));
  10662. port->setCurrentIndex(0);
  10663. }
  10664. }
  10665. else if(node.attribute("name")=="baudrate")
  10666. {
  10667. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  10668. }
  10669. else if(node.attribute("name")=="parity")
  10670. {
  10671. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  10672. }
  10673. else if(node.attribute("name")=="flowcontrol")
  10674. {
  10675. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  10676. }
  10677. else if(node.attribute("name")=="stopbits")
  10678. {
  10679. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  10680. }
  10681. }
  10682. updatePort(port->currentText());
  10683. updateBaudRate(rate->currentText());
  10684. updateParity(parity->currentText());
  10685. updateFlowControl(flow->currentText());
  10686. updateStopBits(stop->currentText());
  10687. setLayout(layout);
  10688. }
  10689. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  10690. {
  10691. updateAttribute("port",newPort);
  10692. }
  10693. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  10694. {
  10695. updateAttribute("baudrate",newRate);
  10696. }
  10697. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  10698. {
  10699. updateAttribute("parity",newParity);
  10700. }
  10701. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  10702. {
  10703. updateAttribute("flowcontrol",newFlow);
  10704. }
  10705. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  10706. {
  10707. updateAttribute("stopbits",newStopBits);
  10708. }
  10709. /*:838*/
  10710. #line 596 "./typica.w"
  10711. /*840:*/
  10712. #line 17686 "./typica.w"
  10713. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  10714. const QModelIndex&index)
  10715. :BasicDeviceConfigurationWidget(model,index),
  10716. unitSpecificationLayout(new QStackedLayout),
  10717. decimalSpecificationLayout(new QStackedLayout)
  10718. {
  10719. QVBoxLayout*layout= new QVBoxLayout;
  10720. QToolButton*addChannelButton= new QToolButton;
  10721. addChannelButton->setText(tr("Add Channel"));
  10722. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  10723. "Temperature Process Value",
  10724. "modbustemperaturepv");
  10725. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  10726. "Temperature Set Value",
  10727. "modbustemperaturesv");
  10728. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  10729. this,SLOT(insertChildNode(QString,QString)));
  10730. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  10731. this,SLOT(insertChildNode(QString,QString)));
  10732. QMenu*channelMenu= new QMenu;
  10733. channelMenu->addAction(addTemperaturePV);
  10734. channelMenu->addAction(addTemperatureSV);
  10735. addChannelButton->setMenu(channelMenu);
  10736. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  10737. layout->addWidget(addChannelButton);
  10738. QHBoxLayout*stationLayout= new QHBoxLayout;
  10739. QLabel*stationLabel= new QLabel(tr("Station:"));
  10740. QSpinBox*stationNumber= new QSpinBox;
  10741. stationNumber->setMinimum(0);
  10742. stationNumber->setMaximum(255);
  10743. stationLayout->addWidget(stationLabel);
  10744. stationLayout->addWidget(stationNumber);
  10745. layout->addLayout(stationLayout);
  10746. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  10747. layout->addWidget(fixedUnit);
  10748. QWidget*fixedUnitPlaceholder= new QWidget(this);
  10749. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  10750. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  10751. QComboBox*fixedUnitSelector= new QComboBox;
  10752. fixedUnitSelector->addItem("Fahrenheit");
  10753. fixedUnitSelector->addItem("Celsius");
  10754. fixedUnitLayout->addWidget(fixedUnitLabel);
  10755. fixedUnitLayout->addWidget(fixedUnitSelector);
  10756. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  10757. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  10758. QWidget*queriedUnitPlaceholder= new QWidget(this);
  10759. QFormLayout*queriedUnitLayout= new QFormLayout;
  10760. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  10761. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  10762. QSpinBox*valueF= new QSpinBox;
  10763. valueF->setMinimum(0);
  10764. valueF->setMaximum(65535);
  10765. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  10766. QSpinBox*valueC= new QSpinBox;
  10767. valueC->setMinimum(0);
  10768. valueC->setMaximum(65535);
  10769. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  10770. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  10771. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  10772. layout->addLayout(unitSpecificationLayout);
  10773. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  10774. layout->addWidget(fixedPrecision);
  10775. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  10776. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  10777. QSpinBox*fixedPrecisionValue= new QSpinBox;
  10778. fixedPrecisionValue->setMinimum(0);
  10779. fixedPrecisionValue->setMaximum(9);
  10780. fixedPrecisionLayout->addRow("Places after the decimal point:",
  10781. fixedPrecisionValue);
  10782. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  10783. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  10784. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  10785. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  10786. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  10787. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  10788. precisionAddress);
  10789. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  10790. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  10791. layout->addLayout(decimalSpecificationLayout);
  10792. /*801:*/
  10793. #line 16651 "./typica.w"
  10794. QDomElement referenceElement=
  10795. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10796. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10797. QDomElement node;
  10798. /*:801*/
  10799. #line 17766 "./typica.w"
  10800. for(int i= 0;i<configData.size();i++)
  10801. {
  10802. node= configData.at(i).toElement();
  10803. if(node.attribute("name")=="station")
  10804. {
  10805. stationNumber->setValue(node.attribute("value").toInt());
  10806. }
  10807. else if(node.attribute("name")=="fixedunit")
  10808. {
  10809. if(node.attribute("value")=="true")
  10810. {
  10811. fixedUnit->setCheckState(Qt::Checked);
  10812. }
  10813. else if(node.attribute("value")=="false")
  10814. {
  10815. fixedUnit->setCheckState(Qt::Unchecked);
  10816. }
  10817. }
  10818. else if(node.attribute("name")=="fixedprecision")
  10819. {
  10820. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10821. }
  10822. else if(node.attribute("name")=="unit")
  10823. {
  10824. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  10825. }
  10826. else if(node.attribute("name")=="unitaddress")
  10827. {
  10828. unitAddress->setValue(node.attribute("value").toInt());
  10829. }
  10830. else if(node.attribute("name")=="fvalue")
  10831. {
  10832. valueF->setValue(node.attribute("value").toInt());
  10833. }
  10834. else if(node.attribute("name")=="cvalue")
  10835. {
  10836. valueC->setValue(node.attribute("value").toInt());
  10837. }
  10838. else if(node.attribute("name")=="precisionaddress")
  10839. {
  10840. precisionAddress->setValue(node.attribute("value").toInt());
  10841. }
  10842. else if(node.attribute("name")=="precision")
  10843. {
  10844. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  10845. }
  10846. }
  10847. updateStationNumber(stationNumber->value());
  10848. updateFixedUnit(fixedUnit->isChecked());
  10849. updateFixedDecimal(fixedPrecision->isChecked());
  10850. updateUnit(fixedUnitSelector->currentText());
  10851. updateUnitAddress(unitAddress->value());
  10852. updateValueF(valueF->value());
  10853. updateValueC(valueC->value());
  10854. updatePrecisionAddress(precisionAddress->value());
  10855. updatePrecisionValue(fixedPrecisionValue->value());
  10856. connect(stationNumber,SIGNAL(valueChanged(int)),
  10857. this,SLOT(updateStationNumber(int)));
  10858. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  10859. this,SLOT(updateUnit(QString)));
  10860. connect(unitAddress,SIGNAL(valueChanged(int)),
  10861. this,SLOT(updateUnitAddress(int)));
  10862. connect(valueF,SIGNAL(valueChanged(int)),
  10863. this,SLOT(updateValueF(int)));
  10864. connect(valueC,SIGNAL(valueChanged(int)),
  10865. this,SLOT(updateValueC(int)));
  10866. connect(fixedUnit,SIGNAL(toggled(bool)),
  10867. this,SLOT(updateFixedUnit(bool)));
  10868. connect(fixedPrecision,SIGNAL(toggled(bool)),
  10869. this,SLOT(updateFixedDecimal(bool)));
  10870. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  10871. this,SLOT(updatePrecisionValue(int)));
  10872. connect(precisionAddress,SIGNAL(valueChanged(int)),
  10873. this,SLOT(updatePrecisionAddress(int)));
  10874. setLayout(layout);
  10875. }
  10876. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  10877. {
  10878. updateAttribute("station",QString("%1").arg(newStation));
  10879. }
  10880. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  10881. {
  10882. if(newFixed)
  10883. {
  10884. unitSpecificationLayout->setCurrentIndex(0);
  10885. updateAttribute("fixedunit","true");
  10886. }
  10887. else
  10888. {
  10889. unitSpecificationLayout->setCurrentIndex(1);
  10890. updateAttribute("fixedunit","false");
  10891. }
  10892. }
  10893. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  10894. {
  10895. if(newFixed)
  10896. {
  10897. decimalSpecificationLayout->setCurrentIndex(0);
  10898. updateAttribute("fixedprecision","true");
  10899. }
  10900. else
  10901. {
  10902. decimalSpecificationLayout->setCurrentIndex(1);
  10903. updateAttribute("fixedprecision","false");
  10904. }
  10905. }
  10906. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  10907. {
  10908. updateAttribute("unit",newUnit);
  10909. }
  10910. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  10911. {
  10912. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  10913. }
  10914. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  10915. {
  10916. updateAttribute("fvalue",QString("%1").arg(newValue));
  10917. }
  10918. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  10919. {
  10920. updateAttribute("cvalue",QString("%1").arg(newValue));
  10921. }
  10922. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  10923. {
  10924. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  10925. }
  10926. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  10927. {
  10928. updateAttribute("precision",QString("%1").arg(newValue));
  10929. }
  10930. /*:840*/
  10931. #line 597 "./typica.w"
  10932. /*842:*/
  10933. #line 17929 "./typica.w"
  10934. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  10935. const QModelIndex&index)
  10936. :BasicDeviceConfigurationWidget(model,index)
  10937. {
  10938. QFormLayout*layout= new QFormLayout;
  10939. ShortHexSpinBox*address= new ShortHexSpinBox;
  10940. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  10941. /*801:*/
  10942. #line 16651 "./typica.w"
  10943. QDomElement referenceElement=
  10944. model->referenceElement(model->data(index,Qt::UserRole).toString());
  10945. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  10946. QDomElement node;
  10947. /*:801*/
  10948. #line 17937 "./typica.w"
  10949. for(int i= 0;i<configData.size();i++)
  10950. {
  10951. node= configData.at(i).toElement();
  10952. if(node.attribute("name")=="address")
  10953. {
  10954. address->setValue(node.attribute("value").toInt());
  10955. break;
  10956. }
  10957. }
  10958. updateAddress(address->value());
  10959. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  10960. setLayout(layout);
  10961. }
  10962. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  10963. {
  10964. updateAttribute("address",QString("%1").arg(newAddress));
  10965. }
  10966. /*:842*/
  10967. #line 598 "./typica.w"
  10968. /*844:*/
  10969. #line 17985 "./typica.w"
  10970. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  10971. const QModelIndex&index)
  10972. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  10973. {
  10974. QVBoxLayout*layout= new QVBoxLayout;
  10975. QFormLayout*addressLayout= new QFormLayout;
  10976. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  10977. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  10978. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  10979. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  10980. layout->addLayout(addressLayout);
  10981. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  10982. layout->addWidget(fixedRange);
  10983. QWidget*queriedRangePlaceholder= new QWidget(this);
  10984. QFormLayout*queriedRangeLayout= new QFormLayout;
  10985. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  10986. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  10987. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  10988. lowerAddress);
  10989. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  10990. upperAddress);
  10991. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  10992. boundsLayout->addWidget(queriedRangePlaceholder);
  10993. QWidget*fixedRangePlaceholder= new QWidget(this);
  10994. QFormLayout*fixedRangeLayout= new QFormLayout;
  10995. QLineEdit*fixedLower= new QLineEdit;
  10996. QLineEdit*fixedUpper= new QLineEdit;
  10997. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  10998. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  10999. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  11000. boundsLayout->addWidget(fixedRangePlaceholder);
  11001. layout->addLayout(boundsLayout);
  11002. /*801:*/
  11003. #line 16651 "./typica.w"
  11004. QDomElement referenceElement=
  11005. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11006. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11007. QDomElement node;
  11008. /*:801*/
  11009. #line 18018 "./typica.w"
  11010. for(int i= 0;i<configData.size();i++)
  11011. {
  11012. node= configData.at(i).toElement();
  11013. if(node.attribute("name")=="readaddress")
  11014. {
  11015. readAddress->setValue(node.attribute("value").toInt());
  11016. }
  11017. else if(node.attribute("name")=="writeaddress")
  11018. {
  11019. writeAddress->setValue(node.attribute("value").toInt());
  11020. }
  11021. else if(node.attribute("name")=="fixedrange")
  11022. {
  11023. if(node.attribute("value")=="true")
  11024. {
  11025. fixedRange->setCheckState(Qt::Checked);
  11026. }
  11027. else if(node.attribute("value")=="false")
  11028. {
  11029. fixedRange->setCheckState(Qt::Unchecked);
  11030. }
  11031. }
  11032. else if(node.attribute("name")=="fixedlower")
  11033. {
  11034. fixedLower->setText(node.attribute("value"));
  11035. }
  11036. else if(node.attribute("name")=="fixedupper")
  11037. {
  11038. fixedUpper->setText(node.attribute("value"));
  11039. }
  11040. else if(node.attribute("name")=="loweraddress")
  11041. {
  11042. lowerAddress->setValue(node.attribute("value").toInt());
  11043. }
  11044. else if(node.attribute("name")=="upperaddress")
  11045. {
  11046. upperAddress->setValue(node.attribute("value").toInt());
  11047. }
  11048. }
  11049. updateReadAddress(readAddress->value());
  11050. updateWriteAddress(writeAddress->value());
  11051. updateFixedRange(fixedRange->isChecked());
  11052. updateLower(fixedLower->text());
  11053. updateUpper(fixedUpper->text());
  11054. updateLowerAddress(lowerAddress->value());
  11055. updateUpperAddress(upperAddress->value());
  11056. connect(readAddress,SIGNAL(valueChanged(int)),
  11057. this,SLOT(updateReadAddress(int)));
  11058. connect(writeAddress,SIGNAL(valueChanged(int)),
  11059. this,SLOT(updateWriteAddress(int)));
  11060. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  11061. connect(fixedLower,SIGNAL(textChanged(QString)),
  11062. this,SLOT(updateLower(QString)));
  11063. connect(fixedUpper,SIGNAL(textChanged(QString)),
  11064. this,SLOT(updateUpper(QString)));
  11065. connect(lowerAddress,SIGNAL(valueChanged(int)),
  11066. this,SLOT(updateLowerAddress(int)));
  11067. connect(upperAddress,SIGNAL(valueChanged(int)),
  11068. this,SLOT(updateUpperAddress(int)));
  11069. setLayout(layout);
  11070. }
  11071. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  11072. {
  11073. updateAttribute("readaddress",QString("%1").arg(newAddress));
  11074. }
  11075. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  11076. {
  11077. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  11078. }
  11079. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  11080. {
  11081. if(fixed)
  11082. {
  11083. updateAttribute("fixedrange","true");
  11084. boundsLayout->setCurrentIndex(1);
  11085. }
  11086. else
  11087. {
  11088. updateAttribute("fixedrange","false");
  11089. boundsLayout->setCurrentIndex(0);
  11090. }
  11091. }
  11092. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  11093. {
  11094. updateAttribute("fixedlower",lower);
  11095. }
  11096. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  11097. {
  11098. updateAttribute("fixedupper",upper);
  11099. }
  11100. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  11101. {
  11102. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  11103. }
  11104. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  11105. {
  11106. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  11107. }
  11108. /*:844*/
  11109. #line 599 "./typica.w"
  11110. /*800:*/
  11111. #line 16521 "./typica.w"
  11112. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11113. :BasicDeviceConfigurationWidget(model,index)
  11114. {
  11115. QVBoxLayout*layout= new QVBoxLayout;
  11116. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  11117. QMenu*deviceMenu= new QMenu;
  11118. NodeInserter*insertAction;
  11119. foreach(insertAction,AppInstance->topLevelNodeInserters)
  11120. {
  11121. connect(insertAction,SIGNAL(triggered(QString,QString)),
  11122. this,SLOT(insertChildNode(QString,QString)));
  11123. deviceMenu->addAction(insertAction);
  11124. }
  11125. addDeviceButton->setMenu(deviceMenu);
  11126. layout->addWidget(addDeviceButton);
  11127. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  11128. QMenu*annotationMenu= new QMenu;
  11129. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  11130. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  11131. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  11132. NodeInserter*freeAnnotationInserter= new NodeInserter(tr("Free Text"),
  11133. tr("Free Text"),
  11134. "freeannotation");
  11135. annotationMenu->addAction(basicButtonInserter);
  11136. annotationMenu->addAction(countingButtonInserter);
  11137. annotationMenu->addAction(spinBoxInserter);
  11138. annotationMenu->addAction(freeAnnotationInserter);
  11139. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  11140. this,SLOT(insertChildNode(QString,QString)));
  11141. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  11142. this,SLOT(insertChildNode(QString,QString)));
  11143. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  11144. this,SLOT(insertChildNode(QString,QString)));
  11145. connect(freeAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11146. this,SLOT(insertChildNode(QString,QString)));
  11147. /*1118:*/
  11148. #line 144 "./valueannotation.w"
  11149. NodeInserter*valueAnnotationInserter= new NodeInserter(tr("Value Annotation"),
  11150. tr("Value Annotation"),
  11151. "valueannotation");
  11152. annotationMenu->addAction(valueAnnotationInserter);
  11153. connect(valueAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11154. this,SLOT(insertChildNode(QString,QString)));
  11155. /*:1118*//*1132:*/
  11156. #line 115 "./thresholdannotation.w"
  11157. NodeInserter*thresholdAnnotationInserter= new NodeInserter(tr("Threshold Annotation"),
  11158. tr("Threshold Annotation"),
  11159. "thresholdannotation");
  11160. annotationMenu->addAction(thresholdAnnotationInserter);
  11161. connect(thresholdAnnotationInserter,SIGNAL(triggered(QString,QString)),
  11162. this,SLOT(insertChildNode(QString,QString)));
  11163. /*:1132*/
  11164. #line 16557 "./typica.w"
  11165. addAnnotationControlButton->setMenu(annotationMenu);
  11166. layout->addWidget(addAnnotationControlButton);
  11167. QPushButton*timersButton= new QPushButton(tr("Extra Timers"));
  11168. QMenu*timersMenu= new QMenu;
  11169. NodeInserter*coolingTimerInserter= new NodeInserter(tr("Cooling Timer"),tr("Cooling Timer"),"coolingtimer");
  11170. NodeInserter*rangeTimerInserter= new NodeInserter(tr("Range Timer"),tr("Range Timer"),"rangetimer");
  11171. NodeInserter*multirangeTimerInserter= new NodeInserter(tr("Multi-Range Timer"),tr("Multi-Range Timer"),"multirangetimer");
  11172. timersMenu->addAction(coolingTimerInserter);
  11173. timersMenu->addAction(rangeTimerInserter);
  11174. timersMenu->addAction(multirangeTimerInserter);
  11175. connect(coolingTimerInserter,SIGNAL(triggered(QString,QString)),
  11176. this,SLOT(insertChildNode(QString,QString)));
  11177. connect(rangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11178. this,SLOT(insertChildNode(QString,QString)));
  11179. connect(multirangeTimerInserter,SIGNAL(triggered(QString,QString)),
  11180. this,SLOT(insertChildNode(QString,QString)));
  11181. timersButton->setMenu(timersMenu);
  11182. layout->addWidget(timersButton);
  11183. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  11184. QMenu*advancedMenu= new QMenu;
  11185. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  11186. advancedMenu->addAction(linearsplineinserter);
  11187. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  11188. advancedMenu->addAction(translationinserter);
  11189. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11190. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11191. /*1030:*/
  11192. #line 258 "./rate.w"
  11193. NodeInserter*rateOfChangeInserter= new NodeInserter(tr("Rate of Change"),tr("Rate of Change"),"rate");
  11194. connect(rateOfChangeInserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  11195. advancedMenu->addAction(rateOfChangeInserter);
  11196. /*:1030*//*1044:*/
  11197. #line 272 "./mergeseries.w"
  11198. NodeInserter*mergeSeriesInserter= new NodeInserter(tr("Merge Series"),
  11199. tr("Merge"),
  11200. "mergeseries");
  11201. connect(mergeSeriesInserter,SIGNAL(triggered(QString,QString)),
  11202. this,SLOT(insertChildNode(QString,QString)));
  11203. advancedMenu->addAction(mergeSeriesInserter);
  11204. /*:1044*/
  11205. #line 16586 "./typica.w"
  11206. advancedButton->setMenu(advancedMenu);
  11207. layout->addWidget(advancedButton);
  11208. QHBoxLayout*idLayout= new QHBoxLayout;
  11209. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  11210. idLayout->addWidget(idLabel);
  11211. QSpinBox*id= new QSpinBox;
  11212. idLayout->addWidget(id);
  11213. idLayout->addStretch();
  11214. layout->addLayout(idLayout);
  11215. QHBoxLayout*capacityLayout= new QHBoxLayout;
  11216. QCheckBox*capacityCheckEnabled= new QCheckBox(tr("Maximum batch size:"));
  11217. QDoubleSpinBox*capacity= new QDoubleSpinBox;
  11218. capacity->setMinimum(0.0);
  11219. capacity->setDecimals(3);
  11220. capacity->setMaximum(999999.999);
  11221. QComboBox*capacityUnit= new QComboBox;
  11222. capacityUnit->addItem("g");
  11223. capacityUnit->addItem("Kg");
  11224. capacityUnit->addItem("oz");
  11225. capacityUnit->addItem("Lb");
  11226. capacityUnit->setCurrentIndex(3);
  11227. capacityLayout->addWidget(capacityCheckEnabled);
  11228. capacityLayout->addWidget(capacity);
  11229. capacityLayout->addWidget(capacityUnit);
  11230. capacityLayout->addStretch();
  11231. layout->addLayout(capacityLayout);
  11232. layout->addStretch();
  11233. /*801:*/
  11234. #line 16651 "./typica.w"
  11235. QDomElement referenceElement=
  11236. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11237. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11238. QDomElement node;
  11239. /*:801*/
  11240. #line 16615 "./typica.w"
  11241. for(int i= 0;i<configData.size();i++)
  11242. {
  11243. node= configData.at(i).toElement();
  11244. if(node.attribute("name")=="databaseid")
  11245. {
  11246. id->setValue(node.attribute("value").toInt());
  11247. }
  11248. else if(node.attribute("name")=="checkcapacity")
  11249. {
  11250. capacityCheckEnabled->setChecked(node.attribute("value")=="true");
  11251. }
  11252. else if(node.attribute("name")=="capacity")
  11253. {
  11254. capacity->setValue(node.attribute("value").toDouble());
  11255. }
  11256. else if(node.attribute("name")=="capacityunit")
  11257. {
  11258. capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
  11259. }
  11260. }
  11261. updateRoasterId(id->value());
  11262. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  11263. connect(capacityCheckEnabled,SIGNAL(stateChanged(int)),this,SLOT(updateCapacityCheck(int)));
  11264. connect(capacity,SIGNAL(valueChanged(QString)),this,SLOT(updateCapacity(QString)));
  11265. connect(capacityUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateCapacityUnit(QString)));
  11266. setLayout(layout);
  11267. }
  11268. /*:800*//*802:*/
  11269. #line 16661 "./typica.w"
  11270. void RoasterConfWidget::updateRoasterId(int id)
  11271. {
  11272. updateAttribute("databaseid",QString("%1").arg(id));
  11273. }
  11274. void RoasterConfWidget::updateCapacityCheck(int value)
  11275. {
  11276. updateAttribute("checkcapacity",value==Qt::Checked?"true":"false");
  11277. }
  11278. void RoasterConfWidget::updateCapacity(const QString&value)
  11279. {
  11280. updateAttribute("capacity",value);
  11281. }
  11282. void RoasterConfWidget::updateCapacityUnit(const QString&value)
  11283. {
  11284. updateAttribute("capacityunit",value);
  11285. }
  11286. /*:802*/
  11287. #line 600 "./typica.w"
  11288. /*848:*/
  11289. #line 18168 "./typica.w"
  11290. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11291. :BasicDeviceConfigurationWidget(model,index)
  11292. {
  11293. QFormLayout*layout= new QFormLayout;
  11294. QLineEdit*buttonTextEdit= new QLineEdit;
  11295. QLineEdit*annotationTextEdit= new QLineEdit;
  11296. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11297. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11298. /*801:*/
  11299. #line 16651 "./typica.w"
  11300. QDomElement referenceElement=
  11301. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11302. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11303. QDomElement node;
  11304. /*:801*/
  11305. #line 18177 "./typica.w"
  11306. for(int i= 0;i<configData.size();i++)
  11307. {
  11308. node= configData.at(i).toElement();
  11309. if(node.attribute("name")=="buttontext")
  11310. {
  11311. buttonTextEdit->setText(node.attribute("value"));
  11312. }
  11313. else if(node.attribute("name")=="annotationtext")
  11314. {
  11315. annotationTextEdit->setText(node.attribute("value"));
  11316. }
  11317. }
  11318. updateButtonText(buttonTextEdit->text());
  11319. updateAnnotationText(annotationTextEdit->text());
  11320. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11321. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11322. setLayout(layout);
  11323. }
  11324. /*:848*//*849:*/
  11325. #line 18199 "./typica.w"
  11326. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  11327. {
  11328. updateAttribute("buttontext",text);
  11329. }
  11330. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11331. {
  11332. updateAttribute("annotationtext",text);
  11333. }
  11334. /*:849*//*852:*/
  11335. #line 18237 "./typica.w"
  11336. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11337. :BasicDeviceConfigurationWidget(model,index)
  11338. {
  11339. QFormLayout*layout= new QFormLayout;
  11340. QLineEdit*buttonTextEdit= new QLineEdit;
  11341. QLineEdit*annotationTextEdit= new QLineEdit;
  11342. layout->addRow(tr("Button Text:"),buttonTextEdit);
  11343. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  11344. /*801:*/
  11345. #line 16651 "./typica.w"
  11346. QDomElement referenceElement=
  11347. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11348. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11349. QDomElement node;
  11350. /*:801*/
  11351. #line 18246 "./typica.w"
  11352. for(int i= 0;i<configData.size();i++)
  11353. {
  11354. node= configData.at(i).toElement();
  11355. if(node.attribute("name")=="buttontext")
  11356. {
  11357. buttonTextEdit->setText(node.attribute("value"));
  11358. }
  11359. else if(node.attribute("name")=="annotationtext")
  11360. {
  11361. annotationTextEdit->setText(node.attribute("value"));
  11362. }
  11363. }
  11364. updateButtonText(buttonTextEdit->text());
  11365. updateAnnotationText(annotationTextEdit->text());
  11366. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  11367. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  11368. QTextEdit*documentation= new QTextEdit;
  11369. 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."));
  11370. documentation->setReadOnly(true);
  11371. layout->addRow("",documentation);
  11372. setLayout(layout);
  11373. }
  11374. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  11375. {
  11376. updateAttribute("buttontext",text);
  11377. }
  11378. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  11379. {
  11380. updateAttribute("annotationtext",text);
  11381. }
  11382. /*:852*/
  11383. #line 601 "./typica.w"
  11384. /*855:*/
  11385. #line 18314 "./typica.w"
  11386. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11387. :BasicDeviceConfigurationWidget(model,index)
  11388. {
  11389. QFormLayout*layout= new QFormLayout;
  11390. QLineEdit*labelEdit= new QLineEdit;
  11391. layout->addRow(tr("Control Label: "),labelEdit);
  11392. QLineEdit*minimumEdit= new QLineEdit;
  11393. layout->addRow(tr("Minimum Value: "),minimumEdit);
  11394. QLineEdit*maximumEdit= new QLineEdit;
  11395. layout->addRow(tr("Maximum Value: "),maximumEdit);
  11396. QSpinBox*precisionEdit= new QSpinBox;
  11397. precisionEdit->setMinimum(0);
  11398. precisionEdit->setMaximum(9);
  11399. layout->addRow(tr("Precision"),precisionEdit);
  11400. QLineEdit*pretext= new QLineEdit;
  11401. layout->addRow(tr("Prefix text"),pretext);
  11402. QLineEdit*posttext= new QLineEdit;
  11403. layout->addRow(tr("Suffix text"),posttext);
  11404. /*801:*/
  11405. #line 16651 "./typica.w"
  11406. QDomElement referenceElement=
  11407. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11408. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11409. QDomElement node;
  11410. /*:801*/
  11411. #line 18333 "./typica.w"
  11412. for(int i= 0;i<configData.size();i++)
  11413. {
  11414. node= configData.at(i).toElement();
  11415. if(node.attribute("name")=="label")
  11416. {
  11417. labelEdit->setText(node.attribute("value"));
  11418. }
  11419. else if(node.attribute("name")=="minimum")
  11420. {
  11421. minimumEdit->setText(node.attribute("value"));
  11422. }
  11423. else if(node.attribute("name")=="maximum")
  11424. {
  11425. maximumEdit->setText(node.attribute("value"));
  11426. }
  11427. else if(node.attribute("name")=="precision")
  11428. {
  11429. precisionEdit->setValue(node.attribute("value").toInt());
  11430. }
  11431. else if(node.attribute("name")=="pretext")
  11432. {
  11433. pretext->setText(node.attribute("value"));
  11434. }
  11435. else if(node.attribute("name")=="posttext")
  11436. {
  11437. posttext->setText(node.attribute("value"));
  11438. }
  11439. }
  11440. updateLabel(labelEdit->text());
  11441. updateMinimum(minimumEdit->text());
  11442. updateMaximum(maximumEdit->text());
  11443. updatePrecision(precisionEdit->value());
  11444. updatePretext(pretext->text());
  11445. updatePosttext(posttext->text());
  11446. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  11447. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  11448. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  11449. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  11450. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  11451. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  11452. setLayout(layout);
  11453. }
  11454. void NoteSpinConfWidget::updateLabel(const QString&text)
  11455. {
  11456. updateAttribute("label",text);
  11457. }
  11458. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  11459. {
  11460. updateAttribute("minimum",minimum);
  11461. }
  11462. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  11463. {
  11464. updateAttribute("maximum",maximum);
  11465. }
  11466. void NoteSpinConfWidget::updatePrecision(int precision)
  11467. {
  11468. updateAttribute("precision",QString("%1").arg(precision));
  11469. }
  11470. void NoteSpinConfWidget::updatePretext(const QString&text)
  11471. {
  11472. updateAttribute("pretext",text);
  11473. }
  11474. void NoteSpinConfWidget::updatePosttext(const QString&text)
  11475. {
  11476. updateAttribute("posttext",text);
  11477. }
  11478. /*:855*/
  11479. #line 602 "./typica.w"
  11480. /*347:*/
  11481. #line 7805 "./typica.w"
  11482. LinearCalibrator::LinearCalibrator(QObject*parent):
  11483. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  11484. {
  11485. connect(this,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11486. }
  11487. /*:347*//*348:*/
  11488. #line 7819 "./typica.w"
  11489. Measurement LinearCalibrator::newMeasurement(Measurement measure)
  11490. {
  11491. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  11492. if(clamp)
  11493. {
  11494. if(outval<Lo1)
  11495. {
  11496. outval= Lo1;
  11497. }
  11498. else if(outval> Up1)
  11499. {
  11500. outval= Up1;
  11501. }
  11502. }
  11503. if(sensitivitySetting>=0.05)
  11504. {
  11505. int temp= qRound(outval/sensitivitySetting);
  11506. outval= temp*sensitivitySetting;
  11507. }
  11508. Measurement adjusted(outval,measure.time(),measure.scale());
  11509. emit measurement(adjusted);
  11510. return adjusted;
  11511. }
  11512. /*:348*//*349:*/
  11513. #line 7846 "./typica.w"
  11514. double LinearCalibrator::measuredLower()
  11515. {
  11516. return Lo2;
  11517. }
  11518. double LinearCalibrator::measuredUpper()
  11519. {
  11520. return Up2;
  11521. }
  11522. double LinearCalibrator::mappedLower()
  11523. {
  11524. return Lo1;
  11525. }
  11526. double LinearCalibrator::mappedUpper()
  11527. {
  11528. return Up1;
  11529. }
  11530. bool LinearCalibrator::isClosedRange()
  11531. {
  11532. return clamp;
  11533. }
  11534. void LinearCalibrator::setMeasuredLower(double lower)
  11535. {
  11536. Lo2= lower;
  11537. }
  11538. void LinearCalibrator::setMeasuredUpper(double upper)
  11539. {
  11540. Up2= upper;
  11541. }
  11542. void LinearCalibrator::setMappedLower(double lower)
  11543. {
  11544. Lo1= lower;
  11545. }
  11546. void LinearCalibrator::setMappedUpper(double upper)
  11547. {
  11548. Up1= upper;
  11549. }
  11550. void LinearCalibrator::setClosedRange(bool closed)
  11551. {
  11552. clamp= closed;
  11553. }
  11554. void LinearCalibrator::setSensitivity(double sensitivity)
  11555. {
  11556. sensitivitySetting= sensitivity;
  11557. }
  11558. double LinearCalibrator::sensitivity()
  11559. {
  11560. return sensitivitySetting;
  11561. }
  11562. /*:349*/
  11563. #line 603 "./typica.w"
  11564. /*354:*/
  11565. #line 7979 "./typica.w"
  11566. void LinearSplineInterpolator::add_pair(double source,double destination)
  11567. {
  11568. pairs->insert(source,destination);
  11569. make_interpolators();
  11570. }
  11571. void LinearSplineInterpolator::make_interpolators()
  11572. {
  11573. if(pairs->size()> 1)
  11574. {
  11575. while(interpolators->size()> 0)
  11576. {
  11577. LinearCalibrator*removed= interpolators->takeFirst();
  11578. removed->deleteLater();
  11579. }
  11580. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11581. QMap<double,double> ::const_iterator j= i+1;
  11582. while(j!=pairs->constEnd())
  11583. {
  11584. LinearCalibrator*segment= new LinearCalibrator();
  11585. segment->setMeasuredLower(i.key());
  11586. segment->setMappedLower(i.value());
  11587. segment->setMeasuredUpper(j.key());
  11588. segment->setMappedUpper(j.value());
  11589. segment->setClosedRange(false);
  11590. interpolators->append(segment);
  11591. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  11592. i++;
  11593. j++;
  11594. }
  11595. }
  11596. }
  11597. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  11598. QObject(parent),pairs(new QMap<double,double> ),
  11599. interpolators(new QList<LinearCalibrator*> )
  11600. {
  11601. }
  11602. Measurement LinearSplineInterpolator::newMeasurement(Measurement measure)
  11603. {
  11604. QMap<double,double> ::const_iterator i= pairs->constBegin();
  11605. int index= -1;
  11606. while(i!=pairs->constEnd())
  11607. {
  11608. if(measure.temperature()<=i.key())
  11609. {
  11610. break;
  11611. }
  11612. i++;
  11613. index++;
  11614. }
  11615. if(index<0)
  11616. {
  11617. index= 0;
  11618. }
  11619. if(index>=interpolators->size())
  11620. {
  11621. index= interpolators->size()-1;
  11622. }
  11623. if(interpolators->at(index)!=NULL)
  11624. {
  11625. return interpolators->at(index)->newMeasurement(measure);
  11626. }
  11627. return Measurement();
  11628. }
  11629. /*:354*/
  11630. #line 604 "./typica.w"
  11631. /*995:*/
  11632. #line 19686 "./typica.w"
  11633. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11634. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  11635. {
  11636. QFormLayout*layout= new QFormLayout;
  11637. QLineEdit*source= new QLineEdit;
  11638. layout->addRow(tr("Source column name:"),source);
  11639. QLineEdit*destination= new QLineEdit;
  11640. layout->addRow(tr("Destination column name:"),destination);
  11641. tablemodel->setHeaderData(0,Qt::Horizontal,"Input");
  11642. tablemodel->setHeaderData(1,Qt::Horizontal,"Output");
  11643. QTableView*mappingTable= new QTableView;
  11644. mappingTable->setModel(tablemodel);
  11645. NumericDelegate*delegate= new NumericDelegate;
  11646. mappingTable->setItemDelegate(delegate);
  11647. layout->addRow(tr("Mapping data:"),mappingTable);
  11648. /*801:*/
  11649. #line 16651 "./typica.w"
  11650. QDomElement referenceElement=
  11651. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11652. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11653. QDomElement node;
  11654. /*:801*/
  11655. #line 19702 "./typica.w"
  11656. for(int i= 0;i<configData.size();i++)
  11657. {
  11658. node= configData.at(i).toElement();
  11659. if(node.attribute("name")=="source")
  11660. {
  11661. source->setText(node.attribute("value"));
  11662. }
  11663. else if(node.attribute("name")=="destination")
  11664. {
  11665. destination->setText(node.attribute("value"));
  11666. }
  11667. else if(node.attribute("name")=="sourcevalues")
  11668. {
  11669. /*996:*/
  11670. #line 19741 "./typica.w"
  11671. QString data= node.attribute("value");
  11672. if(data.length()> 3)
  11673. {
  11674. data.chop(2);
  11675. data= data.remove(0,2);
  11676. }
  11677. QStringList itemList= data.split(",");
  11678. /*:996*/
  11679. #line 19716 "./typica.w"
  11680. int column= 0;
  11681. /*997:*/
  11682. #line 19753 "./typica.w"
  11683. for(int j= 0;j<itemList.size();j++)
  11684. {
  11685. tablemodel->setData(tablemodel->index(j,column),
  11686. QVariant(itemList.at(j).toDouble()),
  11687. Qt::DisplayRole);
  11688. }
  11689. /*:997*/
  11690. #line 19718 "./typica.w"
  11691. }
  11692. else if(node.attribute("name")=="destinationvalues")
  11693. {
  11694. /*996:*/
  11695. #line 19741 "./typica.w"
  11696. QString data= node.attribute("value");
  11697. if(data.length()> 3)
  11698. {
  11699. data.chop(2);
  11700. data= data.remove(0,2);
  11701. }
  11702. QStringList itemList= data.split(",");
  11703. /*:996*/
  11704. #line 19723 "./typica.w"
  11705. int column= 1;
  11706. /*997:*/
  11707. #line 19753 "./typica.w"
  11708. for(int j= 0;j<itemList.size();j++)
  11709. {
  11710. tablemodel->setData(tablemodel->index(j,column),
  11711. QVariant(itemList.at(j).toDouble()),
  11712. Qt::DisplayRole);
  11713. }
  11714. /*:997*/
  11715. #line 19725 "./typica.w"
  11716. }
  11717. }
  11718. updateSourceColumn(source->text());
  11719. updateDestinationColumn(destination->text());
  11720. updateKnots();
  11721. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  11722. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  11723. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  11724. setLayout(layout);
  11725. }
  11726. /*:995*//*998:*/
  11727. #line 19764 "./typica.w"
  11728. void LinearSplineInterpolationConfWidget::updateKnots()
  11729. {
  11730. updateAttribute("sourcevalues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  11731. updateAttribute("destinationvalues",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  11732. }
  11733. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  11734. {
  11735. updateAttribute("source",source);
  11736. }
  11737. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  11738. {
  11739. updateAttribute("destination",dest);
  11740. }
  11741. /*:998*/
  11742. #line 605 "./typica.w"
  11743. /*1015:*/
  11744. #line 20235 "./typica.w"
  11745. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  11746. :BasicDeviceConfigurationWidget(model,index),
  11747. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox),
  11748. delaySelector(new QSpinBox)
  11749. {
  11750. unitSelector->addItem("Fahrenheit");
  11751. unitSelector->addItem("Celsius");
  11752. temperatureValue->setMinimum(0);
  11753. temperatureValue->setMaximum(1000);
  11754. QFormLayout*layout= new QFormLayout;
  11755. QLineEdit*column= new QLineEdit;
  11756. layout->addRow(tr("Column to match:"),column);
  11757. layout->addRow(tr("Unit:"),unitSelector);
  11758. layout->addRow(tr("Value:"),temperatureValue);
  11759. layout->addRow(tr("Start of batch safety delay:"),delaySelector);
  11760. /*801:*/
  11761. #line 16651 "./typica.w"
  11762. QDomElement referenceElement=
  11763. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11764. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11765. QDomElement node;
  11766. /*:801*/
  11767. #line 20251 "./typica.w"
  11768. for(int i= 0;i<configData.size();i++)
  11769. {
  11770. node= configData.at(i).toElement();
  11771. if(node.attribute("name")=="column")
  11772. {
  11773. column->setText(node.attribute("value"));
  11774. }
  11775. else if(node.attribute("name")=="unit")
  11776. {
  11777. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  11778. }
  11779. else if(node.attribute("name")=="value")
  11780. {
  11781. temperatureValue->setValue(node.attribute("value").toDouble());
  11782. }
  11783. else if(node.attribute("name")=="delay")
  11784. {
  11785. delaySelector->setValue(node.attribute("value").toInt());
  11786. }
  11787. }
  11788. updateMatchingColumn(column->text());
  11789. updateTemperature();
  11790. updateDelay();
  11791. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  11792. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  11793. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  11794. connect(delaySelector,SIGNAL(valueChanged(int)),this,SLOT(updateDelay()));
  11795. setLayout(layout);
  11796. }
  11797. /*:1015*//*1016:*/
  11798. #line 20286 "./typica.w"
  11799. void TranslationConfWidget::updateTemperature()
  11800. {
  11801. updateAttribute("unit",unitSelector->currentText());
  11802. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  11803. if(unitSelector->currentText()=="Fahrenheit")
  11804. {
  11805. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  11806. }
  11807. else
  11808. {
  11809. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  11810. }
  11811. }
  11812. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  11813. {
  11814. updateAttribute("column",column);
  11815. }
  11816. void TranslationConfWidget::updateDelay()
  11817. {
  11818. updateAttribute("delay",QString("%1").arg(delaySelector->value()));
  11819. }
  11820. /*:1016*/
  11821. #line 606 "./typica.w"
  11822. /*858:*/
  11823. #line 24 "./freeannotation.w"
  11824. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel*model,
  11825. const QModelIndex&index)
  11826. :BasicDeviceConfigurationWidget(model,index)
  11827. {
  11828. QFormLayout*layout= new QFormLayout;
  11829. QLineEdit*labelEdit= new QLineEdit;
  11830. layout->addRow(tr("Label Text:"),labelEdit);
  11831. /*801:*/
  11832. #line 16651 "./typica.w"
  11833. QDomElement referenceElement=
  11834. model->referenceElement(model->data(index,Qt::UserRole).toString());
  11835. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  11836. QDomElement node;
  11837. /*:801*/
  11838. #line 32 "./freeannotation.w"
  11839. for(int i= 0;i<configData.size();i++)
  11840. {
  11841. node= configData.at(i).toElement();
  11842. if(node.attribute("name")=="labeltext")
  11843. {
  11844. labelEdit->setText(node.attribute("value"));
  11845. }
  11846. }
  11847. updateLabel(labelEdit->text());
  11848. connect(labelEdit,SIGNAL(textEdited(QString)),
  11849. this,SLOT(updateLabel(QString)));
  11850. setLayout(layout);
  11851. }
  11852. /*:858*//*859:*/
  11853. #line 49 "./freeannotation.w"
  11854. void FreeAnnotationConfWidget::updateLabel(const QString&text)
  11855. {
  11856. updateAttribute("labeltext",text);
  11857. }
  11858. /*:859*/
  11859. #line 607 "./typica.w"
  11860. /*1019:*/
  11861. #line 39 "./rate.w"
  11862. void RateOfChange::newMeasurement(Measurement measure)
  11863. {
  11864. cache.append(measure);
  11865. /*1020:*/
  11866. #line 64 "./rate.w"
  11867. if(cache.size()> 2)
  11868. {
  11869. bool done= false;
  11870. while(!done)
  11871. {
  11872. if(cache.front().time().secsTo(cache.back().time())> ct)
  11873. {
  11874. cache.removeFirst();
  11875. }
  11876. else if(cache.back().time()<cache.front().time())
  11877. {
  11878. cache.removeFirst();
  11879. done= true;
  11880. }
  11881. else
  11882. {
  11883. done= true;
  11884. }
  11885. if(cache.size()<3)
  11886. {
  11887. done= true;
  11888. }
  11889. }
  11890. }
  11891. /*:1020*/
  11892. #line 43 "./rate.w"
  11893. if(cache.size()>=2)
  11894. {
  11895. /*1021:*/
  11896. #line 96 "./rate.w"
  11897. int N= cache.size();
  11898. double SXY= 0;
  11899. double SX= 0;
  11900. double SXX= 0;
  11901. double SY= 0;
  11902. double y;
  11903. double x;
  11904. for(int i= 0;i<N;i++)
  11905. {
  11906. y= cache.at(i).temperature();
  11907. SY+= y;
  11908. x= cache.at(0).time().msecsTo(cache.at(i).time())/1000.0;
  11909. SX+= x;
  11910. SXX+= (x*x);
  11911. SXY+= (x*y);
  11912. }
  11913. double M= ((N*SXY)-(SX*SY))/((N*SXX)-(SX*SX));
  11914. Measurement value(M*st,cache.back().time(),cache.back().scale());
  11915. value.insert("relative",true);
  11916. emit newData(value);
  11917. /*:1021*/
  11918. #line 46 "./rate.w"
  11919. }
  11920. }
  11921. /*:1019*//*1022:*/
  11922. #line 120 "./rate.w"
  11923. RateOfChange::RateOfChange(int cachetime,int scaletime):ct(cachetime),st(1)
  11924. {
  11925. setScaleTime(scaletime);
  11926. }
  11927. void RateOfChange::setCacheTime(int seconds)
  11928. {
  11929. ct= seconds;
  11930. }
  11931. void RateOfChange::setScaleTime(int seconds)
  11932. {
  11933. st= (seconds> 0?seconds:1);
  11934. }
  11935. /*:1022*/
  11936. #line 608 "./typica.w"
  11937. /*862:*/
  11938. #line 26 "./settings.w"
  11939. SettingsWindow::SettingsWindow():QMainWindow(NULL)
  11940. {
  11941. QTabWidget*settingsTab= new QTabWidget;
  11942. DeviceConfigurationWindow*deviceSettings= new DeviceConfigurationWindow;
  11943. settingsTab->addTab(deviceSettings,tr("Roasters"));
  11944. GraphSettingsWidget*graphSettings= new GraphSettingsWidget;
  11945. settingsTab->addTab(graphSettings,tr("Graph"));
  11946. AdvancedSettingsWidget*advancedSettings= new AdvancedSettingsWidget;
  11947. settingsTab->addTab(advancedSettings,tr("Advanced"));
  11948. setCentralWidget(settingsTab);
  11949. }
  11950. /*:862*/
  11951. #line 609 "./typica.w"
  11952. /*867:*/
  11953. #line 27 "./graphsettings.w"
  11954. GraphSettingsWidget::GraphSettingsWidget():QWidget(NULL)
  11955. {
  11956. QTabWidget*graphCategories= new QTabWidget;
  11957. GraphSettingsRelativeTab*relative= new GraphSettingsRelativeTab;
  11958. graphCategories->addTab(relative,tr("Relative Temperatures"));
  11959. QVBoxLayout*layout= new QVBoxLayout;
  11960. layout->addWidget(graphCategories);
  11961. setLayout(layout);
  11962. }
  11963. /*:867*//*869:*/
  11964. #line 69 "./graphsettings.w"
  11965. GraphSettingsRelativeTab::GraphSettingsRelativeTab():QWidget(NULL),
  11966. colorEdit(new QLineEdit)
  11967. {
  11968. QSettings settings;
  11969. QVBoxLayout*layout= new QVBoxLayout;
  11970. QCheckBox*enable= new QCheckBox(tr("Graph relative temperatures"));
  11971. enable->setChecked(settings.value("settings/graph/relative/enable",true).toBool());
  11972. updateEnableSetting(enable->isChecked());
  11973. connect(enable,SIGNAL(toggled(bool)),this,SLOT(updateEnableSetting(bool)));
  11974. layout->addWidget(enable);
  11975. QHBoxLayout*colorLayout= new QHBoxLayout;
  11976. QLabel*colorLabel= new QLabel(tr("Axis color:"));
  11977. colorEdit->setText(settings.value("settings/graph/relative/color","#000000").toString());
  11978. updateColorSetting(colorEdit->text());
  11979. connect(colorEdit,SIGNAL(textChanged(QString)),this,SLOT(updateColorSetting(QString)));
  11980. QToolButton*colorPickerButton= new QToolButton();
  11981. colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
  11982. connect(colorPickerButton,SIGNAL(clicked()),this,SLOT(showColorPicker()));
  11983. colorLayout->addWidget(colorLabel);
  11984. colorLayout->addWidget(colorEdit);
  11985. colorLayout->addWidget(colorPickerButton);
  11986. colorLayout->addStretch();
  11987. layout->addLayout(colorLayout);
  11988. QHBoxLayout*unitLayout= new QHBoxLayout;
  11989. QLabel*unitLabel= new QLabel(tr("Unit"));
  11990. QComboBox*unitSelector= new QComboBox;
  11991. unitSelector->addItem(tr("Fahrenheit"));
  11992. unitSelector->addItem(tr("Celsius"));
  11993. unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit",0).toInt());
  11994. updateUnit(unitSelector->currentIndex());
  11995. connect(unitSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  11996. unitLayout->addWidget(unitLabel);
  11997. unitLayout->addWidget(unitSelector);
  11998. unitLayout->addStretch();
  11999. layout->addLayout(unitLayout);
  12000. QHBoxLayout*axisLayout= new QHBoxLayout;
  12001. QLabel*axisLabel= new QLabel(tr("Grid line positions (comma separated):"));
  12002. QLineEdit*axisEdit= new QLineEdit;
  12003. axisEdit->setText(settings.value("settings/graph/relative/grid","-300, -100, 0, 30, 65, 100").toString());
  12004. updateAxisSetting(axisEdit->text());
  12005. connect(axisEdit,SIGNAL(textChanged(QString)),this,SLOT(updateAxisSetting(QString)));
  12006. axisLayout->addWidget(axisLabel);
  12007. axisLayout->addWidget(axisEdit);
  12008. layout->addLayout(axisLayout);
  12009. layout->addStretch();
  12010. setLayout(layout);
  12011. }
  12012. /*:869*//*870:*/
  12013. #line 120 "./graphsettings.w"
  12014. void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
  12015. {
  12016. QSettings settings;
  12017. settings.setValue("settings/graph/relative/enable",enabled);
  12018. }
  12019. void GraphSettingsRelativeTab::updateColorSetting(const QString&color)
  12020. {
  12021. QSettings settings;
  12022. settings.setValue("settings/graph/relative/color",color);
  12023. }
  12024. void GraphSettingsRelativeTab::updateAxisSetting(const QString&gridList)
  12025. {
  12026. QSettings settings;
  12027. QString settingValue;
  12028. QStringList points= gridList.split(QRegExp("[\\s,]+"),QString::SkipEmptyParts);
  12029. QStringList numbers;
  12030. foreach(QString text,points)
  12031. {
  12032. bool okay= false;
  12033. text.toDouble(&okay);
  12034. if(okay)
  12035. {
  12036. numbers.append(text);
  12037. }
  12038. }
  12039. numbers.removeDuplicates();
  12040. settings.setValue("settings/graph/relative/grid",numbers.join(","));
  12041. }
  12042. void GraphSettingsRelativeTab::updateUnit(int unit)
  12043. {
  12044. QSettings settings;
  12045. settings.setValue("settings/graph/relative/unit",unit);
  12046. }
  12047. /*:870*//*871:*/
  12048. #line 163 "./graphsettings.w"
  12049. void GraphSettingsRelativeTab::showColorPicker()
  12050. {
  12051. QColor color= QColorDialog::getColor(QColor(colorEdit->text()),this);
  12052. colorEdit->setText(color.name());
  12053. }
  12054. #line 62 "./settings.w"
  12055. #line 1 "./advancedsettings.w"
  12056. /*:871*/
  12057. #line 610 "./typica.w"
  12058. /*1068:*/
  12059. #line 682 "./dataqsdk.w"
  12060. DataqSdkDeviceConfWidget::DataqSdkDeviceConfWidget(DeviceTreeModel*model,
  12061. const QModelIndex&index)
  12062. :BasicDeviceConfigurationWidget(model,index),
  12063. deviceIdStack(new QStackedWidget)
  12064. {
  12065. QVBoxLayout*layout= new QVBoxLayout;
  12066. QCheckBox*autoDetect= new QCheckBox("Automatically select device");
  12067. layout->addWidget(autoDetect);
  12068. QWidget*autoLayerWidget= new QWidget;
  12069. QHBoxLayout*autoLayerLayout= new QHBoxLayout;
  12070. QLabel*autoLabel= new QLabel(tr("Device number"));
  12071. QSpinBox*autoNumber= new QSpinBox;
  12072. autoNumber->setMinimum(1);
  12073. autoNumber->setMaximum(99);
  12074. autoLayerLayout->addWidget(autoLabel);
  12075. autoLayerLayout->addWidget(autoNumber);
  12076. autoLayerWidget->setLayout(autoLayerLayout);
  12077. QWidget*fixedLayerWidget= new QWidget;
  12078. QHBoxLayout*fixedLayerLayout= new QHBoxLayout;
  12079. QLabel*fixedLabel= new QLabel(tr("Device port"));
  12080. QComboBox*portSelection= new QComboBox;
  12081. portSelection->setEditable(true);
  12082. portSelection->addItems(DataqSdkDevice::detectHardware());
  12083. fixedLayerLayout->addWidget(fixedLabel);
  12084. fixedLayerLayout->addWidget(portSelection);
  12085. fixedLayerWidget->setLayout(fixedLayerLayout);
  12086. deviceIdStack->addWidget(autoLayerWidget);
  12087. deviceIdStack->addWidget(fixedLayerWidget);
  12088. layout->addWidget(deviceIdStack);
  12089. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  12090. layout->addWidget(addChannelButton);
  12091. /*801:*/
  12092. #line 16651 "./typica.w"
  12093. QDomElement referenceElement=
  12094. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12095. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12096. QDomElement node;
  12097. /*:801*/
  12098. #line 714 "./dataqsdk.w"
  12099. for(int i= 0;i<configData.size();i++)
  12100. {
  12101. node= configData.at(i).toElement();
  12102. if(node.attribute("name")=="autoSelect")
  12103. {
  12104. autoDetect->setChecked(node.attribute("value")=="true"?true:false);
  12105. }
  12106. else if(node.attribute("name")=="deviceNumber")
  12107. {
  12108. autoNumber->setValue(node.attribute("value").toInt());
  12109. }
  12110. else if(node.attribute("name")=="port")
  12111. {
  12112. int index= portSelection->findText(node.attribute("value"));
  12113. if(index> -1)
  12114. {
  12115. portSelection->setCurrentIndex(index);
  12116. }
  12117. else
  12118. {
  12119. portSelection->setEditText(node.attribute("value"));
  12120. }
  12121. }
  12122. }
  12123. updateAutoSelect(autoDetect->isChecked());
  12124. updateDeviceNumber(autoNumber->value());
  12125. updatePort(portSelection->currentText());
  12126. connect(autoDetect,SIGNAL(toggled(bool)),this,SLOT(updateAutoSelect(bool)));
  12127. connect(autoNumber,SIGNAL(valueChanged(int)),this,SLOT(updateDeviceNumber(int)));
  12128. connect(portSelection,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12129. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  12130. setLayout(layout);
  12131. }
  12132. /*:1068*//*1069:*/
  12133. #line 758 "./dataqsdk.w"
  12134. void DataqSdkDeviceConfWidget::updateAutoSelect(bool automatic)
  12135. {
  12136. if(automatic)
  12137. {
  12138. updateAttribute("autoSelect","true");
  12139. deviceIdStack->setCurrentIndex(0);
  12140. }
  12141. else
  12142. {
  12143. updateAttribute("autoSelect","false");
  12144. deviceIdStack->setCurrentIndex(1);
  12145. }
  12146. }
  12147. /*:1069*//*1070:*/
  12148. #line 775 "./dataqsdk.w"
  12149. void DataqSdkDeviceConfWidget::updateDeviceNumber(int deviceNumber)
  12150. {
  12151. updateAttribute("deviceNumber",QString("%1").arg(deviceNumber));
  12152. }
  12153. void DataqSdkDeviceConfWidget::updatePort(QString portId)
  12154. {
  12155. updateAttribute("port",portId);
  12156. }
  12157. /*:1070*//*1071:*/
  12158. #line 788 "./dataqsdk.w"
  12159. void DataqSdkDeviceConfWidget::addChannel()
  12160. {
  12161. insertChildNode(tr("Channel"),"dataqsdkchannel");
  12162. }
  12163. /*:1071*//*1074:*/
  12164. #line 868 "./dataqsdk.w"
  12165. DataqSdkChannelConfWidget::DataqSdkChannelConfWidget(DeviceTreeModel*model,
  12166. const QModelIndex&index)
  12167. :BasicDeviceConfigurationWidget(model,index),
  12168. startButton(new QPushButton(tr("Start"))),
  12169. resetButton(new QPushButton(tr("Reset"))),
  12170. stopButton(new QPushButton(tr("Stop"))),
  12171. calibrator(new LinearCalibrator),
  12172. currentMeasurement(new QLineEdit),minimumMeasurement(new QLineEdit),
  12173. maximumMeasurement(new QLineEdit),averageMeasurement(new QLineEdit),
  12174. currentMapped(new QLineEdit),minimumMapped(new QLineEdit),
  12175. maximumMapped(new QLineEdit),averageMapped(new QLineEdit),
  12176. rmCount(0),cmCount(0),
  12177. rmin(std::numeric_limits<double> ::max()),
  12178. rmax(std::numeric_limits<double> ::min()),rmean(0),
  12179. cmin(std::numeric_limits<double> ::max()),
  12180. cmax(std::numeric_limits<double> ::min()),cmean(0)
  12181. {
  12182. /*1078:*/
  12183. #line 1107 "./dataqsdk.w"
  12184. QDomElement parentReference= model->referenceElement(model->data(index.parent(),Qt::UserRole).toString());
  12185. QDomNodeList deviceConfigData= parentReference.elementsByTagName("attribute");
  12186. QDomElement deviceNode;
  12187. QString configPort;
  12188. QString configAuto;
  12189. for(int i= 0;i<deviceConfigData.size();i++)
  12190. {
  12191. deviceNode= deviceConfigData.at(i).toElement();
  12192. if(deviceNode.attribute("name")=="autoSelect")
  12193. {
  12194. autoSelect= (deviceNode.attribute("value")=="true");
  12195. }
  12196. else if(deviceNode.attribute("name")=="deviceNumber")
  12197. {
  12198. configAuto= deviceNode.attribute("value");
  12199. }
  12200. else if(deviceNode.attribute("name")=="port")
  12201. {
  12202. configPort= deviceNode.attribute("value");
  12203. }
  12204. }
  12205. deviceID= autoSelect?configAuto:configPort;
  12206. channelOfInterest= index.row();
  12207. /*:1078*/
  12208. #line 886 "./dataqsdk.w"
  12209. resetButton->setEnabled(false);
  12210. stopButton->setEnabled(false);
  12211. connect(startButton,SIGNAL(clicked()),this,SLOT(startCalibration()));
  12212. connect(resetButton,SIGNAL(clicked()),this,SLOT(resetCalibration()));
  12213. connect(stopButton,SIGNAL(clicked()),this,SLOT(stopCalibration()));
  12214. QVBoxLayout*layout= new QVBoxLayout;
  12215. QFormLayout*topLayout= new QFormLayout;
  12216. QLineEdit*columnEdit= new QLineEdit;
  12217. topLayout->addRow(tr("Column name"),columnEdit);
  12218. QComboBox*unitSelector= new QComboBox;
  12219. unitSelector->addItem(tr("Temperature"));
  12220. unitSelector->addItem(tr("Control"));
  12221. topLayout->addRow(tr("Measurement type"),unitSelector);
  12222. QCheckBox*smoothingBox= new QCheckBox(tr("Enable smoothing"));
  12223. topLayout->addRow(smoothingBox);
  12224. layout->addLayout(topLayout);
  12225. QCheckBox*hideSeries= new QCheckBox(tr("Hide this channel"));
  12226. topLayout->addRow(hideSeries);
  12227. QLabel*calibrationLabel= new QLabel(tr("Calibration settings"));
  12228. layout->addWidget(calibrationLabel);
  12229. QHBoxLayout*calibrationLayout= new QHBoxLayout;
  12230. QFormLayout*calibrationControlsLayout= new QFormLayout;
  12231. QLineEdit*measuredLowerEdit= new QLineEdit;
  12232. measuredLowerEdit->setText("0");
  12233. QLineEdit*measuredUpperEdit= new QLineEdit;
  12234. measuredUpperEdit->setText("10");
  12235. QLineEdit*mappedLowerEdit= new QLineEdit;
  12236. mappedLowerEdit->setText("0");
  12237. QLineEdit*mappedUpperEdit= new QLineEdit;
  12238. mappedUpperEdit->setText("10");
  12239. calibrationControlsLayout->addRow(tr("Measured lower value"),measuredLowerEdit);
  12240. calibrationControlsLayout->addRow(tr("Mapped lower value"),mappedLowerEdit);
  12241. calibrationControlsLayout->addRow(tr("Measured upper value"),measuredUpperEdit);
  12242. calibrationControlsLayout->addRow(tr("Mapped upper value"),mappedUpperEdit);
  12243. QCheckBox*closedBox= new QCheckBox(tr("Closed range"));
  12244. calibrationControlsLayout->addRow(closedBox);
  12245. QLineEdit*sensitivityEdit= new QLineEdit;
  12246. sensitivityEdit->setText("0");
  12247. calibrationControlsLayout->addRow(tr("Discrete interval skip"),sensitivityEdit);
  12248. QVBoxLayout*calibrationTestLayout= new QVBoxLayout;
  12249. QHBoxLayout*deviceControlLayout= new QHBoxLayout;
  12250. deviceControlLayout->addWidget(startButton);
  12251. deviceControlLayout->addWidget(resetButton);
  12252. deviceControlLayout->addWidget(stopButton);
  12253. QFormLayout*indicatorLayout= new QFormLayout;
  12254. currentMeasurement->setReadOnly(true);
  12255. minimumMeasurement->setReadOnly(true);
  12256. maximumMeasurement->setReadOnly(true);
  12257. averageMeasurement->setReadOnly(true);
  12258. currentMapped->setReadOnly(true);
  12259. minimumMapped->setReadOnly(true);
  12260. maximumMapped->setReadOnly(true);
  12261. averageMapped->setReadOnly(true);
  12262. indicatorLayout->addRow(tr("Measured Values"),new QWidget);
  12263. indicatorLayout->addRow(tr("Current"),currentMeasurement);
  12264. indicatorLayout->addRow(tr("Minimum"),minimumMeasurement);
  12265. indicatorLayout->addRow(tr("Maximum"),maximumMeasurement);
  12266. indicatorLayout->addRow(tr("Mean"),averageMeasurement);
  12267. indicatorLayout->addRow(tr("Mapped Values"),new QWidget);
  12268. indicatorLayout->addRow(tr("Current Mapped"),currentMapped);
  12269. indicatorLayout->addRow(tr("Minimum Mapped"),minimumMapped);
  12270. indicatorLayout->addRow(tr("Maximum Mapped"),maximumMapped);
  12271. indicatorLayout->addRow(tr("Mean Mapped"),averageMapped);
  12272. calibrationTestLayout->addLayout(deviceControlLayout);
  12273. calibrationTestLayout->addLayout(indicatorLayout);
  12274. calibrationLayout->addLayout(calibrationControlsLayout);
  12275. calibrationLayout->addLayout(calibrationTestLayout);
  12276. layout->addLayout(calibrationLayout);
  12277. /*801:*/
  12278. #line 16651 "./typica.w"
  12279. QDomElement referenceElement=
  12280. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12281. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12282. QDomElement node;
  12283. /*:801*/
  12284. #line 955 "./dataqsdk.w"
  12285. for(int i= 0;i<configData.size();i++)
  12286. {
  12287. node= configData.at(i).toElement();
  12288. if(node.attribute("name")=="column")
  12289. {
  12290. columnEdit->setText(node.attribute("value"));
  12291. }
  12292. else if(node.attribute("name")=="type")
  12293. {
  12294. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  12295. }
  12296. else if(node.attribute("name")=="smoothing")
  12297. {
  12298. smoothingBox->setChecked(node.attribute("value")=="true");
  12299. }
  12300. else if(node.attribute("name")=="calibrationMeasuredLower")
  12301. {
  12302. measuredLowerEdit->setText(node.attribute("value"));
  12303. }
  12304. else if(node.attribute("name")=="calibrationMeasuredUpper")
  12305. {
  12306. measuredUpperEdit->setText(node.attribute("value"));
  12307. }
  12308. else if(node.attribute("name")=="calibrationMappedLower")
  12309. {
  12310. mappedLowerEdit->setText(node.attribute("value"));
  12311. }
  12312. else if(node.attribute("name")=="calibrationMappedUpper")
  12313. {
  12314. mappedUpperEdit->setText(node.attribute("value"));
  12315. }
  12316. else if(node.attribute("name")=="calibrationClosedInterval")
  12317. {
  12318. closedBox->setChecked(node.attribute("value")=="true");
  12319. }
  12320. else if(node.attribute("name")=="calibrationSensitivity")
  12321. {
  12322. sensitivityEdit->setText(node.attribute("value"));
  12323. }
  12324. else if(node.attribute("name")=="hidden")
  12325. {
  12326. hideSeries->setChecked(node.attribute("value")=="true");
  12327. }
  12328. }
  12329. updateColumnName(columnEdit->text());
  12330. updateUnits(unitSelector->currentText());
  12331. updateSmoothingEnabled(smoothingBox->isChecked());
  12332. updateMeasuredLower(measuredLowerEdit->text());
  12333. updateMeasuredUpper(measuredUpperEdit->text());
  12334. updateMappedLower(mappedLowerEdit->text());
  12335. updateMappedUpper(mappedUpperEdit->text());
  12336. updateClosedInterval(closedBox->isChecked());
  12337. updateSensitivity(sensitivityEdit->text());
  12338. updateHidden(hideSeries->isChecked());
  12339. connect(columnEdit,SIGNAL(textChanged(QString)),
  12340. this,SLOT(updateColumnName(QString)));
  12341. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),
  12342. this,SLOT(updateUnits(QString)));
  12343. connect(smoothingBox,SIGNAL(toggled(bool)),
  12344. this,SLOT(updateSmoothingEnabled(bool)));
  12345. connect(measuredLowerEdit,SIGNAL(textChanged(QString)),
  12346. this,SLOT(updateMeasuredLower(QString)));
  12347. connect(mappedLowerEdit,SIGNAL(textChanged(QString)),
  12348. this,SLOT(updateMappedLower(QString)));
  12349. connect(measuredUpperEdit,SIGNAL(textChanged(QString)),
  12350. this,SLOT(updateMeasuredUpper(QString)));
  12351. connect(mappedUpperEdit,SIGNAL(textChanged(QString)),
  12352. this,SLOT(updateMappedUpper(QString)));
  12353. connect(closedBox,SIGNAL(toggled(bool)),
  12354. this,SLOT(updateClosedInterval(bool)));
  12355. connect(sensitivityEdit,SIGNAL(textChanged(QString)),
  12356. this,SLOT(updateSensitivity(QString)));
  12357. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12358. setLayout(layout);
  12359. }
  12360. /*:1074*//*1075:*/
  12361. #line 1038 "./dataqsdk.w"
  12362. void DataqSdkChannelConfWidget::updateUnits(const QString&unit)
  12363. {
  12364. updateAttribute("type",unit);
  12365. }
  12366. /*:1075*//*1076:*/
  12367. #line 1047 "./dataqsdk.w"
  12368. void DataqSdkChannelConfWidget::updateMeasuredLower(const QString&value)
  12369. {
  12370. updateAttribute("calibrationMeasuredLower",value);
  12371. calibrator->setMeasuredLower(value.toDouble());
  12372. }
  12373. void DataqSdkChannelConfWidget::updateMeasuredUpper(const QString&value)
  12374. {
  12375. updateAttribute("calibrationMeasuredUpper",value);
  12376. calibrator->setMeasuredUpper(value.toDouble());
  12377. }
  12378. void DataqSdkChannelConfWidget::updateMappedLower(const QString&value)
  12379. {
  12380. updateAttribute("calibrationMappedLower",value);
  12381. calibrator->setMappedLower(value.toDouble());
  12382. }
  12383. void DataqSdkChannelConfWidget::updateMappedUpper(const QString&value)
  12384. {
  12385. updateAttribute("calibrationMappedUpper",value);
  12386. calibrator->setMappedUpper(value.toDouble());
  12387. }
  12388. void DataqSdkChannelConfWidget::updateClosedInterval(bool closed)
  12389. {
  12390. updateAttribute("calibrationClosedInterval",closed?"true":"false");
  12391. calibrator->setClosedRange(closed);
  12392. }
  12393. void DataqSdkChannelConfWidget::updateSmoothingEnabled(bool enabled)
  12394. {
  12395. updateAttribute("smoothing",enabled?"true":"false");
  12396. }
  12397. void DataqSdkChannelConfWidget::updateSensitivity(const QString&value)
  12398. {
  12399. updateAttribute("calibrationSensitivity",value);
  12400. calibrator->setSensitivity(value.toDouble());
  12401. }
  12402. void DataqSdkChannelConfWidget::updateHidden(bool hidden)
  12403. {
  12404. updateAttribute("hidden",hidden?"true":"false");
  12405. }
  12406. /*:1076*//*1079:*/
  12407. #line 1136 "./dataqsdk.w"
  12408. void DataqSdkChannelConfWidget::startCalibration()
  12409. {
  12410. startButton->setEnabled(false);
  12411. stopButton->setEnabled(true);
  12412. resetButton->setEnabled(true);
  12413. calibrationDevice= new DataqSdkDevice(deviceID);
  12414. Channel*channel;
  12415. for(unsigned int i= 0;i<=channelOfInterest;i++)
  12416. {
  12417. channel= calibrationDevice->newChannel(Units::Unitless);
  12418. }
  12419. connect(channel,SIGNAL(newData(Measurement)),this,SLOT(updateInput(Measurement)));
  12420. connect(channel,SIGNAL(newData(Measurement)),calibrator,SLOT(newMeasurement(Measurement)));
  12421. connect(calibrator,SIGNAL(newData(Measurement)),this,SLOT(updateOutput(Measurement)));
  12422. calibrationDevice->setClockRate(6.0/(1.0+channelOfInterest));
  12423. calibrationDevice->start();
  12424. }
  12425. void DataqSdkChannelConfWidget::stopCalibration()
  12426. {
  12427. startButton->setEnabled(true);
  12428. stopButton->setEnabled(false);
  12429. resetButton->setEnabled(false);
  12430. calibrationDevice->deleteLater();
  12431. /*1081:*/
  12432. #line 1181 "./dataqsdk.w"
  12433. rmCount= 0;
  12434. cmCount= 0;
  12435. rmin= std::numeric_limits<double> ::max();
  12436. rmax= std::numeric_limits<double> ::min();
  12437. rmean= 0;
  12438. cmin= std::numeric_limits<double> ::max();
  12439. cmax= std::numeric_limits<double> ::min();
  12440. cmean= 0;
  12441. /*:1081*/
  12442. #line 1161 "./dataqsdk.w"
  12443. }
  12444. /*:1079*//*1080:*/
  12445. #line 1172 "./dataqsdk.w"
  12446. void DataqSdkChannelConfWidget::resetCalibration()
  12447. {
  12448. /*1081:*/
  12449. #line 1181 "./dataqsdk.w"
  12450. rmCount= 0;
  12451. cmCount= 0;
  12452. rmin= std::numeric_limits<double> ::max();
  12453. rmax= std::numeric_limits<double> ::min();
  12454. rmean= 0;
  12455. cmin= std::numeric_limits<double> ::max();
  12456. cmax= std::numeric_limits<double> ::min();
  12457. cmean= 0;
  12458. /*:1081*/
  12459. #line 1175 "./dataqsdk.w"
  12460. }
  12461. /*:1080*//*1082:*/
  12462. #line 1195 "./dataqsdk.w"
  12463. void DataqSdkChannelConfWidget::updateInput(Measurement measure)
  12464. {
  12465. double nv= measure.temperature();
  12466. currentMeasurement->setText(QString("%1").arg(nv));
  12467. rmin= qMin(nv,rmin);
  12468. minimumMeasurement->setText(QString("%1").arg(rmin));
  12469. rmax= qMax(nv,rmax);
  12470. maximumMeasurement->setText(QString("%1").arg(rmax));
  12471. rmean= ((rmean*rmCount)+nv)/(rmCount+1);
  12472. rmCount++;
  12473. averageMeasurement->setText(QString("%1").arg(rmean));
  12474. }
  12475. void DataqSdkChannelConfWidget::updateOutput(Measurement measure)
  12476. {
  12477. double nv= measure.temperature();
  12478. currentMapped->setText(QString("%1").arg(nv));
  12479. cmin= qMin(nv,cmin);
  12480. minimumMapped->setText(QString("%1").arg(cmin));
  12481. cmax= qMax(nv,cmax);
  12482. maximumMapped->setText(QString("%1").arg(cmax));
  12483. cmean= ((cmean*cmCount)+nv)/(cmCount+1);
  12484. cmCount++;
  12485. averageMapped->setText(QString("%1").arg(cmean));
  12486. }
  12487. /*:1082*//*1083:*/
  12488. #line 1224 "./dataqsdk.w"
  12489. void DataqSdkChannelConfWidget::updateColumnName(const QString&value)
  12490. {
  12491. updateAttribute("column",value);
  12492. }
  12493. /*:1083*/
  12494. #line 611 "./typica.w"
  12495. /*1107:*/
  12496. #line 423 "./scales.w"
  12497. SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel*model,
  12498. const QModelIndex&index)
  12499. :BasicDeviceConfigurationWidget(model,index),
  12500. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  12501. flow(new FlowSelector),stop(new StopSelector),
  12502. weighcommand(new QLineEdit("!KP")),commandterminator(new QComboBox)
  12503. {
  12504. QFormLayout*layout= new QFormLayout;
  12505. layout->addRow(tr("Port:"),port);
  12506. connect(port,SIGNAL(currentIndexChanged(QString)),
  12507. this,SLOT(updatePort(QString)));
  12508. connect(port,SIGNAL(editTextChanged(QString)),
  12509. this,SLOT(updatePort(QString)));
  12510. layout->addRow(tr("Baud:"),baud);
  12511. connect(baud,SIGNAL(currentIndexChanged(QString)),
  12512. this,SLOT(updateBaudRate(QString)));
  12513. layout->addRow(tr("Parity:"),parity);
  12514. connect(parity,SIGNAL(currentIndexChanged(int)),
  12515. this,SLOT(updateParity(int)));
  12516. layout->addRow(tr("Flow Control:"),flow);
  12517. connect(flow,SIGNAL(currentIndexChanged(int)),
  12518. this,SLOT(updateFlowControl(int)));
  12519. layout->addRow(tr("Stop Bits:"),stop);
  12520. connect(stop,SIGNAL(currentIndexChanged(int)),
  12521. this,SLOT(updateStopBits(int)));
  12522. layout->addRow(tr("Weigh Command:"),weighcommand);
  12523. connect(weighcommand,SIGNAL(textChanged(QString)),
  12524. this,SLOT(updateWeighCommand(QString)));
  12525. commandterminator->addItem("CRLF");
  12526. commandterminator->addItem("CR");
  12527. commandterminator->addItem("LF");
  12528. layout->addRow(tr("Command Terminator:"),commandterminator);
  12529. connect(commandterminator,SIGNAL(currentIndexChanged(QString)),
  12530. this,SLOT(updateCommandTerminator(QString)));
  12531. /*801:*/
  12532. #line 16651 "./typica.w"
  12533. QDomElement referenceElement=
  12534. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12535. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12536. QDomElement node;
  12537. /*:801*/
  12538. #line 459 "./scales.w"
  12539. for(int i= 0;i<configData.size();i++)
  12540. {
  12541. node= configData.at(i).toElement();
  12542. if(node.attribute("name")=="port")
  12543. {
  12544. int j= port->findText(node.attribute("value"));
  12545. if(j>=0)
  12546. {
  12547. port->setCurrentIndex(j);
  12548. }
  12549. else
  12550. {
  12551. port->insertItem(0,node.attribute("value"));
  12552. port->setCurrentIndex(0);
  12553. }
  12554. }
  12555. else if(node.attribute("name")=="baudrate")
  12556. {
  12557. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12558. }
  12559. else if(node.attribute("name")=="parity")
  12560. {
  12561. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  12562. }
  12563. else if(node.attribute("name")=="flowcontrol")
  12564. {
  12565. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  12566. }
  12567. else if(node.attribute("name")=="stopbits")
  12568. {
  12569. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  12570. }
  12571. else if(node.attribute("name")=="weighcommand")
  12572. {
  12573. weighcommand->setText(node.attribute("value"));
  12574. }
  12575. else if(node.attribute("name")=="commandterminator")
  12576. {
  12577. commandterminator->setCurrentIndex(
  12578. commandterminator->findText(node.attribute("value")));
  12579. }
  12580. }
  12581. updatePort(port->currentText());
  12582. updateBaudRate(baud->currentText());
  12583. updateParity(parity->currentIndex());
  12584. updateFlowControl(flow->currentIndex());
  12585. updateStopBits(stop->currentIndex());
  12586. updateWeighCommand(weighcommand->text());
  12587. updateCommandTerminator(commandterminator->currentText());
  12588. setLayout(layout);
  12589. }
  12590. /*:1107*//*1108:*/
  12591. #line 514 "./scales.w"
  12592. void SerialScaleConfWidget::updatePort(const QString&newPort)
  12593. {
  12594. updateAttribute("port",newPort);
  12595. }
  12596. void SerialScaleConfWidget::updateBaudRate(const QString&rate)
  12597. {
  12598. updateAttribute("baudrate",rate);
  12599. }
  12600. void SerialScaleConfWidget::updateParity(int index)
  12601. {
  12602. updateAttribute("parity",parity->itemData(index).toString());
  12603. }
  12604. void SerialScaleConfWidget::updateFlowControl(int index)
  12605. {
  12606. updateAttribute("flowcontrol",flow->itemData(index).toString());
  12607. }
  12608. void SerialScaleConfWidget::updateStopBits(int index)
  12609. {
  12610. updateAttribute("stopbits",stop->itemData(index).toString());
  12611. }
  12612. void SerialScaleConfWidget::updateWeighCommand(const QString&command)
  12613. {
  12614. updateAttribute("weighcommand",command);
  12615. }
  12616. void SerialScaleConfWidget::updateCommandTerminator(const QString&terminator)
  12617. {
  12618. updateAttribute("commandterminator",terminator);
  12619. }
  12620. /*:1108*/
  12621. #line 612 "./typica.w"
  12622. /*1120:*/
  12623. #line 195 "./valueannotation.w"
  12624. void ValueAnnotation::newMeasurement(Measurement measure)
  12625. {
  12626. for(int i= 0;i<values.size();i++)
  12627. {
  12628. if(measure.temperature()> values.at(i)-tolerance&&
  12629. measure.temperature()<values.at(i)+tolerance)
  12630. {
  12631. if(i!=lastIndex)
  12632. {
  12633. lastIndex= i;
  12634. emit annotation(annotations.at(i),measurementColumn,annotationColumn);
  12635. }
  12636. }
  12637. }
  12638. }
  12639. /*:1120*//*1121:*/
  12640. #line 216 "./valueannotation.w"
  12641. void ValueAnnotation::annotate()
  12642. {
  12643. if(lastIndex> -1)
  12644. {
  12645. emit annotation(annotations.at(lastIndex),measurementColumn,annotationColumn);
  12646. }
  12647. }
  12648. /*:1121*//*1122:*/
  12649. #line 228 "./valueannotation.w"
  12650. void ValueAnnotation::setAnnotation(double value,const QString&annotation)
  12651. {
  12652. values.append(value);
  12653. annotations.append(annotation);
  12654. }
  12655. /*:1122*//*1123:*/
  12656. #line 237 "./valueannotation.w"
  12657. void ValueAnnotation::setAnnotationColumn(int column)
  12658. {
  12659. annotationColumn= column;
  12660. }
  12661. void ValueAnnotation::setTemperatureColumn(int column)
  12662. {
  12663. measurementColumn= column;
  12664. }
  12665. void ValueAnnotation::setTolerance(double epsilon)
  12666. {
  12667. tolerance= epsilon;
  12668. }
  12669. /*:1123*//*1124:*/
  12670. #line 255 "./valueannotation.w"
  12671. ValueAnnotation::ValueAnnotation():QObject(),
  12672. lastIndex(-1),annotationColumn(2),measurementColumn(1),tolerance(0.05)
  12673. {
  12674. }
  12675. /*:1124*/
  12676. #line 613 "./typica.w"
  12677. /*1112:*/
  12678. #line 33 "./valueannotation.w"
  12679. ValueAnnotationConfWidget::ValueAnnotationConfWidget(DeviceTreeModel*model,
  12680. const QModelIndex&index)
  12681. :BasicDeviceConfigurationWidget(model,index),
  12682. tablemodel(new SaltModel(2))
  12683. {
  12684. QFormLayout*layout= new QFormLayout;
  12685. QLineEdit*source= new QLineEdit;
  12686. layout->addRow(tr("Source column name:"),source);
  12687. QCheckBox*noteOnStart= new QCheckBox(tr("Produce Start State Annotation"));
  12688. noteOnStart->setChecked(true);
  12689. layout->addRow(noteOnStart);
  12690. tablemodel->setHeaderData(0,Qt::Horizontal,"Value");
  12691. tablemodel->setHeaderData(1,Qt::Horizontal,"Annotation");
  12692. QTableView*annotationTable= new QTableView;
  12693. annotationTable->setModel(tablemodel);
  12694. NumericDelegate*delegate= new NumericDelegate;
  12695. annotationTable->setItemDelegateForColumn(0,delegate);
  12696. layout->addRow(tr("Annotations for values:"),annotationTable);
  12697. /*801:*/
  12698. #line 16651 "./typica.w"
  12699. QDomElement referenceElement=
  12700. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12701. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12702. QDomElement node;
  12703. /*:801*/
  12704. #line 52 "./valueannotation.w"
  12705. for(int i= 0;i<configData.size();i++)
  12706. {
  12707. node= configData.at(i).toElement();
  12708. if(node.attribute("name")=="source")
  12709. {
  12710. source->setText(node.attribute("value"));
  12711. }
  12712. else if(node.attribute("name")=="emitOnStart")
  12713. {
  12714. noteOnStart->setChecked(node.attribute("value")=="true"?true:false);
  12715. }
  12716. else if(node.attribute("name")=="measuredValues")
  12717. {
  12718. /*996:*/
  12719. #line 19741 "./typica.w"
  12720. QString data= node.attribute("value");
  12721. if(data.length()> 3)
  12722. {
  12723. data.chop(2);
  12724. data= data.remove(0,2);
  12725. }
  12726. QStringList itemList= data.split(",");
  12727. /*:996*/
  12728. #line 66 "./valueannotation.w"
  12729. int column= 0;
  12730. /*997:*/
  12731. #line 19753 "./typica.w"
  12732. for(int j= 0;j<itemList.size();j++)
  12733. {
  12734. tablemodel->setData(tablemodel->index(j,column),
  12735. QVariant(itemList.at(j).toDouble()),
  12736. Qt::DisplayRole);
  12737. }
  12738. /*:997*/
  12739. #line 68 "./valueannotation.w"
  12740. }
  12741. else if(node.attribute("name")=="annotations")
  12742. {
  12743. /*1113:*/
  12744. #line 89 "./valueannotation.w"
  12745. QString data= node.attribute("value");
  12746. if(data.length()> 3)
  12747. {
  12748. data.chop(2);
  12749. data= data.remove(0,2);
  12750. }
  12751. QStringList itemList= data.split(",");
  12752. for(int i= 0;i<itemList.size();i++)
  12753. {
  12754. itemList[i]= itemList[i].simplified();
  12755. }
  12756. /*:1113*/
  12757. #line 72 "./valueannotation.w"
  12758. int column= 1;
  12759. /*1114:*/
  12760. #line 104 "./valueannotation.w"
  12761. for(int i= 0;i<itemList.size();i++)
  12762. {
  12763. tablemodel->setData(tablemodel->index(i,column),
  12764. QVariant(itemList.at(i)),
  12765. Qt::DisplayRole);
  12766. }
  12767. /*:1114*/
  12768. #line 74 "./valueannotation.w"
  12769. }
  12770. }
  12771. updateSourceColumn(source->text());
  12772. updateStart(noteOnStart->isChecked());
  12773. updateAnnotations();
  12774. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  12775. connect(noteOnStart,SIGNAL(toggled(bool)),this,SLOT(updateStart(bool)));
  12776. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateAnnotations()));
  12777. setLayout(layout);
  12778. }
  12779. /*:1112*//*1115:*/
  12780. #line 115 "./valueannotation.w"
  12781. void ValueAnnotationConfWidget::updateAnnotations()
  12782. {
  12783. updateAttribute("measuredValues",tablemodel->arrayLiteral(0,Qt::DisplayRole));
  12784. updateAttribute("annotations",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  12785. }
  12786. /*:1115*//*1116:*/
  12787. #line 125 "./valueannotation.w"
  12788. void ValueAnnotationConfWidget::updateSourceColumn(const QString&source)
  12789. {
  12790. updateAttribute("source",source);
  12791. }
  12792. void ValueAnnotationConfWidget::updateStart(bool noteOnStart)
  12793. {
  12794. updateAttribute("emitOnStart",noteOnStart?"true":"false");
  12795. }
  12796. /*:1116*/
  12797. #line 614 "./typica.w"
  12798. /*897:*/
  12799. #line 44 "./modbus.w"
  12800. ModbusNGConfWidget::ModbusNGConfWidget(DeviceTreeModel*model,const QModelIndex&index):
  12801. BasicDeviceConfigurationWidget(model,index),m_parity(new ParitySelector),
  12802. m_flow(new FlowSelector),m_stop(new StopSelector)
  12803. {
  12804. QFormLayout*layout= new QFormLayout;
  12805. PortSelector*port= new PortSelector;
  12806. BaudSelector*baud= new BaudSelector;
  12807. QPushButton*newInput= new QPushButton(tr("Add Input Channel"));
  12808. layout->addRow(QString(tr("Port:")),port);
  12809. layout->addRow(QString(tr("Baud rate:")),baud);
  12810. layout->addRow(QString(tr("Parity:")),m_parity);
  12811. layout->addRow(QString(tr("Flow control:")),m_flow);
  12812. layout->addRow(QString(tr("Stop bits:")),m_stop);
  12813. layout->addRow(newInput);
  12814. /*801:*/
  12815. #line 16651 "./typica.w"
  12816. QDomElement referenceElement=
  12817. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12818. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12819. QDomElement node;
  12820. /*:801*/
  12821. #line 60 "./modbus.w"
  12822. for(int i= 0;i<configData.size();i++)
  12823. {
  12824. node= configData.at(i).toElement();
  12825. if(node.attribute("name")=="port")
  12826. {
  12827. int idx= port->findText(node.attribute("value"));
  12828. if(idx>=0)
  12829. {
  12830. port->setCurrentIndex(idx);
  12831. }
  12832. else
  12833. {
  12834. port->addItem(node.attribute("value"));
  12835. }
  12836. }
  12837. else if(node.attribute("name")=="baud")
  12838. {
  12839. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  12840. }
  12841. else if(node.attribute("name")=="parity")
  12842. {
  12843. m_parity->setCurrentIndex(m_parity->findData(node.attribute("value")));
  12844. }
  12845. else if(node.attribute("name")=="flow")
  12846. {
  12847. m_flow->setCurrentIndex(m_flow->findData(node.attribute("value")));
  12848. }
  12849. else if(node.attribute("name")=="stop")
  12850. {
  12851. m_stop->setCurrentIndex(m_stop->findData(node.attribute("value")));
  12852. }
  12853. }
  12854. updatePort(port->currentText());
  12855. updateBaudRate(baud->currentText());
  12856. updateParity(m_parity->currentIndex());
  12857. updateFlowControl(m_flow->currentIndex());
  12858. updateStopBits(m_stop->currentIndex());
  12859. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  12860. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  12861. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  12862. connect(m_parity,SIGNAL(currentIndexChanged(int)),this,SLOT(updateParity(int)));
  12863. connect(m_flow,SIGNAL(currentIndexChanged(int)),
  12864. this,SLOT(updateFlowControl(int)));
  12865. connect(m_stop,SIGNAL(currentIndexChanged(int)),this,SLOT(updateStopBits(int)));
  12866. connect(newInput,SIGNAL(clicked()),this,SLOT(addInput()));
  12867. setLayout(layout);
  12868. }
  12869. void ModbusNGConfWidget::updatePort(const QString&value)
  12870. {
  12871. updateAttribute("port",value);
  12872. }
  12873. void ModbusNGConfWidget::updateBaudRate(const QString&value)
  12874. {
  12875. updateAttribute("baud",value);
  12876. }
  12877. void ModbusNGConfWidget::updateParity(int value)
  12878. {
  12879. updateAttribute("parity",m_parity->itemData(value).toString());
  12880. }
  12881. void ModbusNGConfWidget::updateFlowControl(int value)
  12882. {
  12883. updateAttribute("flow",m_flow->itemData(value).toString());
  12884. }
  12885. void ModbusNGConfWidget::updateStopBits(int value)
  12886. {
  12887. updateAttribute("stop",m_stop->itemData(value).toString());
  12888. }
  12889. void ModbusNGConfWidget::addInput()
  12890. {
  12891. insertChildNode(tr("Input"),"modbusnginput");
  12892. }
  12893. /*:897*//*899:*/
  12894. #line 164 "./modbus.w"
  12895. ModbusNGInputConfWidget::ModbusNGInputConfWidget(DeviceTreeModel*model,const QModelIndex&index):BasicDeviceConfigurationWidget(model,index)
  12896. {
  12897. QFormLayout*layout= new QFormLayout;
  12898. QSpinBox*station= new QSpinBox;
  12899. station->setMinimum(1);
  12900. station->setMaximum(247);
  12901. layout->addRow(tr("Station ID"),station);
  12902. QComboBox*function= new QComboBox;
  12903. function->addItem("3","3");
  12904. function->addItem("4","4");
  12905. function->setCurrentIndex(1);
  12906. layout->addRow(tr("Function"),function);
  12907. ShortHexSpinBox*address= new ShortHexSpinBox;
  12908. layout->addRow(tr("Address"),address);
  12909. QComboBox*format= new QComboBox;
  12910. format->addItem(tr("16 bits fixed point"),"16fixedint");
  12911. format->addItem(tr("32 bits floating point (High Low)"),"32floathl");
  12912. format->addItem(tr("32 bits floating point (Low High)"),"32floatlh");
  12913. layout->addRow(tr("Data format"),format);
  12914. QSpinBox*decimals= new QSpinBox;
  12915. decimals->setMinimum(0);
  12916. decimals->setMaximum(9);
  12917. layout->addRow(tr("Decimal places"),decimals);
  12918. QComboBox*unit= new QComboBox;
  12919. unit->addItem("Celsius","C");
  12920. unit->addItem("Fahrenheit","F");
  12921. unit->addItem("Control","Control");
  12922. unit->setCurrentIndex(1);
  12923. layout->addRow(tr("Unit"),unit);
  12924. QLineEdit*column= new QLineEdit;
  12925. layout->addRow(tr("Column name"),column);
  12926. QCheckBox*hidden= new QCheckBox(tr("Hide this channel"));
  12927. layout->addRow(hidden);
  12928. /*801:*/
  12929. #line 16651 "./typica.w"
  12930. QDomElement referenceElement=
  12931. model->referenceElement(model->data(index,Qt::UserRole).toString());
  12932. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  12933. QDomElement node;
  12934. /*:801*/
  12935. #line 199 "./modbus.w"
  12936. for(int i= 0;i<configData.size();i++)
  12937. {
  12938. node= configData.at(i).toElement();
  12939. if(node.attribute("name")=="station")
  12940. {
  12941. station->setValue(node.attribute("value").toInt());
  12942. }
  12943. else if(node.attribute("name")=="function")
  12944. {
  12945. function->setCurrentIndex(function->findText(node.attribute("value")));
  12946. }
  12947. else if(node.attribute("name")=="address")
  12948. {
  12949. address->setValue(node.attribute("value").toInt());
  12950. }
  12951. else if(node.attribute("name")=="format")
  12952. {
  12953. format->setCurrentIndex(format->findData(node.attribute("value")));
  12954. }
  12955. else if(node.attribute("name")=="decimals")
  12956. {
  12957. decimals->setValue(node.attribute("value").toInt());
  12958. }
  12959. else if(node.attribute("name")=="unit")
  12960. {
  12961. unit->setCurrentIndex(unit->findData(node.attribute("value")));
  12962. }
  12963. else if(node.attribute("name")=="column")
  12964. {
  12965. column->setText(node.attribute("value"));
  12966. }
  12967. else if(node.attribute("name")=="hidden")
  12968. {
  12969. hidden->setChecked(node.attribute("value")=="true"?true:false);
  12970. }
  12971. }
  12972. updateStation(station->value());
  12973. updateFunction(function->currentIndex());
  12974. updateAddress(address->value());
  12975. updateFormat(format->currentIndex());
  12976. updateDecimals(decimals->value());
  12977. updateUnit(unit->currentIndex());
  12978. updateColumnName(column->text());
  12979. updateHidden(hidden->isChecked());
  12980. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  12981. connect(function,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFunction(int)));
  12982. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  12983. connect(format,SIGNAL(currentIndexChanged(int)),this,SLOT(updateFormat(int)));
  12984. connect(decimals,SIGNAL(valueChanged(int)),this,SLOT(updateDecimals(int)));
  12985. connect(unit,SIGNAL(currentIndexChanged(int)),this,SLOT(updateUnit(int)));
  12986. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  12987. connect(hidden,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  12988. setLayout(layout);
  12989. }
  12990. void ModbusNGInputConfWidget::updateStation(int value)
  12991. {
  12992. updateAttribute("station",QString("%1").arg(value));
  12993. }
  12994. void ModbusNGInputConfWidget::updateFunction(int value)
  12995. {
  12996. updateAttribute("function",QString("%1").arg(value==0?"3":"4"));
  12997. }
  12998. void ModbusNGInputConfWidget::updateAddress(int value)
  12999. {
  13000. updateAttribute("address",QString("%1").arg(value));
  13001. }
  13002. void ModbusNGInputConfWidget::updateFormat(int value)
  13003. {
  13004. switch(value)
  13005. {
  13006. case 0:
  13007. updateAttribute("format","16fixedint");
  13008. break;
  13009. case 1:
  13010. updateAttribute("format","32floathl");
  13011. break;
  13012. case 2:
  13013. updateAttribute("format","32floatlh");
  13014. break;
  13015. }
  13016. }
  13017. void ModbusNGInputConfWidget::updateDecimals(int value)
  13018. {
  13019. updateAttribute("decimals",QString("%1").arg(value));
  13020. }
  13021. void ModbusNGInputConfWidget::updateUnit(int value)
  13022. {
  13023. switch(value)
  13024. {
  13025. case 0:
  13026. updateAttribute("unit","C");
  13027. break;
  13028. case 1:
  13029. updateAttribute("unit","F");
  13030. break;
  13031. case 2:
  13032. updateAttribute("unit","Control");
  13033. break;
  13034. }
  13035. }
  13036. void ModbusNGInputConfWidget::updateColumnName(const QString&value)
  13037. {
  13038. updateAttribute("column",value);
  13039. }
  13040. void ModbusNGInputConfWidget::updateHidden(bool value)
  13041. {
  13042. updateAttribute("hidden",value?"true":"false");
  13043. }
  13044. /*:899*//*904:*/
  13045. #line 403 "./modbus.w"
  13046. ModbusNG::ModbusNG(DeviceTreeModel*model,const QModelIndex&index):
  13047. QObject(NULL),messageDelayTimer(new QTimer),commTimeout(new QTimer),
  13048. rateLimiter(new QTimer),scanPosition(0),waiting(false)
  13049. {
  13050. QDomElement portReferenceElement=
  13051. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13052. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  13053. QDomElement node;
  13054. QVariantMap attributes;
  13055. for(int i= 0;i<portConfigData.size();i++)
  13056. {
  13057. node= portConfigData.at(i).toElement();
  13058. attributes.insert(node.attribute("name"),node.attribute("value"));
  13059. }
  13060. port= new QextSerialPort(attributes.value("port").toString(),
  13061. QextSerialPort::EventDriven);
  13062. port->setBaudRate((BaudRateType)(attributes.value("baud").toInt()));
  13063. port->setDataBits(DATA_8);
  13064. port->setParity((ParityType)attributes.value("parity").toInt());
  13065. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  13066. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  13067. delayTime= (int)(((double)(1)/(double)(attributes.value("baud").toInt()))*144000.0);
  13068. messageDelayTimer->setSingleShot(true);
  13069. commTimeout->setSingleShot(true);
  13070. rateLimiter->setSingleShot(true);
  13071. rateLimiter->setInterval(0);
  13072. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  13073. connect(commTimeout,SIGNAL(timeout()),this,SLOT(timeout()));
  13074. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  13075. connect(rateLimiter,SIGNAL(timeout()),this,SLOT(rateLimitTimeout()));
  13076. if(!port->open(QIODevice::ReadWrite))
  13077. {
  13078. qDebug()<<"Failed to open serial port";
  13079. }
  13080. for(int i= 0;i<model->rowCount(index);i++)
  13081. {
  13082. QModelIndex channelIndex= model->index(i,0,index);
  13083. QDomElement channelReferenceElement=
  13084. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13085. QDomNodeList channelConfigData=
  13086. channelReferenceElement.elementsByTagName("attribute");
  13087. QDomElement channelNode;
  13088. QVariantMap channelAttributes;
  13089. for(int j= 0;j<channelConfigData.size();j++)
  13090. {
  13091. channelNode= channelConfigData.at(j).toElement();
  13092. channelAttributes.insert(channelNode.attribute("name"),
  13093. channelNode.attribute("value"));
  13094. }
  13095. ModbusScanItem scanItem;
  13096. QString format= channelAttributes.value("format").toString();
  13097. if(format=="16fixedint")
  13098. {
  13099. scanItem.format= Int16;
  13100. }
  13101. else if(format=="32floathl")
  13102. {
  13103. scanItem.format= FloatHL;
  13104. }
  13105. else if(format=="32floatlh")
  13106. {
  13107. scanItem.format= FloatLH;
  13108. }
  13109. scanItem.request.append((char)channelAttributes.value("station").toInt());
  13110. scanItem.request.append((char)channelAttributes.value("function").toInt());
  13111. quint16 startAddress= (quint16)channelAttributes.value("address").toInt();
  13112. char*startAddressBytes= (char*)&startAddress;
  13113. scanItem.request.append(startAddressBytes[1]);
  13114. scanItem.request.append(startAddressBytes[0]);
  13115. scanItem.request.append((char)0x00);
  13116. if(scanItem.format==Int16)
  13117. {
  13118. scanItem.request.append((char)0x01);
  13119. }
  13120. else
  13121. {
  13122. scanItem.request.append((char)0x02);
  13123. }
  13124. quint16 crc= calculateCRC(scanItem.request);
  13125. char*crcBytes= (char*)&crc;
  13126. scanItem.request.append(crcBytes[0]);
  13127. scanItem.request.append(crcBytes[1]);
  13128. scanItem.decimalPosition= channelAttributes.value("decimals").toInt();
  13129. if(channelAttributes.value("unit").toString()=="C")
  13130. {
  13131. scanItem.unit= Units::Celsius;
  13132. channelTypeList.append("T");
  13133. }
  13134. else if(channelAttributes.value("unit").toString()=="F")
  13135. {
  13136. scanItem.unit= Units::Fahrenheit;
  13137. channelTypeList.append("T");
  13138. }
  13139. else
  13140. {
  13141. scanItem.unit= Units::Unitless;
  13142. channelTypeList.append("C");
  13143. }
  13144. scanList.append(scanItem);
  13145. lastMeasurement.append(0.0);
  13146. channels.append(new Channel);
  13147. channelNames.append(channelAttributes.value("column").toString());
  13148. hiddenStates.append(
  13149. channelAttributes.value("hidden").toString()=="true"?true:false);
  13150. channelLabels.append(model->data(channelIndex,0).toString());
  13151. }
  13152. messageDelayTimer->start();
  13153. }
  13154. ModbusNG::~ModbusNG()
  13155. {
  13156. commTimeout->stop();
  13157. messageDelayTimer->stop();
  13158. port->close();
  13159. }
  13160. void ModbusNG::sendNextMessage()
  13161. {
  13162. if(scanList.length()> 0&&!waiting)
  13163. {
  13164. port->write(scanList.at(scanPosition).request);
  13165. commTimeout->start(2000);
  13166. messageDelayTimer->start(delayTime);
  13167. waiting= true;
  13168. }
  13169. }
  13170. void ModbusNG::timeout()
  13171. {
  13172. qDebug()<<"Communications timeout.";
  13173. messageDelayTimer->start();
  13174. }
  13175. void ModbusNG::rateLimitTimeout()
  13176. {
  13177. messageDelayTimer->start();
  13178. }
  13179. void ModbusNG::dataAvailable()
  13180. {
  13181. if(messageDelayTimer->isActive())
  13182. {
  13183. messageDelayTimer->stop();
  13184. }
  13185. responseBuffer.append(port->readAll());
  13186. if(responseBuffer.size()<5)
  13187. {
  13188. return;
  13189. }
  13190. if(responseBuffer.size()<5+responseBuffer.at(2))
  13191. {
  13192. return;
  13193. }
  13194. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  13195. commTimeout->stop();
  13196. if(calculateCRC(responseBuffer)==0)
  13197. {
  13198. quint16 intresponse;
  13199. float floatresponse;
  13200. char*ibytes= (char*)&intresponse;
  13201. char*fbytes= (char*)&floatresponse;
  13202. double output;
  13203. switch(scanList.at(scanPosition).format)
  13204. {
  13205. case Int16:
  13206. ibytes[0]= responseBuffer.at(4);
  13207. ibytes[1]= responseBuffer.at(3);
  13208. output= intresponse;
  13209. for(int i= 0;i<scanList.at(scanPosition).decimalPosition;i++)
  13210. {
  13211. output/= 10;
  13212. }
  13213. break;
  13214. case FloatHL:
  13215. fbytes[0]= responseBuffer.at(4);
  13216. fbytes[1]= responseBuffer.at(3);
  13217. fbytes[2]= responseBuffer.at(6);
  13218. fbytes[3]= responseBuffer.at(5);
  13219. output= floatresponse;
  13220. break;
  13221. case FloatLH:
  13222. fbytes[0]= responseBuffer.at(6);
  13223. fbytes[1]= responseBuffer.at(5);
  13224. fbytes[2]= responseBuffer.at(4);
  13225. fbytes[3]= responseBuffer.at(3);
  13226. output= floatresponse;
  13227. break;
  13228. }
  13229. if(scanList.at(scanPosition).unit==Units::Celsius)
  13230. {
  13231. output= output*9.0/5.0+32.0;
  13232. }
  13233. scanList.at(scanPosition).lastValue= output;
  13234. }
  13235. else
  13236. {
  13237. qDebug()<<"CRC failed";
  13238. }
  13239. scanPosition= (scanPosition+1)%scanList.size();
  13240. if(scanPosition==0)
  13241. {
  13242. QTime time= QTime::currentTime();
  13243. bool doOutput= false;
  13244. for(int i= 0;i<scanList.size();i++)
  13245. {
  13246. if(scanList.at(i).lastValue!=lastMeasurement.at(i))
  13247. {
  13248. doOutput= true;
  13249. break;
  13250. }
  13251. }
  13252. if(doOutput)
  13253. {
  13254. for(int i= 0;i<scanList.size();i++)
  13255. {
  13256. lastMeasurement[i]= scanList.at(i).lastValue;
  13257. if(scanList.at(scanPosition).unit==Units::Unitless)
  13258. {
  13259. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Unitless));
  13260. }
  13261. else
  13262. {
  13263. channels.at(i)->input(Measurement(scanList.at(i).lastValue,time,Units::Fahrenheit));
  13264. }
  13265. }
  13266. }
  13267. }
  13268. responseBuffer.clear();
  13269. waiting= false;
  13270. if(scanPosition==0)
  13271. {
  13272. rateLimiter->start();
  13273. }
  13274. else
  13275. {
  13276. messageDelayTimer->start(delayTime);
  13277. }
  13278. }
  13279. quint16 ModbusNG::calculateCRC(QByteArray data)
  13280. {
  13281. quint16 retval= 0xFFFF;
  13282. int i= 0;
  13283. while(i<data.size())
  13284. {
  13285. retval^= 0x00FF&(quint16)data.at(i);
  13286. for(int j= 0;j<8;j++)
  13287. {
  13288. if(retval&1)
  13289. {
  13290. retval= (retval>>1)^0xA001;
  13291. }
  13292. else
  13293. {
  13294. retval>>= 1;
  13295. }
  13296. }
  13297. i++;
  13298. }
  13299. return retval;
  13300. }
  13301. int ModbusNG::channelCount()
  13302. {
  13303. return channels.size();
  13304. }
  13305. Channel*ModbusNG::getChannel(int channel)
  13306. {
  13307. return channels.at(channel);
  13308. }
  13309. QString ModbusNG::channelColumnName(int channel)
  13310. {
  13311. return channelNames.at(channel);
  13312. }
  13313. QString ModbusNG::channelIndicatorText(int channel)
  13314. {
  13315. return channelLabels.at(channel);
  13316. }
  13317. bool ModbusNG::isChannelHidden(int channel)
  13318. {
  13319. return hiddenStates.at(channel);
  13320. }
  13321. QString ModbusNG::channelType(int channel)
  13322. {
  13323. return channelTypeList.at(channel);
  13324. }
  13325. /*:904*/
  13326. #line 615 "./typica.w"
  13327. /*1129:*/
  13328. #line 33 "./thresholdannotation.w"
  13329. ThresholdAnnotationConfWidget::ThresholdAnnotationConfWidget(DeviceTreeModel*model,
  13330. const QModelIndex&index)
  13331. :BasicDeviceConfigurationWidget(model,index)
  13332. {
  13333. QFormLayout*layout= new QFormLayout;
  13334. QLineEdit*source= new QLineEdit;
  13335. layout->addRow(tr("Source column name:"),source);
  13336. QDoubleSpinBox*value= new QDoubleSpinBox;
  13337. value->setMinimum(-9999.99);
  13338. value->setMaximum(9999.99);
  13339. value->setDecimals(2);
  13340. layout->addRow(tr("Threshold value:"),value);
  13341. QComboBox*direction= new QComboBox;
  13342. direction->addItem(tr("Ascending"));
  13343. direction->addItem(tr("Descending"));
  13344. layout->addRow(tr("Direction:"),direction);
  13345. QLineEdit*annotation= new QLineEdit;
  13346. layout->addRow(tr("Annotation:"),annotation);
  13347. /*801:*/
  13348. #line 16651 "./typica.w"
  13349. QDomElement referenceElement=
  13350. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13351. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13352. QDomElement node;
  13353. /*:801*/
  13354. #line 52 "./thresholdannotation.w"
  13355. for(int i= 0;i<configData.size();i++)
  13356. {
  13357. node= configData.at(i).toElement();
  13358. if(node.attribute("name")=="source")
  13359. {
  13360. source->setText(node.attribute("value"));
  13361. }
  13362. else if(node.attribute("name")=="value")
  13363. {
  13364. value->setValue(node.attribute("value").toDouble());
  13365. }
  13366. else if(node.attribute("name")=="direction")
  13367. {
  13368. direction->setCurrentIndex(node.attribute("value").toInt());
  13369. }
  13370. else if(node.attribute("name")=="annotation")
  13371. {
  13372. annotation->setText(node.attribute("value"));
  13373. }
  13374. }
  13375. updateSourceColumn(source->text());
  13376. updateThreshold(value->value());
  13377. updateDirection(direction->currentIndex());
  13378. updateAnnotation(annotation->text());
  13379. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  13380. connect(value,SIGNAL(valueChanged(double)),this,SLOT(updateThreshold(double)));
  13381. connect(direction,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDirection(int)));
  13382. connect(annotation,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotation(QString)));
  13383. setLayout(layout);
  13384. }
  13385. /*:1129*//*1130:*/
  13386. #line 86 "./thresholdannotation.w"
  13387. void ThresholdAnnotationConfWidget::updateSourceColumn(const QString&source)
  13388. {
  13389. updateAttribute("source",source);
  13390. }
  13391. void ThresholdAnnotationConfWidget::updateThreshold(double value)
  13392. {
  13393. updateAttribute("value",QString("%1").arg(value));
  13394. }
  13395. void ThresholdAnnotationConfWidget::updateDirection(int direction)
  13396. {
  13397. updateAttribute("direction",QString("%1").arg(direction));
  13398. }
  13399. void ThresholdAnnotationConfWidget::updateAnnotation(const QString&annotation)
  13400. {
  13401. updateAttribute("annotation",annotation);
  13402. }
  13403. /*:1130*/
  13404. #line 616 "./typica.w"
  13405. /*1134:*/
  13406. #line 152 "./thresholdannotation.w"
  13407. Annotator::Annotator(const QString&text):QObject(NULL),note(text)
  13408. {
  13409. t.setInterval(0);
  13410. t.setSingleShot(true);
  13411. connect(&t,SIGNAL(timeout()),this,SLOT(catchTimer()));
  13412. }
  13413. void Annotator::setAnnotation(const QString&annotation)
  13414. {
  13415. note= annotation;
  13416. }
  13417. void Annotator::setTemperatureColumn(int tempcolumn)
  13418. {
  13419. tc= tempcolumn;
  13420. }
  13421. void Annotator::setAnnotationColumn(int annotationcolumn)
  13422. {
  13423. ac= annotationcolumn;
  13424. }
  13425. /*:1134*//*1135:*/
  13426. #line 181 "./thresholdannotation.w"
  13427. void Annotator::catchTimer()
  13428. {
  13429. emit annotation(note,tc,ac);
  13430. }
  13431. void Annotator::annotate()
  13432. {
  13433. t.start();
  13434. }
  13435. /*:1135*/
  13436. #line 617 "./typica.w"
  13437. /*:4*//*260:*/
  13438. #line 6166 "./typica.w"
  13439. /*257:*/
  13440. #line 6129 "./typica.w"
  13441. void ScriptValidator::fixup(QString&input)const
  13442. {
  13443. QScriptEngine*engine= AppInstance->engine;
  13444. engine->pushContext();
  13445. input= engine->evaluate(input).toString();
  13446. engine->popContext();
  13447. }
  13448. /*:257*//*258:*/
  13449. #line 6142 "./typica.w"
  13450. QValidator::State ScriptValidator::validate(QString&input,int&pos)const
  13451. {
  13452. if(v)
  13453. {
  13454. if(v->validate(input,pos)==QValidator::Acceptable)
  13455. {
  13456. return QValidator::Acceptable;
  13457. }
  13458. }
  13459. return QValidator::Intermediate;
  13460. }
  13461. /*:258*//*259:*/
  13462. #line 6157 "./typica.w"
  13463. ScriptValidator::ScriptValidator(QValidator*validator,QObject*parent)
  13464. :QValidator(parent),v(validator)
  13465. {
  13466. }
  13467. /*:259*/
  13468. #line 6167 "./typica.w"
  13469. /*:260*//*694:*/
  13470. #line 160 "./plugins.w"
  13471. /*691:*/
  13472. #line 92 "./plugins.w"
  13473. PluginAction::PluginAction(const QFileInfo&info,QObject*parent):
  13474. QAction(parent),preRunScript(""),postRunScript("")
  13475. {
  13476. pluginFile= info.absoluteFilePath();
  13477. setText(info.baseName());
  13478. connect(this,SIGNAL(triggered()),this,SLOT(runScript()));
  13479. }
  13480. void PluginAction::runScript()
  13481. {
  13482. QFile file(pluginFile);
  13483. if(file.open(QIODevice::ReadOnly))
  13484. {
  13485. QScriptEngine*engine= AppInstance->engine;
  13486. QScriptContext*context= engine->pushContext();
  13487. if(parent()->dynamicPropertyNames().contains("activationObject"))
  13488. {
  13489. QScriptValue activationObject=
  13490. parent()->property("activationObject").value<QScriptValue> ();
  13491. context->setActivationObject(activationObject);
  13492. }
  13493. QString script(file.readAll());
  13494. QScriptValue retval= engine->evaluate(preRunScript+script+postRunScript,pluginFile);
  13495. if(engine->hasUncaughtException())
  13496. {
  13497. qDebug()<<"Uncaught exception: "<<
  13498. engine->uncaughtException().toString()<<
  13499. " in "<<pluginFile<<" line: "<<
  13500. engine->uncaughtExceptionLineNumber();
  13501. }
  13502. engine->popContext();
  13503. file.close();
  13504. }
  13505. }
  13506. /*:691*//*692:*/
  13507. #line 131 "./plugins.w"
  13508. QString PluginAction::preRun()
  13509. {
  13510. return preRunScript;
  13511. }
  13512. QString PluginAction::postRun()
  13513. {
  13514. return postRunScript;
  13515. }
  13516. void PluginAction::setPreRun(const QString&script)
  13517. {
  13518. preRunScript= script;
  13519. }
  13520. void PluginAction::setPostRun(const QString&script)
  13521. {
  13522. postRunScript= script;
  13523. }
  13524. /*:692*/
  13525. #line 161 "./plugins.w"
  13526. #line 14612 "./typica.w"
  13527. #line 1 "./daterangeselector.w"
  13528. /*:694*//*875:*/
  13529. #line 60 "./advancedsettings.w"
  13530. /*873:*/
  13531. #line 26 "./advancedsettings.w"
  13532. AdvancedSettingsWidget::AdvancedSettingsWidget():QWidget(NULL)
  13533. {
  13534. QSettings settings;
  13535. QFormLayout*layout= new QFormLayout;
  13536. QCheckBox*logDiagnostics= new QCheckBox;
  13537. logDiagnostics->setCheckState(
  13538. settings.value("settings/advanced/logging",false).toBool()?
  13539. Qt::Checked:Qt::Unchecked);
  13540. connect(logDiagnostics,SIGNAL(toggled(bool)),this,SLOT(enableDiagnosticLogging(bool)));
  13541. layout->addRow(tr("Enable diagnostic logging"),logDiagnostics);
  13542. setLayout(layout);
  13543. }
  13544. /*:873*//*874:*/
  13545. #line 43 "./advancedsettings.w"
  13546. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  13547. {
  13548. QSettings settings;
  13549. settings.setValue("settings/advanced/logging",enabled);
  13550. if(enabled)
  13551. {
  13552. qInstallMsgHandler(messageFileOutput);
  13553. }
  13554. else
  13555. {
  13556. qInstallMsgHandler(0);
  13557. }
  13558. }
  13559. /*:874*/
  13560. #line 61 "./advancedsettings.w"
  13561. #line 18415 "./typica.w"
  13562. /*:875*//*934:*/
  13563. #line 639 "./unsupportedserial.w"
  13564. /*909:*/
  13565. #line 58 "./unsupportedserial.w"
  13566. UnsupportedSerialDeviceConfWidget::UnsupportedSerialDeviceConfWidget(DeviceTreeModel*model,
  13567. const QModelIndex&index)
  13568. :BasicDeviceConfigurationWidget(model,index),
  13569. deviceSettingsModel(new SaltModel(2)),
  13570. scriptEditor(new QTextEdit)
  13571. {
  13572. scriptEditor->setTabStopWidth(20);
  13573. QVBoxLayout*dummyLayout= new QVBoxLayout;
  13574. QTabWidget*central= new QTabWidget;
  13575. QWidget*deviceConfigurationWidget= new QWidget;
  13576. QVBoxLayout*deviceConfigurationLayout= new QVBoxLayout;
  13577. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13578. deviceConfigurationLayout->addWidget(addChannelButton);
  13579. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13580. QLabel*deviceSettingsLabel= new QLabel(tr("Device Settings:"));
  13581. deviceConfigurationLayout->addWidget(deviceSettingsLabel);
  13582. QTableView*deviceSettingsView= new QTableView;
  13583. deviceSettingsModel->setHeaderData(0,Qt::Horizontal,tr("Key"));
  13584. deviceSettingsModel->setHeaderData(1,Qt::Horizontal,tr("Value"));
  13585. deviceSettingsView->setModel(deviceSettingsModel);
  13586. deviceConfigurationLayout->addWidget(deviceSettingsView);
  13587. deviceConfigurationWidget->setLayout(deviceConfigurationLayout);
  13588. central->addTab(deviceConfigurationWidget,tr("Configuration"));
  13589. central->addTab(scriptEditor,tr("Script"));
  13590. dummyLayout->addWidget(central);
  13591. /*801:*/
  13592. #line 16651 "./typica.w"
  13593. QDomElement referenceElement=
  13594. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13595. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13596. QDomElement node;
  13597. /*:801*/
  13598. #line 86 "./unsupportedserial.w"
  13599. for(int i= 0;i<configData.size();i++)
  13600. {
  13601. node= configData.at(i).toElement();
  13602. if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13603. {
  13604. int column= 0;
  13605. if(node.attribute("name")=="values")
  13606. {
  13607. column= 1;
  13608. }
  13609. QString data= node.attribute("value");
  13610. if(data.length()> 3)
  13611. {
  13612. data.chop(2);
  13613. data= data.remove(0,2);
  13614. }
  13615. QStringList keyList= data.split(", ");
  13616. for(int j= 0;j<keyList.size();j++)
  13617. {
  13618. deviceSettingsModel->setData(deviceSettingsModel->index(j,column),
  13619. QVariant(keyList.at(j)),
  13620. Qt::EditRole);
  13621. }
  13622. }
  13623. else if(node.attribute("name")=="script")
  13624. {
  13625. scriptEditor->setPlainText(node.attribute("value"));
  13626. }
  13627. }
  13628. connect(deviceSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13629. this,SLOT(updateConfiguration()));
  13630. connect(scriptEditor,SIGNAL(textChanged()),this,SLOT(saveScript()));
  13631. setLayout(dummyLayout);
  13632. }
  13633. /*:909*//*910:*/
  13634. #line 131 "./unsupportedserial.w"
  13635. void UnsupportedSerialDeviceConfWidget::updateConfiguration()
  13636. {
  13637. updateAttribute("keys",deviceSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13638. updateAttribute("values",deviceSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13639. }
  13640. /*:910*//*911:*/
  13641. #line 144 "./unsupportedserial.w"
  13642. void UnsupportedSerialDeviceConfWidget::saveScript()
  13643. {
  13644. updateAttribute("script",scriptEditor->toPlainText());
  13645. }
  13646. /*:911*//*912:*/
  13647. #line 155 "./unsupportedserial.w"
  13648. void UnsupportedSerialDeviceConfWidget::addChannel()
  13649. {
  13650. insertChildNode(tr("Channel"),"unsupporteddevicechannel");
  13651. }
  13652. /*:912*//*914:*/
  13653. #line 183 "./unsupportedserial.w"
  13654. UnsupportedDeviceChannelConfWidget::UnsupportedDeviceChannelConfWidget(DeviceTreeModel*model,
  13655. const QModelIndex&index)
  13656. :BasicDeviceConfigurationWidget(model,index),
  13657. channelSettingsModel(new SaltModel(2))
  13658. {
  13659. QFormLayout*layout= new QFormLayout;
  13660. QLineEdit*columnName= new QLineEdit;
  13661. layout->addRow(tr("Column Name:"),columnName);
  13662. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  13663. layout->addRow(hideSeries);
  13664. QTableView*channelSettings= new QTableView;
  13665. channelSettingsModel->setHeaderData(0,Qt::Horizontal,"Key");
  13666. channelSettingsModel->setHeaderData(1,Qt::Horizontal,"Value");
  13667. channelSettings->setModel(channelSettingsModel);
  13668. layout->addRow(channelSettings);
  13669. setLayout(layout);
  13670. /*801:*/
  13671. #line 16651 "./typica.w"
  13672. QDomElement referenceElement=
  13673. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13674. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13675. QDomElement node;
  13676. /*:801*/
  13677. #line 200 "./unsupportedserial.w"
  13678. for(int i= 0;i<configData.size();i++)
  13679. {
  13680. node= configData.at(i).toElement();
  13681. if(node.attribute("name")=="columnname")
  13682. {
  13683. columnName->setText(node.attribute("value"));
  13684. }
  13685. else if(node.attribute("name")=="hidden")
  13686. {
  13687. hideSeries->setChecked(node.attribute("value")=="true");
  13688. }
  13689. else if(node.attribute("name")=="keys"||node.attribute("name")=="values")
  13690. {
  13691. int column= 0;
  13692. if(node.attribute("name")=="values")
  13693. {
  13694. column= 1;
  13695. }
  13696. QString data= node.attribute("value");
  13697. if(data.length()> 3)
  13698. {
  13699. data.chop(2);
  13700. data= data.remove(0,2);
  13701. }
  13702. QStringList keyList= data.split(", ");
  13703. for(int j= 0;j<keyList.size();j++)
  13704. {
  13705. channelSettingsModel->setData(channelSettingsModel->index(j,column),
  13706. QVariant(keyList.at(j)),
  13707. Qt::EditRole);
  13708. }
  13709. }
  13710. }
  13711. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  13712. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  13713. connect(channelSettingsModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  13714. this,SLOT(updateConfiguration()));
  13715. }
  13716. /*:914*//*915:*/
  13717. #line 244 "./unsupportedserial.w"
  13718. void UnsupportedDeviceChannelConfWidget::updateColumnName(const QString&value)
  13719. {
  13720. updateAttribute("columnname",value);
  13721. }
  13722. void UnsupportedDeviceChannelConfWidget::updateHidden(bool hidden)
  13723. {
  13724. updateAttribute("hidden",hidden?"true":"false");
  13725. }
  13726. void UnsupportedDeviceChannelConfWidget::updateConfiguration()
  13727. {
  13728. updateAttribute("keys",channelSettingsModel->arrayLiteral(0,Qt::DisplayRole));
  13729. updateAttribute("values",channelSettingsModel->arrayLiteral(1,Qt::DisplayRole));
  13730. }
  13731. /*:915*/
  13732. #line 640 "./unsupportedserial.w"
  13733. /*922:*/
  13734. #line 371 "./unsupportedserial.w"
  13735. void JavaScriptDevice::start()
  13736. {
  13737. QScriptValue object= scriptengine->newQObject(this);
  13738. /*923:*/
  13739. #line 390 "./unsupportedserial.w"
  13740. QScriptValue settingsObject= scriptengine->newObject();
  13741. QVariantMap::const_iterator i= deviceSettings.constBegin();
  13742. while(i!=deviceSettings.constEnd())
  13743. {
  13744. settingsObject.setProperty(i.key(),i.value().toString());
  13745. i++;
  13746. }
  13747. object.setProperty("settings",settingsObject);
  13748. /*:923*/
  13749. #line 375 "./unsupportedserial.w"
  13750. /*924:*/
  13751. #line 405 "./unsupportedserial.w"
  13752. QScriptValue channelsArray= scriptengine->newArray(channelCount());
  13753. for(int i= 0;i<channelCount();i++)
  13754. {
  13755. QScriptValue channelObject= scriptengine->newQObject(getChannel(i));
  13756. QScriptValue channelSettingsObject= scriptengine->newObject();
  13757. QVariantMap::const_iterator j= channelSettings.at(i).constBegin();
  13758. while(j!=channelSettings.at(i).constEnd())
  13759. {
  13760. channelSettingsObject.setProperty(j.key(),j.value().toString());
  13761. j++;
  13762. }
  13763. channelObject.setProperty("settings",channelSettingsObject);
  13764. channelsArray.setProperty(i,channelObject);
  13765. }
  13766. object.setProperty("channels",channelsArray);
  13767. /*:924*/
  13768. #line 376 "./unsupportedserial.w"
  13769. QScriptContext*context= scriptengine->currentContext();
  13770. QScriptValue oldThis= context->thisObject();
  13771. context->setThisObject(object);
  13772. QScriptValue result= scriptengine->evaluate(deviceScript);
  13773. QScriptEngine*engine= scriptengine;
  13774. /*196:*/
  13775. #line 4562 "./typica.w"
  13776. if(engine->hasUncaughtException())
  13777. {
  13778. int line= engine->uncaughtExceptionLineNumber();
  13779. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  13780. result.toString();
  13781. QString trace;
  13782. foreach(trace,engine->uncaughtExceptionBacktrace())
  13783. {
  13784. qDebug()<<trace;
  13785. }
  13786. }
  13787. /*:196*/
  13788. #line 382 "./unsupportedserial.w"
  13789. context->setThisObject(oldThis);
  13790. }
  13791. /*:922*//*927:*/
  13792. #line 446 "./unsupportedserial.w"
  13793. void JavaScriptDevice::stop()
  13794. {
  13795. emit deviceStopRequested();
  13796. }
  13797. /*:927*//*928:*/
  13798. #line 459 "./unsupportedserial.w"
  13799. JavaScriptDevice::JavaScriptDevice(const QModelIndex&index,
  13800. QScriptEngine*engine):
  13801. QObject(NULL),scriptengine(engine)
  13802. {
  13803. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  13804. QDomElement deviceReferenceElement=
  13805. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13806. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  13807. QDomElement node;
  13808. QStringList deviceKeys;
  13809. QStringList deviceValues;
  13810. for(int i= 0;i<deviceConfigData.size();i++)
  13811. {
  13812. node= deviceConfigData.at(i).toElement();
  13813. if(node.attribute("name")=="keys")
  13814. {
  13815. QString data= node.attribute("value");
  13816. if(data.length()> 3)
  13817. {
  13818. data.chop(2);
  13819. data= data.remove(0,2);
  13820. }
  13821. deviceKeys= data.split(", ");
  13822. }
  13823. else if(node.attribute("name")=="values")
  13824. {
  13825. QString data= node.attribute("value");
  13826. if(data.length()> 3)
  13827. {
  13828. data.chop(2);
  13829. data= data.remove(0,2);
  13830. }
  13831. deviceValues= data.split(", ");
  13832. }
  13833. else if(node.attribute("name")=="script")
  13834. {
  13835. deviceScript= node.attribute("value");
  13836. }
  13837. deviceSettings.insert(node.attribute("name"),node.attribute("value"));
  13838. }
  13839. for(int i= 0;i<qMin(deviceKeys.length(),deviceValues.length());i++)
  13840. {
  13841. deviceSettings.insert(deviceKeys[i],deviceValues[i]);
  13842. }
  13843. if(model->hasChildren(index))
  13844. {
  13845. for(int i= 0;i<model->rowCount(index);i++)
  13846. {
  13847. QModelIndex channelIndex= model->index(i,0,index);
  13848. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  13849. channelList.append(new Channel);
  13850. QDomElement channelReferenceElement=
  13851. model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  13852. QDomNodeList channelConfigData=
  13853. channelReferenceElement.elementsByTagName("attribute");
  13854. QStringList channelKeys;
  13855. QStringList channelValues;
  13856. for(int j= 0;j<channelConfigData.size();j++)
  13857. {
  13858. node= channelConfigData.at(j).toElement();
  13859. if(node.attribute("name")=="keys")
  13860. {
  13861. QString data= node.attribute("value");
  13862. if(data.length()> 3)
  13863. {
  13864. data.chop(2);
  13865. data= data.remove(0,2);
  13866. }
  13867. channelKeys= data.split(", ");
  13868. }
  13869. else if(node.attribute("name")=="values")
  13870. {
  13871. QString data= node.attribute("value");
  13872. if(data.length()> 3)
  13873. {
  13874. data.chop(2);
  13875. data= data.remove(0,2);
  13876. }
  13877. channelValues= data.split(", ");
  13878. }
  13879. else if(node.attribute("name")=="hidden")
  13880. {
  13881. hiddenState.append(node.attribute("value")=="true");
  13882. }
  13883. else if(node.attribute("name")=="columnname")
  13884. {
  13885. columnNames.append(node.attribute("value"));
  13886. }
  13887. }
  13888. QVariantMap cs;
  13889. for(int j= 0;j<qMin(channelKeys.length(),channelValues.length());j++)
  13890. {
  13891. cs.insert(channelKeys[j],channelValues[j]);
  13892. }
  13893. channelSettings.append(cs);
  13894. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  13895. channelUnits.append(Units::Fahrenheit);
  13896. }
  13897. }
  13898. }
  13899. /*:928*//*929:*/
  13900. #line 564 "./unsupportedserial.w"
  13901. int JavaScriptDevice::channelCount()
  13902. {
  13903. return channelList.length();
  13904. }
  13905. Channel*JavaScriptDevice::getChannel(int channel)
  13906. {
  13907. return channelList.at(channel);
  13908. }
  13909. bool JavaScriptDevice::isChannelHidden(int channel)
  13910. {
  13911. return hiddenState.at(channel);
  13912. }
  13913. Units::Unit JavaScriptDevice::expectedChannelUnit(int channel)
  13914. {
  13915. return channelUnits.at(channel);
  13916. }
  13917. QString JavaScriptDevice::channelColumnName(int channel)
  13918. {
  13919. if(channel>=0&&channel<columnNames.length())
  13920. {
  13921. return columnNames.at(channel);
  13922. }
  13923. return QString();
  13924. }
  13925. QString JavaScriptDevice::channelIndicatorText(int channel)
  13926. {
  13927. return indicatorTexts.at(channel);
  13928. }
  13929. /*:929*//*930:*/
  13930. #line 601 "./unsupportedserial.w"
  13931. void JavaScriptDevice::setTemperatureColumn(int tcol)
  13932. {
  13933. annotationTemperatureColumn= tcol;
  13934. }
  13935. void JavaScriptDevice::setAnnotationColumn(int ncol)
  13936. {
  13937. annotationNoteColumn= ncol;
  13938. }
  13939. /*:930*/
  13940. #line 641 "./unsupportedserial.w"
  13941. /*:934*//*957:*/
  13942. #line 444 "./phidgets.w"
  13943. /*941:*/
  13944. #line 31 "./phidgets.w"
  13945. PhidgetsTemperatureSensorConfWidget::PhidgetsTemperatureSensorConfWidget(DeviceTreeModel*model,
  13946. const QModelIndex&index)
  13947. :BasicDeviceConfigurationWidget(model,index)
  13948. {
  13949. QFormLayout*layout= new QFormLayout;
  13950. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  13951. QSpinBox*sampleRate= new QSpinBox;
  13952. sampleRate->setMinimum(40);
  13953. sampleRate->setMaximum(600);
  13954. sampleRate->setSingleStep(40);
  13955. sampleRate->setValue(360);
  13956. /*801:*/
  13957. #line 16651 "./typica.w"
  13958. QDomElement referenceElement=
  13959. model->referenceElement(model->data(index,Qt::UserRole).toString());
  13960. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13961. QDomElement node;
  13962. /*:801*/
  13963. #line 44 "./phidgets.w"
  13964. for(int i= 0;i<configData.size();i++)
  13965. {
  13966. node= configData.at(i).toElement();
  13967. if(node.attribute("name")=="sampleRate")
  13968. {
  13969. sampleRate->setValue(node.attribute("value").toInt());
  13970. }
  13971. }
  13972. updateRate(sampleRate->value());
  13973. connect(sampleRate,SIGNAL(valueChanged(int)),this,SLOT(updateRate(int)));
  13974. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  13975. layout->addRow(addChannelButton);
  13976. layout->addRow(tr("Sample rate:"),sampleRate);
  13977. setLayout(layout);
  13978. }
  13979. /*:941*//*942:*/
  13980. #line 66 "./phidgets.w"
  13981. void PhidgetsTemperatureSensorConfWidget::addChannel()
  13982. {
  13983. insertChildNode(tr("Channel"),"phidgets1048channel");
  13984. }
  13985. /*:942*//*943:*/
  13986. #line 74 "./phidgets.w"
  13987. void PhidgetsTemperatureSensorConfWidget::updateRate(int ms)
  13988. {
  13989. updateAttribute("sampleRate",QString("%1").arg(ms));
  13990. }
  13991. /*:943*//*945:*/
  13992. #line 103 "./phidgets.w"
  13993. PhidgetTemperatureSensorChannelConfWidget::PhidgetTemperatureSensorChannelConfWidget(
  13994. DeviceTreeModel*model,const QModelIndex&index)
  13995. :BasicDeviceConfigurationWidget(model,index),
  13996. tcType(new QComboBox)
  13997. {
  13998. QFormLayout*layout= new QFormLayout;
  13999. QLineEdit*columnName= new QLineEdit;
  14000. layout->addRow(tr("Column Name:"),columnName);
  14001. QCheckBox*hideSeries= new QCheckBox("Hide this channel");
  14002. layout->addRow(hideSeries);
  14003. layout->addRow(tr("Thermocouple Type:"),tcType);
  14004. tcType->addItem("Type K","1");
  14005. tcType->addItem("Type J","2");
  14006. tcType->addItem("Type E","3");
  14007. tcType->addItem("Type T","4");
  14008. QSpinBox*channel= new QSpinBox;
  14009. layout->addRow(tr("Channel:"),channel);
  14010. channel->setMinimum(0);
  14011. channel->setMaximum(3);
  14012. setLayout(layout);
  14013. /*801:*/
  14014. #line 16651 "./typica.w"
  14015. QDomElement referenceElement=
  14016. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14017. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14018. QDomElement node;
  14019. /*:801*/
  14020. #line 124 "./phidgets.w"
  14021. for(int i= 0;i<configData.size();i++)
  14022. {
  14023. node= configData.at(i).toElement();
  14024. if(node.attribute("name")=="columnname")
  14025. {
  14026. columnName->setText(node.attribute("value"));
  14027. }
  14028. else if(node.attribute("name")=="hidden")
  14029. {
  14030. hideSeries->setChecked(node.attribute("value")=="true");
  14031. }
  14032. else if(node.attribute("name")=="tctype")
  14033. {
  14034. tcType->setCurrentIndex(tcType->findData(node.attribute("value")));
  14035. }
  14036. else if(node.attribute("name")=="channel")
  14037. {
  14038. channel->setValue(node.attribute("value").toInt());
  14039. }
  14040. }
  14041. updateColumnName(columnName->text());
  14042. updateHidden(hideSeries->isChecked());
  14043. updateTC(tcType->currentIndex());
  14044. updateChannel(channel->value());
  14045. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  14046. connect(hideSeries,SIGNAL(toggled(bool)),this,SLOT(updateHidden(bool)));
  14047. connect(tcType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTC(int)));
  14048. connect(channel,SIGNAL(valueChanged(int)),this,SLOT(updateChannel(int)));
  14049. }
  14050. /*:945*//*946:*/
  14051. #line 157 "./phidgets.w"
  14052. void PhidgetTemperatureSensorChannelConfWidget::updateColumnName(const QString&value)
  14053. {
  14054. updateAttribute("columnname",value);
  14055. }
  14056. void PhidgetTemperatureSensorChannelConfWidget::updateHidden(bool hidden)
  14057. {
  14058. updateAttribute("hidden",hidden?"true":"false");
  14059. }
  14060. void PhidgetTemperatureSensorChannelConfWidget::updateTC(int index)
  14061. {
  14062. updateAttribute("tctype",tcType->itemData(index).toString());
  14063. }
  14064. void PhidgetTemperatureSensorChannelConfWidget::updateChannel(int channel)
  14065. {
  14066. updateAttribute("channel",QString("%1").arg(channel));
  14067. }
  14068. /*:946*//*950:*/
  14069. #line 246 "./phidgets.w"
  14070. PhidgetsTemperatureSensor::PhidgetsTemperatureSensor(const QModelIndex&index)
  14071. :QObject(NULL),driver("phidget21"),device(NULL)
  14072. {
  14073. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14074. QDomElement deviceReferenceElement=
  14075. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14076. QDomNodeList deviceConfigData= deviceReferenceElement.elementsByTagName("attribute");
  14077. QDomElement node;
  14078. for(int i= 0;i<deviceConfigData.size();i++)
  14079. {
  14080. node= deviceConfigData.at(i).toElement();
  14081. if(node.attribute("name")=="sampleRate")
  14082. {
  14083. sampleTimer.setInterval(node.attribute("value").toInt());
  14084. }
  14085. }
  14086. if(model->hasChildren(index))
  14087. {
  14088. for(int i= 0;i<model->rowCount(index);i++)
  14089. {
  14090. QModelIndex channelIndex= model->index(i,0,index);
  14091. QDomElement channelReference= model->referenceElement(model->data(channelIndex,32).toString());
  14092. QDomElement channelReferenceElement= model->referenceElement(model->data(channelIndex,Qt::UserRole).toString());
  14093. QDomNodeList channelConfigData= channelReferenceElement.elementsByTagName("attribute");
  14094. for(int j= 0;j<channelConfigData.size();j++)
  14095. {
  14096. node= channelConfigData.at(j).toElement();
  14097. if(node.attribute("name")=="channel")
  14098. {
  14099. int channelID= node.attribute("value").toInt();
  14100. channelIndices.append(channelID);
  14101. Channel*channel= new Channel;
  14102. channelList.append(channel);
  14103. channelMap.insert(channelID,channel);
  14104. }
  14105. else if(node.attribute("name")=="hidden")
  14106. {
  14107. hiddenState.append(node.attribute("value")=="true");
  14108. }
  14109. else if(node.attribute("name")=="columnname")
  14110. {
  14111. columnNames.append(node.attribute("value"));
  14112. }
  14113. else if(node.attribute("name")=="tctype")
  14114. {
  14115. tctypes.append(node.attribute("value").toInt());
  14116. }
  14117. }
  14118. indicatorTexts.append(model->data(channelIndex,Qt::DisplayRole).toString());
  14119. }
  14120. }
  14121. }
  14122. /*:950*//*951:*/
  14123. #line 306 "./phidgets.w"
  14124. int PhidgetsTemperatureSensor::channelCount()
  14125. {
  14126. return channelList.length();
  14127. }
  14128. Channel*PhidgetsTemperatureSensor::getChannel(int channel)
  14129. {
  14130. return channelList.at(channel);
  14131. }
  14132. /*:951*//*952:*/
  14133. #line 319 "./phidgets.w"
  14134. bool PhidgetsTemperatureSensor::isChannelHidden(int channel)
  14135. {
  14136. return hiddenState.at(channel);
  14137. }
  14138. QString PhidgetsTemperatureSensor::channelColumnName(int channel)
  14139. {
  14140. if(channel>=0&&channel<columnNames.length())
  14141. {
  14142. return columnNames.at(channel);
  14143. }
  14144. return QString();
  14145. }
  14146. QString PhidgetsTemperatureSensor::channelIndicatorText(int channel)
  14147. {
  14148. if(channel>=0&&channel<indicatorTexts.length())
  14149. {
  14150. return indicatorTexts.at(channel);
  14151. }
  14152. return QString();
  14153. }
  14154. /*:952*//*954:*/
  14155. #line 371 "./phidgets.w"
  14156. void PhidgetsTemperatureSensor::start()
  14157. {
  14158. if(!driver.load())
  14159. {
  14160. driver.setFileName("Phidget21.framework/Phidget21");
  14161. if(!driver.load())
  14162. {
  14163. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14164. tr("Failed to find phidget21. Please install it."));
  14165. return;
  14166. }
  14167. }
  14168. if((createDevice= (PhidgetHandleOnly)driver.resolve("CPhidgetTemperatureSensor_create"))==0||
  14169. (openDevice= (PhidgetHandleInt)driver.resolve("CPhidget_open"))==0||
  14170. (waitForOpen= (PhidgetHandleInt)driver.resolve("CPhidget_waitForAttachment"))==0||
  14171. (setTCType= (PhidgetHandleIntInt)driver.resolve("CPhidgetTemperatureSensor_setThermocoupleType"))==0||
  14172. (getTemperature= (PhidgetHandleIntDoubleOut)driver.resolve("CPhidgetTemperatureSensor_getTemperature"))==0||
  14173. (closeDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_close"))==0||
  14174. (deleteDevice= (PhidgetHandleOnly)driver.resolve("CPhidget_delete"))==0)
  14175. {
  14176. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14177. tr("Failed to link a required symbol in phidget21."));
  14178. return;
  14179. }
  14180. createDevice(&device);
  14181. openDevice(device,-1);
  14182. int error;
  14183. if((error= waitForOpen(device,10000)))
  14184. {
  14185. closeDevice(device);
  14186. deleteDevice(device);
  14187. QMessageBox::critical(NULL,tr("Typica: Failed to Open Device"),
  14188. tr("CPhidget_waitForAttachment returns error %n",0,error));
  14189. return;
  14190. }
  14191. for(int i= 0;i<channelIndices.length();i++)
  14192. {
  14193. setTCType(device,channelIndices.at(i),tctypes.at(i));
  14194. }
  14195. connect(&sampleTimer,SIGNAL(timeout()),this,SLOT(getMeasurements()));
  14196. sampleTimer.start();
  14197. }
  14198. /*:954*//*955:*/
  14199. #line 418 "./phidgets.w"
  14200. void PhidgetsTemperatureSensor::getMeasurements()
  14201. {
  14202. double value= 0.0;
  14203. QTime time= QTime::currentTime();
  14204. foreach(int i,channelIndices)
  14205. {
  14206. getTemperature(device,i,&value);
  14207. Measurement measure(value*9.0/5.0+32.0,time);
  14208. channelMap[i]->input(measure);
  14209. }
  14210. }
  14211. /*:955*//*956:*/
  14212. #line 433 "./phidgets.w"
  14213. void PhidgetsTemperatureSensor::stop()
  14214. {
  14215. sampleTimer.stop();
  14216. closeDevice(device);
  14217. deleteDevice(device);
  14218. driver.unload();
  14219. }
  14220. /*:956*/
  14221. #line 445 "./phidgets.w"
  14222. /*:957*//*989:*/
  14223. #line 792 "./phidget22.w"
  14224. /*965:*/
  14225. #line 60 "./phidget22.w"
  14226. PhidgetConfWidget::PhidgetConfWidget(DeviceTreeModel*model,
  14227. const QModelIndex&index)
  14228. :BasicDeviceConfigurationWidget(model,index)
  14229. {
  14230. QHBoxLayout*layout= new QHBoxLayout;
  14231. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  14232. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  14233. layout->addWidget(addChannelButton);
  14234. setLayout(layout);
  14235. }
  14236. void PhidgetConfWidget::addChannel()
  14237. {
  14238. insertChildNode(tr("Channel"),"phidgetchannel");
  14239. }
  14240. /*:965*//*970:*/
  14241. #line 179 "./phidget22.w"
  14242. PhidgetChannelSelector::PhidgetChannelSelector():QComboBox(),manager(NULL)
  14243. {
  14244. #if __APPLE__
  14245. driver.setFileName("Phidget22.framework/Phidget22");
  14246. #else
  14247. driver.setFileName("phidget22");
  14248. #endif
  14249. if(!driver.load())
  14250. {
  14251. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14252. tr("Failed to find phidget22. Please install it."));
  14253. return;
  14254. }
  14255. /*969:*/
  14256. #line 157 "./phidget22.w"
  14257. if((createManager= (PhidgetPointer)driver.resolve("PhidgetManager_create"))==0||
  14258. (setOnAttachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnAttachHandler"))==0||
  14259. (setOnDetachManager= (PhidgetPointerCallbackPointer)driver.resolve("PhidgetManager_setOnDetachHandler"))==0||
  14260. (openManager= (PhidgetPointer)driver.resolve("PhidgetManager_open"))==0||
  14261. (getDeviceName= (PhidgetPointerStringOut)driver.resolve("Phidget_getDeviceName"))==0||
  14262. (getDeviceSerialNumber= (PhidgetPointerIntOut)driver.resolve("Phidget_getDeviceSerialNumber"))==0||
  14263. (getChannel= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannel"))==0||
  14264. (getChannelClass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelClass"))==0||
  14265. (getChannelSubclass= (PhidgetPointerIntOut)driver.resolve("Phidget_getChannelSubclass"))==0||
  14266. (getHubPort= (PhidgetPointerIntOut)driver.resolve("Phidget_getHubPort"))==0||
  14267. (closeManager= (PhidgetPointer)driver.resolve("PhidgetManager_close"))==0||
  14268. (deleteManager= (PhidgetPointer)driver.resolve("PhidgetManager_delete"))==0)
  14269. {
  14270. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14271. tr("Failed to link a required symbol in phidget22."));
  14272. return;
  14273. }
  14274. /*:969*/
  14275. #line 193 "./phidget22.w"
  14276. createManager(&manager);
  14277. setOnAttachManager(manager,ChannelListAddChannel,this);
  14278. setOnDetachManager(manager,ChannelListRemoveChannel,this);
  14279. openManager(manager);
  14280. }
  14281. /*:970*//*973:*/
  14282. #line 228 "./phidget22.w"
  14283. void PhidgetChannelSelector::addChannel(void*device)
  14284. {
  14285. char*deviceName;
  14286. int deviceSerialNumber;
  14287. int channel;
  14288. int channelClass;
  14289. int channelSubclass;
  14290. int hubPort;
  14291. getDeviceName(device,&deviceName);
  14292. getDeviceSerialNumber(device,&deviceSerialNumber);
  14293. getChannel(device,&channel);
  14294. getChannelClass(device,&channelClass);
  14295. getChannelSubclass(device,&channelSubclass);
  14296. getHubPort(device,&hubPort);
  14297. QMap<QString,QVariant> itemData;
  14298. if(channelClass==28)
  14299. {
  14300. itemData.insert("serialNumber",QString("%1").arg(deviceSerialNumber));
  14301. itemData.insert("channel",QString("%1").arg(channel));
  14302. itemData.insert("class",QString("%1").arg(channelClass));
  14303. itemData.insert("subclass",QString("%1").arg(channelSubclass));
  14304. itemData.insert("hubport",QString("%1").arg(hubPort));
  14305. addItem(QString("%1: %2").arg(deviceName).arg(channel),QVariant(itemData));
  14306. }
  14307. }
  14308. /*:973*//*974:*/
  14309. #line 266 "./phidget22.w"
  14310. void PhidgetChannelSelector::removeChannel(void*device)
  14311. {
  14312. int deviceSerialNumber;
  14313. getDeviceSerialNumber(device,&deviceSerialNumber);
  14314. for(int i= count()-1;i>=0;i--)
  14315. {
  14316. QMap<QString,QVariant> data= itemData(i).toMap();
  14317. if(data.value("serialNumber").toInt()==deviceSerialNumber)
  14318. {
  14319. removeItem(i);
  14320. }
  14321. }
  14322. }
  14323. /*:974*//*975:*/
  14324. #line 285 "./phidget22.w"
  14325. PhidgetChannelSelector::~PhidgetChannelSelector()
  14326. {
  14327. if(manager!=NULL)
  14328. {
  14329. closeManager(manager);
  14330. deleteManager(&manager);
  14331. }
  14332. }
  14333. /*:975*//*977:*/
  14334. #line 330 "./phidget22.w"
  14335. PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel*model,
  14336. const QModelIndex&index)
  14337. :BasicDeviceConfigurationWidget(model,index),
  14338. channelSelector(new PhidgetChannelSelector),
  14339. serialNumber(new QLineEdit),
  14340. channel(new QLineEdit),
  14341. hubPort(new QLineEdit),
  14342. subtype(new QComboBox),
  14343. subtypeLayout(new QStackedLayout),
  14344. tctype(new QComboBox),
  14345. rtdtype(new QComboBox),
  14346. rtdwiring(new QComboBox)
  14347. {
  14348. QVBoxLayout*outerLayout= new QVBoxLayout;
  14349. QFormLayout*layout= new QFormLayout;
  14350. QLineEdit*columnName= new QLineEdit;
  14351. subtype->addItem(tr("IC"),QVariant(1));
  14352. subtype->addItem(tr("RTD"),QVariant(32));
  14353. subtype->addItem(tr("Thermocouple"),QVariant(33));
  14354. layout->addRow(tr("Channels:"),channelSelector);
  14355. layout->addRow(tr("Column Name:"),columnName);
  14356. QCheckBox*hidden= new QCheckBox(tr("Hide channel"));
  14357. layout->addRow(hidden);
  14358. layout->addRow(tr("Serial Number:"),serialNumber);
  14359. layout->addRow(tr("Hub Port:"),hubPort);
  14360. layout->addRow(tr("Channel Number:"),channel);
  14361. layout->addRow(tr("Channel Type:"),subtype);
  14362. serialNumber->setEnabled(false);
  14363. channel->setEnabled(false);
  14364. subtype->setEnabled(false);
  14365. outerLayout->addLayout(layout);
  14366. QWidget*icconfiguration= new QWidget;
  14367. QWidget*rtdconfiguration= new QWidget;
  14368. QFormLayout*rtdconfigurationLayout= new QFormLayout;
  14369. rtdtype->addItem(tr("PT100 with .00385 curve"),QVariant(1));
  14370. rtdtype->addItem(tr("PT1000 with .00385 curve"),QVariant(2));
  14371. rtdtype->addItem(tr("PT100 with .00392 curve"),QVariant(3));
  14372. rtdtype->addItem(tr("PT1000 with .00392 curve"),QVariant(4));
  14373. rtdconfigurationLayout->addRow(tr("RTD type:"),rtdtype);
  14374. rtdwiring->addItem(tr("2 wire"),QVariant(1));
  14375. rtdwiring->addItem(tr("3 wire"),QVariant(2));
  14376. rtdwiring->addItem(tr("4 wire"),QVariant(3));
  14377. rtdconfigurationLayout->addRow(tr("RTD wiring:"),rtdwiring);
  14378. rtdconfiguration->setLayout(rtdconfigurationLayout);
  14379. QWidget*tcconfiguration= new QWidget;
  14380. QFormLayout*tcconfigurationLayout= new QFormLayout;
  14381. tctype->addItem(tr("Type J"),QVariant(1));
  14382. tctype->addItem(tr("Type K"),QVariant(2));
  14383. tctype->addItem(tr("Type E"),QVariant(3));
  14384. tctype->addItem(tr("Type T"),QVariant(4));
  14385. tcconfigurationLayout->addRow(tr("Thermocouple type:"),tctype);
  14386. tcconfiguration->setLayout(tcconfigurationLayout);
  14387. subtypeLayout->addWidget(icconfiguration);
  14388. subtypeLayout->addWidget(rtdconfiguration);
  14389. subtypeLayout->addWidget(tcconfiguration);
  14390. /*801:*/
  14391. #line 16651 "./typica.w"
  14392. QDomElement referenceElement=
  14393. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14394. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14395. QDomElement node;
  14396. /*:801*/
  14397. #line 387 "./phidget22.w"
  14398. for(int i= 0;i<configData.size();i++)
  14399. {
  14400. node= configData.at(i).toElement();
  14401. if(node.attribute("name")=="serialnumber")
  14402. {
  14403. serialNumber->setText(node.attribute("value"));
  14404. }
  14405. else if(node.attribute("name")=="channel")
  14406. {
  14407. channel->setText(node.attribute("value"));
  14408. }
  14409. else if(node.attribute("name")=="columnname")
  14410. {
  14411. columnName->setText(node.attribute("value"));
  14412. }
  14413. else if(node.attribute("name")=="channeltype")
  14414. {
  14415. subtype->setCurrentIndex(subtype->
  14416. findData(QVariant(node.attribute("value").toInt())));
  14417. subtypeLayout->setCurrentIndex(subtype->currentIndex());
  14418. }
  14419. else if(node.attribute("name")=="tctype")
  14420. {
  14421. tctype->setCurrentIndex(tctype->
  14422. findData(QVariant(node.attribute("value").toInt())));
  14423. }
  14424. else if(node.attribute("name")=="rtdtype")
  14425. {
  14426. rtdtype->setCurrentIndex(rtdtype->
  14427. findData(QVariant(node.attribute("value").toInt())));
  14428. }
  14429. else if(node.attribute("name")=="rtdwiring")
  14430. {
  14431. rtdwiring->setCurrentIndex(rtdwiring->
  14432. findData(QVariant(node.attribute("value").toInt())));
  14433. }
  14434. else if(node.attribute("name")=="hubport")
  14435. {
  14436. hubPort->setText(node.attribute("value"));
  14437. }
  14438. else if(node.attribute("name")=="hidden")
  14439. {
  14440. hidden->setCheckState(node.attribute("value")=="true"?Qt::Checked:Qt::Unchecked);
  14441. }
  14442. }
  14443. outerLayout->addLayout(subtypeLayout);
  14444. setLayout(outerLayout);
  14445. updateSerialNumber(serialNumber->text());
  14446. updateChannel(channel->text());
  14447. updateColumnName(columnName->text());
  14448. updateChannelType(subtype->currentIndex());
  14449. updateTCType(tctype->currentIndex());
  14450. updateRTDType(rtdtype->currentIndex());
  14451. updateRTDWiring(rtdwiring->currentIndex());
  14452. updateHubPort(hubPort->text());
  14453. updateHidden(hidden->checkState());
  14454. connect(channelSelector,SIGNAL(currentIndexChanged(int)),
  14455. this,SLOT(changeSelectedChannel(int)));
  14456. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14457. subtypeLayout,SLOT(setCurrentIndex(int)));
  14458. connect(serialNumber,SIGNAL(textChanged(QString)),
  14459. this,SLOT(updateSerialNumber(QString)));
  14460. connect(channel,SIGNAL(textChanged(QString)),
  14461. this,SLOT(updateChannel(QString)));
  14462. connect(columnName,SIGNAL(textEdited(QString)),
  14463. this,SLOT(updateColumnName(QString)));
  14464. connect(subtype,SIGNAL(currentIndexChanged(int)),
  14465. this,SLOT(updateChannelType(int)));
  14466. connect(tctype,SIGNAL(currentIndexChanged(int)),
  14467. this,SLOT(updateTCType(int)));
  14468. connect(rtdtype,SIGNAL(currentIndexChanged(int)),
  14469. this,SLOT(updateRTDType(int)));
  14470. connect(rtdwiring,SIGNAL(currentIndexChanged(int)),
  14471. this,SLOT(updateRTDWiring(int)));
  14472. connect(hubPort,SIGNAL(textChanged(QString)),
  14473. this,SLOT(updateHubPort(QString)));
  14474. connect(hidden,SIGNAL(stateChanged(int)),
  14475. this,SLOT(updateHidden(int)));
  14476. }
  14477. /*:977*//*978:*/
  14478. #line 471 "./phidget22.w"
  14479. void PhidgetChannelConfWidget::changeSelectedChannel(int index)
  14480. {
  14481. QMap<QString,QVariant> data= channelSelector->itemData(index).toMap();
  14482. serialNumber->setText(data.value("serialNumber").toString());
  14483. channel->setText(data.value("channel").toString());
  14484. subtype->setCurrentIndex(subtype->
  14485. findData(QVariant(data.value("subclass").toString().toInt())));
  14486. hubPort->setText(data.value("hubport").toString());
  14487. }
  14488. /*:978*//*979:*/
  14489. #line 484 "./phidget22.w"
  14490. void PhidgetChannelConfWidget::updateSerialNumber(const QString&value)
  14491. {
  14492. updateAttribute("serialnumber",value);
  14493. }
  14494. void PhidgetChannelConfWidget::updateChannel(const QString&value)
  14495. {
  14496. updateAttribute("channel",value);
  14497. }
  14498. void PhidgetChannelConfWidget::updateColumnName(const QString&value)
  14499. {
  14500. updateAttribute("columnname",value);
  14501. }
  14502. void PhidgetChannelConfWidget::updateChannelType(int value)
  14503. {
  14504. updateAttribute("channeltype",subtype->itemData(value).toString());
  14505. }
  14506. void PhidgetChannelConfWidget::updateTCType(int value)
  14507. {
  14508. updateAttribute("tctype",tctype->itemData(value).toString());
  14509. }
  14510. void PhidgetChannelConfWidget::updateRTDType(int value)
  14511. {
  14512. updateAttribute("rtdtype",rtdtype->itemData(value).toString());
  14513. }
  14514. void PhidgetChannelConfWidget::updateRTDWiring(int value)
  14515. {
  14516. updateAttribute("rtdwiring",rtdwiring->itemData(value).toString());
  14517. }
  14518. void PhidgetChannelConfWidget::updateHubPort(const QString&value)
  14519. {
  14520. updateAttribute("hubport",value);
  14521. }
  14522. void PhidgetChannelConfWidget::updateHidden(int value)
  14523. {
  14524. updateAttribute("hidden",value==0?"false":"true");
  14525. }
  14526. /*:979*//*982:*/
  14527. #line 593 "./phidget22.w"
  14528. Phidget22::Phidget22(const QModelIndex&index):QObject(NULL)
  14529. {
  14530. DeviceTreeModel*model= (DeviceTreeModel*)(index.model());
  14531. if(model->hasChildren(index))
  14532. {
  14533. for(int i= 0;i<model->rowCount(index);i++)
  14534. {
  14535. QModelIndex channelIndex= model->index(i,0,index);
  14536. QDomElement channelReference= model->
  14537. referenceElement(model->data(channelIndex,32).toString());
  14538. QDomElement channelReferenceElement= model->
  14539. referenceElement(model->
  14540. data(channelIndex,Qt::UserRole).toString());
  14541. QDomNodeList channelConfigData=
  14542. channelReferenceElement.elementsByTagName("attribute");
  14543. PhidgetChannelData*c= new PhidgetChannelData;
  14544. c->channel= new Channel;
  14545. c->indicatorLabel=
  14546. model->data(channelIndex,Qt::DisplayRole).toString();
  14547. c->device= NULL;
  14548. c->hubPort= -1;
  14549. for(int j= 0;j<channelConfigData.size();j++)
  14550. {
  14551. QDomElement node= channelConfigData.at(j).toElement();
  14552. if(node.attribute("name")=="serialnumber")
  14553. {
  14554. c->serialNumber= node.attribute("value").toInt();
  14555. }
  14556. else if(node.attribute("name")=="channel")
  14557. {
  14558. c->channelNumber= node.attribute("value").toInt();
  14559. }
  14560. else if(node.attribute("name")=="channeltype")
  14561. {
  14562. c->channelType= node.attribute("value").toInt();
  14563. }
  14564. else if(node.attribute("name")=="tctype")
  14565. {
  14566. c->tcType= node.attribute("value").toInt();
  14567. }
  14568. else if(node.attribute("name")=="rtdtype")
  14569. {
  14570. c->rtdType= node.attribute("value").toInt();
  14571. }
  14572. else if(node.attribute("name")=="rtdwiring")
  14573. {
  14574. c->wiring= node.attribute("value").toInt();
  14575. }
  14576. else if(node.attribute("name")=="hidden")
  14577. {
  14578. c->hidden= (node.attribute("value")=="true");
  14579. }
  14580. else if(node.attribute("name")=="columnname")
  14581. {
  14582. c->columnName= node.attribute("value");
  14583. }
  14584. else if(node.attribute("name")=="hubport")
  14585. {
  14586. c->hubPort= node.attribute("value").toInt();
  14587. }
  14588. }
  14589. channelConfiguration.append(c);
  14590. }
  14591. }
  14592. }
  14593. /*:982*//*983:*/
  14594. #line 663 "./phidget22.w"
  14595. int Phidget22::channelCount()
  14596. {
  14597. return channelConfiguration.length();
  14598. }
  14599. Channel*Phidget22::getChannel(int channel)
  14600. {
  14601. return channelConfiguration.at(channel)->channel;
  14602. }
  14603. /*:983*//*984:*/
  14604. #line 677 "./phidget22.w"
  14605. bool Phidget22::isChannelHidden(int channel)
  14606. {
  14607. return channelConfiguration.at(channel)->hidden;
  14608. }
  14609. QString Phidget22::channelColumnName(int channel)
  14610. {
  14611. return channelConfiguration.at(channel)->columnName;
  14612. }
  14613. QString Phidget22::channelIndicatorText(int channel)
  14614. {
  14615. return channelConfiguration.at(channel)->indicatorLabel;
  14616. }
  14617. /*:984*//*985:*/
  14618. #line 696 "./phidget22.w"
  14619. void Phidget22::start()
  14620. {
  14621. #if __APPLE__
  14622. driver.setFileName("Phidget22.framework/Phidget22");
  14623. #else
  14624. driver.setFileName("phidget22");
  14625. #endif
  14626. if(!driver.load())
  14627. {
  14628. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  14629. tr("Failed to find phidget22. Please install it."));
  14630. return;
  14631. }
  14632. if((p_createTemperatureSensor= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_create"))==0||
  14633. (p_setSerialNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setDeviceSerialNumber"))==0||
  14634. (p_setChannelNumber= (PhidgetPointerIntIn)driver.resolve("Phidget_setChannel"))==0||
  14635. (p_setTCType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setThermocoupleType"))==0||
  14636. (p_setRTDType= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDType"))==0||
  14637. (p_setRTDWiring= (PhidgetPointerIntIn)driver.resolve("PhidgetTemperatureSensor_setRTDWireSetup"))==0||
  14638. (p_setNewDataCallback= (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler"))==0||
  14639. (p_open= (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment"))==0||
  14640. (p_close= (PhidgetPointer)driver.resolve("Phidget_close"))==0||
  14641. (p_delete= (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_delete"))==0||
  14642. (p_setHubPort= (PhidgetPointerIntIn)driver.resolve("Phidget_setHubPort"))==0)
  14643. {
  14644. QMessageBox::critical(NULL,tr("Typica: Link error"),
  14645. tr("Failed to link a required symbol in phidget22."));
  14646. return;
  14647. }
  14648. for(int i= 0;i<channelConfiguration.length();i++)
  14649. {
  14650. PhidgetChannelData*c= channelConfiguration.at(i);
  14651. p_createTemperatureSensor(&(c->device));
  14652. p_setSerialNumber(c->device,c->serialNumber);
  14653. p_setChannelNumber(c->device,c->channelNumber);
  14654. switch(c->channelType)
  14655. {
  14656. case 32:
  14657. p_setRTDType(c->device,c->rtdType);
  14658. p_setRTDWiring(c->device,c->wiring);
  14659. break;
  14660. case 33:
  14661. p_setTCType(c->device,c->tcType);
  14662. break;
  14663. default:
  14664. break;
  14665. }
  14666. if(c->hubPort>=0)
  14667. {
  14668. p_setHubPort(c->device,c->hubPort);
  14669. }
  14670. p_setNewDataCallback(c->device,Phidget22ValueCallback,c->channel);
  14671. p_open(c->device,5000);
  14672. }
  14673. }
  14674. /*:985*//*988:*/
  14675. #line 779 "./phidget22.w"
  14676. void Phidget22::stop()
  14677. {
  14678. for(int i= 0;i<channelConfiguration.length();i++)
  14679. {
  14680. PhidgetChannelData*c= channelConfiguration.at(i);
  14681. p_close(c->device);
  14682. p_delete(&(c->device));
  14683. }
  14684. }
  14685. /*:988*/
  14686. #line 793 "./phidget22.w"
  14687. /*:989*//*1003:*/
  14688. #line 19849 "./typica.w"
  14689. /*1001:*/
  14690. #line 19811 "./typica.w"
  14691. CoolingTimerConfWidget::CoolingTimerConfWidget(DeviceTreeModel*model,
  14692. const QModelIndex&index)
  14693. :BasicDeviceConfigurationWidget(model,index)
  14694. {
  14695. QHBoxLayout*layout= new QHBoxLayout;
  14696. QLabel*label= new QLabel(tr("Cooling Time: "));
  14697. QTimeEdit*editor= new QTimeEdit;
  14698. editor->setDisplayFormat("mm:ss");
  14699. /*801:*/
  14700. #line 16651 "./typica.w"
  14701. QDomElement referenceElement=
  14702. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14703. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14704. QDomElement node;
  14705. /*:801*/
  14706. #line 19820 "./typica.w"
  14707. for(int i= 0;i<configData.size();i++)
  14708. {
  14709. node= configData.at(i).toElement();
  14710. if(node.attribute("name")=="reset")
  14711. {
  14712. editor->setTime(QTime::fromString(node.attribute("value"),"mm:ss"));
  14713. }
  14714. }
  14715. updateResetTime(editor->time());
  14716. connect(editor,SIGNAL(timeChanged(QTime)),
  14717. this,SLOT(updateResetTime(QTime)));
  14718. layout->addWidget(label);
  14719. layout->addWidget(editor);
  14720. setLayout(layout);
  14721. }
  14722. void CoolingTimerConfWidget::updateResetTime(QTime time)
  14723. {
  14724. updateAttribute("reset",time.toString("mm:ss"));
  14725. }
  14726. /*:1001*/
  14727. #line 19850 "./typica.w"
  14728. /*:1003*//*1008:*/
  14729. #line 20108 "./typica.w"
  14730. /*1005:*/
  14731. #line 19882 "./typica.w"
  14732. RangeTimerConfWidget::RangeTimerConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  14733. :BasicDeviceConfigurationWidget(model,index)
  14734. {
  14735. QVBoxLayout*layout= new QVBoxLayout;
  14736. QGroupBox*startConfigurationGroup= new QGroupBox(tr("Start trigger"));
  14737. QRadioButton*startBatchOption= new QRadioButton(tr("Start of batch"));
  14738. QRadioButton*buttonOption= new QRadioButton(tr("Manual"));
  14739. QRadioButton*thresholdOption= new QRadioButton(tr("At temperature"));
  14740. QButtonGroup*startOptionGroup= new QButtonGroup;
  14741. startOptionGroup->addButton(startBatchOption,1);
  14742. startOptionGroup->addButton(buttonOption,2);
  14743. startOptionGroup->addButton(thresholdOption,3);
  14744. startBatchOption->setChecked(true);
  14745. QGridLayout*startOptions= new QGridLayout;
  14746. startOptions->addWidget(startBatchOption,0,0);
  14747. startOptions->addWidget(buttonOption,1,0);
  14748. startOptions->addWidget(thresholdOption,2,0);
  14749. QLabel*buttonTextLabel= new QLabel(tr("Button Text: "));
  14750. QLineEdit*buttonTextEdit= new QLineEdit;
  14751. QHBoxLayout*buttonTextOptions= new QHBoxLayout;
  14752. buttonTextOptions->addWidget(buttonTextLabel);
  14753. buttonTextOptions->addWidget(buttonTextEdit);
  14754. startOptions->addLayout(buttonTextOptions,1,1);
  14755. QFormLayout*thresholdOptions= new QFormLayout;
  14756. QLineEdit*startColumnName= new QLineEdit;
  14757. QLineEdit*startValue= new QLineEdit;
  14758. thresholdOptions->addRow(tr("Column Name: "),startColumnName);
  14759. thresholdOptions->addRow(tr("Value: "),startValue);
  14760. startOptions->addLayout(thresholdOptions,2,1);
  14761. startConfigurationGroup->setLayout(startOptions);
  14762. layout->addWidget(startConfigurationGroup);
  14763. QGroupBox*stopConfigurationGroup= new QGroupBox(tr("Stop trigger"));
  14764. QRadioButton*stopBatchOption= new QRadioButton(tr("End of batch"));
  14765. QRadioButton*stopButtonOption= new QRadioButton(tr("Manual"));
  14766. QRadioButton*stopThresholdOption= new QRadioButton(tr("At temperature"));
  14767. QButtonGroup*stopOptionGroup= new QButtonGroup;
  14768. stopOptionGroup->addButton(stopBatchOption,1);
  14769. stopOptionGroup->addButton(stopButtonOption,2);
  14770. stopOptionGroup->addButton(stopThresholdOption,3);
  14771. stopBatchOption->setChecked(true);
  14772. QGridLayout*stopOptions= new QGridLayout;
  14773. stopOptions->addWidget(stopBatchOption,0,0);
  14774. stopOptions->addWidget(stopButtonOption,1,0);
  14775. stopOptions->addWidget(stopThresholdOption,2,0);
  14776. QLabel*stopButtonLabel= new QLabel(tr("Button Text: "));
  14777. QLineEdit*stopButtonEdit= new QLineEdit;
  14778. QHBoxLayout*stopButtonTextOptions= new QHBoxLayout;
  14779. stopButtonTextOptions->addWidget(stopButtonLabel);
  14780. stopButtonTextOptions->addWidget(stopButtonEdit);
  14781. stopOptions->addLayout(stopButtonTextOptions,1,1);
  14782. QLineEdit*stopColumnName= new QLineEdit;
  14783. QLineEdit*stopValue= new QLineEdit;
  14784. QFormLayout*stopThresholdOptions= new QFormLayout;
  14785. stopThresholdOptions->addRow(tr("Column Name: "),stopColumnName);
  14786. stopThresholdOptions->addRow(tr("Value: "),stopValue);
  14787. stopOptions->addLayout(stopThresholdOptions,2,1);
  14788. stopConfigurationGroup->setLayout(stopOptions);
  14789. layout->addWidget(stopConfigurationGroup);
  14790. /*801:*/
  14791. #line 16651 "./typica.w"
  14792. QDomElement referenceElement=
  14793. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14794. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14795. QDomElement node;
  14796. /*:801*/
  14797. #line 19944 "./typica.w"
  14798. for(int i= 0;i<configData.size();i++)
  14799. {
  14800. node= configData.at(i).toElement();
  14801. if(node.attribute("name")=="startbuttontext")
  14802. {
  14803. buttonTextEdit->setText(node.attribute("value"));
  14804. }
  14805. else if(node.attribute("name")=="stopbuttontext")
  14806. {
  14807. stopButtonEdit->setText(node.attribute("value"));
  14808. }
  14809. else if(node.attribute("name")=="startcolumnname")
  14810. {
  14811. startColumnName->setText(node.attribute("value"));
  14812. }
  14813. else if(node.attribute("name")=="stopcolumnname")
  14814. {
  14815. stopColumnName->setText(node.attribute("value"));
  14816. }
  14817. else if(node.attribute("name")=="startvalue")
  14818. {
  14819. startValue->setText(node.attribute("value"));
  14820. }
  14821. else if(node.attribute("name")=="stopvalue")
  14822. {
  14823. stopValue->setText(node.attribute("value"));
  14824. }
  14825. else if(node.attribute("name")=="starttrigger")
  14826. {
  14827. if(node.attribute("value")=="batch")
  14828. {
  14829. startBatchOption->setChecked(true);
  14830. }
  14831. else if(node.attribute("value")=="manual")
  14832. {
  14833. buttonOption->setChecked(true);
  14834. }
  14835. else if(node.attribute("value")=="value")
  14836. {
  14837. thresholdOption->setChecked(true);
  14838. }
  14839. }
  14840. else if(node.attribute("name")=="stoptrigger")
  14841. {
  14842. if(node.attribute("value")=="batch")
  14843. {
  14844. stopBatchOption->setChecked(true);
  14845. }
  14846. else if(node.attribute("value")=="manual")
  14847. {
  14848. stopButtonOption->setChecked(true);
  14849. }
  14850. else if(node.attribute("value")=="value")
  14851. {
  14852. stopThresholdOption->setChecked(true);
  14853. }
  14854. }
  14855. }
  14856. updateStartButtonText(buttonTextEdit->text());
  14857. updateStopButtonText(stopButtonEdit->text());
  14858. updateStartColumnName(startColumnName->text());
  14859. updateStopColumnName(stopColumnName->text());
  14860. updateStartValue(startValue->text());
  14861. updateStopValue(stopValue->text());
  14862. updateStartTrigger(startOptionGroup->checkedId());
  14863. updateStopTrigger(stopOptionGroup->checkedId());
  14864. setLayout(layout);
  14865. connect(buttonTextEdit,SIGNAL(textChanged(QString)),
  14866. this,SLOT(updateStartButtonText(QString)));
  14867. connect(stopButtonEdit,SIGNAL(textChanged(QString)),
  14868. this,SLOT(updateStopButtonText(QString)));
  14869. connect(startColumnName,SIGNAL(textChanged(QString)),
  14870. this,SLOT(updateStartColumnName(QString)));
  14871. connect(stopColumnName,SIGNAL(textChanged(QString)),
  14872. this,SLOT(updateStopColumnName(QString)));
  14873. connect(startValue,SIGNAL(textChanged(QString)),
  14874. this,SLOT(updateStartValue(QString)));
  14875. connect(stopValue,SIGNAL(textChanged(QString)),
  14876. this,SLOT(updateStopValue(QString)));
  14877. connect(startOptionGroup,SIGNAL(buttonClicked(int)),
  14878. this,SLOT(updateStartTrigger(int)));
  14879. connect(stopOptionGroup,SIGNAL(buttonClicked(int)),
  14880. this,SLOT(updateStopTrigger(int)));
  14881. }
  14882. /*:1005*//*1006:*/
  14883. #line 20034 "./typica.w"
  14884. void RangeTimerConfWidget::updateStartButtonText(const QString&text)
  14885. {
  14886. updateAttribute("startbuttontext",text);
  14887. }
  14888. void RangeTimerConfWidget::updateStopButtonText(const QString&text)
  14889. {
  14890. updateAttribute("stopbuttontext",text);
  14891. }
  14892. void RangeTimerConfWidget::updateStartColumnName(const QString&text)
  14893. {
  14894. updateAttribute("startcolumnname",text);
  14895. }
  14896. void RangeTimerConfWidget::updateStopColumnName(const QString&text)
  14897. {
  14898. updateAttribute("stopcolumnname",text);
  14899. }
  14900. void RangeTimerConfWidget::updateStartValue(const QString&text)
  14901. {
  14902. updateAttribute("startvalue",text);
  14903. }
  14904. void RangeTimerConfWidget::updateStopValue(const QString&text)
  14905. {
  14906. updateAttribute("stopvalue",text);
  14907. }
  14908. void RangeTimerConfWidget::updateStartTrigger(int option)
  14909. {
  14910. switch(option)
  14911. {
  14912. case 1:
  14913. updateAttribute("starttrigger","batch");
  14914. break;
  14915. case 2:
  14916. updateAttribute("starttrigger","manual");
  14917. break;
  14918. case 3:
  14919. updateAttribute("starttrigger","value");
  14920. break;
  14921. default:
  14922. break;
  14923. }
  14924. }
  14925. void RangeTimerConfWidget::updateStopTrigger(int option)
  14926. {
  14927. switch(option)
  14928. {
  14929. case 1:
  14930. updateAttribute("stoptrigger","batch");
  14931. break;
  14932. case 2:
  14933. updateAttribute("stoptrigger","manual");
  14934. break;
  14935. case 3:
  14936. updateAttribute("stoptrigger","value");
  14937. break;
  14938. default:
  14939. break;
  14940. }
  14941. }
  14942. /*:1006*/
  14943. #line 20109 "./typica.w"
  14944. /*:1008*//*1013:*/
  14945. #line 20209 "./typica.w"
  14946. /*1010:*/
  14947. #line 20133 "./typica.w"
  14948. MultiRangeTimerConfWidget::MultiRangeTimerConfWidget(DeviceTreeModel*model,
  14949. const QModelIndex&index)
  14950. :BasicDeviceConfigurationWidget(model,index),tablemodel(new SaltModel(2))
  14951. {
  14952. QFormLayout*layout= new QFormLayout;
  14953. QLineEdit*trigger= new QLineEdit;
  14954. layout->addRow(tr("Trigger column name:"),trigger);
  14955. tablemodel->setHeaderData(0,Qt::Horizontal,"Range Name");
  14956. tablemodel->setHeaderData(1,Qt::Horizontal,"End Temperature");
  14957. QTableView*rangeTable= new QTableView;
  14958. rangeTable->setModel(tablemodel);
  14959. layout->addRow(tr("Range data:"),rangeTable);
  14960. /*801:*/
  14961. #line 16651 "./typica.w"
  14962. QDomElement referenceElement=
  14963. model->referenceElement(model->data(index,Qt::UserRole).toString());
  14964. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  14965. QDomElement node;
  14966. /*:801*/
  14967. #line 20146 "./typica.w"
  14968. for(int i= 0;i<configData.size();i++)
  14969. {
  14970. node= configData.at(i).toElement();
  14971. if(node.attribute("name")=="trigger")
  14972. {
  14973. trigger->setText(node.attribute("value"));
  14974. }
  14975. else if(node.attribute("name")=="rangenames")
  14976. {
  14977. QString data= node.attribute("value");
  14978. if(data.length()> 3)
  14979. {
  14980. data.chop(2);
  14981. data= data.remove(0,2);
  14982. }
  14983. QStringList itemList= data.split(", ");
  14984. for(int j= 0;j<itemList.size();j++)
  14985. {
  14986. QString item= itemList.at(j);
  14987. item.chop(1);
  14988. item= item.remove(0,1);
  14989. tablemodel->setData(tablemodel->index(j,0),
  14990. QVariant(item),Qt::DisplayRole);
  14991. }
  14992. }
  14993. else if(node.attribute("name")=="endtemps")
  14994. {
  14995. /*996:*/
  14996. #line 19741 "./typica.w"
  14997. QString data= node.attribute("value");
  14998. if(data.length()> 3)
  14999. {
  15000. data.chop(2);
  15001. data= data.remove(0,2);
  15002. }
  15003. QStringList itemList= data.split(",");
  15004. /*:996*/
  15005. #line 20174 "./typica.w"
  15006. int column= 1;
  15007. /*997:*/
  15008. #line 19753 "./typica.w"
  15009. for(int j= 0;j<itemList.size();j++)
  15010. {
  15011. tablemodel->setData(tablemodel->index(j,column),
  15012. QVariant(itemList.at(j).toDouble()),
  15013. Qt::DisplayRole);
  15014. }
  15015. /*:997*/
  15016. #line 20176 "./typica.w"
  15017. }
  15018. }
  15019. updateColumnName(trigger->text());
  15020. updateRangeData();
  15021. connect(trigger,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  15022. connect(tablemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateRangeData()));
  15023. setLayout(layout);
  15024. }
  15025. /*:1010*//*1011:*/
  15026. #line 20190 "./typica.w"
  15027. void MultiRangeTimerConfWidget::updateRangeData()
  15028. {
  15029. updateAttribute("rangenames",tablemodel->quotedArrayLiteral(0,Qt::DisplayRole));
  15030. updateAttribute("endtemps",tablemodel->arrayLiteral(1,Qt::DisplayRole));
  15031. }
  15032. void MultiRangeTimerConfWidget::updateColumnName(const QString&text)
  15033. {
  15034. updateAttribute("trigger",text);
  15035. }
  15036. /*:1011*/
  15037. #line 20210 "./typica.w"
  15038. /*:1013*//*1031:*/
  15039. #line 265 "./rate.w"
  15040. /*1027:*/
  15041. #line 191 "./rate.w"
  15042. RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  15043. :BasicDeviceConfigurationWidget(model,index)
  15044. {
  15045. QFormLayout*layout= new QFormLayout;
  15046. QLineEdit*column= new QLineEdit;
  15047. layout->addRow(tr("Primary series column name:"),column);
  15048. QSpinBox*cacheTime= new QSpinBox;
  15049. cacheTime->setMinimum(0);
  15050. cacheTime->setMaximum(300);
  15051. layout->addRow(tr("Cache time:"),cacheTime);
  15052. QSpinBox*scaleTime= new QSpinBox;
  15053. scaleTime->setMinimum(1);
  15054. scaleTime->setMaximum(300);
  15055. layout->addRow(tr("Scale time:"),scaleTime);
  15056. /*801:*/
  15057. #line 16651 "./typica.w"
  15058. QDomElement referenceElement=
  15059. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15060. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15061. QDomElement node;
  15062. /*:801*/
  15063. #line 206 "./rate.w"
  15064. for(int i= 0;i<configData.size();i++)
  15065. {
  15066. node= configData.at(i).toElement();
  15067. if(node.attribute("name")=="column")
  15068. {
  15069. column->setText(node.attribute("value"));
  15070. }
  15071. else if(node.attribute("name")=="cache")
  15072. {
  15073. cacheTime->setValue(node.attribute("value").toInt());
  15074. }
  15075. else if(node.attribute("name")=="scale")
  15076. {
  15077. scaleTime->setValue(node.attribute("value").toInt());
  15078. }
  15079. }
  15080. updateColumn(column->text());
  15081. updateCacheTime(cacheTime->text());
  15082. updateScaleTime(scaleTime->text());
  15083. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateColumn(QString)));
  15084. connect(cacheTime,SIGNAL(valueChanged(QString)),this,SLOT(updateCacheTime(QString)));
  15085. connect(scaleTime,SIGNAL(valueChanged(QString)),this,SLOT(updateScaleTime(QString)));
  15086. setLayout(layout);
  15087. }
  15088. /*:1027*//*1028:*/
  15089. #line 235 "./rate.w"
  15090. void RateOfChangeConfWidget::updateColumn(const QString&column)
  15091. {
  15092. updateAttribute("column",column);
  15093. }
  15094. void RateOfChangeConfWidget::updateCacheTime(const QString&seconds)
  15095. {
  15096. updateAttribute("cache",seconds);
  15097. }
  15098. void RateOfChangeConfWidget::updateScaleTime(const QString&seconds)
  15099. {
  15100. updateAttribute("scale",seconds);
  15101. }
  15102. /*:1028*/
  15103. #line 266 "./rate.w"
  15104. #line 20317 "./typica.w"
  15105. #line 1 "./mergeseries.w"
  15106. /*:1031*//*1045:*/
  15107. #line 282 "./mergeseries.w"
  15108. /*1041:*/
  15109. #line 183 "./mergeseries.w"
  15110. MergeSeriesConfWidget::MergeSeriesConfWidget(DeviceTreeModel*model,
  15111. const QModelIndex&index)
  15112. :BasicDeviceConfigurationWidget(model,index)
  15113. {
  15114. QFormLayout*layout= new QFormLayout;
  15115. QComboBox*type= new QComboBox;
  15116. type->addItem(tr("Difference"),QVariant("Difference"));
  15117. type->addItem(tr("Mean"),QVariant("Mean"));
  15118. layout->addRow(tr("Series type:"),type);
  15119. QLineEdit*column1= new QLineEdit;
  15120. layout->addRow(tr("First input column name:"),column1);
  15121. QLineEdit*column2= new QLineEdit;
  15122. layout->addRow(tr("Second input column name:"),column2);
  15123. QLineEdit*output= new QLineEdit;
  15124. layout->addRow(tr("Output column name:"),output);
  15125. /*801:*/
  15126. #line 16651 "./typica.w"
  15127. QDomElement referenceElement=
  15128. model->referenceElement(model->data(index,Qt::UserRole).toString());
  15129. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  15130. QDomElement node;
  15131. /*:801*/
  15132. #line 199 "./mergeseries.w"
  15133. for(int i= 0;i<configData.size();i++)
  15134. {
  15135. node= configData.at(i).toElement();
  15136. if(node.attribute("name")=="type")
  15137. {
  15138. type->setCurrentIndex(type->findData(node.attribute("value")));
  15139. }
  15140. else if(node.attribute("name")=="column1")
  15141. {
  15142. column1->setText(node.attribute("value"));
  15143. }
  15144. else if(node.attribute("name")=="column2")
  15145. {
  15146. column2->setText(node.attribute("value"));
  15147. }
  15148. else if(node.attribute("name")=="output")
  15149. {
  15150. output->setText(node.attribute("value"));
  15151. }
  15152. }
  15153. updateColumn1(column1->text());
  15154. updateColumn2(column2->text());
  15155. updateOutput(output->text());
  15156. updateType(type->currentIndex());
  15157. connect(column1,SIGNAL(textEdited(QString)),this,SLOT(updateColumn1(QString)));
  15158. connect(column2,SIGNAL(textEdited(QString)),this,SLOT(updateColumn2(QString)));
  15159. connect(output,SIGNAL(textEdited(QString)),this,SLOT(updateOutput(QString)));
  15160. connect(type,SIGNAL(currentIndexChanged(int)),this,SLOT(updateType(int)));
  15161. setLayout(layout);
  15162. }
  15163. /*:1041*//*1042:*/
  15164. #line 233 "./mergeseries.w"
  15165. void MergeSeriesConfWidget::updateColumn1(const QString&column)
  15166. {
  15167. updateAttribute("column1",column);
  15168. }
  15169. void MergeSeriesConfWidget::updateColumn2(const QString&column)
  15170. {
  15171. updateAttribute("column2",column);
  15172. }
  15173. void MergeSeriesConfWidget::updateOutput(const QString&column)
  15174. {
  15175. updateAttribute("output",column);
  15176. }
  15177. void MergeSeriesConfWidget::updateType(int index)
  15178. {
  15179. switch(index)
  15180. {
  15181. case 0:
  15182. updateAttribute("type","Difference");
  15183. break;
  15184. case 1:
  15185. updateAttribute("type","Mean");
  15186. break;
  15187. default:
  15188. break;
  15189. }
  15190. }
  15191. /*:1042*/
  15192. #line 283 "./mergeseries.w"
  15193. /*1033:*/
  15194. #line 59 "./mergeseries.w"
  15195. void MergeSeries::in1(Measurement measure)
  15196. {
  15197. last1= measure;
  15198. received1= true;
  15199. if(received1&&received2)
  15200. {
  15201. calculate(last1,last2);
  15202. received1= false;
  15203. received2= false;
  15204. }
  15205. }
  15206. void MergeSeries::in2(Measurement measure)
  15207. {
  15208. last2= measure;
  15209. received2= true;
  15210. if(received1&&received2)
  15211. {
  15212. calculate(last1,last2);
  15213. received1= false;
  15214. received2= false;
  15215. }
  15216. }
  15217. /*:1033*//*1034:*/
  15218. #line 86 "./mergeseries.w"
  15219. MergeSeries::MergeSeries():QObject(NULL),received1(false),received2(false)
  15220. {
  15221. }
  15222. /*:1034*//*1035:*/
  15223. #line 97 "./mergeseries.w"
  15224. void DifferenceSeries::calculate(Measurement m1,Measurement m2)
  15225. {
  15226. Measurement outval(m1.temperature()-m2.temperature(),
  15227. (m1.time()> m2.time()?m1.time():m2.time()));
  15228. outval.insert("relative",true);
  15229. emit newData(outval);
  15230. }
  15231. void MeanSeries::calculate(Measurement m1,Measurement m2)
  15232. {
  15233. Measurement outval((m1.temperature()+m2.temperature())/2,
  15234. (m1.time()> m2.time()?m1.time():m2.time()));
  15235. emit newData(outval);
  15236. }
  15237. /*:1035*//*1036:*/
  15238. #line 115 "./mergeseries.w"
  15239. DifferenceSeries::DifferenceSeries():MergeSeries()
  15240. {
  15241. }
  15242. MeanSeries::MeanSeries():MergeSeries()
  15243. {
  15244. }
  15245. /*:1036*/
  15246. #line 284 "./mergeseries.w"
  15247. #line 20319 "./typica.w"
  15248. #line 1 "./dataqsdk.w"
  15249. /*:1045*//*1160:*/
  15250. #line 344 "./user.w"
  15251. /*1155:*/
  15252. #line 232 "./user.w"
  15253. NewTypicaUser::NewTypicaUser():QDialog(),
  15254. userField(new QLineEdit),passwordField(new QLineEdit),
  15255. autoLogin(new QCheckBox(tr("Log in automatically"))),
  15256. saveAndCloseButton(new QPushButton(tr("Save and Close"))),
  15257. saveAndNewButton(new QPushButton(tr("Save and Create Another"))),
  15258. cancelButton(new QPushButton(tr("Cancel")))
  15259. {
  15260. setModal(true);
  15261. QVBoxLayout*mainLayout= new QVBoxLayout;
  15262. QFormLayout*form= new QFormLayout;
  15263. QHBoxLayout*buttons= new QHBoxLayout;
  15264. form->addRow(tr("Name:"),userField);
  15265. passwordField->setEchoMode(QLineEdit::Password);
  15266. form->addRow(tr("Password:"),passwordField);
  15267. form->addRow(autoLogin);
  15268. buttons->addWidget(cancelButton);
  15269. buttons->addStretch();
  15270. buttons->addWidget(saveAndNewButton);
  15271. buttons->addWidget(saveAndCloseButton);
  15272. mainLayout->addLayout(form);
  15273. mainLayout->addLayout(buttons);
  15274. setLayout(mainLayout);
  15275. setWindowTitle(tr("Create New User"));
  15276. connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
  15277. connect(saveAndCloseButton,SIGNAL(clicked()),this,SLOT(createAndClose()));
  15278. connect(saveAndNewButton,SIGNAL(clicked()),this,SLOT(createAndReset()));
  15279. connect(userField,SIGNAL(textChanged(QString)),this,SLOT(validate()));
  15280. }
  15281. /*:1155*//*1156:*/
  15282. #line 264 "./user.w"
  15283. void NewTypicaUser::createAndReset()
  15284. {
  15285. createNewUser();
  15286. userField->setText("");
  15287. passwordField->setText("");
  15288. autoLogin->setChecked(false);
  15289. }
  15290. void NewTypicaUser::createAndClose()
  15291. {
  15292. createNewUser();
  15293. accept();
  15294. }
  15295. void NewTypicaUser::createNewUser()
  15296. {
  15297. SqlQueryConnection h;
  15298. QSqlQuery*dbquery= h.operator->();
  15299. dbquery->prepare("INSERT INTO typica_users (name, password, active, auto_login) VALUES (:name, :password, true, :auto)");
  15300. dbquery->bindValue(":name",userField->text());
  15301. dbquery->bindValue(":password",passwordField->text());
  15302. dbquery->bindValue(":auto",autoLogin->isChecked());
  15303. dbquery->exec();
  15304. cancelButton->setEnabled(true);
  15305. }
  15306. void NewTypicaUser::validate()
  15307. {
  15308. if(!userField->text().isEmpty())
  15309. {
  15310. saveAndCloseButton->setEnabled(true);
  15311. saveAndNewButton->setEnabled(true);
  15312. }
  15313. else
  15314. {
  15315. saveAndCloseButton->setEnabled(false);
  15316. saveAndNewButton->setEnabled(false);
  15317. }
  15318. }
  15319. void NewTypicaUser::cancelValidate()
  15320. {
  15321. SqlQueryConnection h;
  15322. QSqlQuery*dbquery= h.operator->();
  15323. dbquery->exec("SELECT count(1) FROM typica_users");
  15324. if(dbquery->next())
  15325. {
  15326. if(dbquery->value(0).toInt()> 0)
  15327. {
  15328. cancelButton->setEnabled(true);
  15329. return;
  15330. }
  15331. }
  15332. cancelButton->setEnabled(false);
  15333. }
  15334. /*:1156*/
  15335. #line 345 "./user.w"
  15336. /*1151:*/
  15337. #line 177 "./user.w"
  15338. UserLabel::UserLabel():QLabel()
  15339. {
  15340. setTextFormat(Qt::PlainText);
  15341. updateLabel(AppInstance->currentTypicaUser());
  15342. connect(AppInstance,SIGNAL(userChanged(QString)),
  15343. this,SLOT(updateLabel(QString)));
  15344. }
  15345. /*:1151*//*1152:*/
  15346. #line 188 "./user.w"
  15347. void UserLabel::updateLabel(const QString&user)
  15348. {
  15349. setText(QString(tr("Current operator: %1").arg(user)));
  15350. }
  15351. /*:1152*//*1153:*/
  15352. #line 196 "./user.w"
  15353. void UserLabel::mouseReleaseEvent(QMouseEvent*)
  15354. {
  15355. LoginDialog*dialog= new LoginDialog;
  15356. dialog->exec();
  15357. }
  15358. /*:1153*/
  15359. #line 346 "./user.w"
  15360. /*1145:*/
  15361. #line 95 "./user.w"
  15362. LoginDialog::LoginDialog():QDialog(),
  15363. user(new QLineEdit),password(new QLineEdit),
  15364. warning(new QLabel(tr("Log in failed."))),
  15365. login(new QPushButton(tr("Log In")))
  15366. {
  15367. setModal(true);
  15368. QVBoxLayout*mainLayout= new QVBoxLayout;
  15369. warning->setVisible(false);
  15370. password->setEchoMode(QLineEdit::Password);
  15371. QFormLayout*form= new QFormLayout;
  15372. form->addRow(tr("Name:"),user);
  15373. form->addRow(tr("Password:"),password);
  15374. form->addRow(warning);
  15375. QHBoxLayout*buttonBox= new QHBoxLayout;
  15376. buttonBox->addStretch();
  15377. buttonBox->addWidget(login);
  15378. mainLayout->addLayout(form);
  15379. mainLayout->addLayout(buttonBox);
  15380. connect(login,SIGNAL(clicked()),this,SLOT(attemptLogin()));
  15381. setLayout(mainLayout);
  15382. }
  15383. /*:1145*//*1146:*/
  15384. #line 120 "./user.w"
  15385. void LoginDialog::attemptLogin()
  15386. {
  15387. if(AppInstance->login(user->text(),password->text()))
  15388. {
  15389. accept();
  15390. }
  15391. else
  15392. {
  15393. warning->setVisible(true);
  15394. }
  15395. }
  15396. /*:1146*/
  15397. #line 347 "./user.w"
  15398. #line 20329 "./typica.w"
  15399. /*:1160*/
  15400. #line 532 "./typica.w"
  15401. /*8:*/
  15402. #line 678 "./typica.w"
  15403. template<class TYPE> TYPE getself(QScriptContext*context)
  15404. {
  15405. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  15406. return self;
  15407. }
  15408. template<> QTime getself(QScriptContext*context)
  15409. {
  15410. QTime self= context->thisObject().toVariant().toTime();
  15411. return self;
  15412. }
  15413. template<> QByteArray getself(QScriptContext*context)
  15414. {
  15415. QByteArray self= context->thisObject().toVariant().toByteArray();
  15416. return self;
  15417. }
  15418. template<> SqlQueryConnection*getself(QScriptContext*context)
  15419. {
  15420. SqlQueryConnection*self=
  15421. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  15422. return self;
  15423. }
  15424. template<> QXmlQuery*getself(QScriptContext*context)
  15425. {
  15426. QXmlQuery*self=
  15427. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  15428. return self;
  15429. }
  15430. template<> QXmlStreamWriter*getself(QScriptContext*context)
  15431. {
  15432. QXmlStreamWriter*self=
  15433. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  15434. return self;
  15435. }
  15436. template<> QXmlStreamReader*getself(QScriptContext*context)
  15437. {
  15438. QXmlStreamReader*self=
  15439. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  15440. return self;
  15441. }
  15442. /*:8*//*9:*/
  15443. #line 729 "./typica.w"
  15444. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  15445. {
  15446. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  15447. return argument;
  15448. }
  15449. template<> QString argument(int arg,QScriptContext*context)
  15450. {
  15451. return context->argument(arg).toString();
  15452. }
  15453. template<> QVariant argument(int arg,QScriptContext*context)
  15454. {
  15455. return context->argument(arg).toVariant();
  15456. }
  15457. template<> int argument(int arg,QScriptContext*context)
  15458. {
  15459. return context->argument(arg).toInt32();
  15460. }
  15461. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  15462. {
  15463. return(SqlQueryConnection*)
  15464. qscriptvalue_cast<void*> (context->argument(arg));
  15465. }
  15466. template<> QModelIndex argument(int arg,QScriptContext*context)
  15467. {
  15468. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  15469. }
  15470. template<> double argument(int arg,QScriptContext*context)
  15471. {
  15472. return(double)(context->argument(arg).toNumber());
  15473. }
  15474. template<> Units::Unit argument(int arg,QScriptContext*context)
  15475. {
  15476. return(Units::Unit)(context->argument(arg).toInt32());
  15477. }
  15478. template<> QByteArray argument(int arg,QScriptContext*context)
  15479. {
  15480. return qscriptvalue_cast<QByteArray> (context->argument(arg));
  15481. }
  15482. template<> bool argument(int arg,QScriptContext*context)
  15483. {
  15484. return context->argument(arg).toBool();
  15485. }
  15486. /*:9*//*13:*/
  15487. #line 828 "./typica.w"
  15488. void setQObjectProperties(QScriptValue value,QScriptEngine*engine)
  15489. {
  15490. value.setProperty("setProperty",engine->newFunction(QObject_setProperty));
  15491. }
  15492. QScriptValue QObject_setProperty(QScriptContext*context,QScriptEngine*)
  15493. {
  15494. QObject*self= getself<QObject*> (context);
  15495. self->setProperty(argument<QString> (0,context).toUtf8().constData(),
  15496. argument<QVariant> (1,context));
  15497. return QScriptValue();
  15498. }
  15499. /*:13*//*15:*/
  15500. #line 850 "./typica.w"
  15501. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  15502. {
  15503. }
  15504. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  15505. {
  15506. }
  15507. /*:15*//*18:*/
  15508. #line 882 "./typica.w"
  15509. void setQTimerProperties(QScriptValue value,QScriptEngine*engine)
  15510. {
  15511. setQObjectProperties(value,engine);
  15512. }
  15513. QScriptValue constructQTimer(QScriptContext*,QScriptEngine*engine)
  15514. {
  15515. QScriptValue object= engine->newQObject(new QTimer);
  15516. setQTimerProperties(object,engine);
  15517. return object;
  15518. }
  15519. /*:18*//*21:*/
  15520. #line 924 "./typica.w"
  15521. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  15522. {
  15523. QScriptValue object= engine->newQObject(new QWidget);
  15524. setQWidgetProperties(object,engine);
  15525. return object;
  15526. }
  15527. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  15528. {
  15529. setQObjectProperties(value,engine);
  15530. setQPaintDeviceProperties(value,engine);
  15531. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  15532. value.setProperty("activateWindow",
  15533. engine->newFunction(QWidget_activateWindow));
  15534. }
  15535. /*:21*//*22:*/
  15536. #line 946 "./typica.w"
  15537. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  15538. {
  15539. if(context->argumentCount()==1)
  15540. {
  15541. QWidget*self= getself<QWidget*> (context);
  15542. QLayout*layout= argument<QLayout*> (0,context);
  15543. if(layout)
  15544. {
  15545. self->setLayout(layout);
  15546. }
  15547. else
  15548. {
  15549. context->throwError("Incorrect argument type passed to "
  15550. "QWidget::setLayout(). This method requires "
  15551. "a QLayout.");
  15552. }
  15553. }
  15554. else
  15555. {
  15556. context->throwError("Incorrect number of arguments passed to "
  15557. "QWidget::setLayout(). This method takes one "
  15558. "QLayout as an argument.");
  15559. }
  15560. return QScriptValue();
  15561. }
  15562. QScriptValue QWidget_activateWindow(QScriptContext*context,
  15563. QScriptEngine*)
  15564. {
  15565. QWidget*self= getself<QWidget*> (context);
  15566. self->activateWindow();
  15567. return QScriptValue();
  15568. }
  15569. /*:22*//*25:*/
  15570. #line 1008 "./typica.w"
  15571. QScriptValue displayWarning(QScriptContext*context,QScriptEngine*)
  15572. {
  15573. QMessageBox::StandardButton selection= QMessageBox::warning(NULL,
  15574. argument<QString> (0,context),
  15575. argument<QString> (1,context),
  15576. QMessageBox::Ok|QMessageBox::Cancel);
  15577. if(selection==QMessageBox::Ok){
  15578. return QScriptValue(true);
  15579. }
  15580. return QScriptValue(false);
  15581. }
  15582. QScriptValue displayError(QScriptContext*context,QScriptEngine*)
  15583. {
  15584. QMessageBox::critical(NULL,argument<QString> (0,context),
  15585. argument<QString> (1,context));
  15586. return QScriptValue();
  15587. }
  15588. /*:25*//*27:*/
  15589. #line 1086 "./typica.w"
  15590. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL),
  15591. cprompt(tr("Closing this window may result in loss of data. Continue?"))
  15592. {
  15593. if(!AppInstance->databaseConnected())
  15594. {
  15595. statusBar()->addWidget(new QLabel(tr("Not connected to database")));
  15596. }
  15597. else
  15598. {
  15599. statusBar()->addWidget(new UserLabel);
  15600. }
  15601. }
  15602. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  15603. {
  15604. QSettings settings;
  15605. settings.beginGroup(key);
  15606. settings.setValue("pos",pos());
  15607. settings.setValue("size",size());
  15608. settings.endGroup();
  15609. }
  15610. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  15611. {
  15612. QSettings settings;
  15613. settings.beginGroup(key);
  15614. if(settings.contains("size"))
  15615. {
  15616. resize(settings.value("size").toSize());
  15617. }
  15618. if(settings.contains("pos"))
  15619. {
  15620. move(settings.value("pos").toPoint());
  15621. }
  15622. settings.endGroup();
  15623. }
  15624. void ScriptQMainWindow::displayStatus(const QString&message)
  15625. {
  15626. statusBar()->showMessage(message);
  15627. }
  15628. void ScriptQMainWindow::showEvent(QShowEvent*event)
  15629. {
  15630. if(!event->spontaneous())
  15631. {
  15632. /*32:*/
  15633. #line 1210 "./typica.w"
  15634. QSettings settings;
  15635. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  15636. toByteArray());
  15637. /*:32*/
  15638. #line 1133 "./typica.w"
  15639. event->accept();
  15640. }
  15641. else
  15642. {
  15643. event->ignore();
  15644. }
  15645. }
  15646. void ScriptQMainWindow::show()
  15647. {
  15648. QMainWindow::show();
  15649. }
  15650. void ScriptQMainWindow::setupFinished()
  15651. {
  15652. emit windowReady();
  15653. }
  15654. /*:27*//*28:*/
  15655. #line 1159 "./typica.w"
  15656. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  15657. {
  15658. if(isWindowModified()){
  15659. /*29:*/
  15660. #line 1173 "./typica.w"
  15661. QMessageBox::StandardButton result;
  15662. result= QMessageBox::warning(this,"Typica",closePrompt(),
  15663. QMessageBox::Ok|QMessageBox::Cancel);
  15664. if(result==QMessageBox::Cancel)
  15665. {
  15666. event->ignore();
  15667. return;
  15668. }
  15669. /*:29*/
  15670. #line 1163 "./typica.w"
  15671. }
  15672. emit aboutToClose();
  15673. /*31:*/
  15674. #line 1204 "./typica.w"
  15675. QSettings settings;
  15676. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  15677. /*:31*/
  15678. #line 1166 "./typica.w"
  15679. event->accept();
  15680. }
  15681. /*:28*//*30:*/
  15682. #line 1185 "./typica.w"
  15683. QString ScriptQMainWindow::closePrompt()
  15684. {
  15685. return cprompt;
  15686. }
  15687. void ScriptQMainWindow::setClosePrompt(QString prompt)
  15688. {
  15689. cprompt= prompt;
  15690. }
  15691. /*:30*//*35:*/
  15692. #line 1238 "./typica.w"
  15693. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  15694. {
  15695. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  15696. setQMainWindowProperties(object,engine);
  15697. return object;
  15698. }
  15699. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  15700. {
  15701. setQWidgetProperties(value,engine);
  15702. value.setProperty("setCentralWidget",
  15703. engine->newFunction(QMainWindow_setCentralWidget));
  15704. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  15705. }
  15706. /*:35*//*36:*/
  15707. #line 1260 "./typica.w"
  15708. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  15709. QScriptEngine*)
  15710. {
  15711. if(context->argumentCount()==1)
  15712. {
  15713. QMainWindow*self= getself<QMainWindow*> (context);
  15714. QWidget*widget= argument<QWidget*> (0,context);
  15715. if(widget)
  15716. {
  15717. self->setCentralWidget(widget);
  15718. }
  15719. else
  15720. {
  15721. context->throwError("Incorrect argument type passed to "
  15722. "QMainWindow::setCentralWidget(). This "
  15723. "method requires a QWidget.");
  15724. }
  15725. }
  15726. else
  15727. {
  15728. context->throwError("Incorrect number of arguments passed to "
  15729. "QMainWindow::setCentralWidget(). This method "
  15730. "takes one QWidget as an argument.");
  15731. }
  15732. return QScriptValue();
  15733. }
  15734. /*:36*//*37:*/
  15735. #line 1294 "./typica.w"
  15736. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  15737. {
  15738. QScriptValue object;
  15739. if(context->argumentCount()==0)
  15740. {
  15741. QMainWindow*self= getself<QMainWindow*> (context);
  15742. QMenuBar*bar= self->menuBar();
  15743. object= engine->newQObject(bar);
  15744. setQMenuBarProperties(object,engine);
  15745. }
  15746. else
  15747. {
  15748. context->throwError("Incorrect number of arguments passed to "
  15749. "QMainWindow::menuBar(). This method takes no "
  15750. "arguments.");
  15751. }
  15752. return object;
  15753. }
  15754. /*:37*//*39:*/
  15755. #line 1324 "./typica.w"
  15756. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  15757. {
  15758. setQWidgetProperties(value,engine);
  15759. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  15760. }
  15761. /*:39*//*40:*/
  15762. #line 1339 "./typica.w"
  15763. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  15764. {
  15765. QScriptValue object;
  15766. if(context->argumentCount()==1)
  15767. {
  15768. QMenuBar*self= getself<QMenuBar*> (context);
  15769. QString title= argument<QString> (0,context);
  15770. object= engine->newQObject(self->addMenu(title));
  15771. setQMenuProperties(object,engine);
  15772. }
  15773. else
  15774. {
  15775. context->throwError("Incorrect number of arguments passed to "
  15776. "QMenuBar::addMenu(). This method takes one "
  15777. "string as an argument.");
  15778. }
  15779. return object;
  15780. }
  15781. /*:40*//*42:*/
  15782. #line 1369 "./typica.w"
  15783. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  15784. {
  15785. setQWidgetProperties(value,engine);
  15786. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  15787. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  15788. }
  15789. /*:42*//*43:*/
  15790. #line 1379 "./typica.w"
  15791. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  15792. {
  15793. if(context->argumentCount()==1)
  15794. {
  15795. QMenu*self= getself<QMenu*> (context);
  15796. QAction*action= argument<QAction*> (0,context);
  15797. if(action)
  15798. {
  15799. self->addAction(action);
  15800. }
  15801. else
  15802. {
  15803. context->throwError("Incorrect argument type passed to "
  15804. "QMenu::addAction(). This method requires a "
  15805. "QAction.");
  15806. }
  15807. }
  15808. else
  15809. {
  15810. context->throwError("Incorrect number of arguments passed to "
  15811. "QMenu::addAction(). This method takes one "
  15812. "QAction as an argument.");
  15813. }
  15814. return QScriptValue();
  15815. }
  15816. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  15817. {
  15818. if(context->argumentCount()==0)
  15819. {
  15820. QMenu*self= getself<QMenu*> (context);
  15821. self->addSeparator();
  15822. }
  15823. else
  15824. {
  15825. context->throwError("Incorrect number of arguments passed to "
  15826. "QMenu::addSeparator(). This method takes no "
  15827. "arguments.");
  15828. }
  15829. return QScriptValue();
  15830. }
  15831. /*:43*//*46:*/
  15832. #line 1441 "./typica.w"
  15833. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  15834. {
  15835. QScriptValue object= engine->newQObject(new QFrame);
  15836. setQFrameProperties(object,engine);
  15837. return object;
  15838. }
  15839. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  15840. {
  15841. setQWidgetProperties(value,engine);
  15842. }
  15843. /*:46*//*49:*/
  15844. #line 1475 "./typica.w"
  15845. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  15846. {
  15847. QString text;
  15848. if(context->argumentCount()==1)
  15849. {
  15850. text= argument<QString> (0,context);
  15851. }
  15852. QScriptValue object= engine->newQObject(new QLabel(text));
  15853. setQLabelProperties(object,engine);
  15854. return object;
  15855. }
  15856. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  15857. {
  15858. setQFrameProperties(value,engine);
  15859. }
  15860. /*:49*//*52:*/
  15861. #line 1517 "./typica.w"
  15862. QScriptValue constructQSvgWidget(QScriptContext*,
  15863. QScriptEngine*engine)
  15864. {
  15865. QScriptValue object= engine->newQObject(new QSvgWidget);
  15866. setQSvgWidgetProperties(object,engine);
  15867. return object;
  15868. }
  15869. /*:52*//*53:*/
  15870. #line 1528 "./typica.w"
  15871. void setQSvgWidgetProperties(QScriptValue value,QScriptEngine*engine)
  15872. {
  15873. setQWidgetProperties(value,engine);
  15874. value.setProperty("loadDevice",
  15875. engine->newFunction(QSvgWidget_loadDevice));
  15876. }
  15877. QScriptValue QSvgWidget_loadDevice(QScriptContext*context,QScriptEngine*)
  15878. {
  15879. if(context->argumentCount()==1)
  15880. {
  15881. QSvgWidget*self= getself<QSvgWidget*> (context);
  15882. QIODevice*device= argument<QIODevice*> (0,context);
  15883. device->reset();
  15884. QByteArray data= device->readAll();
  15885. self->load(data);
  15886. }
  15887. else
  15888. {
  15889. context->throwError("Incorrect number of arguments passed to "
  15890. "QSvgWidget::loadData(). This method takes one "
  15891. "QIODevice as an argument.");
  15892. }
  15893. return QScriptValue();
  15894. }
  15895. /*:53*//*55:*/
  15896. #line 1566 "./typica.w"
  15897. void addSvgWidgetToLayout(QDomElement element,QStack<QWidget*> *,
  15898. QStack<QLayout*> *layoutStack)
  15899. {
  15900. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  15901. QSvgWidget*widget= new QSvgWidget;
  15902. layout->addWidget(widget);
  15903. QString id= element.attribute("id");
  15904. if(!id.isEmpty())
  15905. {
  15906. widget->setObjectName(id);
  15907. }
  15908. }
  15909. /*:55*//*58:*/
  15910. #line 1599 "./typica.w"
  15911. QScriptValue constructQLineEdit(QScriptContext*,QScriptEngine*engine)
  15912. {
  15913. QScriptValue object= engine->newQObject(new QLineEdit());
  15914. setQLineEditProperties(object,engine);
  15915. return object;
  15916. }
  15917. /*:58*//*59:*/
  15918. #line 1610 "./typica.w"
  15919. void setQLineEditProperties(QScriptValue value,QScriptEngine*engine)
  15920. {
  15921. setQWidgetProperties(value,engine);
  15922. }
  15923. /*:59*//*62:*/
  15924. #line 1648 "./typica.w"
  15925. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  15926. {
  15927. QScriptValue object= engine->newQObject(new QSplitter);
  15928. setQSplitterProperties(object,engine);
  15929. return object;
  15930. }
  15931. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  15932. {
  15933. setQFrameProperties(value,engine);
  15934. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  15935. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  15936. value.setProperty("restoreState",
  15937. engine->newFunction(QSplitter_restoreState));
  15938. value.setProperty("count",engine->newFunction(QSplitter_count));
  15939. value.setProperty("setCollapsible",engine->newFunction(QSplitter_setCollapsible));
  15940. }
  15941. /*:62*//*63:*/
  15942. #line 1670 "./typica.w"
  15943. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  15944. {
  15945. if(context->argumentCount()==1)
  15946. {
  15947. QSplitter*self= getself<QSplitter*> (context);
  15948. QWidget*widget= argument<QWidget*> (0,context);
  15949. if(widget)
  15950. {
  15951. self->addWidget(widget);
  15952. }
  15953. else
  15954. {
  15955. context->throwError("Incorrect argument type passed to "
  15956. "QSplitter::addWidget(). This method "
  15957. "requires a QWidget.");
  15958. }
  15959. }
  15960. else
  15961. {
  15962. context->throwError("Incorrect number of arguments passed to "
  15963. "QSplitter::addWidget(). This method takes one "
  15964. "QWidget as an argument.");
  15965. }
  15966. return QScriptValue();
  15967. }
  15968. /*:63*//*64:*/
  15969. #line 1707 "./typica.w"
  15970. QScriptValue QSplitter_count(QScriptContext*context,QScriptEngine*)
  15971. {
  15972. QSplitter*self= getself<QSplitter*> (context);
  15973. return QScriptValue(self->count());
  15974. }
  15975. /*:64*//*65:*/
  15976. #line 1720 "./typica.w"
  15977. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  15978. {
  15979. if(context->argumentCount()==1)
  15980. {
  15981. QSplitter*self= getself<QSplitter*> (context);
  15982. QString key= argument<QString> (0,context);
  15983. QSettings settings;
  15984. settings.setValue(key,self->saveState());
  15985. }
  15986. else
  15987. {
  15988. context->throwError("Incorrect number of arguments passed to "
  15989. "QSplitter::saveState(). This method takes one "
  15990. "string as an argument.");
  15991. }
  15992. return QScriptValue();
  15993. }
  15994. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  15995. {
  15996. if(context->argumentCount()==1)
  15997. {
  15998. QSplitter*self= getself<QSplitter*> (context);
  15999. QString key= argument<QString> (0,context);
  16000. QSettings settings;
  16001. self->restoreState(settings.value(key).toByteArray());
  16002. }
  16003. else
  16004. {
  16005. context->throwError("Incorrect number of arguments passed to "
  16006. "QSplitter::restoreState(). This method takes "
  16007. "one string as an argument.");
  16008. }
  16009. return QScriptValue();
  16010. }
  16011. /*:65*//*66:*/
  16012. #line 1761 "./typica.w"
  16013. QScriptValue QSplitter_setCollapsible(QScriptContext*context,QScriptEngine*)
  16014. {
  16015. if(context->argumentCount()==2)
  16016. {
  16017. QSplitter*self= getself<QSplitter*> (context);
  16018. self->setCollapsible(argument<int> (0,context),argument<bool> (1,context));
  16019. }
  16020. else
  16021. {
  16022. context->throwError("Incorrect number of arguments");
  16023. }
  16024. return QScriptValue();
  16025. }
  16026. /*:66*//*68:*/
  16027. #line 1792 "./typica.w"
  16028. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16029. {
  16030. setQLayoutItemProperties(value,engine);
  16031. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  16032. }
  16033. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16034. {
  16035. if(context->argumentCount()==1)
  16036. {
  16037. QLayout*self= getself<QLayout*> (context);
  16038. QWidget*widget= argument<QWidget*> (0,context);
  16039. if(widget)
  16040. {
  16041. self->addWidget(widget);
  16042. }
  16043. else
  16044. {
  16045. context->throwError("Incorrect argument type passed to "
  16046. "QLayout::addWidget(). This method requires "
  16047. "a QWidget.");
  16048. }
  16049. }
  16050. else
  16051. {
  16052. context->throwError("Incorrect number of arguments passed to "
  16053. "QLayout::addWidget(). This method takes one "
  16054. "QWidget as an argument.");
  16055. }
  16056. return QScriptValue();
  16057. }
  16058. /*:68*//*71:*/
  16059. #line 1859 "./typica.w"
  16060. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  16061. {
  16062. QScriptValue object=
  16063. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  16064. setQBoxLayoutProperties(object,engine);
  16065. return object;
  16066. }
  16067. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  16068. {
  16069. setQLayoutProperties(value,engine);
  16070. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  16071. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  16072. }
  16073. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  16074. {
  16075. if(context->argumentCount()> 0&&context->argumentCount()<3)
  16076. {
  16077. QBoxLayout*self= getself<QBoxLayout*> (context);
  16078. QLayout*layout= argument<QLayout*> (0,context);
  16079. int stretch= 0;
  16080. if(context->argumentCount()==2)
  16081. {
  16082. stretch= argument<int> (1,context);
  16083. }
  16084. if(layout)
  16085. {
  16086. self->addLayout(layout,stretch);
  16087. }
  16088. else
  16089. {
  16090. context->throwError("Incorrect argument type passed to "
  16091. "QLayout::addLayout(). This method requires "
  16092. "a QLayout.");
  16093. }
  16094. }
  16095. else
  16096. {
  16097. context->throwError("Incorrect number of arguments passed to "
  16098. "QLayout::addLayout(). This method takes one "
  16099. "QLayout as an argument and optionally one integer.");
  16100. }
  16101. return QScriptValue();
  16102. }
  16103. /*:71*//*72:*/
  16104. #line 1910 "./typica.w"
  16105. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  16106. {
  16107. if(context->argumentCount()> 0&&context->argumentCount()<4)
  16108. {
  16109. QBoxLayout*self= getself<QBoxLayout*> (context);
  16110. QWidget*widget= argument<QWidget*> (0,context);
  16111. int stretch= 0;
  16112. Qt::Alignment alignment= 0;
  16113. if(context->argumentCount()> 1)
  16114. {
  16115. stretch= argument<int> (1,context);
  16116. }
  16117. if(context->argumentCount()> 2)
  16118. {
  16119. alignment= (Qt::Alignment)(argument<int> (2,context));
  16120. }
  16121. if(widget)
  16122. {
  16123. self->addWidget(widget,stretch,alignment);
  16124. }
  16125. else
  16126. {
  16127. context->throwError("Incorrect argument type passed to "
  16128. "QBoxLayout::addWidget(). This method requires "
  16129. "a QWidget.");
  16130. }
  16131. }
  16132. else
  16133. {
  16134. context->throwError("Incorrect number of arguments passed to "
  16135. "QBoxLayout::addWidget(). This method takes one "
  16136. "QWidget and optionally up to two integers as "
  16137. "arguments.");
  16138. }
  16139. return QScriptValue();
  16140. }
  16141. /*:72*//*75:*/
  16142. #line 1974 "./typica.w"
  16143. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  16144. {
  16145. QScriptValue object= engine->newQObject(new QAction(NULL));
  16146. setQActionProperties(object,engine);
  16147. return object;
  16148. }
  16149. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  16150. {
  16151. setQObjectProperties(value,engine);
  16152. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  16153. }
  16154. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  16155. {
  16156. if(context->argumentCount()==1)
  16157. {
  16158. QAction*self= getself<QAction*> (context);
  16159. self->setShortcut(argument<QString> (0,context));
  16160. }
  16161. else
  16162. {
  16163. context->throwError("Incorrect number of arguments passed to "
  16164. "QAction::setShortcut(). This method takes one "
  16165. "string as an argument.");
  16166. }
  16167. return QScriptValue();
  16168. }
  16169. /*:75*//*78:*/
  16170. #line 2032 "./typica.w"
  16171. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  16172. QScriptEngine*engine)
  16173. {
  16174. QScriptValue retval;
  16175. if(context->argumentCount()==3)
  16176. {
  16177. QWidget*widget= argument<QWidget*> (0,context);
  16178. if(widget)
  16179. {
  16180. QString caption= argument<QString> (1,context);
  16181. QString dir= argument<QString> (2,context);
  16182. retval= QScriptValue(engine,
  16183. QFileDialog::getOpenFileName(widget,caption,
  16184. dir,"",0,0));
  16185. setQFileDialogProperties(retval,engine);
  16186. }
  16187. else
  16188. {
  16189. context->throwError("Incorrect argument type passed to "
  16190. "QFileDialog::getOpenFileName(). The first "
  16191. "argument to this method must be a QWidget.");
  16192. }
  16193. }
  16194. else
  16195. {
  16196. context->throwError("Incorrect number of arguments passed to "
  16197. "QFileDialog::getOpenFileName(). This method "
  16198. "takes one QWidget followed by two strings for a "
  16199. "total of three arguments.");
  16200. }
  16201. return retval;
  16202. }
  16203. /*:78*//*79:*/
  16204. #line 2068 "./typica.w"
  16205. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  16206. QScriptEngine*engine)
  16207. {
  16208. QScriptValue retval;
  16209. if(context->argumentCount()==3)
  16210. {
  16211. QWidget*widget= argument<QWidget*> (0,context);
  16212. if(widget)
  16213. {
  16214. QString caption= argument<QString> (1,context);
  16215. QString dir= argument<QString> (2,context);
  16216. retval= QScriptValue(engine,
  16217. QFileDialog::getSaveFileName(widget,caption,
  16218. dir,"",0,0));
  16219. setQFileDialogProperties(retval,engine);
  16220. }
  16221. else
  16222. {
  16223. context->throwError("Incorrect argument type passed to "
  16224. "QFileDialog::getSaveFileName(). The first "
  16225. "argument to this method must be a QWidget.");
  16226. }
  16227. }
  16228. else
  16229. {
  16230. context->throwError("Incorrect number of arguments passed to "
  16231. "QFileDialog::getSaveFileName(). This method "
  16232. "takes one QWidget followed by two strings for a "
  16233. "total of three arguments.");
  16234. }
  16235. return retval;
  16236. }
  16237. /*:79*//*80:*/
  16238. #line 2105 "./typica.w"
  16239. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  16240. {
  16241. setQDialogProperties(value,engine);
  16242. }
  16243. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  16244. {
  16245. setQWidgetProperties(value,engine);
  16246. }
  16247. /*:80*//*83:*/
  16248. #line 2146 "./typica.w"
  16249. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  16250. {
  16251. QScriptValue object=
  16252. engine->newQObject(new QFile(argument<QString> (0,context)));
  16253. setQFileProperties(object,engine);
  16254. return object;
  16255. }
  16256. /*:83*//*84:*/
  16257. #line 2157 "./typica.w"
  16258. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  16259. {
  16260. setQIODeviceProperties(value,engine);
  16261. value.setProperty("remove",engine->newFunction(QFile_remove));
  16262. }
  16263. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  16264. {
  16265. QFile*self= getself<QFile*> (context);
  16266. bool retval= self->remove();
  16267. return QScriptValue(engine,retval);
  16268. }
  16269. /*:84*//*85:*/
  16270. #line 2179 "./typica.w"
  16271. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  16272. {
  16273. setQObjectProperties(value,engine);
  16274. value.setProperty("open",engine->newFunction(QIODevice_open));
  16275. value.setProperty("close",engine->newFunction(QIODevice_close));
  16276. value.setProperty("readToString",
  16277. engine->newFunction(QIODevice_readToString));
  16278. value.setProperty("putChar",engine->newFunction(QIODevice_putChar));
  16279. value.setProperty("writeString",engine->newFunction(QIODevice_writeString));
  16280. value.setProperty("writeBytes",engine->newFunction(QIODevice_writeBytes));
  16281. value.setProperty("readBytes",engine->newFunction(QIODevice_readBytes));
  16282. value.setProperty("peek",engine->newFunction(QIODevice_peek));
  16283. value.setProperty("read",engine->newFunction(QIODevice_read));
  16284. }
  16285. /*:85*//*86:*/
  16286. #line 2200 "./typica.w"
  16287. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  16288. {
  16289. QIODevice*self= getself<QIODevice*> (context);
  16290. bool retval= false;
  16291. if(context->argumentCount()==1)
  16292. {
  16293. switch(argument<int> (0,context))
  16294. {
  16295. case 1:
  16296. retval= self->open(QIODevice::ReadOnly);
  16297. break;
  16298. case 2:
  16299. retval= self->open(QIODevice::WriteOnly);
  16300. break;
  16301. case 3:
  16302. retval= self->open(QIODevice::ReadWrite);
  16303. break;
  16304. default:
  16305. break;
  16306. }
  16307. }
  16308. else
  16309. {
  16310. retval= self->open(QIODevice::ReadWrite);
  16311. }
  16312. return QScriptValue(retval);
  16313. }
  16314. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  16315. {
  16316. QIODevice*self= getself<QIODevice*> (context);
  16317. self->close();
  16318. return QScriptValue();
  16319. }
  16320. /*:86*//*87:*/
  16321. #line 2240 "./typica.w"
  16322. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  16323. {
  16324. QIODevice*self= getself<QIODevice*> (context);
  16325. self->reset();
  16326. return QScriptValue(QString(self->readAll()));
  16327. }
  16328. /*:87*//*88:*/
  16329. #line 2256 "./typica.w"
  16330. QScriptValue QIODevice_putChar(QScriptContext*context,QScriptEngine*)
  16331. {
  16332. QIODevice*self= getself<QIODevice*> (context);
  16333. if(context->argumentCount()==1)
  16334. {
  16335. return QScriptValue(self->putChar(argument<QString> (0,context).toUtf8().at(0)));
  16336. }
  16337. context->throwError("Incorrect number of arguments passed to "
  16338. "QIODevice::putChar()");
  16339. return QScriptValue();
  16340. }
  16341. /*:88*//*89:*/
  16342. #line 2274 "./typica.w"
  16343. QScriptValue QIODevice_writeString(QScriptContext*context,QScriptEngine*)
  16344. {
  16345. QIODevice*self= getself<QIODevice*> (context);
  16346. if(context->argumentCount()==1)
  16347. {
  16348. self->write(argument<QString> (0,context).toUtf8());
  16349. }
  16350. else
  16351. {
  16352. context->throwError("Incorrect number of arguments passed to "
  16353. "QIODevice::writeString()");
  16354. }
  16355. return QScriptValue();
  16356. }
  16357. QScriptValue QIODevice_writeBytes(QScriptContext*context,QScriptEngine*)
  16358. {
  16359. QIODevice*self= getself<QIODevice*> (context);
  16360. if(context->argumentCount()==1)
  16361. {
  16362. self->write(argument<QByteArray> (0,context));
  16363. }
  16364. else
  16365. {
  16366. context->throwError("Incorrect number of arguments passed to "
  16367. "QIODevice::writeBytes()");
  16368. }
  16369. return QScriptValue();
  16370. }
  16371. /*:89*//*90:*/
  16372. #line 2308 "./typica.w"
  16373. QScriptValue QIODevice_readBytes(QScriptContext*context,QScriptEngine*engine)
  16374. {
  16375. QIODevice*self= getself<QIODevice*> (context);
  16376. QScriptValue value= engine->toScriptValue<QByteArray> (self->readAll());
  16377. setQByteArrayProperties(value,engine);
  16378. return value;
  16379. }
  16380. /*:90*//*91:*/
  16381. #line 2319 "./typica.w"
  16382. QScriptValue QIODevice_peek(QScriptContext*context,QScriptEngine*engine)
  16383. {
  16384. QIODevice*self= getself<QIODevice*> (context);
  16385. QScriptValue value= engine->toScriptValue<QByteArray> (
  16386. self->peek(argument<int> (0,context)));
  16387. setQByteArrayProperties(value,engine);
  16388. return value;
  16389. }
  16390. QScriptValue QIODevice_read(QScriptContext*context,QScriptEngine*engine)
  16391. {
  16392. QIODevice*self= getself<QIODevice*> (context);
  16393. QScriptValue value= engine->toScriptValue<QByteArray> (
  16394. self->read(argument<int> (0,context)));
  16395. setQByteArrayProperties(value,engine);
  16396. return value;
  16397. }
  16398. /*:91*//*94:*/
  16399. #line 2364 "./typica.w"
  16400. QScriptValue constructQProcess(QScriptContext*,QScriptEngine*engine)
  16401. {
  16402. QScriptValue object= engine->newQObject(new QProcess);
  16403. setQProcessProperties(object,engine);
  16404. return object;
  16405. }
  16406. /*:94*//*95:*/
  16407. #line 2375 "./typica.w"
  16408. void setQProcessProperties(QScriptValue value,QScriptEngine*engine)
  16409. {
  16410. setQIODeviceProperties(value,engine);
  16411. value.setProperty("execute",engine->newFunction(QProcess_execute));
  16412. value.setProperty("startDetached",engine->newFunction(QProcess_startDetached));
  16413. value.setProperty("setWorkingDirectory",engine->newFunction(QProcess_setWorkingDirectory));
  16414. value.setProperty("start",engine->newFunction(QProcess_start));
  16415. }
  16416. /*:95*//*96:*/
  16417. #line 2389 "./typica.w"
  16418. QScriptValue QProcess_execute(QScriptContext*context,QScriptEngine*)
  16419. {
  16420. QProcess*self= getself<QProcess*> (context);
  16421. QString program= argument<QString> (0,context);
  16422. QStringList arguments= QStringList();
  16423. if(context->argumentCount()> 1){
  16424. arguments= argument<QVariant> (1,context).toStringList();
  16425. }
  16426. int retval= self->execute(program,arguments);
  16427. return QScriptValue(retval);
  16428. }
  16429. /*:96*//*97:*/
  16430. #line 2404 "./typica.w"
  16431. QScriptValue QProcess_startDetached(QScriptContext*context,QScriptEngine*)
  16432. {
  16433. QProcess*self= getself<QProcess*> (context);
  16434. QString program= argument<QString> (0,context);
  16435. QStringList arguments= QStringList();
  16436. if(context->argumentCount()> 1){
  16437. arguments= argument<QVariant> (1,context).toStringList();
  16438. }
  16439. QString workingDirectory= "";
  16440. if(context->argumentCount()> 2){
  16441. workingDirectory= argument<QString> (2,context);
  16442. }
  16443. bool retval;
  16444. switch(context->argumentCount())
  16445. {
  16446. case 1:
  16447. retval= self->startDetached(program);
  16448. break;
  16449. case 2:
  16450. retval= self->startDetached(program,arguments);
  16451. break;
  16452. case 3:
  16453. retval= self->startDetached(program,arguments,workingDirectory);
  16454. break;
  16455. default:
  16456. retval= false;
  16457. }
  16458. return QScriptValue(retval);
  16459. }
  16460. /*:97*//*98:*/
  16461. #line 2437 "./typica.w"
  16462. QScriptValue QProcess_setWorkingDirectory(QScriptContext*context,QScriptEngine*)
  16463. {
  16464. QProcess*self= getself<QProcess*> (context);
  16465. QString directory= argument<QString> (0,context);
  16466. self->setWorkingDirectory(directory);
  16467. return QScriptValue();
  16468. }
  16469. /*:98*//*99:*/
  16470. #line 2449 "./typica.w"
  16471. QScriptValue QProcess_start(QScriptContext*context,QScriptEngine*)
  16472. {
  16473. QProcess*self= getself<QProcess*> (context);
  16474. QString program= argument<QString> (0,context);
  16475. QStringList arguments= QStringList();
  16476. if(context->argumentCount()> 1){
  16477. arguments= argument<QVariant> (1,context).toStringList();
  16478. }
  16479. self->start(program,arguments);
  16480. return QScriptValue();
  16481. }
  16482. /*:99*//*101:*/
  16483. #line 2490 "./typica.w"
  16484. QScriptValue QByteArray_toScriptValue(QScriptEngine*engine,const QByteArray&bytes)
  16485. {
  16486. QScriptValue object= engine->newVariant(QVariant(bytes));
  16487. setQByteArrayProperties(object,engine);
  16488. return object;
  16489. }
  16490. void QByteArray_fromScriptValue(const QScriptValue&value,QByteArray&bytes)
  16491. {
  16492. bytes= value.toVariant().toByteArray();
  16493. }
  16494. /*:101*//*103:*/
  16495. #line 2513 "./typica.w"
  16496. QScriptValue constructQByteArray(QScriptContext*,QScriptEngine*engine)
  16497. {
  16498. QScriptValue object= engine->toScriptValue<QByteArray> (QByteArray());
  16499. setQByteArrayProperties(object,engine);
  16500. return object;
  16501. }
  16502. /*:103*//*104:*/
  16503. #line 2524 "./typica.w"
  16504. void setQByteArrayProperties(QScriptValue value,QScriptEngine*engine)
  16505. {
  16506. value.setProperty("fromHex",engine->newFunction(QByteArray_fromHex));
  16507. value.setProperty("getAt",engine->newFunction(QByteArray_getAt));
  16508. value.setProperty("setAt",engine->newFunction(QByteArray_setAt));
  16509. value.setProperty("appendBytes",engine->newFunction(QByteArray_appendBytes));
  16510. value.setProperty("appendString",engine->newFunction(QByteArray_appendString));
  16511. value.setProperty("size",engine->newFunction(QByteArray_size));
  16512. value.setProperty("left",engine->newFunction(QByteArray_left));
  16513. value.setProperty("right",engine->newFunction(QByteArray_right));
  16514. value.setProperty("mid",engine->newFunction(QByteArray_mid));
  16515. value.setProperty("chop",engine->newFunction(QByteArray_chop));
  16516. value.setProperty("remove",engine->newFunction(QByteArray_remove));
  16517. value.setProperty("toInt8",engine->newFunction(QByteArray_toInt8));
  16518. value.setProperty("toInt16",engine->newFunction(QByteArray_toInt16));
  16519. value.setProperty("toInt32",engine->newFunction(QByteArray_toInt32));
  16520. value.setProperty("toFloat",engine->newFunction(QByteArray_toFloat));
  16521. value.setProperty("toDouble",engine->newFunction(QByteArray_toDouble));
  16522. }
  16523. /*:104*//*105:*/
  16524. #line 2548 "./typica.w"
  16525. QScriptValue QByteArray_fromHex(QScriptContext*context,QScriptEngine*engine)
  16526. {
  16527. QByteArray self= getself<QByteArray> (context);
  16528. QByteArray retval;
  16529. retval= self.fromHex(argument<QString> (0,context).toUtf8());
  16530. QScriptValue value= engine->toScriptValue<QByteArray> (retval);
  16531. setQByteArrayProperties(value,engine);
  16532. return value;
  16533. }
  16534. /*:105*//*106:*/
  16535. #line 2562 "./typica.w"
  16536. QScriptValue QByteArray_getAt(QScriptContext*context,QScriptEngine*)
  16537. {
  16538. QByteArray self= getself<QByteArray> (context);
  16539. return QScriptValue((int)(self.at(argument<int> (0,context))));
  16540. }
  16541. QScriptValue QByteArray_setAt(QScriptContext*context,QScriptEngine*)
  16542. {
  16543. QByteArray self= getself<QByteArray> (context);
  16544. self[argument<int> (0,context)]= (char)(argument<int> (1,context));
  16545. return QScriptValue();
  16546. }
  16547. /*:106*//*107:*/
  16548. #line 2580 "./typica.w"
  16549. QScriptValue QByteArray_appendBytes(QScriptContext*context,QScriptEngine*engine)
  16550. {
  16551. QByteArray self= getself<QByteArray> (context);
  16552. QScriptValue value=
  16553. engine->toScriptValue<QByteArray> (
  16554. self.append(argument<QByteArray> (0,context)));
  16555. setQByteArrayProperties(value,engine);
  16556. return value;
  16557. }
  16558. QScriptValue QByteArray_appendString(QScriptContext*context,QScriptEngine*engine)
  16559. {
  16560. QByteArray self= getself<QByteArray> (context);
  16561. QScriptValue value= engine->toScriptValue<QByteArray> (
  16562. self.append(argument<QString> (0,context)));
  16563. setQByteArrayProperties(value,engine);
  16564. return value;
  16565. }
  16566. /*:107*//*108:*/
  16567. #line 2602 "./typica.w"
  16568. QScriptValue QByteArray_size(QScriptContext*context,QScriptEngine*)
  16569. {
  16570. QByteArray self= getself<QByteArray> (context);
  16571. return QScriptValue(self.size());
  16572. }
  16573. /*:108*//*109:*/
  16574. #line 2612 "./typica.w"
  16575. QScriptValue QByteArray_left(QScriptContext*context,QScriptEngine*engine)
  16576. {
  16577. QByteArray self= getself<QByteArray> (context);
  16578. QScriptValue value= engine->toScriptValue<QByteArray> (
  16579. self.left(argument<int> (0,context)));
  16580. setQByteArrayProperties(value,engine);
  16581. return value;
  16582. }
  16583. QScriptValue QByteArray_right(QScriptContext*context,QScriptEngine*engine)
  16584. {
  16585. QByteArray self= getself<QByteArray> (context);
  16586. QScriptValue value= engine->toScriptValue<QByteArray> (
  16587. self.right(argument<int> (0,context)));
  16588. setQByteArrayProperties(value,engine);
  16589. return value;
  16590. }
  16591. QScriptValue QByteArray_mid(QScriptContext*context,QScriptEngine*engine)
  16592. {
  16593. QByteArray self= getself<QByteArray> (context);
  16594. int length= -1;
  16595. if(context->argumentCount()> 1)
  16596. {
  16597. length= argument<int> (1,context);
  16598. }
  16599. QScriptValue value= engine->toScriptValue<QByteArray> (
  16600. self.mid(argument<int> (0,context),length));
  16601. setQByteArrayProperties(value,engine);
  16602. return value;
  16603. }
  16604. /*:109*//*110:*/
  16605. #line 2647 "./typica.w"
  16606. QScriptValue QByteArray_chop(QScriptContext*context,QScriptEngine*)
  16607. {
  16608. QByteArray self= getself<QByteArray> (context);
  16609. self.chop(argument<int> (0,context));
  16610. return QScriptValue();
  16611. }
  16612. QScriptValue QByteArray_remove(QScriptContext*context,QScriptEngine*engine)
  16613. {
  16614. QByteArray self= getself<QByteArray> (context);
  16615. QScriptValue value= engine->toScriptValue<QByteArray> (
  16616. self.remove(argument<int> (0,context),argument<int> (1,context)));
  16617. setQByteArrayProperties(value,engine);
  16618. return value;
  16619. }
  16620. /*:110*//*111:*/
  16621. #line 2670 "./typica.w"
  16622. QScriptValue QByteArray_toInt8(QScriptContext*context,QScriptEngine*)
  16623. {
  16624. QByteArray self= getself<QByteArray> (context);
  16625. int value= 0;
  16626. char*bytes= (char*)&value;
  16627. bytes[0]= self[0];
  16628. return QScriptValue(value);
  16629. }
  16630. QScriptValue QByteArray_toInt16(QScriptContext*context,QScriptEngine*)
  16631. {
  16632. QByteArray self= getself<QByteArray> (context);
  16633. int value= 0;
  16634. char*bytes= (char*)&value;
  16635. bytes[0]= self[0];
  16636. bytes[1]= self[1];
  16637. return QScriptValue(value);
  16638. }
  16639. QScriptValue QByteArray_toInt32(QScriptContext*context,QScriptEngine*)
  16640. {
  16641. QByteArray self= getself<QByteArray> (context);
  16642. int value= 0;
  16643. char*bytes= (char*)&value;
  16644. bytes[0]= self[0];
  16645. bytes[1]= self[1];
  16646. bytes[2]= self[2];
  16647. bytes[3]= self[3];
  16648. return QScriptValue(value);
  16649. }
  16650. /*:111*//*112:*/
  16651. #line 2706 "./typica.w"
  16652. QScriptValue QByteArray_toFloat(QScriptContext*context,QScriptEngine*)
  16653. {
  16654. QByteArray self= getself<QByteArray> (context);
  16655. float value= 0.0;
  16656. char*bytes= (char*)&value;
  16657. bytes[0]= self[0];
  16658. bytes[1]= self[1];
  16659. bytes[2]= self[2];
  16660. bytes[3]= self[3];
  16661. return QScriptValue(value);
  16662. }
  16663. QScriptValue QByteArray_toDouble(QScriptContext*context,QScriptEngine*)
  16664. {
  16665. QByteArray self= getself<QByteArray> (context);
  16666. double value= 0.0;
  16667. char*bytes= (char*)&value;
  16668. bytes[0]= self[0];
  16669. bytes[1]= self[1];
  16670. bytes[2]= self[2];
  16671. bytes[3]= self[3];
  16672. bytes[4]= self[4];
  16673. bytes[5]= self[5];
  16674. bytes[6]= self[6];
  16675. bytes[7]= self[7];
  16676. return QScriptValue(value);
  16677. }
  16678. /*:112*//*115:*/
  16679. #line 2761 "./typica.w"
  16680. QScriptValue bytesFromInt8(QScriptContext*context,QScriptEngine*engine)
  16681. {
  16682. qint8 value= (qint8)(argument<int> (0,context));
  16683. char*bytes= (char*)&value;
  16684. QByteArray retval;
  16685. retval.resize(1);
  16686. retval[0]= bytes[0];
  16687. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16688. setQByteArrayProperties(v,engine);
  16689. return v;
  16690. }
  16691. QScriptValue bytesFromInt16(QScriptContext*context,QScriptEngine*engine)
  16692. {
  16693. qint16 value= (qint16)(argument<int> (0,context));
  16694. char*bytes= (char*)&value;
  16695. QByteArray retval;
  16696. retval.resize(2);
  16697. retval[0]= bytes[0];
  16698. retval[1]= bytes[1];
  16699. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16700. setQByteArrayProperties(v,engine);
  16701. return v;
  16702. }
  16703. QScriptValue bytesFromInt32(QScriptContext*context,QScriptEngine*engine)
  16704. {
  16705. qint32 value= (qint32)(argument<int> (0,context));
  16706. char*bytes= (char*)&value;
  16707. QByteArray retval;
  16708. retval.resize(4);
  16709. retval[0]= bytes[0];
  16710. retval[1]= bytes[1];
  16711. retval[2]= bytes[2];
  16712. retval[3]= bytes[3];
  16713. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16714. setQByteArrayProperties(v,engine);
  16715. return v;
  16716. }
  16717. QScriptValue bytesFromFloat(QScriptContext*context,QScriptEngine*engine)
  16718. {
  16719. float value= (float)(argument<double> (0,context));
  16720. char*bytes= (char*)&value;
  16721. QByteArray retval;
  16722. retval.resize(4);
  16723. retval[0]= bytes[0];
  16724. retval[1]= bytes[1];
  16725. retval[2]= bytes[2];
  16726. retval[3]= bytes[3];
  16727. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16728. setQByteArrayProperties(v,engine);
  16729. return v;
  16730. }
  16731. QScriptValue bytesFromDouble(QScriptContext*context,QScriptEngine*engine)
  16732. {
  16733. double value= (double)(argument<double> (0,context));
  16734. char*bytes= (char*)&value;
  16735. QByteArray retval;
  16736. retval.resize(8);
  16737. retval[0]= bytes[0];
  16738. retval[1]= bytes[1];
  16739. retval[2]= bytes[2];
  16740. retval[3]= bytes[3];
  16741. retval[4]= bytes[4];
  16742. retval[5]= bytes[5];
  16743. retval[6]= bytes[6];
  16744. retval[7]= bytes[7];
  16745. QScriptValue v= engine->toScriptValue<QByteArray> (retval);
  16746. setQByteArrayProperties(v,engine);
  16747. return v;
  16748. }
  16749. /*:115*//*118:*/
  16750. #line 2858 "./typica.w"
  16751. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  16752. {
  16753. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  16754. QScriptValue object= engine->newQObject(new QBuffer(array));
  16755. setQBufferProperties(object,engine);
  16756. return object;
  16757. }
  16758. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  16759. {
  16760. setQIODeviceProperties(value,engine);
  16761. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  16762. }
  16763. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  16764. {
  16765. QBuffer*self= getself<QBuffer*> (context);
  16766. self->setData(argument<QString> (0,context).toAscii());
  16767. return QScriptValue();
  16768. }
  16769. /*:118*//*121:*/
  16770. #line 2907 "./typica.w"
  16771. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  16772. {
  16773. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  16774. setXQueryProperties(object,engine);
  16775. return object;
  16776. }
  16777. QScriptValue XQuery_invalidate(QScriptContext*context,QScriptEngine*)
  16778. {
  16779. QXmlQuery*self= getself<QXmlQuery*> (context);
  16780. delete self;
  16781. return QScriptValue();
  16782. }
  16783. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  16784. {
  16785. value.setProperty("bind",engine->newFunction(XQuery_bind));
  16786. value.setProperty("exec",engine->newFunction(XQuery_exec));
  16787. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  16788. value.setProperty("invalidate",engine->newFunction(XQuery_invalidate));
  16789. }
  16790. /*:121*//*122:*/
  16791. #line 2933 "./typica.w"
  16792. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  16793. {
  16794. QXmlQuery*self= getself<QXmlQuery*> (context);
  16795. QIODevice*buffer= argument<QIODevice*> (1,context);
  16796. self->bindVariable(argument<QString> (0,context),buffer);
  16797. return QScriptValue();
  16798. }
  16799. /*:122*//*123:*/
  16800. #line 2944 "./typica.w"
  16801. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  16802. {
  16803. QXmlQuery*self= getself<QXmlQuery*> (context);
  16804. self->setQuery(argument<QString> (0,context));
  16805. return QScriptValue();
  16806. }
  16807. /*:123*//*124:*/
  16808. #line 2954 "./typica.w"
  16809. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  16810. {
  16811. QXmlQuery*self= getself<QXmlQuery*> (context);
  16812. QString result;
  16813. self->evaluateTo(&result);
  16814. return QScriptValue(result);
  16815. }
  16816. /*:124*//*127:*/
  16817. #line 3009 "./typica.w"
  16818. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  16819. {
  16820. QXmlStreamWriter*retval;
  16821. if(context->argumentCount()==1)
  16822. {
  16823. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  16824. }
  16825. else
  16826. {
  16827. retval= new QXmlStreamWriter;
  16828. }
  16829. QScriptValue object= engine->toScriptValue<void*> (retval);
  16830. setXmlWriterProperties(object,engine);
  16831. return object;
  16832. }
  16833. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  16834. {
  16835. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  16836. value.setProperty("writeAttribute",
  16837. engine->newFunction(XmlWriter_writeAttribute));
  16838. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  16839. value.setProperty("writeCharacters",
  16840. engine->newFunction(XmlWriter_writeCharacters));
  16841. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  16842. value.setProperty("writeEmptyElement",
  16843. engine->newFunction(XmlWriter_writeEmptyElement));
  16844. value.setProperty("writeEndDocument",
  16845. engine->newFunction(XmlWriter_writeEndDocument));
  16846. value.setProperty("writeEndElement",
  16847. engine->newFunction(XmlWriter_writeEndElement));
  16848. value.setProperty("writeEntityReference",
  16849. engine->newFunction(XmlWriter_writeEntityReference));
  16850. value.setProperty("writeProcessingInstruction",
  16851. engine->newFunction(XmlWriter_writeProcessingInstruction));
  16852. value.setProperty("writeStartDocument",
  16853. engine->newFunction(XmlWriter_writeStartDocument));
  16854. value.setProperty("writeStartElement",
  16855. engine->newFunction(XmlWriter_writeStartElement));
  16856. value.setProperty("writeTextElement",
  16857. engine->newFunction(XmlWriter_writeTextElement));
  16858. }
  16859. /*:127*//*128:*/
  16860. #line 3056 "./typica.w"
  16861. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  16862. {
  16863. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16864. QIODevice*device= argument<QIODevice*> (0,context);
  16865. self->setDevice(device);
  16866. return QScriptValue();
  16867. }
  16868. /*:128*//*129:*/
  16869. #line 3070 "./typica.w"
  16870. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  16871. QScriptEngine*)
  16872. {
  16873. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16874. self->writeStartDocument(argument<QString> (0,context));
  16875. return QScriptValue();
  16876. }
  16877. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  16878. QScriptEngine*)
  16879. {
  16880. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16881. self->writeEndDocument();
  16882. return QScriptValue();
  16883. }
  16884. /*:129*//*130:*/
  16885. #line 3089 "./typica.w"
  16886. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  16887. {
  16888. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16889. self->writeDTD(argument<QString> (0,context));
  16890. return QScriptValue();
  16891. }
  16892. /*:130*//*131:*/
  16893. #line 3100 "./typica.w"
  16894. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  16895. QScriptEngine*)
  16896. {
  16897. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16898. self->writeStartElement(argument<QString> (0,context));
  16899. return QScriptValue();
  16900. }
  16901. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  16902. {
  16903. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16904. self->writeAttribute(argument<QString> (0,context),
  16905. argument<QString> (1,context));
  16906. return QScriptValue();
  16907. }
  16908. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  16909. {
  16910. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16911. self->writeCharacters(argument<QString> (0,context));
  16912. return QScriptValue();
  16913. }
  16914. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  16915. {
  16916. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16917. self->writeEndElement();
  16918. return QScriptValue();
  16919. }
  16920. /*:131*//*132:*/
  16921. #line 3136 "./typica.w"
  16922. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  16923. QScriptEngine*)
  16924. {
  16925. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16926. self->writeEmptyElement(argument<QString> (0,context));
  16927. return QScriptValue();
  16928. }
  16929. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  16930. QScriptEngine*)
  16931. {
  16932. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16933. self->writeTextElement(argument<QString> (0,context),
  16934. argument<QString> (1,context));
  16935. return QScriptValue();
  16936. }
  16937. /*:132*//*133:*/
  16938. #line 3157 "./typica.w"
  16939. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  16940. {
  16941. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16942. self->writeCDATA(argument<QString> (0,context));
  16943. return QScriptValue();
  16944. }
  16945. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  16946. QScriptEngine*)
  16947. {
  16948. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16949. self->writeEntityReference(argument<QString> (0,context));
  16950. return QScriptValue();
  16951. }
  16952. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  16953. QScriptEngine*)
  16954. {
  16955. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  16956. self->writeProcessingInstruction(argument<QString> (0,context),
  16957. argument<QString> (1,context));
  16958. return QScriptValue();
  16959. }
  16960. /*:133*//*136:*/
  16961. #line 3216 "./typica.w"
  16962. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  16963. {
  16964. QXmlStreamReader*retval=
  16965. new QXmlStreamReader(argument<QIODevice*> (0,context));
  16966. QScriptValue object= engine->toScriptValue<void*> (retval);
  16967. setXmlReaderProperties(object,engine);
  16968. return object;
  16969. }
  16970. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  16971. {
  16972. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  16973. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  16974. value.setProperty("hasAttribute",
  16975. engine->newFunction(XmlReader_hasAttribute));
  16976. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  16977. value.setProperty("isStartElement",
  16978. engine->newFunction(XmlReader_isStartElement));
  16979. value.setProperty("name",engine->newFunction(XmlReader_name));
  16980. value.setProperty("readElementText",
  16981. engine->newFunction(XmlReader_readElementText));
  16982. value.setProperty("readNext",
  16983. engine->newFunction(XmlReader_readNext));
  16984. value.setProperty("text",engine->newFunction(XmlReader_text));
  16985. }
  16986. /*:136*//*137:*/
  16987. #line 3246 "./typica.w"
  16988. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  16989. {
  16990. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16991. QString retval=
  16992. self->attributes().value(argument<QString> (0,context)).toString();
  16993. return QScriptValue(retval);
  16994. }
  16995. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  16996. {
  16997. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  16998. bool retval=
  16999. self->attributes().hasAttribute(argument<QString> (0,context));
  17000. return QScriptValue(retval);
  17001. }
  17002. /*:137*//*138:*/
  17003. #line 3266 "./typica.w"
  17004. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  17005. {
  17006. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17007. return QScriptValue(self->atEnd());
  17008. }
  17009. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  17010. {
  17011. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17012. return QScriptValue(self->isDTD());
  17013. }
  17014. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  17015. {
  17016. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17017. return QScriptValue(self->isStartElement());
  17018. }
  17019. /*:138*//*139:*/
  17020. #line 3287 "./typica.w"
  17021. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  17022. {
  17023. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17024. self->readNext();
  17025. return QScriptValue();
  17026. }
  17027. /*:139*//*140:*/
  17028. #line 3297 "./typica.w"
  17029. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  17030. {
  17031. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17032. return QScriptValue(self->name().toString());
  17033. }
  17034. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  17035. {
  17036. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17037. return QScriptValue(self->readElementText());
  17038. }
  17039. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  17040. {
  17041. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  17042. return QScriptValue(self->text().toString());
  17043. }
  17044. /*:140*//*143:*/
  17045. #line 3339 "./typica.w"
  17046. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  17047. {
  17048. setQObjectProperties(value,engine);
  17049. value.setProperty("value",engine->newFunction(QSettings_value));
  17050. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  17051. }
  17052. /*:143*//*144:*/
  17053. #line 3351 "./typica.w"
  17054. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  17055. {
  17056. QScriptValue object;
  17057. if(context->argumentCount()==1||context->argumentCount()==2)
  17058. {
  17059. QSettings settings;
  17060. QString key= argument<QString> (0,context);
  17061. QVariant value;
  17062. QVariant retval;
  17063. if(context->argumentCount()> 1)
  17064. {
  17065. value= argument<QVariant> (1,context);
  17066. retval= settings.value(key,value);
  17067. }
  17068. else
  17069. {
  17070. retval= settings.value(key);
  17071. }
  17072. object= engine->newVariant(retval);
  17073. }
  17074. else
  17075. {
  17076. context->throwError("Incorrect number of arguments passed to "
  17077. "QSettings::value(). This method takes one "
  17078. "string and one optional variant type.");
  17079. }
  17080. return object;
  17081. }
  17082. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  17083. {
  17084. if(context->argumentCount()==2)
  17085. {
  17086. QSettings settings;
  17087. QString key= argument<QString> (0,context);
  17088. QVariant value= argument<QVariant> (1,context);
  17089. settings.setValue(key,value);
  17090. }
  17091. else
  17092. {
  17093. context->throwError("Incorrect number of arguments passed to "
  17094. "QSettings::setValue(). This method takes one "
  17095. "string and one variant type for a total of two "
  17096. "arguments.");
  17097. }
  17098. return QScriptValue();
  17099. }
  17100. /*:144*//*147:*/
  17101. #line 3420 "./typica.w"
  17102. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  17103. {
  17104. QScriptValue object= engine->newQObject(new QLCDNumber());
  17105. setQLCDNumberProperties(object,engine);
  17106. return object;
  17107. }
  17108. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  17109. {
  17110. setQFrameProperties(value,engine);
  17111. }
  17112. /*:147*//*150:*/
  17113. #line 3478 "./typica.w"
  17114. QScriptValue constructQTime(QScriptContext*context,
  17115. QScriptEngine*engine)
  17116. {
  17117. QScriptValue object;
  17118. if(context->argumentCount()==0||
  17119. (context->argumentCount()>=2&&context->argumentCount()<=4))
  17120. {
  17121. int arg1= 0;
  17122. int arg2= 0;
  17123. int arg3= 0;
  17124. int arg4= 0;
  17125. switch(context->argumentCount())
  17126. {
  17127. case 4:
  17128. arg4= argument<int> (3,context);
  17129. case 3:
  17130. arg3= argument<int> (2,context);
  17131. case 2:
  17132. arg2= argument<int> (1,context);
  17133. arg1= argument<int> (0,context);
  17134. default:
  17135. break;
  17136. }
  17137. if(context->argumentCount())
  17138. {
  17139. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  17140. arg4));
  17141. }
  17142. else
  17143. {
  17144. object= engine->toScriptValue<QTime> (QTime());
  17145. }
  17146. setQTimeProperties(object,engine);
  17147. }
  17148. else
  17149. {
  17150. context->throwError("Incorrect number of arguments passed to "
  17151. "QTime::QTime(). This method takes zero, two, "
  17152. "three, or four integer arguments.");
  17153. }
  17154. return object;
  17155. }
  17156. /*:150*//*151:*/
  17157. #line 3526 "./typica.w"
  17158. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  17159. {
  17160. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  17161. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  17162. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  17163. value.setProperty("hour",engine->newFunction(QTime_hour));
  17164. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  17165. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  17166. value.setProperty("minute",engine->newFunction(QTime_minute));
  17167. value.setProperty("msec",engine->newFunction(QTime_msec));
  17168. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  17169. value.setProperty("restart",engine->newFunction(QTime_restart));
  17170. value.setProperty("second",engine->newFunction(QTime_second));
  17171. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  17172. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  17173. value.setProperty("start",engine->newFunction(QTime_start));
  17174. value.setProperty("toString",engine->newFunction(QTime_toString));
  17175. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  17176. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  17177. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  17178. }
  17179. /*:151*//*152:*/
  17180. #line 3555 "./typica.w"
  17181. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  17182. {
  17183. QTime self= getself<QTime> (context);
  17184. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  17185. (self.second()*1000)+self.msec();
  17186. return QScriptValue(retval);
  17187. }
  17188. /*:152*//*153:*/
  17189. #line 3569 "./typica.w"
  17190. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  17191. {
  17192. QTime time;
  17193. QScriptValue retval;
  17194. if(context->argumentCount()==1)
  17195. {
  17196. QTime self= getself<QTime> (context);
  17197. time= self.addMSecs(argument<int> (0,context));
  17198. retval= engine->toScriptValue<QTime> (time);
  17199. setQTimeProperties(retval,engine);
  17200. }
  17201. else
  17202. {
  17203. context->throwError("Incorrect number of arguments passed to "
  17204. "QTime::addMSecs(). This method takes one "
  17205. "integer as an argument.");
  17206. }
  17207. return retval;
  17208. }
  17209. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  17210. {
  17211. QTime time;
  17212. QScriptValue retval;
  17213. if(context->argumentCount()==1)
  17214. {
  17215. QTime self= getself<QTime> (context);
  17216. time= self.addSecs(argument<int> (0,context));
  17217. retval= engine->toScriptValue<QTime> (time);
  17218. setQTimeProperties(retval,engine);
  17219. }
  17220. else
  17221. {
  17222. context->throwError("Incorrect number of arguments passed to "
  17223. "QTime::addSecs(). This method takes one "
  17224. "integer as an argument.");
  17225. }
  17226. return retval;
  17227. }
  17228. /*:153*//*154:*/
  17229. #line 3612 "./typica.w"
  17230. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  17231. {
  17232. QScriptValue retval;
  17233. if(context->argumentCount()==0)
  17234. {
  17235. QTime self= getself<QTime> (context);
  17236. retval= QScriptValue(engine,self.elapsed());
  17237. }
  17238. else
  17239. {
  17240. context->throwError("Incorrect number of arguments passed to "
  17241. "QTime::elapsed(). This method takes no "
  17242. "arguments.");
  17243. }
  17244. return retval;
  17245. }
  17246. /*:154*//*155:*/
  17247. #line 3633 "./typica.w"
  17248. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  17249. {
  17250. QScriptValue retval;
  17251. if(context->argumentCount()==0)
  17252. {
  17253. QTime self= getself<QTime> (context);
  17254. retval= QScriptValue(engine,self.hour());
  17255. }
  17256. else
  17257. {
  17258. context->throwError("Incorrect number of arguments passed to "
  17259. "QTime::hour(). This method takes no "
  17260. "arguments.");
  17261. }
  17262. return retval;
  17263. }
  17264. /*:155*//*156:*/
  17265. #line 3653 "./typica.w"
  17266. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  17267. {
  17268. QScriptValue retval;
  17269. if(context->argumentCount()==0)
  17270. {
  17271. QTime self= getself<QTime> (context);
  17272. retval= QScriptValue(engine,self.minute());
  17273. }
  17274. else
  17275. {
  17276. context->throwError("Incorrect number of arguments passed to "
  17277. "QTime::minute(). This method takes no "
  17278. "arguments.");
  17279. }
  17280. return retval;
  17281. }
  17282. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  17283. {
  17284. QScriptValue retval;
  17285. if(context->argumentCount()==0)
  17286. {
  17287. QTime self= getself<QTime> (context);
  17288. retval= QScriptValue(engine,self.second());
  17289. }
  17290. else
  17291. {
  17292. context->throwError("Incorrect number of arguments passed to "
  17293. "QTime::second(). This method takes no "
  17294. "arguments.");
  17295. }
  17296. return retval;
  17297. }
  17298. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  17299. {
  17300. QScriptValue retval;
  17301. if(context->argumentCount()==0)
  17302. {
  17303. QTime self= getself<QTime> (context);
  17304. retval= QScriptValue(engine,self.msec());
  17305. }
  17306. else
  17307. {
  17308. context->throwError("Incorrect number of arguments passed to "
  17309. "QTime::msec(). This method takes no "
  17310. "arguments.");
  17311. }
  17312. return retval;
  17313. }
  17314. /*:156*//*157:*/
  17315. #line 3709 "./typica.w"
  17316. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  17317. {
  17318. QScriptValue retval;
  17319. if(context->argumentCount()==0)
  17320. {
  17321. QTime self= getself<QTime> (context);
  17322. retval= QScriptValue(engine,self.isNull());
  17323. }
  17324. else
  17325. {
  17326. context->throwError("Incorrect number of arguments passed to "
  17327. "QTime::isNull(). This method takes no "
  17328. "arguments.");
  17329. }
  17330. return retval;
  17331. }
  17332. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  17333. {
  17334. QScriptValue retval;
  17335. if(context->argumentCount()==0)
  17336. {
  17337. QTime self= getself<QTime> (context);
  17338. retval= QScriptValue(engine,self.isValid());
  17339. }
  17340. else
  17341. {
  17342. context->throwError("Incorrect number of arguments passed to "
  17343. "QTime::isValid(). This method takes no "
  17344. "arguments.");
  17345. }
  17346. return retval;
  17347. }
  17348. /*:157*//*158:*/
  17349. #line 3747 "./typica.w"
  17350. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  17351. {
  17352. QScriptValue retval;
  17353. if(context->argumentCount()==1)
  17354. {
  17355. QTime self= getself<QTime> (context);
  17356. QTime arg= argument<QVariant> (0,context).toTime();
  17357. retval= QScriptValue(engine,self.msecsTo(arg));
  17358. }
  17359. else
  17360. {
  17361. context->throwError("Incorrect number of arguments passed to "
  17362. "QTime::msecsTo(). This method takes one QTime.");
  17363. }
  17364. return retval;
  17365. }
  17366. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  17367. {
  17368. QScriptValue retval;
  17369. if(context->argumentCount()==1)
  17370. {
  17371. QTime self= getself<QTime> (context);
  17372. QTime arg= argument<QVariant> (0,context).toTime();
  17373. retval= QScriptValue(engine,self.secsTo(arg));
  17374. }
  17375. else
  17376. {
  17377. context->throwError("Incorrect number of arguments passed to "
  17378. "QTime::secsTo(). This method takes one QTime.");
  17379. }
  17380. return retval;
  17381. }
  17382. /*:158*//*159:*/
  17383. #line 3786 "./typica.w"
  17384. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  17385. {
  17386. QScriptValue retval;
  17387. if(context->argumentCount()==0)
  17388. {
  17389. QTime self= getself<QTime> (context);
  17390. retval= QScriptValue(engine,self.restart());
  17391. }
  17392. else
  17393. {
  17394. context->throwError("Incorrect number of arguments passed to "
  17395. "QTime::restart(). This method takes no "
  17396. "arguments.");
  17397. }
  17398. return retval;
  17399. }
  17400. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  17401. {
  17402. if(context->argumentCount()==0)
  17403. {
  17404. QTime self= getself<QTime> (context);
  17405. self.start();
  17406. }
  17407. else
  17408. {
  17409. context->throwError("Incorrect number of arguments passed to "
  17410. "QTime::start(). This method takes no arguments.");
  17411. }
  17412. return QScriptValue();
  17413. }
  17414. /*:159*//*160:*/
  17415. #line 3822 "./typica.w"
  17416. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  17417. {
  17418. QScriptValue retval;
  17419. if(context->argumentCount()==3||context->argumentCount()==4)
  17420. {
  17421. QTime self= getself<QTime> (context);
  17422. int arg1= 0;
  17423. int arg2= 0;
  17424. int arg3= 0;
  17425. int arg4= 0;
  17426. switch(context->argumentCount())
  17427. {
  17428. case 4:
  17429. arg4= argument<int> (3,context);
  17430. case 3:
  17431. arg3= argument<int> (2,context);
  17432. arg2= argument<int> (1,context);
  17433. arg1= argument<int> (0,context);
  17434. default:
  17435. break;
  17436. }
  17437. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  17438. }
  17439. else
  17440. {
  17441. context->throwError("Incorrect number of arguments passed to "
  17442. "QTime::setHMS(). This method takes three or "
  17443. "four integer arguments.");
  17444. }
  17445. return retval;
  17446. }
  17447. /*:160*//*161:*/
  17448. #line 3858 "./typica.w"
  17449. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  17450. {
  17451. QScriptValue retval;
  17452. if(context->argumentCount()==1)
  17453. {
  17454. QTime self= getself<QTime> (context);
  17455. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  17456. }
  17457. else
  17458. {
  17459. context->throwError("Incorrect number of arguments passed to "
  17460. "QTime::toString(). This method takes one QString "
  17461. "as an argument.");
  17462. }
  17463. return retval;
  17464. }
  17465. /*:161*//*162:*/
  17466. #line 3879 "./typica.w"
  17467. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  17468. {
  17469. QScriptValue object;
  17470. object= engine->toScriptValue<QTime> (QTime::currentTime());
  17471. setQTimeProperties(object,engine);
  17472. return object;
  17473. }
  17474. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  17475. {
  17476. QScriptValue object;
  17477. if(context->argumentCount()==2)
  17478. {
  17479. QString time= argument<QString> (0,context);
  17480. QString format= argument<QString> (1,context);
  17481. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  17482. setQTimeProperties(object,engine);
  17483. }
  17484. else
  17485. {
  17486. context->throwError("Incorrect number of arguments passed to "
  17487. "QTime::fromString(). This method takes two "
  17488. "string arguments.");
  17489. }
  17490. return object;
  17491. }
  17492. /*:162*//*163:*/
  17493. #line 3910 "./typica.w"
  17494. template<> QTime argument(int arg,QScriptContext*context)
  17495. {
  17496. return qscriptvalue_cast<QTime> (context->argument(arg));
  17497. }
  17498. /*:163*//*165:*/
  17499. #line 3928 "./typica.w"
  17500. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  17501. {
  17502. setQFrameProperties(value,engine);
  17503. }
  17504. /*:165*//*167:*/
  17505. #line 3942 "./typica.w"
  17506. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  17507. {
  17508. setQAbstractScrollAreaProperties(value,engine);
  17509. }
  17510. /*:167*//*169:*/
  17511. #line 3956 "./typica.w"
  17512. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  17513. {
  17514. setQAbstractScrollAreaProperties(value,engine);
  17515. }
  17516. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  17517. {
  17518. setQAbstractItemViewProperties(value,engine);
  17519. }
  17520. /*:169*//*172:*/
  17521. #line 3989 "./typica.w"
  17522. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  17523. {
  17524. QScriptValue object= engine->newQObject(new QPushButton());
  17525. setQPushButtonProperties(object,engine);
  17526. return object;
  17527. }
  17528. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  17529. {
  17530. setQAbstractButtonProperties(value,engine);
  17531. }
  17532. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  17533. {
  17534. setQWidgetProperties(value,engine);
  17535. }
  17536. /*:172*//*179:*/
  17537. #line 4101 "./typica.w"
  17538. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  17539. {
  17540. SqlQueryConnection*obj= new SqlQueryConnection();
  17541. QScriptValue object=
  17542. engine->toScriptValue<void*> (obj);
  17543. setQSqlQueryProperties(object,engine);
  17544. return object;
  17545. }
  17546. /*:179*//*180:*/
  17547. #line 4114 "./typica.w"
  17548. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  17549. {
  17550. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  17551. value.setProperty("bindFileData",
  17552. engine->newFunction(QSqlQuery_bindFileData));
  17553. value.setProperty("bindDeviceData",
  17554. engine->newFunction(QSqlQuery_bindDeviceData));
  17555. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  17556. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  17557. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  17558. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  17559. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  17560. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  17561. }
  17562. /*:180*//*181:*/
  17563. #line 4132 "./typica.w"
  17564. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  17565. {
  17566. QSqlQuery*q= getself<SqlQueryConnection*> (context)->operator->();
  17567. QScriptValue retval;
  17568. if(context->argumentCount()==1)
  17569. {
  17570. retval= QScriptValue(engine,
  17571. q->exec(argument<QString> (0,context)));
  17572. }
  17573. else
  17574. {
  17575. retval= QScriptValue(engine,q->exec());
  17576. }
  17577. if(q->lastError().isValid())
  17578. {
  17579. qDebug()<<q->lastQuery();
  17580. qDebug()<<q->lastError().text();
  17581. }
  17582. return retval;
  17583. }
  17584. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  17585. {
  17586. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17587. return QScriptValue(query->lastQuery());
  17588. }
  17589. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  17590. {
  17591. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17592. return QScriptValue(engine,query->next());
  17593. }
  17594. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  17595. {
  17596. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17597. return QScriptValue(engine,
  17598. query->value(argument<int> (0,context)).toString());
  17599. }
  17600. /*:181*//*182:*/
  17601. #line 4176 "./typica.w"
  17602. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  17603. {
  17604. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17605. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  17606. }
  17607. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  17608. {
  17609. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17610. query->bindValue(argument<QString> (0,context),
  17611. argument<QVariant> (1,context));
  17612. return QScriptValue();
  17613. }
  17614. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  17615. QScriptEngine*)
  17616. {
  17617. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17618. QString placeholder= argument<QString> (0,context);
  17619. QString filename= argument<QString> (1,context);
  17620. QFile file(filename);
  17621. QByteArray data;
  17622. if(file.open(QIODevice::ReadOnly))
  17623. {
  17624. data= file.readAll();
  17625. file.close();
  17626. }
  17627. query->bindValue(placeholder,data);
  17628. return QScriptValue();
  17629. }
  17630. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  17631. QScriptEngine*)
  17632. {
  17633. QSqlQuery*query= getself<SqlQueryConnection*> (context)->operator->();
  17634. QString placeholder= argument<QString> (0,context);
  17635. QIODevice*device= argument<QIODevice*> (1,context);
  17636. device->reset();
  17637. QByteArray data;
  17638. data= device->readAll();
  17639. query->bindValue(placeholder,data);
  17640. return QScriptValue();
  17641. }
  17642. /*:182*//*183:*/
  17643. #line 4228 "./typica.w"
  17644. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  17645. {
  17646. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  17647. delete query;
  17648. return QScriptValue::UndefinedValue;
  17649. }
  17650. /*:183*//*186:*/
  17651. #line 4275 "./typica.w"
  17652. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  17653. {
  17654. QFileInfo info(argument<QString> (0,context));
  17655. QScriptValue retval(engine,info.baseName());
  17656. return retval;
  17657. }
  17658. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  17659. {
  17660. QFileInfo info(argument<QString> (0,context));
  17661. QDir dir= info.dir();
  17662. QScriptValue retval(engine,dir.path());
  17663. return retval;
  17664. }
  17665. /*:186*//*187:*/
  17666. #line 4294 "./typica.w"
  17667. QScriptValue saveFileFromDatabase(QScriptContext*context,QScriptEngine*)
  17668. {
  17669. SqlQueryConnection h;
  17670. QSqlQuery*query= h.operator->();
  17671. QString q= "SELECT file FROM files WHERE id = :file";
  17672. query->prepare(q);
  17673. query->bindValue(":file",argument<int> (0,context));
  17674. query->exec();
  17675. query->next();
  17676. QByteArray array= query->value(0).toByteArray();
  17677. QFile file(argument<QString> (1,context));
  17678. file.open(QIODevice::WriteOnly);
  17679. file.write(array);
  17680. file.close();
  17681. return QScriptValue();
  17682. }
  17683. /*:187*//*188:*/
  17684. #line 4315 "./typica.w"
  17685. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  17686. {
  17687. QString source= argument<QString> (0,context);
  17688. source.remove(0,1);
  17689. source.chop(1);
  17690. QStringList elements= source.split(",");
  17691. QString element;
  17692. QScriptValue dest= engine->newArray(elements.size());
  17693. int i= 0;
  17694. foreach(element,elements)
  17695. {
  17696. if(element.startsWith("\"")&&element.endsWith("\""))
  17697. {
  17698. element.chop(1);
  17699. element= element.remove(0,1);
  17700. }
  17701. dest.setProperty(i,QScriptValue(engine,element));
  17702. i++;
  17703. }
  17704. return dest;
  17705. }
  17706. /*:188*//*189:*/
  17707. #line 4341 "./typica.w"
  17708. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  17709. {
  17710. QString font= argument<QString> (0,context);
  17711. QString classname;
  17712. if(context->argumentCount()> 1)
  17713. {
  17714. classname= argument<QString> (1,context);
  17715. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  17716. }
  17717. else
  17718. {
  17719. QApplication::setFont(QFont(font));
  17720. }
  17721. return QScriptValue();
  17722. }
  17723. /*:189*//*190:*/
  17724. #line 4361 "./typica.w"
  17725. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  17726. {
  17727. SqlQueryConnection h;
  17728. QSqlQuery*query= h.operator->();
  17729. QString q= "SELECT file FROM files WHERE id = :file";
  17730. query->prepare(q);
  17731. query->bindValue(":file",argument<int> (0,context));
  17732. query->exec();
  17733. query->next();
  17734. QByteArray array= query->value(0).toByteArray();
  17735. QBuffer buffer(&array);
  17736. buffer.open(QIODevice::ReadOnly);
  17737. QXmlQuery xquery;
  17738. xquery.bindVariable("profile",&buffer);
  17739. QString xq;
  17740. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  17741. xquery.setQuery(xq);
  17742. QString result;
  17743. xquery.evaluateTo(&result);
  17744. return QScriptValue(result);
  17745. }
  17746. /*:190*//*191:*/
  17747. #line 4388 "./typica.w"
  17748. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  17749. {
  17750. QWidget::setTabOrder(argument<QWidget*> (0,context),
  17751. argument<QWidget*> (1,context));
  17752. return QScriptValue();
  17753. }
  17754. /*:191*//*192:*/
  17755. #line 4399 "./typica.w"
  17756. QScriptValue scriptTr(QScriptContext*context,QScriptEngine*)
  17757. {
  17758. return QScriptValue(QCoreApplication::translate(
  17759. "configuration",
  17760. argument<QString> (1,context).toUtf8().data()));
  17761. }
  17762. /*:192*//*199:*/
  17763. #line 4668 "./typica.w"
  17764. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  17765. {
  17766. QString targetID= argument<QString> (0,context);
  17767. QDomNode element;
  17768. QScriptValue object;
  17769. /*201:*/
  17770. #line 4715 "./typica.w"
  17771. QDomNodeList windows=
  17772. AppInstance->configuration()->documentElement().elementsByTagName("window");
  17773. QDomNode nullNode;
  17774. int i= 0;
  17775. element= nullNode;
  17776. while(i<windows.count())
  17777. {
  17778. element= windows.at(i);
  17779. QDomNamedNodeMap attributes= element.attributes();
  17780. if(attributes.contains("id"))
  17781. {
  17782. if(attributes.namedItem("id").toAttr().value()==targetID)
  17783. {
  17784. break;
  17785. }
  17786. }
  17787. element= nullNode;
  17788. i++;
  17789. }
  17790. /*:201*/
  17791. #line 4674 "./typica.w"
  17792. if(!element.isNull())
  17793. {
  17794. /*202:*/
  17795. #line 4747 "./typica.w"
  17796. ScriptQMainWindow*window= new ScriptQMainWindow;
  17797. window->setObjectName(targetID);
  17798. object= engine->newQObject(window);
  17799. setQMainWindowProperties(object,engine);
  17800. QWidget*central= new(QWidget);
  17801. central->setParent(window);
  17802. central->setObjectName("centralWidget");
  17803. window->setCentralWidget(central);
  17804. if(element.hasChildNodes())
  17805. {
  17806. /*203:*/
  17807. #line 4783 "./typica.w"
  17808. QStack<QWidget*> widgetStack;
  17809. QStack<QLayout*> layoutStack;
  17810. QString windowScript;
  17811. widgetStack.push(central);
  17812. QDomNodeList windowChildren= element.childNodes();
  17813. int i= 0;
  17814. while(i<windowChildren.count())
  17815. {
  17816. QDomNode current;
  17817. QDomElement element;
  17818. current= windowChildren.at(i);
  17819. if(current.isElement())
  17820. {
  17821. element= current.toElement();
  17822. if(element.tagName()=="program")
  17823. {
  17824. windowScript.append(element.text());
  17825. }
  17826. else if(element.tagName()=="layout")
  17827. {
  17828. element.setAttribute("trcontext","configuration");
  17829. addLayoutToWidget(element,&widgetStack,&layoutStack);
  17830. }
  17831. else if(element.tagName()=="menu")
  17832. {
  17833. /*204:*/
  17834. #line 4831 "./typica.w"
  17835. QMenuBar*bar= window->menuBar();
  17836. bar->setParent(window);
  17837. bar->setObjectName("menuBar");
  17838. if(element.hasAttribute("name"))
  17839. {
  17840. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  17841. element.attribute("name").toUtf8().data()));
  17842. menu->setParent(bar);
  17843. if(element.hasAttribute("type"))
  17844. {
  17845. if(element.attribute("type")=="reports")
  17846. {
  17847. if(element.hasAttribute("src"))
  17848. {
  17849. /*664:*/
  17850. #line 14154 "./typica.w"
  17851. QSettings settings;
  17852. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  17853. toString()).
  17854. arg(element.attribute("src"));
  17855. QDir::addSearchPath("reports",reportDirectory);
  17856. QDir directory(reportDirectory);
  17857. directory.setFilter(QDir::Files);
  17858. directory.setSorting(QDir::Name);
  17859. QStringList nameFilter;
  17860. nameFilter<<"*.xml";
  17861. directory.setNameFilters(nameFilter);
  17862. QFileInfoList reportFiles= directory.entryInfoList();
  17863. for(int i= 0;i<reportFiles.size();i++)
  17864. {
  17865. QFileInfo reportFile= reportFiles.at(i);
  17866. /*668:*/
  17867. #line 14234 "./typica.w"
  17868. QString path= reportFile.absoluteFilePath();
  17869. QFile file(path);
  17870. if(file.open(QIODevice::ReadOnly))
  17871. {
  17872. QDomDocument document;
  17873. document.setContent(&file,true);
  17874. QDomElement root= document.documentElement();
  17875. QString translationContext= root.attribute("id");
  17876. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  17877. if(!titleNode.isNull())
  17878. {
  17879. QDomElement titleElement= titleNode.toElement();
  17880. QString title= QCoreApplication::translate("configuration",
  17881. titleElement.text().toUtf8().data());
  17882. if(!title.isEmpty())
  17883. {
  17884. QStringList hierarchy= title.split(":->");
  17885. QMenu*insertionPoint= menu;
  17886. /*669:*/
  17887. #line 14263 "./typica.w"
  17888. for(int j= 0;j<hierarchy.size()-1;j++)
  17889. {
  17890. QObjectList menuList= insertionPoint->children();
  17891. bool menuFound= false;
  17892. for(int k= 0;k<menuList.size();k++)
  17893. {
  17894. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  17895. if(currentItem)
  17896. {
  17897. if(currentItem->title()==hierarchy.at(j))
  17898. {
  17899. menuFound= true;
  17900. insertionPoint= currentItem;
  17901. break;
  17902. }
  17903. }
  17904. }
  17905. if(!menuFound)
  17906. {
  17907. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  17908. }
  17909. }
  17910. /*:669*/
  17911. #line 14253 "./typica.w"
  17912. ReportAction*action= new ReportAction(path,hierarchy.last());
  17913. insertionPoint->addAction(action);
  17914. }
  17915. }
  17916. }
  17917. /*:668*/
  17918. #line 14170 "./typica.w"
  17919. }
  17920. /*:664*/
  17921. #line 4846 "./typica.w"
  17922. }
  17923. }
  17924. }
  17925. if(element.hasChildNodes())
  17926. {
  17927. /*205:*/
  17928. #line 4859 "./typica.w"
  17929. QDomNodeList menuItems= element.childNodes();
  17930. int j= 0;
  17931. while(j<menuItems.count())
  17932. {
  17933. QDomNode item= menuItems.at(j);
  17934. if(item.isElement())
  17935. {
  17936. QDomElement itemElement= item.toElement();
  17937. if(itemElement.tagName()=="item")
  17938. {
  17939. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  17940. itemElement.text().toUtf8().data()),menu);
  17941. if(itemElement.hasAttribute("id"))
  17942. {
  17943. itemAction->setObjectName(itemElement.attribute("id"));
  17944. }
  17945. if(itemElement.hasAttribute("shortcut"))
  17946. {
  17947. itemAction->setShortcut(itemElement.attribute("shortcut"));
  17948. }
  17949. menu->addAction(itemAction);
  17950. }
  17951. else if(itemElement.tagName()=="separator")
  17952. {
  17953. menu->addSeparator();
  17954. }
  17955. else if(itemElement.tagName()=="plugins")
  17956. {
  17957. /*689:*/
  17958. #line 21 "./plugins.w"
  17959. QMenu*pluginMenu= new QMenu(menu);
  17960. if(itemElement.hasAttribute("id"))
  17961. {
  17962. pluginMenu->setObjectName(itemElement.attribute("id"));
  17963. }
  17964. if(itemElement.hasAttribute("title"))
  17965. {
  17966. pluginMenu->setTitle(itemElement.attribute("title"));
  17967. }
  17968. if(itemElement.hasAttribute("src"))
  17969. {
  17970. QSettings settings;
  17971. QString pluginDirectory= QString("%1/%2").
  17972. arg(settings.value("config").toString()).
  17973. arg(itemElement.attribute("src"));
  17974. QDir directory(pluginDirectory);
  17975. directory.setFilter(QDir::Files);
  17976. directory.setSorting(QDir::Name);
  17977. QStringList nameFilter;
  17978. nameFilter<<"*.js";
  17979. directory.setNameFilters(nameFilter);
  17980. QFileInfoList pluginFiles= directory.entryInfoList();
  17981. for(int k= 0;k<pluginFiles.size();k++)
  17982. {
  17983. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  17984. if(itemElement.hasAttribute("preRun"))
  17985. {
  17986. pa->setPreRun(itemElement.attribute("preRun"));
  17987. }
  17988. if(itemElement.hasAttribute("postRun"))
  17989. {
  17990. pa->setPostRun(itemElement.attribute("postRun"));
  17991. }
  17992. pluginMenu->addAction(pa);
  17993. }
  17994. }
  17995. menu->addMenu(pluginMenu);
  17996. /*:689*/
  17997. #line 4888 "./typica.w"
  17998. }
  17999. }
  18000. j++;
  18001. }
  18002. #line 1 "./helpmenu.w"
  18003. /*:205*/
  18004. #line 4852 "./typica.w"
  18005. }
  18006. }
  18007. /*:204*/
  18008. #line 4809 "./typica.w"
  18009. }
  18010. }
  18011. i++;
  18012. }
  18013. QScriptValue oldThis= context->thisObject();
  18014. context->setThisObject(object);
  18015. QScriptValue result= engine->evaluate(windowScript);
  18016. /*196:*/
  18017. #line 4562 "./typica.w"
  18018. if(engine->hasUncaughtException())
  18019. {
  18020. int line= engine->uncaughtExceptionLineNumber();
  18021. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18022. result.toString();
  18023. QString trace;
  18024. foreach(trace,engine->uncaughtExceptionBacktrace())
  18025. {
  18026. qDebug()<<trace;
  18027. }
  18028. }
  18029. /*:196*/
  18030. #line 4817 "./typica.w"
  18031. context->setThisObject(oldThis);
  18032. /*:203*/
  18033. #line 4758 "./typica.w"
  18034. }
  18035. /*206:*/
  18036. #line 9 "./helpmenu.w"
  18037. HelpMenu*helpMenu= new HelpMenu();
  18038. window->menuBar()->addMenu(helpMenu);
  18039. /*:206*/
  18040. #line 4760 "./typica.w"
  18041. window->show();
  18042. window->setupFinished();
  18043. /*:202*/
  18044. #line 4677 "./typica.w"
  18045. }
  18046. return object;
  18047. }
  18048. /*:199*//*200:*/
  18049. #line 4688 "./typica.w"
  18050. QScriptValue createReport(QScriptContext*context,QScriptEngine*engine)
  18051. {
  18052. QString targetID= argument<QString> (0,context);
  18053. QFile file(QString("reports:%1").arg(targetID));
  18054. QScriptValue object;
  18055. if(file.open(QIODevice::ReadOnly))
  18056. {
  18057. QDomDocument document;
  18058. document.setContent(&file,true);
  18059. QDomElement element= document.documentElement();
  18060. if(!element.isNull())
  18061. {
  18062. /*202:*/
  18063. #line 4747 "./typica.w"
  18064. ScriptQMainWindow*window= new ScriptQMainWindow;
  18065. window->setObjectName(targetID);
  18066. object= engine->newQObject(window);
  18067. setQMainWindowProperties(object,engine);
  18068. QWidget*central= new(QWidget);
  18069. central->setParent(window);
  18070. central->setObjectName("centralWidget");
  18071. window->setCentralWidget(central);
  18072. if(element.hasChildNodes())
  18073. {
  18074. /*203:*/
  18075. #line 4783 "./typica.w"
  18076. QStack<QWidget*> widgetStack;
  18077. QStack<QLayout*> layoutStack;
  18078. QString windowScript;
  18079. widgetStack.push(central);
  18080. QDomNodeList windowChildren= element.childNodes();
  18081. int i= 0;
  18082. while(i<windowChildren.count())
  18083. {
  18084. QDomNode current;
  18085. QDomElement element;
  18086. current= windowChildren.at(i);
  18087. if(current.isElement())
  18088. {
  18089. element= current.toElement();
  18090. if(element.tagName()=="program")
  18091. {
  18092. windowScript.append(element.text());
  18093. }
  18094. else if(element.tagName()=="layout")
  18095. {
  18096. element.setAttribute("trcontext","configuration");
  18097. addLayoutToWidget(element,&widgetStack,&layoutStack);
  18098. }
  18099. else if(element.tagName()=="menu")
  18100. {
  18101. /*204:*/
  18102. #line 4831 "./typica.w"
  18103. QMenuBar*bar= window->menuBar();
  18104. bar->setParent(window);
  18105. bar->setObjectName("menuBar");
  18106. if(element.hasAttribute("name"))
  18107. {
  18108. QMenu*menu= bar->addMenu(QCoreApplication::translate("configuration",
  18109. element.attribute("name").toUtf8().data()));
  18110. menu->setParent(bar);
  18111. if(element.hasAttribute("type"))
  18112. {
  18113. if(element.attribute("type")=="reports")
  18114. {
  18115. if(element.hasAttribute("src"))
  18116. {
  18117. /*664:*/
  18118. #line 14154 "./typica.w"
  18119. QSettings settings;
  18120. QString reportDirectory= QString("%1/%2").arg(settings.value("config").
  18121. toString()).
  18122. arg(element.attribute("src"));
  18123. QDir::addSearchPath("reports",reportDirectory);
  18124. QDir directory(reportDirectory);
  18125. directory.setFilter(QDir::Files);
  18126. directory.setSorting(QDir::Name);
  18127. QStringList nameFilter;
  18128. nameFilter<<"*.xml";
  18129. directory.setNameFilters(nameFilter);
  18130. QFileInfoList reportFiles= directory.entryInfoList();
  18131. for(int i= 0;i<reportFiles.size();i++)
  18132. {
  18133. QFileInfo reportFile= reportFiles.at(i);
  18134. /*668:*/
  18135. #line 14234 "./typica.w"
  18136. QString path= reportFile.absoluteFilePath();
  18137. QFile file(path);
  18138. if(file.open(QIODevice::ReadOnly))
  18139. {
  18140. QDomDocument document;
  18141. document.setContent(&file,true);
  18142. QDomElement root= document.documentElement();
  18143. QString translationContext= root.attribute("id");
  18144. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  18145. if(!titleNode.isNull())
  18146. {
  18147. QDomElement titleElement= titleNode.toElement();
  18148. QString title= QCoreApplication::translate("configuration",
  18149. titleElement.text().toUtf8().data());
  18150. if(!title.isEmpty())
  18151. {
  18152. QStringList hierarchy= title.split(":->");
  18153. QMenu*insertionPoint= menu;
  18154. /*669:*/
  18155. #line 14263 "./typica.w"
  18156. for(int j= 0;j<hierarchy.size()-1;j++)
  18157. {
  18158. QObjectList menuList= insertionPoint->children();
  18159. bool menuFound= false;
  18160. for(int k= 0;k<menuList.size();k++)
  18161. {
  18162. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  18163. if(currentItem)
  18164. {
  18165. if(currentItem->title()==hierarchy.at(j))
  18166. {
  18167. menuFound= true;
  18168. insertionPoint= currentItem;
  18169. break;
  18170. }
  18171. }
  18172. }
  18173. if(!menuFound)
  18174. {
  18175. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  18176. }
  18177. }
  18178. /*:669*/
  18179. #line 14253 "./typica.w"
  18180. ReportAction*action= new ReportAction(path,hierarchy.last());
  18181. insertionPoint->addAction(action);
  18182. }
  18183. }
  18184. }
  18185. /*:668*/
  18186. #line 14170 "./typica.w"
  18187. }
  18188. /*:664*/
  18189. #line 4846 "./typica.w"
  18190. }
  18191. }
  18192. }
  18193. if(element.hasChildNodes())
  18194. {
  18195. /*205:*/
  18196. #line 4859 "./typica.w"
  18197. QDomNodeList menuItems= element.childNodes();
  18198. int j= 0;
  18199. while(j<menuItems.count())
  18200. {
  18201. QDomNode item= menuItems.at(j);
  18202. if(item.isElement())
  18203. {
  18204. QDomElement itemElement= item.toElement();
  18205. if(itemElement.tagName()=="item")
  18206. {
  18207. QAction*itemAction= new QAction(QCoreApplication::translate("configuration",
  18208. itemElement.text().toUtf8().data()),menu);
  18209. if(itemElement.hasAttribute("id"))
  18210. {
  18211. itemAction->setObjectName(itemElement.attribute("id"));
  18212. }
  18213. if(itemElement.hasAttribute("shortcut"))
  18214. {
  18215. itemAction->setShortcut(itemElement.attribute("shortcut"));
  18216. }
  18217. menu->addAction(itemAction);
  18218. }
  18219. else if(itemElement.tagName()=="separator")
  18220. {
  18221. menu->addSeparator();
  18222. }
  18223. else if(itemElement.tagName()=="plugins")
  18224. {
  18225. /*689:*/
  18226. #line 21 "./plugins.w"
  18227. QMenu*pluginMenu= new QMenu(menu);
  18228. if(itemElement.hasAttribute("id"))
  18229. {
  18230. pluginMenu->setObjectName(itemElement.attribute("id"));
  18231. }
  18232. if(itemElement.hasAttribute("title"))
  18233. {
  18234. pluginMenu->setTitle(itemElement.attribute("title"));
  18235. }
  18236. if(itemElement.hasAttribute("src"))
  18237. {
  18238. QSettings settings;
  18239. QString pluginDirectory= QString("%1/%2").
  18240. arg(settings.value("config").toString()).
  18241. arg(itemElement.attribute("src"));
  18242. QDir directory(pluginDirectory);
  18243. directory.setFilter(QDir::Files);
  18244. directory.setSorting(QDir::Name);
  18245. QStringList nameFilter;
  18246. nameFilter<<"*.js";
  18247. directory.setNameFilters(nameFilter);
  18248. QFileInfoList pluginFiles= directory.entryInfoList();
  18249. for(int k= 0;k<pluginFiles.size();k++)
  18250. {
  18251. PluginAction*pa= new PluginAction(pluginFiles.at(k),pluginMenu);
  18252. if(itemElement.hasAttribute("preRun"))
  18253. {
  18254. pa->setPreRun(itemElement.attribute("preRun"));
  18255. }
  18256. if(itemElement.hasAttribute("postRun"))
  18257. {
  18258. pa->setPostRun(itemElement.attribute("postRun"));
  18259. }
  18260. pluginMenu->addAction(pa);
  18261. }
  18262. }
  18263. menu->addMenu(pluginMenu);
  18264. /*:689*/
  18265. #line 4888 "./typica.w"
  18266. }
  18267. }
  18268. j++;
  18269. }
  18270. #line 1 "./helpmenu.w"
  18271. /*:205*/
  18272. #line 4852 "./typica.w"
  18273. }
  18274. }
  18275. /*:204*/
  18276. #line 4809 "./typica.w"
  18277. }
  18278. }
  18279. i++;
  18280. }
  18281. QScriptValue oldThis= context->thisObject();
  18282. context->setThisObject(object);
  18283. QScriptValue result= engine->evaluate(windowScript);
  18284. /*196:*/
  18285. #line 4562 "./typica.w"
  18286. if(engine->hasUncaughtException())
  18287. {
  18288. int line= engine->uncaughtExceptionLineNumber();
  18289. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  18290. result.toString();
  18291. QString trace;
  18292. foreach(trace,engine->uncaughtExceptionBacktrace())
  18293. {
  18294. qDebug()<<trace;
  18295. }
  18296. }
  18297. /*:196*/
  18298. #line 4817 "./typica.w"
  18299. context->setThisObject(oldThis);
  18300. /*:203*/
  18301. #line 4758 "./typica.w"
  18302. }
  18303. /*206:*/
  18304. #line 9 "./helpmenu.w"
  18305. HelpMenu*helpMenu= new HelpMenu();
  18306. window->menuBar()->addMenu(helpMenu);
  18307. /*:206*/
  18308. #line 4760 "./typica.w"
  18309. window->show();
  18310. window->setupFinished();
  18311. /*:202*/
  18312. #line 4701 "./typica.w"
  18313. }
  18314. file.close();
  18315. }
  18316. return object;
  18317. }
  18318. /*:200*//*218:*/
  18319. #line 4908 "./typica.w"
  18320. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  18321. QStack<QLayout*> *layoutStack)
  18322. {
  18323. if(element.hasAttribute("type"))
  18324. {
  18325. /*219:*/
  18326. #line 4929 "./typica.w"
  18327. QLayout*layout;
  18328. QString layoutType= element.attribute("type");
  18329. if(layoutType=="horizontal")
  18330. {
  18331. layout= new QHBoxLayout;
  18332. layoutStack->push(layout);
  18333. populateBoxLayout(element,widgetStack,layoutStack);
  18334. }
  18335. else if(layoutType=="vertical")
  18336. {
  18337. layout= new QVBoxLayout;
  18338. layoutStack->push(layout);
  18339. populateBoxLayout(element,widgetStack,layoutStack);
  18340. }
  18341. else if(layoutType=="grid")
  18342. {
  18343. layout= new QGridLayout;
  18344. layoutStack->push(layout);
  18345. populateGridLayout(element,widgetStack,layoutStack);
  18346. }
  18347. else if(layoutType=="stack")
  18348. {
  18349. layout= new QStackedLayout;
  18350. layoutStack->push(layout);
  18351. populateStackedLayout(element,widgetStack,layoutStack);
  18352. }
  18353. if(element.hasAttribute("id"))
  18354. {
  18355. layout->setObjectName(element.attribute("id"));
  18356. }
  18357. if(element.hasAttribute("spacing"))
  18358. {
  18359. layout->setSpacing(element.attribute("spacing").toInt());
  18360. }
  18361. if(element.hasAttribute("margin"))
  18362. {
  18363. int m= element.attribute("margin").toInt();
  18364. layout->setContentsMargins(m,m,m,m);
  18365. }
  18366. /*:219*/
  18367. #line 4914 "./typica.w"
  18368. QWidget*widget= widgetStack->top();
  18369. if(layout)
  18370. {
  18371. widget->setLayout(layout);
  18372. }
  18373. layoutStack->pop();
  18374. }
  18375. }
  18376. /*:218*//*220:*/
  18377. #line 4976 "./typica.w"
  18378. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18379. QStack<QLayout*> *layoutStack)
  18380. {
  18381. QDomNodeList children= element.childNodes();
  18382. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  18383. for(int i= 0;i<children.count();i++)
  18384. {
  18385. QDomNode current;
  18386. QDomElement currentElement;
  18387. current= children.at(i);
  18388. if(current.isElement())
  18389. {
  18390. currentElement= current.toElement();
  18391. if(currentElement.tagName()=="page")
  18392. {
  18393. QWidget*widget= new QWidget;
  18394. layout->addWidget(widget);
  18395. widgetStack->push(widget);
  18396. currentElement.setAttribute("trcontext","configuration");
  18397. populateWidget(currentElement,widgetStack,layoutStack);
  18398. widgetStack->pop();
  18399. }
  18400. }
  18401. }
  18402. }
  18403. /*:220*//*222:*/
  18404. #line 5015 "./typica.w"
  18405. void addTabBarToLayout(QDomElement element,QStack<QWidget*> *,QStack<QLayout*> *layoutStack)
  18406. {
  18407. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18408. QTabBar*widget= new QTabBar;
  18409. layout->addWidget(widget);
  18410. if(!element.attribute("id").isEmpty())
  18411. {
  18412. widget->setObjectName(element.attribute("id"));
  18413. }
  18414. }
  18415. /*:222*//*224:*/
  18416. #line 5037 "./typica.w"
  18417. QScriptValue constructQTabBar(QScriptContext*,QScriptEngine*engine)
  18418. {
  18419. QScriptValue object= engine->newQObject(new QTabBar);
  18420. setQTabBarProperties(object,engine);
  18421. return object;
  18422. }
  18423. /*:224*//*225:*/
  18424. #line 5048 "./typica.w"
  18425. void setQTabBarProperties(QScriptValue value,QScriptEngine*engine)
  18426. {
  18427. setQWidgetProperties(value,engine);
  18428. value.setProperty("addTab",engine->newFunction(QTabBar_addTab));
  18429. }
  18430. QScriptValue QTabBar_addTab(QScriptContext*context,QScriptEngine*)
  18431. {
  18432. QTabBar*self= getself<QTabBar*> (context);
  18433. if(context->argumentCount()> 0)
  18434. {
  18435. self->addTab(argument<QString> (0,context));
  18436. }
  18437. else
  18438. {
  18439. context->throwError("Incorrect number of arguments passed to "
  18440. "QTabBar::addTab().");
  18441. }
  18442. return QScriptValue();
  18443. }
  18444. /*:225*//*227:*/
  18445. #line 5083 "./typica.w"
  18446. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18447. QStack<QLayout*> *layoutStack)
  18448. {
  18449. QDomNodeList children= element.childNodes();
  18450. int row= -1;
  18451. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  18452. for(int i= 0;i<children.count();i++)
  18453. {
  18454. QDomNode current;
  18455. QDomElement currentElement;
  18456. current= children.at(i);
  18457. if(current.isElement())
  18458. {
  18459. currentElement= current.toElement();
  18460. if(currentElement.tagName()=="row")
  18461. {
  18462. row++;
  18463. if(currentElement.hasAttribute("height"))
  18464. {
  18465. layout->setRowMinimumHeight(row,
  18466. currentElement.attribute("height").toInt());
  18467. }
  18468. if(currentElement.hasAttribute("stretch"))
  18469. {
  18470. layout->setRowStretch(row,
  18471. currentElement.attribute("stretch").toInt());
  18472. }
  18473. /*228:*/
  18474. #line 5139 "./typica.w"
  18475. int column= -1;
  18476. QDomNodeList rowChildren= currentElement.childNodes();
  18477. for(int j= 0;j<rowChildren.count();j++)
  18478. {
  18479. QDomNode columnNode;
  18480. QDomElement columnElement;
  18481. columnNode= rowChildren.at(j);
  18482. if(columnNode.isElement())
  18483. {
  18484. columnElement= columnNode.toElement();
  18485. if(columnElement.tagName()=="column")
  18486. {
  18487. column++;
  18488. if(columnElement.hasAttribute("column"))
  18489. {
  18490. column= columnElement.attribute("column").toInt();
  18491. }
  18492. if(columnElement.hasAttribute("width"))
  18493. {
  18494. layout->setColumnMinimumWidth(column,
  18495. columnElement.attribute("width").toInt());
  18496. }
  18497. if(columnElement.hasAttribute("stretch"))
  18498. {
  18499. layout->setColumnStretch(column,
  18500. columnElement.attribute("stretch").toInt());
  18501. }
  18502. int hspan= 1;
  18503. int vspan= 1;
  18504. if(columnElement.hasAttribute("rowspan"))
  18505. {
  18506. vspan= columnElement.attribute("rowspan").toInt();
  18507. }
  18508. if(columnElement.hasAttribute("colspan"))
  18509. {
  18510. hspan= columnElement.attribute("colspan").toInt();
  18511. }
  18512. QHBoxLayout*cell= new QHBoxLayout;
  18513. layout->addLayout(cell,row,column,vspan,hspan);
  18514. layoutStack->push(cell);
  18515. columnElement.setAttribute("trcontext","configuration");
  18516. populateBoxLayout(columnElement,widgetStack,layoutStack);
  18517. layoutStack->pop();
  18518. }
  18519. }
  18520. }
  18521. /*:228*/
  18522. #line 5111 "./typica.w"
  18523. }
  18524. }
  18525. }
  18526. }
  18527. /*:227*//*229:*/
  18528. #line 5190 "./typica.w"
  18529. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18530. QStack<QLayout*> *layoutStack)
  18531. {
  18532. QDomNodeList children= element.childNodes();
  18533. for(int i= 0;i<children.count();i++)
  18534. {
  18535. QDomNode current;
  18536. QDomElement currentElement;
  18537. current= children.at(i);
  18538. if(current.isElement())
  18539. {
  18540. currentElement= current.toElement();
  18541. currentElement.setAttribute("trcontext","configuration");
  18542. if(currentElement.tagName()=="button")
  18543. {
  18544. addButtonToLayout(currentElement,widgetStack,layoutStack);
  18545. }
  18546. else if(currentElement.tagName()=="calendar")
  18547. {
  18548. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  18549. }
  18550. else if(currentElement.tagName()=="timeedit")
  18551. {
  18552. addTimeEditToLayout(currentElement,widgetStack,layoutStack);
  18553. }
  18554. else if(currentElement.tagName()=="decoration")
  18555. {
  18556. addDecorationToLayout(currentElement,widgetStack,
  18557. layoutStack);
  18558. }
  18559. else if(currentElement.tagName()=="layout")
  18560. {
  18561. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  18562. }
  18563. else if(currentElement.tagName()=="splitter")
  18564. {
  18565. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  18566. }
  18567. else if(currentElement.tagName()=="label")
  18568. {
  18569. QBoxLayout*layout=
  18570. qobject_cast<QBoxLayout*> (layoutStack->top());
  18571. QLabel*label= new QLabel(QCoreApplication::translate(
  18572. "configuration",
  18573. currentElement.text().toUtf8().data()));
  18574. layout->addWidget(label);
  18575. }
  18576. else if(currentElement.tagName()=="lcdtemperature")
  18577. {
  18578. addTemperatureDisplayToLayout(currentElement,widgetStack,
  18579. layoutStack);
  18580. }
  18581. else if(currentElement.tagName()=="lcdtimer")
  18582. {
  18583. addTimerDisplayToLayout(currentElement,widgetStack,
  18584. layoutStack);
  18585. }
  18586. else if(currentElement.tagName()=="line")
  18587. {
  18588. addLineToLayout(currentElement,widgetStack,layoutStack);
  18589. }
  18590. else if(currentElement.tagName()=="report")
  18591. {
  18592. addReportToLayout(currentElement,widgetStack,layoutStack);
  18593. }
  18594. else if(currentElement.tagName()=="sqldrop")
  18595. {
  18596. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  18597. }
  18598. else if(currentElement.tagName()=="sqltablearray")
  18599. {
  18600. addSaltToLayout(currentElement,widgetStack,layoutStack);
  18601. }
  18602. else if(currentElement.tagName()=="sqlview")
  18603. {
  18604. addSqlQueryViewToLayout(currentElement,widgetStack,
  18605. layoutStack);
  18606. }
  18607. else if(currentElement.tagName()=="textarea")
  18608. {
  18609. addTextToLayout(currentElement,widgetStack,layoutStack);
  18610. }
  18611. else if(currentElement.tagName()=="spinbox")
  18612. {
  18613. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  18614. }
  18615. else if(currentElement.tagName()=="formarray")
  18616. {
  18617. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  18618. }
  18619. else if(currentElement.tagName()=="hscale")
  18620. {
  18621. addScaleControlToLayout(currentElement,widgetStack,
  18622. layoutStack);
  18623. }
  18624. else if(currentElement.tagName()=="vscale")
  18625. {
  18626. addIntensityControlToLayout(currentElement,widgetStack,
  18627. layoutStack);
  18628. }
  18629. else if(currentElement.tagName()=="webview")
  18630. {
  18631. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  18632. }
  18633. else if(currentElement.tagName()=="stretch")
  18634. {
  18635. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18636. layout->addStretch();
  18637. }
  18638. /*54:*/
  18639. #line 1558 "./typica.w"
  18640. else if(currentElement.tagName()=="svgwidget")
  18641. {
  18642. addSvgWidgetToLayout(currentElement,widgetStack,layoutStack);
  18643. }
  18644. /*:54*//*221:*/
  18645. #line 5007 "./typica.w"
  18646. else if(currentElement.tagName()=="tabbar")
  18647. {
  18648. addTabBarToLayout(currentElement,widgetStack,layoutStack);
  18649. }
  18650. /*:221*//*597:*/
  18651. #line 111 "./printerselector.w"
  18652. else if(currentElement.tagName()=="printerselector")
  18653. {
  18654. addPrinterSelectorToLayout(currentElement,widgetStack,layoutStack);
  18655. }
  18656. #line 12854 "./typica.w"
  18657. /*:597*//*712:*/
  18658. #line 451 "./daterangeselector.w"
  18659. else if(currentElement.tagName()=="daterange")
  18660. {
  18661. addDateRangeToLayout(currentElement,widgetStack,layoutStack);
  18662. }
  18663. /*:712*/
  18664. #line 5300 "./typica.w"
  18665. }
  18666. }
  18667. }
  18668. /*:229*//*230:*/
  18669. #line 5308 "./typica.w"
  18670. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18671. QStack<QLayout*> *layoutStack)
  18672. {
  18673. QLayout*targetLayout= layoutStack->pop();
  18674. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  18675. if(element.hasAttribute("type"))
  18676. {
  18677. /*219:*/
  18678. #line 4929 "./typica.w"
  18679. QLayout*layout;
  18680. QString layoutType= element.attribute("type");
  18681. if(layoutType=="horizontal")
  18682. {
  18683. layout= new QHBoxLayout;
  18684. layoutStack->push(layout);
  18685. populateBoxLayout(element,widgetStack,layoutStack);
  18686. }
  18687. else if(layoutType=="vertical")
  18688. {
  18689. layout= new QVBoxLayout;
  18690. layoutStack->push(layout);
  18691. populateBoxLayout(element,widgetStack,layoutStack);
  18692. }
  18693. else if(layoutType=="grid")
  18694. {
  18695. layout= new QGridLayout;
  18696. layoutStack->push(layout);
  18697. populateGridLayout(element,widgetStack,layoutStack);
  18698. }
  18699. else if(layoutType=="stack")
  18700. {
  18701. layout= new QStackedLayout;
  18702. layoutStack->push(layout);
  18703. populateStackedLayout(element,widgetStack,layoutStack);
  18704. }
  18705. if(element.hasAttribute("id"))
  18706. {
  18707. layout->setObjectName(element.attribute("id"));
  18708. }
  18709. if(element.hasAttribute("spacing"))
  18710. {
  18711. layout->setSpacing(element.attribute("spacing").toInt());
  18712. }
  18713. if(element.hasAttribute("margin"))
  18714. {
  18715. int m= element.attribute("margin").toInt();
  18716. layout->setContentsMargins(m,m,m,m);
  18717. }
  18718. /*:219*/
  18719. #line 5316 "./typica.w"
  18720. boxLayout->addLayout(layout);
  18721. layoutStack->pop();
  18722. }
  18723. layoutStack->push(targetLayout);
  18724. }
  18725. /*:230*//*231:*/
  18726. #line 5327 "./typica.w"
  18727. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  18728. QStack<QLayout*> *layoutStack)
  18729. {
  18730. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18731. QSplitter*splitter= new(QSplitter);
  18732. layout->addWidget(splitter);
  18733. /*232:*/
  18734. #line 5340 "./typica.w"
  18735. QString orientation= element.attribute("type");
  18736. if(orientation=="horizontal")
  18737. {
  18738. splitter->setOrientation(Qt::Horizontal);
  18739. }
  18740. else if(orientation=="vertical")
  18741. {
  18742. splitter->setOrientation(Qt::Vertical);
  18743. }
  18744. QString id= element.attribute("id");
  18745. if(!id.isEmpty())
  18746. {
  18747. splitter->setObjectName(id);
  18748. }
  18749. if(element.hasChildNodes())
  18750. {
  18751. widgetStack->push(splitter);
  18752. populateSplitter(element,widgetStack,layoutStack);
  18753. widgetStack->pop();
  18754. }
  18755. /*:232*/
  18756. #line 5334 "./typica.w"
  18757. }
  18758. /*:231*//*233:*/
  18759. #line 5366 "./typica.w"
  18760. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18761. QStack<QLayout*> *layoutStack)
  18762. {
  18763. QDomNodeList children= element.childNodes();
  18764. for(int i= 0;i<children.count();i++)
  18765. {
  18766. QDomNode current;
  18767. QDomElement currentElement;
  18768. current= children.at(i);
  18769. if(current.isElement())
  18770. {
  18771. currentElement= current.toElement();
  18772. currentElement.setAttribute("trcontext","configuration");
  18773. if(currentElement.tagName()=="decoration")
  18774. {
  18775. addDecorationToSplitter(currentElement,widgetStack,
  18776. layoutStack);
  18777. }
  18778. else if(currentElement.tagName()=="graph")
  18779. {
  18780. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  18781. }
  18782. else if(currentElement.tagName()=="splitter")
  18783. {
  18784. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  18785. }
  18786. else if(currentElement.tagName()=="lcdtemperature")
  18787. {
  18788. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  18789. layoutStack);
  18790. }
  18791. else if(currentElement.tagName()=="lcdtimer")
  18792. {
  18793. addTimerDisplayToSplitter(currentElement,widgetStack,
  18794. layoutStack);
  18795. }
  18796. else if(currentElement.tagName()=="measurementtable")
  18797. {
  18798. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  18799. }
  18800. else if(currentElement.tagName()=="widget")
  18801. {
  18802. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  18803. }
  18804. }
  18805. }
  18806. }
  18807. /*:233*//*234:*/
  18808. #line 5417 "./typica.w"
  18809. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  18810. QStack<QLayout*> *layoutStack)
  18811. {
  18812. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  18813. QSplitter*splitter= new(QSplitter);
  18814. splitter->setParent(parent);
  18815. parent->addWidget(splitter);
  18816. /*232:*/
  18817. #line 5340 "./typica.w"
  18818. QString orientation= element.attribute("type");
  18819. if(orientation=="horizontal")
  18820. {
  18821. splitter->setOrientation(Qt::Horizontal);
  18822. }
  18823. else if(orientation=="vertical")
  18824. {
  18825. splitter->setOrientation(Qt::Vertical);
  18826. }
  18827. QString id= element.attribute("id");
  18828. if(!id.isEmpty())
  18829. {
  18830. splitter->setObjectName(id);
  18831. }
  18832. if(element.hasChildNodes())
  18833. {
  18834. widgetStack->push(splitter);
  18835. populateSplitter(element,widgetStack,layoutStack);
  18836. widgetStack->pop();
  18837. }
  18838. /*:232*/
  18839. #line 5425 "./typica.w"
  18840. }
  18841. /*:234*//*235:*/
  18842. #line 5434 "./typica.w"
  18843. void addTemperatureDisplayToSplitter(QDomElement element,
  18844. QStack<QWidget*> *widgetStack,
  18845. QStack<QLayout*> *)
  18846. {
  18847. TemperatureDisplay*display= new(TemperatureDisplay);
  18848. if(element.hasAttribute("id"))
  18849. {
  18850. display->setObjectName(element.attribute("id"));
  18851. }
  18852. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18853. splitter->addWidget(display);
  18854. }
  18855. void addTemperatureDisplayToLayout(QDomElement element,
  18856. QStack<QWidget*> *,
  18857. QStack<QLayout*> *layoutStack)
  18858. {
  18859. TemperatureDisplay*display= new(TemperatureDisplay);
  18860. if(element.hasAttribute("id"))
  18861. {
  18862. display->setObjectName(element.attribute("id"));
  18863. }
  18864. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18865. layout->addWidget(display);
  18866. }
  18867. /*:235*//*236:*/
  18868. #line 5465 "./typica.w"
  18869. void addTimerDisplayToSplitter(QDomElement element,
  18870. QStack<QWidget*> *widgetStack,
  18871. QStack<QLayout*> *)
  18872. {
  18873. TimerDisplay*display= new(TimerDisplay);
  18874. if(element.hasAttribute("id"))
  18875. {
  18876. display->setObjectName(element.attribute("id"));
  18877. }
  18878. if(element.hasAttribute("format"))
  18879. {
  18880. display->setDisplayFormat(element.attribute("format"));
  18881. }
  18882. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  18883. splitter->addWidget(display);
  18884. }
  18885. void addTimerDisplayToLayout(QDomElement element,
  18886. QStack<QWidget*> *,
  18887. QStack<QLayout*> *layoutStack)
  18888. {
  18889. TimerDisplay*display= new(TimerDisplay);
  18890. if(element.hasAttribute("id"))
  18891. {
  18892. display->setObjectName(element.attribute("id"));
  18893. }
  18894. if(element.hasAttribute("format"))
  18895. {
  18896. display->setDisplayFormat(element.attribute("format"));
  18897. }
  18898. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18899. layout->addWidget(display);
  18900. }
  18901. /*:236*//*237:*/
  18902. #line 5503 "./typica.w"
  18903. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  18904. QStack<QLayout*> *layoutStack)
  18905. {
  18906. /*238:*/
  18907. #line 5524 "./typica.w"
  18908. QString labelText=
  18909. QCoreApplication::translate("configuration",
  18910. element.attribute("name").toUtf8().data());
  18911. Qt::Orientations orientation= Qt::Horizontal;
  18912. if(element.hasAttribute("type"))
  18913. {
  18914. if(element.attribute("type")=="horizontal")
  18915. {
  18916. orientation= Qt::Horizontal;
  18917. }
  18918. else if(element.attribute("type")=="vertical")
  18919. {
  18920. orientation= Qt::Vertical;
  18921. }
  18922. }
  18923. /*239:*/
  18924. #line 5551 "./typica.w"
  18925. QWidget*theWidget= NULL;
  18926. QDomNodeList children= element.childNodes();
  18927. for(int i= 0;i<children.count();i++)
  18928. {
  18929. QDomNode item= children.at(i);
  18930. if(item.isElement())
  18931. {
  18932. QDomElement itemElement= item.toElement();
  18933. if(itemElement.tagName()=="lcdtemperature")
  18934. {
  18935. TemperatureDisplay*display= new TemperatureDisplay;
  18936. if(itemElement.hasAttribute("id"))
  18937. {
  18938. display->setObjectName(itemElement.attribute("id"));
  18939. }
  18940. theWidget= display;
  18941. }
  18942. else if(itemElement.tagName()=="lcdtimer")
  18943. {
  18944. TimerDisplay*display= new TimerDisplay;
  18945. if(itemElement.hasAttribute("id"))
  18946. {
  18947. display->setObjectName(itemElement.attribute("id"));
  18948. }
  18949. if(itemElement.hasAttribute("format"))
  18950. {
  18951. display->setDisplayFormat(itemElement.attribute("format"));
  18952. }
  18953. theWidget= display;
  18954. }
  18955. }
  18956. }
  18957. /*:239*/
  18958. #line 5540 "./typica.w"
  18959. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  18960. orientation);
  18961. if(element.hasAttribute("id"))
  18962. {
  18963. decoration->setObjectName(element.attribute("id"));
  18964. }
  18965. /*:238*/
  18966. #line 5507 "./typica.w"
  18967. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  18968. layout->addWidget(decoration);
  18969. }
  18970. void addDecorationToSplitter(QDomElement element,
  18971. QStack<QWidget*> *widgetStack,
  18972. QStack<QLayout*> *)
  18973. {
  18974. /*238:*/
  18975. #line 5524 "./typica.w"
  18976. QString labelText=
  18977. QCoreApplication::translate("configuration",
  18978. element.attribute("name").toUtf8().data());
  18979. Qt::Orientations orientation= Qt::Horizontal;
  18980. if(element.hasAttribute("type"))
  18981. {
  18982. if(element.attribute("type")=="horizontal")
  18983. {
  18984. orientation= Qt::Horizontal;
  18985. }
  18986. else if(element.attribute("type")=="vertical")
  18987. {
  18988. orientation= Qt::Vertical;
  18989. }
  18990. }
  18991. /*239:*/
  18992. #line 5551 "./typica.w"
  18993. QWidget*theWidget= NULL;
  18994. QDomNodeList children= element.childNodes();
  18995. for(int i= 0;i<children.count();i++)
  18996. {
  18997. QDomNode item= children.at(i);
  18998. if(item.isElement())
  18999. {
  19000. QDomElement itemElement= item.toElement();
  19001. if(itemElement.tagName()=="lcdtemperature")
  19002. {
  19003. TemperatureDisplay*display= new TemperatureDisplay;
  19004. if(itemElement.hasAttribute("id"))
  19005. {
  19006. display->setObjectName(itemElement.attribute("id"));
  19007. }
  19008. theWidget= display;
  19009. }
  19010. else if(itemElement.tagName()=="lcdtimer")
  19011. {
  19012. TimerDisplay*display= new TimerDisplay;
  19013. if(itemElement.hasAttribute("id"))
  19014. {
  19015. display->setObjectName(itemElement.attribute("id"));
  19016. }
  19017. if(itemElement.hasAttribute("format"))
  19018. {
  19019. display->setDisplayFormat(itemElement.attribute("format"));
  19020. }
  19021. theWidget= display;
  19022. }
  19023. }
  19024. }
  19025. /*:239*/
  19026. #line 5540 "./typica.w"
  19027. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  19028. orientation);
  19029. if(element.hasAttribute("id"))
  19030. {
  19031. decoration->setObjectName(element.attribute("id"));
  19032. }
  19033. /*:238*/
  19034. #line 5516 "./typica.w"
  19035. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19036. splitter->addWidget(decoration);
  19037. }
  19038. /*:237*//*240:*/
  19039. #line 5596 "./typica.w"
  19040. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19041. QStack<QLayout*> *layoutStack)
  19042. {
  19043. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19044. QWidget*widget= new QWidget;
  19045. if(element.hasAttribute("id"))
  19046. {
  19047. widget->setObjectName(element.attribute("id"));
  19048. }
  19049. if(element.hasAttribute("ignoreSizePolicy"))
  19050. {
  19051. if(element.attribute("ignoreSizePolicy")=="true")
  19052. {
  19053. widget->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
  19054. }
  19055. }
  19056. splitter->addWidget(widget);
  19057. if(element.hasChildNodes())
  19058. {
  19059. widgetStack->push(widget);
  19060. populateWidget(element,widgetStack,layoutStack);
  19061. widgetStack->pop();
  19062. }
  19063. }
  19064. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  19065. QStack<QLayout*> *layoutStack)
  19066. {
  19067. QDomNodeList children= element.childNodes();
  19068. for(int i= 0;i<children.count();i++)
  19069. {
  19070. QDomNode current;
  19071. QDomElement currentElement;
  19072. current= children.at(i);
  19073. if(current.isElement())
  19074. {
  19075. currentElement= current.toElement();
  19076. if(currentElement.tagName()=="layout")
  19077. {
  19078. currentElement.setAttribute("trcontext","configuration");
  19079. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  19080. }
  19081. }
  19082. }
  19083. }
  19084. /*:240*//*241:*/
  19085. #line 5647 "./typica.w"
  19086. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  19087. QStack<QLayout*> *layoutStack)
  19088. {
  19089. QAbstractButton*button= NULL;
  19090. QString text=
  19091. QCoreApplication::translate("configuration",
  19092. element.attribute("name").toUtf8().data());
  19093. if(element.hasAttribute("type"))
  19094. {
  19095. QString type= element.attribute("type");
  19096. if(type=="annotation")
  19097. {
  19098. AnnotationButton*abutton= new AnnotationButton(text);
  19099. if(element.hasAttribute("annotation"))
  19100. {
  19101. abutton->setAnnotation(element.attribute("annotation"));
  19102. }
  19103. if(element.hasAttribute("series"))
  19104. {
  19105. abutton->setTemperatureColumn(element.attribute("series").
  19106. toInt());
  19107. }
  19108. if(element.hasAttribute("column"))
  19109. {
  19110. abutton->setAnnotationColumn(element.attribute("column").
  19111. toInt());
  19112. }
  19113. button= abutton;
  19114. }
  19115. else if(type=="check")
  19116. {
  19117. button= new QCheckBox(text);
  19118. }
  19119. else if(type=="push")
  19120. {
  19121. button= new QPushButton(text);
  19122. }
  19123. }
  19124. if(element.hasAttribute("id"))
  19125. {
  19126. button->setObjectName(element.attribute("id"));
  19127. }
  19128. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19129. layout->addWidget(button);
  19130. }
  19131. /*:241*//*242:*/
  19132. #line 5701 "./typica.w"
  19133. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  19134. QStack<QLayout*> *layoutStack)
  19135. {
  19136. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  19137. if(element.hasAttribute("pretext"))
  19138. {
  19139. box->setPretext(QCoreApplication::translate(
  19140. "configuration",
  19141. element.attribute("pretext").toUtf8().data()));
  19142. }
  19143. if(element.hasAttribute("posttext"))
  19144. {
  19145. box->setPosttext(QCoreApplication::translate(
  19146. "configuration",
  19147. element.attribute("posttext").toUtf8().data()));
  19148. }
  19149. if(element.hasAttribute("series"))
  19150. {
  19151. box->setTemperatureColumn(element.attribute("series").toInt());
  19152. }
  19153. if(element.hasAttribute("column"))
  19154. {
  19155. box->setAnnotationColumn(element.attribute("column").toInt());
  19156. }
  19157. if(element.hasAttribute("min"))
  19158. {
  19159. box->setMinimum(element.attribute("min").toDouble());
  19160. }
  19161. if(element.hasAttribute("max"))
  19162. {
  19163. box->setMaximum(element.attribute("max").toDouble());
  19164. }
  19165. if(element.hasAttribute("decimals"))
  19166. {
  19167. box->setDecimals(element.attribute("decimals").toInt());
  19168. }
  19169. if(element.hasAttribute("step"))
  19170. {
  19171. box->setSingleStep(element.attribute("step").toDouble());
  19172. }
  19173. if(element.hasAttribute("id"))
  19174. {
  19175. box->setObjectName(element.attribute("id"));
  19176. }
  19177. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19178. layout->addWidget(box);
  19179. }
  19180. /*:242*//*243:*/
  19181. #line 5761 "./typica.w"
  19182. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19183. QStack<QLayout*> *)
  19184. {
  19185. ZoomLog*widget= new ZoomLog;
  19186. if(element.hasAttribute("id"))
  19187. {
  19188. widget->setObjectName(element.attribute("id"));
  19189. }
  19190. if(element.hasChildNodes())
  19191. {
  19192. QDomNodeList children= element.childNodes();
  19193. int column= 0;
  19194. for(int i= 0;i<children.count();i++)
  19195. {
  19196. QDomNode current;
  19197. QDomElement currentElement;
  19198. current= children.at(i);
  19199. if(current.isElement())
  19200. {
  19201. currentElement= current.toElement();
  19202. if(currentElement.tagName()=="column")
  19203. {
  19204. QString text=
  19205. QCoreApplication::translate(
  19206. "configuration",
  19207. currentElement.text().toUtf8().data());
  19208. widget->setHeaderData(column,text);
  19209. column++;
  19210. }
  19211. }
  19212. }
  19213. }
  19214. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19215. if(splitter)
  19216. {
  19217. splitter->addWidget(widget);
  19218. }
  19219. else
  19220. {
  19221. qDebug()<<"Splitter not found at top of widget stack!";
  19222. }
  19223. }
  19224. /*:243*//*244:*/
  19225. #line 5808 "./typica.w"
  19226. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  19227. QStack<QLayout*> *)
  19228. {
  19229. GraphView*view= new GraphView;
  19230. if(element.hasAttribute("id"))
  19231. {
  19232. view->setObjectName(element.attribute("id"));
  19233. }
  19234. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  19235. splitter->addWidget(view);
  19236. }
  19237. /*:244*//*245:*/
  19238. #line 5825 "./typica.w"
  19239. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  19240. QStack<QLayout*> *layoutStack)
  19241. {
  19242. SqlComboBox*box= new SqlComboBox();
  19243. if(element.hasAttribute("data"))
  19244. {
  19245. box->setDataColumn(element.attribute("data").toInt());
  19246. }
  19247. if(element.hasAttribute("display"))
  19248. {
  19249. box->setDisplayColumn(element.attribute("display").toInt());
  19250. }
  19251. if(element.hasAttribute("showdata"))
  19252. {
  19253. if(element.attribute("showdata")=="true")
  19254. {
  19255. box->showData(true);
  19256. }
  19257. }
  19258. if(element.hasAttribute("editable"))
  19259. {
  19260. if(element.attribute("editable")=="true")
  19261. {
  19262. box->setEditable(true);
  19263. }
  19264. }
  19265. if(element.hasChildNodes())
  19266. {
  19267. QDomNodeList children= element.childNodes();
  19268. for(int i= 0;i<children.count();i++)
  19269. {
  19270. QDomNode current;
  19271. QDomElement currentElement;
  19272. current= children.at(i);
  19273. if(current.isElement())
  19274. {
  19275. currentElement= current.toElement();
  19276. if(currentElement.tagName()=="null")
  19277. {
  19278. box->addNullOption();
  19279. }
  19280. else if(currentElement.tagName()=="query")
  19281. {
  19282. box->addSqlOptions(currentElement.text());
  19283. }
  19284. }
  19285. }
  19286. }
  19287. if(element.hasAttribute("id"))
  19288. {
  19289. box->setObjectName(element.attribute("id"));
  19290. }
  19291. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19292. layout->addWidget(box);
  19293. }
  19294. /*:245*//*246:*/
  19295. #line 5904 "./typica.w"
  19296. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  19297. QStack<QLayout*> *layoutStack)
  19298. {
  19299. QTableView*view= new QTableView;
  19300. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  19301. SaltModel*model= new SaltModel(element.childNodes().count());
  19302. if(element.hasAttribute("id"))
  19303. {
  19304. view->setObjectName(element.attribute("id"));
  19305. }
  19306. if(element.hasChildNodes())
  19307. {
  19308. QDomNodeList children= element.childNodes();
  19309. int currentColumn= 0;
  19310. for(int i= 0;i<children.count();i++)
  19311. {
  19312. QDomNode current;
  19313. QDomElement currentElement;
  19314. current= children.at(i);
  19315. if(current.isElement())
  19316. {
  19317. currentElement= current.toElement();
  19318. if(currentElement.tagName()=="column")
  19319. {
  19320. if(currentElement.hasAttribute("name"))
  19321. {
  19322. model->setHeaderData(currentColumn,
  19323. Qt::Horizontal,
  19324. QCoreApplication::translate(
  19325. "configuration",
  19326. currentElement.attribute("name").toUtf8().data()));
  19327. }
  19328. if(currentElement.hasAttribute("delegate"))
  19329. {
  19330. /*247:*/
  19331. #line 5955 "./typica.w"
  19332. if(currentElement.attribute("delegate")=="sql")
  19333. {
  19334. /*248:*/
  19335. #line 5971 "./typica.w"
  19336. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  19337. SqlComboBox*widget= new SqlComboBox();
  19338. if(currentElement.hasAttribute("nulltext"))
  19339. {
  19340. widget->setNullText(currentElement.attribute("nulltext"));
  19341. }
  19342. if(currentElement.hasAttribute("nulldata"))
  19343. {
  19344. widget->setNullData(QVariant(currentElement.attribute("nulldata")));
  19345. }
  19346. if(currentElement.hasAttribute("null"))
  19347. {
  19348. if(currentElement.attribute("null")=="true")
  19349. {
  19350. widget->addNullOption();
  19351. }
  19352. }
  19353. if(currentElement.hasAttribute("showdata"))
  19354. {
  19355. if(currentElement.attribute("showdata")=="true")
  19356. {
  19357. widget->showData(true);
  19358. }
  19359. }
  19360. if(currentElement.hasAttribute("data"))
  19361. {
  19362. widget->setDataColumn(currentElement.attribute("data").toInt());
  19363. }
  19364. if(currentElement.hasAttribute("display"))
  19365. {
  19366. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  19367. }
  19368. widget->addSqlOptions(currentElement.text());
  19369. delegate->setWidget(widget);
  19370. view->setItemDelegateForColumn(currentColumn,delegate);
  19371. /*:248*/
  19372. #line 5958 "./typica.w"
  19373. }
  19374. else if(currentElement.attribute("delegate")=="numeric")
  19375. {
  19376. /*249:*/
  19377. #line 6012 "./typica.w"
  19378. NumericDelegate*delegate= new NumericDelegate;
  19379. view->setItemDelegateForColumn(currentColumn,delegate);
  19380. /*:249*/
  19381. #line 5962 "./typica.w"
  19382. }
  19383. /*:247*/
  19384. #line 5939 "./typica.w"
  19385. }
  19386. currentColumn++;
  19387. }
  19388. }
  19389. }
  19390. }
  19391. view->setModel(model);
  19392. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19393. layout->addWidget(view);
  19394. }
  19395. /*:246*//*261:*/
  19396. #line 6185 "./typica.w"
  19397. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  19398. QStack<QLayout*> *layoutStack)
  19399. {
  19400. QLineEdit*widget= new QLineEdit(element.text());
  19401. if(element.hasAttribute("id"))
  19402. {
  19403. widget->setObjectName(element.attribute("id"));
  19404. }
  19405. if(element.hasAttribute("writable"))
  19406. {
  19407. if(element.attribute("writable")=="false")
  19408. {
  19409. widget->setReadOnly(true);
  19410. }
  19411. }
  19412. if(element.hasAttribute("validator"))
  19413. {
  19414. if(element.attribute("validator")=="numeric")
  19415. {
  19416. widget->setValidator(new ScriptValidator(new QDoubleValidator));
  19417. }
  19418. else if(element.attribute("validator")=="integer")
  19419. {
  19420. widget->setValidator(new ScriptValidator(new QIntValidator));
  19421. }
  19422. else if(element.attribute("validator")=="expression"&&
  19423. element.hasAttribute("expression"))
  19424. {
  19425. widget->setValidator(new QRegExpValidator(
  19426. QRegExp(element.attribute("expression")),
  19427. NULL));
  19428. }
  19429. }
  19430. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19431. layout->addWidget(widget);
  19432. }
  19433. /*:261*//*262:*/
  19434. #line 6226 "./typica.w"
  19435. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  19436. QStack<QLayout*> *layoutStack)
  19437. {
  19438. QTextEdit*widget= new QTextEdit;
  19439. if(element.hasAttribute("id"))
  19440. {
  19441. widget->setObjectName(element.attribute("id"));
  19442. }
  19443. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19444. layout->addWidget(widget);
  19445. }
  19446. /*:262*//*263:*/
  19447. #line 6243 "./typica.w"
  19448. void addSqlQueryViewToLayout(QDomElement element,
  19449. QStack<QWidget*> *,
  19450. QStack<QLayout*> *layoutStack)
  19451. {
  19452. SqlQueryView*view= new SqlQueryView;
  19453. if(element.hasAttribute("id"))
  19454. {
  19455. view->setObjectName(element.attribute("id"));
  19456. }
  19457. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19458. layout->addWidget(view);
  19459. }
  19460. /*:263*//*264:*/
  19461. #line 6260 "./typica.w"
  19462. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  19463. QStack<QLayout*> *layoutStack)
  19464. {
  19465. QWidget*widget;
  19466. if(element.hasAttribute("time"))
  19467. {
  19468. if(element.attribute("time")=="true")
  19469. {
  19470. QDateTimeEdit*edit= new QDateTimeEdit;
  19471. edit->setDateTime(QDateTime::currentDateTime());
  19472. edit->setCalendarPopup(true);
  19473. edit->setDisplayFormat("yyyy-MM-dd hh:mm:ss");
  19474. widget= qobject_cast<QWidget*> (edit);
  19475. }
  19476. else
  19477. {
  19478. QDateEdit*edit= new QDateEdit;
  19479. edit->setDate(QDate::currentDate());
  19480. edit->setCalendarPopup(true);
  19481. edit->setDisplayFormat("yyyy-MM-dd");
  19482. widget= qobject_cast<QWidget*> (edit);
  19483. }
  19484. }
  19485. else
  19486. {
  19487. QDateEdit*edit= new QDateEdit;
  19488. edit->setDate(QDate::currentDate());
  19489. edit->setCalendarPopup(true);
  19490. edit->setDisplayFormat("yyyy-MM-dd");
  19491. widget= qobject_cast<QWidget*> (edit);
  19492. }
  19493. if(element.hasAttribute("id"))
  19494. {
  19495. widget->setObjectName(element.attribute("id"));
  19496. }
  19497. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19498. layout->addWidget(widget);
  19499. }
  19500. /*:264*//*265:*/
  19501. #line 6303 "./typica.w"
  19502. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  19503. {
  19504. setQDateTimeEditProperties(value,engine);
  19505. }
  19506. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19507. {
  19508. setQAbstractSpinBoxProperties(value,engine);
  19509. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  19510. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  19511. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  19512. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  19513. value.setProperty("setToCurrentTime",
  19514. engine->newFunction(QDateTimeEdit_setToCurrentTime));
  19515. }
  19516. /*:265*//*266:*/
  19517. #line 6325 "./typica.w"
  19518. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  19519. {
  19520. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19521. if(context->argumentCount()==3)
  19522. {
  19523. self->setDate(QDate(argument<int> (0,context),
  19524. argument<int> (1,context),
  19525. argument<int> (2,context)));
  19526. }
  19527. else
  19528. {
  19529. context->throwError("Incorrect number of arguments passed to "
  19530. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  19531. "specifying the year, month, and day.");
  19532. }
  19533. return QScriptValue();
  19534. }
  19535. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  19536. {
  19537. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19538. return QScriptValue(self->date().day());
  19539. }
  19540. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  19541. {
  19542. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19543. return QScriptValue(self->date().month());
  19544. }
  19545. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  19546. {
  19547. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19548. return QScriptValue(self->date().year());
  19549. }
  19550. QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext*context,QScriptEngine*)
  19551. {
  19552. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  19553. self->setDateTime(QDateTime::currentDateTime());
  19554. return QScriptValue();
  19555. }
  19556. /*:266*//*268:*/
  19557. #line 6385 "./typica.w"
  19558. void addTimeEditToLayout(QDomElement element,QStack<QWidget*> *,
  19559. QStack<QLayout*> *layoutStack)
  19560. {
  19561. QTimeEdit*edit= new QTimeEdit;
  19562. if(element.hasAttribute("displayFormat"))
  19563. {
  19564. edit->setDisplayFormat(element.attribute("displayFormat"));
  19565. }
  19566. else
  19567. {
  19568. edit->setDisplayFormat("mm:ss.zzz");
  19569. }
  19570. if(element.hasAttribute("id"))
  19571. {
  19572. edit->setObjectName(element.attribute("id"));
  19573. }
  19574. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  19575. layout->addWidget(edit);
  19576. }
  19577. /*:268*//*269:*/
  19578. #line 6408 "./typica.w"
  19579. void setQTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  19580. {
  19581. setQDateTimeEditProperties(value,engine);
  19582. }
  19583. /*:269*//*273:*/
  19584. #line 6437 "./typica.w"
  19585. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  19586. {
  19587. QObject*parent= argument<QObject*> (0,context);
  19588. QString name= argument<QString> (1,context);
  19589. QObject*object= parent->findChild<QObject*> (name);
  19590. QScriptValue value;
  19591. if(object)
  19592. {
  19593. value= engine->newQObject(object);
  19594. QString className= object->metaObject()->className();
  19595. /*274:*/
  19596. #line 6455 "./typica.w"
  19597. if(className=="TemperatureDisplay")
  19598. {
  19599. setTemperatureDisplayProperties(value,engine);
  19600. }
  19601. else if(className=="TimerDisplay")
  19602. {
  19603. setTimerDisplayProperties(value,engine);
  19604. }
  19605. else if(className=="QAction")
  19606. {
  19607. setQActionProperties(value,engine);
  19608. }
  19609. else if(className=="QBoxLayout")
  19610. {
  19611. setQBoxLayoutProperties(value,engine);
  19612. }
  19613. else if(className=="QDateEdit")
  19614. {
  19615. setQDateEditProperties(value,engine);
  19616. }
  19617. else if(className=="QDateTimeEdit")
  19618. {
  19619. setQDateTimeEditProperties(value,engine);
  19620. }
  19621. else if(className=="QFrame")
  19622. {
  19623. setQFrameProperties(value,engine);
  19624. }
  19625. else if(className=="QHBoxLayout")
  19626. {
  19627. setQBoxLayoutProperties(value,engine);
  19628. }
  19629. else if(className=="QLCDNumber")
  19630. {
  19631. setQLCDNumberProperties(value,engine);
  19632. }
  19633. else if(className=="QMenu")
  19634. {
  19635. setQMenuProperties(value,engine);
  19636. }
  19637. else if(className=="QMenuBar")
  19638. {
  19639. setQMenuBarProperties(value,engine);
  19640. }
  19641. else if(className=="QPushButton")
  19642. {
  19643. setQPushButtonProperties(value,engine);
  19644. }
  19645. else if(className=="QSplitter")
  19646. {
  19647. setQSplitterProperties(value,engine);
  19648. }
  19649. else if(className=="QTableView")
  19650. {
  19651. if(object->property("tabletype").isValid())
  19652. {
  19653. if(object->property("tabletype").toString()=="SaltTable")
  19654. {
  19655. setSaltTableProperties(value,engine);
  19656. }
  19657. }
  19658. }
  19659. else if(className=="QVBoxLayout")
  19660. {
  19661. setQBoxLayoutProperties(value,engine);
  19662. }
  19663. else if(className=="QWidget")
  19664. {
  19665. setQWidgetProperties(value,engine);
  19666. }
  19667. else if(className=="ScriptQMainWindow")
  19668. {
  19669. setQMainWindowProperties(value,engine);
  19670. }
  19671. else if(className=="SqlComboBox")
  19672. {
  19673. setSqlComboBoxProperties(value,engine);
  19674. }
  19675. else if(className=="SqlQueryView")
  19676. {
  19677. setSqlQueryViewProperties(value,engine);
  19678. }
  19679. else if(className=="ZoomLog")
  19680. {
  19681. setZoomLogProperties(value,engine);
  19682. }
  19683. else if(className=="QTextEdit")
  19684. {
  19685. setQTextEditProperties(value,engine);
  19686. }
  19687. else if(className=="QWebView")
  19688. {
  19689. setQWebViewProperties(value,engine);
  19690. }
  19691. else if(className=="QLineEdit")
  19692. {
  19693. setQLineEditProperties(value,engine);
  19694. }
  19695. else if(className=="QSvgWidget")
  19696. {
  19697. setQSvgWidgetProperties(value,engine);
  19698. }
  19699. else if(className=="QTabBar")
  19700. {
  19701. setQTabBarProperties(value,engine);
  19702. }
  19703. else if(className=="PrinterSelector")
  19704. {
  19705. setQComboBoxProperties(value,engine);
  19706. }
  19707. /*:274*/
  19708. #line 6448 "./typica.w"
  19709. }
  19710. return value;
  19711. }
  19712. /*:273*//*276:*/
  19713. #line 6596 "./typica.w"
  19714. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  19715. {
  19716. QTableView*self= getself<QTableView*> (context);
  19717. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19718. QString datum;
  19719. double total= 0.0;
  19720. int column= argument<int> (0,context);
  19721. int role= argument<int> (1,context);
  19722. for(int i= 0;i<model->rowCount();i++)
  19723. {
  19724. datum= model->data(model->index(i,column),role).toString();
  19725. if(!datum.isEmpty())
  19726. {
  19727. total+= datum.toDouble();
  19728. }
  19729. }
  19730. return QScriptValue(engine,total);
  19731. }
  19732. /*:276*//*277:*/
  19733. #line 6620 "./typica.w"
  19734. QScriptValue SaltTable_columnArray(QScriptContext*context,
  19735. QScriptEngine*engine)
  19736. {
  19737. QTableView*self= getself<QTableView*> (context);
  19738. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19739. int column= argument<int> (0,context);
  19740. int role= argument<int> (1,context);
  19741. QString literal= model->arrayLiteral(column,role);
  19742. return QScriptValue(engine,literal);
  19743. }
  19744. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  19745. QScriptEngine*engine)
  19746. {
  19747. QTableView*self= getself<QTableView*> (context);
  19748. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19749. int column= argument<int> (0,context);
  19750. int role= argument<int> (1,context);
  19751. QString literal= model->quotedArrayLiteral(column,role);
  19752. return QScriptValue(engine,literal);
  19753. }
  19754. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  19755. QScriptEngine*engine)
  19756. {
  19757. QTableView*self= getself<QTableView*> (context);
  19758. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19759. int column= argument<int> (0,context);
  19760. int role= argument<int> (1,context);
  19761. QString literal= model->arrayLiteral(column,role);
  19762. literal.chop(1);
  19763. literal= literal.remove(0,1);
  19764. return QScriptValue(engine,literal);
  19765. }
  19766. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  19767. QScriptEngine*engine)
  19768. {
  19769. QTableView*self= getself<QTableView*> (context);
  19770. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19771. int column= argument<int> (0,context);
  19772. int role= argument<int> (1,context);
  19773. QString literal= model->quotedArrayLiteral(column,role);
  19774. literal.chop(1);
  19775. literal= literal.remove(0,1);
  19776. return QScriptValue(engine,literal);
  19777. }
  19778. /*:277*//*278:*/
  19779. #line 6672 "./typica.w"
  19780. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  19781. {
  19782. QTableView*self= getself<QTableView*> (context);
  19783. QScriptValue value= engine->newQObject(self->model());
  19784. return value;
  19785. }
  19786. /*:278*//*279:*/
  19787. #line 6686 "./typica.w"
  19788. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  19789. {
  19790. QTableView*self= getself<QTableView*> (context);
  19791. int row= argument<int> (0,context);
  19792. int column= argument<int> (1,context);
  19793. QVariant value= argument<QVariant> (2,context);
  19794. int role= argument<int> (3,context);
  19795. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19796. QModelIndex cell= model->index(row,column);
  19797. model->setData(cell,value,role);
  19798. self->update(cell);
  19799. return QScriptValue();
  19800. }
  19801. /*:279*//*280:*/
  19802. #line 6704 "./typica.w"
  19803. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  19804. {
  19805. QTableView*self= getself<QTableView*> (context);
  19806. int row= argument<int> (0,context);
  19807. int column= argument<int> (1,context);
  19808. int role= argument<int> (2,context);
  19809. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19810. QModelIndex cell= model->index(row,column);
  19811. QVariant value= model->data(cell,role);
  19812. QScriptValue retval= engine->newVariant(value);
  19813. retval.setProperty("value",QScriptValue(value.toString()));
  19814. return retval;
  19815. }
  19816. /*:280*//*281:*/
  19817. #line 6724 "./typica.w"
  19818. QScriptValue SaltTable_clear(QScriptContext*context,QScriptEngine*)
  19819. {
  19820. QTableView*self= getself<QTableView*> (context);
  19821. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19822. model->clear();
  19823. return QScriptValue();
  19824. }
  19825. /*:281*//*282:*/
  19826. #line 6736 "./typica.w"
  19827. QScriptValue SaltTable_removeRow(QScriptContext*context,QScriptEngine*engine)
  19828. {
  19829. QTableView*self= getself<QTableView*> (context);
  19830. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19831. int row= argument<int> (0,context);
  19832. return engine->newVariant(model->removeRow(row));
  19833. }
  19834. /*:282*//*283:*/
  19835. #line 6749 "./typica.w"
  19836. QScriptValue SaltTable_findData(QScriptContext*context,QScriptEngine*engine)
  19837. {
  19838. QTableView*self= getself<QTableView*> (context);
  19839. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  19840. QVariant value= argument<QVariant> (0,context);
  19841. int column= argument<int> (1,context);
  19842. return engine->newVariant(model->findData(value,column));
  19843. }
  19844. /*:283*//*284:*/
  19845. #line 6762 "./typica.w"
  19846. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  19847. {
  19848. setQWidgetProperties(value,engine);
  19849. value.setProperty("columnArray",
  19850. engine->newFunction(SaltTable_columnArray));
  19851. value.setProperty("quotedColumnArray",
  19852. engine->newFunction(SaltTable_quotedColumnArray));
  19853. value.setProperty("bindableColumnArray",
  19854. engine->newFunction(SaltTable_bindableColumnArray));
  19855. value.setProperty("bindableQuotedColumnArray",
  19856. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  19857. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  19858. value.setProperty("data",engine->newFunction(SaltTable_data));
  19859. value.setProperty("model",engine->newFunction(SaltTable_model));
  19860. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  19861. value.setProperty("clear",engine->newFunction(SaltTable_clear));
  19862. value.setProperty("removeRow",engine->newFunction(SaltTable_removeRow));
  19863. value.setProperty("findData",engine->newFunction(SaltTable_findData));
  19864. }
  19865. /*:284*//*286:*/
  19866. #line 6799 "./typica.w"
  19867. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  19868. {
  19869. setQComboBoxProperties(value,engine);
  19870. }
  19871. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  19872. {
  19873. setQWidgetProperties(value,engine);
  19874. value.setProperty("currentData",
  19875. engine->newFunction(QComboBox_currentData));
  19876. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  19877. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  19878. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  19879. value.setProperty("findData",engine->newFunction(QComboBox_findData));
  19880. }
  19881. QScriptValue QComboBox_currentData(QScriptContext*context,
  19882. QScriptEngine*engine)
  19883. {
  19884. QComboBox*self= getself<QComboBox*> (context);
  19885. return QScriptValue(engine,
  19886. self->itemData(self->currentIndex()).toString());
  19887. }
  19888. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  19889. {
  19890. QComboBox*self= getself<QComboBox*> (context);
  19891. self->addItem(argument<QString> (0,context));
  19892. return QScriptValue();
  19893. }
  19894. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  19895. {
  19896. QComboBox*self= getself<QComboBox*> (context);
  19897. self->setModel(argument<QAbstractItemModel*> (0,context));
  19898. return QScriptValue();
  19899. }
  19900. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  19901. {
  19902. QComboBox*self= getself<QComboBox*> (context);
  19903. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  19904. }
  19905. QScriptValue QComboBox_findData(QScriptContext*context,QScriptEngine*engine)
  19906. {
  19907. QComboBox*self= getself<QComboBox*> (context);
  19908. return QScriptValue(engine,self->findData(argument<QVariant> (0,context)));
  19909. }
  19910. #line 1 "./abouttypica.w"
  19911. /*:286*//*299:*/
  19912. #line 401 "./units.w"
  19913. QScriptValue Units_convertTemperature(QScriptContext*context,QScriptEngine*)
  19914. {
  19915. return QScriptValue(Units::convertTemperature(argument<double> (0,context),
  19916. argument<Units::Unit> (1,context),
  19917. argument<Units::Unit> (2,context)));
  19918. }
  19919. QScriptValue Units_convertRelativeTemperature(QScriptContext*context,
  19920. QScriptEngine*)
  19921. {
  19922. return QScriptValue(Units::convertRelativeTemperature(
  19923. argument<double> (0,context),
  19924. argument<Units::Unit> (1,context),
  19925. argument<Units::Unit> (2,context)));
  19926. }
  19927. QScriptValue Units_isTemperatureUnit(QScriptContext*context,QScriptEngine*)
  19928. {
  19929. return QScriptValue(Units::isTemperatureUnit(argument<Units::Unit> (0,context)));
  19930. }
  19931. QScriptValue Units_convertWeight(QScriptContext*context,QScriptEngine*)
  19932. {
  19933. return QScriptValue(Units::convertWeight(argument<double> (0,context),
  19934. argument<Units::Unit> (1,context),
  19935. argument<Units::Unit> (2,context)));
  19936. }
  19937. QScriptValue Units_isWeightUnit(QScriptContext*context,QScriptEngine*)
  19938. {
  19939. return QScriptValue(Units::isWeightUnit(argument<Units::Unit> (0,context)));
  19940. }
  19941. /*:299*//*302:*/
  19942. #line 449 "./units.w"
  19943. QScriptValue Unit_toScriptValue(QScriptEngine*engine,const Units::Unit&value)
  19944. {
  19945. return engine->newVariant(QVariant(value));
  19946. }
  19947. void Unit_fromScriptValue(const QScriptValue&sv,Units::Unit&value)
  19948. {
  19949. value= sv.toVariant().value<Units::Unit> ();
  19950. }
  19951. /*:302*//*312:*/
  19952. #line 149 "./measurement.w"
  19953. QScriptValue constructMeasurement(QScriptContext*context,QScriptEngine*engine)
  19954. {
  19955. QScriptValue object;
  19956. if(context->argumentCount()==2||context->argumentCount()==3)
  19957. {
  19958. double measurement= argument<double> (0,context);
  19959. QTime timestamp= argument<QTime> (1,context);
  19960. Units::Unit unit= Units::Fahrenheit;
  19961. if(context->argumentCount()==3)
  19962. {
  19963. unit= argument<Units::Unit> (2,context);
  19964. }
  19965. object= engine->toScriptValue<Measurement> (Measurement(measurement,timestamp,unit));
  19966. setMeasurementProperties(object,engine);
  19967. }
  19968. else
  19969. {
  19970. context->throwError("Incorrect number of arguments passed to "
  19971. "Measurement::Measurement(). This method takes two "
  19972. "or three arguments.");
  19973. }
  19974. return object;
  19975. }
  19976. /*:312*//*313:*/
  19977. #line 176 "./measurement.w"
  19978. void setMeasurementProperties(QScriptValue,QScriptEngine*)
  19979. {
  19980. }
  19981. /*:313*//*314:*/
  19982. #line 184 "./measurement.w"
  19983. QScriptValue Measurement_toScriptValue(QScriptEngine*engine,const Measurement&measurement)
  19984. {
  19985. QVariant var;
  19986. var.setValue(measurement);
  19987. return engine->newVariant(var);
  19988. }
  19989. void Measurement_fromScriptValue(const QScriptValue&value,Measurement&measurement)
  19990. {
  19991. measurement= value.toVariant().value<Measurement> ();
  19992. }
  19993. #line 6868 "./typica.w"
  19994. /*:314*//*332:*/
  19995. #line 7446 "./typica.w"
  19996. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  19997. {
  19998. QScriptValue object;
  19999. if(context->argumentCount()==1)
  20000. {
  20001. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  20002. QScriptEngine::ScriptOwnership);
  20003. setDAQProperties(object,engine);
  20004. }
  20005. else if(context->argumentCount()==2)
  20006. {
  20007. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  20008. argument<QString> (1,context)),
  20009. QScriptEngine::ScriptOwnership);
  20010. setDAQProperties(object,engine);
  20011. }
  20012. else
  20013. {
  20014. context->throwError("Incorrect number of arguments passed to DAQ"
  20015. "constructor. The DAQ constructor takes one"
  20016. "string as an argument specifying a device name."
  20017. "Example: Dev1");
  20018. }
  20019. return object;
  20020. }
  20021. /*:332*//*333:*/
  20022. #line 7476 "./typica.w"
  20023. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  20024. {
  20025. setQObjectProperties(value,engine);
  20026. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  20027. }
  20028. /*:333*//*334:*/
  20029. #line 7486 "./typica.w"
  20030. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20031. {
  20032. DAQ*self= getself<DAQ*> (context);
  20033. QScriptValue object;
  20034. if(self)
  20035. {
  20036. object=
  20037. engine->newQObject(self->newChannel(argument<int> (0,context),
  20038. argument<int> (1,context)));
  20039. setChannelProperties(object,engine);
  20040. }
  20041. return object;
  20042. }
  20043. /*:334*//*341:*/
  20044. #line 7642 "./typica.w"
  20045. QScriptValue constructFakeDAQ(QScriptContext*context,
  20046. QScriptEngine*engine)
  20047. {
  20048. QScriptValue object;
  20049. if(context->argumentCount()==1)
  20050. {
  20051. object=
  20052. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  20053. QScriptEngine::ScriptOwnership);
  20054. setFakeDAQProperties(object,engine);
  20055. }
  20056. else
  20057. {
  20058. context->throwError("Incorrect number of arguments passed to DAQ"
  20059. "constructor. The DAQ constructor takes one"
  20060. "string as an argument specifying a device name."
  20061. "Example: Dev1");
  20062. }
  20063. return object;
  20064. }
  20065. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  20066. {
  20067. setQObjectProperties(value,engine);
  20068. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  20069. }
  20070. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  20071. {
  20072. FakeDAQ*self= getself<FakeDAQ*> (context);
  20073. QScriptValue object;
  20074. if(self)
  20075. {
  20076. object=
  20077. engine->newQObject(self->newChannel(argument<int> (0,context),
  20078. argument<int> (1,context)));
  20079. setChannelProperties(object,engine);
  20080. }
  20081. return object;
  20082. }
  20083. /*:341*//*345:*/
  20084. #line 7733 "./typica.w"
  20085. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  20086. {
  20087. setQObjectProperties(value,engine);
  20088. }
  20089. /*:345*//*352:*/
  20090. #line 7925 "./typica.w"
  20091. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  20092. {
  20093. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  20094. setLinearCalibratorProperties(object,engine);
  20095. return object;
  20096. }
  20097. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  20098. {
  20099. setQObjectProperties(value,engine);
  20100. }
  20101. /*:352*//*357:*/
  20102. #line 8063 "./typica.w"
  20103. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  20104. {
  20105. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  20106. setLinearSplineInterpolatorProperties(object,engine);
  20107. return object;
  20108. }
  20109. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  20110. {
  20111. setQObjectProperties(value,engine);
  20112. }
  20113. /*:357*//*367:*/
  20114. #line 8272 "./typica.w"
  20115. QScriptValue constructTemperatureDisplay(QScriptContext*,
  20116. QScriptEngine*engine)
  20117. {
  20118. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  20119. setTemperatureDisplayProperties(object,engine);
  20120. return object;
  20121. }
  20122. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20123. {
  20124. setQLCDNumberProperties(value,engine);
  20125. value.setProperty("setDisplayUnits",
  20126. engine->newFunction(TemperatureDisplay_setDisplayUnits));
  20127. }
  20128. /*:367*//*368:*/
  20129. #line 8296 "./typica.w"
  20130. QScriptValue TemperatureDisplay_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20131. {
  20132. TemperatureDisplay*self= getself<TemperatureDisplay*> (context);
  20133. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20134. return QScriptValue();
  20135. }
  20136. /*:368*//*375:*/
  20137. #line 8433 "./typica.w"
  20138. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  20139. QScriptEngine*engine)
  20140. {
  20141. QScriptValue object=
  20142. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  20143. setMeasurementTimeOffsetProperties(object,engine);
  20144. return object;
  20145. }
  20146. void setMeasurementTimeOffsetProperties(QScriptValue value,
  20147. QScriptEngine*engine)
  20148. {
  20149. setQObjectProperties(value,engine);
  20150. }
  20151. /*:375*//*380:*/
  20152. #line 8552 "./typica.w"
  20153. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  20154. {
  20155. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  20156. return object;
  20157. }
  20158. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  20159. {
  20160. setQObjectProperties(value,engine);
  20161. }
  20162. /*:380*//*385:*/
  20163. #line 8649 "./typica.w"
  20164. QScriptValue constructZeroEmitter(QScriptContext*context,
  20165. QScriptEngine*engine)
  20166. {
  20167. QScriptValue object=
  20168. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  20169. setZeroEmitterProperties(object,engine);
  20170. return object;
  20171. }
  20172. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  20173. {
  20174. setQObjectProperties(value,engine);
  20175. }
  20176. /*:385*//*390:*/
  20177. #line 8729 "./typica.w"
  20178. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  20179. QScriptEngine*engine)
  20180. {
  20181. QScriptValue object=
  20182. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  20183. setMeasurementAdapterProperties(object,engine);
  20184. return object;
  20185. }
  20186. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  20187. {
  20188. setQObjectProperties(value,engine);
  20189. }
  20190. /*:390*//*407:*/
  20191. #line 9191 "./typica.w"
  20192. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  20193. {
  20194. QScriptValue object= engine->newQObject(new GraphView);
  20195. setGraphViewProperties(object,engine);
  20196. return object;
  20197. }
  20198. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  20199. {
  20200. setQGraphicsViewProperties(value,engine);
  20201. }
  20202. /*:407*//*430:*/
  20203. #line 9841 "./typica.w"
  20204. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  20205. {
  20206. QScriptValue object= engine->newQObject(new ZoomLog);
  20207. setZoomLogProperties(object,engine);
  20208. return object;
  20209. }
  20210. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  20211. {
  20212. setQTableViewProperties(value,engine);
  20213. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  20214. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  20215. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  20216. value.setProperty("restoreState",
  20217. engine->newFunction(ZoomLog_restoreState));
  20218. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  20219. value.setProperty("saveTemporary",
  20220. engine->newFunction(ZoomLog_saveTemporary));
  20221. value.setProperty("setDisplayUnits",engine->newFunction(ZoomLog_setDisplayUnits));
  20222. }
  20223. /*:430*//*431:*/
  20224. #line 9868 "./typica.w"
  20225. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  20226. {
  20227. ZoomLog*self= getself<ZoomLog*> (context);
  20228. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  20229. return QScriptValue(engine,retval);
  20230. }
  20231. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  20232. {
  20233. ZoomLog*self= getself<ZoomLog*> (context);
  20234. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  20235. return QScriptValue(engine,retval);
  20236. }
  20237. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  20238. QScriptEngine*engine)
  20239. {
  20240. ZoomLog*self= getself<ZoomLog*> (context);
  20241. QString filename= QDir::tempPath();
  20242. filename.append("/");
  20243. filename.append(QUuid::createUuid().toString());
  20244. filename.append(".xml");
  20245. QFile*file= new QFile(filename);
  20246. self->saveXML(file);
  20247. file->close();
  20248. delete file;
  20249. return QScriptValue(engine,filename);
  20250. }
  20251. /*:431*//*432:*/
  20252. #line 9916 "./typica.w"
  20253. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  20254. {
  20255. ZoomLog*self= getself<ZoomLog*> (context);
  20256. QString key= argument<QString> (0,context);
  20257. int columns= argument<int> (1,context);
  20258. QSettings settings;
  20259. for(int i= 0;i<columns;i++)
  20260. {
  20261. if(self->columnWidth(i))
  20262. {
  20263. settings.beginGroup(key);
  20264. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  20265. settings.endGroup();
  20266. }
  20267. }
  20268. return QScriptValue();
  20269. }
  20270. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  20271. {
  20272. ZoomLog*self= getself<ZoomLog*> (context);
  20273. QString key= argument<QString> (0,context);
  20274. int columns= argument<int> (1,context);
  20275. QSettings settings;
  20276. for(int i= 0;i<columns;i++)
  20277. {
  20278. settings.beginGroup(key);
  20279. self->setColumnWidth(i,
  20280. settings.value(QString("%1").arg(i),80).toInt());
  20281. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  20282. {
  20283. self->setColumnWidth(i,80);
  20284. }
  20285. settings.endGroup();
  20286. }
  20287. return QScriptValue();
  20288. }
  20289. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  20290. {
  20291. ZoomLog*self= getself<ZoomLog*> (context);
  20292. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  20293. }
  20294. /*:432*//*433:*/
  20295. #line 9969 "./typica.w"
  20296. QScriptValue ZoomLog_setDisplayUnits(QScriptContext*context,QScriptEngine*)
  20297. {
  20298. ZoomLog*self= getself<ZoomLog*> (context);
  20299. self->setDisplayUnits((Units::Unit)argument<int> (0,context));
  20300. return QScriptValue();
  20301. }
  20302. /*:433*//*468:*/
  20303. #line 10789 "./typica.w"
  20304. QScriptValue constructAnnotationButton(QScriptContext*context,
  20305. QScriptEngine*engine)
  20306. {
  20307. QScriptValue object=
  20308. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  20309. setAnnotationButtonProperties(object,engine);
  20310. return object;
  20311. }
  20312. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  20313. {
  20314. setQPushButtonProperties(value,engine);
  20315. }
  20316. /*:468*//*476:*/
  20317. #line 10932 "./typica.w"
  20318. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  20319. QScriptEngine*engine)
  20320. {
  20321. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  20322. argument<QString> (0,context),argument<QString> (1,context)));
  20323. setAnnotationSpinBoxProperties(object,engine);
  20324. return object;
  20325. }
  20326. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20327. {
  20328. setQDoubleSpinBoxProperties(value,engine);
  20329. }
  20330. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20331. {
  20332. setQAbstractSpinBoxProperties(value,engine);
  20333. }
  20334. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  20335. {
  20336. setQWidgetProperties(value,engine);
  20337. }
  20338. /*:476*//*497:*/
  20339. #line 11355 "./typica.w"
  20340. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  20341. {
  20342. QScriptValue object= engine->newQObject(new TimerDisplay);
  20343. setTimerDisplayProperties(object,engine);
  20344. return object;
  20345. }
  20346. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  20347. {
  20348. setQLCDNumberProperties(value,engine);
  20349. value.setProperty("setTimerMode",engine->newFunction(TimerDisplay_setTimerMode));
  20350. }
  20351. /*:497*//*498:*/
  20352. #line 11374 "./typica.w"
  20353. QScriptValue TimerDisplay_setTimerMode(QScriptContext*context,QScriptEngine*)
  20354. {
  20355. TimerDisplay*self= getself<TimerDisplay*> (context);
  20356. if(self)
  20357. {
  20358. switch(argument<int> (0,context))
  20359. {
  20360. case 0:
  20361. self->setMode(TimerDisplay::CountUp);
  20362. break;
  20363. case 1:
  20364. self->setMode(TimerDisplay::CountDown);
  20365. break;
  20366. case 2:
  20367. self->setMode(TimerDisplay::Clock);
  20368. break;
  20369. default:
  20370. break;
  20371. }
  20372. }
  20373. return QScriptValue();
  20374. }
  20375. /*:498*//*525:*/
  20376. #line 11880 "./typica.w"
  20377. QScriptValue constructWidgetDecorator(QScriptContext*context,
  20378. QScriptEngine*engine)
  20379. {
  20380. QWidget*widget= argument<QWidget*> (0,context);
  20381. QString text= argument<QString> (1,context);
  20382. Qt::Orientations orientation;
  20383. switch(argument<int> (2,context))
  20384. {
  20385. case 2:
  20386. orientation= Qt::Vertical;
  20387. break;
  20388. default:
  20389. orientation= Qt::Horizontal;
  20390. break;
  20391. }
  20392. QScriptValue object=
  20393. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  20394. setWidgetDecoratorProperties(object,engine);
  20395. return object;
  20396. }
  20397. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  20398. {
  20399. setQWidgetProperties(value,engine);
  20400. }
  20401. /*:525*//*538:*/
  20402. #line 12161 "./typica.w"
  20403. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  20404. {
  20405. QScriptValue object= engine->newQObject(new LogEditWindow);
  20406. return object;
  20407. }
  20408. /*:538*//*557:*/
  20409. #line 12688 "./typica.w"
  20410. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  20411. {
  20412. QIODevice*device= argument<QIODevice*> (0,context);
  20413. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  20414. argument<int> (1,context)));
  20415. object.setProperty("input",engine->newFunction(XMLInput_input));
  20416. return object;
  20417. }
  20418. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  20419. {
  20420. XMLInput*self= getself<XMLInput*> (context);
  20421. self->input();
  20422. return QScriptValue();
  20423. }
  20424. /*:557*//*572:*/
  20425. #line 172 "./webview.w"
  20426. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  20427. {
  20428. QScriptValue object= engine->newQObject(new TypicaWebView);
  20429. setQWebViewProperties(object,engine);
  20430. return object;
  20431. }
  20432. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  20433. {
  20434. setQWidgetProperties(value,engine);
  20435. }
  20436. /*:572*//*573:*/
  20437. #line 189 "./webview.w"
  20438. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  20439. QStack<QLayout*> *layoutStack)
  20440. {
  20441. TypicaWebView*view= new TypicaWebView;
  20442. if(element.hasAttribute("id"))
  20443. {
  20444. view->setObjectName(element.attribute("id"));
  20445. }
  20446. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20447. layout->addWidget(view);
  20448. }
  20449. /*:573*//*578:*/
  20450. #line 240 "./webview.w"
  20451. QScriptValue QWebElement_toScriptValue(QScriptEngine*engine,const QWebElement&element)
  20452. {
  20453. QVariant var;
  20454. var.setValue(element);
  20455. QScriptValue object= engine->newVariant(var);
  20456. return object;
  20457. }
  20458. void QWebElement_fromScriptValue(const QScriptValue&value,QWebElement&element)
  20459. {
  20460. element= value.toVariant().value<QWebElement> ();
  20461. }
  20462. /*:578*//*583:*/
  20463. #line 305 "./webview.w"
  20464. template<> QWebElement argument(int arg,QScriptContext*context)
  20465. {
  20466. return qscriptvalue_cast<QWebElement> (context->argument(arg));
  20467. }
  20468. /*:583*//*584:*/
  20469. #line 314 "./webview.w"
  20470. QScriptValue constructWebElement(QScriptContext*context,
  20471. QScriptEngine*engine)
  20472. {
  20473. QWebElement element= argument<QWebElement> (0,context);
  20474. QScriptValue object= engine->newQObject(new TypicaWebElement(element));
  20475. return object;
  20476. }
  20477. /*:584*//*595:*/
  20478. #line 85 "./printerselector.w"
  20479. QScriptValue constructPrinterSelector(QScriptContext*,QScriptEngine*engine)
  20480. {
  20481. QScriptValue object= engine->newQObject(new PrinterSelector);
  20482. setQComboBoxProperties(object,engine);
  20483. return object;
  20484. }
  20485. /*:595*//*596:*/
  20486. #line 96 "./printerselector.w"
  20487. void addPrinterSelectorToLayout(QDomElement element,QStack<QWidget*> *,
  20488. QStack<QLayout*> *layoutStack)
  20489. {
  20490. PrinterSelector*selector= new PrinterSelector;
  20491. if(element.hasAttribute("id"))
  20492. {
  20493. selector->setObjectName(element.attribute("id"));
  20494. }
  20495. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20496. layout->addWidget(selector);
  20497. }
  20498. /*:596*//*662:*/
  20499. #line 14075 "./typica.w"
  20500. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  20501. {
  20502. QScriptValue object= engine->newQObject(new SqlQueryView);
  20503. setSqlQueryViewProperties(object,engine);
  20504. return object;
  20505. }
  20506. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  20507. {
  20508. setQTableViewProperties(value,engine);
  20509. value.setProperty("setHeaderData",
  20510. engine->newFunction(SqlQueryView_setHeaderData));
  20511. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  20512. }
  20513. /*:662*//*663:*/
  20514. #line 14093 "./typica.w"
  20515. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  20516. {
  20517. SqlQueryView*self= getself<SqlQueryView*> (context);
  20518. QString query= argument<QString> (0,context);
  20519. self->setQuery(query);
  20520. self->reset();
  20521. return QScriptValue();
  20522. }
  20523. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  20524. QScriptEngine*)
  20525. {
  20526. SqlQueryView*self= getself<SqlQueryView*> (context);
  20527. int section= argument<int> (0,context);
  20528. QString data= argument<QString> (1,context);
  20529. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  20530. return QScriptValue();
  20531. }
  20532. /*:663*//*671:*/
  20533. #line 14302 "./typica.w"
  20534. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  20535. QStack<QLayout*> *layoutStack)
  20536. {
  20537. QTextEdit*widget= new QTextEdit;
  20538. if(element.hasAttribute("id"))
  20539. {
  20540. widget->setObjectName(element.attribute("id"));
  20541. }
  20542. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20543. layout->addWidget(widget);
  20544. QTextDocument*document= new QTextDocument;
  20545. QFont defaultFont;
  20546. defaultFont.setPointSize(11);
  20547. document->setDefaultFont(defaultFont);
  20548. QTextCursor cursor(document);
  20549. /*672:*/
  20550. #line 14325 "./typica.w"
  20551. QDomNodeList children= element.childNodes();
  20552. for(int i= 0;i<children.count();i++)
  20553. {
  20554. QDomNode current;
  20555. QDomElement currentElement;
  20556. current= children.at(i);
  20557. if(current.isElement())
  20558. {
  20559. currentElement= current.toElement();
  20560. /*673:*/
  20561. #line 14342 "./typica.w"
  20562. if(currentElement.tagName()=="style")
  20563. {
  20564. document->setDefaultStyleSheet(currentElement.text());
  20565. }
  20566. /*:673*//*674:*/
  20567. #line 14353 "./typica.w"
  20568. if(currentElement.tagName()=="html")
  20569. {
  20570. cursor.insertHtml(currentElement.text());
  20571. }
  20572. /*:674*//*675:*/
  20573. #line 14363 "./typica.w"
  20574. if(currentElement.tagName()=="text")
  20575. {
  20576. cursor.insertText(currentElement.text());
  20577. }
  20578. /*:675*//*676:*/
  20579. #line 14373 "./typica.w"
  20580. if(currentElement.tagName()=="table")
  20581. {
  20582. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  20583. ReportTable*table= new ReportTable(frame,currentElement);
  20584. table->setParent(widget);
  20585. if(currentElement.hasAttribute("id"))
  20586. {
  20587. table->setObjectName(currentElement.attribute("id"));
  20588. }
  20589. }
  20590. /*:676*/
  20591. #line 14335 "./typica.w"
  20592. }
  20593. }
  20594. /*:672*/
  20595. #line 14318 "./typica.w"
  20596. widget->setDocument(document);
  20597. }
  20598. /*:671*//*687:*/
  20599. #line 14586 "./typica.w"
  20600. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  20601. {
  20602. QTextEdit*self= getself<QTextEdit*> (context);
  20603. QTextDocument*document= self->document();
  20604. QPrinter printer;
  20605. QPrintDialog printwindow(&printer,self);
  20606. if(printwindow.exec()!=QDialog::Accepted)
  20607. {
  20608. return QScriptValue();
  20609. }
  20610. document->print(&printer);
  20611. return QScriptValue();
  20612. }
  20613. /*:687*//*688:*/
  20614. #line 14604 "./typica.w"
  20615. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  20616. {
  20617. setQAbstractScrollAreaProperties(value,engine);
  20618. value.setProperty("print",engine->newFunction(QTextEdit_print));
  20619. }
  20620. #line 1 "./plugins.w"
  20621. /*:688*//*713:*/
  20622. #line 461 "./daterangeselector.w"
  20623. void addDateRangeToLayout(QDomElement element,QStack<QWidget*> *,
  20624. QStack<QLayout*> *layoutStack)
  20625. {
  20626. DateRangeSelector*widget= new DateRangeSelector;
  20627. if(element.hasAttribute("id"))
  20628. {
  20629. widget->setObjectName(element.attribute("id"));
  20630. }
  20631. if(element.hasAttribute("initial"))
  20632. {
  20633. widget->setCurrentIndex(element.attribute("initial").toInt());
  20634. }
  20635. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20636. layout->addWidget(widget);
  20637. }
  20638. /*:713*//*724:*/
  20639. #line 14786 "./typica.w"
  20640. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  20641. QStack<QLayout*> *layoutStack)
  20642. {
  20643. FormArray*widget= new FormArray(element);
  20644. if(element.hasAttribute("id"))
  20645. {
  20646. widget->setObjectName(element.attribute("id"));
  20647. }
  20648. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20649. layout->addWidget(widget);
  20650. }
  20651. /*:724*//*745:*/
  20652. #line 15373 "./typica.w"
  20653. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  20654. QStack<QLayout*> *layoutStack)
  20655. {
  20656. ScaleControl*scale= new ScaleControl;
  20657. if(element.hasAttribute("id"))
  20658. {
  20659. scale->setObjectName(element.attribute("id"));
  20660. }
  20661. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20662. layout->addWidget(scale);
  20663. }
  20664. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  20665. QStack<QLayout*> *layoutStack)
  20666. {
  20667. IntensityControl*scale= new IntensityControl;
  20668. if(element.hasAttribute("id"))
  20669. {
  20670. scale->setObjectName(element.attribute("id"));
  20671. }
  20672. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  20673. layout->addWidget(scale);
  20674. }
  20675. /*:745*//*771:*/
  20676. #line 15963 "./typica.w"
  20677. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  20678. {
  20679. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  20680. setDeviceTreeModelProperties(object,engine);
  20681. return object;
  20682. }
  20683. /*:771*//*773:*/
  20684. #line 15986 "./typica.w"
  20685. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  20686. {
  20687. setQAbstractItemModelProperties(value,engine);
  20688. value.setProperty("referenceElement",
  20689. engine->newFunction(DeviceTreeModel_referenceElement));
  20690. }
  20691. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  20692. {
  20693. setQObjectProperties(value,engine);
  20694. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  20695. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  20696. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  20697. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  20698. }
  20699. /*:773*//*774:*/
  20700. #line 16013 "./typica.w"
  20701. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  20702. QScriptEngine*engine)
  20703. {
  20704. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  20705. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  20706. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  20707. QDomElement node;
  20708. QVariantMap retval;
  20709. retval.insert("driver",referenceElement.attribute("driver"));
  20710. for(int i= 0;i<configData.size();i++)
  20711. {
  20712. node= configData.at(i).toElement();
  20713. retval.insert(node.attribute("name"),node.attribute("value"));
  20714. }
  20715. return engine->toScriptValue(retval);
  20716. }
  20717. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  20718. {
  20719. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20720. QModelIndex index= argument<QModelIndex> (0,context);
  20721. int role= argument<int> (1,context);
  20722. return engine->toScriptValue(model->data(index,role));
  20723. }
  20724. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  20725. {
  20726. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20727. int row= 0;
  20728. int column= 0;
  20729. QModelIndex index;
  20730. if(context->argumentCount()> 1)
  20731. {
  20732. row= argument<int> (0,context);
  20733. column= argument<int> (1,context);
  20734. }
  20735. if(context->argumentCount()> 2)
  20736. {
  20737. index= argument<QModelIndex> (2,context);
  20738. }
  20739. QModelIndex retval= model->index(row,column,index);
  20740. return engine->toScriptValue(retval);
  20741. }
  20742. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  20743. QScriptEngine*)
  20744. {
  20745. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20746. QModelIndex index;
  20747. if(context->argumentCount()==1)
  20748. {
  20749. index= argument<QModelIndex> (0,context);
  20750. }
  20751. return QScriptValue(model->rowCount(index));
  20752. }
  20753. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  20754. QScriptEngine*engine)
  20755. {
  20756. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  20757. QModelIndex index;
  20758. if(context->argumentCount()==1)
  20759. {
  20760. index= argument<QModelIndex> (0,context);
  20761. }
  20762. return QScriptValue(engine,model->hasChildren(index));
  20763. }
  20764. /*:774*//*777:*/
  20765. #line 16097 "./typica.w"
  20766. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  20767. {
  20768. QVariant var;
  20769. var.setValue(index);
  20770. QScriptValue object= engine->newVariant(var);
  20771. return object;
  20772. }
  20773. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  20774. {
  20775. index= value.toVariant().value<QModelIndex> ();
  20776. }
  20777. /*:777*//*793:*/
  20778. #line 16395 "./typica.w"
  20779. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  20780. QScriptEngine*engine)
  20781. {
  20782. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  20783. return object;
  20784. }
  20785. /*:793*//*864:*/
  20786. #line 47 "./settings.w"
  20787. QScriptValue constructSettingsWindow(QScriptContext*,QScriptEngine*engine)
  20788. {
  20789. QScriptValue object= engine->newQObject(new SettingsWindow);
  20790. return object;
  20791. }
  20792. /*:864*//*889:*/
  20793. #line 19049 "./typica.w"
  20794. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  20795. {
  20796. QScriptValue object;
  20797. if(context->argumentCount()==2)
  20798. {
  20799. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  20800. argument<QModelIndex> (1,context)),
  20801. QScriptEngine::ScriptOwnership);
  20802. setModbusRTUDeviceProperties(object,engine);
  20803. }
  20804. else
  20805. {
  20806. context->throwError("Incorrect number of arguments passed to "
  20807. "ModbusRTUDevice constructor. This takes the configuration model "
  20808. "and an index.");
  20809. }
  20810. return object;
  20811. }
  20812. /*:889*//*890:*/
  20813. #line 19071 "./typica.w"
  20814. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  20815. {
  20816. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  20817. QScriptValue object;
  20818. if(self)
  20819. {
  20820. if(self->channels.size()> 0)
  20821. {
  20822. object= engine->newQObject(self->channels.at(0));
  20823. setChannelProperties(object,engine);
  20824. }
  20825. }
  20826. return object;
  20827. }
  20828. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  20829. {
  20830. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  20831. QScriptValue object;
  20832. if(self)
  20833. {
  20834. if(self->channels.size()> 1)
  20835. {
  20836. object= engine->newQObject(self->channels.at(1));
  20837. setChannelProperties(object,engine);
  20838. }
  20839. }
  20840. return object;
  20841. }
  20842. /*:890*//*891:*/
  20843. #line 19104 "./typica.w"
  20844. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  20845. {
  20846. setQObjectProperties(value,engine);
  20847. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  20848. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  20849. }
  20850. /*:891*//*907:*/
  20851. #line 713 "./modbus.w"
  20852. QScriptValue constructModbusNG(QScriptContext*context,QScriptEngine*engine)
  20853. {
  20854. QScriptValue object;
  20855. if(context->argumentCount()==2)
  20856. {
  20857. object= engine->newQObject(new ModbusNG(argument<DeviceTreeModel*> (0,context),
  20858. argument<QModelIndex> (1,context)),
  20859. QScriptEngine::ScriptOwnership);
  20860. setModbusNGProperties(object,engine);
  20861. }
  20862. else
  20863. {
  20864. context->throwError("Incorrect number of arguments passed to "
  20865. "ModbusNG constructor.");
  20866. }
  20867. return object;
  20868. }
  20869. void setModbusNGProperties(QScriptValue value,QScriptEngine*engine)
  20870. {
  20871. setQObjectProperties(value,engine);
  20872. value.setProperty("getChannel",engine->newFunction(ModbusNG_getChannel));
  20873. }
  20874. QScriptValue ModbusNG_getChannel(QScriptContext*context,QScriptEngine*engine)
  20875. {
  20876. ModbusNG*self= getself<ModbusNG*> (context);
  20877. QScriptValue object;
  20878. if(self)
  20879. {
  20880. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20881. setChannelProperties(object,engine);
  20882. }
  20883. return object;
  20884. }
  20885. #line 19655 "./typica.w"
  20886. #line 1 "./unsupportedserial.w"
  20887. /*:907*//*921:*/
  20888. #line 357 "./unsupportedserial.w"
  20889. QScriptValue createDevice(QScriptContext*context,QScriptEngine*engine)
  20890. {
  20891. QModelIndex deviceIndex= argument<QModelIndex> (0,context);
  20892. JavaScriptDevice*device= new JavaScriptDevice(deviceIndex,engine);
  20893. QScriptValue object= engine->newQObject(device);
  20894. setQObjectProperties(object,engine);
  20895. object.setProperty("getChannel",engine->newFunction(JavaScriptDevice_getChannel));
  20896. return object;
  20897. }
  20898. /*:921*//*926:*/
  20899. #line 430 "./unsupportedserial.w"
  20900. QScriptValue JavaScriptDevice_getChannel(QScriptContext*context,QScriptEngine*engine)
  20901. {
  20902. JavaScriptDevice*self= getself<JavaScriptDevice*> (context);
  20903. QScriptValue object;
  20904. if(self)
  20905. {
  20906. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20907. setChannelProperties(object,engine);
  20908. }
  20909. return object;
  20910. }
  20911. /*:926*//*933:*/
  20912. #line 630 "./unsupportedserial.w"
  20913. QScriptValue getMeasurementTimestamp(QScriptContext*,QScriptEngine*engine)
  20914. {
  20915. return engine->toScriptValue<QTime> (QTime::currentTime());
  20916. }
  20917. /*:933*//*937:*/
  20918. #line 667 "./unsupportedserial.w"
  20919. QScriptValue constructSerialPort(QScriptContext*,QScriptEngine*engine)
  20920. {
  20921. QScriptValue object= engine->newQObject(new QextSerialPort());
  20922. setSerialPortProperties(object,engine);
  20923. return object;
  20924. }
  20925. /*:937*//*938:*/
  20926. #line 678 "./unsupportedserial.w"
  20927. void setSerialPortProperties(QScriptValue value,QScriptEngine*engine)
  20928. {
  20929. setQIODeviceProperties(value,engine);
  20930. value.setProperty("flush",engine->newFunction(SerialPort_flush));
  20931. }
  20932. /*:938*//*939:*/
  20933. #line 687 "./unsupportedserial.w"
  20934. QScriptValue SerialPort_flush(QScriptContext*context,QScriptEngine*)
  20935. {
  20936. QextSerialPort*self= getself<QextSerialPort*> (context);
  20937. self->flush();
  20938. return QScriptValue();
  20939. }
  20940. #line 19657 "./typica.w"
  20941. #line 1 "./phidgets.w"
  20942. /*:939*//*960:*/
  20943. #line 463 "./phidgets.w"
  20944. QScriptValue constructPhidgetsTemperatureSensor(QScriptContext*context,QScriptEngine*engine)
  20945. {
  20946. if(context->argumentCount()!=1)
  20947. {
  20948. context->throwError("Incorrect number of arguments passed to "
  20949. "PhidgetsTemperatureSensor constructor. This takes "
  20950. "a QModelIndex.");
  20951. }
  20952. QScriptValue object= engine->newQObject(new PhidgetsTemperatureSensor(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  20953. setQObjectProperties(object,engine);
  20954. object.setProperty("getChannel",engine->newFunction(Phidgets_getChannel));
  20955. return object;
  20956. }
  20957. /*:960*//*961:*/
  20958. #line 480 "./phidgets.w"
  20959. QScriptValue Phidgets_getChannel(QScriptContext*context,QScriptEngine*engine)
  20960. {
  20961. PhidgetsTemperatureSensor*self= getself<PhidgetsTemperatureSensor*> (context);
  20962. QScriptValue object;
  20963. if(self)
  20964. {
  20965. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20966. setChannelProperties(object,engine);
  20967. }
  20968. return object;
  20969. }
  20970. #line 19659 "./typica.w"
  20971. #line 1 "./phidget22.w"
  20972. /*:961*//*992:*/
  20973. #line 811 "./phidget22.w"
  20974. QScriptValue constructPhidget22(QScriptContext*context,QScriptEngine*engine)
  20975. {
  20976. if(context->argumentCount()!=1)
  20977. {
  20978. context->throwError("Incorrect number of arguments");
  20979. }
  20980. QScriptValue object= engine->newQObject(new Phidget22(argument<QModelIndex> (0,context)),QScriptEngine::ScriptOwnership);
  20981. setQObjectProperties(object,engine);
  20982. object.setProperty("getChannel",engine->newFunction(Phidget22_getChannel));
  20983. return object;
  20984. }
  20985. /*:992*//*993:*/
  20986. #line 826 "./phidget22.w"
  20987. QScriptValue Phidget22_getChannel(QScriptContext*context,QScriptEngine*engine)
  20988. {
  20989. Phidget22*self= getself<Phidget22*> (context);
  20990. QScriptValue object;
  20991. if(self)
  20992. {
  20993. object= engine->newQObject(self->getChannel(argument<int> (0,context)));
  20994. setChannelProperties(object,engine);
  20995. }
  20996. return object;
  20997. }
  20998. #line 19661 "./typica.w"
  20999. /*:993*//*1025:*/
  21000. #line 151 "./rate.w"
  21001. QScriptValue constructRateOfChange(QScriptContext*context,QScriptEngine*engine)
  21002. {
  21003. int cachetime= 1;
  21004. int scaletime= 1;
  21005. if(context->argumentCount()> 0)
  21006. {
  21007. cachetime= argument<int> (0,context);
  21008. if(context->argumentCount()> 1)
  21009. {
  21010. scaletime= argument<int> (1,context);
  21011. }
  21012. }
  21013. QScriptValue object= engine->newQObject(new RateOfChange(cachetime,scaletime));
  21014. setRateOfChangeProperties(object,engine);
  21015. return object;
  21016. }
  21017. void setRateOfChangeProperties(QScriptValue value,QScriptEngine*engine)
  21018. {
  21019. setQObjectProperties(value,engine);
  21020. }
  21021. /*:1025*//*1039:*/
  21022. #line 148 "./mergeseries.w"
  21023. QScriptValue constructDifferenceSeries(QScriptContext*,QScriptEngine*engine)
  21024. {
  21025. QScriptValue object= engine->newQObject(new DifferenceSeries);
  21026. setQObjectProperties(object,engine);
  21027. return object;
  21028. }
  21029. QScriptValue constructMeanSeries(QScriptContext*,QScriptEngine*engine)
  21030. {
  21031. QScriptValue object= engine->newQObject(new MeanSeries);
  21032. setQObjectProperties(object,engine);
  21033. return object;
  21034. }
  21035. /*:1039*//*1064:*/
  21036. #line 614 "./dataqsdk.w"
  21037. QScriptValue constructDataqSdkDevice(QScriptContext*context,QScriptEngine*engine)
  21038. {
  21039. QScriptValue object;
  21040. if(context->argumentCount()==1)
  21041. {
  21042. object= engine->newQObject(new DataqSdkDevice(argument<QString> (0,context)),
  21043. QScriptEngine::ScriptOwnership);
  21044. setDataqSdkDeviceProperties(object,engine);
  21045. }
  21046. else
  21047. {
  21048. context->throwError("Incorrect number of arguments passed to "
  21049. "DataqSdkDevice. The constructor takes one string "
  21050. "as an argument specifying a device name. "
  21051. "Example: Dev1");
  21052. }
  21053. return object;
  21054. }
  21055. /*:1064*//*1065:*/
  21056. #line 637 "./dataqsdk.w"
  21057. void setDataqSdkDeviceProperties(QScriptValue value,QScriptEngine*engine)
  21058. {
  21059. setQObjectProperties(value,engine);
  21060. value.setProperty("newChannel",engine->newFunction(DataqSdkDevice_newChannel));
  21061. }
  21062. /*:1065*//*1066:*/
  21063. #line 647 "./dataqsdk.w"
  21064. QScriptValue DataqSdkDevice_newChannel(QScriptContext*context,QScriptEngine*engine)
  21065. {
  21066. DataqSdkDevice*self= getself<DataqSdkDevice*> (context);
  21067. QScriptValue object;
  21068. if(self)
  21069. {
  21070. object= engine->newQObject(self->newChannel((Units::Unit)argument<int> (0,context)));
  21071. setChannelProperties(object,engine);
  21072. }
  21073. return object;
  21074. }
  21075. /*:1066*//*1091:*/
  21076. #line 80 "./scales.w"
  21077. QScriptValue constructDragLabel(QScriptContext*context,QScriptEngine*engine)
  21078. {
  21079. QScriptValue object;
  21080. QString labelText= "";
  21081. if(context->argumentCount()==1)
  21082. {
  21083. labelText= argument<QString> (0,context);
  21084. }
  21085. object= engine->newQObject(new DragLabel(labelText));
  21086. setDragLabelProperties(object,engine);
  21087. return object;
  21088. }
  21089. void setDragLabelProperties(QScriptValue value,QScriptEngine*engine)
  21090. {
  21091. setQLabelProperties(value,engine);
  21092. }
  21093. /*:1091*//*1101:*/
  21094. #line 298 "./scales.w"
  21095. QScriptValue BaudRateType_toScriptValue(QScriptEngine*engine,const BaudRateType&value)
  21096. {
  21097. return engine->newVariant(QVariant((int)(value)));
  21098. }
  21099. void BaudRateType_fromScriptValue(const QScriptValue&sv,BaudRateType&value)
  21100. {
  21101. value= (BaudRateType)(sv.toVariant().toInt());
  21102. }
  21103. QScriptValue DataBitsType_toScriptValue(QScriptEngine*engine,const DataBitsType&value)
  21104. {
  21105. return engine->newVariant(QVariant((int)(value)));
  21106. }
  21107. void DataBitsType_fromScriptValue(const QScriptValue&sv,DataBitsType&value)
  21108. {
  21109. value= (DataBitsType)(sv.toVariant().toInt());
  21110. }
  21111. QScriptValue ParityType_toScriptValue(QScriptEngine*engine,const ParityType&value)
  21112. {
  21113. return engine->newVariant(QVariant((int)(value)));
  21114. }
  21115. void ParityType_fromScriptValue(const QScriptValue&sv,ParityType&value)
  21116. {
  21117. value= (ParityType)(sv.toVariant().toInt());
  21118. }
  21119. QScriptValue StopBitsType_toScriptValue(QScriptEngine*engine,const StopBitsType&value)
  21120. {
  21121. return engine->newVariant(QVariant((int)(value)));
  21122. }
  21123. void StopBitsType_fromScriptValue(const QScriptValue&sv,StopBitsType&value)
  21124. {
  21125. value= (StopBitsType)(sv.toVariant().toInt());
  21126. }
  21127. QScriptValue FlowType_toScriptValue(QScriptEngine*engine,const FlowType&value)
  21128. {
  21129. return engine->newVariant(QVariant((int)(value)));
  21130. }
  21131. void FlowType_fromScriptValue(const QScriptValue&sv,FlowType&value)
  21132. {
  21133. value= (FlowType)(sv.toVariant().toInt());
  21134. }
  21135. /*:1101*//*1104:*/
  21136. #line 367 "./scales.w"
  21137. void setSerialScaleProperties(QScriptValue value,QScriptEngine*engine)
  21138. {
  21139. setQIODeviceProperties(value,engine);
  21140. }
  21141. /*:1104*//*1105:*/
  21142. #line 375 "./scales.w"
  21143. QScriptValue constructSerialScale(QScriptContext*context,QScriptEngine*engine)
  21144. {
  21145. QScriptValue object;
  21146. if(context->argumentCount()==1)
  21147. {
  21148. object= engine->newQObject(new SerialScale(argument<QString> (0,context)));
  21149. setSerialScaleProperties(object,engine);
  21150. }
  21151. else
  21152. {
  21153. context->throwError("Incorrect number of arguments passed to "
  21154. "SerialScale. The constructor takes one string "
  21155. "as an argument specifying a port name.");
  21156. }
  21157. return object;
  21158. }
  21159. /*:1105*//*1127:*/
  21160. #line 278 "./valueannotation.w"
  21161. QScriptValue constructValueAnnotation(QScriptContext*,QScriptEngine*engine)
  21162. {
  21163. QScriptValue object= engine->newQObject(new ValueAnnotation);
  21164. setValueAnnotationProperties(object,engine);
  21165. return object;
  21166. }
  21167. void setValueAnnotationProperties(QScriptValue value,QScriptEngine*engine)
  21168. {
  21169. setQObjectProperties(value,engine);
  21170. }
  21171. #line 20325 "./typica.w"
  21172. #line 1 "./thresholdannotation.w"
  21173. /*:1127*//*1138:*/
  21174. #line 208 "./thresholdannotation.w"
  21175. QScriptValue constructAnnotator(QScriptContext*context,QScriptEngine*engine)
  21176. {
  21177. QScriptValue object= engine->newQObject(new Annotator(argument<QString> (0,context)));
  21178. setAnnotatorProperties(object,engine);
  21179. return object;
  21180. }
  21181. void setAnnotatorProperties(QScriptValue value,QScriptEngine*engine)
  21182. {
  21183. setQObjectProperties(value,engine);
  21184. }
  21185. #line 20327 "./typica.w"
  21186. #line 1 "./user.w"
  21187. /*:1138*//*1148:*/
  21188. #line 142 "./user.w"
  21189. QScriptValue constructLoginDialog(QScriptContext*,QScriptEngine*engine)
  21190. {
  21191. QScriptValue object= engine->newQObject(new LoginDialog);
  21192. return object;
  21193. }
  21194. /*:1148*//*1158:*/
  21195. #line 330 "./user.w"
  21196. QScriptValue constructNewTypicaUser(QScriptContext*,QScriptEngine*engine)
  21197. {
  21198. QScriptValue object= engine->newQObject(new NewTypicaUser);
  21199. return object;
  21200. }
  21201. /*:1158*/
  21202. #line 533 "./typica.w"
  21203. /*641:*/
  21204. #line 13703 "./typica.w"
  21205. void messageFileOutput(QtMsgType,const char*msg)
  21206. {
  21207. QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
  21208. output.open(QIODevice::WriteOnly|QIODevice::Append);
  21209. QTextStream outstream(&output);
  21210. outstream<<msg<<"\r\n";
  21211. }
  21212. /*:641*/
  21213. #line 534 "./typica.w"
  21214. /*638:*/
  21215. #line 13664 "./typica.w"
  21216. int main(int argc,char**argv)
  21217. {
  21218. int*c= &argc;
  21219. Application app(*c,argv);
  21220. QSettings settings;
  21221. /*639:*/
  21222. #line 13690 "./typica.w"
  21223. if(settings.value("settings/advanced/logging",false).toBool())
  21224. {
  21225. qInstallMsgHandler(messageFileOutput);
  21226. }
  21227. /*:639*/
  21228. #line 13670 "./typica.w"
  21229. /*642:*/
  21230. #line 13716 "./typica.w"
  21231. QStringList themeSearchPath= QIcon::themeSearchPaths();
  21232. themeSearchPath.append(":/resources/icons/tango");
  21233. QIcon::setThemeSearchPaths(themeSearchPath);
  21234. QIcon::setThemeName(":/resources/icons/tango");
  21235. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  21236. /*:642*/
  21237. #line 13671 "./typica.w"
  21238. /*643:*/
  21239. #line 13736 "./typica.w"
  21240. QFile entypo(":/resources/fonts/entypo.ttf");
  21241. entypo.open(QIODevice::ReadOnly);
  21242. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  21243. entypo.close();
  21244. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-regular.otf");
  21245. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bold.otf");
  21246. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-bolditalic.otf");
  21247. QFontDatabase::addApplicationFont(":/resources/fonts/texgyrepagella-italic.otf");
  21248. QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont,"Tex Gyre Pagella");
  21249. /*:643*/
  21250. #line 13672 "./typica.w"
  21251. /*803:*/
  21252. #line 16685 "./typica.w"
  21253. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  21254. /*:803*//*813:*/
  21255. #line 16927 "./typica.w"
  21256. app.registerDeviceConfigurationWidget("nidaqmxbase",
  21257. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  21258. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  21259. NiDaqMxBase9211ConfWidget::staticMetaObject);
  21260. app.registerDeviceConfigurationWidget("ni9211seriestc",
  21261. Ni9211TcConfWidget::staticMetaObject);
  21262. /*:813*//*821:*/
  21263. #line 17158 "./typica.w"
  21264. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  21265. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  21266. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  21267. /*:821*//*845:*/
  21268. #line 18127 "./typica.w"
  21269. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  21270. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  21271. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  21272. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  21273. /*:845*//*850:*/
  21274. #line 18212 "./typica.w"
  21275. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  21276. /*:850*//*853:*/
  21277. #line 18282 "./typica.w"
  21278. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  21279. /*:853*//*856:*/
  21280. #line 18409 "./typica.w"
  21281. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  21282. #line 1 "./freeannotation.w"
  21283. /*:856*//*860:*/
  21284. #line 57 "./freeannotation.w"
  21285. app.registerDeviceConfigurationWidget("freeannotation",
  21286. FreeAnnotationConfWidget::staticMetaObject);
  21287. #line 18413 "./typica.w"
  21288. #line 1 "./settings.w"
  21289. /*:860*//*894:*/
  21290. #line 19645 "./typica.w"
  21291. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  21292. /*:894*//*900:*/
  21293. #line 321 "./modbus.w"
  21294. app.registerDeviceConfigurationWidget("modbusngport",ModbusNGConfWidget::staticMetaObject);
  21295. app.registerDeviceConfigurationWidget("modbusnginput",
  21296. ModbusNGInputConfWidget::staticMetaObject);
  21297. /*:900*//*916:*/
  21298. #line 264 "./unsupportedserial.w"
  21299. app.registerDeviceConfigurationWidget("unsupporteddevicechannel",
  21300. UnsupportedDeviceChannelConfWidget::staticMetaObject);
  21301. app.registerDeviceConfigurationWidget("unsupporteddevice",
  21302. UnsupportedSerialDeviceConfWidget::staticMetaObject);
  21303. /*:916*//*947:*/
  21304. #line 181 "./phidgets.w"
  21305. app.registerDeviceConfigurationWidget("phidgets1048",
  21306. PhidgetsTemperatureSensorConfWidget::staticMetaObject);
  21307. app.registerDeviceConfigurationWidget("phidgets1048channel",
  21308. PhidgetTemperatureSensorChannelConfWidget::staticMetaObject);
  21309. /*:947*//*963:*/
  21310. #line 35 "./phidget22.w"
  21311. app.registerDeviceConfigurationWidget("phidget22",
  21312. PhidgetConfWidget::staticMetaObject);
  21313. app.registerDeviceConfigurationWidget("phidgetchannel",
  21314. PhidgetChannelConfWidget::staticMetaObject);
  21315. /*:963*//*999:*/
  21316. #line 19783 "./typica.w"
  21317. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  21318. /*:999*//*1002:*/
  21319. #line 19843 "./typica.w"
  21320. app.registerDeviceConfigurationWidget("coolingtimer",
  21321. CoolingTimerConfWidget::staticMetaObject);
  21322. /*:1002*//*1007:*/
  21323. #line 20102 "./typica.w"
  21324. app.registerDeviceConfigurationWidget("rangetimer",
  21325. RangeTimerConfWidget::staticMetaObject);
  21326. /*:1007*//*1012:*/
  21327. #line 20203 "./typica.w"
  21328. app.registerDeviceConfigurationWidget("multirangetimer",
  21329. MultiRangeTimerConfWidget::staticMetaObject);
  21330. /*:1012*//*1017:*/
  21331. #line 20313 "./typica.w"
  21332. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  21333. #line 1 "./rate.w"
  21334. /*:1017*//*1029:*/
  21335. #line 253 "./rate.w"
  21336. app.registerDeviceConfigurationWidget("rate",RateOfChangeConfWidget::staticMetaObject);
  21337. /*:1029*//*1043:*/
  21338. #line 266 "./mergeseries.w"
  21339. app.registerDeviceConfigurationWidget("mergeseries",
  21340. MergeSeriesConfWidget::staticMetaObject);
  21341. /*:1043*//*1084:*/
  21342. #line 1233 "./dataqsdk.w"
  21343. app.registerDeviceConfigurationWidget("dataqsdk",DataqSdkDeviceConfWidget::staticMetaObject);
  21344. app.registerDeviceConfigurationWidget("dataqsdkchannel",
  21345. DataqSdkChannelConfWidget::staticMetaObject);
  21346. /*:1084*//*1109:*/
  21347. #line 552 "./scales.w"
  21348. app.registerDeviceConfigurationWidget("scale",SerialScaleConfWidget::staticMetaObject);
  21349. /*:1109*//*1117:*/
  21350. #line 138 "./valueannotation.w"
  21351. app.registerDeviceConfigurationWidget("valueannotation",
  21352. ValueAnnotationConfWidget::staticMetaObject);
  21353. /*:1117*//*1131:*/
  21354. #line 109 "./thresholdannotation.w"
  21355. app.registerDeviceConfigurationWidget("thresholdannotation",
  21356. ThresholdAnnotationConfWidget::staticMetaObject);
  21357. /*:1131*/
  21358. #line 13674 "./typica.w"
  21359. /*644:*/
  21360. #line 13753 "./typica.w"
  21361. if(settings.value("database/exists","false").toString()=="true")
  21362. {
  21363. /*649:*/
  21364. #line 13888 "./typica.w"
  21365. QSqlDatabase database=
  21366. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  21367. database.setConnectOptions("application_name=Typica");
  21368. database.setHostName(settings.value("database/hostname").toString());
  21369. database.setPort(settings.value("database/portnumber",5432).toInt());
  21370. database.setDatabaseName(settings.value("database/dbname").toString());
  21371. database.setUserName(settings.value("database/user").toString());
  21372. database.setPassword(settings.value("database/password").toString());
  21373. if(!database.open())
  21374. {
  21375. settings.setValue("database/exists","false");
  21376. }
  21377. else
  21378. {
  21379. database.close();
  21380. AppInstance->setDatabaseConnected(true);
  21381. }
  21382. /*:649*/
  21383. #line 13756 "./typica.w"
  21384. }
  21385. if(settings.value("database/exists","false").toString()=="false")
  21386. {
  21387. /*648:*/
  21388. #line 13879 "./typica.w"
  21389. SqlConnectionSetup dialog;
  21390. dialog.exec();
  21391. /*:648*/
  21392. #line 13760 "./typica.w"
  21393. }
  21394. /*:644*/
  21395. #line 13675 "./typica.w"
  21396. /*193:*/
  21397. #line 4436 "./typica.w"
  21398. QStringList arguments= QCoreApplication::arguments();
  21399. int position= arguments.indexOf("-c");
  21400. QString filename= QString();
  21401. if(position!=-1)
  21402. {
  21403. if(arguments.size()>=position+1)
  21404. {
  21405. filename= arguments.at(position+1);
  21406. }
  21407. }else{
  21408. QDir checkPath(QCoreApplication::applicationDirPath()+"/../config/");
  21409. if(checkPath.exists("config.xml")){
  21410. filename= checkPath.filePath("config.xml");
  21411. }else{
  21412. checkPath= QDir(QCoreApplication::applicationDirPath()+"/config/");
  21413. if(checkPath.exists("config.xml")){
  21414. filename= checkPath.filePath("config.xml");
  21415. }
  21416. }
  21417. }
  21418. if(filename.isEmpty())
  21419. {
  21420. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  21421. settings.value("config","").toString());
  21422. }
  21423. QDir directory;
  21424. if(!filename.isEmpty())
  21425. {
  21426. QFile file(filename);
  21427. QFileInfo info(filename);
  21428. directory= info.dir();
  21429. QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
  21430. QTranslator*configtr= new QTranslator;
  21431. if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
  21432. QString("%1/Translations").arg(directory.canonicalPath())))
  21433. {
  21434. QCoreApplication::installTranslator(configtr);
  21435. }
  21436. settings.setValue("config",directory.path());
  21437. if(file.open(QIODevice::ReadOnly))
  21438. {
  21439. app.configuration()->setContent(&file,true);
  21440. }
  21441. }else{
  21442. return 1;
  21443. }
  21444. /*194:*/
  21445. #line 4489 "./typica.w"
  21446. QDomElement root= app.configuration()->documentElement();
  21447. QDomNodeList children= root.childNodes();
  21448. QString replacementDoc;
  21449. QDomDocument includedDoc;
  21450. QDomDocumentFragment fragment;
  21451. for(int i= 0;i<children.size();i++)
  21452. {
  21453. QDomNode currentNode= children.at(i);
  21454. QDomElement currentElement;
  21455. if(currentNode.nodeName()=="include")
  21456. {
  21457. currentElement= currentNode.toElement();
  21458. if(currentElement.hasAttribute("src"))
  21459. {
  21460. replacementDoc= directory.path();
  21461. replacementDoc.append('/');
  21462. replacementDoc.append(currentElement.attribute("src"));
  21463. QFile doc(replacementDoc);
  21464. if(doc.open(QIODevice::ReadOnly))
  21465. {
  21466. includedDoc.setContent(&doc,true);
  21467. fragment= includedDoc.createDocumentFragment();
  21468. fragment.appendChild(includedDoc.documentElement());
  21469. root.replaceChild(fragment,currentNode);
  21470. doc.close();
  21471. }
  21472. }
  21473. }
  21474. }
  21475. /*:194*/
  21476. #line 4483 "./typica.w"
  21477. /*:193*/
  21478. #line 13676 "./typica.w"
  21479. /*7:*/
  21480. #line 666 "./typica.w"
  21481. QScriptEngine*engine= new QScriptEngine;
  21482. QScriptValue constructor;
  21483. QScriptValue value;
  21484. /*:7*//*17:*/
  21485. #line 874 "./typica.w"
  21486. constructor= engine->newFunction(constructQTimer);
  21487. value= engine->newQMetaObject(&QTimer::staticMetaObject,constructor);
  21488. engine->globalObject().setProperty("Timer",value);
  21489. /*:17*//*20:*/
  21490. #line 913 "./typica.w"
  21491. constructor= engine->newFunction(constructQWidget);
  21492. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  21493. engine->globalObject().setProperty("QWidget",value);
  21494. /*:20*//*24:*/
  21495. #line 1000 "./typica.w"
  21496. constructor= engine->newFunction(displayWarning);
  21497. engine->globalObject().setProperty("displayWarning",constructor);
  21498. constructor= engine->newFunction(displayError);
  21499. engine->globalObject().setProperty("displayError",constructor);
  21500. /*:24*//*34:*/
  21501. #line 1229 "./typica.w"
  21502. constructor= engine->newFunction(constructQMainWindow);
  21503. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  21504. constructor);
  21505. engine->globalObject().setProperty("QMainWindow",value);
  21506. /*:34*//*45:*/
  21507. #line 1434 "./typica.w"
  21508. constructor= engine->newFunction(constructQFrame);
  21509. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  21510. engine->globalObject().setProperty("QFrame",value);
  21511. /*:45*//*48:*/
  21512. #line 1467 "./typica.w"
  21513. constructor= engine->newFunction(constructQLabel);
  21514. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  21515. engine->globalObject().setProperty("QLabel",value);
  21516. /*:48*//*51:*/
  21517. #line 1510 "./typica.w"
  21518. constructor= engine->newFunction(constructQSvgWidget);
  21519. value= engine->newQMetaObject(&QSvgWidget::staticMetaObject,constructor);
  21520. engine->globalObject().setProperty("QSvgWidget",value);
  21521. /*:51*//*57:*/
  21522. #line 1592 "./typica.w"
  21523. constructor= engine->newFunction(constructQLineEdit);
  21524. value= engine->newQMetaObject(&QLineEdit::staticMetaObject,constructor);
  21525. engine->globalObject().setProperty("QLineEdit",value);
  21526. /*:57*//*61:*/
  21527. #line 1641 "./typica.w"
  21528. constructor= engine->newFunction(constructQSplitter);
  21529. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  21530. engine->globalObject().setProperty("QSplitter",value);
  21531. /*:61*//*70:*/
  21532. #line 1850 "./typica.w"
  21533. constructor= engine->newFunction(constructQBoxLayout);
  21534. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  21535. engine->globalObject().setProperty("QBoxLayout",value);
  21536. /*:70*//*74:*/
  21537. #line 1962 "./typica.w"
  21538. constructor= engine->newFunction(constructQAction);
  21539. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  21540. engine->globalObject().setProperty("QAction",value);
  21541. /*:74*//*77:*/
  21542. #line 2021 "./typica.w"
  21543. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  21544. value.setProperty("getOpenFileName",
  21545. engine->newFunction(QFileDialog_getOpenFileName));
  21546. value.setProperty("getSaveFileName",
  21547. engine->newFunction(QFileDialog_getSaveFileName));
  21548. engine->globalObject().setProperty("QFileDialog",value);
  21549. /*:77*//*82:*/
  21550. #line 2139 "./typica.w"
  21551. constructor= engine->newFunction(constructQFile);
  21552. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  21553. engine->globalObject().setProperty("QFile",value);
  21554. /*:82*//*93:*/
  21555. #line 2357 "./typica.w"
  21556. constructor= engine->newFunction(constructQProcess);
  21557. value= engine->newQMetaObject(&QProcess::staticMetaObject,constructor);
  21558. engine->globalObject().setProperty("QProcess",value);
  21559. /*:93*//*102:*/
  21560. #line 2506 "./typica.w"
  21561. qScriptRegisterMetaType(engine,QByteArray_toScriptValue,QByteArray_fromScriptValue);
  21562. constructor= engine->newFunction(constructQByteArray);
  21563. engine->globalObject().setProperty("QByteArray",constructor);
  21564. /*:102*//*114:*/
  21565. #line 2748 "./typica.w"
  21566. engine->globalObject().setProperty("bytesFromInt8",engine->newFunction(bytesFromInt8));
  21567. engine->globalObject().setProperty("bytesFromInt16",engine->newFunction(bytesFromInt16));
  21568. engine->globalObject().setProperty("bytesFromInt32",engine->newFunction(bytesFromInt32));
  21569. engine->globalObject().setProperty("bytesFromFloat",engine->newFunction(bytesFromFloat));
  21570. engine->globalObject().setProperty("bytesFromDouble",engine->newFunction(bytesFromDouble));
  21571. /*:114*//*117:*/
  21572. #line 2851 "./typica.w"
  21573. constructor= engine->newFunction(constructQBuffer);
  21574. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  21575. engine->globalObject().setProperty("QBuffer",value);
  21576. /*:117*//*120:*/
  21577. #line 2900 "./typica.w"
  21578. constructor= engine->newFunction(constructXQuery);
  21579. engine->globalObject().setProperty("XQuery",constructor);
  21580. /*:120*//*126:*/
  21581. #line 3002 "./typica.w"
  21582. constructor= engine->newFunction(constructXmlWriter);
  21583. engine->globalObject().setProperty("XmlWriter",constructor);
  21584. /*:126*//*135:*/
  21585. #line 3208 "./typica.w"
  21586. constructor= engine->newFunction(constructXmlReader);
  21587. engine->globalObject().setProperty("XmlReader",constructor);
  21588. /*:135*//*142:*/
  21589. #line 3332 "./typica.w"
  21590. value= engine->newQObject(&settings);
  21591. setQSettingsProperties(value,engine);
  21592. engine->globalObject().setProperty("QSettings",value);
  21593. /*:142*//*146:*/
  21594. #line 3413 "./typica.w"
  21595. constructor= engine->newFunction(constructQLCDNumber);
  21596. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  21597. engine->globalObject().setProperty("QLCDNumber",value);
  21598. /*:146*//*149:*/
  21599. #line 3469 "./typica.w"
  21600. constructor= engine->newFunction(constructQTime);
  21601. engine->globalObject().setProperty("QTime",constructor);
  21602. /*:149*//*171:*/
  21603. #line 3982 "./typica.w"
  21604. constructor= engine->newFunction(constructQPushButton);
  21605. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  21606. engine->globalObject().setProperty("QPushButton",value);
  21607. /*:171*//*178:*/
  21608. #line 4093 "./typica.w"
  21609. constructor= engine->newFunction(constructQSqlQuery);
  21610. engine->globalObject().setProperty("QSqlQuery",constructor);
  21611. /*:178*//*185:*/
  21612. #line 4257 "./typica.w"
  21613. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  21614. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  21615. engine->globalObject().setProperty("sqlToArray",
  21616. engine->newFunction(sqlToArray));
  21617. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  21618. engine->globalObject().setProperty("annotationFromRecord",
  21619. engine->newFunction(annotationFromRecord));
  21620. engine->globalObject().setProperty("setTabOrder",
  21621. engine->newFunction(setTabOrder));
  21622. engine->globalObject().setProperty("saveFileFromDatabase",
  21623. engine->newFunction(saveFileFromDatabase));
  21624. engine->globalObject().setProperty("TTR",engine->newFunction(scriptTr));
  21625. /*:185*//*198:*/
  21626. #line 4658 "./typica.w"
  21627. engine->globalObject().setProperty("createWindow",
  21628. engine->newFunction(createWindow));
  21629. engine->globalObject().setProperty("createReport",
  21630. engine->newFunction(createReport));
  21631. /*:198*//*223:*/
  21632. #line 5030 "./typica.w"
  21633. constructor= engine->newFunction(constructQTabBar);
  21634. value= engine->newQMetaObject(&QTabBar::staticMetaObject,constructor);
  21635. engine->globalObject().setProperty("QTabBar",value);
  21636. /*:223*//*272:*/
  21637. #line 6429 "./typica.w"
  21638. engine->globalObject().setProperty("findChildObject",
  21639. engine->newFunction(findChildObject));
  21640. /*:272*//*298:*/
  21641. #line 389 "./units.w"
  21642. value= engine->newQMetaObject(&Units::staticMetaObject);
  21643. value.setProperty("convertTemperature",engine->newFunction(Units_convertTemperature));
  21644. value.setProperty("convertRelativeTemperature",
  21645. engine->newFunction(Units_convertRelativeTemperature));
  21646. value.setProperty("isTemperatureUnit",engine->newFunction(Units_isTemperatureUnit));
  21647. value.setProperty("convertWeight",engine->newFunction(Units_convertWeight));
  21648. value.setProperty("isWeightUnit",engine->newFunction(Units_isWeightUnit));
  21649. engine->globalObject().setProperty("Units",value);
  21650. /*:298*//*303:*/
  21651. #line 462 "./units.w"
  21652. qScriptRegisterMetaType(engine,Unit_toScriptValue,Unit_fromScriptValue);
  21653. #line 6861 "./typica.w"
  21654. /*:303*//*311:*/
  21655. #line 141 "./measurement.w"
  21656. constructor= engine->newFunction(constructMeasurement);
  21657. engine->globalObject().setProperty("Measurement",constructor);
  21658. qScriptRegisterMetaType(engine,Measurement_toScriptValue,Measurement_fromScriptValue);
  21659. /*:311*//*331:*/
  21660. #line 7432 "./typica.w"
  21661. constructor= engine->newFunction(constructDAQ);
  21662. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  21663. value.setProperty("Fahrenheit",Units::Fahrenheit);
  21664. value.setProperty("Celsius",Units::Celsius);
  21665. value.setProperty("Kelvin",Units::Kelvin);
  21666. value.setProperty("Rankine",Units::Rankine);
  21667. engine->globalObject().setProperty("DAQ",value);
  21668. /*:331*//*340:*/
  21669. #line 7634 "./typica.w"
  21670. constructor= engine->newFunction(constructFakeDAQ);
  21671. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  21672. engine->globalObject().setProperty("FakeDAQ",value);
  21673. /*:340*//*351:*/
  21674. #line 7917 "./typica.w"
  21675. constructor= engine->newFunction(constructLinearCalibrator);
  21676. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  21677. constructor);
  21678. engine->globalObject().setProperty("LinearCalibrator",value);
  21679. /*:351*//*356:*/
  21680. #line 8056 "./typica.w"
  21681. constructor= engine->newFunction(constructLinearSplineInterpolator);
  21682. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  21683. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  21684. /*:356*//*366:*/
  21685. #line 8264 "./typica.w"
  21686. constructor= engine->newFunction(constructTemperatureDisplay);
  21687. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  21688. constructor);
  21689. engine->globalObject().setProperty("TemperatureDisplay",value);
  21690. /*:366*//*374:*/
  21691. #line 8422 "./typica.w"
  21692. constructor= engine->newFunction(constructMeasurementTimeOffset);
  21693. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  21694. constructor);
  21695. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  21696. /*:374*//*379:*/
  21697. #line 8543 "./typica.w"
  21698. constructor= engine->newFunction(constructThresholdDetector);
  21699. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  21700. engine->globalObject().setProperty("ThresholdDetector",value);
  21701. /*:379*//*384:*/
  21702. #line 8642 "./typica.w"
  21703. constructor= engine->newFunction(constructZeroEmitter);
  21704. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  21705. engine->globalObject().setProperty("ZeroEmitter",value);
  21706. /*:384*//*389:*/
  21707. #line 8721 "./typica.w"
  21708. constructor= engine->newFunction(constructMeasurementAdapter);
  21709. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  21710. constructor);
  21711. engine->globalObject().setProperty("MeasurementAdapter",value);
  21712. /*:389*//*406:*/
  21713. #line 9184 "./typica.w"
  21714. constructor= engine->newFunction(constructGraphView);
  21715. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  21716. engine->globalObject().setProperty("GraphView",value);
  21717. /*:406*//*429:*/
  21718. #line 9833 "./typica.w"
  21719. constructor= engine->newFunction(constructZoomLog);
  21720. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  21721. engine->globalObject().setProperty("ZoomLog",value);
  21722. /*:429*//*467:*/
  21723. #line 10781 "./typica.w"
  21724. constructor= engine->newFunction(constructAnnotationButton);
  21725. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  21726. constructor);
  21727. engine->globalObject().setProperty("AnnotationButton",value);
  21728. /*:467*//*475:*/
  21729. #line 10923 "./typica.w"
  21730. constructor= engine->newFunction(constructAnnotationSpinBox);
  21731. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  21732. constructor);
  21733. engine->globalObject().setProperty("AnnotationSpinBox",value);
  21734. /*:475*//*496:*/
  21735. #line 11348 "./typica.w"
  21736. constructor= engine->newFunction(constructTimerDisplay);
  21737. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  21738. engine->globalObject().setProperty("TimerDisplay",value);
  21739. /*:496*//*524:*/
  21740. #line 11872 "./typica.w"
  21741. constructor= engine->newFunction(constructWidgetDecorator);
  21742. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  21743. engine->globalObject().setProperty("WidgetDecorator",value);
  21744. /*:524*//*537:*/
  21745. #line 12154 "./typica.w"
  21746. constructor= engine->newFunction(constructLogEditWindow);
  21747. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  21748. engine->globalObject().setProperty("LogEditWindow",value);
  21749. /*:537*//*556:*/
  21750. #line 12681 "./typica.w"
  21751. constructor= engine->newFunction(constructXMLInput);
  21752. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  21753. engine->globalObject().setProperty("XMLInput",value);
  21754. /*:556*//*571:*/
  21755. #line 164 "./webview.w"
  21756. constructor= engine->newFunction(constructWebView);
  21757. value= engine->newQMetaObject(&TypicaWebView::staticMetaObject,constructor);
  21758. engine->globalObject().setProperty("WebView",value);
  21759. /*:571*//*579:*/
  21760. #line 256 "./webview.w"
  21761. qScriptRegisterMetaType(engine,QWebElement_toScriptValue,QWebElement_fromScriptValue);
  21762. /*:579*//*582:*/
  21763. #line 298 "./webview.w"
  21764. constructor= engine->newFunction(constructWebElement);
  21765. engine->globalObject().setProperty("WebElement",constructor);
  21766. /*:582*//*594:*/
  21767. #line 76 "./printerselector.w"
  21768. constructor= engine->newFunction(constructPrinterSelector);
  21769. engine->globalObject().setProperty("PrinterSelector",constructor);
  21770. /*:594*//*602:*/
  21771. #line 12937 "./typica.w"
  21772. value= engine->newQObject(AppInstance);
  21773. engine->globalObject().setProperty("Application",value);
  21774. /*:602*//*661:*/
  21775. #line 14067 "./typica.w"
  21776. constructor= engine->newFunction(constructSqlQueryView);
  21777. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  21778. engine->globalObject().setProperty("SqlQueryView",value);
  21779. /*:661*//*772:*/
  21780. #line 15973 "./typica.w"
  21781. constructor= engine->newFunction(constructDeviceTreeModel);
  21782. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  21783. constructor);
  21784. engine->globalObject().setProperty("DeviceTreeModel",value);
  21785. /*:772*//*778:*/
  21786. #line 16113 "./typica.w"
  21787. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  21788. /*:778*//*794:*/
  21789. #line 16405 "./typica.w"
  21790. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  21791. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  21792. constructor);
  21793. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  21794. /*:794*//*865:*/
  21795. #line 56 "./settings.w"
  21796. constructor= engine->newFunction(constructSettingsWindow);
  21797. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,constructor);
  21798. engine->globalObject().setProperty("SettingsWindow",value);
  21799. #line 1 "./graphsettings.w"
  21800. /*:865*//*888:*/
  21801. #line 19040 "./typica.w"
  21802. constructor= engine->newFunction(constructModbusRTUDevice);
  21803. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  21804. engine->globalObject().setProperty("ModbusRTUDevice",value);
  21805. /*:888*//*906:*/
  21806. #line 705 "./modbus.w"
  21807. constructor= engine->newFunction(constructModbusNG);
  21808. value= engine->newQMetaObject(&ModbusNG::staticMetaObject,constructor);
  21809. engine->globalObject().setProperty("ModbusNG",value);
  21810. /*:906*//*920:*/
  21811. #line 350 "./unsupportedserial.w"
  21812. engine->globalObject().setProperty("createDevice",
  21813. engine->newFunction(createDevice));
  21814. /*:920*//*932:*/
  21815. #line 622 "./unsupportedserial.w"
  21816. engine->globalObject().setProperty("getMeasurementTimestamp",
  21817. engine->newFunction(getMeasurementTimestamp));
  21818. /*:932*//*936:*/
  21819. #line 658 "./unsupportedserial.w"
  21820. constructor= engine->newFunction(constructSerialPort);
  21821. value= engine->newQMetaObject(&QextSerialPort::staticMetaObject,constructor);
  21822. engine->globalObject().setProperty("SerialPort",value);
  21823. /*:936*//*958:*/
  21824. #line 450 "./phidgets.w"
  21825. constructor= engine->newFunction(constructPhidgetsTemperatureSensor);
  21826. value= engine->newQMetaObject(&PhidgetsTemperatureSensor::staticMetaObject,constructor);
  21827. engine->globalObject().setProperty("PhidgetsTemperatureSensor",value);
  21828. /*:958*//*990:*/
  21829. #line 798 "./phidget22.w"
  21830. constructor= engine->newFunction(constructPhidget22);
  21831. value= engine->newQMetaObject(&Phidget22::staticMetaObject,constructor);
  21832. engine->globalObject().setProperty("Phidget22",value);
  21833. /*:990*//*1024:*/
  21834. #line 144 "./rate.w"
  21835. constructor= engine->newFunction(constructRateOfChange);
  21836. value= engine->newQMetaObject(&RateOfChange::staticMetaObject,constructor);
  21837. engine->globalObject().setProperty("RateOfChange",value);
  21838. /*:1024*//*1038:*/
  21839. #line 137 "./mergeseries.w"
  21840. constructor= engine->newFunction(constructDifferenceSeries);
  21841. value= engine->newQMetaObject(&DifferenceSeries::staticMetaObject,
  21842. constructor);
  21843. engine->globalObject().setProperty("DifferenceSeries",value);
  21844. constructor= engine->newFunction(constructMeanSeries);
  21845. value= engine->newQMetaObject(&MeanSeries::staticMetaObject,constructor);
  21846. engine->globalObject().setProperty("MeanSeries",value);
  21847. /*:1038*//*1063:*/
  21848. #line 604 "./dataqsdk.w"
  21849. constructor= engine->newFunction(constructDataqSdkDevice);
  21850. value= engine->newQMetaObject(&DataqSdkDevice::staticMetaObject,constructor);
  21851. engine->globalObject().setProperty("DataqSdkDevice",value);
  21852. /*:1063*//*1090:*/
  21853. #line 73 "./scales.w"
  21854. constructor= engine->newFunction(constructDragLabel);
  21855. value= engine->newQMetaObject(&DragLabel::staticMetaObject,constructor);
  21856. engine->globalObject().setProperty("DragLabel",value);
  21857. /*:1090*//*1098:*/
  21858. #line 265 "./scales.w"
  21859. constructor= engine->newFunction(constructSerialScale);
  21860. value= engine->newQMetaObject(&SerialScale::staticMetaObject,constructor);
  21861. engine->globalObject().setProperty("SerialScale",value);
  21862. /*:1098*//*1102:*/
  21863. #line 351 "./scales.w"
  21864. qScriptRegisterMetaType(engine,BaudRateType_toScriptValue,BaudRateType_fromScriptValue);
  21865. qScriptRegisterMetaType(engine,DataBitsType_toScriptValue,DataBitsType_fromScriptValue);
  21866. qScriptRegisterMetaType(engine,ParityType_toScriptValue,ParityType_fromScriptValue);
  21867. qScriptRegisterMetaType(engine,StopBitsType_toScriptValue,StopBitsType_fromScriptValue);
  21868. qScriptRegisterMetaType(engine,FlowType_toScriptValue,FlowType_fromScriptValue);
  21869. /*:1102*//*1126:*/
  21870. #line 271 "./valueannotation.w"
  21871. constructor= engine->newFunction(constructValueAnnotation);
  21872. value= engine->newQMetaObject(&ValueAnnotation::staticMetaObject,constructor);
  21873. engine->globalObject().setProperty("ValueAnnotation",value);
  21874. /*:1126*//*1137:*/
  21875. #line 201 "./thresholdannotation.w"
  21876. constructor= engine->newFunction(constructAnnotator);
  21877. value= engine->newQMetaObject(&Annotator::staticMetaObject,constructor);
  21878. engine->globalObject().setProperty("Annotator",value);
  21879. /*:1137*//*1147:*/
  21880. #line 135 "./user.w"
  21881. constructor= engine->newFunction(constructLoginDialog);
  21882. value= engine->newQMetaObject(&LoginDialog::staticMetaObject,constructor);
  21883. engine->globalObject().setProperty("LoginDialog",value);
  21884. /*:1147*//*1157:*/
  21885. #line 323 "./user.w"
  21886. constructor= engine->newFunction(constructNewTypicaUser);
  21887. value= engine->newQMetaObject(&NewTypicaUser::staticMetaObject,constructor);
  21888. engine->globalObject().setProperty("NewTypicaUser",value);
  21889. /*:1157*/
  21890. #line 13677 "./typica.w"
  21891. app.engine= engine;
  21892. /*195:*/
  21893. #line 4537 "./typica.w"
  21894. QString styleText;
  21895. QString programText;
  21896. QDomElement currentElement;
  21897. for(int i= 0;i<children.size();i++)
  21898. {
  21899. QDomNode currentNode= children.at(i);
  21900. if(currentNode.nodeName()=="style")
  21901. {
  21902. currentElement= currentNode.toElement();
  21903. styleText.append(currentElement.text());
  21904. }
  21905. else if(currentNode.nodeName()=="program")
  21906. {
  21907. currentElement= currentNode.toElement();
  21908. programText.append(currentElement.text());
  21909. }
  21910. }
  21911. app.setStyleSheet(styleText);
  21912. QScriptValue result= engine->evaluate(programText);
  21913. /*196:*/
  21914. #line 4562 "./typica.w"
  21915. if(engine->hasUncaughtException())
  21916. {
  21917. int line= engine->uncaughtExceptionLineNumber();
  21918. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  21919. result.toString();
  21920. QString trace;
  21921. foreach(trace,engine->uncaughtExceptionBacktrace())
  21922. {
  21923. qDebug()<<trace;
  21924. }
  21925. }
  21926. /*:196*/
  21927. #line 4557 "./typica.w"
  21928. /*:195*/
  21929. #line 13679 "./typica.w"
  21930. int retval= app.exec();
  21931. delete engine;
  21932. return retval;
  21933. }
  21934. /*:638*/
  21935. #line 535 "./typica.w"
  21936. #include "moc_typica.cpp"
  21937. /*:3*/